• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Main file for NULL named library for Profile1 shell command functions.
3 
4   Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
5   This program and the accompanying materials
6   are licensed and made available under the terms and conditions of the BSD License
7   which accompanies this distribution.  The full text of the license may be found at
8   http://opensource.org/licenses/bsd-license.php
9 
10   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #ifndef _UEFI_SHELL_DEBUG1_COMMANDS_LIB_H_
16 #define _UEFI_SHELL_DEBUG1_COMMANDS_LIB_H_
17 
18 #include <Uefi.h>
19 
20 #include <Guid/GlobalVariable.h>
21 #include <Guid/ConsoleInDevice.h>
22 #include <Guid/ConsoleOutDevice.h>
23 #include <Guid/FileSystemInfo.h>
24 #include <Guid/ShellLibHiiGuid.h>
25 
26 #include <Protocol/Shell.h>
27 #include <Protocol/ShellParameters.h>
28 #include <Protocol/DevicePath.h>
29 #include <Protocol/LoadedImage.h>
30 #include <Protocol/UnicodeCollation.h>
31 #include <Protocol/DriverDiagnostics2.h>
32 #include <Protocol/DriverDiagnostics.h>
33 #include <Protocol/PlatformDriverOverride.h>
34 #include <Protocol/BusSpecificDriverOverride.h>
35 #include <Protocol/PlatformToDriverConfiguration.h>
36 #include <Protocol/DriverSupportedEfiVersion.h>
37 #include <Protocol/DriverFamilyOverride.h>
38 #include <Protocol/DriverHealth.h>
39 #include <Protocol/SimplePointer.h>
40 #include <Protocol/CpuIo2.h>
41 #include <Protocol/PciRootBridgeIo.h>
42 
43 #include <Library/BaseLib.h>
44 #include <Library/BaseMemoryLib.h>
45 #include <Library/DebugLib.h>
46 #include <Library/MemoryAllocationLib.h>
47 #include <Library/PcdLib.h>
48 #include <Library/ShellCommandLib.h>
49 #include <Library/ShellLib.h>
50 #include <Library/SortLib.h>
51 #include <Library/UefiLib.h>
52 #include <Library/UefiRuntimeServicesTableLib.h>
53 #include <Library/UefiBootServicesTableLib.h>
54 #include <Library/HiiLib.h>
55 #include <Library/FileHandleLib.h>
56 #include <Library/DevicePathLib.h>
57 #include <Library/PrintLib.h>
58 #include <Library/HandleParsingLib.h>
59 
60 
61 extern        EFI_HANDLE                        gShellDebug1HiiHandle;
62 
63 /**
64   Function returns a system configuration table that is stored in the
65   EFI System Table based on the provided GUID.
66 
67   @param[in]   TableGuid    A pointer to the table's GUID type.
68   @param[in, out] Table     On exit, a pointer to a system configuration table.
69 
70   @retval EFI_SUCCESS      A configuration table matching TableGuid was found.
71   @retval EFI_NOT_FOUND    A configuration table matching TableGuid was not found.
72 **/
73 EFI_STATUS
74 GetSystemConfigurationTable (
75   IN EFI_GUID *TableGuid,
76   IN OUT VOID **Table
77   );
78 
79 /**
80   Convert a string representation of a GUID to the GUID value.
81 
82   @param[in]  StringGuid   The pointer to the string containing a GUID printed.
83   @param[in, out] Guid     The pointer to the buffer to get the GUID value.
84 **/
85 EFI_STATUS
86 ConvertStringToGuid (
87   IN CONST CHAR16 *StringGuid,
88   IN OUT EFI_GUID *Guid
89   );
90 
91 /**
92   Convert a Unicode character to numerical value.
93 
94   This internal function only deal with Unicode character
95   which maps to a valid hexadecimal ASII character, i.e.
96   L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other
97   Unicode character, the value returned does not make sense.
98 
99   @param  Char  The character to convert.
100 
101   @return The numerical value converted.
102 
103 **/
104 UINTN
105 HexCharToUintn (
106   IN      CHAR16                    Char
107   );
108 
109 /**
110   Function for 'setsize' command.
111 
112   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
113   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
114 **/
115 SHELL_STATUS
116 EFIAPI
117 ShellCommandRunSetSize (
118   IN EFI_HANDLE        ImageHandle,
119   IN EFI_SYSTEM_TABLE  *SystemTable
120   );
121 
122 /**
123   Function for 'comp' command.
124 
125   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
126   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
127 **/
128 SHELL_STATUS
129 EFIAPI
130 ShellCommandRunComp (
131   IN EFI_HANDLE        ImageHandle,
132   IN EFI_SYSTEM_TABLE  *SystemTable
133   );
134 
135 /**
136   Function for 'mode' command.
137 
138   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
139   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
140 **/
141 SHELL_STATUS
142 EFIAPI
143 ShellCommandRunMode (
144   IN EFI_HANDLE        ImageHandle,
145   IN EFI_SYSTEM_TABLE  *SystemTable
146   );
147 
148 /**
149   Function for 'memmap' command.
150 
151   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
152   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
153 **/
154 SHELL_STATUS
155 EFIAPI
156 ShellCommandRunMemMap (
157   IN EFI_HANDLE        ImageHandle,
158   IN EFI_SYSTEM_TABLE  *SystemTable
159   );
160 
161 /**
162   Function for 'compress' command.
163 
164   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
165   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
166 **/
167 SHELL_STATUS
168 EFIAPI
169 ShellCommandRunEfiCompress (
170   IN EFI_HANDLE        ImageHandle,
171   IN EFI_SYSTEM_TABLE  *SystemTable
172   );
173 
174 /**
175   Function for 'decompress' command.
176 
177   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
178   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
179 **/
180 SHELL_STATUS
181 EFIAPI
182 ShellCommandRunEfiDecompress (
183   IN EFI_HANDLE        ImageHandle,
184   IN EFI_SYSTEM_TABLE  *SystemTable
185   );
186 
187 /**
188   Function for 'dmem' command.
189 
190   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
191   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
192 **/
193 SHELL_STATUS
194 EFIAPI
195 ShellCommandRunDmem (
196   IN EFI_HANDLE        ImageHandle,
197   IN EFI_SYSTEM_TABLE  *SystemTable
198   );
199 
200 /**
201   Function for 'loadpcirom' command.
202 
203   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
204   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
205 **/
206 SHELL_STATUS
207 EFIAPI
208 ShellCommandRunLoadPciRom (
209   IN EFI_HANDLE        ImageHandle,
210   IN EFI_SYSTEM_TABLE  *SystemTable
211   );
212 
213 /**
214   Function for 'mm' command.
215 
216   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
217   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
218 **/
219 SHELL_STATUS
220 EFIAPI
221 ShellCommandRunMm (
222   IN EFI_HANDLE        ImageHandle,
223   IN EFI_SYSTEM_TABLE  *SystemTable
224   );
225 
226 /**
227   Function for 'setvar' command.
228 
229   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
230   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
231 **/
232 SHELL_STATUS
233 EFIAPI
234 ShellCommandRunSetVar (
235   IN EFI_HANDLE        ImageHandle,
236   IN EFI_SYSTEM_TABLE  *SystemTable
237   );
238 
239 /**
240   Function for 'sermode' command.
241 
242   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
243   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
244 **/
245 SHELL_STATUS
246 EFIAPI
247 ShellCommandRunSerMode (
248   IN EFI_HANDLE        ImageHandle,
249   IN EFI_SYSTEM_TABLE  *SystemTable
250   );
251 
252 /**
253   Function for 'bcfg' command.
254 
255   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
256   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
257 **/
258 SHELL_STATUS
259 EFIAPI
260 ShellCommandRunBcfg (
261   IN EFI_HANDLE        ImageHandle,
262   IN EFI_SYSTEM_TABLE  *SystemTable
263   );
264 
265 /**
266   Function for 'pci' command.
267 
268   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
269   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
270 **/
271 SHELL_STATUS
272 EFIAPI
273 ShellCommandRunPci (
274   IN EFI_HANDLE        ImageHandle,
275   IN EFI_SYSTEM_TABLE  *SystemTable
276   );
277 
278 /**
279   Function for 'smbiosview' command.
280 
281   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
282   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
283 **/
284 SHELL_STATUS
285 EFIAPI
286 ShellCommandRunSmbiosView (
287   IN EFI_HANDLE        ImageHandle,
288   IN EFI_SYSTEM_TABLE  *SystemTable
289   );
290 
291 /**
292   Function for 'dmpstore' command.
293 
294   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
295   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
296 **/
297 SHELL_STATUS
298 EFIAPI
299 ShellCommandRunDmpStore (
300   IN EFI_HANDLE        ImageHandle,
301   IN EFI_SYSTEM_TABLE  *SystemTable
302   );
303 
304 /**
305   Function for 'dblk' command.
306 
307   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
308   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
309 **/
310 SHELL_STATUS
311 EFIAPI
312 ShellCommandRunDblk (
313   IN EFI_HANDLE        ImageHandle,
314   IN EFI_SYSTEM_TABLE  *SystemTable
315   );
316 
317 /**
318   Function for 'edit' command.
319 
320   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
321   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
322 **/
323 SHELL_STATUS
324 EFIAPI
325 ShellCommandRunEdit (
326   IN EFI_HANDLE        ImageHandle,
327   IN EFI_SYSTEM_TABLE  *SystemTable
328   );
329 
330 /**
331   Function for 'hexedit' command.
332 
333   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
334   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
335 **/
336 SHELL_STATUS
337 EFIAPI
338 ShellCommandRunHexEdit (
339   IN EFI_HANDLE        ImageHandle,
340   IN EFI_SYSTEM_TABLE  *SystemTable
341   );
342 
343 /**
344   Clear the line at the specified Row.
345 
346   @param[in] Row                The row number to be cleared ( start from 1 )
347   @param[in] LastCol            The last printable column.
348   @param[in] LastRow            The last printable row.
349 **/
350 VOID
351 EditorClearLine (
352   IN UINTN Row,
353   IN UINTN LastCol,
354   IN UINTN LastRow
355   );
356 
357 /**
358   Check if file name has illegal characters.
359 
360   @param Name       The filename to check.
361 
362   @retval TRUE      The filename is ok.
363   @retval FALSE     The filename is not ok.
364 **/
365 BOOLEAN
366 IsValidFileName (
367   IN CONST CHAR16 *Name
368   );
369 
370 /**
371   Find a filename that is valid (not taken) with the given extension.
372 
373   @param[in] Extension      The file extension.
374 
375   @retval NULL  Something went wrong.
376   @return the valid filename.
377 **/
378 CHAR16 *
379 EditGetDefaultFileName (
380   IN CONST CHAR16 *Extension
381   );
382 
383 /**
384   Read a file into an allocated buffer.  The buffer is the responsibility
385   of the caller to free.
386 
387   @param[in]  FileName          The filename of the file to open.
388   @param[out] Buffer            Upon successful return, the pointer to the
389                                 address of the allocated buffer.
390   @param[out] BufferSize        If not NULL, then the pointer to the size
391                                 of the allocated buffer.
392   @param[out] ReadOnly          Upon successful return TRUE if the file is
393                                 read only.  FALSE otherwise.
394 
395   @retval EFI_NOT_FOUND         The filename did not represent a file in the
396                                 file system.  Directories cannot be read with
397                                 this method.
398   @retval EFI_SUCCESS           The file was read into the buffer.
399   @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.
400   @retval EFI_LOAD_ERROR        The file read operation failed.
401   @retval EFI_INVALID_PARAMETER A parameter was invalid.
402   @retval EFI_INVALID_PARAMETER FileName was NULL.
403   @retval EFI_INVALID_PARAMETER FileName was a directory.
404 **/
405 EFI_STATUS
406 ReadFileIntoBuffer (
407   IN CONST CHAR16 *FileName,
408   OUT VOID        **Buffer,
409   OUT UINTN       *BufferSize OPTIONAL,
410   OUT BOOLEAN     *ReadOnly
411   );
412 
413 #endif
414