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-2016 Hewlett Packard Enterprise Development LP<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "UefiHandleParsingLib.h"
18 #include "IndustryStandard/Acpi10.h"
19 #include "IndustryStandard/Pci.h"
21 #include <Protocol/FirmwareVolume2.h>
23 EFI_HANDLE mHandleParsingHiiHandle
= NULL
;
24 HANDLE_INDEX_LIST mHandleList
= {{{NULL
,NULL
},0,0},0};
25 GUID_INFO_BLOCK
*mGuidList
;
29 Function to find the file name associated with a LoadedImageProtocol.
31 @param[in] LoadedImage An instance of LoadedImageProtocol.
33 @retval A string representation of the file name associated
34 with LoadedImage, or NULL if no name can be found.
37 FindLoadedImageFileName (
38 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
43 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
46 UINT32 AuthenticationStatus
;
48 if ((LoadedImage
== NULL
) || (LoadedImage
->FilePath
== NULL
)) {
52 NameGuid
= EfiGetNameGuidFromFwVolDevicePathNode((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*)LoadedImage
->FilePath
);
54 if (NameGuid
== NULL
) {
59 // Get the FirmwareVolume2Protocol of the device handle that this image was loaded from.
61 Status
= gBS
->HandleProtocol (LoadedImage
->DeviceHandle
, &gEfiFirmwareVolume2ProtocolGuid
, (VOID
**) &Fv
);
64 // FirmwareVolume2Protocol is PI, and is not required to be available.
66 if (EFI_ERROR (Status
)) {
71 // Read the user interface section of the image.
74 Status
= Fv
->ReadSection(Fv
, NameGuid
, EFI_SECTION_USER_INTERFACE
, 0, &Buffer
, &BufferSize
, &AuthenticationStatus
);
76 if (EFI_ERROR (Status
)) {
81 // ReadSection returns just the section data, without any section header. For
82 // a user interface section, the only data is the file name.
88 Function to translate the EFI_MEMORY_TYPE into a string.
90 @param[in] Memory The memory type.
92 @retval A string representation of the type allocated from BS Pool.
96 IN CONST EFI_MEMORY_TYPE Memory
103 case EfiReservedMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiReservedMemoryType", 0); break;
104 case EfiLoaderCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderCode", 0); break;
105 case EfiLoaderData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderData", 0); break;
106 case EfiBootServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesCode", 0); break;
107 case EfiBootServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesData", 0); break;
108 case EfiRuntimeServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesCode", 0); break;
109 case EfiRuntimeServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesData", 0); break;
110 case EfiConventionalMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiConventionalMemory", 0); break;
111 case EfiUnusableMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiUnusableMemory", 0); break;
112 case EfiACPIReclaimMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIReclaimMemory", 0); break;
113 case EfiACPIMemoryNVS
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIMemoryNVS", 0); break;
114 case EfiMemoryMappedIO
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIO", 0); break;
115 case EfiMemoryMappedIOPortSpace
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIOPortSpace", 0); break;
116 case EfiPalCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiPalCode", 0); break;
117 case EfiMaxMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMaxMemoryType", 0); break;
118 default: ASSERT(FALSE
);
124 Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.
126 @param[in] Fmt The format type.
128 @retval A string representation of the type allocated from BS Pool.
132 IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt
139 case PixelRedGreenBlueReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelRedGreenBlueReserved8BitPerColor", 0); break;
140 case PixelBlueGreenRedReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBlueGreenRedReserved8BitPerColor", 0); break;
141 case PixelBitMask
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBitMask", 0); break;
142 case PixelBltOnly
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBltOnly", 0); break;
143 case PixelFormatMax
: StrnCatGrow(&RetVal
, NULL
, L
"PixelFormatMax", 0); break;
144 default: ASSERT(FALSE
);
150 Constructor for the library.
152 @param[in] ImageHandle Ignored.
153 @param[in] SystemTable Ignored.
155 @retval EFI_SUCCESS The operation was successful.
159 HandleParsingLibConstructor (
160 IN EFI_HANDLE ImageHandle
,
161 IN EFI_SYSTEM_TABLE
*SystemTable
168 // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.
170 return (EFI_SUCCESS
);
174 Initialization function for HII packages.
178 HandleParsingHiiInit (VOID
)
180 if (mHandleParsingHiiHandle
== NULL
) {
181 mHandleParsingHiiHandle
= HiiAddPackages (&gHandleParsingHiiGuid
, gImageHandle
, UefiHandleParsingLibStrings
, NULL
);
182 ASSERT (mHandleParsingHiiHandle
!= NULL
);
187 Destructor for the library. free any resources.
189 @param[in] ImageHandle Ignored.
190 @param[in] SystemTable Ignored.
192 @retval EFI_SUCCESS The operation was successful.
196 HandleParsingLibDestructor (
197 IN EFI_HANDLE ImageHandle
,
198 IN EFI_SYSTEM_TABLE
*SystemTable
203 for (LoopCount
= 0; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++) {
204 SHELL_FREE_NON_NULL(mGuidList
[LoopCount
].GuidId
);
207 SHELL_FREE_NON_NULL(mGuidList
);
208 if (mHandleParsingHiiHandle
!= NULL
) {
209 HiiRemovePackages(mHandleParsingHiiHandle
);
211 return (EFI_SUCCESS
);
215 Function to dump information about LoadedImage.
217 This will allocate the return buffer from boot services pool.
219 @param[in] TheHandle The handle that has LoadedImage installed.
220 @param[in] Verbose TRUE for additional information, FALSE otherwise.
222 @retval A poitner to a string containing the information.
226 LoadedImageProtocolDumpInformation(
227 IN CONST EFI_HANDLE TheHandle
,
228 IN CONST BOOLEAN Verbose
231 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
241 Status
= gBS
->OpenProtocol (
243 &gEfiLoadedImageProtocolGuid
,
244 (VOID
**)&LoadedImage
,
247 EFI_OPEN_PROTOCOL_GET_PROTOCOL
250 if (EFI_ERROR (Status
)) {
254 FileName
= FindLoadedImageFileName(LoadedImage
);
255 FilePath
= ConvertDevicePathToText(LoadedImage
->FilePath
, TRUE
, TRUE
);
257 if (FileName
== NULL
) {
260 SHELL_FREE_NON_NULL(FilePath
);
262 RetVal
= CatSPrint(NULL
, FileName
);
263 SHELL_FREE_NON_NULL(FileName
);
267 HandleParsingHiiInit();
269 if (FileName
!= NULL
) {
270 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_NAME
), NULL
);
273 RetVal
= CatSPrint(NULL
, Temp
, FileName
);
276 SHELL_FREE_NON_NULL(Temp
);
277 SHELL_FREE_NON_NULL(FileName
);
280 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_MAIN
), NULL
);
284 PdbFileName
= PeCoffLoaderGetPdbPointer (LoadedImage
->ImageBase
);
285 DataType
= ConvertMemoryType(LoadedImage
->ImageDataType
);
286 CodeType
= ConvertMemoryType(LoadedImage
->ImageCodeType
);
291 LoadedImage
->Revision
,
292 LoadedImage
->ParentHandle
,
293 LoadedImage
->SystemTable
,
294 LoadedImage
->DeviceHandle
,
297 LoadedImage
->LoadOptionsSize
,
298 LoadedImage
->LoadOptions
,
299 LoadedImage
->ImageBase
,
300 LoadedImage
->ImageSize
,
307 SHELL_FREE_NON_NULL(Temp
);
308 SHELL_FREE_NON_NULL(FilePath
);
309 SHELL_FREE_NON_NULL(CodeType
);
310 SHELL_FREE_NON_NULL(DataType
);
316 Function to dump information about GOP.
318 This will allocate the return buffer from boot services pool.
320 @param[in] TheHandle The handle that has LoadedImage installed.
321 @param[in] Verbose TRUE for additional information, FALSE otherwise.
323 @retval A poitner to a string containing the information.
327 GraphicsOutputProtocolDumpInformation(
328 IN CONST EFI_HANDLE TheHandle
,
329 IN CONST BOOLEAN Verbose
332 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
340 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*GopInfo
;
343 return (CatSPrint(NULL
, L
"GraphicsOutput"));
346 HandleParsingHiiInit();
348 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_GOP_DUMP_MAIN
), NULL
);
353 Status
= gBS
->OpenProtocol (
355 &gEfiGraphicsOutputProtocolGuid
,
356 (VOID
**)&GraphicsOutput
,
359 EFI_OPEN_PROTOCOL_GET_PROTOCOL
362 if (EFI_ERROR (Status
)) {
363 SHELL_FREE_NON_NULL (Temp
);
367 Fmt
= ConvertPixelFormat(GraphicsOutput
->Mode
->Info
->PixelFormat
);
372 GraphicsOutput
->Mode
->MaxMode
,
373 GraphicsOutput
->Mode
->Mode
,
374 GraphicsOutput
->Mode
->FrameBufferBase
,
375 (UINT64
)GraphicsOutput
->Mode
->FrameBufferSize
,
376 (UINT64
)GraphicsOutput
->Mode
->SizeOfInfo
,
377 GraphicsOutput
->Mode
->Info
->Version
,
378 GraphicsOutput
->Mode
->Info
->HorizontalResolution
,
379 GraphicsOutput
->Mode
->Info
->VerticalResolution
,
381 GraphicsOutput
->Mode
->Info
->PixelsPerScanLine
,
382 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.RedMask
,
383 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.GreenMask
,
384 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.BlueMask
387 SHELL_FREE_NON_NULL (Temp
);
389 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_GOP_RES_LIST_MAIN
), NULL
);
391 SHELL_FREE_NON_NULL (RetVal
);
395 TempRetVal
= CatSPrint (RetVal
, Temp
);
396 SHELL_FREE_NON_NULL (RetVal
);
397 if (TempRetVal
== NULL
) {
401 SHELL_FREE_NON_NULL (Temp
);
403 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_GOP_RES_LIST_ENTRY
), NULL
);
405 SHELL_FREE_NON_NULL (RetVal
);
410 for (Mode
= 0; Mode
< GraphicsOutput
->Mode
->MaxMode
; Mode
++) {
411 Status
= GraphicsOutput
->QueryMode (
417 if (EFI_ERROR (Status
)) {
421 TempRetVal
= CatSPrint (
425 GopInfo
->HorizontalResolution
,
426 GopInfo
->VerticalResolution
429 SHELL_FREE_NON_NULL (GopInfo
);
430 SHELL_FREE_NON_NULL (RetVal
);
436 SHELL_FREE_NON_NULL(Temp
);
437 SHELL_FREE_NON_NULL(Fmt
);
443 Function to dump information about EDID Discovered Protocol.
445 This will allocate the return buffer from boot services pool.
447 @param[in] TheHandle The handle that has LoadedImage installed.
448 @param[in] Verbose TRUE for additional information, FALSE otherwise.
450 @retval A pointer to a string containing the information.
454 EdidDiscoveredProtocolDumpInformation (
455 IN CONST EFI_HANDLE TheHandle
,
456 IN CONST BOOLEAN Verbose
459 EFI_EDID_DISCOVERED_PROTOCOL
*EdidDiscovered
;
466 return (CatSPrint (NULL
, L
"EDIDDiscovered"));
469 Status
= gBS
->OpenProtocol (
471 &gEfiEdidDiscoveredProtocolGuid
,
472 (VOID
**)&EdidDiscovered
,
475 EFI_OPEN_PROTOCOL_GET_PROTOCOL
478 if (EFI_ERROR (Status
)) {
482 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_DISCOVERED_MAIN
), NULL
);
487 RetVal
= CatSPrint (NULL
, Temp
, EdidDiscovered
->SizeOfEdid
);
488 SHELL_FREE_NON_NULL (Temp
);
490 if (EdidDiscovered
->SizeOfEdid
!= 0) {
491 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_DISCOVERED_DATA
), NULL
);
493 SHELL_FREE_NON_NULL (RetVal
);
496 TempRetVal
= CatSPrint (RetVal
, Temp
);
497 SHELL_FREE_NON_NULL (RetVal
);
500 TempRetVal
= CatSDumpHex (RetVal
, 4, 0, EdidDiscovered
->SizeOfEdid
, EdidDiscovered
->Edid
);
507 Function to dump information about EDID Active Protocol.
509 This will allocate the return buffer from boot services pool.
511 @param[in] TheHandle The handle that has LoadedImage installed.
512 @param[in] Verbose TRUE for additional information, FALSE otherwise.
514 @retval A pointer to a string containing the information.
518 EdidActiveProtocolDumpInformation (
519 IN CONST EFI_HANDLE TheHandle
,
520 IN CONST BOOLEAN Verbose
523 EFI_EDID_ACTIVE_PROTOCOL
*EdidActive
;
530 return (CatSPrint (NULL
, L
"EDIDActive"));
533 Status
= gBS
->OpenProtocol (
535 &gEfiEdidActiveProtocolGuid
,
539 EFI_OPEN_PROTOCOL_GET_PROTOCOL
542 if (EFI_ERROR (Status
)) {
546 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_ACTIVE_MAIN
), NULL
);
551 RetVal
= CatSPrint (NULL
, Temp
, EdidActive
->SizeOfEdid
);
552 SHELL_FREE_NON_NULL (Temp
);
554 if (EdidActive
->SizeOfEdid
!= 0) {
555 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_ACTIVE_DATA
), NULL
);
557 SHELL_FREE_NON_NULL (RetVal
);
560 TempRetVal
= CatSPrint (RetVal
, Temp
);
561 SHELL_FREE_NON_NULL (RetVal
);
564 TempRetVal
= CatSDumpHex (RetVal
, 4, 0, EdidActive
->SizeOfEdid
, EdidActive
->Edid
);
571 Function to dump information about PciRootBridgeIo.
573 This will allocate the return buffer from boot services pool.
575 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
576 @param[in] Verbose TRUE for additional information, FALSE otherwise.
578 @retval A poitner to a string containing the information.
582 PciRootBridgeIoDumpInformation(
583 IN CONST EFI_HANDLE TheHandle
,
584 IN CONST BOOLEAN Verbose
587 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
588 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Configuration
;
599 return (CatSPrint(NULL
, L
"PciRootBridgeIo"));
602 HandleParsingHiiInit();
604 Status
= gBS
->HandleProtocol(
606 &gEfiPciRootBridgeIoProtocolGuid
,
607 (VOID
**)&PciRootBridgeIo
);
609 if (EFI_ERROR(Status
)) {
613 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_PH
), NULL
);
617 Temp2
= CatSPrint(NULL
, Temp
, PciRootBridgeIo
->ParentHandle
);
622 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SEG
), NULL
);
624 SHELL_FREE_NON_NULL(RetVal
);
627 Temp2
= CatSPrint(RetVal
, Temp
, PciRootBridgeIo
->SegmentNumber
);
635 Status
= PciRootBridgeIo
->GetAttributes (PciRootBridgeIo
, &Supports
, &Attributes
);
636 if (!EFI_ERROR(Status
)) {
637 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_ATT
), NULL
);
639 SHELL_FREE_NON_NULL(RetVal
);
642 Temp2
= CatSPrint(RetVal
, Temp
, Attributes
);
648 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS
), NULL
);
650 SHELL_FREE_NON_NULL(RetVal
);
653 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
660 Configuration
= NULL
;
661 Status
= PciRootBridgeIo
->Configuration (PciRootBridgeIo
, (VOID
**) &Configuration
);
662 if (!EFI_ERROR(Status
) && Configuration
!= NULL
) {
663 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_TITLE
), NULL
);
665 SHELL_FREE_NON_NULL(RetVal
);
668 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
673 while (Configuration
->Desc
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
675 switch (Configuration
->ResType
) {
676 case ACPI_ADDRESS_SPACE_TYPE_MEM
:
677 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_MEM
), NULL
);
679 case ACPI_ADDRESS_SPACE_TYPE_IO
:
680 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_IO
), NULL
);
682 case ACPI_ADDRESS_SPACE_TYPE_BUS
:
683 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_BUS
), NULL
);
687 Temp2
= CatSPrint(RetVal
, L
"%s", Temp
);
694 Temp2
= CatSPrint(RetVal
,
695 L
"\r\n%%H%02x %016lx %016lx %02x%%N",
696 Configuration
->SpecificFlag
,
697 Configuration
->AddrRangeMin
,
698 Configuration
->AddrRangeMax
,
699 Configuration
->AddrSpaceGranularity
711 Function to dump information about SimpleTextOut.
713 This will allocate the return buffer from boot services pool.
715 @param[in] TheHandle The handle that has SimpleTextOut installed.
716 @param[in] Verbose TRUE for additional information, FALSE otherwise.
718 @retval A poitner to a string containing the information.
722 TxtOutProtocolDumpInformation(
723 IN CONST EFI_HANDLE TheHandle
,
724 IN CONST BOOLEAN Verbose
727 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Dev
;
741 HandleParsingHiiInit();
746 Status
= gBS
->HandleProtocol(
748 &gEfiSimpleTextOutProtocolGuid
,
751 ASSERT_EFI_ERROR(Status
);
752 ASSERT (Dev
!= NULL
&& Dev
->Mode
!= NULL
);
754 Size
= (Dev
->Mode
->MaxMode
+ 1) * 80;
755 RetVal
= AllocateZeroPool(Size
);
757 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER
), NULL
);
759 UnicodeSPrint(RetVal
, Size
, Temp
, Dev
, Dev
->Mode
->Attribute
);
766 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE
), NULL
);
767 for (Index
= 0; Index
< Dev
->Mode
->MaxMode
; Index
++) {
768 Status
= Dev
->QueryMode (Dev
, Index
, &Col
, &Row
);
769 NewSize
= Size
- StrSize(RetVal
);
771 RetVal
+ StrLen(RetVal
),
773 Temp
== NULL
?L
"":Temp
,
774 Index
== Dev
->Mode
->Mode
? L
'*' : L
' ',
776 !EFI_ERROR(Status
)?(INTN
)Col
:-1,
777 !EFI_ERROR(Status
)?(INTN
)Row
:-1
784 STATIC CONST UINTN VersionStringSize
= 60;
787 Function to dump information about EfiDriverSupportedEfiVersion protocol.
789 This will allocate the return buffer from boot services pool.
791 @param[in] TheHandle The handle that has the protocol installed.
792 @param[in] Verbose TRUE for additional information, FALSE otherwise.
794 @retval A poitner to a string containing the information.
798 DriverEfiVersionProtocolDumpInformation(
799 IN CONST EFI_HANDLE TheHandle
,
800 IN CONST BOOLEAN Verbose
803 EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL
*DriverEfiVersion
;
807 Status
= gBS
->HandleProtocol(
809 &gEfiDriverSupportedEfiVersionProtocolGuid
,
810 (VOID
**)&DriverEfiVersion
);
812 ASSERT_EFI_ERROR(Status
);
814 RetVal
= AllocateZeroPool(VersionStringSize
);
815 if (RetVal
!= NULL
) {
816 UnicodeSPrint (RetVal
, VersionStringSize
, L
"0x%08x", DriverEfiVersion
->FirmwareVersion
);
821 Function to convert device path to string.
823 This will allocate the return buffer from boot services pool.
825 @param[in] DevPath Pointer to device path instance.
826 @param[in] Verbose TRUE for additional information, FALSE otherwise.
827 @param[in] Length Maximum allowed text length of the device path.
829 @retval A pointer to a string containing the information.
832 ConvertDevicePathToShortText(
833 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevPath
,
834 IN CONST BOOLEAN Verbose
,
835 IN CONST UINTN Length
843 // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
845 Temp
= ConvertDevicePathToText(DevPath
, TRUE
, TRUE
);
846 if (!Verbose
&& Temp
!= NULL
&& StrLen(Temp
) > Length
) {
849 Temp2
= StrnCatGrow(&Temp2
, &Size
, L
"..", 0);
850 Temp2
= StrnCatGrow(&Temp2
, &Size
, Temp
+(StrLen(Temp
) - (Length
- 2)), 0);
858 Function to dump protocol information.
860 This will allocate the return buffer from boot services pool.
862 @param[in] TheHandle The handle that has the protocol installed.
863 @param[in] Verbose TRUE for additional information, FALSE otherwise.
864 @param[in] Protocol The protocol is needed to dump.
866 @retval A pointer to a string containing the information.
870 DevicePathProtocolDumpInformationEx (
871 IN CONST EFI_HANDLE TheHandle
,
872 IN CONST BOOLEAN Verbose
,
873 IN EFI_GUID
*Protocol
876 EFI_DEVICE_PATH_PROTOCOL
*DevPath
;
878 CHAR16
*DevPathStrTemp
;
882 DevPathStrTemp
= NULL
;
883 Status
= gBS
->OpenProtocol(TheHandle
, Protocol
, (VOID
**)&DevPath
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
884 if (!EFI_ERROR(Status
)) {
885 DevPathStr
= ConvertDevicePathToShortText (DevPath
, Verbose
, 30);
887 Size
= StrSize(DevPathStr
) + sizeof(CHAR16
) * 2;
888 DevPathStrTemp
= AllocateZeroPool (Size
);
889 if (DevPathStrTemp
!= NULL
) {
890 StrnCatS (DevPathStrTemp
, Size
/sizeof(CHAR16
), L
" ", 2);
891 StrnCatS (DevPathStrTemp
, Size
/sizeof(CHAR16
), DevPathStr
, StrLen (DevPathStr
));
893 FreePool (DevPathStr
);
894 DevPathStr
= DevPathStrTemp
;
896 gBS
->CloseProtocol(TheHandle
, Protocol
, gImageHandle
, NULL
);
902 Function to dump information about DevicePath protocol.
904 This will allocate the return buffer from boot services pool.
906 @param[in] TheHandle The handle that has the protocol installed.
907 @param[in] Verbose TRUE for additional information, FALSE otherwise.
909 @retval A pointer to a string containing the information.
913 DevicePathProtocolDumpInformation(
914 IN CONST EFI_HANDLE TheHandle
,
915 IN CONST BOOLEAN Verbose
918 return DevicePathProtocolDumpInformationEx (TheHandle
, Verbose
, &gEfiDevicePathProtocolGuid
);
922 Function to dump information about LoadedImageDevicePath protocol.
924 This will allocate the return buffer from boot services pool.
926 @param[in] TheHandle The handle that has the protocol installed.
927 @param[in] Verbose TRUE for additional information, FALSE otherwise.
929 @retval A pointer to a string containing the information.
933 LoadedImageDevicePathProtocolDumpInformation(
934 IN CONST EFI_HANDLE TheHandle
,
935 IN CONST BOOLEAN Verbose
938 return DevicePathProtocolDumpInformationEx (TheHandle
, Verbose
, &gEfiLoadedImageDevicePathProtocolGuid
);
942 Function to dump information about BusSpecificDriverOverride protocol.
944 This will allocate the return buffer from boot services pool.
946 @param[in] TheHandle The handle that has the protocol installed.
947 @param[in] Verbose TRUE for additional information, FALSE otherwise.
949 @retval A pointer to a string containing the information.
953 BusSpecificDriverOverrideProtocolDumpInformation (
954 IN CONST EFI_HANDLE TheHandle
,
955 IN CONST BOOLEAN Verbose
962 EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL
*BusSpecificDriverOverride
;
963 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
964 EFI_HANDLE ImageHandle
;
976 Status
= gBS
->OpenProtocol (
978 &gEfiBusSpecificDriverOverrideProtocolGuid
,
979 (VOID
**)&BusSpecificDriverOverride
,
982 EFI_OPEN_PROTOCOL_GET_PROTOCOL
984 if (EFI_ERROR (Status
)) {
987 HandleParsingHiiInit ();
988 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_BSDO_DUMP_MAIN
), NULL
);
989 if (GetString
== NULL
) {
993 Status
= BusSpecificDriverOverride
->GetDriver (
994 BusSpecificDriverOverride
,
997 if (!EFI_ERROR (Status
)) {
998 Status
= gBS
->HandleProtocol (
1000 &gEfiLoadedImageProtocolGuid
,
1001 (VOID
**) &LoadedImage
1003 if(!EFI_ERROR (Status
)) {
1004 TempRetVal
= CatSPrint (
1007 ConvertHandleToHandleIndex (ImageHandle
),
1008 ConvertDevicePathToText (LoadedImage
->FilePath
, TRUE
, TRUE
)
1010 StrnCatGrow (&RetVal
, &Size
, TempRetVal
, 0);
1011 SHELL_FREE_NON_NULL (TempRetVal
);
1014 } while (!EFI_ERROR (Status
));
1016 SHELL_FREE_NON_NULL (GetString
);
1021 Function to dump information about BlockIo protocol.
1023 This will allocate the return buffer from boot services pool.
1025 @param[in] TheHandle The handle that has the protocol installed.
1026 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1028 @retval A pointer to a string containing the information.
1032 BlockIoProtocolDumpInformation (
1033 IN CONST EFI_HANDLE TheHandle
,
1034 IN CONST BOOLEAN Verbose
1038 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
1039 EFI_BLOCK_IO_MEDIA
*BlockMedia
;
1049 Status
= gBS
->OpenProtocol (
1051 &gEfiBlockIoProtocolGuid
,
1055 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1057 if (EFI_ERROR (Status
)) {
1060 BlockMedia
= BlockIo
->Media
;
1063 // The function (ReadBlocks) must return EFI_NO_MEDIA or
1064 // EFI_MEDIA_CHANGED even if LBA, BufferSize, or Buffer are invalid so the caller can probe
1065 // for changes in media state.
1067 BlockIo
->ReadBlocks (
1069 BlockIo
->Media
->MediaId
,
1075 HandleParsingHiiInit ();
1076 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_BLOCKIO_INFO
), NULL
);
1077 if (GetString
== NULL
) {
1080 RetVal
= CatSPrint (
1083 BlockMedia
->RemovableMedia
? L
"Removable " : L
"Fixed ",
1084 BlockMedia
->MediaPresent
? L
"" : L
"not-present ",
1085 BlockMedia
->MediaId
,
1086 BlockMedia
->BlockSize
,
1087 BlockMedia
->LastBlock
,
1088 MultU64x32 (BlockMedia
->LastBlock
+ 1, BlockMedia
->BlockSize
),
1089 BlockMedia
->LogicalPartition
? L
"partition" : L
"raw",
1090 BlockMedia
->ReadOnly
? L
"ro" : L
"rw",
1091 BlockMedia
->WriteCaching
? L
"cached" : L
"!cached"
1094 SHELL_FREE_NON_NULL (GetString
);
1099 Function to dump information about DebugSupport Protocol.
1101 @param[in] TheHandle The handle that has the protocol installed.
1102 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1104 @retval A pointer to a string containing the information.
1108 DebugSupportProtocolDumpInformation (
1109 IN CONST EFI_HANDLE TheHandle
,
1110 IN CONST BOOLEAN Verbose
1114 EFI_DEBUG_SUPPORT_PROTOCOL
*DebugSupport
;
1123 Status
= gBS
->OpenProtocol (
1125 &gEfiDebugSupportProtocolGuid
,
1126 (VOID
**)&DebugSupport
,
1129 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1131 if (EFI_ERROR (Status
)) {
1134 HandleParsingHiiInit ();
1135 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_DEBUGSUPPORT_INFO
), NULL
);
1136 if (GetString
== NULL
) {
1140 // Dump Debug support info
1142 switch (DebugSupport
->Isa
) {
1144 RetVal
= CatSPrint (RetVal
, GetString
, L
"IA-32");
1147 RetVal
= CatSPrint (RetVal
, GetString
, L
"IPF");
1150 RetVal
= CatSPrint (RetVal
, GetString
, L
"EBC");
1153 SHELL_FREE_NON_NULL (GetString
);
1154 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_DEBUGSUPPORT_UNKNOWN
), NULL
);
1155 RetVal
= GetString
!= NULL
? CatSPrint (RetVal
, GetString
, DebugSupport
->Isa
) : NULL
;
1159 SHELL_FREE_NON_NULL (GetString
);
1164 Function to dump information about PciIoProtocol.
1166 This will allocate the return buffer from boot services pool.
1168 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
1169 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1171 @retval A poitner to a string containing the information.
1175 PciIoProtocolDumpInformation (
1176 IN CONST EFI_HANDLE TheHandle
,
1177 IN CONST BOOLEAN Verbose
1181 EFI_PCI_IO_PROTOCOL
*PciIo
;
1198 Status
= gBS
->OpenProtocol (
1200 &gEfiPciIoProtocolGuid
,
1204 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1207 if (EFI_ERROR(Status
)) {
1210 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint8
, 0, sizeof (Pci
), &Pci
);
1211 PciIo
->GetLocation (PciIo
, &Segment
, &Bus
, &Device
, &Function
);
1212 HandleParsingHiiInit ();
1213 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIIO_DUMP_MAIN
), NULL
);
1214 if (GetString
== NULL
) {
1217 RetVal
= CatSPrint (
1228 Pci
.Hdr
.ClassCode
[0],
1229 Pci
.Hdr
.ClassCode
[1],
1230 Pci
.Hdr
.ClassCode
[2]
1232 for (Index
= 0; Index
< sizeof (Pci
); Index
++) {
1233 if ((Index
% 0x10) == 0) {
1234 TempRetVal
= CatSPrint (RetVal
, L
"\r\n %02x", *((UINT8
*) (&Pci
) + Index
));
1236 TempRetVal
= CatSPrint (RetVal
, L
"%02x", *((UINT8
*) (&Pci
) + Index
));
1239 RetVal
= TempRetVal
;
1243 FreePool(GetString
);
1248 Function to dump information about UsbIoProtocol.
1250 This will allocate the return buffer from boot services pool.
1252 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
1253 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1255 @retval A poitner to a string containing the information.
1259 UsbIoProtocolDumpInformation (
1260 IN CONST EFI_HANDLE TheHandle
,
1261 IN CONST BOOLEAN Verbose
1265 EFI_USB_IO_PROTOCOL
*UsbIo
;
1266 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDesc
;
1275 Status
= gBS
->OpenProtocol (
1277 &gEfiUsbIoProtocolGuid
,
1281 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1284 if (EFI_ERROR(Status
)) {
1287 UsbIo
->UsbGetInterfaceDescriptor (UsbIo
, &InterfaceDesc
);
1288 HandleParsingHiiInit ();
1289 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_USBIO_DUMP_MAIN
), NULL
);
1290 if (GetString
== NULL
) {
1293 RetVal
= CatSPrint (
1296 InterfaceDesc
.InterfaceNumber
,
1297 InterfaceDesc
.InterfaceClass
,
1298 InterfaceDesc
.InterfaceSubClass
,
1299 InterfaceDesc
.InterfaceProtocol
1302 FreePool (GetString
);
1307 Function to dump information about EfiAdapterInformation Protocol.
1309 @param[in] TheHandle The handle that has the protocol installed.
1310 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1312 @retval A pointer to a string containing the information.
1316 AdapterInformationDumpInformation (
1317 IN CONST EFI_HANDLE TheHandle
,
1318 IN CONST BOOLEAN Verbose
1322 EFI_ADAPTER_INFORMATION_PROTOCOL
*EfiAdptrInfoProtocol
;
1323 UINTN InfoTypesBufferCount
;
1325 EFI_GUID
*InfoTypesBuffer
;
1330 VOID
*InformationBlock
;
1331 UINTN InformationBlockSize
;
1334 return (CatSPrint(NULL
, L
"AdapterInfo"));
1337 InfoTypesBuffer
= NULL
;
1338 InformationBlock
= NULL
;
1341 Status
= gBS
->OpenProtocol (
1342 (EFI_HANDLE
) (TheHandle
),
1343 &gEfiAdapterInformationProtocolGuid
,
1344 (VOID
**) &EfiAdptrInfoProtocol
,
1347 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1350 if (EFI_ERROR (Status
)) {
1355 // Get a list of supported information types for this instance of the protocol.
1357 Status
= EfiAdptrInfoProtocol
->GetSupportedTypes (
1358 EfiAdptrInfoProtocol
,
1360 &InfoTypesBufferCount
1363 if (EFI_ERROR (Status
)) {
1364 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED
), NULL
);
1365 if (TempStr
!= NULL
) {
1366 RetVal
= CatSPrint (NULL
, TempStr
, Status
);
1371 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SUPP_TYPE_HEADER
), NULL
);
1372 if (TempStr
== NULL
) {
1375 RetVal
= CatSPrint (NULL
, TempStr
);
1376 SHELL_FREE_NON_NULL (TempStr
);
1378 for (GuidIndex
= 0; GuidIndex
< InfoTypesBufferCount
; GuidIndex
++) {
1379 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_NUMBER
), NULL
);
1380 if (TempStr
== NULL
) {
1383 TempRetVal
= CatSPrint (RetVal
, TempStr
, (GuidIndex
+ 1), &InfoTypesBuffer
[GuidIndex
]);
1384 SHELL_FREE_NON_NULL (RetVal
);
1385 RetVal
= TempRetVal
;
1386 SHELL_FREE_NON_NULL (TempStr
);
1388 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_STRING
), NULL
);
1389 if (TempStr
== NULL
) {
1393 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
1394 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoMediaStateGuid");
1395 SHELL_FREE_NON_NULL (RetVal
);
1396 RetVal
= TempRetVal
;
1397 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
1398 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoNetworkBootGuid");
1399 SHELL_FREE_NON_NULL (RetVal
);
1400 RetVal
= TempRetVal
;
1401 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
)) {
1402 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoSanMacAddressGuid");
1403 SHELL_FREE_NON_NULL (RetVal
);
1404 RetVal
= TempRetVal
;
1405 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
)) {
1406 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoUndiIpv6SupportGuid");
1407 SHELL_FREE_NON_NULL (RetVal
);
1408 RetVal
= TempRetVal
;
1411 GuidStr
= GetStringNameFromGuid (&InfoTypesBuffer
[GuidIndex
], NULL
);
1412 if (GuidStr
== NULL
) {
1413 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"UnknownInfoType");
1414 SHELL_FREE_NON_NULL (RetVal
);
1415 RetVal
= TempRetVal
;
1417 SHELL_FREE_NON_NULL (TempStr
);
1418 SHELL_FREE_NON_NULL(GuidStr
);
1420 // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
1424 TempRetVal
= CatSPrint (RetVal
, TempStr
, GuidStr
);
1425 SHELL_FREE_NON_NULL (RetVal
);
1426 RetVal
= TempRetVal
;
1427 SHELL_FREE_NON_NULL(GuidStr
);
1431 SHELL_FREE_NON_NULL (TempStr
);
1433 Status
= EfiAdptrInfoProtocol
->GetInformation (
1434 EfiAdptrInfoProtocol
,
1435 &InfoTypesBuffer
[GuidIndex
],
1437 &InformationBlockSize
1440 if (EFI_ERROR (Status
)) {
1441 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GETINFO_FAILED
), NULL
);
1442 if (TempStr
== NULL
) {
1445 TempRetVal
= CatSPrint (RetVal
, TempStr
, Status
);
1446 SHELL_FREE_NON_NULL (RetVal
);
1447 RetVal
= TempRetVal
;
1449 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
1450 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_MEDIA_STATE
), NULL
);
1451 if (TempStr
== NULL
) {
1454 TempRetVal
= CatSPrint (
1457 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
,
1458 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
1460 SHELL_FREE_NON_NULL (RetVal
);
1461 RetVal
= TempRetVal
;
1462 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
1463 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_NETWORK_BOOT_INFO
), NULL
);
1464 if (TempStr
== NULL
) {
1467 TempRetVal
= CatSPrint (
1470 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4BootCapablity
,
1471 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6BootCapablity
,
1472 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBootCapablity
,
1473 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->OffloadCapability
,
1474 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiMpioCapability
,
1475 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4Boot
,
1476 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6Boot
,
1477 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBoot
1479 SHELL_FREE_NON_NULL (RetVal
);
1480 RetVal
= TempRetVal
;
1481 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
) == TRUE
) {
1482 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO
), NULL
);
1483 if (TempStr
== NULL
) {
1486 TempRetVal
= CatSPrint (
1489 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[0],
1490 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[1],
1491 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[2],
1492 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[3],
1493 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[4],
1494 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[5]
1496 SHELL_FREE_NON_NULL (RetVal
);
1497 RetVal
= TempRetVal
;
1498 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
) == TRUE
) {
1499 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNDI_IPV6_INFO
), NULL
);
1500 if (TempStr
== NULL
) {
1504 TempRetVal
= CatSPrint (
1507 ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT
*)InformationBlock
)->Ipv6Support
1509 SHELL_FREE_NON_NULL (RetVal
);
1510 RetVal
= TempRetVal
;
1512 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE
), NULL
);
1513 if (TempStr
== NULL
) {
1516 TempRetVal
= CatSPrint (RetVal
, TempStr
, &InfoTypesBuffer
[GuidIndex
]);
1517 SHELL_FREE_NON_NULL (RetVal
);
1518 RetVal
= TempRetVal
;
1521 SHELL_FREE_NON_NULL (TempStr
);
1522 SHELL_FREE_NON_NULL (InformationBlock
);
1526 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1530 SHELL_FREE_NON_NULL (RetVal
);
1531 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1532 SHELL_FREE_NON_NULL (InformationBlock
);
1537 Function to dump information about EFI_FIRMWARE_MANAGEMENT_PROTOCOL Protocol.
1539 @param[in] TheHandle The handle that has the protocol installed.
1540 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1542 @retval A pointer to a string containing the information.
1546 FirmwareManagementDumpInformation (
1547 IN CONST EFI_HANDLE TheHandle
,
1548 IN CONST BOOLEAN Verbose
1552 EFI_FIRMWARE_MANAGEMENT_PROTOCOL
*EfiFwMgmtProtocol
;
1553 EFI_FIRMWARE_IMAGE_DESCRIPTOR
*ImageInfo
;
1554 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*ImageInfoV1
;
1555 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*ImageInfoV2
;
1556 UINT64 AttributeSetting
;
1557 UINTN ImageInfoSize
;
1558 UINTN DescriptorSize
;
1559 UINT32 DescriptorVersion
;
1560 UINT32 PackageVersion
;
1561 UINT8 DescriptorCount
;
1565 CHAR16
*PackageVersionName
;
1569 CHAR16
*AttributeSettingStr
;
1571 BOOLEAN AttributeSupported
;
1574 // Initialize local variables
1578 AttributeSetting
= 0;
1580 AttributeSupported
= FALSE
;
1584 PackageVersionName
= NULL
;
1588 AttributeSettingStr
= NULL
;
1591 return (CatSPrint(NULL
, L
"FirmwareManagement"));
1594 Status
= gBS
->OpenProtocol (
1595 (EFI_HANDLE
) (TheHandle
),
1596 &gEfiFirmwareManagementProtocolGuid
,
1597 (VOID
**) &EfiFwMgmtProtocol
,
1600 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1603 if (EFI_ERROR (Status
)) {
1607 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1618 if (Status
== EFI_BUFFER_TOO_SMALL
) {
1619 ImageInfo
= AllocateZeroPool (ImageInfoSize
);
1621 if (ImageInfo
== NULL
) {
1622 Status
= EFI_OUT_OF_RESOURCES
;
1624 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1637 if (EFI_ERROR (Status
)) {
1642 // Decode Image Descriptor data only if its version is supported
1644 if (DescriptorVersion
<= EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION
) {
1646 if (ImageInfo
== NULL
) {
1650 ImageInfoV1
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*)ImageInfo
;
1651 ImageInfoV2
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*)ImageInfo
;
1654 // Set ImageInfoSize in return buffer
1656 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_INFO_SIZE
), NULL
);
1657 if (TempStr
== NULL
) {
1660 RetVal
= CatSPrint (NULL
, TempStr
, ImageInfoSize
);
1661 SHELL_FREE_NON_NULL (TempStr
);
1664 // Set DescriptorVersion in return buffer
1666 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_VERSION
), NULL
);
1667 if (TempStr
== NULL
) {
1670 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorVersion
);
1671 SHELL_FREE_NON_NULL (RetVal
);
1672 RetVal
= TempRetVal
;
1673 SHELL_FREE_NON_NULL (TempStr
);
1676 // Set DescriptorCount in return buffer
1678 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_COUNT
), NULL
);
1679 if (TempStr
== NULL
) {
1682 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorCount
);
1683 SHELL_FREE_NON_NULL (RetVal
);
1684 RetVal
= TempRetVal
;
1685 SHELL_FREE_NON_NULL (TempStr
);
1689 // Set DescriptorSize in return buffer
1691 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_SIZE
), NULL
);
1692 if (TempStr
== NULL
) {
1695 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorSize
);
1696 SHELL_FREE_NON_NULL (RetVal
);
1697 RetVal
= TempRetVal
;
1698 SHELL_FREE_NON_NULL (TempStr
);
1701 // Set PackageVersion in return buffer
1703 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION
), NULL
);
1704 if (TempStr
== NULL
) {
1707 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersion
);
1708 SHELL_FREE_NON_NULL (RetVal
);
1709 RetVal
= TempRetVal
;
1710 SHELL_FREE_NON_NULL (TempStr
);
1713 // Set PackageVersionName in return buffer
1715 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION_NAME
), NULL
);
1716 if (TempStr
== NULL
) {
1719 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersionName
);
1720 SHELL_FREE_NON_NULL (RetVal
);
1721 RetVal
= TempRetVal
;
1722 SHELL_FREE_NON_NULL (TempStr
);
1724 for (Index
= 0; Index
< DescriptorCount
; Index
++) {
1726 // First check if Attribute is supported
1727 // and generate a string for AttributeSetting field
1729 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1730 AttributeSupported
= FALSE
;
1731 AttributeSetting
= 0;
1732 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1733 if (ImageInfoV1
[Index
].AttributesSupported
!= 0x0) {
1734 AttributeSupported
= TRUE
;
1735 AttributeSetting
= ImageInfoV1
[Index
].AttributesSetting
;
1737 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1738 if (ImageInfoV2
[Index
].AttributesSupported
!= 0x0) {
1739 AttributeSupported
= TRUE
;
1740 AttributeSetting
= ImageInfoV2
[Index
].AttributesSetting
;
1743 if (ImageInfo
[Index
].AttributesSupported
!= 0x0) {
1744 AttributeSupported
= TRUE
;
1745 AttributeSetting
= ImageInfo
[Index
].AttributesSetting
;
1749 if (!AttributeSupported
) {
1750 AttributeSettingStr
= CatSPrint (NULL
, L
"None");
1752 AttributeSettingStr
= CatSPrint (NULL
, L
"(");
1754 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
) != 0x0) {
1755 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IMAGE_UPDATABLE");
1756 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1757 AttributeSettingStr
= TempRetVal
;
1759 if ((AttributeSetting
& IMAGE_ATTRIBUTE_RESET_REQUIRED
) != 0x0) {
1760 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_RESET_REQUIRED");
1761 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1762 AttributeSettingStr
= TempRetVal
;
1764 if ((AttributeSetting
& IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
) != 0x0) {
1765 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED");
1766 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1767 AttributeSettingStr
= TempRetVal
;
1769 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IN_USE
) != 0x0) {
1770 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IN_USE");
1771 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1772 AttributeSettingStr
= TempRetVal
;
1774 if ((AttributeSetting
& IMAGE_ATTRIBUTE_UEFI_IMAGE
) != 0x0) {
1775 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_UEFI_IMAGE");
1776 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1777 AttributeSettingStr
= TempRetVal
;
1779 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" )");
1780 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1781 AttributeSettingStr
= TempRetVal
;
1784 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1785 if (ImageInfoV1
[Index
].ImageIndex
!= 0x0) {
1789 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V1
), NULL
);
1790 if (TempStr
== NULL
) {
1793 TempRetVal
= CatSPrint (
1797 ImageInfoV1
[Index
].ImageIndex
,
1798 &ImageInfoV1
[Index
].ImageTypeId
,
1799 ImageInfoV1
[Index
].ImageId
,
1800 ImageInfoV1
[Index
].ImageIdName
,
1801 ImageInfoV1
[Index
].Version
,
1802 ImageInfoV1
[Index
].VersionName
,
1803 ImageInfoV1
[Index
].Size
,
1804 ImageInfoV1
[Index
].AttributesSupported
,
1805 AttributeSettingStr
,
1806 ImageInfoV1
[Index
].Compatibilities
1808 SHELL_FREE_NON_NULL (RetVal
);
1809 RetVal
= TempRetVal
;
1810 SHELL_FREE_NON_NULL (TempStr
);
1811 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1812 if (ImageInfoV2
[Index
].ImageIndex
!= 0x0) {
1816 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V2
), NULL
);
1817 if (TempStr
== NULL
) {
1820 TempRetVal
= CatSPrint (
1824 ImageInfoV2
[Index
].ImageIndex
,
1825 &ImageInfoV2
[Index
].ImageTypeId
,
1826 ImageInfoV2
[Index
].ImageId
,
1827 ImageInfoV2
[Index
].ImageIdName
,
1828 ImageInfoV2
[Index
].Version
,
1829 ImageInfoV2
[Index
].VersionName
,
1830 ImageInfoV2
[Index
].Size
,
1831 ImageInfoV2
[Index
].AttributesSupported
,
1832 AttributeSettingStr
,
1833 ImageInfoV2
[Index
].Compatibilities
,
1834 ImageInfoV2
[Index
].LowestSupportedImageVersion
1836 SHELL_FREE_NON_NULL (RetVal
);
1837 RetVal
= TempRetVal
;
1838 SHELL_FREE_NON_NULL (TempStr
);
1840 if (ImageInfo
[Index
].ImageIndex
!= 0x0) {
1844 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO
), NULL
);
1845 if (TempStr
== NULL
) {
1848 TempRetVal
= CatSPrint (
1852 ImageInfo
[Index
].ImageIndex
,
1853 &ImageInfo
[Index
].ImageTypeId
,
1854 ImageInfo
[Index
].ImageId
,
1855 ImageInfo
[Index
].ImageIdName
,
1856 ImageInfo
[Index
].Version
,
1857 ImageInfo
[Index
].VersionName
,
1858 ImageInfo
[Index
].Size
,
1859 ImageInfo
[Index
].AttributesSupported
,
1860 AttributeSettingStr
,
1861 ImageInfo
[Index
].Compatibilities
,
1862 ImageInfo
[Index
].LowestSupportedImageVersion
,
1863 ImageInfo
[Index
].LastAttemptVersion
,
1864 ImageInfo
[Index
].LastAttemptStatus
,
1865 ImageInfo
[Index
].HardwareInstance
1867 SHELL_FREE_NON_NULL (RetVal
);
1868 RetVal
= TempRetVal
;
1869 SHELL_FREE_NON_NULL (TempStr
);
1874 if (ImageCount
> 0) {
1875 for (Index
=0; Index
<DescriptorCount
; Index
++) {
1876 for (Index1
=Index
+1; Index1
<DescriptorCount
; Index1
++) {
1877 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1878 if (ImageInfoV1
[Index
].ImageId
== ImageInfoV1
[Index1
].ImageId
) {
1881 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1885 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1886 if (ImageInfoV2
[Index
].ImageId
== ImageInfoV2
[Index1
].ImageId
) {
1889 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1894 if (ImageInfo
[Index
].ImageId
== ImageInfo
[Index1
].ImageId
) {
1897 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1908 // Check if ImageId with duplicate value was found
1911 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGEID_NON_UNIQUE
), NULL
);
1912 if (TempStr
== NULL
) {
1915 TempRetVal
= CatSPrint (RetVal
, TempStr
);
1916 SHELL_FREE_NON_NULL (RetVal
);
1917 RetVal
= TempRetVal
;
1918 SHELL_FREE_NON_NULL (TempStr
);
1921 SHELL_FREE_NON_NULL (ImageInfo
);
1922 SHELL_FREE_NON_NULL (PackageVersionName
);
1923 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1928 SHELL_FREE_NON_NULL (RetVal
);
1929 SHELL_FREE_NON_NULL (ImageInfo
);
1930 SHELL_FREE_NON_NULL (PackageVersionName
);
1931 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1937 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
1939 #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
1941 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1944 #define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
1946 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1949 #define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
1951 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1953 STATIC CONST EFI_GUID WinNtThunkProtocolGuid
= LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID
;
1954 STATIC CONST EFI_GUID WinNtIoProtocolGuid
= LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID
;
1955 STATIC CONST EFI_GUID WinNtSerialPortGuid
= LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID
;
1958 // Deprecated protocols we dont want to link from IntelFrameworkModulePkg
1960 #define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \
1962 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
1964 #define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \
1966 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \
1968 STATIC CONST EFI_GUID EfiIsaIoProtocolGuid
= LOCAL_EFI_ISA_IO_PROTOCOL_GUID
;
1969 STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid
= LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID
;
1972 STATIC CONST GUID_INFO_BLOCK mGuidStringListNT
[] = {
1973 {STRING_TOKEN(STR_WINNT_THUNK
), (EFI_GUID
*)&WinNtThunkProtocolGuid
, NULL
},
1974 {STRING_TOKEN(STR_WINNT_DRIVER_IO
), (EFI_GUID
*)&WinNtIoProtocolGuid
, NULL
},
1975 {STRING_TOKEN(STR_WINNT_SERIAL_PORT
), (EFI_GUID
*)&WinNtSerialPortGuid
, NULL
},
1979 STATIC CONST GUID_INFO_BLOCK mGuidStringList
[] = {
1980 {STRING_TOKEN(STR_LOADED_IMAGE
), &gEfiLoadedImageProtocolGuid
, LoadedImageProtocolDumpInformation
},
1981 {STRING_TOKEN(STR_DEVICE_PATH
), &gEfiDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
1982 {STRING_TOKEN(STR_IMAGE_PATH
), &gEfiLoadedImageDevicePathProtocolGuid
, LoadedImageDevicePathProtocolDumpInformation
},
1983 {STRING_TOKEN(STR_DEVICE_PATH_UTIL
), &gEfiDevicePathUtilitiesProtocolGuid
, NULL
},
1984 {STRING_TOKEN(STR_DEVICE_PATH_TXT
), &gEfiDevicePathToTextProtocolGuid
, NULL
},
1985 {STRING_TOKEN(STR_DEVICE_PATH_FTXT
), &gEfiDevicePathFromTextProtocolGuid
, NULL
},
1986 {STRING_TOKEN(STR_DEVICE_PATH_PC
), &gEfiPcAnsiGuid
, NULL
},
1987 {STRING_TOKEN(STR_DEVICE_PATH_VT100
), &gEfiVT100Guid
, NULL
},
1988 {STRING_TOKEN(STR_DEVICE_PATH_VT100P
), &gEfiVT100PlusGuid
, NULL
},
1989 {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8
), &gEfiVTUTF8Guid
, NULL
},
1990 {STRING_TOKEN(STR_DRIVER_BINDING
), &gEfiDriverBindingProtocolGuid
, NULL
},
1991 {STRING_TOKEN(STR_PLATFORM_OVERRIDE
), &gEfiPlatformDriverOverrideProtocolGuid
, NULL
},
1992 {STRING_TOKEN(STR_BUS_OVERRIDE
), &gEfiBusSpecificDriverOverrideProtocolGuid
, BusSpecificDriverOverrideProtocolDumpInformation
},
1993 {STRING_TOKEN(STR_DRIVER_DIAG
), &gEfiDriverDiagnosticsProtocolGuid
, NULL
},
1994 {STRING_TOKEN(STR_DRIVER_DIAG2
), &gEfiDriverDiagnostics2ProtocolGuid
, NULL
},
1995 {STRING_TOKEN(STR_DRIVER_CN
), &gEfiComponentNameProtocolGuid
, NULL
},
1996 {STRING_TOKEN(STR_DRIVER_CN2
), &gEfiComponentName2ProtocolGuid
, NULL
},
1997 {STRING_TOKEN(STR_PLAT_DRV_CFG
), &gEfiPlatformToDriverConfigurationProtocolGuid
, NULL
},
1998 {STRING_TOKEN(STR_DRIVER_VERSION
), &gEfiDriverSupportedEfiVersionProtocolGuid
, DriverEfiVersionProtocolDumpInformation
},
1999 {STRING_TOKEN(STR_TXT_IN
), &gEfiSimpleTextInProtocolGuid
, NULL
},
2000 {STRING_TOKEN(STR_TXT_IN_EX
), &gEfiSimpleTextInputExProtocolGuid
, NULL
},
2001 {STRING_TOKEN(STR_TXT_OUT
), &gEfiSimpleTextOutProtocolGuid
, TxtOutProtocolDumpInformation
},
2002 {STRING_TOKEN(STR_SIM_POINTER
), &gEfiSimplePointerProtocolGuid
, NULL
},
2003 {STRING_TOKEN(STR_ABS_POINTER
), &gEfiAbsolutePointerProtocolGuid
, NULL
},
2004 {STRING_TOKEN(STR_SERIAL_IO
), &gEfiSerialIoProtocolGuid
, NULL
},
2005 {STRING_TOKEN(STR_GRAPHICS_OUTPUT
), &gEfiGraphicsOutputProtocolGuid
, GraphicsOutputProtocolDumpInformation
},
2006 {STRING_TOKEN(STR_EDID_DISCOVERED
), &gEfiEdidDiscoveredProtocolGuid
, EdidDiscoveredProtocolDumpInformation
},
2007 {STRING_TOKEN(STR_EDID_ACTIVE
), &gEfiEdidActiveProtocolGuid
, EdidActiveProtocolDumpInformation
},
2008 {STRING_TOKEN(STR_EDID_OVERRIDE
), &gEfiEdidOverrideProtocolGuid
, NULL
},
2009 {STRING_TOKEN(STR_CON_IN
), &gEfiConsoleInDeviceGuid
, NULL
},
2010 {STRING_TOKEN(STR_CON_OUT
), &gEfiConsoleOutDeviceGuid
, NULL
},
2011 {STRING_TOKEN(STR_STD_ERR
), &gEfiStandardErrorDeviceGuid
, NULL
},
2012 {STRING_TOKEN(STR_LOAD_FILE
), &gEfiLoadFileProtocolGuid
, NULL
},
2013 {STRING_TOKEN(STR_LOAD_FILE2
), &gEfiLoadFile2ProtocolGuid
, NULL
},
2014 {STRING_TOKEN(STR_SIMPLE_FILE_SYS
), &gEfiSimpleFileSystemProtocolGuid
, NULL
},
2015 {STRING_TOKEN(STR_TAPE_IO
), &gEfiTapeIoProtocolGuid
, NULL
},
2016 {STRING_TOKEN(STR_DISK_IO
), &gEfiDiskIoProtocolGuid
, NULL
},
2017 {STRING_TOKEN(STR_BLK_IO
), &gEfiBlockIoProtocolGuid
, BlockIoProtocolDumpInformation
},
2018 {STRING_TOKEN(STR_UC
), &gEfiUnicodeCollationProtocolGuid
, NULL
},
2019 {STRING_TOKEN(STR_UC2
), &gEfiUnicodeCollation2ProtocolGuid
, NULL
},
2020 {STRING_TOKEN(STR_PCIRB_IO
), &gEfiPciRootBridgeIoProtocolGuid
, PciRootBridgeIoDumpInformation
},
2021 {STRING_TOKEN(STR_PCI_IO
), &gEfiPciIoProtocolGuid
, PciIoProtocolDumpInformation
},
2022 {STRING_TOKEN(STR_SCSI_PT
), &gEfiScsiPassThruProtocolGuid
, NULL
},
2023 {STRING_TOKEN(STR_SCSI_IO
), &gEfiScsiIoProtocolGuid
, NULL
},
2024 {STRING_TOKEN(STR_SCSI_PT_EXT
), &gEfiExtScsiPassThruProtocolGuid
, NULL
},
2025 {STRING_TOKEN(STR_ISCSI
), &gEfiIScsiInitiatorNameProtocolGuid
, NULL
},
2026 {STRING_TOKEN(STR_USB_IO
), &gEfiUsbIoProtocolGuid
, UsbIoProtocolDumpInformation
},
2027 {STRING_TOKEN(STR_USB_HC
), &gEfiUsbHcProtocolGuid
, NULL
},
2028 {STRING_TOKEN(STR_USB_HC2
), &gEfiUsb2HcProtocolGuid
, NULL
},
2029 {STRING_TOKEN(STR_DEBUG_SUPPORT
), &gEfiDebugSupportProtocolGuid
, DebugSupportProtocolDumpInformation
},
2030 {STRING_TOKEN(STR_DEBUG_PORT
), &gEfiDebugPortProtocolGuid
, NULL
},
2031 {STRING_TOKEN(STR_DECOMPRESS
), &gEfiDecompressProtocolGuid
, NULL
},
2032 {STRING_TOKEN(STR_ACPI_TABLE
), &gEfiAcpiTableProtocolGuid
, NULL
},
2033 {STRING_TOKEN(STR_EBC_INTERPRETER
), &gEfiEbcProtocolGuid
, NULL
},
2034 {STRING_TOKEN(STR_SNP
), &gEfiSimpleNetworkProtocolGuid
, NULL
},
2035 {STRING_TOKEN(STR_NII
), &gEfiNetworkInterfaceIdentifierProtocolGuid
, NULL
},
2036 {STRING_TOKEN(STR_NII_31
), &gEfiNetworkInterfaceIdentifierProtocolGuid_31
, NULL
},
2037 {STRING_TOKEN(STR_PXE_BC
), &gEfiPxeBaseCodeProtocolGuid
, NULL
},
2038 {STRING_TOKEN(STR_PXE_CB
), &gEfiPxeBaseCodeCallbackProtocolGuid
, NULL
},
2039 {STRING_TOKEN(STR_BIS
), &gEfiBisProtocolGuid
, NULL
},
2040 {STRING_TOKEN(STR_MNP_SB
), &gEfiManagedNetworkServiceBindingProtocolGuid
, NULL
},
2041 {STRING_TOKEN(STR_MNP
), &gEfiManagedNetworkProtocolGuid
, NULL
},
2042 {STRING_TOKEN(STR_ARP_SB
), &gEfiArpServiceBindingProtocolGuid
, NULL
},
2043 {STRING_TOKEN(STR_ARP
), &gEfiArpProtocolGuid
, NULL
},
2044 {STRING_TOKEN(STR_DHCPV4_SB
), &gEfiDhcp4ServiceBindingProtocolGuid
, NULL
},
2045 {STRING_TOKEN(STR_DHCPV4
), &gEfiDhcp4ProtocolGuid
, NULL
},
2046 {STRING_TOKEN(STR_TCPV4_SB
), &gEfiTcp4ServiceBindingProtocolGuid
, NULL
},
2047 {STRING_TOKEN(STR_TCPV4
), &gEfiTcp4ProtocolGuid
, NULL
},
2048 {STRING_TOKEN(STR_IPV4_SB
), &gEfiIp4ServiceBindingProtocolGuid
, NULL
},
2049 {STRING_TOKEN(STR_IPV4
), &gEfiIp4ProtocolGuid
, NULL
},
2050 {STRING_TOKEN(STR_IPV4_CFG
), &gEfiIp4ConfigProtocolGuid
, NULL
},
2051 {STRING_TOKEN(STR_IPV4_CFG2
), &gEfiIp4Config2ProtocolGuid
, NULL
},
2052 {STRING_TOKEN(STR_UDPV4_SB
), &gEfiUdp4ServiceBindingProtocolGuid
, NULL
},
2053 {STRING_TOKEN(STR_UDPV4
), &gEfiUdp4ProtocolGuid
, NULL
},
2054 {STRING_TOKEN(STR_MTFTPV4_SB
), &gEfiMtftp4ServiceBindingProtocolGuid
, NULL
},
2055 {STRING_TOKEN(STR_MTFTPV4
), &gEfiMtftp4ProtocolGuid
, NULL
},
2056 {STRING_TOKEN(STR_AUTH_INFO
), &gEfiAuthenticationInfoProtocolGuid
, NULL
},
2057 {STRING_TOKEN(STR_HASH_SB
), &gEfiHashServiceBindingProtocolGuid
, NULL
},
2058 {STRING_TOKEN(STR_HASH
), &gEfiHashProtocolGuid
, NULL
},
2059 {STRING_TOKEN(STR_HII_FONT
), &gEfiHiiFontProtocolGuid
, NULL
},
2060 {STRING_TOKEN(STR_HII_STRING
), &gEfiHiiStringProtocolGuid
, NULL
},
2061 {STRING_TOKEN(STR_HII_IMAGE
), &gEfiHiiImageProtocolGuid
, NULL
},
2062 {STRING_TOKEN(STR_HII_DATABASE
), &gEfiHiiDatabaseProtocolGuid
, NULL
},
2063 {STRING_TOKEN(STR_HII_CONFIG_ROUT
), &gEfiHiiConfigRoutingProtocolGuid
, NULL
},
2064 {STRING_TOKEN(STR_HII_CONFIG_ACC
), &gEfiHiiConfigAccessProtocolGuid
, NULL
},
2065 {STRING_TOKEN(STR_HII_FORM_BROWSER2
), &gEfiFormBrowser2ProtocolGuid
, NULL
},
2066 {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE
), &gEfiDriverFamilyOverrideProtocolGuid
, NULL
},
2067 {STRING_TOKEN(STR_PCD
), &gPcdProtocolGuid
, NULL
},
2068 {STRING_TOKEN(STR_TCG
), &gEfiTcgProtocolGuid
, NULL
},
2069 {STRING_TOKEN(STR_HII_PACKAGE_LIST
), &gEfiHiiPackageListProtocolGuid
, NULL
},
2072 // the ones under this are deprecated by the current UEFI Spec, but may be found anyways...
2074 {STRING_TOKEN(STR_SHELL_INTERFACE
), &gEfiShellInterfaceGuid
, NULL
},
2075 {STRING_TOKEN(STR_SHELL_ENV2
), &gEfiShellEnvironment2Guid
, NULL
},
2076 {STRING_TOKEN(STR_SHELL_ENV
), &gEfiShellEnvironment2Guid
, NULL
},
2077 {STRING_TOKEN(STR_DEVICE_IO
), &gEfiDeviceIoProtocolGuid
, NULL
},
2078 {STRING_TOKEN(STR_UGA_DRAW
), &gEfiUgaDrawProtocolGuid
, NULL
},
2079 {STRING_TOKEN(STR_UGA_IO
), &gEfiUgaIoProtocolGuid
, NULL
},
2080 {STRING_TOKEN(STR_ESP
), &gEfiPartTypeSystemPartGuid
, NULL
},
2081 {STRING_TOKEN(STR_GPT_NBR
), &gEfiPartTypeLegacyMbrGuid
, NULL
},
2082 {STRING_TOKEN(STR_DRIVER_CONFIG
), &gEfiDriverConfigurationProtocolGuid
, NULL
},
2083 {STRING_TOKEN(STR_DRIVER_CONFIG2
), &gEfiDriverConfiguration2ProtocolGuid
, NULL
},
2086 // these are using local (non-global) definitions to reduce package dependancy.
2088 {STRING_TOKEN(STR_ISA_IO
), (EFI_GUID
*)&EfiIsaIoProtocolGuid
, NULL
},
2089 {STRING_TOKEN(STR_ISA_ACPI
), (EFI_GUID
*)&EfiIsaAcpiProtocolGuid
, NULL
},
2092 // the ones under this are GUID identified structs, not protocols
2094 {STRING_TOKEN(STR_FILE_INFO
), &gEfiFileInfoGuid
, NULL
},
2095 {STRING_TOKEN(STR_FILE_SYS_INFO
), &gEfiFileSystemInfoGuid
, NULL
},
2098 // the ones under this are misc GUIDS.
2100 {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE
), &gEfiGlobalVariableGuid
, NULL
},
2105 {STRING_TOKEN(STR_IP6_SB
), &gEfiIp6ServiceBindingProtocolGuid
, NULL
},
2106 {STRING_TOKEN(STR_IP6
), &gEfiIp6ProtocolGuid
, NULL
},
2107 {STRING_TOKEN(STR_IP6_CONFIG
), &gEfiIp6ConfigProtocolGuid
, NULL
},
2108 {STRING_TOKEN(STR_MTFTP6_SB
), &gEfiMtftp6ServiceBindingProtocolGuid
, NULL
},
2109 {STRING_TOKEN(STR_MTFTP6
), &gEfiMtftp6ProtocolGuid
, NULL
},
2110 {STRING_TOKEN(STR_DHCP6_SB
), &gEfiDhcp6ServiceBindingProtocolGuid
, NULL
},
2111 {STRING_TOKEN(STR_DHCP6
), &gEfiDhcp6ProtocolGuid
, NULL
},
2112 {STRING_TOKEN(STR_UDP6_SB
), &gEfiUdp6ServiceBindingProtocolGuid
, NULL
},
2113 {STRING_TOKEN(STR_UDP6
), &gEfiUdp6ProtocolGuid
, NULL
},
2114 {STRING_TOKEN(STR_TCP6_SB
), &gEfiTcp6ServiceBindingProtocolGuid
, NULL
},
2115 {STRING_TOKEN(STR_TCP6
), &gEfiTcp6ProtocolGuid
, NULL
},
2116 {STRING_TOKEN(STR_VLAN_CONFIG
), &gEfiVlanConfigProtocolGuid
, NULL
},
2117 {STRING_TOKEN(STR_EAP
), &gEfiEapProtocolGuid
, NULL
},
2118 {STRING_TOKEN(STR_EAP_MGMT
), &gEfiEapManagementProtocolGuid
, NULL
},
2119 {STRING_TOKEN(STR_FTP4_SB
), &gEfiFtp4ServiceBindingProtocolGuid
, NULL
},
2120 {STRING_TOKEN(STR_FTP4
), &gEfiFtp4ProtocolGuid
, NULL
},
2121 {STRING_TOKEN(STR_IP_SEC_CONFIG
), &gEfiIpSecConfigProtocolGuid
, NULL
},
2122 {STRING_TOKEN(STR_DH
), &gEfiDriverHealthProtocolGuid
, NULL
},
2123 {STRING_TOKEN(STR_DEF_IMG_LOAD
), &gEfiDeferredImageLoadProtocolGuid
, NULL
},
2124 {STRING_TOKEN(STR_USER_CRED
), &gEfiUserCredentialProtocolGuid
, NULL
},
2125 {STRING_TOKEN(STR_USER_MNGR
), &gEfiUserManagerProtocolGuid
, NULL
},
2126 {STRING_TOKEN(STR_ATA_PASS_THRU
), &gEfiAtaPassThruProtocolGuid
, NULL
},
2131 {STRING_TOKEN(STR_FW_MGMT
), &gEfiFirmwareManagementProtocolGuid
, FirmwareManagementDumpInformation
},
2132 {STRING_TOKEN(STR_IP_SEC
), &gEfiIpSecProtocolGuid
, NULL
},
2133 {STRING_TOKEN(STR_IP_SEC2
), &gEfiIpSec2ProtocolGuid
, NULL
},
2138 {STRING_TOKEN(STR_KMS
), &gEfiKmsProtocolGuid
, NULL
},
2139 {STRING_TOKEN(STR_BLK_IO2
), &gEfiBlockIo2ProtocolGuid
, NULL
},
2140 {STRING_TOKEN(STR_SSC
), &gEfiStorageSecurityCommandProtocolGuid
, NULL
},
2141 {STRING_TOKEN(STR_UCRED2
), &gEfiUserCredential2ProtocolGuid
, NULL
},
2146 {STRING_TOKEN(STR_DISK_IO2
), &gEfiDiskIo2ProtocolGuid
, NULL
},
2147 {STRING_TOKEN(STR_ADAPTER_INFO
), &gEfiAdapterInformationProtocolGuid
, AdapterInformationDumpInformation
},
2152 {STRING_TOKEN(STR_TLS_SB
), &gEfiTlsServiceBindingProtocolGuid
, NULL
},
2153 {STRING_TOKEN(STR_TLS
), &gEfiTlsProtocolGuid
, NULL
},
2154 {STRING_TOKEN(STR_TLS_CONFIG
), &gEfiTlsConfigurationProtocolGuid
, NULL
},
2155 {STRING_TOKEN(STR_SUPPLICANT_SB
), &gEfiSupplicantServiceBindingProtocolGuid
, NULL
},
2156 {STRING_TOKEN(STR_SUPPLICANT
), &gEfiSupplicantProtocolGuid
, NULL
},
2161 {STRING_TOKEN(STR_WIFI2
), &gEfiWiFi2ProtocolGuid
, NULL
},
2162 {STRING_TOKEN(STR_RAMDISK
), &gEfiRamDiskProtocolGuid
, NULL
},
2163 {STRING_TOKEN(STR_HII_ID
), &gEfiHiiImageDecoderProtocolGuid
, NULL
},
2164 {STRING_TOKEN(STR_HII_IE
), &gEfiHiiImageExProtocolGuid
, NULL
},
2165 {STRING_TOKEN(STR_SD_MPT
), &gEfiSdMmcPassThruProtocolGuid
, NULL
},
2166 {STRING_TOKEN(STR_ERASE_BLOCK
), &gEfiEraseBlockProtocolGuid
, NULL
},
2171 {STRING_TOKEN(STR_BLUETOOTH_ATTR
), &gEfiBluetoothAttributeProtocolGuid
, NULL
},
2172 {STRING_TOKEN(STR_BLUETOOTH_ATTR_SB
), &gEfiBluetoothAttributeServiceBindingProtocolGuid
, NULL
},
2173 {STRING_TOKEN(STR_BLUETOOTH_LE_CONFIG
), &gEfiBluetoothLeConfigProtocolGuid
, NULL
},
2174 {STRING_TOKEN(STR_UFS_DEV_CONFIG
), &gEfiUfsDeviceConfigProtocolGuid
, NULL
},
2175 {STRING_TOKEN(STR_HTTP_BOOT_CALL
), &gEfiHttpBootCallbackProtocolGuid
, NULL
},
2176 {STRING_TOKEN(STR_RESET_NOTI
), &gEfiResetNotificationProtocolGuid
, NULL
},
2177 {STRING_TOKEN(STR_PARTITION_INFO
), &gEfiPartitionInfoProtocolGuid
, NULL
},
2178 {STRING_TOKEN(STR_HII_POPUP
), &gEfiHiiPopupProtocolGuid
, NULL
},
2183 {STRING_TOKEN(STR_IDE_CONT_INIT
), &gEfiIdeControllerInitProtocolGuid
, NULL
},
2184 {STRING_TOKEN(STR_DISK_INFO
), &gEfiDiskInfoProtocolGuid
, NULL
},
2189 {STRING_TOKEN(STR_BDS_ARCH
), &gEfiBdsArchProtocolGuid
, NULL
},
2190 {STRING_TOKEN(STR_CPU_ARCH
), &gEfiCpuArchProtocolGuid
, NULL
},
2191 {STRING_TOKEN(STR_MET_ARCH
), &gEfiMetronomeArchProtocolGuid
, NULL
},
2192 {STRING_TOKEN(STR_MON_ARCH
), &gEfiMonotonicCounterArchProtocolGuid
, NULL
},
2193 {STRING_TOKEN(STR_RTC_ARCH
), &gEfiRealTimeClockArchProtocolGuid
, NULL
},
2194 {STRING_TOKEN(STR_RESET_ARCH
), &gEfiResetArchProtocolGuid
, NULL
},
2195 {STRING_TOKEN(STR_RT_ARCH
), &gEfiRuntimeArchProtocolGuid
, NULL
},
2196 {STRING_TOKEN(STR_SEC_ARCH
), &gEfiSecurityArchProtocolGuid
, NULL
},
2197 {STRING_TOKEN(STR_TIMER_ARCH
), &gEfiTimerArchProtocolGuid
, NULL
},
2198 {STRING_TOKEN(STR_VAR_ARCH
), &gEfiVariableWriteArchProtocolGuid
, NULL
},
2199 {STRING_TOKEN(STR_V_ARCH
), &gEfiVariableArchProtocolGuid
, NULL
},
2200 {STRING_TOKEN(STR_SECP
), &gEfiSecurityPolicyProtocolGuid
, NULL
},
2201 {STRING_TOKEN(STR_WDT_ARCH
), &gEfiWatchdogTimerArchProtocolGuid
, NULL
},
2202 {STRING_TOKEN(STR_SCR
), &gEfiStatusCodeRuntimeProtocolGuid
, NULL
},
2203 {STRING_TOKEN(STR_SMB_HC
), &gEfiSmbusHcProtocolGuid
, NULL
},
2204 {STRING_TOKEN(STR_FV_2
), &gEfiFirmwareVolume2ProtocolGuid
, NULL
},
2205 {STRING_TOKEN(STR_FV_BLOCK
), &gEfiFirmwareVolumeBlockProtocolGuid
, NULL
},
2206 {STRING_TOKEN(STR_CAP_ARCH
), &gEfiCapsuleArchProtocolGuid
, NULL
},
2207 {STRING_TOKEN(STR_MP_SERVICE
), &gEfiMpServiceProtocolGuid
, NULL
},
2208 {STRING_TOKEN(STR_HBRAP
), &gEfiPciHostBridgeResourceAllocationProtocolGuid
, NULL
},
2209 {STRING_TOKEN(STR_PCIP
), &gEfiPciPlatformProtocolGuid
, NULL
},
2210 {STRING_TOKEN(STR_PCIO
), &gEfiPciOverrideProtocolGuid
, NULL
},
2211 {STRING_TOKEN(STR_PCIE
), &gEfiPciEnumerationCompleteProtocolGuid
, NULL
},
2212 {STRING_TOKEN(STR_IPCID
), &gEfiIncompatiblePciDeviceSupportProtocolGuid
, NULL
},
2213 {STRING_TOKEN(STR_PCIHPI
), &gEfiPciHotPlugInitProtocolGuid
, NULL
},
2214 {STRING_TOKEN(STR_PCIHPR
), &gEfiPciHotPlugRequestProtocolGuid
, NULL
},
2215 {STRING_TOKEN(STR_SMBIOS
), &gEfiSmbiosProtocolGuid
, NULL
},
2216 {STRING_TOKEN(STR_S3_SAVE
), &gEfiS3SaveStateProtocolGuid
, NULL
},
2217 {STRING_TOKEN(STR_S3_S_SMM
), &gEfiS3SmmSaveStateProtocolGuid
, NULL
},
2218 {STRING_TOKEN(STR_RSC
), &gEfiRscHandlerProtocolGuid
, NULL
},
2219 {STRING_TOKEN(STR_S_RSC
), &gEfiSmmRscHandlerProtocolGuid
, NULL
},
2220 {STRING_TOKEN(STR_ACPI_SDT
), &gEfiAcpiSdtProtocolGuid
, NULL
},
2221 {STRING_TOKEN(STR_SIO
), &gEfiSioProtocolGuid
, NULL
},
2222 {STRING_TOKEN(STR_S_CPU2
), &gEfiSmmCpuIo2ProtocolGuid
, NULL
},
2223 {STRING_TOKEN(STR_S_BASE2
), &gEfiSmmBase2ProtocolGuid
, NULL
},
2224 {STRING_TOKEN(STR_S_ACC_2
), &gEfiSmmAccess2ProtocolGuid
, NULL
},
2225 {STRING_TOKEN(STR_S_CON_2
), &gEfiSmmControl2ProtocolGuid
, NULL
},
2226 {STRING_TOKEN(STR_S_CONFIG
), &gEfiSmmConfigurationProtocolGuid
, NULL
},
2227 {STRING_TOKEN(STR_S_RTL
), &gEfiSmmReadyToLockProtocolGuid
, NULL
},
2228 {STRING_TOKEN(STR_DS_RTL
), &gEfiDxeSmmReadyToLockProtocolGuid
, NULL
},
2229 {STRING_TOKEN(STR_S_COMM
), &gEfiSmmCommunicationProtocolGuid
, NULL
},
2230 {STRING_TOKEN(STR_S_STAT
), &gEfiSmmStatusCodeProtocolGuid
, NULL
},
2231 {STRING_TOKEN(STR_S_CPU
), &gEfiSmmCpuProtocolGuid
, NULL
},
2232 {STRING_TOKEN(STR_S_PCIRBIO
), &gEfiPciRootBridgeIoProtocolGuid
, NULL
},
2233 {STRING_TOKEN(STR_S_SWD
), &gEfiSmmSwDispatch2ProtocolGuid
, NULL
},
2234 {STRING_TOKEN(STR_S_SXD
), &gEfiSmmSxDispatch2ProtocolGuid
, NULL
},
2235 {STRING_TOKEN(STR_S_PTD2
), &gEfiSmmPeriodicTimerDispatch2ProtocolGuid
, NULL
},
2236 {STRING_TOKEN(STR_S_UD2
), &gEfiSmmUsbDispatch2ProtocolGuid
, NULL
},
2237 {STRING_TOKEN(STR_S_GD2
), &gEfiSmmGpiDispatch2ProtocolGuid
, NULL
},
2238 {STRING_TOKEN(STR_S_SBD2
), &gEfiSmmStandbyButtonDispatch2ProtocolGuid
, NULL
},
2239 {STRING_TOKEN(STR_S_PBD2
), &gEfiSmmPowerButtonDispatch2ProtocolGuid
, NULL
},
2240 {STRING_TOKEN(STR_S_ITD2
), &gEfiSmmIoTrapDispatch2ProtocolGuid
, NULL
},
2241 {STRING_TOKEN(STR_PCD
), &gEfiPcdProtocolGuid
, NULL
},
2242 {STRING_TOKEN(STR_FVB2
), &gEfiFirmwareVolumeBlock2ProtocolGuid
, NULL
},
2243 {STRING_TOKEN(STR_CPUIO2
), &gEfiCpuIo2ProtocolGuid
, NULL
},
2244 {STRING_TOKEN(STR_LEGACY_R2
), &gEfiLegacyRegion2ProtocolGuid
, NULL
},
2245 {STRING_TOKEN(STR_SAL_MIP
), &gEfiSalMcaInitPmiProtocolGuid
, NULL
},
2246 {STRING_TOKEN(STR_ES_BS
), &gEfiExtendedSalBootServiceProtocolGuid
, NULL
},
2247 {STRING_TOKEN(STR_ES_BIO
), &gEfiExtendedSalBaseIoServicesProtocolGuid
, NULL
},
2248 {STRING_TOKEN(STR_ES_STALL
), &gEfiExtendedSalStallServicesProtocolGuid
, NULL
},
2249 {STRING_TOKEN(STR_ES_RTC
), &gEfiExtendedSalRtcServicesProtocolGuid
, NULL
},
2250 {STRING_TOKEN(STR_ES_VS
), &gEfiExtendedSalVariableServicesProtocolGuid
, NULL
},
2251 {STRING_TOKEN(STR_ES_MTC
), &gEfiExtendedSalMtcServicesProtocolGuid
, NULL
},
2252 {STRING_TOKEN(STR_ES_RESET
), &gEfiExtendedSalResetServicesProtocolGuid
, NULL
},
2253 {STRING_TOKEN(STR_ES_SC
), &gEfiExtendedSalStatusCodeServicesProtocolGuid
, NULL
},
2254 {STRING_TOKEN(STR_ES_FBS
), &gEfiExtendedSalFvBlockServicesProtocolGuid
, NULL
},
2255 {STRING_TOKEN(STR_ES_MP
), &gEfiExtendedSalMpServicesProtocolGuid
, NULL
},
2256 {STRING_TOKEN(STR_ES_PAL
), &gEfiExtendedSalPalServicesProtocolGuid
, NULL
},
2257 {STRING_TOKEN(STR_ES_BASE
), &gEfiExtendedSalBaseServicesProtocolGuid
, NULL
},
2258 {STRING_TOKEN(STR_ES_MCA
), &gEfiExtendedSalMcaServicesProtocolGuid
, NULL
},
2259 {STRING_TOKEN(STR_ES_PCI
), &gEfiExtendedSalPciServicesProtocolGuid
, NULL
},
2260 {STRING_TOKEN(STR_ES_CACHE
), &gEfiExtendedSalCacheServicesProtocolGuid
, NULL
},
2261 {STRING_TOKEN(STR_ES_MCA_LOG
), &gEfiExtendedSalMcaLogServicesProtocolGuid
, NULL
},
2262 {STRING_TOKEN(STR_S2ARCH
), &gEfiSecurity2ArchProtocolGuid
, NULL
},
2263 {STRING_TOKEN(STR_EODXE
), &gEfiSmmEndOfDxeProtocolGuid
, NULL
},
2264 {STRING_TOKEN(STR_ISAHC
), &gEfiIsaHcProtocolGuid
, NULL
},
2265 {STRING_TOKEN(STR_ISAHC_B
), &gEfiIsaHcServiceBindingProtocolGuid
, NULL
},
2266 {STRING_TOKEN(STR_SIO_C
), &gEfiSioControlProtocolGuid
, NULL
},
2267 {STRING_TOKEN(STR_GET_PCD
), &gEfiGetPcdInfoProtocolGuid
, NULL
},
2268 {STRING_TOKEN(STR_I2C_M
), &gEfiI2cMasterProtocolGuid
, NULL
},
2269 {STRING_TOKEN(STR_I2CIO
), &gEfiI2cIoProtocolGuid
, NULL
},
2270 {STRING_TOKEN(STR_I2CEN
), &gEfiI2cEnumerateProtocolGuid
, NULL
},
2271 {STRING_TOKEN(STR_I2C_H
), &gEfiI2cHostProtocolGuid
, NULL
},
2272 {STRING_TOKEN(STR_I2C_BCM
), &gEfiI2cBusConfigurationManagementProtocolGuid
, NULL
},
2273 {STRING_TOKEN(STR_TREE
), &gEfiTrEEProtocolGuid
, NULL
},
2274 {STRING_TOKEN(STR_TCG2
), &gEfiTcg2ProtocolGuid
, NULL
},
2275 {STRING_TOKEN(STR_TIMESTAMP
), &gEfiTimestampProtocolGuid
, NULL
},
2276 {STRING_TOKEN(STR_RNG
), &gEfiRngProtocolGuid
, NULL
},
2277 {STRING_TOKEN(STR_NVMEPT
), &gEfiNvmExpressPassThruProtocolGuid
, NULL
},
2278 {STRING_TOKEN(STR_H2_SB
), &gEfiHash2ServiceBindingProtocolGuid
, NULL
},
2279 {STRING_TOKEN(STR_HASH2
), &gEfiHash2ProtocolGuid
, NULL
},
2280 {STRING_TOKEN(STR_BIO_C
), &gEfiBlockIoCryptoProtocolGuid
, NULL
},
2281 {STRING_TOKEN(STR_SCR
), &gEfiSmartCardReaderProtocolGuid
, NULL
},
2282 {STRING_TOKEN(STR_SCE
), &gEfiSmartCardEdgeProtocolGuid
, NULL
},
2283 {STRING_TOKEN(STR_USB_FIO
), &gEfiUsbFunctionIoProtocolGuid
, NULL
},
2284 {STRING_TOKEN(STR_BC_HC
), &gEfiBluetoothHcProtocolGuid
, NULL
},
2285 {STRING_TOKEN(STR_BC_IO_SB
), &gEfiBluetoothIoServiceBindingProtocolGuid
, NULL
},
2286 {STRING_TOKEN(STR_BC_IO
), &gEfiBluetoothIoProtocolGuid
, NULL
},
2287 {STRING_TOKEN(STR_BC_C
), &gEfiBluetoothConfigProtocolGuid
, NULL
},
2288 {STRING_TOKEN(STR_REG_EXP
), &gEfiRegularExpressionProtocolGuid
, NULL
},
2289 {STRING_TOKEN(STR_B_MGR_P
), &gEfiBootManagerPolicyProtocolGuid
, NULL
},
2290 {STRING_TOKEN(STR_CKH
), &gEfiConfigKeywordHandlerProtocolGuid
, NULL
},
2291 {STRING_TOKEN(STR_WIFI
), &gEfiWiFiProtocolGuid
, NULL
},
2292 {STRING_TOKEN(STR_EAP_M
), &gEfiEapManagement2ProtocolGuid
, NULL
},
2293 {STRING_TOKEN(STR_EAP_C
), &gEfiEapConfigurationProtocolGuid
, NULL
},
2294 {STRING_TOKEN(STR_PKCS7
), &gEfiPkcs7VerifyProtocolGuid
, NULL
},
2295 {STRING_TOKEN(STR_NET_DNS4_SB
), &gEfiDns4ServiceBindingProtocolGuid
, NULL
},
2296 {STRING_TOKEN(STR_NET_DNS4
), &gEfiDns4ProtocolGuid
, NULL
},
2297 {STRING_TOKEN(STR_NET_DNS6_SB
), &gEfiDns6ServiceBindingProtocolGuid
, NULL
},
2298 {STRING_TOKEN(STR_NET_DNS6
), &gEfiDns6ProtocolGuid
, NULL
},
2299 {STRING_TOKEN(STR_NET_HTTP_SB
), &gEfiHttpServiceBindingProtocolGuid
, NULL
},
2300 {STRING_TOKEN(STR_NET_HTTP
), &gEfiHttpProtocolGuid
, NULL
},
2301 {STRING_TOKEN(STR_NET_HTTP_U
), &gEfiHttpUtilitiesProtocolGuid
, NULL
},
2302 {STRING_TOKEN(STR_REST
), &gEfiRestProtocolGuid
, NULL
},
2307 {STRING_TOKEN(STR_MM_EOD
), &gEfiMmEndOfDxeProtocolGuid
, NULL
},
2308 {STRING_TOKEN(STR_MM_ITD
), &gEfiMmIoTrapDispatchProtocolGuid
, NULL
},
2309 {STRING_TOKEN(STR_MM_PBD
), &gEfiMmPowerButtonDispatchProtocolGuid
, NULL
},
2310 {STRING_TOKEN(STR_MM_SBD
), &gEfiMmStandbyButtonDispatchProtocolGuid
, NULL
},
2311 {STRING_TOKEN(STR_MM_GD
), &gEfiMmGpiDispatchProtocolGuid
, NULL
},
2312 {STRING_TOKEN(STR_MM_UD
), &gEfiMmUsbDispatchProtocolGuid
, NULL
},
2313 {STRING_TOKEN(STR_MM_PTD
), &gEfiMmPeriodicTimerDispatchProtocolGuid
, NULL
},
2314 {STRING_TOKEN(STR_MM_SXD
), &gEfiMmSxDispatchProtocolGuid
, NULL
},
2315 {STRING_TOKEN(STR_MM_SWD
), &gEfiMmSwDispatchProtocolGuid
, NULL
},
2316 {STRING_TOKEN(STR_MM_PRBI
), &gEfiMmPciRootBridgeIoProtocolGuid
, NULL
},
2317 {STRING_TOKEN(STR_MM_CPU
), &gEfiMmCpuProtocolGuid
, NULL
},
2318 {STRING_TOKEN(STR_MM_STACODE
), &gEfiMmStatusCodeProtocolGuid
, NULL
},
2319 {STRING_TOKEN(STR_DXEMM_RTL
), &gEfiDxeMmReadyToLockProtocolGuid
, NULL
},
2320 {STRING_TOKEN(STR_MM_CONFIG
), &gEfiMmConfigurationProtocolGuid
, NULL
},
2321 {STRING_TOKEN(STR_MM_RTL
), &gEfiMmReadyToLockProtocolGuid
, NULL
},
2322 {STRING_TOKEN(STR_MM_CONTROL
), &gEfiMmControlProtocolGuid
, NULL
},
2323 {STRING_TOKEN(STR_MM_ACCESS
), &gEfiMmAccessProtocolGuid
, NULL
},
2324 {STRING_TOKEN(STR_MM_BASE
), &gEfiMmBaseProtocolGuid
, NULL
},
2325 {STRING_TOKEN(STR_MM_CPUIO
), &gEfiMmCpuIoProtocolGuid
, NULL
},
2326 {STRING_TOKEN(STR_MM_RH
), &gEfiMmRscHandlerProtocolGuid
, NULL
},
2327 {STRING_TOKEN(STR_MM_COM
), &gEfiMmCommunicationProtocolGuid
, NULL
},
2330 // UEFI Shell Spec 2.0
2332 {STRING_TOKEN(STR_SHELL_PARAMETERS
), &gEfiShellParametersProtocolGuid
, NULL
},
2333 {STRING_TOKEN(STR_SHELL
), &gEfiShellProtocolGuid
, NULL
},
2336 // UEFI Shell Spec 2.1
2338 {STRING_TOKEN(STR_SHELL_DYNAMIC
), &gEfiShellDynamicCommandProtocolGuid
, NULL
},
2343 {STRING_TOKEN(STR_PCDINFOPROT
), &gGetPcdInfoProtocolGuid
, NULL
},
2352 Function to get the node for a protocol or struct from it's GUID.
2354 if Guid is NULL, then ASSERT.
2356 @param[in] Guid The GUID to look for the name of.
2360 CONST GUID_INFO_BLOCK
*
2361 InternalShellGetNodeFromGuid(
2362 IN CONST EFI_GUID
* Guid
2365 CONST GUID_INFO_BLOCK
*ListWalker
;
2368 ASSERT(Guid
!= NULL
);
2370 for (LoopCount
= 0, ListWalker
= mGuidList
; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++, ListWalker
++) {
2371 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
2372 return (ListWalker
);
2376 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
2377 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2378 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
2379 return (ListWalker
);
2383 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2384 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
2385 return (ListWalker
);
2392 Function to add a new GUID/Name mapping.
2394 @param[in] Guid The Guid
2395 @param[in] NameID The STRING id of the HII string to use
2396 @param[in] DumpFunc The pointer to the dump function
2399 @retval EFI_SUCCESS The operation was sucessful
2400 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
2401 @retval EFI_INVALID_PARAMETER Guid NameId was invalid
2404 InsertNewGuidNameMapping(
2405 IN CONST EFI_GUID
*Guid
,
2406 IN CONST EFI_STRING_ID NameID
,
2407 IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
2410 ASSERT(Guid
!= NULL
);
2411 ASSERT(NameID
!= 0);
2413 mGuidList
= ReallocatePool(mGuidListCount
* sizeof(GUID_INFO_BLOCK
), mGuidListCount
+1 * sizeof(GUID_INFO_BLOCK
), mGuidList
);
2414 if (mGuidList
== NULL
) {
2416 return (EFI_OUT_OF_RESOURCES
);
2420 mGuidList
[mGuidListCount
- 1].GuidId
= AllocateCopyPool(sizeof(EFI_GUID
), Guid
);
2421 mGuidList
[mGuidListCount
- 1].StringId
= NameID
;
2422 mGuidList
[mGuidListCount
- 1].DumpInfo
= DumpFunc
;
2424 if (mGuidList
[mGuidListCount
- 1].GuidId
== NULL
) {
2425 return (EFI_OUT_OF_RESOURCES
);
2428 return (EFI_SUCCESS
);
2432 Function to add a new GUID/Name mapping.
2434 This cannot overwrite an existing mapping.
2436 @param[in] Guid The Guid
2437 @param[in] TheName The Guid's name
2438 @param[in] Lang RFC4646 language code list or NULL
2440 @retval EFI_SUCCESS The operation was sucessful
2441 @retval EFI_ACCESS_DENIED There was a duplicate
2442 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
2443 @retval EFI_INVALID_PARAMETER Guid or TheName was NULL
2447 AddNewGuidNameMapping(
2448 IN CONST EFI_GUID
*Guid
,
2449 IN CONST CHAR16
*TheName
,
2450 IN CONST CHAR8
*Lang OPTIONAL
2453 EFI_STRING_ID NameID
;
2455 HandleParsingHiiInit();
2457 if (Guid
== NULL
|| TheName
== NULL
){
2458 return (EFI_INVALID_PARAMETER
);
2461 if ((InternalShellGetNodeFromGuid(Guid
)) != NULL
) {
2462 return (EFI_ACCESS_DENIED
);
2465 NameID
= HiiSetString(mHandleParsingHiiHandle
, 0, (CHAR16
*)TheName
, Lang
);
2467 return (EFI_OUT_OF_RESOURCES
);
2470 return (InsertNewGuidNameMapping(Guid
, NameID
, NULL
));
2474 Function to get the name of a protocol or struct from it's GUID.
2476 if Guid is NULL, then ASSERT.
2478 @param[in] Guid The GUID to look for the name of.
2479 @param[in] Lang The language to use.
2481 @return pointer to string of the name. The caller
2482 is responsible to free this memory.
2486 GetStringNameFromGuid(
2487 IN CONST EFI_GUID
*Guid
,
2488 IN CONST CHAR8
*Lang OPTIONAL
2491 CONST GUID_INFO_BLOCK
*Id
;
2493 HandleParsingHiiInit();
2495 Id
= InternalShellGetNodeFromGuid(Guid
);
2499 return HiiGetString (mHandleParsingHiiHandle
, Id
->StringId
, Lang
);
2503 Function to dump protocol information from a handle.
2505 This function will return a allocated string buffer containing the
2506 information. The caller is responsible for freeing the memory.
2508 If Guid is NULL, ASSERT().
2509 If TheHandle is NULL, ASSERT().
2511 @param[in] TheHandle The handle to dump information from.
2512 @param[in] Guid The GUID of the protocol to dump.
2513 @param[in] Verbose TRUE for extra info. FALSE otherwise.
2515 @return The pointer to string.
2516 @retval NULL An error was encountered.
2520 GetProtocolInformationDump(
2521 IN CONST EFI_HANDLE TheHandle
,
2522 IN CONST EFI_GUID
*Guid
,
2523 IN CONST BOOLEAN Verbose
2526 CONST GUID_INFO_BLOCK
*Id
;
2528 ASSERT(TheHandle
!= NULL
);
2529 ASSERT(Guid
!= NULL
);
2531 if (TheHandle
== NULL
|| Guid
== NULL
) {
2535 Id
= InternalShellGetNodeFromGuid(Guid
);
2536 if (Id
!= NULL
&& Id
->DumpInfo
!= NULL
) {
2537 return (Id
->DumpInfo(TheHandle
, Verbose
));
2543 Function to get the Guid for a protocol or struct based on it's string name.
2545 do not modify the returned Guid.
2547 @param[in] Name The pointer to the string name.
2548 @param[in] Lang The pointer to the language code.
2549 @param[out] Guid The pointer to the Guid.
2551 @retval EFI_SUCCESS The operation was sucessful.
2555 GetGuidFromStringName(
2556 IN CONST CHAR16
*Name
,
2557 IN CONST CHAR8
*Lang OPTIONAL
,
2561 CONST GUID_INFO_BLOCK
*ListWalker
;
2565 HandleParsingHiiInit();
2567 ASSERT(Guid
!= NULL
);
2569 return (EFI_INVALID_PARAMETER
);
2573 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
2574 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2575 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2576 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2577 *Guid
= ListWalker
->GuidId
;
2579 SHELL_FREE_NON_NULL(String
);
2580 if (*Guid
!= NULL
) {
2581 return (EFI_SUCCESS
);
2585 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2586 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2587 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2588 *Guid
= ListWalker
->GuidId
;
2590 SHELL_FREE_NON_NULL(String
);
2591 if (*Guid
!= NULL
) {
2592 return (EFI_SUCCESS
);
2596 for (LoopCount
= 0, ListWalker
= mGuidList
; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++, ListWalker
++) {
2597 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2598 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2599 *Guid
= ListWalker
->GuidId
;
2601 SHELL_FREE_NON_NULL(String
);
2602 if (*Guid
!= NULL
) {
2603 return (EFI_SUCCESS
);
2607 return (EFI_NOT_FOUND
);
2611 Get best support language for this driver.
2613 First base on the user input language to search, second base on the current
2614 platform used language to search, third get the first language from the
2615 support language list. The caller need to free the buffer of the best language.
2617 @param[in] SupportedLanguages The support languages for this driver.
2618 @param[in] InputLanguage The user input language.
2619 @param[in] Iso639Language Whether get language for ISO639.
2621 @return The best support language for this driver.
2625 GetBestLanguageForDriver (
2626 IN CONST CHAR8
*SupportedLanguages
,
2627 IN CONST CHAR8
*InputLanguage
,
2628 IN BOOLEAN Iso639Language
2631 CHAR8
*LanguageVariable
;
2632 CHAR8
*BestLanguage
;
2634 GetVariable2 (Iso639Language
? L
"Lang" : L
"PlatformLang", &gEfiGlobalVariableGuid
, (VOID
**)&LanguageVariable
, NULL
);
2636 BestLanguage
= GetBestLanguage(
2639 (InputLanguage
!= NULL
) ? InputLanguage
: "",
2640 (LanguageVariable
!= NULL
) ? LanguageVariable
: "",
2645 if (LanguageVariable
!= NULL
) {
2646 FreePool (LanguageVariable
);
2649 return BestLanguage
;
2653 Function to retrieve the driver name (if possible) from the ComponentName or
2654 ComponentName2 protocol
2656 @param[in] TheHandle The driver handle to get the name of.
2657 @param[in] Language The language to use.
2659 @retval NULL The name could not be found.
2660 @return A pointer to the string name. Do not de-allocate the memory.
2664 GetStringNameFromHandle(
2665 IN CONST EFI_HANDLE TheHandle
,
2666 IN CONST CHAR8
*Language
2669 EFI_COMPONENT_NAME2_PROTOCOL
*CompNameStruct
;
2676 Status
= gBS
->OpenProtocol(
2678 &gEfiComponentName2ProtocolGuid
,
2679 (VOID
**)&CompNameStruct
,
2682 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2683 if (!EFI_ERROR(Status
)) {
2684 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2685 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2686 if (BestLang
!= NULL
) {
2687 FreePool (BestLang
);
2690 if (!EFI_ERROR(Status
)) {
2694 Status
= gBS
->OpenProtocol(
2696 &gEfiComponentNameProtocolGuid
,
2697 (VOID
**)&CompNameStruct
,
2700 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2701 if (!EFI_ERROR(Status
)) {
2702 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2703 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2704 if (BestLang
!= NULL
) {
2705 FreePool (BestLang
);
2707 if (!EFI_ERROR(Status
)) {
2715 Function to initialize the file global mHandleList object for use in
2716 vonverting handles to index and index to handle.
2718 @retval EFI_SUCCESS The operation was successful.
2721 InternalShellInitHandleList(
2726 EFI_HANDLE
*HandleBuffer
;
2728 HANDLE_LIST
*ListWalker
;
2730 if (mHandleList
.NextIndex
!= 0) {
2733 InitializeListHead(&mHandleList
.List
.Link
);
2734 mHandleList
.NextIndex
= 1;
2735 Status
= gBS
->LocateHandleBuffer (
2742 ASSERT_EFI_ERROR(Status
);
2743 if (EFI_ERROR(Status
)) {
2746 for (mHandleList
.NextIndex
= 1 ; mHandleList
.NextIndex
<= HandleCount
; mHandleList
.NextIndex
++){
2747 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2748 if (ListWalker
!= NULL
) {
2749 ListWalker
->TheHandle
= HandleBuffer
[mHandleList
.NextIndex
- 1];
2750 ListWalker
->TheIndex
= mHandleList
.NextIndex
;
2751 InsertTailList (&mHandleList
.List
.Link
, &ListWalker
->Link
);
2754 FreePool(HandleBuffer
);
2755 return (EFI_SUCCESS
);
2759 Function to retrieve the human-friendly index of a given handle. If the handle
2760 does not have a index one will be automatically assigned. The index value is valid
2761 until the termination of the shell application.
2763 @param[in] TheHandle The handle to retrieve an index for.
2765 @retval 0 A memory allocation failed.
2766 @return The index of the handle.
2771 ConvertHandleToHandleIndex(
2772 IN CONST EFI_HANDLE TheHandle
2776 EFI_GUID
**ProtocolBuffer
;
2777 UINTN ProtocolCount
;
2778 HANDLE_LIST
*ListWalker
;
2780 if (TheHandle
== NULL
) {
2784 InternalShellInitHandleList();
2786 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2787 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2788 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2790 if (ListWalker
->TheHandle
== TheHandle
) {
2792 // Verify that TheHandle is still present in the Handle Database
2794 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2795 if (EFI_ERROR (Status
)) {
2797 // TheHandle is not present in the Handle Database, so delete from the handle list
2799 RemoveEntryList (&ListWalker
->Link
);
2802 FreePool (ProtocolBuffer
);
2803 return (ListWalker
->TheIndex
);
2808 // Verify that TheHandle is valid handle
2810 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2811 if (EFI_ERROR (Status
)) {
2813 // TheHandle is not valid, so do not add to handle list
2817 FreePool (ProtocolBuffer
);
2819 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2820 if (ListWalker
== NULL
) {
2823 ListWalker
->TheHandle
= TheHandle
;
2824 ListWalker
->TheIndex
= mHandleList
.NextIndex
++;
2825 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
2826 return (ListWalker
->TheIndex
);
2832 Function to retrieve the EFI_HANDLE from the human-friendly index.
2834 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.
2836 @retval NULL The index was invalid.
2837 @return The EFI_HANDLE that index represents.
2842 ConvertHandleIndexToHandle(
2843 IN CONST UINTN TheIndex
2847 EFI_GUID
**ProtocolBuffer
;
2848 UINTN ProtocolCount
;
2849 HANDLE_LIST
*ListWalker
;
2851 InternalShellInitHandleList();
2853 if (TheIndex
>= mHandleList
.NextIndex
) {
2857 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2858 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2859 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2861 if (ListWalker
->TheIndex
== TheIndex
&& ListWalker
->TheHandle
!= NULL
) {
2863 // Verify that LinkWalker->TheHandle is valid handle
2865 Status
= gBS
->ProtocolsPerHandle(ListWalker
->TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2866 if (!EFI_ERROR (Status
)) {
2867 FreePool (ProtocolBuffer
);
2870 // TheHandle is not valid, so do not add to handle list
2872 ListWalker
->TheHandle
= NULL
;
2874 return (ListWalker
->TheHandle
);
2881 Gets all the related EFI_HANDLEs based on the mask supplied.
2883 This function scans all EFI_HANDLES in the UEFI environment's handle database
2884 and returns the ones with the specified relationship (Mask) to the specified
2887 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2888 If MatchingHandleCount is NULL, then ASSERT.
2890 If MatchingHandleBuffer is not NULL upon a successful return the memory must be
2893 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.
2894 @param[in] ControllerHandle The handle with Device Path protocol on it.
2895 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in
2896 MatchingHandleBuffer.
2897 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount
2898 EFI_HANDLEs with a terminating NULL EFI_HANDLE.
2899 @param[out] HandleType An array of type information.
2901 @retval EFI_SUCCESS The operation was successful, and any related handles
2902 are in MatchingHandleBuffer.
2903 @retval EFI_NOT_FOUND No matching handles were found.
2904 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2908 ParseHandleDatabaseByRelationshipWithType (
2909 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
2910 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
2911 IN UINTN
*HandleCount
,
2912 OUT EFI_HANDLE
**HandleBuffer
,
2913 OUT UINTN
**HandleType
2918 EFI_GUID
**ProtocolGuidArray
;
2920 UINTN ProtocolIndex
;
2921 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfo
;
2922 UINTN OpenInfoCount
;
2923 UINTN OpenInfoIndex
;
2925 INTN DriverBindingHandleIndex
;
2927 ASSERT(HandleCount
!= NULL
);
2928 ASSERT(HandleBuffer
!= NULL
);
2929 ASSERT(HandleType
!= NULL
);
2930 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
2933 *HandleBuffer
= NULL
;
2937 // Retrieve the list of all handles from the handle database
2939 Status
= gBS
->LocateHandleBuffer (
2946 if (EFI_ERROR (Status
)) {
2950 *HandleType
= AllocateZeroPool (*HandleCount
* sizeof (UINTN
));
2951 if (*HandleType
== NULL
) {
2952 SHELL_FREE_NON_NULL (*HandleBuffer
);
2954 return EFI_OUT_OF_RESOURCES
;
2957 DriverBindingHandleIndex
= -1;
2958 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
2959 if (DriverBindingHandle
!= NULL
&& (*HandleBuffer
)[HandleIndex
] == DriverBindingHandle
) {
2960 DriverBindingHandleIndex
= (INTN
)HandleIndex
;
2964 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
2966 // Retrieve the list of all the protocols on each handle
2968 Status
= gBS
->ProtocolsPerHandle (
2969 (*HandleBuffer
)[HandleIndex
],
2973 if (EFI_ERROR (Status
)) {
2977 for (ProtocolIndex
= 0; ProtocolIndex
< ArrayCount
; ProtocolIndex
++) {
2980 // Set the bit describing what this handle has
2982 if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiLoadedImageProtocolGuid
) ) {
2983 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_IMAGE_HANDLE
;
2984 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverBindingProtocolGuid
) ) {
2985 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_BINDING_HANDLE
;
2986 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfiguration2ProtocolGuid
)) {
2987 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
2988 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfigurationProtocolGuid
) ) {
2989 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
2990 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnostics2ProtocolGuid
) ) {
2991 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
2992 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnosticsProtocolGuid
) ) {
2993 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
2994 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentName2ProtocolGuid
) ) {
2995 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
2996 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentNameProtocolGuid
) ) {
2997 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
2998 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDevicePathProtocolGuid
) ) {
2999 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DEVICE_HANDLE
;
3002 // Retrieve the list of agents that have opened each protocol
3004 Status
= gBS
->OpenProtocolInformation (
3005 (*HandleBuffer
)[HandleIndex
],
3006 ProtocolGuidArray
[ProtocolIndex
],
3010 if (EFI_ERROR (Status
)) {
3014 if (ControllerHandle
== NULL
) {
3016 // ControllerHandle == NULL and DriverBindingHandle != NULL.
3017 // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
3019 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
3020 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
3021 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
3022 if (DriverBindingHandleIndex
!= -1) {
3023 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
3026 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
3027 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
3028 if (DriverBindingHandleIndex
!= -1) {
3029 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
3031 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
3032 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
3033 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
3039 if (DriverBindingHandle
== NULL
&& ControllerHandle
!= NULL
) {
3040 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
3041 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
3042 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
3043 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
3044 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
3045 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
3046 (*HandleType
)[ChildIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
3050 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
3051 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
3052 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
3053 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
3055 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
3056 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
3062 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
3063 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
3064 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
3065 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
3071 if (DriverBindingHandle
!= NULL
&& ControllerHandle
!= NULL
) {
3072 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
3073 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
3074 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
3075 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
3076 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
3077 if (DriverBindingHandleIndex
!= -1) {
3078 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
3082 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
3083 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
3084 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
3085 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
3086 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
3091 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
3092 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
3093 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
3099 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
3100 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
3101 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
3102 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
3108 FreePool (OpenInfo
);
3110 FreePool (ProtocolGuidArray
);
3116 Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask
3119 This function will scan all EFI_HANDLES in the UEFI environment's handle database
3120 and return all the ones with the specified relationship (Mask) to the specified
3123 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
3124 If MatchingHandleCount is NULL, then ASSERT.
3126 If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be
3129 @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol
3131 @param[in] ControllerHandle Handle to a device with Device Path protocol on it.
3132 @param[in] Mask Mask of what relationship(s) is desired.
3133 @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in
3134 MatchingHandleBuffer.
3135 @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount
3136 EFI_HANDLEs and a terminating NULL EFI_HANDLE.
3138 @retval EFI_SUCCESS The operation was sucessful and any related handles
3139 are in MatchingHandleBuffer;
3140 @retval EFI_NOT_FOUND No matching handles were found.
3141 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
3145 ParseHandleDatabaseByRelationship (
3146 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
3147 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
3148 IN CONST UINTN Mask
,
3149 IN UINTN
*MatchingHandleCount
,
3150 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
3155 EFI_HANDLE
*HandleBuffer
;
3159 ASSERT(MatchingHandleCount
!= NULL
);
3160 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
3162 if ((Mask
& HR_VALID_MASK
) != Mask
) {
3163 return (EFI_INVALID_PARAMETER
);
3166 if ((Mask
& HR_CHILD_HANDLE
) != 0 && DriverBindingHandle
== NULL
) {
3167 return (EFI_INVALID_PARAMETER
);
3170 *MatchingHandleCount
= 0;
3171 if (MatchingHandleBuffer
!= NULL
) {
3172 *MatchingHandleBuffer
= NULL
;
3175 HandleBuffer
= NULL
;
3178 Status
= ParseHandleDatabaseByRelationshipWithType (
3179 DriverBindingHandle
,
3185 if (!EFI_ERROR (Status
)) {
3187 // Count the number of handles that match the attributes in Mask
3189 for (HandleIndex
= 0; HandleIndex
< HandleCount
; HandleIndex
++) {
3190 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
3191 (*MatchingHandleCount
)++;
3195 // If no handles match the attributes in Mask then return EFI_NOT_FOUND
3197 if (*MatchingHandleCount
== 0) {
3198 Status
= EFI_NOT_FOUND
;
3201 if (MatchingHandleBuffer
== NULL
) {
3203 // Someone just wanted the count...
3205 Status
= EFI_SUCCESS
;
3208 // Allocate a handle buffer for the number of handles that matched the attributes in Mask
3210 *MatchingHandleBuffer
= AllocateZeroPool ((*MatchingHandleCount
+1)* sizeof (EFI_HANDLE
));
3211 if (*MatchingHandleBuffer
== NULL
) {
3212 Status
= EFI_OUT_OF_RESOURCES
;
3214 for (HandleIndex
= 0, *MatchingHandleCount
= 0
3215 ; HandleIndex
< HandleCount
3219 // Fill the allocated buffer with the handles that matched the attributes in Mask
3221 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
3222 (*MatchingHandleBuffer
)[(*MatchingHandleCount
)++] = HandleBuffer
[HandleIndex
];
3227 // Make the last one NULL
3229 (*MatchingHandleBuffer
)[*MatchingHandleCount
] = NULL
;
3231 Status
= EFI_SUCCESS
;
3232 } // *MatchingHandleBuffer == NULL (ELSE)
3233 } // MacthingHandleBuffer == NULL (ELSE)
3234 } // *MatchingHandleCount == 0 (ELSE)
3235 } // no error on ParseHandleDatabaseByRelationshipWithType
3237 if (HandleBuffer
!= NULL
) {
3238 FreePool (HandleBuffer
);
3241 if (HandleType
!= NULL
) {
3242 FreePool (HandleType
);
3245 ASSERT ((MatchingHandleBuffer
== NULL
) ||
3246 (*MatchingHandleCount
== 0 && *MatchingHandleBuffer
== NULL
) ||
3247 (*MatchingHandleCount
!= 0 && *MatchingHandleBuffer
!= NULL
));
3252 Gets handles for any child controllers of the passed in controller.
3254 @param[in] ControllerHandle The handle of the "parent controller"
3255 @param[out] MatchingHandleCount Pointer to the number of handles in
3256 MatchingHandleBuffer on return.
3257 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
3261 @retval EFI_SUCCESS The operation was sucessful.
3265 ParseHandleDatabaseForChildControllers(
3266 IN CONST EFI_HANDLE ControllerHandle
,
3267 OUT UINTN
*MatchingHandleCount
,
3268 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
3273 UINTN DriverBindingHandleCount
;
3274 EFI_HANDLE
*DriverBindingHandleBuffer
;
3275 UINTN DriverBindingHandleIndex
;
3276 UINTN ChildControllerHandleCount
;
3277 EFI_HANDLE
*ChildControllerHandleBuffer
;
3278 UINTN ChildControllerHandleIndex
;
3279 EFI_HANDLE
*HandleBufferForReturn
;
3281 if (MatchingHandleCount
== NULL
) {
3282 return (EFI_INVALID_PARAMETER
);
3284 *MatchingHandleCount
= 0;
3286 Status
= PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
3288 &DriverBindingHandleCount
,
3289 &DriverBindingHandleBuffer
3291 if (EFI_ERROR (Status
)) {
3296 // Get a buffer big enough for all the controllers.
3298 HandleBufferForReturn
= GetHandleListByProtocol(NULL
);
3299 if (HandleBufferForReturn
== NULL
) {
3300 FreePool (DriverBindingHandleBuffer
);
3301 return (EFI_NOT_FOUND
);
3304 for (DriverBindingHandleIndex
= 0; DriverBindingHandleIndex
< DriverBindingHandleCount
; DriverBindingHandleIndex
++) {
3305 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
3306 DriverBindingHandleBuffer
[DriverBindingHandleIndex
],
3308 &ChildControllerHandleCount
,
3309 &ChildControllerHandleBuffer
3311 if (EFI_ERROR (Status
)) {
3315 for (ChildControllerHandleIndex
= 0;
3316 ChildControllerHandleIndex
< ChildControllerHandleCount
;
3317 ChildControllerHandleIndex
++
3319 for (HandleIndex
= 0; HandleIndex
< *MatchingHandleCount
; HandleIndex
++) {
3320 if (HandleBufferForReturn
[HandleIndex
] == ChildControllerHandleBuffer
[ChildControllerHandleIndex
]) {
3324 if (HandleIndex
>= *MatchingHandleCount
) {
3325 HandleBufferForReturn
[(*MatchingHandleCount
)++] = ChildControllerHandleBuffer
[ChildControllerHandleIndex
];
3329 FreePool (ChildControllerHandleBuffer
);
3332 FreePool (DriverBindingHandleBuffer
);
3334 if (MatchingHandleBuffer
== NULL
|| *MatchingHandleCount
== 0) {
3336 // The caller is not interested in the actual handles, or we've found none.
3338 FreePool (HandleBufferForReturn
);
3339 HandleBufferForReturn
= NULL
;
3342 if (MatchingHandleBuffer
!= NULL
) {
3343 *MatchingHandleBuffer
= HandleBufferForReturn
;
3346 ASSERT ((MatchingHandleBuffer
== NULL
) ||
3347 (*MatchingHandleCount
== 0 && *MatchingHandleBuffer
== NULL
) ||
3348 (*MatchingHandleCount
!= 0 && *MatchingHandleBuffer
!= NULL
));
3350 return (EFI_SUCCESS
);
3354 Appends 1 buffer to another buffer. This will re-allocate the destination buffer
3355 if necessary to fit all of the data.
3357 If DestinationBuffer is NULL, then ASSERT().
3359 @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.
3360 @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.
3361 @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.
3362 @param[in] SourceSize The number of bytes of SourceBuffer to append.
3364 @retval NULL A memory allocation failed.
3365 @retval NULL A parameter was invalid.
3366 @return A pointer to (*DestinationBuffer).
3370 IN OUT VOID
**DestinationBuffer
,
3371 IN OUT UINTN
*DestinationSize
,
3372 IN VOID
*SourceBuffer
,
3376 UINTN LocalDestinationSize
;
3377 UINTN LocalDestinationFinalSize
;
3379 ASSERT(DestinationBuffer
!= NULL
);
3381 if (SourceSize
== 0 || SourceBuffer
== NULL
) {
3382 return (*DestinationBuffer
);
3385 if (DestinationSize
== NULL
) {
3386 LocalDestinationSize
= 0;
3388 LocalDestinationSize
= *DestinationSize
;
3391 LocalDestinationFinalSize
= LocalDestinationSize
+ SourceSize
;
3393 if (DestinationSize
!= NULL
) {
3394 *DestinationSize
= LocalDestinationSize
;
3397 if (LocalDestinationSize
== 0) {
3399 *DestinationBuffer
= AllocateZeroPool(LocalDestinationFinalSize
);
3402 *DestinationBuffer
= ReallocatePool(LocalDestinationSize
, LocalDestinationFinalSize
, *DestinationBuffer
);
3405 ASSERT(*DestinationBuffer
!= NULL
);
3408 return (CopyMem(((UINT8
*)(*DestinationBuffer
)) + LocalDestinationSize
, SourceBuffer
, SourceSize
));
3412 Gets handles for any child devices produced by the passed in driver.
3414 @param[in] DriverHandle The handle of the driver.
3415 @param[in] MatchingHandleCount Pointer to the number of handles in
3416 MatchingHandleBuffer on return.
3417 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
3419 @retval EFI_SUCCESS The operation was sucessful.
3420 @sa ParseHandleDatabaseByRelationship
3424 ParseHandleDatabaseForChildDevices(
3425 IN CONST EFI_HANDLE DriverHandle
,
3426 IN UINTN
*MatchingHandleCount
,
3427 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
3431 EFI_HANDLE
*Buffer2
;
3436 UINTN HandleBufferSize
;
3438 ASSERT(MatchingHandleCount
!= NULL
);
3440 HandleBufferSize
= 0;
3443 *MatchingHandleCount
= 0;
3445 Status
= PARSE_HANDLE_DATABASE_DEVICES (
3450 if (!EFI_ERROR (Status
)) {
3451 for (HandleIndex
= 0; HandleIndex
< Count1
; HandleIndex
++) {
3453 // now find the children
3455 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
3457 Buffer
[HandleIndex
],
3461 if (EFI_ERROR(Status
)) {
3465 // save out required and optional data elements
3467 *MatchingHandleCount
+= Count2
;
3468 if (MatchingHandleBuffer
!= NULL
) {
3469 *MatchingHandleBuffer
= BuffernCatGrow((VOID
**)MatchingHandleBuffer
, &HandleBufferSize
, Buffer2
, Count2
* sizeof(Buffer2
[0]));
3475 if (Buffer2
!= NULL
) {
3481 if (Buffer
!= NULL
) {
3488 Function to get all handles that support a given protocol or all handles.
3490 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL
3491 then the function will return all handles.
3493 @retval NULL A memory allocation failed.
3494 @return A NULL terminated list of handles.
3498 GetHandleListByProtocol (
3499 IN CONST EFI_GUID
*ProtocolGuid OPTIONAL
3502 EFI_HANDLE
*HandleList
;
3510 // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!
3512 if (ProtocolGuid
== NULL
) {
3513 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
3514 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3515 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
3516 if (HandleList
== NULL
) {
3519 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
3520 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
3523 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
3524 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3525 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
3526 if (HandleList
== NULL
) {
3529 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
3530 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
3533 if (EFI_ERROR(Status
)) {
3534 if (HandleList
!= NULL
) {
3535 FreePool(HandleList
);
3539 return (HandleList
);
3543 Function to get all handles that support some protocols.
3545 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
3547 @retval NULL A memory allocation failed.
3548 @retval NULL ProtocolGuids was NULL.
3549 @return A NULL terminated list of EFI_HANDLEs.
3553 GetHandleListByProtocolList (
3554 IN CONST EFI_GUID
**ProtocolGuids
3557 EFI_HANDLE
*HandleList
;
3562 CONST EFI_GUID
**GuidWalker
;
3563 EFI_HANDLE
*HandleWalker1
;
3564 EFI_HANDLE
*HandleWalker2
;
3568 TotalSize
= sizeof(EFI_HANDLE
);
3570 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++,Size
= 0){
3571 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &Size
, NULL
);
3572 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3578 // No handles were found...
3580 if (TotalSize
== sizeof(EFI_HANDLE
)) {
3584 HandleList
= AllocateZeroPool(TotalSize
);
3585 if (HandleList
== NULL
) {
3590 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++){
3591 TempSize
= TotalSize
- Size
;
3592 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &TempSize
, HandleList
+(Size
/sizeof(EFI_HANDLE
)));
3595 // Allow for missing protocols... Only update the 'used' size upon success.
3597 if (!EFI_ERROR(Status
)) {
3601 ASSERT(HandleList
[(TotalSize
/sizeof(EFI_HANDLE
))-1] == NULL
);
3603 for (HandleWalker1
= HandleList
; HandleWalker1
!= NULL
&& *HandleWalker1
!= NULL
; HandleWalker1
++) {
3604 for (HandleWalker2
= HandleWalker1
+ 1; HandleWalker2
!= NULL
&& *HandleWalker2
!= NULL
; HandleWalker2
++) {
3605 if (*HandleWalker1
== *HandleWalker2
) {
3607 // copy memory back 1 handle width.
3609 CopyMem(HandleWalker2
, HandleWalker2
+ 1, TotalSize
- ((HandleWalker2
-HandleList
+1)*sizeof(EFI_HANDLE
)));
3614 return (HandleList
);
3618 Return all supported GUIDs.
3620 @param[out] Guids The buffer to return all supported GUIDs.
3621 @param[in, out] Count On input, the count of GUIDs the buffer can hold,
3622 On output, the count of GUIDs to return.
3624 @retval EFI_INVALID_PARAMETER Count is NULL.
3625 @retval EFI_BUFFER_TOO_SMALL Buffer is not enough to hold all GUIDs.
3626 @retval EFI_SUCCESS GUIDs are returned successfully.
3630 GetAllMappingGuids (
3631 OUT EFI_GUID
*Guids
,
3639 if (Count
== NULL
) {
3640 return EFI_INVALID_PARAMETER
;
3644 if (PcdGetBool (PcdShellIncludeNtGuids
)) {
3645 NtGuidCount
= ARRAY_SIZE (mGuidStringListNT
) - 1;
3647 GuidCount
= ARRAY_SIZE (mGuidStringList
) - 1;
3649 if (*Count
< NtGuidCount
+ GuidCount
+ mGuidListCount
) {
3650 *Count
= NtGuidCount
+ GuidCount
+ mGuidListCount
;
3651 return EFI_BUFFER_TOO_SMALL
;
3654 for (Index
= 0; Index
< NtGuidCount
; Index
++) {
3655 CopyGuid (&Guids
[Index
], mGuidStringListNT
[Index
].GuidId
);
3658 for (Index
= 0; Index
< GuidCount
; Index
++) {
3659 CopyGuid (&Guids
[NtGuidCount
+ Index
], mGuidStringList
[Index
].GuidId
);
3662 for (Index
= 0; Index
< mGuidListCount
; Index
++) {
3663 CopyGuid (&Guids
[NtGuidCount
+ GuidCount
+ Index
], mGuidList
[Index
].GuidId
);