2 Provides interface to advanced shell functionality for parsing both handle and protocol database.
4 Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
6 (C) Copyright 2015-2021 Hewlett Packard Enterprise Development LP<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "UefiHandleParsingLib.h"
12 #include "IndustryStandard/Acpi10.h"
13 #include "IndustryStandard/Pci.h"
15 #include <Protocol/FirmwareVolume2.h>
17 EFI_HII_HANDLE mHandleParsingHiiHandle
= NULL
;
18 HANDLE_INDEX_LIST mHandleList
= {{{NULL
,NULL
},0,0},0};
19 GUID_INFO_BLOCK
*mGuidList
;
23 Function to find the file name associated with a LoadedImageProtocol.
25 @param[in] LoadedImage An instance of LoadedImageProtocol.
27 @retval A string representation of the file name associated
28 with LoadedImage, or NULL if no name can be found.
31 FindLoadedImageFileName (
32 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
37 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
40 UINT32 AuthenticationStatus
;
42 if ((LoadedImage
== NULL
) || (LoadedImage
->FilePath
== NULL
)) {
46 NameGuid
= EfiGetNameGuidFromFwVolDevicePathNode((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*)LoadedImage
->FilePath
);
48 if (NameGuid
== NULL
) {
53 // Get the FirmwareVolume2Protocol of the device handle that this image was loaded from.
55 Status
= gBS
->HandleProtocol (LoadedImage
->DeviceHandle
, &gEfiFirmwareVolume2ProtocolGuid
, (VOID
**) &Fv
);
58 // FirmwareVolume2Protocol is PI, and is not required to be available.
60 if (EFI_ERROR (Status
)) {
65 // Read the user interface section of the image.
68 Status
= Fv
->ReadSection(Fv
, NameGuid
, EFI_SECTION_USER_INTERFACE
, 0, &Buffer
, &BufferSize
, &AuthenticationStatus
);
70 if (EFI_ERROR (Status
)) {
75 // ReadSection returns just the section data, without any section header. For
76 // a user interface section, the only data is the file name.
82 Function to translate the EFI_MEMORY_TYPE into a string.
84 @param[in] Memory The memory type.
86 @retval A string representation of the type allocated from BS Pool.
90 IN CONST EFI_MEMORY_TYPE Memory
97 case EfiReservedMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiReservedMemoryType", 0); break;
98 case EfiLoaderCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderCode", 0); break;
99 case EfiLoaderData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderData", 0); break;
100 case EfiBootServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesCode", 0); break;
101 case EfiBootServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesData", 0); break;
102 case EfiRuntimeServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesCode", 0); break;
103 case EfiRuntimeServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesData", 0); break;
104 case EfiConventionalMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiConventionalMemory", 0); break;
105 case EfiUnusableMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiUnusableMemory", 0); break;
106 case EfiACPIReclaimMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIReclaimMemory", 0); break;
107 case EfiACPIMemoryNVS
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIMemoryNVS", 0); break;
108 case EfiMemoryMappedIO
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIO", 0); break;
109 case EfiMemoryMappedIOPortSpace
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIOPortSpace", 0); break;
110 case EfiPalCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiPalCode", 0); break;
111 case EfiMaxMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMaxMemoryType", 0); break;
112 default: ASSERT(FALSE
);
118 Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.
120 @param[in] Fmt The format type.
122 @retval A string representation of the type allocated from BS Pool.
126 IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt
133 case PixelRedGreenBlueReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelRedGreenBlueReserved8BitPerColor", 0); break;
134 case PixelBlueGreenRedReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBlueGreenRedReserved8BitPerColor", 0); break;
135 case PixelBitMask
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBitMask", 0); break;
136 case PixelBltOnly
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBltOnly", 0); break;
137 case PixelFormatMax
: StrnCatGrow(&RetVal
, NULL
, L
"PixelFormatMax", 0); break;
138 default: ASSERT(FALSE
);
144 Constructor for the library.
146 @param[in] ImageHandle Ignored.
147 @param[in] SystemTable Ignored.
149 @retval EFI_SUCCESS The operation was successful.
153 HandleParsingLibConstructor (
154 IN EFI_HANDLE ImageHandle
,
155 IN EFI_SYSTEM_TABLE
*SystemTable
162 // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.
164 return (EFI_SUCCESS
);
168 Initialization function for HII packages.
172 HandleParsingHiiInit (VOID
)
174 if (mHandleParsingHiiHandle
== NULL
) {
175 mHandleParsingHiiHandle
= HiiAddPackages (&gHandleParsingHiiGuid
, gImageHandle
, UefiHandleParsingLibStrings
, NULL
);
176 ASSERT (mHandleParsingHiiHandle
!= NULL
);
181 Destructor for the library. free any resources.
183 @param[in] ImageHandle Ignored.
184 @param[in] SystemTable Ignored.
186 @retval EFI_SUCCESS The operation was successful.
190 HandleParsingLibDestructor (
191 IN EFI_HANDLE ImageHandle
,
192 IN EFI_SYSTEM_TABLE
*SystemTable
197 for (LoopCount
= 0; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++) {
198 SHELL_FREE_NON_NULL(mGuidList
[LoopCount
].GuidId
);
201 SHELL_FREE_NON_NULL(mGuidList
);
202 if (mHandleParsingHiiHandle
!= NULL
) {
203 HiiRemovePackages(mHandleParsingHiiHandle
);
205 return (EFI_SUCCESS
);
209 Function to dump information about LoadedImage.
211 This will allocate the return buffer from boot services pool.
213 @param[in] TheHandle The handle that has LoadedImage installed.
214 @param[in] Verbose TRUE for additional information, FALSE otherwise.
216 @retval A poitner to a string containing the information.
220 LoadedImageProtocolDumpInformation(
221 IN CONST EFI_HANDLE TheHandle
,
222 IN CONST BOOLEAN Verbose
225 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
235 Status
= gBS
->OpenProtocol (
237 &gEfiLoadedImageProtocolGuid
,
238 (VOID
**)&LoadedImage
,
241 EFI_OPEN_PROTOCOL_GET_PROTOCOL
244 if (EFI_ERROR (Status
)) {
248 FileName
= FindLoadedImageFileName(LoadedImage
);
249 FilePath
= ConvertDevicePathToText(LoadedImage
->FilePath
, TRUE
, TRUE
);
251 if (FileName
== NULL
) {
254 SHELL_FREE_NON_NULL(FilePath
);
259 HandleParsingHiiInit();
261 if (FileName
!= NULL
) {
262 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_NAME
), NULL
);
265 RetVal
= CatSPrint(NULL
, Temp
, FileName
);
268 SHELL_FREE_NON_NULL(Temp
);
269 SHELL_FREE_NON_NULL(FileName
);
272 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_MAIN
), NULL
);
276 PdbFileName
= PeCoffLoaderGetPdbPointer (LoadedImage
->ImageBase
);
277 DataType
= ConvertMemoryType(LoadedImage
->ImageDataType
);
278 CodeType
= ConvertMemoryType(LoadedImage
->ImageCodeType
);
283 LoadedImage
->Revision
,
284 LoadedImage
->ParentHandle
,
285 LoadedImage
->SystemTable
,
286 LoadedImage
->DeviceHandle
,
289 LoadedImage
->LoadOptionsSize
,
290 LoadedImage
->LoadOptions
,
291 LoadedImage
->ImageBase
,
292 LoadedImage
->ImageSize
,
299 SHELL_FREE_NON_NULL(Temp
);
300 SHELL_FREE_NON_NULL(FilePath
);
301 SHELL_FREE_NON_NULL(CodeType
);
302 SHELL_FREE_NON_NULL(DataType
);
308 Function to dump information about GOP.
310 This will allocate the return buffer from boot services pool.
312 @param[in] TheHandle The handle that has LoadedImage installed.
313 @param[in] Verbose TRUE for additional information, FALSE otherwise.
315 @retval A poitner to a string containing the information.
319 GraphicsOutputProtocolDumpInformation(
320 IN CONST EFI_HANDLE TheHandle
,
321 IN CONST BOOLEAN Verbose
324 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
332 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*GopInfo
;
335 return (CatSPrint(NULL
, L
"GraphicsOutput"));
338 HandleParsingHiiInit();
340 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_GOP_DUMP_MAIN
), NULL
);
345 Status
= gBS
->OpenProtocol (
347 &gEfiGraphicsOutputProtocolGuid
,
348 (VOID
**)&GraphicsOutput
,
351 EFI_OPEN_PROTOCOL_GET_PROTOCOL
354 if (EFI_ERROR (Status
)) {
355 SHELL_FREE_NON_NULL (Temp
);
359 Fmt
= ConvertPixelFormat(GraphicsOutput
->Mode
->Info
->PixelFormat
);
364 GraphicsOutput
->Mode
->MaxMode
,
365 GraphicsOutput
->Mode
->Mode
,
366 GraphicsOutput
->Mode
->FrameBufferBase
,
367 (UINT64
)GraphicsOutput
->Mode
->FrameBufferSize
,
368 (UINT64
)GraphicsOutput
->Mode
->SizeOfInfo
,
369 GraphicsOutput
->Mode
->Info
->Version
,
370 GraphicsOutput
->Mode
->Info
->HorizontalResolution
,
371 GraphicsOutput
->Mode
->Info
->VerticalResolution
,
373 GraphicsOutput
->Mode
->Info
->PixelsPerScanLine
,
374 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.RedMask
,
375 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.GreenMask
,
376 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.BlueMask
379 SHELL_FREE_NON_NULL (Temp
);
381 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_GOP_RES_LIST_MAIN
), NULL
);
383 SHELL_FREE_NON_NULL (RetVal
);
387 TempRetVal
= CatSPrint (RetVal
, Temp
);
388 SHELL_FREE_NON_NULL (RetVal
);
389 if (TempRetVal
== NULL
) {
393 SHELL_FREE_NON_NULL (Temp
);
395 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_GOP_RES_LIST_ENTRY
), NULL
);
397 SHELL_FREE_NON_NULL (RetVal
);
402 for (Mode
= 0; Mode
< GraphicsOutput
->Mode
->MaxMode
; Mode
++) {
403 Status
= GraphicsOutput
->QueryMode (
409 if (EFI_ERROR (Status
)) {
413 TempRetVal
= CatSPrint (
417 GopInfo
->HorizontalResolution
,
418 GopInfo
->VerticalResolution
421 SHELL_FREE_NON_NULL (GopInfo
);
422 SHELL_FREE_NON_NULL (RetVal
);
428 SHELL_FREE_NON_NULL(Temp
);
429 SHELL_FREE_NON_NULL(Fmt
);
435 Function to dump information about EDID Discovered Protocol.
437 This will allocate the return buffer from boot services pool.
439 @param[in] TheHandle The handle that has LoadedImage installed.
440 @param[in] Verbose TRUE for additional information, FALSE otherwise.
442 @retval A pointer to a string containing the information.
446 EdidDiscoveredProtocolDumpInformation (
447 IN CONST EFI_HANDLE TheHandle
,
448 IN CONST BOOLEAN Verbose
451 EFI_EDID_DISCOVERED_PROTOCOL
*EdidDiscovered
;
458 return (CatSPrint (NULL
, L
"EDIDDiscovered"));
461 Status
= gBS
->OpenProtocol (
463 &gEfiEdidDiscoveredProtocolGuid
,
464 (VOID
**)&EdidDiscovered
,
467 EFI_OPEN_PROTOCOL_GET_PROTOCOL
470 if (EFI_ERROR (Status
)) {
474 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_DISCOVERED_MAIN
), NULL
);
479 RetVal
= CatSPrint (NULL
, Temp
, EdidDiscovered
->SizeOfEdid
);
480 SHELL_FREE_NON_NULL (Temp
);
482 if (EdidDiscovered
->SizeOfEdid
!= 0) {
483 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_DISCOVERED_DATA
), NULL
);
485 SHELL_FREE_NON_NULL (RetVal
);
488 TempRetVal
= CatSPrint (RetVal
, Temp
);
489 SHELL_FREE_NON_NULL (RetVal
);
492 TempRetVal
= CatSDumpHex (RetVal
, 4, 0, EdidDiscovered
->SizeOfEdid
, EdidDiscovered
->Edid
);
499 Function to dump information about EDID Active Protocol.
501 This will allocate the return buffer from boot services pool.
503 @param[in] TheHandle The handle that has LoadedImage installed.
504 @param[in] Verbose TRUE for additional information, FALSE otherwise.
506 @retval A pointer to a string containing the information.
510 EdidActiveProtocolDumpInformation (
511 IN CONST EFI_HANDLE TheHandle
,
512 IN CONST BOOLEAN Verbose
515 EFI_EDID_ACTIVE_PROTOCOL
*EdidActive
;
522 return (CatSPrint (NULL
, L
"EDIDActive"));
525 Status
= gBS
->OpenProtocol (
527 &gEfiEdidActiveProtocolGuid
,
531 EFI_OPEN_PROTOCOL_GET_PROTOCOL
534 if (EFI_ERROR (Status
)) {
538 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_ACTIVE_MAIN
), NULL
);
543 RetVal
= CatSPrint (NULL
, Temp
, EdidActive
->SizeOfEdid
);
544 SHELL_FREE_NON_NULL (Temp
);
546 if (EdidActive
->SizeOfEdid
!= 0) {
547 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_ACTIVE_DATA
), NULL
);
549 SHELL_FREE_NON_NULL (RetVal
);
552 TempRetVal
= CatSPrint (RetVal
, Temp
);
553 SHELL_FREE_NON_NULL (RetVal
);
556 TempRetVal
= CatSDumpHex (RetVal
, 4, 0, EdidActive
->SizeOfEdid
, EdidActive
->Edid
);
563 Function to dump information about PciRootBridgeIo.
565 This will allocate the return buffer from boot services pool.
567 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
568 @param[in] Verbose TRUE for additional information, FALSE otherwise.
570 @retval A poitner to a string containing the information.
574 PciRootBridgeIoDumpInformation(
575 IN CONST EFI_HANDLE TheHandle
,
576 IN CONST BOOLEAN Verbose
579 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
580 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Configuration
;
591 return (CatSPrint(NULL
, L
"PciRootBridgeIo"));
594 HandleParsingHiiInit();
596 Status
= gBS
->HandleProtocol(
598 &gEfiPciRootBridgeIoProtocolGuid
,
599 (VOID
**)&PciRootBridgeIo
);
601 if (EFI_ERROR(Status
)) {
605 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_PH
), NULL
);
609 Temp2
= CatSPrint(NULL
, Temp
, PciRootBridgeIo
->ParentHandle
);
614 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SEG
), NULL
);
616 SHELL_FREE_NON_NULL(RetVal
);
619 Temp2
= CatSPrint(RetVal
, Temp
, PciRootBridgeIo
->SegmentNumber
);
627 Status
= PciRootBridgeIo
->GetAttributes (PciRootBridgeIo
, &Supports
, &Attributes
);
628 if (!EFI_ERROR(Status
)) {
629 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_ATT
), NULL
);
631 SHELL_FREE_NON_NULL(RetVal
);
634 Temp2
= CatSPrint(RetVal
, Temp
, Attributes
);
640 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS
), NULL
);
642 SHELL_FREE_NON_NULL(RetVal
);
645 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
652 Configuration
= NULL
;
653 Status
= PciRootBridgeIo
->Configuration (PciRootBridgeIo
, (VOID
**) &Configuration
);
654 if (!EFI_ERROR(Status
) && Configuration
!= NULL
) {
655 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_TITLE
), NULL
);
657 SHELL_FREE_NON_NULL(RetVal
);
660 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
665 while (Configuration
->Desc
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
667 switch (Configuration
->ResType
) {
668 case ACPI_ADDRESS_SPACE_TYPE_MEM
:
669 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_MEM
), NULL
);
671 case ACPI_ADDRESS_SPACE_TYPE_IO
:
672 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_IO
), NULL
);
674 case ACPI_ADDRESS_SPACE_TYPE_BUS
:
675 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_BUS
), NULL
);
679 Temp2
= CatSPrint(RetVal
, L
"\r\n%s", Temp
);
686 Temp2
= CatSPrint(RetVal
,
687 L
"%%H%02x %016lx %016lx %02x%%N",
688 Configuration
->SpecificFlag
,
689 Configuration
->AddrRangeMin
,
690 Configuration
->AddrRangeMax
,
691 Configuration
->AddrSpaceGranularity
703 Function to dump information about SimpleTextOut.
705 This will allocate the return buffer from boot services pool.
707 @param[in] TheHandle The handle that has SimpleTextOut installed.
708 @param[in] Verbose TRUE for additional information, FALSE otherwise.
710 @retval A poitner to a string containing the information.
714 TxtOutProtocolDumpInformation(
715 IN CONST EFI_HANDLE TheHandle
,
716 IN CONST BOOLEAN Verbose
719 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Dev
;
733 HandleParsingHiiInit();
738 Status
= gBS
->HandleProtocol(
740 &gEfiSimpleTextOutProtocolGuid
,
743 ASSERT_EFI_ERROR(Status
);
744 ASSERT (Dev
!= NULL
&& Dev
->Mode
!= NULL
);
746 Size
= (Dev
->Mode
->MaxMode
+ 1) * 80;
747 RetVal
= AllocateZeroPool(Size
);
749 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER
), NULL
);
751 UnicodeSPrint(RetVal
, Size
, Temp
, Dev
, Dev
->Mode
->Attribute
);
758 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE
), NULL
);
759 for (Index
= 0; Index
< Dev
->Mode
->MaxMode
; Index
++) {
760 Status
= Dev
->QueryMode (Dev
, Index
, &Col
, &Row
);
761 NewSize
= Size
- StrSize(RetVal
);
763 RetVal
+ StrLen(RetVal
),
765 Temp
== NULL
?L
"":Temp
,
766 Index
== Dev
->Mode
->Mode
? L
'*' : L
' ',
768 !EFI_ERROR(Status
)?(INTN
)Col
:-1,
769 !EFI_ERROR(Status
)?(INTN
)Row
:-1
776 STATIC CONST UINTN VersionStringSize
= 60;
779 Function to dump information about EfiDriverSupportedEfiVersion protocol.
781 This will allocate the return buffer from boot services pool.
783 @param[in] TheHandle The handle that has the protocol installed.
784 @param[in] Verbose TRUE for additional information, FALSE otherwise.
786 @retval A poitner to a string containing the information.
790 DriverEfiVersionProtocolDumpInformation(
791 IN CONST EFI_HANDLE TheHandle
,
792 IN CONST BOOLEAN Verbose
795 EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL
*DriverEfiVersion
;
799 Status
= gBS
->HandleProtocol(
801 &gEfiDriverSupportedEfiVersionProtocolGuid
,
802 (VOID
**)&DriverEfiVersion
);
804 ASSERT_EFI_ERROR(Status
);
806 RetVal
= AllocateZeroPool(VersionStringSize
);
807 if (RetVal
!= NULL
) {
808 UnicodeSPrint (RetVal
, VersionStringSize
, L
"0x%08x", DriverEfiVersion
->FirmwareVersion
);
813 Function to convert device path to string.
815 This will allocate the return buffer from boot services pool.
817 @param[in] DevPath Pointer to device path instance.
818 @param[in] Verbose TRUE for additional information, FALSE otherwise.
819 @param[in] Length Maximum allowed text length of the device path.
821 @retval A pointer to a string containing the information.
824 ConvertDevicePathToShortText(
825 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevPath
,
826 IN CONST BOOLEAN Verbose
,
827 IN CONST UINTN Length
835 // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
837 Temp
= ConvertDevicePathToText(DevPath
, TRUE
, TRUE
);
838 if (!Verbose
&& Temp
!= NULL
&& StrLen(Temp
) > Length
) {
841 Temp2
= StrnCatGrow(&Temp2
, &Size
, L
"..", 0);
842 Temp2
= StrnCatGrow(&Temp2
, &Size
, Temp
+(StrLen(Temp
) - (Length
- 2)), 0);
850 Function to dump protocol information.
852 This will allocate the return buffer from boot services pool.
854 @param[in] TheHandle The handle that has the protocol installed.
855 @param[in] Verbose TRUE for additional information, FALSE otherwise.
856 @param[in] Protocol The protocol is needed to dump.
858 @retval A pointer to a string containing the information.
862 DevicePathProtocolDumpInformationEx (
863 IN CONST EFI_HANDLE TheHandle
,
864 IN CONST BOOLEAN Verbose
,
865 IN EFI_GUID
*Protocol
868 EFI_DEVICE_PATH_PROTOCOL
*DevPath
;
870 CHAR16
*DevPathStrTemp
;
874 DevPathStrTemp
= NULL
;
875 Status
= gBS
->OpenProtocol(TheHandle
, Protocol
, (VOID
**)&DevPath
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
876 if (!EFI_ERROR(Status
)) {
877 DevPathStr
= ConvertDevicePathToShortText (DevPath
, Verbose
, 30);
879 Size
= StrSize(DevPathStr
) + sizeof(CHAR16
) * 2;
880 DevPathStrTemp
= AllocateZeroPool (Size
);
881 if (DevPathStrTemp
!= NULL
) {
882 StrnCatS (DevPathStrTemp
, Size
/sizeof(CHAR16
), L
" ", 2);
883 StrnCatS (DevPathStrTemp
, Size
/sizeof(CHAR16
), DevPathStr
, StrLen (DevPathStr
));
885 FreePool (DevPathStr
);
886 DevPathStr
= DevPathStrTemp
;
888 gBS
->CloseProtocol(TheHandle
, Protocol
, gImageHandle
, NULL
);
894 Function to dump information about DevicePath protocol.
896 This will allocate the return buffer from boot services pool.
898 @param[in] TheHandle The handle that has the protocol installed.
899 @param[in] Verbose TRUE for additional information, FALSE otherwise.
901 @retval A pointer to a string containing the information.
905 DevicePathProtocolDumpInformation(
906 IN CONST EFI_HANDLE TheHandle
,
907 IN CONST BOOLEAN Verbose
910 return DevicePathProtocolDumpInformationEx (TheHandle
, Verbose
, &gEfiDevicePathProtocolGuid
);
914 Function to dump information about LoadedImageDevicePath protocol.
916 This will allocate the return buffer from boot services pool.
918 @param[in] TheHandle The handle that has the protocol installed.
919 @param[in] Verbose TRUE for additional information, FALSE otherwise.
921 @retval A pointer to a string containing the information.
925 LoadedImageDevicePathProtocolDumpInformation(
926 IN CONST EFI_HANDLE TheHandle
,
927 IN CONST BOOLEAN Verbose
930 return DevicePathProtocolDumpInformationEx (TheHandle
, Verbose
, &gEfiLoadedImageDevicePathProtocolGuid
);
934 Function to dump information about BusSpecificDriverOverride protocol.
936 This will allocate the return buffer from boot services pool.
938 @param[in] TheHandle The handle that has the protocol installed.
939 @param[in] Verbose TRUE for additional information, FALSE otherwise.
941 @retval A pointer to a string containing the information.
945 BusSpecificDriverOverrideProtocolDumpInformation (
946 IN CONST EFI_HANDLE TheHandle
,
947 IN CONST BOOLEAN Verbose
954 EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL
*BusSpecificDriverOverride
;
955 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
956 EFI_HANDLE ImageHandle
;
968 Status
= gBS
->OpenProtocol (
970 &gEfiBusSpecificDriverOverrideProtocolGuid
,
971 (VOID
**)&BusSpecificDriverOverride
,
974 EFI_OPEN_PROTOCOL_GET_PROTOCOL
976 if (EFI_ERROR (Status
)) {
979 HandleParsingHiiInit ();
980 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_BSDO_DUMP_MAIN
), NULL
);
981 if (GetString
== NULL
) {
985 Status
= BusSpecificDriverOverride
->GetDriver (
986 BusSpecificDriverOverride
,
989 if (!EFI_ERROR (Status
)) {
990 Status
= gBS
->HandleProtocol (
992 &gEfiLoadedImageProtocolGuid
,
993 (VOID
**) &LoadedImage
995 if(!EFI_ERROR (Status
)) {
996 TempRetVal
= CatSPrint (
999 ConvertHandleToHandleIndex (ImageHandle
),
1000 ConvertDevicePathToText (LoadedImage
->FilePath
, TRUE
, TRUE
)
1002 StrnCatGrow (&RetVal
, &Size
, TempRetVal
, 0);
1003 SHELL_FREE_NON_NULL (TempRetVal
);
1006 } while (!EFI_ERROR (Status
));
1008 SHELL_FREE_NON_NULL (GetString
);
1013 Function to dump information about BlockIo protocol.
1015 This will allocate the return buffer from boot services pool.
1017 @param[in] TheHandle The handle that has the protocol installed.
1018 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1020 @retval A pointer to a string containing the information.
1024 BlockIoProtocolDumpInformation (
1025 IN CONST EFI_HANDLE TheHandle
,
1026 IN CONST BOOLEAN Verbose
1030 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
1031 EFI_BLOCK_IO_MEDIA
*BlockMedia
;
1041 Status
= gBS
->OpenProtocol (
1043 &gEfiBlockIoProtocolGuid
,
1047 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1049 if (EFI_ERROR (Status
)) {
1052 BlockMedia
= BlockIo
->Media
;
1055 // The function (ReadBlocks) must return EFI_NO_MEDIA or
1056 // EFI_MEDIA_CHANGED even if LBA, BufferSize, or Buffer are invalid so the caller can probe
1057 // for changes in media state.
1059 BlockIo
->ReadBlocks (
1061 BlockIo
->Media
->MediaId
,
1067 HandleParsingHiiInit ();
1068 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_BLOCKIO_INFO
), NULL
);
1069 if (GetString
== NULL
) {
1072 RetVal
= CatSPrint (
1075 BlockMedia
->RemovableMedia
? L
"Removable " : L
"Fixed ",
1076 BlockMedia
->MediaPresent
? L
"" : L
"not-present ",
1077 BlockMedia
->MediaId
,
1078 BlockMedia
->BlockSize
,
1079 BlockMedia
->LastBlock
,
1080 MultU64x32 (BlockMedia
->LastBlock
+ 1, BlockMedia
->BlockSize
),
1081 BlockMedia
->LogicalPartition
? L
"partition" : L
"raw",
1082 BlockMedia
->ReadOnly
? L
"ro" : L
"rw",
1083 BlockMedia
->WriteCaching
? L
"cached" : L
"!cached"
1086 SHELL_FREE_NON_NULL (GetString
);
1091 Function to dump information about DebugSupport Protocol.
1093 @param[in] TheHandle The handle that has the protocol installed.
1094 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1096 @retval A pointer to a string containing the information.
1100 DebugSupportProtocolDumpInformation (
1101 IN CONST EFI_HANDLE TheHandle
,
1102 IN CONST BOOLEAN Verbose
1106 EFI_DEBUG_SUPPORT_PROTOCOL
*DebugSupport
;
1115 Status
= gBS
->OpenProtocol (
1117 &gEfiDebugSupportProtocolGuid
,
1118 (VOID
**)&DebugSupport
,
1121 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1123 if (EFI_ERROR (Status
)) {
1126 HandleParsingHiiInit ();
1127 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_DEBUGSUPPORT_INFO
), NULL
);
1128 if (GetString
== NULL
) {
1132 // Dump Debug support info
1134 switch (DebugSupport
->Isa
) {
1136 RetVal
= CatSPrint (RetVal
, GetString
, L
"IA-32");
1139 RetVal
= CatSPrint (RetVal
, GetString
, L
"IPF");
1142 RetVal
= CatSPrint (RetVal
, GetString
, L
"EBC");
1145 SHELL_FREE_NON_NULL (GetString
);
1146 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_DEBUGSUPPORT_UNKNOWN
), NULL
);
1147 RetVal
= GetString
!= NULL
? CatSPrint (RetVal
, GetString
, DebugSupport
->Isa
) : NULL
;
1151 SHELL_FREE_NON_NULL (GetString
);
1156 Function to dump information about PciIoProtocol.
1158 This will allocate the return buffer from boot services pool.
1160 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
1161 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1163 @retval A poitner to a string containing the information.
1167 PciIoProtocolDumpInformation (
1168 IN CONST EFI_HANDLE TheHandle
,
1169 IN CONST BOOLEAN Verbose
1173 EFI_PCI_IO_PROTOCOL
*PciIo
;
1190 Status
= gBS
->OpenProtocol (
1192 &gEfiPciIoProtocolGuid
,
1196 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1199 if (EFI_ERROR(Status
)) {
1202 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint8
, 0, sizeof (Pci
), &Pci
);
1203 PciIo
->GetLocation (PciIo
, &Segment
, &Bus
, &Device
, &Function
);
1204 HandleParsingHiiInit ();
1205 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIIO_DUMP_MAIN
), NULL
);
1206 if (GetString
== NULL
) {
1209 RetVal
= CatSPrint (
1220 Pci
.Hdr
.ClassCode
[0],
1221 Pci
.Hdr
.ClassCode
[1],
1222 Pci
.Hdr
.ClassCode
[2]
1224 for (Index
= 0; Index
< sizeof (Pci
); Index
++) {
1225 if ((Index
% 0x10) == 0) {
1226 TempRetVal
= CatSPrint (RetVal
, L
"\r\n %02x", *((UINT8
*) (&Pci
) + Index
));
1228 TempRetVal
= CatSPrint (RetVal
, L
"%02x", *((UINT8
*) (&Pci
) + Index
));
1231 RetVal
= TempRetVal
;
1235 FreePool(GetString
);
1240 Function to dump information about UsbIoProtocol.
1242 This will allocate the return buffer from boot services pool.
1244 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
1245 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1247 @retval A poitner to a string containing the information.
1251 UsbIoProtocolDumpInformation (
1252 IN CONST EFI_HANDLE TheHandle
,
1253 IN CONST BOOLEAN Verbose
1257 EFI_USB_IO_PROTOCOL
*UsbIo
;
1258 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDesc
;
1267 Status
= gBS
->OpenProtocol (
1269 &gEfiUsbIoProtocolGuid
,
1273 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1276 if (EFI_ERROR(Status
)) {
1279 UsbIo
->UsbGetInterfaceDescriptor (UsbIo
, &InterfaceDesc
);
1280 HandleParsingHiiInit ();
1281 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_USBIO_DUMP_MAIN
), NULL
);
1282 if (GetString
== NULL
) {
1285 RetVal
= CatSPrint (
1288 InterfaceDesc
.InterfaceNumber
,
1289 InterfaceDesc
.InterfaceClass
,
1290 InterfaceDesc
.InterfaceSubClass
,
1291 InterfaceDesc
.InterfaceProtocol
1294 FreePool (GetString
);
1299 Function to dump information about EfiAdapterInformation Protocol.
1301 @param[in] TheHandle The handle that has the protocol installed.
1302 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1304 @retval A pointer to a string containing the information.
1308 AdapterInformationDumpInformation (
1309 IN CONST EFI_HANDLE TheHandle
,
1310 IN CONST BOOLEAN Verbose
1314 EFI_ADAPTER_INFORMATION_PROTOCOL
*EfiAdptrInfoProtocol
;
1315 UINTN InfoTypesBufferCount
;
1317 EFI_GUID
*InfoTypesBuffer
;
1322 VOID
*InformationBlock
;
1323 UINTN InformationBlockSize
;
1326 return (CatSPrint(NULL
, L
"AdapterInfo"));
1329 InfoTypesBuffer
= NULL
;
1330 InformationBlock
= NULL
;
1333 Status
= gBS
->OpenProtocol (
1334 (EFI_HANDLE
) (TheHandle
),
1335 &gEfiAdapterInformationProtocolGuid
,
1336 (VOID
**) &EfiAdptrInfoProtocol
,
1339 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1342 if (EFI_ERROR (Status
)) {
1347 // Get a list of supported information types for this instance of the protocol.
1349 Status
= EfiAdptrInfoProtocol
->GetSupportedTypes (
1350 EfiAdptrInfoProtocol
,
1352 &InfoTypesBufferCount
1355 if (EFI_ERROR (Status
)) {
1356 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED
), NULL
);
1357 if (TempStr
!= NULL
) {
1358 RetVal
= CatSPrint (NULL
, TempStr
, Status
);
1363 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SUPP_TYPE_HEADER
), NULL
);
1364 if (TempStr
== NULL
) {
1367 RetVal
= CatSPrint (NULL
, TempStr
);
1368 SHELL_FREE_NON_NULL (TempStr
);
1370 for (GuidIndex
= 0; GuidIndex
< InfoTypesBufferCount
; GuidIndex
++) {
1371 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_NUMBER
), NULL
);
1372 if (TempStr
== NULL
) {
1375 TempRetVal
= CatSPrint (RetVal
, TempStr
, (GuidIndex
+ 1), &InfoTypesBuffer
[GuidIndex
]);
1376 SHELL_FREE_NON_NULL (RetVal
);
1377 RetVal
= TempRetVal
;
1378 SHELL_FREE_NON_NULL (TempStr
);
1380 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_STRING
), NULL
);
1381 if (TempStr
== NULL
) {
1385 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
1386 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoMediaStateGuid");
1387 SHELL_FREE_NON_NULL (RetVal
);
1388 RetVal
= TempRetVal
;
1389 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
1390 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoNetworkBootGuid");
1391 SHELL_FREE_NON_NULL (RetVal
);
1392 RetVal
= TempRetVal
;
1393 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
)) {
1394 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoSanMacAddressGuid");
1395 SHELL_FREE_NON_NULL (RetVal
);
1396 RetVal
= TempRetVal
;
1397 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
)) {
1398 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoUndiIpv6SupportGuid");
1399 SHELL_FREE_NON_NULL (RetVal
);
1400 RetVal
= TempRetVal
;
1403 GuidStr
= GetStringNameFromGuid (&InfoTypesBuffer
[GuidIndex
], NULL
);
1404 if (GuidStr
== NULL
) {
1405 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"UnknownInfoType");
1406 SHELL_FREE_NON_NULL (RetVal
);
1407 RetVal
= TempRetVal
;
1409 SHELL_FREE_NON_NULL (TempStr
);
1410 SHELL_FREE_NON_NULL(GuidStr
);
1412 // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
1416 TempRetVal
= CatSPrint (RetVal
, TempStr
, GuidStr
);
1417 SHELL_FREE_NON_NULL (RetVal
);
1418 RetVal
= TempRetVal
;
1419 SHELL_FREE_NON_NULL(GuidStr
);
1423 SHELL_FREE_NON_NULL (TempStr
);
1425 Status
= EfiAdptrInfoProtocol
->GetInformation (
1426 EfiAdptrInfoProtocol
,
1427 &InfoTypesBuffer
[GuidIndex
],
1429 &InformationBlockSize
1432 if (EFI_ERROR (Status
)) {
1433 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GETINFO_FAILED
), NULL
);
1434 if (TempStr
== NULL
) {
1437 TempRetVal
= CatSPrint (RetVal
, TempStr
, Status
);
1438 SHELL_FREE_NON_NULL (RetVal
);
1439 RetVal
= TempRetVal
;
1441 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
1442 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_MEDIA_STATE
), NULL
);
1443 if (TempStr
== NULL
) {
1446 TempRetVal
= CatSPrint (
1449 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
,
1450 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
1452 SHELL_FREE_NON_NULL (RetVal
);
1453 RetVal
= TempRetVal
;
1454 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
1455 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_NETWORK_BOOT_INFO
), NULL
);
1456 if (TempStr
== NULL
) {
1459 TempRetVal
= CatSPrint (
1462 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4BootCapablity
,
1463 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6BootCapablity
,
1464 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBootCapablity
,
1465 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->OffloadCapability
,
1466 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiMpioCapability
,
1467 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4Boot
,
1468 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6Boot
,
1469 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBoot
1471 SHELL_FREE_NON_NULL (RetVal
);
1472 RetVal
= TempRetVal
;
1473 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
) == TRUE
) {
1474 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO
), NULL
);
1475 if (TempStr
== NULL
) {
1478 TempRetVal
= CatSPrint (
1481 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[0],
1482 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[1],
1483 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[2],
1484 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[3],
1485 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[4],
1486 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[5]
1488 SHELL_FREE_NON_NULL (RetVal
);
1489 RetVal
= TempRetVal
;
1490 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
) == TRUE
) {
1491 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNDI_IPV6_INFO
), NULL
);
1492 if (TempStr
== NULL
) {
1496 TempRetVal
= CatSPrint (
1499 ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT
*)InformationBlock
)->Ipv6Support
1501 SHELL_FREE_NON_NULL (RetVal
);
1502 RetVal
= TempRetVal
;
1504 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE
), NULL
);
1505 if (TempStr
== NULL
) {
1508 TempRetVal
= CatSPrint (RetVal
, TempStr
, &InfoTypesBuffer
[GuidIndex
]);
1509 SHELL_FREE_NON_NULL (RetVal
);
1510 RetVal
= TempRetVal
;
1513 SHELL_FREE_NON_NULL (TempStr
);
1514 SHELL_FREE_NON_NULL (InformationBlock
);
1518 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1522 SHELL_FREE_NON_NULL (RetVal
);
1523 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1524 SHELL_FREE_NON_NULL (InformationBlock
);
1529 Function to dump information about EFI_FIRMWARE_MANAGEMENT_PROTOCOL Protocol.
1531 @param[in] TheHandle The handle that has the protocol installed.
1532 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1534 @retval A pointer to a string containing the information.
1538 FirmwareManagementDumpInformation (
1539 IN CONST EFI_HANDLE TheHandle
,
1540 IN CONST BOOLEAN Verbose
1544 EFI_FIRMWARE_MANAGEMENT_PROTOCOL
*EfiFwMgmtProtocol
;
1545 EFI_FIRMWARE_IMAGE_DESCRIPTOR
*ImageInfo
;
1546 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*ImageInfoV1
;
1547 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*ImageInfoV2
;
1548 UINT64 AttributeSetting
;
1549 UINTN ImageInfoSize
;
1550 UINTN DescriptorSize
;
1551 UINT32 DescriptorVersion
;
1552 UINT32 PackageVersion
;
1553 UINT8 DescriptorCount
;
1557 CHAR16
*PackageVersionName
;
1561 CHAR16
*AttributeSettingStr
;
1563 BOOLEAN AttributeSupported
;
1566 // Initialize local variables
1570 AttributeSetting
= 0;
1572 AttributeSupported
= FALSE
;
1576 PackageVersionName
= NULL
;
1580 AttributeSettingStr
= NULL
;
1583 return (CatSPrint(NULL
, L
"FirmwareManagement"));
1586 Status
= gBS
->OpenProtocol (
1587 (EFI_HANDLE
) (TheHandle
),
1588 &gEfiFirmwareManagementProtocolGuid
,
1589 (VOID
**) &EfiFwMgmtProtocol
,
1592 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1595 if (EFI_ERROR (Status
)) {
1599 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1610 if (Status
== EFI_BUFFER_TOO_SMALL
) {
1611 ImageInfo
= AllocateZeroPool (ImageInfoSize
);
1613 if (ImageInfo
== NULL
) {
1614 Status
= EFI_OUT_OF_RESOURCES
;
1616 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1629 if (EFI_ERROR (Status
)) {
1634 // Decode Image Descriptor data only if its version is supported
1636 if (DescriptorVersion
<= EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION
) {
1638 if (ImageInfo
== NULL
) {
1642 ImageInfoV1
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*)ImageInfo
;
1643 ImageInfoV2
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*)ImageInfo
;
1646 // Set ImageInfoSize in return buffer
1648 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_INFO_SIZE
), NULL
);
1649 if (TempStr
== NULL
) {
1652 RetVal
= CatSPrint (NULL
, TempStr
, ImageInfoSize
);
1653 SHELL_FREE_NON_NULL (TempStr
);
1656 // Set DescriptorVersion in return buffer
1658 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_VERSION
), NULL
);
1659 if (TempStr
== NULL
) {
1662 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorVersion
);
1663 SHELL_FREE_NON_NULL (RetVal
);
1664 RetVal
= TempRetVal
;
1665 SHELL_FREE_NON_NULL (TempStr
);
1668 // Set DescriptorCount in return buffer
1670 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_COUNT
), NULL
);
1671 if (TempStr
== NULL
) {
1674 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorCount
);
1675 SHELL_FREE_NON_NULL (RetVal
);
1676 RetVal
= TempRetVal
;
1677 SHELL_FREE_NON_NULL (TempStr
);
1681 // Set DescriptorSize in return buffer
1683 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_SIZE
), NULL
);
1684 if (TempStr
== NULL
) {
1687 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorSize
);
1688 SHELL_FREE_NON_NULL (RetVal
);
1689 RetVal
= TempRetVal
;
1690 SHELL_FREE_NON_NULL (TempStr
);
1693 // Set PackageVersion in return buffer
1695 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION
), NULL
);
1696 if (TempStr
== NULL
) {
1699 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersion
);
1700 SHELL_FREE_NON_NULL (RetVal
);
1701 RetVal
= TempRetVal
;
1702 SHELL_FREE_NON_NULL (TempStr
);
1705 // Set PackageVersionName in return buffer
1707 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION_NAME
), NULL
);
1708 if (TempStr
== NULL
) {
1711 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersionName
);
1712 SHELL_FREE_NON_NULL (RetVal
);
1713 RetVal
= TempRetVal
;
1714 SHELL_FREE_NON_NULL (TempStr
);
1716 for (Index
= 0; Index
< DescriptorCount
; Index
++) {
1718 // First check if Attribute is supported
1719 // and generate a string for AttributeSetting field
1721 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1722 AttributeSupported
= FALSE
;
1723 AttributeSetting
= 0;
1724 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1725 if (ImageInfoV1
[Index
].AttributesSupported
!= 0x0) {
1726 AttributeSupported
= TRUE
;
1727 AttributeSetting
= ImageInfoV1
[Index
].AttributesSetting
;
1729 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1730 if (ImageInfoV2
[Index
].AttributesSupported
!= 0x0) {
1731 AttributeSupported
= TRUE
;
1732 AttributeSetting
= ImageInfoV2
[Index
].AttributesSetting
;
1735 if (ImageInfo
[Index
].AttributesSupported
!= 0x0) {
1736 AttributeSupported
= TRUE
;
1737 AttributeSetting
= ImageInfo
[Index
].AttributesSetting
;
1741 if (!AttributeSupported
) {
1742 AttributeSettingStr
= CatSPrint (NULL
, L
"None");
1744 AttributeSettingStr
= CatSPrint (NULL
, L
"(");
1746 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
) != 0x0) {
1747 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IMAGE_UPDATABLE");
1748 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1749 AttributeSettingStr
= TempRetVal
;
1751 if ((AttributeSetting
& IMAGE_ATTRIBUTE_RESET_REQUIRED
) != 0x0) {
1752 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_RESET_REQUIRED");
1753 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1754 AttributeSettingStr
= TempRetVal
;
1756 if ((AttributeSetting
& IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
) != 0x0) {
1757 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED");
1758 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1759 AttributeSettingStr
= TempRetVal
;
1761 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IN_USE
) != 0x0) {
1762 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IN_USE");
1763 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1764 AttributeSettingStr
= TempRetVal
;
1766 if ((AttributeSetting
& IMAGE_ATTRIBUTE_UEFI_IMAGE
) != 0x0) {
1767 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_UEFI_IMAGE");
1768 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1769 AttributeSettingStr
= TempRetVal
;
1771 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" )");
1772 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1773 AttributeSettingStr
= TempRetVal
;
1776 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1777 if (ImageInfoV1
[Index
].ImageIndex
!= 0x0) {
1781 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V1
), NULL
);
1782 if (TempStr
== NULL
) {
1785 TempRetVal
= CatSPrint (
1789 ImageInfoV1
[Index
].ImageIndex
,
1790 &ImageInfoV1
[Index
].ImageTypeId
,
1791 ImageInfoV1
[Index
].ImageId
,
1792 ImageInfoV1
[Index
].ImageIdName
,
1793 ImageInfoV1
[Index
].Version
,
1794 ImageInfoV1
[Index
].VersionName
,
1795 ImageInfoV1
[Index
].Size
,
1796 ImageInfoV1
[Index
].AttributesSupported
,
1797 AttributeSettingStr
,
1798 ImageInfoV1
[Index
].Compatibilities
1800 SHELL_FREE_NON_NULL (RetVal
);
1801 RetVal
= TempRetVal
;
1802 SHELL_FREE_NON_NULL (TempStr
);
1803 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1804 if (ImageInfoV2
[Index
].ImageIndex
!= 0x0) {
1808 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V2
), NULL
);
1809 if (TempStr
== NULL
) {
1812 TempRetVal
= CatSPrint (
1816 ImageInfoV2
[Index
].ImageIndex
,
1817 &ImageInfoV2
[Index
].ImageTypeId
,
1818 ImageInfoV2
[Index
].ImageId
,
1819 ImageInfoV2
[Index
].ImageIdName
,
1820 ImageInfoV2
[Index
].Version
,
1821 ImageInfoV2
[Index
].VersionName
,
1822 ImageInfoV2
[Index
].Size
,
1823 ImageInfoV2
[Index
].AttributesSupported
,
1824 AttributeSettingStr
,
1825 ImageInfoV2
[Index
].Compatibilities
,
1826 ImageInfoV2
[Index
].LowestSupportedImageVersion
1828 SHELL_FREE_NON_NULL (RetVal
);
1829 RetVal
= TempRetVal
;
1830 SHELL_FREE_NON_NULL (TempStr
);
1832 if (ImageInfo
[Index
].ImageIndex
!= 0x0) {
1836 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO
), NULL
);
1837 if (TempStr
== NULL
) {
1840 TempRetVal
= CatSPrint (
1844 ImageInfo
[Index
].ImageIndex
,
1845 &ImageInfo
[Index
].ImageTypeId
,
1846 ImageInfo
[Index
].ImageId
,
1847 ImageInfo
[Index
].ImageIdName
,
1848 ImageInfo
[Index
].Version
,
1849 ImageInfo
[Index
].VersionName
,
1850 ImageInfo
[Index
].Size
,
1851 ImageInfo
[Index
].AttributesSupported
,
1852 AttributeSettingStr
,
1853 ImageInfo
[Index
].Compatibilities
,
1854 ImageInfo
[Index
].LowestSupportedImageVersion
,
1855 ImageInfo
[Index
].LastAttemptVersion
,
1856 ImageInfo
[Index
].LastAttemptStatus
,
1857 ImageInfo
[Index
].HardwareInstance
1859 SHELL_FREE_NON_NULL (RetVal
);
1860 RetVal
= TempRetVal
;
1861 SHELL_FREE_NON_NULL (TempStr
);
1866 if (ImageCount
> 0) {
1867 for (Index
=0; Index
<DescriptorCount
; Index
++) {
1868 for (Index1
=Index
+1; Index1
<DescriptorCount
; Index1
++) {
1869 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1870 if (ImageInfoV1
[Index
].ImageId
== ImageInfoV1
[Index1
].ImageId
) {
1873 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1877 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1878 if (ImageInfoV2
[Index
].ImageId
== ImageInfoV2
[Index1
].ImageId
) {
1881 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1886 if (ImageInfo
[Index
].ImageId
== ImageInfo
[Index1
].ImageId
) {
1889 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1900 // Check if ImageId with duplicate value was found
1903 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGEID_NON_UNIQUE
), NULL
);
1904 if (TempStr
== NULL
) {
1907 TempRetVal
= CatSPrint (RetVal
, TempStr
);
1908 SHELL_FREE_NON_NULL (RetVal
);
1909 RetVal
= TempRetVal
;
1910 SHELL_FREE_NON_NULL (TempStr
);
1913 SHELL_FREE_NON_NULL (ImageInfo
);
1914 SHELL_FREE_NON_NULL (PackageVersionName
);
1915 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1920 SHELL_FREE_NON_NULL (RetVal
);
1921 SHELL_FREE_NON_NULL (ImageInfo
);
1922 SHELL_FREE_NON_NULL (PackageVersionName
);
1923 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1929 Function to dump information about Partition Information protocol.
1931 This will allocate the return buffer from boot services pool.
1933 @param[in] TheHandle The handle that has the protocol installed.
1934 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1936 @retval A pointer to a string containing the information.
1940 PartitionInfoProtocolDumpInformation (
1941 IN CONST EFI_HANDLE TheHandle
,
1942 IN CONST BOOLEAN Verbose
1946 EFI_PARTITION_INFO_PROTOCOL
*PartitionInfo
;
1947 CHAR16
*PartitionType
;
1948 CHAR16
*EfiSystemPartition
;
1955 Status
= gBS
->OpenProtocol (
1957 &gEfiPartitionInfoProtocolGuid
,
1958 (VOID
**)&PartitionInfo
,
1961 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1963 if (EFI_ERROR (Status
)) {
1967 HandleParsingHiiInit ();
1969 switch (PartitionInfo
->Type
) {
1970 case PARTITION_TYPE_OTHER
:
1971 PartitionType
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_OTHER
), NULL
);
1973 case PARTITION_TYPE_MBR
:
1974 PartitionType
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_MBR
), NULL
);
1976 case PARTITION_TYPE_GPT
:
1977 PartitionType
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_GPT
), NULL
);
1980 PartitionType
= NULL
;
1983 if (PartitionType
== NULL
) {
1987 if (PartitionInfo
->System
== 1) {
1988 EfiSystemPartition
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_PARTINFO_DUMP_EFI_SYS_PART
), NULL
);
1990 EfiSystemPartition
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_PARTINFO_DUMP_NOT_EFI_SYS_PART
), NULL
);
1992 if (EfiSystemPartition
== NULL
) {
1993 SHELL_FREE_NON_NULL (PartitionType
);
1997 RetVal
= CatSPrint (
2004 SHELL_FREE_NON_NULL (EfiSystemPartition
);
2005 SHELL_FREE_NON_NULL (PartitionType
);
2010 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
2012 #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
2014 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
2017 #define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
2019 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
2022 #define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
2024 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
2026 STATIC CONST EFI_GUID WinNtThunkProtocolGuid
= LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID
;
2027 STATIC CONST EFI_GUID WinNtIoProtocolGuid
= LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID
;
2028 STATIC CONST EFI_GUID WinNtSerialPortGuid
= LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID
;
2031 // Deprecated protocols we dont want to link from IntelFrameworkModulePkg
2033 #define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \
2035 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
2037 #define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \
2039 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \
2041 STATIC CONST EFI_GUID EfiIsaIoProtocolGuid
= LOCAL_EFI_ISA_IO_PROTOCOL_GUID
;
2042 STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid
= LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID
;
2045 STATIC CONST GUID_INFO_BLOCK mGuidStringListNT
[] = {
2046 {STRING_TOKEN(STR_WINNT_THUNK
), (EFI_GUID
*)&WinNtThunkProtocolGuid
, NULL
},
2047 {STRING_TOKEN(STR_WINNT_DRIVER_IO
), (EFI_GUID
*)&WinNtIoProtocolGuid
, NULL
},
2048 {STRING_TOKEN(STR_WINNT_SERIAL_PORT
), (EFI_GUID
*)&WinNtSerialPortGuid
, NULL
},
2052 STATIC CONST GUID_INFO_BLOCK mGuidStringList
[] = {
2053 {STRING_TOKEN(STR_LOADED_IMAGE
), &gEfiLoadedImageProtocolGuid
, LoadedImageProtocolDumpInformation
},
2054 {STRING_TOKEN(STR_DEVICE_PATH
), &gEfiDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
2055 {STRING_TOKEN(STR_IMAGE_PATH
), &gEfiLoadedImageDevicePathProtocolGuid
, LoadedImageDevicePathProtocolDumpInformation
},
2056 {STRING_TOKEN(STR_DEVICE_PATH_UTIL
), &gEfiDevicePathUtilitiesProtocolGuid
, NULL
},
2057 {STRING_TOKEN(STR_DEVICE_PATH_TXT
), &gEfiDevicePathToTextProtocolGuid
, NULL
},
2058 {STRING_TOKEN(STR_DEVICE_PATH_FTXT
), &gEfiDevicePathFromTextProtocolGuid
, NULL
},
2059 {STRING_TOKEN(STR_DEVICE_PATH_PC
), &gEfiPcAnsiGuid
, NULL
},
2060 {STRING_TOKEN(STR_DEVICE_PATH_VT100
), &gEfiVT100Guid
, NULL
},
2061 {STRING_TOKEN(STR_DEVICE_PATH_VT100P
), &gEfiVT100PlusGuid
, NULL
},
2062 {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8
), &gEfiVTUTF8Guid
, NULL
},
2063 {STRING_TOKEN(STR_DRIVER_BINDING
), &gEfiDriverBindingProtocolGuid
, NULL
},
2064 {STRING_TOKEN(STR_PLATFORM_OVERRIDE
), &gEfiPlatformDriverOverrideProtocolGuid
, NULL
},
2065 {STRING_TOKEN(STR_BUS_OVERRIDE
), &gEfiBusSpecificDriverOverrideProtocolGuid
, BusSpecificDriverOverrideProtocolDumpInformation
},
2066 {STRING_TOKEN(STR_DRIVER_DIAG
), &gEfiDriverDiagnosticsProtocolGuid
, NULL
},
2067 {STRING_TOKEN(STR_DRIVER_DIAG2
), &gEfiDriverDiagnostics2ProtocolGuid
, NULL
},
2068 {STRING_TOKEN(STR_DRIVER_CN
), &gEfiComponentNameProtocolGuid
, NULL
},
2069 {STRING_TOKEN(STR_DRIVER_CN2
), &gEfiComponentName2ProtocolGuid
, NULL
},
2070 {STRING_TOKEN(STR_PLAT_DRV_CFG
), &gEfiPlatformToDriverConfigurationProtocolGuid
, NULL
},
2071 {STRING_TOKEN(STR_DRIVER_VERSION
), &gEfiDriverSupportedEfiVersionProtocolGuid
, DriverEfiVersionProtocolDumpInformation
},
2072 {STRING_TOKEN(STR_TXT_IN
), &gEfiSimpleTextInProtocolGuid
, NULL
},
2073 {STRING_TOKEN(STR_TXT_IN_EX
), &gEfiSimpleTextInputExProtocolGuid
, NULL
},
2074 {STRING_TOKEN(STR_TXT_OUT
), &gEfiSimpleTextOutProtocolGuid
, TxtOutProtocolDumpInformation
},
2075 {STRING_TOKEN(STR_SIM_POINTER
), &gEfiSimplePointerProtocolGuid
, NULL
},
2076 {STRING_TOKEN(STR_ABS_POINTER
), &gEfiAbsolutePointerProtocolGuid
, NULL
},
2077 {STRING_TOKEN(STR_SERIAL_IO
), &gEfiSerialIoProtocolGuid
, NULL
},
2078 {STRING_TOKEN(STR_GRAPHICS_OUTPUT
), &gEfiGraphicsOutputProtocolGuid
, GraphicsOutputProtocolDumpInformation
},
2079 {STRING_TOKEN(STR_EDID_DISCOVERED
), &gEfiEdidDiscoveredProtocolGuid
, EdidDiscoveredProtocolDumpInformation
},
2080 {STRING_TOKEN(STR_EDID_ACTIVE
), &gEfiEdidActiveProtocolGuid
, EdidActiveProtocolDumpInformation
},
2081 {STRING_TOKEN(STR_EDID_OVERRIDE
), &gEfiEdidOverrideProtocolGuid
, NULL
},
2082 {STRING_TOKEN(STR_CON_IN
), &gEfiConsoleInDeviceGuid
, NULL
},
2083 {STRING_TOKEN(STR_CON_OUT
), &gEfiConsoleOutDeviceGuid
, NULL
},
2084 {STRING_TOKEN(STR_STD_ERR
), &gEfiStandardErrorDeviceGuid
, NULL
},
2085 {STRING_TOKEN(STR_LOAD_FILE
), &gEfiLoadFileProtocolGuid
, NULL
},
2086 {STRING_TOKEN(STR_LOAD_FILE2
), &gEfiLoadFile2ProtocolGuid
, NULL
},
2087 {STRING_TOKEN(STR_SIMPLE_FILE_SYS
), &gEfiSimpleFileSystemProtocolGuid
, NULL
},
2088 {STRING_TOKEN(STR_TAPE_IO
), &gEfiTapeIoProtocolGuid
, NULL
},
2089 {STRING_TOKEN(STR_DISK_IO
), &gEfiDiskIoProtocolGuid
, NULL
},
2090 {STRING_TOKEN(STR_BLK_IO
), &gEfiBlockIoProtocolGuid
, BlockIoProtocolDumpInformation
},
2091 {STRING_TOKEN(STR_UC
), &gEfiUnicodeCollationProtocolGuid
, NULL
},
2092 {STRING_TOKEN(STR_UC2
), &gEfiUnicodeCollation2ProtocolGuid
, NULL
},
2093 {STRING_TOKEN(STR_PCIRB_IO
), &gEfiPciRootBridgeIoProtocolGuid
, PciRootBridgeIoDumpInformation
},
2094 {STRING_TOKEN(STR_PCI_IO
), &gEfiPciIoProtocolGuid
, PciIoProtocolDumpInformation
},
2095 {STRING_TOKEN(STR_SCSI_PT
), &gEfiScsiPassThruProtocolGuid
, NULL
},
2096 {STRING_TOKEN(STR_SCSI_IO
), &gEfiScsiIoProtocolGuid
, NULL
},
2097 {STRING_TOKEN(STR_SCSI_PT_EXT
), &gEfiExtScsiPassThruProtocolGuid
, NULL
},
2098 {STRING_TOKEN(STR_ISCSI
), &gEfiIScsiInitiatorNameProtocolGuid
, NULL
},
2099 {STRING_TOKEN(STR_USB_IO
), &gEfiUsbIoProtocolGuid
, UsbIoProtocolDumpInformation
},
2100 {STRING_TOKEN(STR_USB_HC
), &gEfiUsbHcProtocolGuid
, NULL
},
2101 {STRING_TOKEN(STR_USB_HC2
), &gEfiUsb2HcProtocolGuid
, NULL
},
2102 {STRING_TOKEN(STR_DEBUG_SUPPORT
), &gEfiDebugSupportProtocolGuid
, DebugSupportProtocolDumpInformation
},
2103 {STRING_TOKEN(STR_DEBUG_PORT
), &gEfiDebugPortProtocolGuid
, NULL
},
2104 {STRING_TOKEN(STR_DECOMPRESS
), &gEfiDecompressProtocolGuid
, NULL
},
2105 {STRING_TOKEN(STR_ACPI_TABLE
), &gEfiAcpiTableProtocolGuid
, NULL
},
2106 {STRING_TOKEN(STR_EBC_INTERPRETER
), &gEfiEbcProtocolGuid
, NULL
},
2107 {STRING_TOKEN(STR_SNP
), &gEfiSimpleNetworkProtocolGuid
, NULL
},
2108 {STRING_TOKEN(STR_NII
), &gEfiNetworkInterfaceIdentifierProtocolGuid
, NULL
},
2109 {STRING_TOKEN(STR_NII_31
), &gEfiNetworkInterfaceIdentifierProtocolGuid_31
, NULL
},
2110 {STRING_TOKEN(STR_PXE_BC
), &gEfiPxeBaseCodeProtocolGuid
, NULL
},
2111 {STRING_TOKEN(STR_PXE_CB
), &gEfiPxeBaseCodeCallbackProtocolGuid
, NULL
},
2112 {STRING_TOKEN(STR_BIS
), &gEfiBisProtocolGuid
, NULL
},
2113 {STRING_TOKEN(STR_MNP_SB
), &gEfiManagedNetworkServiceBindingProtocolGuid
, NULL
},
2114 {STRING_TOKEN(STR_MNP
), &gEfiManagedNetworkProtocolGuid
, NULL
},
2115 {STRING_TOKEN(STR_ARP_SB
), &gEfiArpServiceBindingProtocolGuid
, NULL
},
2116 {STRING_TOKEN(STR_ARP
), &gEfiArpProtocolGuid
, NULL
},
2117 {STRING_TOKEN(STR_DHCPV4_SB
), &gEfiDhcp4ServiceBindingProtocolGuid
, NULL
},
2118 {STRING_TOKEN(STR_DHCPV4
), &gEfiDhcp4ProtocolGuid
, NULL
},
2119 {STRING_TOKEN(STR_TCPV4_SB
), &gEfiTcp4ServiceBindingProtocolGuid
, NULL
},
2120 {STRING_TOKEN(STR_TCPV4
), &gEfiTcp4ProtocolGuid
, NULL
},
2121 {STRING_TOKEN(STR_IPV4_SB
), &gEfiIp4ServiceBindingProtocolGuid
, NULL
},
2122 {STRING_TOKEN(STR_IPV4
), &gEfiIp4ProtocolGuid
, NULL
},
2123 {STRING_TOKEN(STR_IPV4_CFG
), &gEfiIp4ConfigProtocolGuid
, NULL
},
2124 {STRING_TOKEN(STR_IPV4_CFG2
), &gEfiIp4Config2ProtocolGuid
, NULL
},
2125 {STRING_TOKEN(STR_UDPV4_SB
), &gEfiUdp4ServiceBindingProtocolGuid
, NULL
},
2126 {STRING_TOKEN(STR_UDPV4
), &gEfiUdp4ProtocolGuid
, NULL
},
2127 {STRING_TOKEN(STR_MTFTPV4_SB
), &gEfiMtftp4ServiceBindingProtocolGuid
, NULL
},
2128 {STRING_TOKEN(STR_MTFTPV4
), &gEfiMtftp4ProtocolGuid
, NULL
},
2129 {STRING_TOKEN(STR_AUTH_INFO
), &gEfiAuthenticationInfoProtocolGuid
, NULL
},
2130 {STRING_TOKEN(STR_HASH_SB
), &gEfiHashServiceBindingProtocolGuid
, NULL
},
2131 {STRING_TOKEN(STR_HASH
), &gEfiHashProtocolGuid
, NULL
},
2132 {STRING_TOKEN(STR_HII_FONT
), &gEfiHiiFontProtocolGuid
, NULL
},
2133 {STRING_TOKEN(STR_HII_STRING
), &gEfiHiiStringProtocolGuid
, NULL
},
2134 {STRING_TOKEN(STR_HII_IMAGE
), &gEfiHiiImageProtocolGuid
, NULL
},
2135 {STRING_TOKEN(STR_HII_DATABASE
), &gEfiHiiDatabaseProtocolGuid
, NULL
},
2136 {STRING_TOKEN(STR_HII_CONFIG_ROUT
), &gEfiHiiConfigRoutingProtocolGuid
, NULL
},
2137 {STRING_TOKEN(STR_HII_CONFIG_ACC
), &gEfiHiiConfigAccessProtocolGuid
, NULL
},
2138 {STRING_TOKEN(STR_HII_FORM_BROWSER2
), &gEfiFormBrowser2ProtocolGuid
, NULL
},
2139 {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE
), &gEfiDriverFamilyOverrideProtocolGuid
, NULL
},
2140 {STRING_TOKEN(STR_PCD
), &gPcdProtocolGuid
, NULL
},
2141 {STRING_TOKEN(STR_TCG
), &gEfiTcgProtocolGuid
, NULL
},
2142 {STRING_TOKEN(STR_HII_PACKAGE_LIST
), &gEfiHiiPackageListProtocolGuid
, NULL
},
2145 // the ones under this are deprecated by the current UEFI Spec, but may be found anyways...
2147 {STRING_TOKEN(STR_SHELL_INTERFACE
), &gEfiShellInterfaceGuid
, NULL
},
2148 {STRING_TOKEN(STR_SHELL_ENV2
), &gEfiShellEnvironment2Guid
, NULL
},
2149 {STRING_TOKEN(STR_SHELL_ENV
), &gEfiShellEnvironment2Guid
, NULL
},
2150 {STRING_TOKEN(STR_DEVICE_IO
), &gEfiDeviceIoProtocolGuid
, NULL
},
2151 {STRING_TOKEN(STR_UGA_DRAW
), &gEfiUgaDrawProtocolGuid
, NULL
},
2152 {STRING_TOKEN(STR_UGA_IO
), &gEfiUgaIoProtocolGuid
, NULL
},
2153 {STRING_TOKEN(STR_ESP
), &gEfiPartTypeSystemPartGuid
, NULL
},
2154 {STRING_TOKEN(STR_GPT_NBR
), &gEfiPartTypeLegacyMbrGuid
, NULL
},
2155 {STRING_TOKEN(STR_DRIVER_CONFIG
), &gEfiDriverConfigurationProtocolGuid
, NULL
},
2156 {STRING_TOKEN(STR_DRIVER_CONFIG2
), &gEfiDriverConfiguration2ProtocolGuid
, NULL
},
2159 // these are using local (non-global) definitions to reduce package dependancy.
2161 {STRING_TOKEN(STR_ISA_IO
), (EFI_GUID
*)&EfiIsaIoProtocolGuid
, NULL
},
2162 {STRING_TOKEN(STR_ISA_ACPI
), (EFI_GUID
*)&EfiIsaAcpiProtocolGuid
, NULL
},
2165 // the ones under this are GUID identified structs, not protocols
2167 {STRING_TOKEN(STR_FILE_INFO
), &gEfiFileInfoGuid
, NULL
},
2168 {STRING_TOKEN(STR_FILE_SYS_INFO
), &gEfiFileSystemInfoGuid
, NULL
},
2171 // the ones under this are misc GUIDS.
2173 {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE
), &gEfiGlobalVariableGuid
, NULL
},
2178 {STRING_TOKEN(STR_IP6_SB
), &gEfiIp6ServiceBindingProtocolGuid
, NULL
},
2179 {STRING_TOKEN(STR_IP6
), &gEfiIp6ProtocolGuid
, NULL
},
2180 {STRING_TOKEN(STR_IP6_CONFIG
), &gEfiIp6ConfigProtocolGuid
, NULL
},
2181 {STRING_TOKEN(STR_MTFTP6_SB
), &gEfiMtftp6ServiceBindingProtocolGuid
, NULL
},
2182 {STRING_TOKEN(STR_MTFTP6
), &gEfiMtftp6ProtocolGuid
, NULL
},
2183 {STRING_TOKEN(STR_DHCP6_SB
), &gEfiDhcp6ServiceBindingProtocolGuid
, NULL
},
2184 {STRING_TOKEN(STR_DHCP6
), &gEfiDhcp6ProtocolGuid
, NULL
},
2185 {STRING_TOKEN(STR_UDP6_SB
), &gEfiUdp6ServiceBindingProtocolGuid
, NULL
},
2186 {STRING_TOKEN(STR_UDP6
), &gEfiUdp6ProtocolGuid
, NULL
},
2187 {STRING_TOKEN(STR_TCP6_SB
), &gEfiTcp6ServiceBindingProtocolGuid
, NULL
},
2188 {STRING_TOKEN(STR_TCP6
), &gEfiTcp6ProtocolGuid
, NULL
},
2189 {STRING_TOKEN(STR_VLAN_CONFIG
), &gEfiVlanConfigProtocolGuid
, NULL
},
2190 {STRING_TOKEN(STR_EAP
), &gEfiEapProtocolGuid
, NULL
},
2191 {STRING_TOKEN(STR_EAP_MGMT
), &gEfiEapManagementProtocolGuid
, NULL
},
2192 {STRING_TOKEN(STR_FTP4_SB
), &gEfiFtp4ServiceBindingProtocolGuid
, NULL
},
2193 {STRING_TOKEN(STR_FTP4
), &gEfiFtp4ProtocolGuid
, NULL
},
2194 {STRING_TOKEN(STR_IP_SEC_CONFIG
), &gEfiIpSecConfigProtocolGuid
, NULL
},
2195 {STRING_TOKEN(STR_DH
), &gEfiDriverHealthProtocolGuid
, NULL
},
2196 {STRING_TOKEN(STR_DEF_IMG_LOAD
), &gEfiDeferredImageLoadProtocolGuid
, NULL
},
2197 {STRING_TOKEN(STR_USER_CRED
), &gEfiUserCredentialProtocolGuid
, NULL
},
2198 {STRING_TOKEN(STR_USER_MNGR
), &gEfiUserManagerProtocolGuid
, NULL
},
2199 {STRING_TOKEN(STR_ATA_PASS_THRU
), &gEfiAtaPassThruProtocolGuid
, NULL
},
2204 {STRING_TOKEN(STR_FW_MGMT
), &gEfiFirmwareManagementProtocolGuid
, FirmwareManagementDumpInformation
},
2205 {STRING_TOKEN(STR_IP_SEC
), &gEfiIpSecProtocolGuid
, NULL
},
2206 {STRING_TOKEN(STR_IP_SEC2
), &gEfiIpSec2ProtocolGuid
, NULL
},
2211 {STRING_TOKEN(STR_KMS
), &gEfiKmsProtocolGuid
, NULL
},
2212 {STRING_TOKEN(STR_BLK_IO2
), &gEfiBlockIo2ProtocolGuid
, NULL
},
2213 {STRING_TOKEN(STR_SSC
), &gEfiStorageSecurityCommandProtocolGuid
, NULL
},
2214 {STRING_TOKEN(STR_UCRED2
), &gEfiUserCredential2ProtocolGuid
, NULL
},
2219 {STRING_TOKEN(STR_DISK_IO2
), &gEfiDiskIo2ProtocolGuid
, NULL
},
2220 {STRING_TOKEN(STR_ADAPTER_INFO
), &gEfiAdapterInformationProtocolGuid
, AdapterInformationDumpInformation
},
2225 {STRING_TOKEN(STR_TLS_SB
), &gEfiTlsServiceBindingProtocolGuid
, NULL
},
2226 {STRING_TOKEN(STR_TLS
), &gEfiTlsProtocolGuid
, NULL
},
2227 {STRING_TOKEN(STR_TLS_CONFIG
), &gEfiTlsConfigurationProtocolGuid
, NULL
},
2228 {STRING_TOKEN(STR_SUPPLICANT_SB
), &gEfiSupplicantServiceBindingProtocolGuid
, NULL
},
2229 {STRING_TOKEN(STR_SUPPLICANT
), &gEfiSupplicantProtocolGuid
, NULL
},
2234 {STRING_TOKEN(STR_WIFI2
), &gEfiWiFi2ProtocolGuid
, NULL
},
2235 {STRING_TOKEN(STR_RAMDISK
), &gEfiRamDiskProtocolGuid
, NULL
},
2236 {STRING_TOKEN(STR_HII_ID
), &gEfiHiiImageDecoderProtocolGuid
, NULL
},
2237 {STRING_TOKEN(STR_HII_IE
), &gEfiHiiImageExProtocolGuid
, NULL
},
2238 {STRING_TOKEN(STR_SD_MPT
), &gEfiSdMmcPassThruProtocolGuid
, NULL
},
2239 {STRING_TOKEN(STR_ERASE_BLOCK
), &gEfiEraseBlockProtocolGuid
, NULL
},
2244 {STRING_TOKEN(STR_BLUETOOTH_ATTR
), &gEfiBluetoothAttributeProtocolGuid
, NULL
},
2245 {STRING_TOKEN(STR_BLUETOOTH_ATTR_SB
), &gEfiBluetoothAttributeServiceBindingProtocolGuid
, NULL
},
2246 {STRING_TOKEN(STR_BLUETOOTH_LE_CONFIG
), &gEfiBluetoothLeConfigProtocolGuid
, NULL
},
2247 {STRING_TOKEN(STR_UFS_DEV_CONFIG
), &gEfiUfsDeviceConfigProtocolGuid
, NULL
},
2248 {STRING_TOKEN(STR_HTTP_BOOT_CALL
), &gEfiHttpBootCallbackProtocolGuid
, NULL
},
2249 {STRING_TOKEN(STR_RESET_NOTI
), &gEfiResetNotificationProtocolGuid
, NULL
},
2250 {STRING_TOKEN(STR_PARTITION_INFO
), &gEfiPartitionInfoProtocolGuid
, PartitionInfoProtocolDumpInformation
},
2251 {STRING_TOKEN(STR_HII_POPUP
), &gEfiHiiPopupProtocolGuid
, NULL
},
2256 {STRING_TOKEN(STR_REST_EX
), &gEfiRestExProtocolGuid
, NULL
},
2257 {STRING_TOKEN(STR_REDFISH_DISCOVER
), &gEfiRedfishDiscoverProtocolGuid
, NULL
},
2262 {STRING_TOKEN(STR_IDE_CONT_INIT
), &gEfiIdeControllerInitProtocolGuid
, NULL
},
2263 {STRING_TOKEN(STR_DISK_INFO
), &gEfiDiskInfoProtocolGuid
, NULL
},
2268 {STRING_TOKEN(STR_BDS_ARCH
), &gEfiBdsArchProtocolGuid
, NULL
},
2269 {STRING_TOKEN(STR_CPU_ARCH
), &gEfiCpuArchProtocolGuid
, NULL
},
2270 {STRING_TOKEN(STR_MET_ARCH
), &gEfiMetronomeArchProtocolGuid
, NULL
},
2271 {STRING_TOKEN(STR_MON_ARCH
), &gEfiMonotonicCounterArchProtocolGuid
, NULL
},
2272 {STRING_TOKEN(STR_RTC_ARCH
), &gEfiRealTimeClockArchProtocolGuid
, NULL
},
2273 {STRING_TOKEN(STR_RESET_ARCH
), &gEfiResetArchProtocolGuid
, NULL
},
2274 {STRING_TOKEN(STR_RT_ARCH
), &gEfiRuntimeArchProtocolGuid
, NULL
},
2275 {STRING_TOKEN(STR_SEC_ARCH
), &gEfiSecurityArchProtocolGuid
, NULL
},
2276 {STRING_TOKEN(STR_TIMER_ARCH
), &gEfiTimerArchProtocolGuid
, NULL
},
2277 {STRING_TOKEN(STR_VAR_ARCH
), &gEfiVariableWriteArchProtocolGuid
, NULL
},
2278 {STRING_TOKEN(STR_V_ARCH
), &gEfiVariableArchProtocolGuid
, NULL
},
2279 {STRING_TOKEN(STR_SECP
), &gEfiSecurityPolicyProtocolGuid
, NULL
},
2280 {STRING_TOKEN(STR_WDT_ARCH
), &gEfiWatchdogTimerArchProtocolGuid
, NULL
},
2281 {STRING_TOKEN(STR_SCR
), &gEfiStatusCodeRuntimeProtocolGuid
, NULL
},
2282 {STRING_TOKEN(STR_SMB_HC
), &gEfiSmbusHcProtocolGuid
, NULL
},
2283 {STRING_TOKEN(STR_FV_2
), &gEfiFirmwareVolume2ProtocolGuid
, NULL
},
2284 {STRING_TOKEN(STR_FV_BLOCK
), &gEfiFirmwareVolumeBlockProtocolGuid
, NULL
},
2285 {STRING_TOKEN(STR_CAP_ARCH
), &gEfiCapsuleArchProtocolGuid
, NULL
},
2286 {STRING_TOKEN(STR_MP_SERVICE
), &gEfiMpServiceProtocolGuid
, NULL
},
2287 {STRING_TOKEN(STR_HBRAP
), &gEfiPciHostBridgeResourceAllocationProtocolGuid
, NULL
},
2288 {STRING_TOKEN(STR_PCIP
), &gEfiPciPlatformProtocolGuid
, NULL
},
2289 {STRING_TOKEN(STR_PCIO
), &gEfiPciOverrideProtocolGuid
, NULL
},
2290 {STRING_TOKEN(STR_PCIE
), &gEfiPciEnumerationCompleteProtocolGuid
, NULL
},
2291 {STRING_TOKEN(STR_IPCID
), &gEfiIncompatiblePciDeviceSupportProtocolGuid
, NULL
},
2292 {STRING_TOKEN(STR_PCIHPI
), &gEfiPciHotPlugInitProtocolGuid
, NULL
},
2293 {STRING_TOKEN(STR_PCIHPR
), &gEfiPciHotPlugRequestProtocolGuid
, NULL
},
2294 {STRING_TOKEN(STR_SMBIOS
), &gEfiSmbiosProtocolGuid
, NULL
},
2295 {STRING_TOKEN(STR_S3_SAVE
), &gEfiS3SaveStateProtocolGuid
, NULL
},
2296 {STRING_TOKEN(STR_S3_S_SMM
), &gEfiS3SmmSaveStateProtocolGuid
, NULL
},
2297 {STRING_TOKEN(STR_RSC
), &gEfiRscHandlerProtocolGuid
, NULL
},
2298 {STRING_TOKEN(STR_S_RSC
), &gEfiSmmRscHandlerProtocolGuid
, NULL
},
2299 {STRING_TOKEN(STR_ACPI_SDT
), &gEfiAcpiSdtProtocolGuid
, NULL
},
2300 {STRING_TOKEN(STR_SIO
), &gEfiSioProtocolGuid
, NULL
},
2301 {STRING_TOKEN(STR_S_CPU2
), &gEfiSmmCpuIo2ProtocolGuid
, NULL
},
2302 {STRING_TOKEN(STR_S_BASE2
), &gEfiSmmBase2ProtocolGuid
, NULL
},
2303 {STRING_TOKEN(STR_S_ACC_2
), &gEfiSmmAccess2ProtocolGuid
, NULL
},
2304 {STRING_TOKEN(STR_S_CON_2
), &gEfiSmmControl2ProtocolGuid
, NULL
},
2305 {STRING_TOKEN(STR_S_CONFIG
), &gEfiSmmConfigurationProtocolGuid
, NULL
},
2306 {STRING_TOKEN(STR_S_RTL
), &gEfiSmmReadyToLockProtocolGuid
, NULL
},
2307 {STRING_TOKEN(STR_DS_RTL
), &gEfiDxeSmmReadyToLockProtocolGuid
, NULL
},
2308 {STRING_TOKEN(STR_S_COMM
), &gEfiSmmCommunicationProtocolGuid
, NULL
},
2309 {STRING_TOKEN(STR_S_STAT
), &gEfiSmmStatusCodeProtocolGuid
, NULL
},
2310 {STRING_TOKEN(STR_S_CPU
), &gEfiSmmCpuProtocolGuid
, NULL
},
2311 {STRING_TOKEN(STR_S_PCIRBIO
), &gEfiSmmPciRootBridgeIoProtocolGuid
, NULL
},
2312 {STRING_TOKEN(STR_S_SWD
), &gEfiSmmSwDispatch2ProtocolGuid
, NULL
},
2313 {STRING_TOKEN(STR_S_SXD
), &gEfiSmmSxDispatch2ProtocolGuid
, NULL
},
2314 {STRING_TOKEN(STR_S_PTD2
), &gEfiSmmPeriodicTimerDispatch2ProtocolGuid
, NULL
},
2315 {STRING_TOKEN(STR_S_UD2
), &gEfiSmmUsbDispatch2ProtocolGuid
, NULL
},
2316 {STRING_TOKEN(STR_S_GD2
), &gEfiSmmGpiDispatch2ProtocolGuid
, NULL
},
2317 {STRING_TOKEN(STR_S_SBD2
), &gEfiSmmStandbyButtonDispatch2ProtocolGuid
, NULL
},
2318 {STRING_TOKEN(STR_S_PBD2
), &gEfiSmmPowerButtonDispatch2ProtocolGuid
, NULL
},
2319 {STRING_TOKEN(STR_S_ITD2
), &gEfiSmmIoTrapDispatch2ProtocolGuid
, NULL
},
2320 {STRING_TOKEN(STR_PCD
), &gEfiPcdProtocolGuid
, NULL
},
2321 {STRING_TOKEN(STR_FVB2
), &gEfiFirmwareVolumeBlock2ProtocolGuid
, NULL
},
2322 {STRING_TOKEN(STR_CPUIO2
), &gEfiCpuIo2ProtocolGuid
, NULL
},
2323 {STRING_TOKEN(STR_LEGACY_R2
), &gEfiLegacyRegion2ProtocolGuid
, NULL
},
2324 {STRING_TOKEN(STR_S2ARCH
), &gEfiSecurity2ArchProtocolGuid
, NULL
},
2325 {STRING_TOKEN(STR_EODXE
), &gEfiSmmEndOfDxeProtocolGuid
, NULL
},
2326 {STRING_TOKEN(STR_ISAHC
), &gEfiIsaHcProtocolGuid
, NULL
},
2327 {STRING_TOKEN(STR_ISAHC_B
), &gEfiIsaHcServiceBindingProtocolGuid
, NULL
},
2328 {STRING_TOKEN(STR_SIO_C
), &gEfiSioControlProtocolGuid
, NULL
},
2329 {STRING_TOKEN(STR_GET_PCD
), &gEfiGetPcdInfoProtocolGuid
, NULL
},
2330 {STRING_TOKEN(STR_I2C_M
), &gEfiI2cMasterProtocolGuid
, NULL
},
2331 {STRING_TOKEN(STR_I2CIO
), &gEfiI2cIoProtocolGuid
, NULL
},
2332 {STRING_TOKEN(STR_I2CEN
), &gEfiI2cEnumerateProtocolGuid
, NULL
},
2333 {STRING_TOKEN(STR_I2C_H
), &gEfiI2cHostProtocolGuid
, NULL
},
2334 {STRING_TOKEN(STR_I2C_BCM
), &gEfiI2cBusConfigurationManagementProtocolGuid
, NULL
},
2335 {STRING_TOKEN(STR_TCG2
), &gEfiTcg2ProtocolGuid
, NULL
},
2336 {STRING_TOKEN(STR_TIMESTAMP
), &gEfiTimestampProtocolGuid
, NULL
},
2337 {STRING_TOKEN(STR_RNG
), &gEfiRngProtocolGuid
, NULL
},
2338 {STRING_TOKEN(STR_NVMEPT
), &gEfiNvmExpressPassThruProtocolGuid
, NULL
},
2339 {STRING_TOKEN(STR_H2_SB
), &gEfiHash2ServiceBindingProtocolGuid
, NULL
},
2340 {STRING_TOKEN(STR_HASH2
), &gEfiHash2ProtocolGuid
, NULL
},
2341 {STRING_TOKEN(STR_BIO_C
), &gEfiBlockIoCryptoProtocolGuid
, NULL
},
2342 {STRING_TOKEN(STR_SCR
), &gEfiSmartCardReaderProtocolGuid
, NULL
},
2343 {STRING_TOKEN(STR_SCE
), &gEfiSmartCardEdgeProtocolGuid
, NULL
},
2344 {STRING_TOKEN(STR_USB_FIO
), &gEfiUsbFunctionIoProtocolGuid
, NULL
},
2345 {STRING_TOKEN(STR_BC_HC
), &gEfiBluetoothHcProtocolGuid
, NULL
},
2346 {STRING_TOKEN(STR_BC_IO_SB
), &gEfiBluetoothIoServiceBindingProtocolGuid
, NULL
},
2347 {STRING_TOKEN(STR_BC_IO
), &gEfiBluetoothIoProtocolGuid
, NULL
},
2348 {STRING_TOKEN(STR_BC_C
), &gEfiBluetoothConfigProtocolGuid
, NULL
},
2349 {STRING_TOKEN(STR_REG_EXP
), &gEfiRegularExpressionProtocolGuid
, NULL
},
2350 {STRING_TOKEN(STR_B_MGR_P
), &gEfiBootManagerPolicyProtocolGuid
, NULL
},
2351 {STRING_TOKEN(STR_CKH
), &gEfiConfigKeywordHandlerProtocolGuid
, NULL
},
2352 {STRING_TOKEN(STR_WIFI
), &gEfiWiFiProtocolGuid
, NULL
},
2353 {STRING_TOKEN(STR_EAP_M
), &gEfiEapManagement2ProtocolGuid
, NULL
},
2354 {STRING_TOKEN(STR_EAP_C
), &gEfiEapConfigurationProtocolGuid
, NULL
},
2355 {STRING_TOKEN(STR_PKCS7
), &gEfiPkcs7VerifyProtocolGuid
, NULL
},
2356 {STRING_TOKEN(STR_NET_DNS4_SB
), &gEfiDns4ServiceBindingProtocolGuid
, NULL
},
2357 {STRING_TOKEN(STR_NET_DNS4
), &gEfiDns4ProtocolGuid
, NULL
},
2358 {STRING_TOKEN(STR_NET_DNS6_SB
), &gEfiDns6ServiceBindingProtocolGuid
, NULL
},
2359 {STRING_TOKEN(STR_NET_DNS6
), &gEfiDns6ProtocolGuid
, NULL
},
2360 {STRING_TOKEN(STR_NET_HTTP_SB
), &gEfiHttpServiceBindingProtocolGuid
, NULL
},
2361 {STRING_TOKEN(STR_NET_HTTP
), &gEfiHttpProtocolGuid
, NULL
},
2362 {STRING_TOKEN(STR_NET_HTTP_U
), &gEfiHttpUtilitiesProtocolGuid
, NULL
},
2363 {STRING_TOKEN(STR_REST
), &gEfiRestProtocolGuid
, NULL
},
2368 {STRING_TOKEN(STR_MM_EOD
), &gEfiMmEndOfDxeProtocolGuid
, NULL
},
2369 {STRING_TOKEN(STR_MM_ITD
), &gEfiMmIoTrapDispatchProtocolGuid
, NULL
},
2370 {STRING_TOKEN(STR_MM_PBD
), &gEfiMmPowerButtonDispatchProtocolGuid
, NULL
},
2371 {STRING_TOKEN(STR_MM_SBD
), &gEfiMmStandbyButtonDispatchProtocolGuid
, NULL
},
2372 {STRING_TOKEN(STR_MM_GD
), &gEfiMmGpiDispatchProtocolGuid
, NULL
},
2373 {STRING_TOKEN(STR_MM_UD
), &gEfiMmUsbDispatchProtocolGuid
, NULL
},
2374 {STRING_TOKEN(STR_MM_PTD
), &gEfiMmPeriodicTimerDispatchProtocolGuid
, NULL
},
2375 {STRING_TOKEN(STR_MM_SXD
), &gEfiMmSxDispatchProtocolGuid
, NULL
},
2376 {STRING_TOKEN(STR_MM_SWD
), &gEfiMmSwDispatchProtocolGuid
, NULL
},
2377 {STRING_TOKEN(STR_MM_PRBI
), &gEfiMmPciRootBridgeIoProtocolGuid
, NULL
},
2378 {STRING_TOKEN(STR_MM_CPU
), &gEfiMmCpuProtocolGuid
, NULL
},
2379 {STRING_TOKEN(STR_MM_STACODE
), &gEfiMmStatusCodeProtocolGuid
, NULL
},
2380 {STRING_TOKEN(STR_DXEMM_RTL
), &gEfiDxeMmReadyToLockProtocolGuid
, NULL
},
2381 {STRING_TOKEN(STR_MM_CONFIG
), &gEfiMmConfigurationProtocolGuid
, NULL
},
2382 {STRING_TOKEN(STR_MM_RTL
), &gEfiMmReadyToLockProtocolGuid
, NULL
},
2383 {STRING_TOKEN(STR_MM_CONTROL
), &gEfiMmControlProtocolGuid
, NULL
},
2384 {STRING_TOKEN(STR_MM_ACCESS
), &gEfiMmAccessProtocolGuid
, NULL
},
2385 {STRING_TOKEN(STR_MM_BASE
), &gEfiMmBaseProtocolGuid
, NULL
},
2386 {STRING_TOKEN(STR_MM_CPUIO
), &gEfiMmCpuIoProtocolGuid
, NULL
},
2387 {STRING_TOKEN(STR_MM_RH
), &gEfiMmRscHandlerProtocolGuid
, NULL
},
2388 {STRING_TOKEN(STR_MM_COM
), &gEfiMmCommunicationProtocolGuid
, NULL
},
2391 // UEFI Shell Spec 2.0
2393 {STRING_TOKEN(STR_SHELL_PARAMETERS
), &gEfiShellParametersProtocolGuid
, NULL
},
2394 {STRING_TOKEN(STR_SHELL
), &gEfiShellProtocolGuid
, NULL
},
2397 // UEFI Shell Spec 2.1
2399 {STRING_TOKEN(STR_SHELL_DYNAMIC
), &gEfiShellDynamicCommandProtocolGuid
, NULL
},
2404 {STRING_TOKEN(STR_PCDINFOPROT
), &gGetPcdInfoProtocolGuid
, NULL
},
2413 Function to get the node for a protocol or struct from it's GUID.
2415 if Guid is NULL, then ASSERT.
2417 @param[in] Guid The GUID to look for the name of.
2421 CONST GUID_INFO_BLOCK
*
2422 InternalShellGetNodeFromGuid(
2423 IN CONST EFI_GUID
* Guid
2426 CONST GUID_INFO_BLOCK
*ListWalker
;
2429 ASSERT(Guid
!= NULL
);
2431 for (LoopCount
= 0, ListWalker
= mGuidList
; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++, ListWalker
++) {
2432 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
2433 return (ListWalker
);
2437 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
2438 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2439 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
2440 return (ListWalker
);
2444 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2445 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
2446 return (ListWalker
);
2453 Function to add a new GUID/Name mapping.
2455 @param[in] Guid The Guid
2456 @param[in] NameID The STRING id of the HII string to use
2457 @param[in] DumpFunc The pointer to the dump function
2460 @retval EFI_SUCCESS The operation was sucessful
2461 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
2462 @retval EFI_INVALID_PARAMETER Guid NameId was invalid
2465 InsertNewGuidNameMapping(
2466 IN CONST EFI_GUID
*Guid
,
2467 IN CONST EFI_STRING_ID NameID
,
2468 IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
2471 ASSERT (Guid
!= NULL
);
2472 ASSERT (NameID
!= 0);
2474 mGuidList
= ReallocatePool (
2475 mGuidListCount
* sizeof (GUID_INFO_BLOCK
),
2476 (mGuidListCount
+ 1) * sizeof (GUID_INFO_BLOCK
),
2479 if (mGuidList
== NULL
) {
2481 return (EFI_OUT_OF_RESOURCES
);
2485 mGuidList
[mGuidListCount
- 1].GuidId
= AllocateCopyPool (sizeof (EFI_GUID
), Guid
);
2486 mGuidList
[mGuidListCount
- 1].StringId
= NameID
;
2487 mGuidList
[mGuidListCount
- 1].DumpInfo
= DumpFunc
;
2489 if (mGuidList
[mGuidListCount
- 1].GuidId
== NULL
) {
2490 return (EFI_OUT_OF_RESOURCES
);
2493 return (EFI_SUCCESS
);
2497 Function to add a new GUID/Name mapping.
2499 This cannot overwrite an existing mapping.
2501 @param[in] Guid The Guid
2502 @param[in] TheName The Guid's name
2503 @param[in] Lang RFC4646 language code list or NULL
2505 @retval EFI_SUCCESS The operation was sucessful
2506 @retval EFI_ACCESS_DENIED There was a duplicate
2507 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
2508 @retval EFI_INVALID_PARAMETER Guid or TheName was NULL
2512 AddNewGuidNameMapping(
2513 IN CONST EFI_GUID
*Guid
,
2514 IN CONST CHAR16
*TheName
,
2515 IN CONST CHAR8
*Lang OPTIONAL
2518 EFI_STRING_ID NameID
;
2520 HandleParsingHiiInit();
2522 if (Guid
== NULL
|| TheName
== NULL
){
2523 return (EFI_INVALID_PARAMETER
);
2526 if ((InternalShellGetNodeFromGuid(Guid
)) != NULL
) {
2527 return (EFI_ACCESS_DENIED
);
2530 NameID
= HiiSetString(mHandleParsingHiiHandle
, 0, (CHAR16
*)TheName
, Lang
);
2532 return (EFI_OUT_OF_RESOURCES
);
2535 return (InsertNewGuidNameMapping(Guid
, NameID
, NULL
));
2539 Function to get the name of a protocol or struct from it's GUID.
2541 if Guid is NULL, then ASSERT.
2543 @param[in] Guid The GUID to look for the name of.
2544 @param[in] Lang The language to use.
2546 @return pointer to string of the name. The caller
2547 is responsible to free this memory.
2551 GetStringNameFromGuid(
2552 IN CONST EFI_GUID
*Guid
,
2553 IN CONST CHAR8
*Lang OPTIONAL
2556 CONST GUID_INFO_BLOCK
*Id
;
2558 HandleParsingHiiInit();
2560 Id
= InternalShellGetNodeFromGuid(Guid
);
2564 return HiiGetString (mHandleParsingHiiHandle
, Id
->StringId
, Lang
);
2568 Function to dump protocol information from a handle.
2570 This function will return a allocated string buffer containing the
2571 information. The caller is responsible for freeing the memory.
2573 If Guid is NULL, ASSERT().
2574 If TheHandle is NULL, ASSERT().
2576 @param[in] TheHandle The handle to dump information from.
2577 @param[in] Guid The GUID of the protocol to dump.
2578 @param[in] Verbose TRUE for extra info. FALSE otherwise.
2580 @return The pointer to string.
2581 @retval NULL An error was encountered.
2585 GetProtocolInformationDump(
2586 IN CONST EFI_HANDLE TheHandle
,
2587 IN CONST EFI_GUID
*Guid
,
2588 IN CONST BOOLEAN Verbose
2591 CONST GUID_INFO_BLOCK
*Id
;
2593 ASSERT(TheHandle
!= NULL
);
2594 ASSERT(Guid
!= NULL
);
2596 if (TheHandle
== NULL
|| Guid
== NULL
) {
2600 Id
= InternalShellGetNodeFromGuid(Guid
);
2601 if (Id
!= NULL
&& Id
->DumpInfo
!= NULL
) {
2602 return (Id
->DumpInfo(TheHandle
, Verbose
));
2608 Function to get the Guid for a protocol or struct based on it's string name.
2610 do not modify the returned Guid.
2612 @param[in] Name The pointer to the string name.
2613 @param[in] Lang The pointer to the language code.
2614 @param[out] Guid The pointer to the Guid.
2616 @retval EFI_SUCCESS The operation was sucessful.
2620 GetGuidFromStringName(
2621 IN CONST CHAR16
*Name
,
2622 IN CONST CHAR8
*Lang OPTIONAL
,
2626 CONST GUID_INFO_BLOCK
*ListWalker
;
2630 HandleParsingHiiInit();
2632 ASSERT(Guid
!= NULL
);
2634 return (EFI_INVALID_PARAMETER
);
2638 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
2639 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2640 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2641 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2642 *Guid
= ListWalker
->GuidId
;
2644 SHELL_FREE_NON_NULL(String
);
2645 if (*Guid
!= NULL
) {
2646 return (EFI_SUCCESS
);
2650 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2651 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2652 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2653 *Guid
= ListWalker
->GuidId
;
2655 SHELL_FREE_NON_NULL(String
);
2656 if (*Guid
!= NULL
) {
2657 return (EFI_SUCCESS
);
2661 for (LoopCount
= 0, ListWalker
= mGuidList
; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++, ListWalker
++) {
2662 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2663 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2664 *Guid
= ListWalker
->GuidId
;
2666 SHELL_FREE_NON_NULL(String
);
2667 if (*Guid
!= NULL
) {
2668 return (EFI_SUCCESS
);
2672 return (EFI_NOT_FOUND
);
2676 Get best support language for this driver.
2678 First base on the user input language to search, second base on the current
2679 platform used language to search, third get the first language from the
2680 support language list. The caller need to free the buffer of the best language.
2682 @param[in] SupportedLanguages The support languages for this driver.
2683 @param[in] InputLanguage The user input language.
2684 @param[in] Iso639Language Whether get language for ISO639.
2686 @return The best support language for this driver.
2690 GetBestLanguageForDriver (
2691 IN CONST CHAR8
*SupportedLanguages
,
2692 IN CONST CHAR8
*InputLanguage
,
2693 IN BOOLEAN Iso639Language
2696 CHAR8
*LanguageVariable
;
2697 CHAR8
*BestLanguage
;
2699 GetVariable2 (Iso639Language
? L
"Lang" : L
"PlatformLang", &gEfiGlobalVariableGuid
, (VOID
**)&LanguageVariable
, NULL
);
2701 BestLanguage
= GetBestLanguage(
2704 (InputLanguage
!= NULL
) ? InputLanguage
: "",
2705 (LanguageVariable
!= NULL
) ? LanguageVariable
: "",
2710 if (LanguageVariable
!= NULL
) {
2711 FreePool (LanguageVariable
);
2714 return BestLanguage
;
2718 Function to retrieve the driver name (if possible) from the ComponentName or
2719 ComponentName2 protocol
2721 @param[in] TheHandle The driver handle to get the name of.
2722 @param[in] Language The language to use.
2724 @retval NULL The name could not be found.
2725 @return A pointer to the string name. Do not de-allocate the memory.
2729 GetStringNameFromHandle(
2730 IN CONST EFI_HANDLE TheHandle
,
2731 IN CONST CHAR8
*Language
2734 EFI_COMPONENT_NAME2_PROTOCOL
*CompNameStruct
;
2741 Status
= gBS
->OpenProtocol(
2743 &gEfiComponentName2ProtocolGuid
,
2744 (VOID
**)&CompNameStruct
,
2747 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2748 if (!EFI_ERROR(Status
)) {
2749 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2750 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2751 if (BestLang
!= NULL
) {
2752 FreePool (BestLang
);
2755 if (!EFI_ERROR(Status
)) {
2759 Status
= gBS
->OpenProtocol(
2761 &gEfiComponentNameProtocolGuid
,
2762 (VOID
**)&CompNameStruct
,
2765 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2766 if (!EFI_ERROR(Status
)) {
2767 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2768 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2769 if (BestLang
!= NULL
) {
2770 FreePool (BestLang
);
2772 if (!EFI_ERROR(Status
)) {
2780 Function to initialize the file global mHandleList object for use in
2781 vonverting handles to index and index to handle.
2783 @retval EFI_SUCCESS The operation was successful.
2786 InternalShellInitHandleList(
2791 EFI_HANDLE
*HandleBuffer
;
2793 HANDLE_LIST
*ListWalker
;
2795 if (mHandleList
.NextIndex
!= 0) {
2798 InitializeListHead(&mHandleList
.List
.Link
);
2799 mHandleList
.NextIndex
= 1;
2800 Status
= gBS
->LocateHandleBuffer (
2807 ASSERT_EFI_ERROR(Status
);
2808 if (EFI_ERROR(Status
)) {
2811 for (mHandleList
.NextIndex
= 1 ; mHandleList
.NextIndex
<= HandleCount
; mHandleList
.NextIndex
++){
2812 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2813 if (ListWalker
!= NULL
) {
2814 ListWalker
->TheHandle
= HandleBuffer
[mHandleList
.NextIndex
- 1];
2815 ListWalker
->TheIndex
= mHandleList
.NextIndex
;
2816 InsertTailList (&mHandleList
.List
.Link
, &ListWalker
->Link
);
2819 FreePool(HandleBuffer
);
2820 return (EFI_SUCCESS
);
2824 Function to retrieve the human-friendly index of a given handle. If the handle
2825 does not have a index one will be automatically assigned. The index value is valid
2826 until the termination of the shell application.
2828 @param[in] TheHandle The handle to retrieve an index for.
2830 @retval 0 A memory allocation failed.
2831 @return The index of the handle.
2836 ConvertHandleToHandleIndex(
2837 IN CONST EFI_HANDLE TheHandle
2841 EFI_GUID
**ProtocolBuffer
;
2842 UINTN ProtocolCount
;
2843 HANDLE_LIST
*ListWalker
;
2845 if (TheHandle
== NULL
) {
2849 InternalShellInitHandleList();
2851 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2852 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2853 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2855 if (ListWalker
->TheHandle
== TheHandle
) {
2857 // Verify that TheHandle is still present in the Handle Database
2859 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2860 if (EFI_ERROR (Status
)) {
2862 // TheHandle is not present in the Handle Database, so delete from the handle list
2864 RemoveEntryList (&ListWalker
->Link
);
2867 FreePool (ProtocolBuffer
);
2868 return (ListWalker
->TheIndex
);
2873 // Verify that TheHandle is valid handle
2875 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2876 if (EFI_ERROR (Status
)) {
2878 // TheHandle is not valid, so do not add to handle list
2882 FreePool (ProtocolBuffer
);
2884 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2885 if (ListWalker
== NULL
) {
2888 ListWalker
->TheHandle
= TheHandle
;
2889 ListWalker
->TheIndex
= mHandleList
.NextIndex
++;
2890 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
2891 return (ListWalker
->TheIndex
);
2897 Function to retrieve the EFI_HANDLE from the human-friendly index.
2899 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.
2901 @retval NULL The index was invalid.
2902 @return The EFI_HANDLE that index represents.
2907 ConvertHandleIndexToHandle(
2908 IN CONST UINTN TheIndex
2912 EFI_GUID
**ProtocolBuffer
;
2913 UINTN ProtocolCount
;
2914 HANDLE_LIST
*ListWalker
;
2916 InternalShellInitHandleList();
2918 if (TheIndex
>= mHandleList
.NextIndex
) {
2922 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2923 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2924 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2926 if (ListWalker
->TheIndex
== TheIndex
&& ListWalker
->TheHandle
!= NULL
) {
2928 // Verify that LinkWalker->TheHandle is valid handle
2930 Status
= gBS
->ProtocolsPerHandle(ListWalker
->TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2931 if (!EFI_ERROR (Status
)) {
2932 FreePool (ProtocolBuffer
);
2935 // TheHandle is not valid, so do not add to handle list
2937 ListWalker
->TheHandle
= NULL
;
2939 return (ListWalker
->TheHandle
);
2946 Gets all the related EFI_HANDLEs based on the mask supplied.
2948 This function scans all EFI_HANDLES in the UEFI environment's handle database
2949 and returns the ones with the specified relationship (Mask) to the specified
2952 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2953 If MatchingHandleCount is NULL, then ASSERT.
2955 If MatchingHandleBuffer is not NULL upon a successful return the memory must be
2958 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.
2959 @param[in] ControllerHandle The handle with Device Path protocol on it.
2960 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in
2961 MatchingHandleBuffer.
2962 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount
2963 EFI_HANDLEs with a terminating NULL EFI_HANDLE.
2964 @param[out] HandleType An array of type information.
2966 @retval EFI_SUCCESS The operation was successful, and any related handles
2967 are in MatchingHandleBuffer.
2968 @retval EFI_NOT_FOUND No matching handles were found.
2969 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2973 ParseHandleDatabaseByRelationshipWithType (
2974 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
2975 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
2976 IN UINTN
*HandleCount
,
2977 OUT EFI_HANDLE
**HandleBuffer
,
2978 OUT UINTN
**HandleType
2983 EFI_GUID
**ProtocolGuidArray
;
2985 UINTN ProtocolIndex
;
2986 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfo
;
2987 UINTN OpenInfoCount
;
2988 UINTN OpenInfoIndex
;
2990 INTN DriverBindingHandleIndex
;
2992 ASSERT(HandleCount
!= NULL
);
2993 ASSERT(HandleBuffer
!= NULL
);
2994 ASSERT(HandleType
!= NULL
);
2995 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
2998 *HandleBuffer
= NULL
;
3002 // Retrieve the list of all handles from the handle database
3004 Status
= gBS
->LocateHandleBuffer (
3011 if (EFI_ERROR (Status
)) {
3015 *HandleType
= AllocateZeroPool (*HandleCount
* sizeof (UINTN
));
3016 if (*HandleType
== NULL
) {
3017 SHELL_FREE_NON_NULL (*HandleBuffer
);
3019 return EFI_OUT_OF_RESOURCES
;
3022 DriverBindingHandleIndex
= -1;
3023 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
3024 if (DriverBindingHandle
!= NULL
&& (*HandleBuffer
)[HandleIndex
] == DriverBindingHandle
) {
3025 DriverBindingHandleIndex
= (INTN
)HandleIndex
;
3029 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
3031 // Retrieve the list of all the protocols on each handle
3033 Status
= gBS
->ProtocolsPerHandle (
3034 (*HandleBuffer
)[HandleIndex
],
3038 if (EFI_ERROR (Status
)) {
3042 for (ProtocolIndex
= 0; ProtocolIndex
< ArrayCount
; ProtocolIndex
++) {
3045 // Set the bit describing what this handle has
3047 if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiLoadedImageProtocolGuid
) ) {
3048 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_IMAGE_HANDLE
;
3049 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverBindingProtocolGuid
) ) {
3050 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_BINDING_HANDLE
;
3051 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfiguration2ProtocolGuid
)) {
3052 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
3053 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfigurationProtocolGuid
) ) {
3054 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
3055 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnostics2ProtocolGuid
) ) {
3056 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
3057 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnosticsProtocolGuid
) ) {
3058 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
3059 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentName2ProtocolGuid
) ) {
3060 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
3061 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentNameProtocolGuid
) ) {
3062 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
3063 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDevicePathProtocolGuid
) ) {
3064 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DEVICE_HANDLE
;
3067 // Retrieve the list of agents that have opened each protocol
3069 Status
= gBS
->OpenProtocolInformation (
3070 (*HandleBuffer
)[HandleIndex
],
3071 ProtocolGuidArray
[ProtocolIndex
],
3075 if (EFI_ERROR (Status
)) {
3079 if (ControllerHandle
== NULL
) {
3081 // ControllerHandle == NULL and DriverBindingHandle != NULL.
3082 // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
3084 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
3085 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
3086 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
3087 if (DriverBindingHandleIndex
!= -1) {
3088 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
3091 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
3092 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
3093 if (DriverBindingHandleIndex
!= -1) {
3094 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
3096 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
3097 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
3098 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
3104 if (DriverBindingHandle
== NULL
&& ControllerHandle
!= NULL
) {
3105 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
3106 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
3107 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
3108 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
3109 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
3110 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
3111 (*HandleType
)[ChildIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
3115 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
3116 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
3117 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
3118 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
3120 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
3121 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
3127 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
3128 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
3129 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
3130 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
3136 if (DriverBindingHandle
!= NULL
&& ControllerHandle
!= NULL
) {
3137 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
3138 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
3139 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
3140 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
3141 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
3142 if (DriverBindingHandleIndex
!= -1) {
3143 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
3147 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
3148 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
3149 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
3150 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
3151 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
3156 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
3157 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
3158 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
3164 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
3165 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
3166 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
3167 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
3173 FreePool (OpenInfo
);
3175 FreePool (ProtocolGuidArray
);
3181 Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask
3184 This function will scan all EFI_HANDLES in the UEFI environment's handle database
3185 and return all the ones with the specified relationship (Mask) to the specified
3188 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
3189 If MatchingHandleCount is NULL, then ASSERT.
3191 If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be
3194 @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol
3196 @param[in] ControllerHandle Handle to a device with Device Path protocol on it.
3197 @param[in] Mask Mask of what relationship(s) is desired.
3198 @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in
3199 MatchingHandleBuffer.
3200 @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount
3201 EFI_HANDLEs and a terminating NULL EFI_HANDLE.
3203 @retval EFI_SUCCESS The operation was sucessful and any related handles
3204 are in MatchingHandleBuffer;
3205 @retval EFI_NOT_FOUND No matching handles were found.
3206 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
3210 ParseHandleDatabaseByRelationship (
3211 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
3212 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
3213 IN CONST UINTN Mask
,
3214 IN UINTN
*MatchingHandleCount
,
3215 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
3220 EFI_HANDLE
*HandleBuffer
;
3224 ASSERT(MatchingHandleCount
!= NULL
);
3225 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
3227 if ((Mask
& HR_VALID_MASK
) != Mask
) {
3228 return (EFI_INVALID_PARAMETER
);
3231 if ((Mask
& HR_CHILD_HANDLE
) != 0 && DriverBindingHandle
== NULL
) {
3232 return (EFI_INVALID_PARAMETER
);
3235 *MatchingHandleCount
= 0;
3236 if (MatchingHandleBuffer
!= NULL
) {
3237 *MatchingHandleBuffer
= NULL
;
3240 HandleBuffer
= NULL
;
3243 Status
= ParseHandleDatabaseByRelationshipWithType (
3244 DriverBindingHandle
,
3250 if (!EFI_ERROR (Status
)) {
3252 // Count the number of handles that match the attributes in Mask
3254 for (HandleIndex
= 0; HandleIndex
< HandleCount
; HandleIndex
++) {
3255 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
3256 (*MatchingHandleCount
)++;
3260 // If no handles match the attributes in Mask then return EFI_NOT_FOUND
3262 if (*MatchingHandleCount
== 0) {
3263 Status
= EFI_NOT_FOUND
;
3266 if (MatchingHandleBuffer
== NULL
) {
3268 // Someone just wanted the count...
3270 Status
= EFI_SUCCESS
;
3273 // Allocate a handle buffer for the number of handles that matched the attributes in Mask
3275 *MatchingHandleBuffer
= AllocateZeroPool ((*MatchingHandleCount
+1)* sizeof (EFI_HANDLE
));
3276 if (*MatchingHandleBuffer
== NULL
) {
3277 Status
= EFI_OUT_OF_RESOURCES
;
3279 for (HandleIndex
= 0, *MatchingHandleCount
= 0
3280 ; HandleIndex
< HandleCount
3284 // Fill the allocated buffer with the handles that matched the attributes in Mask
3286 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
3287 (*MatchingHandleBuffer
)[(*MatchingHandleCount
)++] = HandleBuffer
[HandleIndex
];
3292 // Make the last one NULL
3294 (*MatchingHandleBuffer
)[*MatchingHandleCount
] = NULL
;
3296 Status
= EFI_SUCCESS
;
3297 } // *MatchingHandleBuffer == NULL (ELSE)
3298 } // MacthingHandleBuffer == NULL (ELSE)
3299 } // *MatchingHandleCount == 0 (ELSE)
3300 } // no error on ParseHandleDatabaseByRelationshipWithType
3302 if (HandleBuffer
!= NULL
) {
3303 FreePool (HandleBuffer
);
3306 if (HandleType
!= NULL
) {
3307 FreePool (HandleType
);
3310 ASSERT ((MatchingHandleBuffer
== NULL
) ||
3311 (*MatchingHandleCount
== 0 && *MatchingHandleBuffer
== NULL
) ||
3312 (*MatchingHandleCount
!= 0 && *MatchingHandleBuffer
!= NULL
));
3317 Gets handles for any child controllers of the passed in controller.
3319 @param[in] ControllerHandle The handle of the "parent controller"
3320 @param[out] MatchingHandleCount Pointer to the number of handles in
3321 MatchingHandleBuffer on return.
3322 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
3326 @retval EFI_SUCCESS The operation was sucessful.
3330 ParseHandleDatabaseForChildControllers(
3331 IN CONST EFI_HANDLE ControllerHandle
,
3332 OUT UINTN
*MatchingHandleCount
,
3333 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
3338 UINTN DriverBindingHandleCount
;
3339 EFI_HANDLE
*DriverBindingHandleBuffer
;
3340 UINTN DriverBindingHandleIndex
;
3341 UINTN ChildControllerHandleCount
;
3342 EFI_HANDLE
*ChildControllerHandleBuffer
;
3343 UINTN ChildControllerHandleIndex
;
3344 EFI_HANDLE
*HandleBufferForReturn
;
3346 if (MatchingHandleCount
== NULL
) {
3347 return (EFI_INVALID_PARAMETER
);
3349 *MatchingHandleCount
= 0;
3351 Status
= PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
3353 &DriverBindingHandleCount
,
3354 &DriverBindingHandleBuffer
3356 if (EFI_ERROR (Status
)) {
3361 // Get a buffer big enough for all the controllers.
3363 HandleBufferForReturn
= GetHandleListByProtocol(NULL
);
3364 if (HandleBufferForReturn
== NULL
) {
3365 FreePool (DriverBindingHandleBuffer
);
3366 return (EFI_NOT_FOUND
);
3369 for (DriverBindingHandleIndex
= 0; DriverBindingHandleIndex
< DriverBindingHandleCount
; DriverBindingHandleIndex
++) {
3370 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
3371 DriverBindingHandleBuffer
[DriverBindingHandleIndex
],
3373 &ChildControllerHandleCount
,
3374 &ChildControllerHandleBuffer
3376 if (EFI_ERROR (Status
)) {
3380 for (ChildControllerHandleIndex
= 0;
3381 ChildControllerHandleIndex
< ChildControllerHandleCount
;
3382 ChildControllerHandleIndex
++
3384 for (HandleIndex
= 0; HandleIndex
< *MatchingHandleCount
; HandleIndex
++) {
3385 if (HandleBufferForReturn
[HandleIndex
] == ChildControllerHandleBuffer
[ChildControllerHandleIndex
]) {
3389 if (HandleIndex
>= *MatchingHandleCount
) {
3390 HandleBufferForReturn
[(*MatchingHandleCount
)++] = ChildControllerHandleBuffer
[ChildControllerHandleIndex
];
3394 FreePool (ChildControllerHandleBuffer
);
3397 FreePool (DriverBindingHandleBuffer
);
3399 if (MatchingHandleBuffer
== NULL
|| *MatchingHandleCount
== 0) {
3401 // The caller is not interested in the actual handles, or we've found none.
3403 FreePool (HandleBufferForReturn
);
3404 HandleBufferForReturn
= NULL
;
3407 if (MatchingHandleBuffer
!= NULL
) {
3408 *MatchingHandleBuffer
= HandleBufferForReturn
;
3411 ASSERT ((MatchingHandleBuffer
== NULL
) ||
3412 (*MatchingHandleCount
== 0 && *MatchingHandleBuffer
== NULL
) ||
3413 (*MatchingHandleCount
!= 0 && *MatchingHandleBuffer
!= NULL
));
3415 return (EFI_SUCCESS
);
3419 Appends 1 buffer to another buffer. This will re-allocate the destination buffer
3420 if necessary to fit all of the data.
3422 If DestinationBuffer is NULL, then ASSERT().
3424 @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.
3425 @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.
3426 @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.
3427 @param[in] SourceSize The number of bytes of SourceBuffer to append.
3429 @retval NULL A memory allocation failed.
3430 @retval NULL A parameter was invalid.
3431 @return A pointer to (*DestinationBuffer).
3435 IN OUT VOID
**DestinationBuffer
,
3436 IN OUT UINTN
*DestinationSize
,
3437 IN VOID
*SourceBuffer
,
3441 UINTN LocalDestinationSize
;
3442 UINTN LocalDestinationFinalSize
;
3444 ASSERT(DestinationBuffer
!= NULL
);
3446 if (SourceSize
== 0 || SourceBuffer
== NULL
) {
3447 return (*DestinationBuffer
);
3450 if (DestinationSize
== NULL
) {
3451 LocalDestinationSize
= 0;
3453 LocalDestinationSize
= *DestinationSize
;
3456 LocalDestinationFinalSize
= LocalDestinationSize
+ SourceSize
;
3458 if (DestinationSize
!= NULL
) {
3459 *DestinationSize
= LocalDestinationSize
;
3462 if (LocalDestinationSize
== 0) {
3464 *DestinationBuffer
= AllocateZeroPool(LocalDestinationFinalSize
);
3467 *DestinationBuffer
= ReallocatePool(LocalDestinationSize
, LocalDestinationFinalSize
, *DestinationBuffer
);
3470 ASSERT(*DestinationBuffer
!= NULL
);
3473 return (CopyMem(((UINT8
*)(*DestinationBuffer
)) + LocalDestinationSize
, SourceBuffer
, SourceSize
));
3477 Gets handles for any child devices produced by the passed in driver.
3479 @param[in] DriverHandle The handle of the driver.
3480 @param[in] MatchingHandleCount Pointer to the number of handles in
3481 MatchingHandleBuffer on return.
3482 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
3484 @retval EFI_SUCCESS The operation was sucessful.
3485 @sa ParseHandleDatabaseByRelationship
3489 ParseHandleDatabaseForChildDevices(
3490 IN CONST EFI_HANDLE DriverHandle
,
3491 IN UINTN
*MatchingHandleCount
,
3492 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
3496 EFI_HANDLE
*Buffer2
;
3501 UINTN HandleBufferSize
;
3503 ASSERT(MatchingHandleCount
!= NULL
);
3505 HandleBufferSize
= 0;
3508 *MatchingHandleCount
= 0;
3510 Status
= PARSE_HANDLE_DATABASE_DEVICES (
3515 if (!EFI_ERROR (Status
)) {
3516 for (HandleIndex
= 0; HandleIndex
< Count1
; HandleIndex
++) {
3518 // now find the children
3520 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
3522 Buffer
[HandleIndex
],
3526 if (EFI_ERROR(Status
)) {
3530 // save out required and optional data elements
3532 *MatchingHandleCount
+= Count2
;
3533 if (MatchingHandleBuffer
!= NULL
) {
3534 *MatchingHandleBuffer
= BuffernCatGrow((VOID
**)MatchingHandleBuffer
, &HandleBufferSize
, Buffer2
, Count2
* sizeof(Buffer2
[0]));
3540 if (Buffer2
!= NULL
) {
3546 if (Buffer
!= NULL
) {
3553 Function to get all handles that support a given protocol or all handles.
3555 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL
3556 then the function will return all handles.
3558 @retval NULL A memory allocation failed.
3559 @return A NULL terminated list of handles.
3563 GetHandleListByProtocol (
3564 IN CONST EFI_GUID
*ProtocolGuid OPTIONAL
3567 EFI_HANDLE
*HandleList
;
3575 // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!
3577 if (ProtocolGuid
== NULL
) {
3578 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
3579 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3580 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
3581 if (HandleList
== NULL
) {
3584 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
3585 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
3588 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
3589 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3590 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
3591 if (HandleList
== NULL
) {
3594 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
3595 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
3598 if (EFI_ERROR(Status
)) {
3599 if (HandleList
!= NULL
) {
3600 FreePool(HandleList
);
3604 return (HandleList
);
3608 Function to get all handles that support some protocols.
3610 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
3612 @retval NULL A memory allocation failed.
3613 @retval NULL ProtocolGuids was NULL.
3614 @return A NULL terminated list of EFI_HANDLEs.
3618 GetHandleListByProtocolList (
3619 IN CONST EFI_GUID
**ProtocolGuids
3622 EFI_HANDLE
*HandleList
;
3627 CONST EFI_GUID
**GuidWalker
;
3628 EFI_HANDLE
*HandleWalker1
;
3629 EFI_HANDLE
*HandleWalker2
;
3633 TotalSize
= sizeof(EFI_HANDLE
);
3635 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++,Size
= 0){
3636 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &Size
, NULL
);
3637 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3643 // No handles were found...
3645 if (TotalSize
== sizeof(EFI_HANDLE
)) {
3649 HandleList
= AllocateZeroPool(TotalSize
);
3650 if (HandleList
== NULL
) {
3655 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++){
3656 TempSize
= TotalSize
- Size
;
3657 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &TempSize
, HandleList
+(Size
/sizeof(EFI_HANDLE
)));
3660 // Allow for missing protocols... Only update the 'used' size upon success.
3662 if (!EFI_ERROR(Status
)) {
3666 ASSERT(HandleList
[(TotalSize
/sizeof(EFI_HANDLE
))-1] == NULL
);
3668 for (HandleWalker1
= HandleList
; HandleWalker1
!= NULL
&& *HandleWalker1
!= NULL
; HandleWalker1
++) {
3669 for (HandleWalker2
= HandleWalker1
+ 1; HandleWalker2
!= NULL
&& *HandleWalker2
!= NULL
; HandleWalker2
++) {
3670 if (*HandleWalker1
== *HandleWalker2
) {
3672 // copy memory back 1 handle width.
3674 CopyMem(HandleWalker2
, HandleWalker2
+ 1, TotalSize
- ((HandleWalker2
-HandleList
+1)*sizeof(EFI_HANDLE
)));
3679 return (HandleList
);
3683 Return all supported GUIDs.
3685 @param[out] Guids The buffer to return all supported GUIDs.
3686 @param[in, out] Count On input, the count of GUIDs the buffer can hold,
3687 On output, the count of GUIDs to return.
3689 @retval EFI_INVALID_PARAMETER Count is NULL.
3690 @retval EFI_BUFFER_TOO_SMALL Buffer is not enough to hold all GUIDs.
3691 @retval EFI_SUCCESS GUIDs are returned successfully.
3695 GetAllMappingGuids (
3696 OUT EFI_GUID
*Guids
,
3704 if (Count
== NULL
) {
3705 return EFI_INVALID_PARAMETER
;
3709 if (PcdGetBool (PcdShellIncludeNtGuids
)) {
3710 NtGuidCount
= ARRAY_SIZE (mGuidStringListNT
) - 1;
3712 GuidCount
= ARRAY_SIZE (mGuidStringList
) - 1;
3714 if (*Count
< NtGuidCount
+ GuidCount
+ mGuidListCount
) {
3715 *Count
= NtGuidCount
+ GuidCount
+ mGuidListCount
;
3716 return EFI_BUFFER_TOO_SMALL
;
3719 for (Index
= 0; Index
< NtGuidCount
; Index
++) {
3720 CopyGuid (&Guids
[Index
], mGuidStringListNT
[Index
].GuidId
);
3723 for (Index
= 0; Index
< GuidCount
; Index
++) {
3724 CopyGuid (&Guids
[NtGuidCount
+ Index
], mGuidStringList
[Index
].GuidId
);
3727 for (Index
= 0; Index
< mGuidListCount
; Index
++) {
3728 CopyGuid (&Guids
[NtGuidCount
+ GuidCount
+ Index
], mGuidList
[Index
].GuidId
);