]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h
pointer verification (not NULL) and buffer overrun fixes.
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / UefiShellDebug1CommandsLib.h
1 /** @file
2 Main file for NULL named library for Profile1 shell command functions.
3
4 Copyright (c) 2010 - 2011, 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 #if !defined (_UEFI_SHELL_DEBUG1_COMMANDS_LIB_H_)
16 #define _UEFI_SHELL_DEBUG1_COMMANDS_LIB_H_
17
18 #include <Uefi.h>
19 #include <ShellBase.h>
20
21 #include <Guid/GlobalVariable.h>
22 #include <Guid/ConsoleInDevice.h>
23 #include <Guid/ConsoleOutDevice.h>
24 #include <Guid/FileSystemInfo.h>
25
26 #include <Protocol/EfiShell.h>
27 #include <Protocol/EfiShellParameters.h>
28 #include <Protocol/DevicePath.h>
29 #include <Protocol/LoadedImage.h>
30 #include <Protocol/UnicodeCollation.h>
31 #include <Protocol/DevicePathToText.h>
32 #include <Protocol/DriverDiagnostics2.h>
33 #include <Protocol/DriverDiagnostics.h>
34 #include <Protocol/PlatformDriverOverride.h>
35 #include <Protocol/BusSpecificDriverOverride.h>
36 #include <Protocol/PlatformToDriverConfiguration.h>
37 #include <Protocol/DriverSupportedEfiVersion.h>
38 #include <Protocol/DriverFamilyOverride.h>
39 #include <Protocol/DriverHealth.h>
40 #include <Protocol/DevicePathFromText.h>
41 #include <Protocol/SimplePointer.h>
42 #include <Protocol/PciRootBridgeIo.h>
43
44 #include <Library/BaseLib.h>
45 #include <Library/BaseMemoryLib.h>
46 #include <Library/DebugLib.h>
47 #include <Library/MemoryAllocationLib.h>
48 #include <Library/PcdLib.h>
49 #include <Library/ShellCommandLib.h>
50 #include <Library/ShellLib.h>
51 #include <Library/SortLib.h>
52 #include <Library/UefiLib.h>
53 #include <Library/UefiRuntimeServicesTableLib.h>
54 #include <Library/UefiBootServicesTableLib.h>
55 #include <Library/HiiLib.h>
56 #include <Library/FileHandleLib.h>
57 #include <Library/DevicePathLib.h>
58 #include <Library/PrintLib.h>
59 #include <Library/HandleParsingLib.h>
60
61
62 extern EFI_HANDLE gShellDebug1HiiHandle;
63 extern CONST EFI_GUID gShellDebug1HiiGuid;
64
65 /**
66 Function printing hex output to the console.
67
68 @param[in] Indent Number of spaces to indent.
69 @param[in] Offset Offset to start with.
70 @param[in] DataSize Length of data.
71 @param[in] UserData Pointer to some data.
72 **/
73 VOID
74 DumpHex (
75 IN UINTN Indent,
76 IN UINTN Offset,
77 IN UINTN DataSize,
78 IN VOID *UserData
79 );
80
81 /**
82 Function returns a system configuration table that is stored in the
83 EFI System Table based on the provided GUID.
84
85 @param[in] TableGuid A pointer to the table's GUID type.
86 @param[in,out] Table On exit, a pointer to a system configuration table.
87
88 @retval EFI_SUCCESS A configuration table matching TableGuid was found.
89 @retval EFI_NOT_FOUND A configuration table matching TableGuid was not found.
90 **/
91 EFI_STATUS
92 EFIAPI
93 GetSystemConfigurationTable (
94 IN EFI_GUID *TableGuid,
95 IN OUT VOID **Table
96 );
97
98 /**
99 Convert a string representation of a GUID to the GUID value.
100
101 @param[in] StringGuid The pointer to the string containing a GUID printed.
102 @param[in,out] Guid The pointer to the buffer to get the GUID value.
103 **/
104 EFI_STATUS
105 EFIAPI
106 ConvertStringToGuid (
107 IN CONST CHAR16 *StringGuid,
108 IN OUT EFI_GUID *Guid
109 );
110
111 /**
112 Convert a Unicode character to numerical value.
113
114 This internal function only deal with Unicode character
115 which maps to a valid hexadecimal ASII character, i.e.
116 L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other
117 Unicode character, the value returned does not make sense.
118
119 @param Char The character to convert.
120
121 @return The numerical value converted.
122
123 **/
124 UINTN
125 EFIAPI
126 HexCharToUintn (
127 IN CHAR16 Char
128 );
129
130 /**
131 Function for 'setsize' command.
132
133 @param[in] ImageHandle Handle to the Image (NULL if Internal).
134 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
135 **/
136 SHELL_STATUS
137 EFIAPI
138 ShellCommandRunSetSize (
139 IN EFI_HANDLE ImageHandle,
140 IN EFI_SYSTEM_TABLE *SystemTable
141 );
142
143 /**
144 Function for 'comp' command.
145
146 @param[in] ImageHandle Handle to the Image (NULL if Internal).
147 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
148 **/
149 SHELL_STATUS
150 EFIAPI
151 ShellCommandRunComp (
152 IN EFI_HANDLE ImageHandle,
153 IN EFI_SYSTEM_TABLE *SystemTable
154 );
155
156 /**
157 Function for 'mode' command.
158
159 @param[in] ImageHandle Handle to the Image (NULL if Internal).
160 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
161 **/
162 SHELL_STATUS
163 EFIAPI
164 ShellCommandRunMode (
165 IN EFI_HANDLE ImageHandle,
166 IN EFI_SYSTEM_TABLE *SystemTable
167 );
168
169 /**
170 Function for 'memmap' command.
171
172 @param[in] ImageHandle Handle to the Image (NULL if Internal).
173 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
174 **/
175 SHELL_STATUS
176 EFIAPI
177 ShellCommandRunMemMap (
178 IN EFI_HANDLE ImageHandle,
179 IN EFI_SYSTEM_TABLE *SystemTable
180 );
181
182 /**
183 Function for 'compress' command.
184
185 @param[in] ImageHandle Handle to the Image (NULL if Internal).
186 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
187 **/
188 SHELL_STATUS
189 EFIAPI
190 ShellCommandRunEfiCompress (
191 IN EFI_HANDLE ImageHandle,
192 IN EFI_SYSTEM_TABLE *SystemTable
193 );
194
195 /**
196 Function for 'decompress' command.
197
198 @param[in] ImageHandle Handle to the Image (NULL if Internal).
199 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
200 **/
201 SHELL_STATUS
202 EFIAPI
203 ShellCommandRunEfiDecompress (
204 IN EFI_HANDLE ImageHandle,
205 IN EFI_SYSTEM_TABLE *SystemTable
206 );
207
208 /**
209 Function for 'dmem' command.
210
211 @param[in] ImageHandle Handle to the Image (NULL if Internal).
212 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
213 **/
214 SHELL_STATUS
215 EFIAPI
216 ShellCommandRunDmem (
217 IN EFI_HANDLE ImageHandle,
218 IN EFI_SYSTEM_TABLE *SystemTable
219 );
220
221 /**
222 Function for 'loadpcirom' command.
223
224 @param[in] ImageHandle Handle to the Image (NULL if Internal).
225 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
226 **/
227 SHELL_STATUS
228 EFIAPI
229 ShellCommandRunLoadPciRom (
230 IN EFI_HANDLE ImageHandle,
231 IN EFI_SYSTEM_TABLE *SystemTable
232 );
233
234 /**
235 Function for 'mm' command.
236
237 @param[in] ImageHandle Handle to the Image (NULL if Internal).
238 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
239 **/
240 SHELL_STATUS
241 EFIAPI
242 ShellCommandRunMm (
243 IN EFI_HANDLE ImageHandle,
244 IN EFI_SYSTEM_TABLE *SystemTable
245 );
246
247 /**
248 Function for 'setvar' command.
249
250 @param[in] ImageHandle Handle to the Image (NULL if Internal).
251 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
252 **/
253 SHELL_STATUS
254 EFIAPI
255 ShellCommandRunSetVar (
256 IN EFI_HANDLE ImageHandle,
257 IN EFI_SYSTEM_TABLE *SystemTable
258 );
259
260 /**
261 Function for 'sermode' command.
262
263 @param[in] ImageHandle Handle to the Image (NULL if Internal).
264 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
265 **/
266 SHELL_STATUS
267 EFIAPI
268 ShellCommandRunSerMode (
269 IN EFI_HANDLE ImageHandle,
270 IN EFI_SYSTEM_TABLE *SystemTable
271 );
272
273 /**
274 Function for 'bcfg' command.
275
276 @param[in] ImageHandle Handle to the Image (NULL if Internal).
277 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
278 **/
279 SHELL_STATUS
280 EFIAPI
281 ShellCommandRunBcfg (
282 IN EFI_HANDLE ImageHandle,
283 IN EFI_SYSTEM_TABLE *SystemTable
284 );
285
286 /**
287 Function for 'pci' command.
288
289 @param[in] ImageHandle Handle to the Image (NULL if Internal).
290 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
291 **/
292 SHELL_STATUS
293 EFIAPI
294 ShellCommandRunPci (
295 IN EFI_HANDLE ImageHandle,
296 IN EFI_SYSTEM_TABLE *SystemTable
297 );
298
299 /**
300 Function for 'smbiosview' command.
301
302 @param[in] ImageHandle Handle to the Image (NULL if Internal).
303 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
304 **/
305 SHELL_STATUS
306 EFIAPI
307 ShellCommandRunSmbiosView (
308 IN EFI_HANDLE ImageHandle,
309 IN EFI_SYSTEM_TABLE *SystemTable
310 );
311
312 /**
313 Function for 'dmpstore' command.
314
315 @param[in] ImageHandle Handle to the Image (NULL if Internal).
316 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
317 **/
318 SHELL_STATUS
319 EFIAPI
320 ShellCommandRunDmpStore (
321 IN EFI_HANDLE ImageHandle,
322 IN EFI_SYSTEM_TABLE *SystemTable
323 );
324
325 /**
326 Function for 'dblk' command.
327
328 @param[in] ImageHandle Handle to the Image (NULL if Internal).
329 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
330 **/
331 SHELL_STATUS
332 EFIAPI
333 ShellCommandRunDblk (
334 IN EFI_HANDLE ImageHandle,
335 IN EFI_SYSTEM_TABLE *SystemTable
336 );
337
338 /**
339 Function for 'edit' command.
340
341 @param[in] ImageHandle Handle to the Image (NULL if Internal).
342 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
343 **/
344 SHELL_STATUS
345 EFIAPI
346 ShellCommandRunEdit (
347 IN EFI_HANDLE ImageHandle,
348 IN EFI_SYSTEM_TABLE *SystemTable
349 );
350
351 /**
352 Function for 'hexedit' command.
353
354 @param[in] ImageHandle Handle to the Image (NULL if Internal).
355 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
356 **/
357 SHELL_STATUS
358 EFIAPI
359 ShellCommandRunHexEdit (
360 IN EFI_HANDLE ImageHandle,
361 IN EFI_SYSTEM_TABLE *SystemTable
362 );
363
364 /**
365 Appends a formatted Unicode string to a Null-terminated Unicode string
366
367 This function appends a formatted Unicode string to the Null-terminated
368 Unicode string specified by String. String is optional and may be NULL.
369 Storage for the formatted Unicode string returned is allocated using
370 AllocateZeroPool(). The pointer to the appended string is returned. The caller
371 is responsible for freeing the returned string.
372
373 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().
374 If Format is NULL, then ASSERT().
375 If Format is not aligned on a 16-bit boundary, then ASSERT().
376
377 @param String A null-terminated Unicode string.
378 @param FormatString A null-terminated Unicode format string.
379 @param ... The variable argument list whose contents are accessed based
380 on the format string specified by Format.
381
382 @retval NULL There was not enough available memory.
383 @return Null terminated Unicode string is that is the formatted
384 string appended to String.
385 @sa CatVSPrint
386 **/
387 CHAR16*
388 EFIAPI
389 CatSPrint (
390 IN CONST CHAR16 *String OPTIONAL,
391 IN CONST CHAR16 *FormatString,
392 ...
393 );
394
395 /**
396 Clear the line at the specified Row.
397
398 @param[in] Row The row number to be cleared ( start from 1 )
399 @param[in] LastCol The last printable column.
400 @param[in] LastRow The last printable row.
401 **/
402 VOID
403 EFIAPI
404 EditorClearLine (
405 IN UINTN Row,
406 IN UINTN LastCol,
407 IN UINTN LastRow
408 );
409
410 /**
411 Check if file name has illegal characters.
412
413 @param Name The filename to check.
414
415 @retval TRUE The filename is ok.
416 @retval FALSE The filename is not ok.
417 **/
418 BOOLEAN
419 EFIAPI
420 IsValidFileName (
421 IN CONST CHAR16 *Name
422 );
423
424 /**
425 Find a filename that is valid (not taken) with the given extension.
426
427 @param[in] Extension The file extension.
428
429 @retval NULL Something went wrong.
430 @return the valid filename.
431 **/
432 CHAR16 *
433 EFIAPI
434 EditGetDefaultFileName (
435 IN CONST CHAR16 *Extension
436 );
437
438 /**
439 Read a file into an allocated buffer. The buffer is the responsibility
440 of the caller to free.
441
442 @param[in] FileName The filename of the file to open.
443 @param[out] Buffer Upon successful return, the pointer to the
444 address of the allocated buffer.
445 @param[out] BufferSize If not NULL, then the pointer to the size
446 of the allocated buffer.
447 @param[out] ReadOnly Upon successful return TRUE if the file is
448 read only. FALSE otherwise.
449
450 @retval EFI_NOT_FOUND The filename did not represent a file in the
451 file system. Directories cannot be read with
452 this method.
453 @retval EFI_SUCCESS The file was read into the buffer.
454 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
455 @retval EFI_LOAD_ERROR The file read operation failed.
456 @retval EFI_INVALID_PARAMETER A parameter was invalid.
457 @retval EFI_INVALID_PARAMETER FileName was NULL.
458 @retval EFI_INVALID_PARAMETER FileName was a directory.
459 **/
460 EFI_STATUS
461 EFIAPI
462 ReadFileIntoBuffer (
463 IN CONST CHAR16 *FileName,
464 OUT VOID **Buffer,
465 OUT UINTN *BufferSize OPTIONAL,
466 OUT BOOLEAN *ReadOnly
467 );
468
469 #endif