1 /** @file 2 Main file for NULL named library for Profile1 shell command functions. 3 4 Copyright (c) 2010 - 2015, 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 #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 #include <Guid/ShellLibHiiGuid.h> 26 27 #include <Protocol/EfiShell.h> 28 #include <Protocol/EfiShellParameters.h> 29 #include <Protocol/DevicePath.h> 30 #include <Protocol/LoadedImage.h> 31 #include <Protocol/UnicodeCollation.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/SimplePointer.h> 41 #include <Protocol/CpuIo2.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 64 /** 65 Function printing hex output to the console. 66 67 @param[in] Indent Number of spaces to indent. 68 @param[in] Offset Offset to start with. 69 @param[in] DataSize Length of data. 70 @param[in] UserData Pointer to some data. 71 **/ 72 VOID 73 DumpHex ( 74 IN UINTN Indent, 75 IN UINTN Offset, 76 IN UINTN DataSize, 77 IN VOID *UserData 78 ); 79 80 /** 81 Function returns a system configuration table that is stored in the 82 EFI System Table based on the provided GUID. 83 84 @param[in] TableGuid A pointer to the table's GUID type. 85 @param[in, out] Table On exit, a pointer to a system configuration table. 86 87 @retval EFI_SUCCESS A configuration table matching TableGuid was found. 88 @retval EFI_NOT_FOUND A configuration table matching TableGuid was not found. 89 **/ 90 EFI_STATUS 91 EFIAPI 92 GetSystemConfigurationTable ( 93 IN EFI_GUID *TableGuid, 94 IN OUT VOID **Table 95 ); 96 97 /** 98 Convert a string representation of a GUID to the GUID value. 99 100 @param[in] StringGuid The pointer to the string containing a GUID printed. 101 @param[in, out] Guid The pointer to the buffer to get the GUID value. 102 **/ 103 EFI_STATUS 104 EFIAPI 105 ConvertStringToGuid ( 106 IN CONST CHAR16 *StringGuid, 107 IN OUT EFI_GUID *Guid 108 ); 109 110 /** 111 Convert a Unicode character to numerical value. 112 113 This internal function only deal with Unicode character 114 which maps to a valid hexadecimal ASII character, i.e. 115 L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other 116 Unicode character, the value returned does not make sense. 117 118 @param Char The character to convert. 119 120 @return The numerical value converted. 121 122 **/ 123 UINTN 124 EFIAPI 125 HexCharToUintn ( 126 IN CHAR16 Char 127 ); 128 129 /** 130 Function for 'setsize' command. 131 132 @param[in] ImageHandle Handle to the Image (NULL if Internal). 133 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 134 **/ 135 SHELL_STATUS 136 EFIAPI 137 ShellCommandRunSetSize ( 138 IN EFI_HANDLE ImageHandle, 139 IN EFI_SYSTEM_TABLE *SystemTable 140 ); 141 142 /** 143 Function for 'comp' command. 144 145 @param[in] ImageHandle Handle to the Image (NULL if Internal). 146 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 147 **/ 148 SHELL_STATUS 149 EFIAPI 150 ShellCommandRunComp ( 151 IN EFI_HANDLE ImageHandle, 152 IN EFI_SYSTEM_TABLE *SystemTable 153 ); 154 155 /** 156 Function for 'mode' command. 157 158 @param[in] ImageHandle Handle to the Image (NULL if Internal). 159 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 160 **/ 161 SHELL_STATUS 162 EFIAPI 163 ShellCommandRunMode ( 164 IN EFI_HANDLE ImageHandle, 165 IN EFI_SYSTEM_TABLE *SystemTable 166 ); 167 168 /** 169 Function for 'memmap' command. 170 171 @param[in] ImageHandle Handle to the Image (NULL if Internal). 172 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 173 **/ 174 SHELL_STATUS 175 EFIAPI 176 ShellCommandRunMemMap ( 177 IN EFI_HANDLE ImageHandle, 178 IN EFI_SYSTEM_TABLE *SystemTable 179 ); 180 181 /** 182 Function for 'compress' command. 183 184 @param[in] ImageHandle Handle to the Image (NULL if Internal). 185 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 186 **/ 187 SHELL_STATUS 188 EFIAPI 189 ShellCommandRunEfiCompress ( 190 IN EFI_HANDLE ImageHandle, 191 IN EFI_SYSTEM_TABLE *SystemTable 192 ); 193 194 /** 195 Function for 'decompress' command. 196 197 @param[in] ImageHandle Handle to the Image (NULL if Internal). 198 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 199 **/ 200 SHELL_STATUS 201 EFIAPI 202 ShellCommandRunEfiDecompress ( 203 IN EFI_HANDLE ImageHandle, 204 IN EFI_SYSTEM_TABLE *SystemTable 205 ); 206 207 /** 208 Function for 'dmem' command. 209 210 @param[in] ImageHandle Handle to the Image (NULL if Internal). 211 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 212 **/ 213 SHELL_STATUS 214 EFIAPI 215 ShellCommandRunDmem ( 216 IN EFI_HANDLE ImageHandle, 217 IN EFI_SYSTEM_TABLE *SystemTable 218 ); 219 220 /** 221 Function for 'loadpcirom' command. 222 223 @param[in] ImageHandle Handle to the Image (NULL if Internal). 224 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 225 **/ 226 SHELL_STATUS 227 EFIAPI 228 ShellCommandRunLoadPciRom ( 229 IN EFI_HANDLE ImageHandle, 230 IN EFI_SYSTEM_TABLE *SystemTable 231 ); 232 233 /** 234 Function for 'mm' command. 235 236 @param[in] ImageHandle Handle to the Image (NULL if Internal). 237 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 238 **/ 239 SHELL_STATUS 240 EFIAPI 241 ShellCommandRunMm ( 242 IN EFI_HANDLE ImageHandle, 243 IN EFI_SYSTEM_TABLE *SystemTable 244 ); 245 246 /** 247 Function for 'setvar' command. 248 249 @param[in] ImageHandle Handle to the Image (NULL if Internal). 250 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 251 **/ 252 SHELL_STATUS 253 EFIAPI 254 ShellCommandRunSetVar ( 255 IN EFI_HANDLE ImageHandle, 256 IN EFI_SYSTEM_TABLE *SystemTable 257 ); 258 259 /** 260 Function for 'sermode' command. 261 262 @param[in] ImageHandle Handle to the Image (NULL if Internal). 263 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 264 **/ 265 SHELL_STATUS 266 EFIAPI 267 ShellCommandRunSerMode ( 268 IN EFI_HANDLE ImageHandle, 269 IN EFI_SYSTEM_TABLE *SystemTable 270 ); 271 272 /** 273 Function for 'bcfg' command. 274 275 @param[in] ImageHandle Handle to the Image (NULL if Internal). 276 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 277 **/ 278 SHELL_STATUS 279 EFIAPI 280 ShellCommandRunBcfg ( 281 IN EFI_HANDLE ImageHandle, 282 IN EFI_SYSTEM_TABLE *SystemTable 283 ); 284 285 /** 286 Function for 'pci' command. 287 288 @param[in] ImageHandle Handle to the Image (NULL if Internal). 289 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 290 **/ 291 SHELL_STATUS 292 EFIAPI 293 ShellCommandRunPci ( 294 IN EFI_HANDLE ImageHandle, 295 IN EFI_SYSTEM_TABLE *SystemTable 296 ); 297 298 /** 299 Function for 'smbiosview' command. 300 301 @param[in] ImageHandle Handle to the Image (NULL if Internal). 302 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 303 **/ 304 SHELL_STATUS 305 EFIAPI 306 ShellCommandRunSmbiosView ( 307 IN EFI_HANDLE ImageHandle, 308 IN EFI_SYSTEM_TABLE *SystemTable 309 ); 310 311 /** 312 Function for 'dmpstore' command. 313 314 @param[in] ImageHandle Handle to the Image (NULL if Internal). 315 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 316 **/ 317 SHELL_STATUS 318 EFIAPI 319 ShellCommandRunDmpStore ( 320 IN EFI_HANDLE ImageHandle, 321 IN EFI_SYSTEM_TABLE *SystemTable 322 ); 323 324 /** 325 Function for 'dblk' command. 326 327 @param[in] ImageHandle Handle to the Image (NULL if Internal). 328 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 329 **/ 330 SHELL_STATUS 331 EFIAPI 332 ShellCommandRunDblk ( 333 IN EFI_HANDLE ImageHandle, 334 IN EFI_SYSTEM_TABLE *SystemTable 335 ); 336 337 /** 338 Function for 'edit' command. 339 340 @param[in] ImageHandle Handle to the Image (NULL if Internal). 341 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 342 **/ 343 SHELL_STATUS 344 EFIAPI 345 ShellCommandRunEdit ( 346 IN EFI_HANDLE ImageHandle, 347 IN EFI_SYSTEM_TABLE *SystemTable 348 ); 349 350 /** 351 Function for 'hexedit' command. 352 353 @param[in] ImageHandle Handle to the Image (NULL if Internal). 354 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 355 **/ 356 SHELL_STATUS 357 EFIAPI 358 ShellCommandRunHexEdit ( 359 IN EFI_HANDLE ImageHandle, 360 IN EFI_SYSTEM_TABLE *SystemTable 361 ); 362 363 /** 364 Clear the line at the specified Row. 365 366 @param[in] Row The row number to be cleared ( start from 1 ) 367 @param[in] LastCol The last printable column. 368 @param[in] LastRow The last printable row. 369 **/ 370 VOID 371 EFIAPI 372 EditorClearLine ( 373 IN UINTN Row, 374 IN UINTN LastCol, 375 IN UINTN LastRow 376 ); 377 378 /** 379 Check if file name has illegal characters. 380 381 @param Name The filename to check. 382 383 @retval TRUE The filename is ok. 384 @retval FALSE The filename is not ok. 385 **/ 386 BOOLEAN 387 EFIAPI 388 IsValidFileName ( 389 IN CONST CHAR16 *Name 390 ); 391 392 /** 393 Find a filename that is valid (not taken) with the given extension. 394 395 @param[in] Extension The file extension. 396 397 @retval NULL Something went wrong. 398 @return the valid filename. 399 **/ 400 CHAR16 * 401 EFIAPI 402 EditGetDefaultFileName ( 403 IN CONST CHAR16 *Extension 404 ); 405 406 /** 407 Read a file into an allocated buffer. The buffer is the responsibility 408 of the caller to free. 409 410 @param[in] FileName The filename of the file to open. 411 @param[out] Buffer Upon successful return, the pointer to the 412 address of the allocated buffer. 413 @param[out] BufferSize If not NULL, then the pointer to the size 414 of the allocated buffer. 415 @param[out] ReadOnly Upon successful return TRUE if the file is 416 read only. FALSE otherwise. 417 418 @retval EFI_NOT_FOUND The filename did not represent a file in the 419 file system. Directories cannot be read with 420 this method. 421 @retval EFI_SUCCESS The file was read into the buffer. 422 @retval EFI_OUT_OF_RESOURCES A memory allocation failed. 423 @retval EFI_LOAD_ERROR The file read operation failed. 424 @retval EFI_INVALID_PARAMETER A parameter was invalid. 425 @retval EFI_INVALID_PARAMETER FileName was NULL. 426 @retval EFI_INVALID_PARAMETER FileName was a directory. 427 **/ 428 EFI_STATUS 429 EFIAPI 430 ReadFileIntoBuffer ( 431 IN CONST CHAR16 *FileName, 432 OUT VOID **Buffer, 433 OUT UINTN *BufferSize OPTIONAL, 434 OUT BOOLEAN *ReadOnly 435 ); 436 437 #endif 438