2 Provides interface to advanced shell functionality for parsing both handle and protocol database.
4 Copyright (c) 2010 - 2016, 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"
20 EFI_HANDLE mHandleParsingHiiHandle
= NULL
;
21 HANDLE_INDEX_LIST mHandleList
= {{{NULL
,NULL
},0,0},0};
22 GUID_INFO_BLOCK
*GuidList
;
25 Function to translate the EFI_MEMORY_TYPE into a string.
27 @param[in] Memory The memory type.
29 @retval A string representation of the type allocated from BS Pool.
34 IN CONST EFI_MEMORY_TYPE Memory
41 case EfiReservedMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiReservedMemoryType", 0); break;
42 case EfiLoaderCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderCode", 0); break;
43 case EfiLoaderData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderData", 0); break;
44 case EfiBootServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesCode", 0); break;
45 case EfiBootServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesData", 0); break;
46 case EfiRuntimeServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesCode", 0); break;
47 case EfiRuntimeServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesData", 0); break;
48 case EfiConventionalMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiConventionalMemory", 0); break;
49 case EfiUnusableMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiUnusableMemory", 0); break;
50 case EfiACPIReclaimMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIReclaimMemory", 0); break;
51 case EfiACPIMemoryNVS
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIMemoryNVS", 0); break;
52 case EfiMemoryMappedIO
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIO", 0); break;
53 case EfiMemoryMappedIOPortSpace
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIOPortSpace", 0); break;
54 case EfiPalCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiPalCode", 0); break;
55 case EfiMaxMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMaxMemoryType", 0); break;
56 default: ASSERT(FALSE
);
62 Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.
64 @param[in] Fmt The format type.
66 @retval A string representation of the type allocated from BS Pool.
71 IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt
78 case PixelRedGreenBlueReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelRedGreenBlueReserved8BitPerColor", 0); break;
79 case PixelBlueGreenRedReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBlueGreenRedReserved8BitPerColor", 0); break;
80 case PixelBitMask
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBitMask", 0); break;
81 case PixelBltOnly
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBltOnly", 0); break;
82 case PixelFormatMax
: StrnCatGrow(&RetVal
, NULL
, L
"PixelFormatMax", 0); break;
83 default: ASSERT(FALSE
);
89 Constructor for the library.
91 @param[in] ImageHandle Ignored.
92 @param[in] SystemTable Ignored.
94 @retval EFI_SUCCESS The operation was successful.
98 HandleParsingLibConstructor (
99 IN EFI_HANDLE ImageHandle
,
100 IN EFI_SYSTEM_TABLE
*SystemTable
107 // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.
109 return (EFI_SUCCESS
);
113 Initialization function for HII packages.
117 HandleParsingHiiInit (VOID
)
119 if (mHandleParsingHiiHandle
== NULL
) {
120 mHandleParsingHiiHandle
= HiiAddPackages (&gHandleParsingHiiGuid
, gImageHandle
, UefiHandleParsingLibStrings
, NULL
);
121 ASSERT (mHandleParsingHiiHandle
!= NULL
);
126 Destructor for the library. free any resources.
128 @param[in] ImageHandle Ignored.
129 @param[in] SystemTable Ignored.
131 @retval EFI_SUCCESS The operation was successful.
135 HandleParsingLibDestructor (
136 IN EFI_HANDLE ImageHandle
,
137 IN EFI_SYSTEM_TABLE
*SystemTable
142 for (LoopCount
= 0; GuidList
!= NULL
&& LoopCount
< GuidListCount
; LoopCount
++) {
143 SHELL_FREE_NON_NULL(GuidList
[LoopCount
].GuidId
);
146 SHELL_FREE_NON_NULL(GuidList
);
147 if (mHandleParsingHiiHandle
!= NULL
) {
148 HiiRemovePackages(mHandleParsingHiiHandle
);
150 return (EFI_SUCCESS
);
154 Function to dump information about LoadedImage.
156 This will allocate the return buffer from boot services pool.
158 @param[in] TheHandle The handle that has LoadedImage installed.
159 @param[in] Verbose TRUE for additional information, FALSE otherwise.
161 @retval A poitner to a string containing the information.
165 LoadedImageProtocolDumpInformation(
166 IN CONST EFI_HANDLE TheHandle
,
167 IN CONST BOOLEAN Verbose
170 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
178 return (CatSPrint(NULL
, L
"LoadedImage"));
181 HandleParsingHiiInit();
183 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_MAIN
), NULL
);
188 Status
= gBS
->OpenProtocol (
190 &gEfiLoadedImageProtocolGuid
,
191 (VOID
**)&LoadedImage
,
194 EFI_OPEN_PROTOCOL_GET_PROTOCOL
197 if (EFI_ERROR (Status
)) {
198 SHELL_FREE_NON_NULL (Temp
);
202 DataType
= ConvertMemoryType(LoadedImage
->ImageDataType
);
203 CodeType
= ConvertMemoryType(LoadedImage
->ImageCodeType
);
208 LoadedImage
->Revision
,
209 LoadedImage
->ParentHandle
,
210 LoadedImage
->SystemTable
,
211 LoadedImage
->DeviceHandle
,
212 LoadedImage
->FilePath
,
213 LoadedImage
->LoadOptionsSize
,
214 LoadedImage
->LoadOptions
,
215 LoadedImage
->ImageBase
,
216 LoadedImage
->ImageSize
,
223 SHELL_FREE_NON_NULL(Temp
);
224 SHELL_FREE_NON_NULL(CodeType
);
225 SHELL_FREE_NON_NULL(DataType
);
231 Function to dump information about GOP.
233 This will allocate the return buffer from boot services pool.
235 @param[in] TheHandle The handle that has LoadedImage installed.
236 @param[in] Verbose TRUE for additional information, FALSE otherwise.
238 @retval A poitner to a string containing the information.
242 GraphicsOutputProtocolDumpInformation(
243 IN CONST EFI_HANDLE TheHandle
,
244 IN CONST BOOLEAN Verbose
247 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
255 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*GopInfo
;
258 return (CatSPrint(NULL
, L
"GraphicsOutput"));
261 HandleParsingHiiInit();
263 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_GOP_DUMP_MAIN
), NULL
);
268 Status
= gBS
->OpenProtocol (
270 &gEfiGraphicsOutputProtocolGuid
,
271 (VOID
**)&GraphicsOutput
,
274 EFI_OPEN_PROTOCOL_GET_PROTOCOL
277 if (EFI_ERROR (Status
)) {
278 SHELL_FREE_NON_NULL (Temp
);
282 Fmt
= ConvertPixelFormat(GraphicsOutput
->Mode
->Info
->PixelFormat
);
287 GraphicsOutput
->Mode
->MaxMode
,
288 GraphicsOutput
->Mode
->Mode
,
289 GraphicsOutput
->Mode
->FrameBufferBase
,
290 (UINT64
)GraphicsOutput
->Mode
->FrameBufferSize
,
291 (UINT64
)GraphicsOutput
->Mode
->SizeOfInfo
,
292 GraphicsOutput
->Mode
->Info
->Version
,
293 GraphicsOutput
->Mode
->Info
->HorizontalResolution
,
294 GraphicsOutput
->Mode
->Info
->VerticalResolution
,
296 GraphicsOutput
->Mode
->Info
->PixelsPerScanLine
,
297 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.RedMask
,
298 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.GreenMask
,
299 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.BlueMask
302 SHELL_FREE_NON_NULL (Temp
);
304 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_GOP_RES_LIST_MAIN
), NULL
);
306 SHELL_FREE_NON_NULL (RetVal
);
310 TempRetVal
= CatSPrint (RetVal
, Temp
);
311 SHELL_FREE_NON_NULL (RetVal
);
312 if (TempRetVal
== NULL
) {
316 SHELL_FREE_NON_NULL (Temp
);
318 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_GOP_RES_LIST_ENTRY
), NULL
);
320 SHELL_FREE_NON_NULL (RetVal
);
325 for (Mode
= 0; Mode
< GraphicsOutput
->Mode
->MaxMode
; Mode
++) {
326 Status
= GraphicsOutput
->QueryMode (
332 if (EFI_ERROR (Status
)) {
336 TempRetVal
= CatSPrint (
340 GopInfo
->HorizontalResolution
,
341 GopInfo
->VerticalResolution
344 SHELL_FREE_NON_NULL (GopInfo
);
345 SHELL_FREE_NON_NULL (RetVal
);
351 SHELL_FREE_NON_NULL(Temp
);
352 SHELL_FREE_NON_NULL(Fmt
);
358 Function to dump information about EDID Discovered Protocol.
360 This will allocate the return buffer from boot services pool.
362 @param[in] TheHandle The handle that has LoadedImage installed.
363 @param[in] Verbose TRUE for additional information, FALSE otherwise.
365 @retval A pointer to a string containing the information.
369 EdidDiscoveredProtocolDumpInformation (
370 IN CONST EFI_HANDLE TheHandle
,
371 IN CONST BOOLEAN Verbose
374 EFI_EDID_DISCOVERED_PROTOCOL
*EdidDiscovered
;
381 return (CatSPrint (NULL
, L
"EDIDDiscovered"));
384 Status
= gBS
->OpenProtocol (
386 &gEfiEdidDiscoveredProtocolGuid
,
387 (VOID
**)&EdidDiscovered
,
390 EFI_OPEN_PROTOCOL_GET_PROTOCOL
393 if (EFI_ERROR (Status
)) {
397 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_DISCOVERED_MAIN
), NULL
);
402 RetVal
= CatSPrint (NULL
, Temp
, EdidDiscovered
->SizeOfEdid
);
403 SHELL_FREE_NON_NULL (Temp
);
405 if (EdidDiscovered
->SizeOfEdid
!= 0) {
406 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_DISCOVERED_DATA
), NULL
);
408 SHELL_FREE_NON_NULL (RetVal
);
411 TempRetVal
= CatSPrint (RetVal
, Temp
);
412 SHELL_FREE_NON_NULL (RetVal
);
415 TempRetVal
= CatSDumpHex (RetVal
, 7, 0, EdidDiscovered
->SizeOfEdid
, EdidDiscovered
->Edid
);
422 Function to dump information about EDID Active Protocol.
424 This will allocate the return buffer from boot services pool.
426 @param[in] TheHandle The handle that has LoadedImage installed.
427 @param[in] Verbose TRUE for additional information, FALSE otherwise.
429 @retval A pointer to a string containing the information.
433 EdidActiveProtocolDumpInformation (
434 IN CONST EFI_HANDLE TheHandle
,
435 IN CONST BOOLEAN Verbose
438 EFI_EDID_ACTIVE_PROTOCOL
*EdidActive
;
445 return (CatSPrint (NULL
, L
"EDIDActive"));
448 Status
= gBS
->OpenProtocol (
450 &gEfiEdidActiveProtocolGuid
,
454 EFI_OPEN_PROTOCOL_GET_PROTOCOL
457 if (EFI_ERROR (Status
)) {
461 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_ACTIVE_MAIN
), NULL
);
466 RetVal
= CatSPrint (NULL
, Temp
, EdidActive
->SizeOfEdid
);
467 SHELL_FREE_NON_NULL (Temp
);
469 if (EdidActive
->SizeOfEdid
!= 0) {
470 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_ACTIVE_DATA
), NULL
);
472 SHELL_FREE_NON_NULL (RetVal
);
475 TempRetVal
= CatSPrint (RetVal
, Temp
);
476 SHELL_FREE_NON_NULL (RetVal
);
479 TempRetVal
= CatSDumpHex (RetVal
, 7, 0, EdidActive
->SizeOfEdid
, EdidActive
->Edid
);
486 Function to dump information about PciRootBridgeIo.
488 This will allocate the return buffer from boot services pool.
490 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
491 @param[in] Verbose TRUE for additional information, FALSE otherwise.
493 @retval A poitner to a string containing the information.
497 PciRootBridgeIoDumpInformation(
498 IN CONST EFI_HANDLE TheHandle
,
499 IN CONST BOOLEAN Verbose
502 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
503 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Configuration
;
514 return (CatSPrint(NULL
, L
"PciRootBridgeIo"));
517 HandleParsingHiiInit();
519 Status
= gBS
->HandleProtocol(
521 &gEfiPciRootBridgeIoProtocolGuid
,
522 (VOID
**)&PciRootBridgeIo
);
524 if (EFI_ERROR(Status
)) {
528 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_PH
), NULL
);
532 Temp2
= CatSPrint(L
"\r\n", Temp
, PciRootBridgeIo
->ParentHandle
);
537 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SEG
), NULL
);
539 SHELL_FREE_NON_NULL(RetVal
);
542 Temp2
= CatSPrint(RetVal
, Temp
, PciRootBridgeIo
->SegmentNumber
);
550 Status
= PciRootBridgeIo
->GetAttributes (PciRootBridgeIo
, &Supports
, &Attributes
);
551 if (!EFI_ERROR(Status
)) {
552 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_ATT
), NULL
);
554 SHELL_FREE_NON_NULL(RetVal
);
557 Temp2
= CatSPrint(RetVal
, Temp
, Attributes
);
563 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS
), NULL
);
565 SHELL_FREE_NON_NULL(RetVal
);
568 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
575 Configuration
= NULL
;
576 Status
= PciRootBridgeIo
->Configuration (PciRootBridgeIo
, (VOID
**) &Configuration
);
577 if (!EFI_ERROR(Status
) && Configuration
!= NULL
) {
578 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_TITLE
), NULL
);
580 SHELL_FREE_NON_NULL(RetVal
);
583 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
588 while (Configuration
->Desc
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
590 switch (Configuration
->ResType
) {
591 case ACPI_ADDRESS_SPACE_TYPE_MEM
:
592 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_MEM
), NULL
);
594 case ACPI_ADDRESS_SPACE_TYPE_IO
:
595 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_IO
), NULL
);
597 case ACPI_ADDRESS_SPACE_TYPE_BUS
:
598 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_BUS
), NULL
);
602 Temp2
= CatSPrint(RetVal
, L
"%s", Temp
);
609 Temp2
= CatSPrint(RetVal
,
610 L
"%H%02x %016lx %016lx %02x%N\r\n",
611 Configuration
->SpecificFlag
,
612 Configuration
->AddrRangeMin
,
613 Configuration
->AddrRangeMax
,
614 Configuration
->AddrSpaceGranularity
626 Function to dump information about SimpleTextOut.
628 This will allocate the return buffer from boot services pool.
630 @param[in] TheHandle The handle that has SimpleTextOut installed.
631 @param[in] Verbose TRUE for additional information, FALSE otherwise.
633 @retval A poitner to a string containing the information.
637 TxtOutProtocolDumpInformation(
638 IN CONST EFI_HANDLE TheHandle
,
639 IN CONST BOOLEAN Verbose
642 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Dev
;
656 HandleParsingHiiInit();
661 Status
= gBS
->HandleProtocol(
663 &gEfiSimpleTextOutProtocolGuid
,
666 ASSERT_EFI_ERROR(Status
);
667 ASSERT (Dev
!= NULL
&& Dev
->Mode
!= NULL
);
669 Size
= (Dev
->Mode
->MaxMode
+ 1) * 80;
670 RetVal
= AllocateZeroPool(Size
);
672 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER
), NULL
);
674 UnicodeSPrint(RetVal
, Size
, Temp
, Dev
, Dev
->Mode
->Attribute
);
681 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE
), NULL
);
682 for (Index
= 0; Index
< Dev
->Mode
->MaxMode
; Index
++) {
683 Status
= Dev
->QueryMode (Dev
, Index
, &Col
, &Row
);
684 NewSize
= Size
- StrSize(RetVal
);
686 RetVal
+ StrLen(RetVal
),
688 Temp
== NULL
?L
"":Temp
,
689 Index
== Dev
->Mode
->Mode
? L
'*' : L
' ',
691 !EFI_ERROR(Status
)?(INTN
)Col
:-1,
692 !EFI_ERROR(Status
)?(INTN
)Row
:-1
699 STATIC CONST UINTN VersionStringSize
= 60;
702 Function to dump information about EfiDriverSupportedEfiVersion protocol.
704 This will allocate the return buffer from boot services pool.
706 @param[in] TheHandle The handle that has the protocol installed.
707 @param[in] Verbose TRUE for additional information, FALSE otherwise.
709 @retval A poitner to a string containing the information.
713 DriverEfiVersionProtocolDumpInformation(
714 IN CONST EFI_HANDLE TheHandle
,
715 IN CONST BOOLEAN Verbose
718 EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL
*DriverEfiVersion
;
722 Status
= gBS
->HandleProtocol(
724 &gEfiDriverSupportedEfiVersionProtocolGuid
,
725 (VOID
**)&DriverEfiVersion
);
727 ASSERT_EFI_ERROR(Status
);
729 RetVal
= AllocateZeroPool(VersionStringSize
);
730 ASSERT(RetVal
!= NULL
);
731 UnicodeSPrint(RetVal
, VersionStringSize
, L
"0x%08x", DriverEfiVersion
->FirmwareVersion
);
736 Function to dump information about DevicePath protocol.
738 This will allocate the return buffer from boot services pool.
740 @param[in] TheHandle The handle that has the protocol installed.
741 @param[in] Verbose TRUE for additional information, FALSE otherwise.
743 @retval A poitner to a string containing the information.
747 DevicePathProtocolDumpInformation(
748 IN CONST EFI_HANDLE TheHandle
,
749 IN CONST BOOLEAN Verbose
752 EFI_DEVICE_PATH_PROTOCOL
*DevPath
;
759 Status
= gBS
->OpenProtocol(TheHandle
, &gEfiDevicePathProtocolGuid
, (VOID
**)&DevPath
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
760 if (!EFI_ERROR(Status
)) {
762 // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
764 Temp
= ConvertDevicePathToText(DevPath
, TRUE
, TRUE
);
765 gBS
->CloseProtocol(TheHandle
, &gEfiDevicePathProtocolGuid
, gImageHandle
, NULL
);
767 if (!Verbose
&& Temp
!= NULL
&& StrLen(Temp
) > 30) {
770 Temp2
= StrnCatGrow(&Temp2
, &Size
, L
"..", 0);
771 Temp2
= StrnCatGrow(&Temp2
, &Size
, Temp
+(StrLen(Temp
) - 28), 0);
779 Function to dump information about EfiAdapterInformation Protocol.
781 @param[in] TheHandle The handle that has the protocol installed.
782 @param[in] Verbose TRUE for additional information, FALSE otherwise.
784 @retval A pointer to a string containing the information.
788 AdapterInformationDumpInformation (
789 IN CONST EFI_HANDLE TheHandle
,
790 IN CONST BOOLEAN Verbose
794 EFI_ADAPTER_INFORMATION_PROTOCOL
*EfiAdptrInfoProtocol
;
795 UINTN InfoTypesBufferCount
;
797 EFI_GUID
*InfoTypesBuffer
;
802 VOID
*InformationBlock
;
803 UINTN InformationBlockSize
;
806 return (CatSPrint(NULL
, L
"AdapterInfo"));
809 InfoTypesBuffer
= NULL
;
810 InformationBlock
= NULL
;
813 Status
= gBS
->OpenProtocol (
814 (EFI_HANDLE
) (TheHandle
),
815 &gEfiAdapterInformationProtocolGuid
,
816 (VOID
**) &EfiAdptrInfoProtocol
,
819 EFI_OPEN_PROTOCOL_GET_PROTOCOL
822 if (EFI_ERROR (Status
)) {
827 // Get a list of supported information types for this instance of the protocol.
829 Status
= EfiAdptrInfoProtocol
->GetSupportedTypes (
830 EfiAdptrInfoProtocol
,
832 &InfoTypesBufferCount
835 if (EFI_ERROR (Status
)) {
836 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED
), NULL
);
837 if (TempStr
!= NULL
) {
838 RetVal
= CatSPrint (NULL
, TempStr
, Status
);
843 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SUPP_TYPE_HEADER
), NULL
);
844 if (TempStr
== NULL
) {
847 RetVal
= CatSPrint (NULL
, TempStr
);
848 SHELL_FREE_NON_NULL (TempStr
);
850 for (GuidIndex
= 0; GuidIndex
< InfoTypesBufferCount
; GuidIndex
++) {
851 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_NUMBER
), NULL
);
852 if (TempStr
== NULL
) {
855 TempRetVal
= CatSPrint (RetVal
, TempStr
, (GuidIndex
+ 1), &InfoTypesBuffer
[GuidIndex
]);
856 SHELL_FREE_NON_NULL (RetVal
);
858 SHELL_FREE_NON_NULL (TempStr
);
860 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_STRING
), NULL
);
861 if (TempStr
== NULL
) {
865 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
866 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoMediaStateGuid");
867 SHELL_FREE_NON_NULL (RetVal
);
869 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
870 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoNetworkBootGuid");
871 SHELL_FREE_NON_NULL (RetVal
);
873 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
)) {
874 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoSanMacAddressGuid");
875 SHELL_FREE_NON_NULL (RetVal
);
877 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
)) {
878 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoUndiIpv6SupportGuid");
879 SHELL_FREE_NON_NULL (RetVal
);
883 GuidStr
= GetStringNameFromGuid (&InfoTypesBuffer
[GuidIndex
], NULL
);
885 if (GuidStr
!= NULL
) {
886 if (StrCmp(GuidStr
, L
"UnknownDevice") == 0) {
887 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"UnknownInfoType");
888 SHELL_FREE_NON_NULL (RetVal
);
891 SHELL_FREE_NON_NULL (TempStr
);
892 SHELL_FREE_NON_NULL(GuidStr
);
894 // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
898 TempRetVal
= CatSPrint (RetVal
, TempStr
, GuidStr
);
899 SHELL_FREE_NON_NULL (RetVal
);
901 SHELL_FREE_NON_NULL(GuidStr
);
906 SHELL_FREE_NON_NULL (TempStr
);
908 Status
= EfiAdptrInfoProtocol
->GetInformation (
909 EfiAdptrInfoProtocol
,
910 &InfoTypesBuffer
[GuidIndex
],
912 &InformationBlockSize
915 if (EFI_ERROR (Status
)) {
916 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GETINFO_FAILED
), NULL
);
917 if (TempStr
== NULL
) {
920 TempRetVal
= CatSPrint (RetVal
, TempStr
, Status
);
921 SHELL_FREE_NON_NULL (RetVal
);
924 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
925 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_MEDIA_STATE
), NULL
);
926 if (TempStr
== NULL
) {
929 TempRetVal
= CatSPrint (
932 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
,
933 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
935 SHELL_FREE_NON_NULL (RetVal
);
937 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
938 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_NETWORK_BOOT_INFO
), NULL
);
939 if (TempStr
== NULL
) {
942 TempRetVal
= CatSPrint (
945 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4BootCapablity
,
946 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6BootCapablity
,
947 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBootCapablity
,
948 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->OffloadCapability
,
949 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiMpioCapability
,
950 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4Boot
,
951 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6Boot
,
952 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBoot
954 SHELL_FREE_NON_NULL (RetVal
);
956 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
) == TRUE
) {
957 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO
), NULL
);
958 if (TempStr
== NULL
) {
961 TempRetVal
= CatSPrint (
964 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[0],
965 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[1],
966 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[2],
967 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[3],
968 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[4],
969 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[5]
971 SHELL_FREE_NON_NULL (RetVal
);
973 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
) == TRUE
) {
974 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNDI_IPV6_INFO
), NULL
);
975 if (TempStr
== NULL
) {
979 TempRetVal
= CatSPrint (
982 ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT
*)InformationBlock
)->Ipv6Support
984 SHELL_FREE_NON_NULL (RetVal
);
987 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE
), NULL
);
988 if (TempStr
== NULL
) {
991 TempRetVal
= CatSPrint (RetVal
, TempStr
, &InfoTypesBuffer
[GuidIndex
]);
992 SHELL_FREE_NON_NULL (RetVal
);
996 SHELL_FREE_NON_NULL (TempStr
);
997 SHELL_FREE_NON_NULL (InformationBlock
);
1001 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1005 SHELL_FREE_NON_NULL (RetVal
);
1006 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1007 SHELL_FREE_NON_NULL (InformationBlock
);
1012 Function to dump information about EFI_FIRMWARE_MANAGEMENT_PROTOCOL Protocol.
1014 @param[in] TheHandle The handle that has the protocol installed.
1015 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1017 @retval A pointer to a string containing the information.
1021 FirmwareManagementDumpInformation (
1022 IN CONST EFI_HANDLE TheHandle
,
1023 IN CONST BOOLEAN Verbose
1027 EFI_FIRMWARE_MANAGEMENT_PROTOCOL
*EfiFwMgmtProtocol
;
1028 EFI_FIRMWARE_IMAGE_DESCRIPTOR
*ImageInfo
;
1029 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*ImageInfoV1
;
1030 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*ImageInfoV2
;
1031 UINT64 AttributeSetting
;
1032 UINTN ImageInfoSize
;
1033 UINTN DescriptorSize
;
1034 UINT32 DescriptorVersion
;
1035 UINT32 PackageVersion
;
1036 UINT8 DescriptorCount
;
1040 CHAR16
*PackageVersionName
;
1044 CHAR16
*AttributeSettingStr
;
1046 BOOLEAN AttributeSupported
;
1049 // Initialize local variables
1053 AttributeSetting
= 0;
1055 AttributeSupported
= FALSE
;
1059 PackageVersionName
= NULL
;
1063 AttributeSettingStr
= NULL
;
1066 return (CatSPrint(NULL
, L
"FirmwareManagement"));
1069 Status
= gBS
->OpenProtocol (
1070 (EFI_HANDLE
) (TheHandle
),
1071 &gEfiFirmwareManagementProtocolGuid
,
1072 (VOID
**) &EfiFwMgmtProtocol
,
1075 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1078 if (EFI_ERROR (Status
)) {
1082 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1093 if (Status
== EFI_BUFFER_TOO_SMALL
) {
1094 ImageInfo
= AllocateZeroPool (ImageInfoSize
);
1096 if (ImageInfo
== NULL
) {
1097 Status
= EFI_OUT_OF_RESOURCES
;
1099 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1112 if (EFI_ERROR (Status
)) {
1117 // Decode Image Descriptor data only if its version is supported
1119 if (DescriptorVersion
<= EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION
) {
1121 if (ImageInfo
== NULL
) {
1125 ImageInfoV1
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*)ImageInfo
;
1126 ImageInfoV2
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*)ImageInfo
;
1129 // Set ImageInfoSize in return buffer
1131 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_INFO_SIZE
), NULL
);
1132 if (TempStr
== NULL
) {
1135 RetVal
= CatSPrint (NULL
, TempStr
, ImageInfoSize
);
1136 SHELL_FREE_NON_NULL (TempStr
);
1139 // Set DescriptorVersion in return buffer
1141 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_VERSION
), NULL
);
1142 if (TempStr
== NULL
) {
1145 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorVersion
);
1146 SHELL_FREE_NON_NULL (RetVal
);
1147 RetVal
= TempRetVal
;
1148 SHELL_FREE_NON_NULL (TempStr
);
1151 // Set DescriptorCount in return buffer
1153 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_COUNT
), NULL
);
1154 if (TempStr
== NULL
) {
1157 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorCount
);
1158 SHELL_FREE_NON_NULL (RetVal
);
1159 RetVal
= TempRetVal
;
1160 SHELL_FREE_NON_NULL (TempStr
);
1164 // Set DescriptorSize in return buffer
1166 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_SIZE
), NULL
);
1167 if (TempStr
== NULL
) {
1170 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorSize
);
1171 SHELL_FREE_NON_NULL (RetVal
);
1172 RetVal
= TempRetVal
;
1173 SHELL_FREE_NON_NULL (TempStr
);
1176 // Set PackageVersion in return buffer
1178 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION
), NULL
);
1179 if (TempStr
== NULL
) {
1182 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersion
);
1183 SHELL_FREE_NON_NULL (RetVal
);
1184 RetVal
= TempRetVal
;
1185 SHELL_FREE_NON_NULL (TempStr
);
1188 // Set PackageVersionName in return buffer
1190 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION_NAME
), NULL
);
1191 if (TempStr
== NULL
) {
1194 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersionName
);
1195 SHELL_FREE_NON_NULL (RetVal
);
1196 RetVal
= TempRetVal
;
1197 SHELL_FREE_NON_NULL (TempStr
);
1199 for (Index
= 0; Index
< DescriptorCount
; Index
++) {
1201 // First check if Attribute is supported
1202 // and generate a string for AttributeSetting field
1204 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1205 AttributeSupported
= FALSE
;
1206 AttributeSetting
= 0;
1207 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1208 if (ImageInfoV1
[Index
].AttributesSupported
!= 0x0) {
1209 AttributeSupported
= TRUE
;
1210 AttributeSetting
= ImageInfoV1
[Index
].AttributesSetting
;
1212 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1213 if (ImageInfoV2
[Index
].AttributesSupported
!= 0x0) {
1214 AttributeSupported
= TRUE
;
1215 AttributeSetting
= ImageInfoV2
[Index
].AttributesSetting
;
1218 if (ImageInfo
[Index
].AttributesSupported
!= 0x0) {
1219 AttributeSupported
= TRUE
;
1220 AttributeSetting
= ImageInfo
[Index
].AttributesSetting
;
1224 if (!AttributeSupported
) {
1225 AttributeSettingStr
= CatSPrint (NULL
, L
"None");
1227 AttributeSettingStr
= CatSPrint (NULL
, L
"(");
1229 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
) != 0x0) {
1230 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IMAGE_UPDATABLE");
1231 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1232 AttributeSettingStr
= TempRetVal
;
1234 if ((AttributeSetting
& IMAGE_ATTRIBUTE_RESET_REQUIRED
) != 0x0) {
1235 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_RESET_REQUIRED");
1236 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1237 AttributeSettingStr
= TempRetVal
;
1239 if ((AttributeSetting
& IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
) != 0x0) {
1240 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED");
1241 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1242 AttributeSettingStr
= TempRetVal
;
1244 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IN_USE
) != 0x0) {
1245 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IN_USE");
1246 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1247 AttributeSettingStr
= TempRetVal
;
1249 if ((AttributeSetting
& IMAGE_ATTRIBUTE_UEFI_IMAGE
) != 0x0) {
1250 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_UEFI_IMAGE");
1251 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1252 AttributeSettingStr
= TempRetVal
;
1254 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" )");
1255 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1256 AttributeSettingStr
= TempRetVal
;
1259 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1260 if (ImageInfoV1
[Index
].ImageIndex
!= 0x0) {
1264 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V1
), NULL
);
1265 if (TempStr
== NULL
) {
1268 TempRetVal
= CatSPrint (
1272 ImageInfoV1
[Index
].ImageIndex
,
1273 ImageInfoV1
[Index
].ImageTypeId
,
1274 ImageInfoV1
[Index
].ImageId
,
1275 ImageInfoV1
[Index
].ImageIdName
,
1276 ImageInfoV1
[Index
].Version
,
1277 ImageInfoV1
[Index
].VersionName
,
1278 ImageInfoV1
[Index
].Size
,
1279 ImageInfoV1
[Index
].AttributesSupported
,
1280 AttributeSettingStr
,
1281 ImageInfoV1
[Index
].Compatibilities
1283 SHELL_FREE_NON_NULL (RetVal
);
1284 RetVal
= TempRetVal
;
1285 SHELL_FREE_NON_NULL (TempStr
);
1286 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1287 if (ImageInfoV2
[Index
].ImageIndex
!= 0x0) {
1291 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V2
), NULL
);
1292 if (TempStr
== NULL
) {
1295 TempRetVal
= CatSPrint (
1299 ImageInfoV2
[Index
].ImageIndex
,
1300 ImageInfoV2
[Index
].ImageTypeId
,
1301 ImageInfoV2
[Index
].ImageId
,
1302 ImageInfoV2
[Index
].ImageIdName
,
1303 ImageInfoV2
[Index
].Version
,
1304 ImageInfoV2
[Index
].VersionName
,
1305 ImageInfoV2
[Index
].Size
,
1306 ImageInfoV2
[Index
].AttributesSupported
,
1307 AttributeSettingStr
,
1308 ImageInfoV2
[Index
].Compatibilities
,
1309 ImageInfoV2
[Index
].LowestSupportedImageVersion
1311 SHELL_FREE_NON_NULL (RetVal
);
1312 RetVal
= TempRetVal
;
1313 SHELL_FREE_NON_NULL (TempStr
);
1315 if (ImageInfo
[Index
].ImageIndex
!= 0x0) {
1319 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO
), NULL
);
1320 if (TempStr
== NULL
) {
1323 TempRetVal
= CatSPrint (
1327 ImageInfo
[Index
].ImageIndex
,
1328 ImageInfo
[Index
].ImageTypeId
,
1329 ImageInfo
[Index
].ImageId
,
1330 ImageInfo
[Index
].ImageIdName
,
1331 ImageInfo
[Index
].Version
,
1332 ImageInfo
[Index
].VersionName
,
1333 ImageInfo
[Index
].Size
,
1334 ImageInfo
[Index
].AttributesSupported
,
1335 AttributeSettingStr
,
1336 ImageInfo
[Index
].Compatibilities
,
1337 ImageInfo
[Index
].LowestSupportedImageVersion
,
1338 ImageInfo
[Index
].LastAttemptVersion
,
1339 ImageInfo
[Index
].LastAttemptStatus
,
1340 ImageInfo
[Index
].HardwareInstance
1342 SHELL_FREE_NON_NULL (RetVal
);
1343 RetVal
= TempRetVal
;
1344 SHELL_FREE_NON_NULL (TempStr
);
1349 if (ImageCount
> 0) {
1350 for (Index
=0; Index
<DescriptorCount
; Index
++) {
1351 for (Index1
=Index
+1; Index1
<DescriptorCount
; Index1
++) {
1352 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1353 if (ImageInfoV1
[Index
].ImageId
== ImageInfoV1
[Index1
].ImageId
) {
1356 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1360 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1361 if (ImageInfoV2
[Index
].ImageId
== ImageInfoV2
[Index1
].ImageId
) {
1364 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1369 if (ImageInfo
[Index
].ImageId
== ImageInfo
[Index1
].ImageId
) {
1372 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1383 // Check if ImageId with duplicate value was found
1386 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGEID_NON_UNIQUE
), NULL
);
1387 if (TempStr
== NULL
) {
1390 TempRetVal
= CatSPrint (RetVal
, TempStr
);
1391 SHELL_FREE_NON_NULL (RetVal
);
1392 RetVal
= TempRetVal
;
1393 SHELL_FREE_NON_NULL (TempStr
);
1396 SHELL_FREE_NON_NULL (ImageInfo
);
1397 SHELL_FREE_NON_NULL (PackageVersionName
);
1398 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1403 SHELL_FREE_NON_NULL (RetVal
);
1404 SHELL_FREE_NON_NULL (ImageInfo
);
1405 SHELL_FREE_NON_NULL (PackageVersionName
);
1406 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1412 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
1414 #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
1416 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1419 #define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
1421 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1424 #define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
1426 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1428 STATIC CONST EFI_GUID WinNtThunkProtocolGuid
= LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID
;
1429 STATIC CONST EFI_GUID WinNtIoProtocolGuid
= LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID
;
1430 STATIC CONST EFI_GUID WinNtSerialPortGuid
= LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID
;
1433 // Deprecated protocols we dont want to link from IntelFrameworkModulePkg
1435 #define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \
1437 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
1439 #define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \
1441 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \
1443 STATIC CONST EFI_GUID EfiIsaIoProtocolGuid
= LOCAL_EFI_ISA_IO_PROTOCOL_GUID
;
1444 STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid
= LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID
;
1447 STATIC CONST GUID_INFO_BLOCK mGuidStringListNT
[] = {
1448 {STRING_TOKEN(STR_WINNT_THUNK
), (EFI_GUID
*)&WinNtThunkProtocolGuid
, NULL
},
1449 {STRING_TOKEN(STR_WINNT_DRIVER_IO
), (EFI_GUID
*)&WinNtIoProtocolGuid
, NULL
},
1450 {STRING_TOKEN(STR_WINNT_SERIAL_PORT
), (EFI_GUID
*)&WinNtSerialPortGuid
, NULL
},
1451 {STRING_TOKEN(STR_UNKNOWN_DEVICE
), NULL
, NULL
},
1454 STATIC CONST GUID_INFO_BLOCK mGuidStringList
[] = {
1455 {STRING_TOKEN(STR_LOADED_IMAGE
), &gEfiLoadedImageProtocolGuid
, LoadedImageProtocolDumpInformation
},
1456 {STRING_TOKEN(STR_DEVICE_PATH
), &gEfiDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
1457 {STRING_TOKEN(STR_IMAGE_PATH
), &gEfiLoadedImageDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
1458 {STRING_TOKEN(STR_DEVICE_PATH_UTIL
), &gEfiDevicePathUtilitiesProtocolGuid
, NULL
},
1459 {STRING_TOKEN(STR_DEVICE_PATH_TXT
), &gEfiDevicePathToTextProtocolGuid
, NULL
},
1460 {STRING_TOKEN(STR_DEVICE_PATH_FTXT
), &gEfiDevicePathFromTextProtocolGuid
, NULL
},
1461 {STRING_TOKEN(STR_DEVICE_PATH_PC
), &gEfiPcAnsiGuid
, NULL
},
1462 {STRING_TOKEN(STR_DEVICE_PATH_VT100
), &gEfiVT100Guid
, NULL
},
1463 {STRING_TOKEN(STR_DEVICE_PATH_VT100P
), &gEfiVT100PlusGuid
, NULL
},
1464 {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8
), &gEfiVTUTF8Guid
, NULL
},
1465 {STRING_TOKEN(STR_DRIVER_BINDING
), &gEfiDriverBindingProtocolGuid
, NULL
},
1466 {STRING_TOKEN(STR_PLATFORM_OVERRIDE
), &gEfiPlatformDriverOverrideProtocolGuid
, NULL
},
1467 {STRING_TOKEN(STR_BUS_OVERRIDE
), &gEfiBusSpecificDriverOverrideProtocolGuid
, NULL
},
1468 {STRING_TOKEN(STR_DRIVER_DIAG
), &gEfiDriverDiagnosticsProtocolGuid
, NULL
},
1469 {STRING_TOKEN(STR_DRIVER_DIAG2
), &gEfiDriverDiagnostics2ProtocolGuid
, NULL
},
1470 {STRING_TOKEN(STR_DRIVER_CN
), &gEfiComponentNameProtocolGuid
, NULL
},
1471 {STRING_TOKEN(STR_DRIVER_CN2
), &gEfiComponentName2ProtocolGuid
, NULL
},
1472 {STRING_TOKEN(STR_PLAT_DRV_CFG
), &gEfiPlatformToDriverConfigurationProtocolGuid
, NULL
},
1473 {STRING_TOKEN(STR_DRIVER_VERSION
), &gEfiDriverSupportedEfiVersionProtocolGuid
, DriverEfiVersionProtocolDumpInformation
},
1474 {STRING_TOKEN(STR_TXT_IN
), &gEfiSimpleTextInProtocolGuid
, NULL
},
1475 {STRING_TOKEN(STR_TXT_IN_EX
), &gEfiSimpleTextInputExProtocolGuid
, NULL
},
1476 {STRING_TOKEN(STR_TXT_OUT
), &gEfiSimpleTextOutProtocolGuid
, TxtOutProtocolDumpInformation
},
1477 {STRING_TOKEN(STR_SIM_POINTER
), &gEfiSimplePointerProtocolGuid
, NULL
},
1478 {STRING_TOKEN(STR_ABS_POINTER
), &gEfiAbsolutePointerProtocolGuid
, NULL
},
1479 {STRING_TOKEN(STR_SERIAL_IO
), &gEfiSerialIoProtocolGuid
, NULL
},
1480 {STRING_TOKEN(STR_GRAPHICS_OUTPUT
), &gEfiGraphicsOutputProtocolGuid
, GraphicsOutputProtocolDumpInformation
},
1481 {STRING_TOKEN(STR_EDID_DISCOVERED
), &gEfiEdidDiscoveredProtocolGuid
, EdidDiscoveredProtocolDumpInformation
},
1482 {STRING_TOKEN(STR_EDID_ACTIVE
), &gEfiEdidActiveProtocolGuid
, EdidActiveProtocolDumpInformation
},
1483 {STRING_TOKEN(STR_EDID_OVERRIDE
), &gEfiEdidOverrideProtocolGuid
, NULL
},
1484 {STRING_TOKEN(STR_CON_IN
), &gEfiConsoleInDeviceGuid
, NULL
},
1485 {STRING_TOKEN(STR_CON_OUT
), &gEfiConsoleOutDeviceGuid
, NULL
},
1486 {STRING_TOKEN(STR_STD_ERR
), &gEfiStandardErrorDeviceGuid
, NULL
},
1487 {STRING_TOKEN(STR_LOAD_FILE
), &gEfiLoadFileProtocolGuid
, NULL
},
1488 {STRING_TOKEN(STR_LOAD_FILE2
), &gEfiLoadFile2ProtocolGuid
, NULL
},
1489 {STRING_TOKEN(STR_SIMPLE_FILE_SYS
), &gEfiSimpleFileSystemProtocolGuid
, NULL
},
1490 {STRING_TOKEN(STR_TAPE_IO
), &gEfiTapeIoProtocolGuid
, NULL
},
1491 {STRING_TOKEN(STR_DISK_IO
), &gEfiDiskIoProtocolGuid
, NULL
},
1492 {STRING_TOKEN(STR_BLK_IO
), &gEfiBlockIoProtocolGuid
, NULL
},
1493 {STRING_TOKEN(STR_UC
), &gEfiUnicodeCollationProtocolGuid
, NULL
},
1494 {STRING_TOKEN(STR_UC2
), &gEfiUnicodeCollation2ProtocolGuid
, NULL
},
1495 {STRING_TOKEN(STR_PCIRB_IO
), &gEfiPciRootBridgeIoProtocolGuid
, PciRootBridgeIoDumpInformation
},
1496 {STRING_TOKEN(STR_PCI_IO
), &gEfiPciIoProtocolGuid
, NULL
},
1497 {STRING_TOKEN(STR_SCSI_PT
), &gEfiScsiPassThruProtocolGuid
, NULL
},
1498 {STRING_TOKEN(STR_SCSI_IO
), &gEfiScsiIoProtocolGuid
, NULL
},
1499 {STRING_TOKEN(STR_SCSI_PT_EXT
), &gEfiExtScsiPassThruProtocolGuid
, NULL
},
1500 {STRING_TOKEN(STR_ISCSI
), &gEfiIScsiInitiatorNameProtocolGuid
, NULL
},
1501 {STRING_TOKEN(STR_USB_IO
), &gEfiUsbIoProtocolGuid
, NULL
},
1502 {STRING_TOKEN(STR_USB_HC
), &gEfiUsbHcProtocolGuid
, NULL
},
1503 {STRING_TOKEN(STR_USB_HC2
), &gEfiUsb2HcProtocolGuid
, NULL
},
1504 {STRING_TOKEN(STR_DEBUG_SUPPORT
), &gEfiDebugSupportProtocolGuid
, NULL
},
1505 {STRING_TOKEN(STR_DEBUG_PORT
), &gEfiDebugPortProtocolGuid
, NULL
},
1506 {STRING_TOKEN(STR_DECOMPRESS
), &gEfiDecompressProtocolGuid
, NULL
},
1507 {STRING_TOKEN(STR_ACPI_TABLE
), &gEfiAcpiTableProtocolGuid
, NULL
},
1508 {STRING_TOKEN(STR_EBC_INTERPRETER
), &gEfiEbcProtocolGuid
, NULL
},
1509 {STRING_TOKEN(STR_SNP
), &gEfiSimpleNetworkProtocolGuid
, NULL
},
1510 {STRING_TOKEN(STR_NII
), &gEfiNetworkInterfaceIdentifierProtocolGuid
, NULL
},
1511 {STRING_TOKEN(STR_NII_31
), &gEfiNetworkInterfaceIdentifierProtocolGuid_31
, NULL
},
1512 {STRING_TOKEN(STR_PXE_BC
), &gEfiPxeBaseCodeProtocolGuid
, NULL
},
1513 {STRING_TOKEN(STR_PXE_CB
), &gEfiPxeBaseCodeCallbackProtocolGuid
, NULL
},
1514 {STRING_TOKEN(STR_BIS
), &gEfiBisProtocolGuid
, NULL
},
1515 {STRING_TOKEN(STR_MNP_SB
), &gEfiManagedNetworkServiceBindingProtocolGuid
, NULL
},
1516 {STRING_TOKEN(STR_MNP
), &gEfiManagedNetworkProtocolGuid
, NULL
},
1517 {STRING_TOKEN(STR_ARP_SB
), &gEfiArpServiceBindingProtocolGuid
, NULL
},
1518 {STRING_TOKEN(STR_ARP
), &gEfiArpProtocolGuid
, NULL
},
1519 {STRING_TOKEN(STR_DHCPV4_SB
), &gEfiDhcp4ServiceBindingProtocolGuid
, NULL
},
1520 {STRING_TOKEN(STR_DHCPV4
), &gEfiDhcp4ProtocolGuid
, NULL
},
1521 {STRING_TOKEN(STR_TCPV4_SB
), &gEfiTcp4ServiceBindingProtocolGuid
, NULL
},
1522 {STRING_TOKEN(STR_TCPV4
), &gEfiTcp4ProtocolGuid
, NULL
},
1523 {STRING_TOKEN(STR_IPV4_SB
), &gEfiIp4ServiceBindingProtocolGuid
, NULL
},
1524 {STRING_TOKEN(STR_IPV4
), &gEfiIp4ProtocolGuid
, NULL
},
1525 {STRING_TOKEN(STR_IPV4_CFG
), &gEfiIp4ConfigProtocolGuid
, NULL
},
1526 {STRING_TOKEN(STR_IPV4_CFG2
), &gEfiIp4Config2ProtocolGuid
, NULL
},
1527 {STRING_TOKEN(STR_UDPV4_SB
), &gEfiUdp4ServiceBindingProtocolGuid
, NULL
},
1528 {STRING_TOKEN(STR_UDPV4
), &gEfiUdp4ProtocolGuid
, NULL
},
1529 {STRING_TOKEN(STR_MTFTPV4_SB
), &gEfiMtftp4ServiceBindingProtocolGuid
, NULL
},
1530 {STRING_TOKEN(STR_MTFTPV4
), &gEfiMtftp4ProtocolGuid
, NULL
},
1531 {STRING_TOKEN(STR_AUTH_INFO
), &gEfiAuthenticationInfoProtocolGuid
, NULL
},
1532 {STRING_TOKEN(STR_HASH_SB
), &gEfiHashServiceBindingProtocolGuid
, NULL
},
1533 {STRING_TOKEN(STR_HASH
), &gEfiHashProtocolGuid
, NULL
},
1534 {STRING_TOKEN(STR_HII_FONT
), &gEfiHiiFontProtocolGuid
, NULL
},
1535 {STRING_TOKEN(STR_HII_STRING
), &gEfiHiiStringProtocolGuid
, NULL
},
1536 {STRING_TOKEN(STR_HII_IMAGE
), &gEfiHiiImageProtocolGuid
, NULL
},
1537 {STRING_TOKEN(STR_HII_DATABASE
), &gEfiHiiDatabaseProtocolGuid
, NULL
},
1538 {STRING_TOKEN(STR_HII_CONFIG_ROUT
), &gEfiHiiConfigRoutingProtocolGuid
, NULL
},
1539 {STRING_TOKEN(STR_HII_CONFIG_ACC
), &gEfiHiiConfigAccessProtocolGuid
, NULL
},
1540 {STRING_TOKEN(STR_HII_FORM_BROWSER2
), &gEfiFormBrowser2ProtocolGuid
, NULL
},
1541 {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE
), &gEfiDriverFamilyOverrideProtocolGuid
, NULL
},
1542 {STRING_TOKEN(STR_PCD
), &gPcdProtocolGuid
, NULL
},
1543 {STRING_TOKEN(STR_TCG
), &gEfiTcgProtocolGuid
, NULL
},
1544 {STRING_TOKEN(STR_HII_PACKAGE_LIST
), &gEfiHiiPackageListProtocolGuid
, NULL
},
1547 // the ones under this are deprecated by the current UEFI Spec, but may be found anyways...
1549 {STRING_TOKEN(STR_SHELL_INTERFACE
), &gEfiShellInterfaceGuid
, NULL
},
1550 {STRING_TOKEN(STR_SHELL_ENV2
), &gEfiShellEnvironment2Guid
, NULL
},
1551 {STRING_TOKEN(STR_SHELL_ENV
), &gEfiShellEnvironment2Guid
, NULL
},
1552 {STRING_TOKEN(STR_DEVICE_IO
), &gEfiDeviceIoProtocolGuid
, NULL
},
1553 {STRING_TOKEN(STR_UGA_DRAW
), &gEfiUgaDrawProtocolGuid
, NULL
},
1554 {STRING_TOKEN(STR_UGA_IO
), &gEfiUgaIoProtocolGuid
, NULL
},
1555 {STRING_TOKEN(STR_ESP
), &gEfiPartTypeSystemPartGuid
, NULL
},
1556 {STRING_TOKEN(STR_GPT_NBR
), &gEfiPartTypeLegacyMbrGuid
, NULL
},
1557 {STRING_TOKEN(STR_DRIVER_CONFIG
), &gEfiDriverConfigurationProtocolGuid
, NULL
},
1558 {STRING_TOKEN(STR_DRIVER_CONFIG2
), &gEfiDriverConfiguration2ProtocolGuid
, NULL
},
1561 // these are using local (non-global) definitions to reduce package dependancy.
1563 {STRING_TOKEN(STR_ISA_IO
), (EFI_GUID
*)&EfiIsaIoProtocolGuid
, NULL
},
1564 {STRING_TOKEN(STR_ISA_ACPI
), (EFI_GUID
*)&EfiIsaAcpiProtocolGuid
, NULL
},
1567 // the ones under this are GUID identified structs, not protocols
1569 {STRING_TOKEN(STR_FILE_INFO
), &gEfiFileInfoGuid
, NULL
},
1570 {STRING_TOKEN(STR_FILE_SYS_INFO
), &gEfiFileSystemInfoGuid
, NULL
},
1573 // the ones under this are misc GUIDS.
1575 {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE
), &gEfiGlobalVariableGuid
, NULL
},
1580 {STRING_TOKEN(STR_IP6_SB
), &gEfiIp6ServiceBindingProtocolGuid
, NULL
},
1581 {STRING_TOKEN(STR_IP6
), &gEfiIp6ProtocolGuid
, NULL
},
1582 {STRING_TOKEN(STR_IP6_CONFIG
), &gEfiIp6ConfigProtocolGuid
, NULL
},
1583 {STRING_TOKEN(STR_MTFTP6_SB
), &gEfiMtftp6ServiceBindingProtocolGuid
, NULL
},
1584 {STRING_TOKEN(STR_MTFTP6
), &gEfiMtftp6ProtocolGuid
, NULL
},
1585 {STRING_TOKEN(STR_DHCP6_SB
), &gEfiDhcp6ServiceBindingProtocolGuid
, NULL
},
1586 {STRING_TOKEN(STR_DHCP6
), &gEfiDhcp6ProtocolGuid
, NULL
},
1587 {STRING_TOKEN(STR_UDP6_SB
), &gEfiUdp6ServiceBindingProtocolGuid
, NULL
},
1588 {STRING_TOKEN(STR_UDP6
), &gEfiUdp6ProtocolGuid
, NULL
},
1589 {STRING_TOKEN(STR_TCP6_SB
), &gEfiTcp6ServiceBindingProtocolGuid
, NULL
},
1590 {STRING_TOKEN(STR_TCP6
), &gEfiTcp6ProtocolGuid
, NULL
},
1591 {STRING_TOKEN(STR_VLAN_CONFIG
), &gEfiVlanConfigProtocolGuid
, NULL
},
1592 {STRING_TOKEN(STR_EAP
), &gEfiEapProtocolGuid
, NULL
},
1593 {STRING_TOKEN(STR_EAP_MGMT
), &gEfiEapManagementProtocolGuid
, NULL
},
1594 {STRING_TOKEN(STR_FTP4_SB
), &gEfiFtp4ServiceBindingProtocolGuid
, NULL
},
1595 {STRING_TOKEN(STR_FTP4
), &gEfiFtp4ProtocolGuid
, NULL
},
1596 {STRING_TOKEN(STR_IP_SEC_CONFIG
), &gEfiIpSecConfigProtocolGuid
, NULL
},
1597 {STRING_TOKEN(STR_DH
), &gEfiDriverHealthProtocolGuid
, NULL
},
1598 {STRING_TOKEN(STR_DEF_IMG_LOAD
), &gEfiDeferredImageLoadProtocolGuid
, NULL
},
1599 {STRING_TOKEN(STR_USER_CRED
), &gEfiUserCredentialProtocolGuid
, NULL
},
1600 {STRING_TOKEN(STR_USER_MNGR
), &gEfiUserManagerProtocolGuid
, NULL
},
1601 {STRING_TOKEN(STR_ATA_PASS_THRU
), &gEfiAtaPassThruProtocolGuid
, NULL
},
1606 {STRING_TOKEN(STR_FW_MGMT
), &gEfiFirmwareManagementProtocolGuid
, FirmwareManagementDumpInformation
},
1607 {STRING_TOKEN(STR_IP_SEC
), &gEfiIpSecProtocolGuid
, NULL
},
1608 {STRING_TOKEN(STR_IP_SEC2
), &gEfiIpSec2ProtocolGuid
, NULL
},
1613 {STRING_TOKEN(STR_KMS
), &gEfiKmsProtocolGuid
, NULL
},
1614 {STRING_TOKEN(STR_BLK_IO2
), &gEfiBlockIo2ProtocolGuid
, NULL
},
1615 {STRING_TOKEN(STR_SSC
), &gEfiStorageSecurityCommandProtocolGuid
, NULL
},
1616 {STRING_TOKEN(STR_UCRED2
), &gEfiUserCredential2ProtocolGuid
, NULL
},
1621 {STRING_TOKEN(STR_DISK_IO2
), &gEfiDiskIo2ProtocolGuid
, NULL
},
1622 {STRING_TOKEN(STR_ADAPTER_INFO
), &gEfiAdapterInformationProtocolGuid
, AdapterInformationDumpInformation
},
1627 {STRING_TOKEN(STR_IDE_CONT_INIT
), &gEfiIdeControllerInitProtocolGuid
, NULL
},
1628 {STRING_TOKEN(STR_DISK_INFO
), &gEfiDiskInfoProtocolGuid
, NULL
},
1633 {STRING_TOKEN(STR_BDS_ARCH
), &gEfiBdsArchProtocolGuid
, NULL
},
1634 {STRING_TOKEN(STR_CPU_ARCH
), &gEfiCpuArchProtocolGuid
, NULL
},
1635 {STRING_TOKEN(STR_MET_ARCH
), &gEfiMetronomeArchProtocolGuid
, NULL
},
1636 {STRING_TOKEN(STR_MON_ARCH
), &gEfiMonotonicCounterArchProtocolGuid
, NULL
},
1637 {STRING_TOKEN(STR_RTC_ARCH
), &gEfiRealTimeClockArchProtocolGuid
, NULL
},
1638 {STRING_TOKEN(STR_RESET_ARCH
), &gEfiResetArchProtocolGuid
, NULL
},
1639 {STRING_TOKEN(STR_RT_ARCH
), &gEfiRuntimeArchProtocolGuid
, NULL
},
1640 {STRING_TOKEN(STR_SEC_ARCH
), &gEfiSecurityArchProtocolGuid
, NULL
},
1641 {STRING_TOKEN(STR_TIMER_ARCH
), &gEfiTimerArchProtocolGuid
, NULL
},
1642 {STRING_TOKEN(STR_VAR_ARCH
), &gEfiVariableWriteArchProtocolGuid
, NULL
},
1643 {STRING_TOKEN(STR_V_ARCH
), &gEfiVariableArchProtocolGuid
, NULL
},
1644 {STRING_TOKEN(STR_SECP
), &gEfiSecurityPolicyProtocolGuid
, NULL
},
1645 {STRING_TOKEN(STR_WDT_ARCH
), &gEfiWatchdogTimerArchProtocolGuid
, NULL
},
1646 {STRING_TOKEN(STR_SCR
), &gEfiStatusCodeRuntimeProtocolGuid
, NULL
},
1647 {STRING_TOKEN(STR_SMB_HC
), &gEfiSmbusHcProtocolGuid
, NULL
},
1648 {STRING_TOKEN(STR_FV_2
), &gEfiFirmwareVolume2ProtocolGuid
, NULL
},
1649 {STRING_TOKEN(STR_FV_BLOCK
), &gEfiFirmwareVolumeBlockProtocolGuid
, NULL
},
1650 {STRING_TOKEN(STR_CAP_ARCH
), &gEfiCapsuleArchProtocolGuid
, NULL
},
1651 {STRING_TOKEN(STR_MP_SERVICE
), &gEfiMpServiceProtocolGuid
, NULL
},
1652 {STRING_TOKEN(STR_HBRAP
), &gEfiPciHostBridgeResourceAllocationProtocolGuid
, NULL
},
1653 {STRING_TOKEN(STR_PCIP
), &gEfiPciPlatformProtocolGuid
, NULL
},
1654 {STRING_TOKEN(STR_PCIO
), &gEfiPciOverrideProtocolGuid
, NULL
},
1655 {STRING_TOKEN(STR_PCIE
), &gEfiPciEnumerationCompleteProtocolGuid
, NULL
},
1656 {STRING_TOKEN(STR_IPCID
), &gEfiIncompatiblePciDeviceSupportProtocolGuid
, NULL
},
1657 {STRING_TOKEN(STR_PCIHPI
), &gEfiPciHotPlugInitProtocolGuid
, NULL
},
1658 {STRING_TOKEN(STR_PCIHPR
), &gEfiPciHotPlugRequestProtocolGuid
, NULL
},
1659 {STRING_TOKEN(STR_SMBIOS
), &gEfiSmbiosProtocolGuid
, NULL
},
1660 {STRING_TOKEN(STR_S3_SAVE
), &gEfiS3SaveStateProtocolGuid
, NULL
},
1661 {STRING_TOKEN(STR_S3_S_SMM
), &gEfiS3SmmSaveStateProtocolGuid
, NULL
},
1662 {STRING_TOKEN(STR_RSC
), &gEfiRscHandlerProtocolGuid
, NULL
},
1663 {STRING_TOKEN(STR_S_RSC
), &gEfiSmmRscHandlerProtocolGuid
, NULL
},
1664 {STRING_TOKEN(STR_ACPI_SDT
), &gEfiAcpiSdtProtocolGuid
, NULL
},
1665 {STRING_TOKEN(STR_SIO
), &gEfiSioProtocolGuid
, NULL
},
1666 {STRING_TOKEN(STR_S_CPU2
), &gEfiSmmCpuIo2ProtocolGuid
, NULL
},
1667 {STRING_TOKEN(STR_S_BASE2
), &gEfiSmmBase2ProtocolGuid
, NULL
},
1668 {STRING_TOKEN(STR_S_ACC_2
), &gEfiSmmAccess2ProtocolGuid
, NULL
},
1669 {STRING_TOKEN(STR_S_CON_2
), &gEfiSmmControl2ProtocolGuid
, NULL
},
1670 {STRING_TOKEN(STR_S_CONFIG
), &gEfiSmmConfigurationProtocolGuid
, NULL
},
1671 {STRING_TOKEN(STR_S_RTL
), &gEfiSmmReadyToLockProtocolGuid
, NULL
},
1672 {STRING_TOKEN(STR_DS_RTL
), &gEfiDxeSmmReadyToLockProtocolGuid
, NULL
},
1673 {STRING_TOKEN(STR_S_COMM
), &gEfiSmmCommunicationProtocolGuid
, NULL
},
1674 {STRING_TOKEN(STR_S_STAT
), &gEfiSmmStatusCodeProtocolGuid
, NULL
},
1675 {STRING_TOKEN(STR_S_CPU
), &gEfiSmmCpuProtocolGuid
, NULL
},
1676 {STRING_TOKEN(STR_S_PCIRBIO
), &gEfiPciRootBridgeIoProtocolGuid
, NULL
},
1677 {STRING_TOKEN(STR_S_SWD
), &gEfiSmmSwDispatch2ProtocolGuid
, NULL
},
1678 {STRING_TOKEN(STR_S_SXD
), &gEfiSmmSxDispatch2ProtocolGuid
, NULL
},
1679 {STRING_TOKEN(STR_S_PTD2
), &gEfiSmmPeriodicTimerDispatch2ProtocolGuid
, NULL
},
1680 {STRING_TOKEN(STR_S_UD2
), &gEfiSmmUsbDispatch2ProtocolGuid
, NULL
},
1681 {STRING_TOKEN(STR_S_GD2
), &gEfiSmmGpiDispatch2ProtocolGuid
, NULL
},
1682 {STRING_TOKEN(STR_S_SBD2
), &gEfiSmmStandbyButtonDispatch2ProtocolGuid
, NULL
},
1683 {STRING_TOKEN(STR_S_PBD2
), &gEfiSmmPowerButtonDispatch2ProtocolGuid
, NULL
},
1684 {STRING_TOKEN(STR_S_ITD2
), &gEfiSmmIoTrapDispatch2ProtocolGuid
, NULL
},
1685 {STRING_TOKEN(STR_PCD
), &gEfiPcdProtocolGuid
, NULL
},
1686 {STRING_TOKEN(STR_FVB2
), &gEfiFirmwareVolumeBlock2ProtocolGuid
, NULL
},
1687 {STRING_TOKEN(STR_CPUIO2
), &gEfiCpuIo2ProtocolGuid
, NULL
},
1688 {STRING_TOKEN(STR_LEGACY_R2
), &gEfiLegacyRegion2ProtocolGuid
, NULL
},
1689 {STRING_TOKEN(STR_SAL_MIP
), &gEfiSalMcaInitPmiProtocolGuid
, NULL
},
1690 {STRING_TOKEN(STR_ES_BS
), &gEfiExtendedSalBootServiceProtocolGuid
, NULL
},
1691 {STRING_TOKEN(STR_ES_BIO
), &gEfiExtendedSalBaseIoServicesProtocolGuid
, NULL
},
1692 {STRING_TOKEN(STR_ES_STALL
), &gEfiExtendedSalStallServicesProtocolGuid
, NULL
},
1693 {STRING_TOKEN(STR_ES_RTC
), &gEfiExtendedSalRtcServicesProtocolGuid
, NULL
},
1694 {STRING_TOKEN(STR_ES_VS
), &gEfiExtendedSalVariableServicesProtocolGuid
, NULL
},
1695 {STRING_TOKEN(STR_ES_MTC
), &gEfiExtendedSalMtcServicesProtocolGuid
, NULL
},
1696 {STRING_TOKEN(STR_ES_RESET
), &gEfiExtendedSalResetServicesProtocolGuid
, NULL
},
1697 {STRING_TOKEN(STR_ES_SC
), &gEfiExtendedSalStatusCodeServicesProtocolGuid
, NULL
},
1698 {STRING_TOKEN(STR_ES_FBS
), &gEfiExtendedSalFvBlockServicesProtocolGuid
, NULL
},
1699 {STRING_TOKEN(STR_ES_MP
), &gEfiExtendedSalMpServicesProtocolGuid
, NULL
},
1700 {STRING_TOKEN(STR_ES_PAL
), &gEfiExtendedSalPalServicesProtocolGuid
, NULL
},
1701 {STRING_TOKEN(STR_ES_BASE
), &gEfiExtendedSalBaseServicesProtocolGuid
, NULL
},
1702 {STRING_TOKEN(STR_ES_MCA
), &gEfiExtendedSalMcaServicesProtocolGuid
, NULL
},
1703 {STRING_TOKEN(STR_ES_PCI
), &gEfiExtendedSalPciServicesProtocolGuid
, NULL
},
1704 {STRING_TOKEN(STR_ES_CACHE
), &gEfiExtendedSalCacheServicesProtocolGuid
, NULL
},
1705 {STRING_TOKEN(STR_ES_MCA_LOG
), &gEfiExtendedSalMcaLogServicesProtocolGuid
, NULL
},
1706 {STRING_TOKEN(STR_S2ARCH
), &gEfiSecurity2ArchProtocolGuid
, NULL
},
1707 {STRING_TOKEN(STR_EODXE
), &gEfiSmmEndOfDxeProtocolGuid
, NULL
},
1708 {STRING_TOKEN(STR_ISAHC
), &gEfiIsaHcProtocolGuid
, NULL
},
1709 {STRING_TOKEN(STR_ISAHC_B
), &gEfiIsaHcServiceBindingProtocolGuid
, NULL
},
1710 {STRING_TOKEN(STR_SIO_C
), &gEfiSioControlProtocolGuid
, NULL
},
1711 {STRING_TOKEN(STR_GET_PCD
), &gEfiGetPcdInfoProtocolGuid
, NULL
},
1712 {STRING_TOKEN(STR_I2C_M
), &gEfiI2cMasterProtocolGuid
, NULL
},
1713 {STRING_TOKEN(STR_I2CIO
), &gEfiI2cIoProtocolGuid
, NULL
},
1714 {STRING_TOKEN(STR_I2CEN
), &gEfiI2cEnumerateProtocolGuid
, NULL
},
1715 {STRING_TOKEN(STR_I2C_H
), &gEfiI2cHostProtocolGuid
, NULL
},
1716 {STRING_TOKEN(STR_I2C_BCM
), &gEfiI2cBusConfigurationManagementProtocolGuid
, NULL
},
1717 {STRING_TOKEN(STR_TREE
), &gEfiTrEEProtocolGuid
, NULL
},
1718 {STRING_TOKEN(STR_TCG2
), &gEfiTcg2ProtocolGuid
, NULL
},
1719 {STRING_TOKEN(STR_TIMESTAMP
), &gEfiTimestampProtocolGuid
, NULL
},
1720 {STRING_TOKEN(STR_RNG
), &gEfiRngProtocolGuid
, NULL
},
1721 {STRING_TOKEN(STR_NVMEPT
), &gEfiNvmExpressPassThruProtocolGuid
, NULL
},
1722 {STRING_TOKEN(STR_H2_SB
), &gEfiHash2ServiceBindingProtocolGuid
, NULL
},
1723 {STRING_TOKEN(STR_HASH2
), &gEfiHash2ProtocolGuid
, NULL
},
1724 {STRING_TOKEN(STR_BIO_C
), &gEfiBlockIoCryptoProtocolGuid
, NULL
},
1725 {STRING_TOKEN(STR_SCR
), &gEfiSmartCardReaderProtocolGuid
, NULL
},
1726 {STRING_TOKEN(STR_SCE
), &gEfiSmartCardEdgeProtocolGuid
, NULL
},
1727 {STRING_TOKEN(STR_USB_FIO
), &gEfiUsbFunctionIoProtocolGuid
, NULL
},
1728 {STRING_TOKEN(STR_BC_HC
), &gEfiBluetoothHcProtocolGuid
, NULL
},
1729 {STRING_TOKEN(STR_BC_IO_SB
), &gEfiBluetoothIoServiceBindingProtocolGuid
, NULL
},
1730 {STRING_TOKEN(STR_BC_IO
), &gEfiBluetoothIoProtocolGuid
, NULL
},
1731 {STRING_TOKEN(STR_BC_C
), &gEfiBluetoothConfigProtocolGuid
, NULL
},
1732 {STRING_TOKEN(STR_REG_EXP
), &gEfiRegularExpressionProtocolGuid
, NULL
},
1733 {STRING_TOKEN(STR_B_MGR_P
), &gEfiBootManagerPolicyProtocolGuid
, NULL
},
1734 {STRING_TOKEN(STR_CKH
), &gEfiConfigKeywordHandlerProtocolGuid
, NULL
},
1735 {STRING_TOKEN(STR_WIFI
), &gEfiWiFiProtocolGuid
, NULL
},
1736 {STRING_TOKEN(STR_EAP_M
), &gEfiEapManagement2ProtocolGuid
, NULL
},
1737 {STRING_TOKEN(STR_EAP_C
), &gEfiEapConfigurationProtocolGuid
, NULL
},
1738 {STRING_TOKEN(STR_PKCS7
), &gEfiPkcs7VerifyProtocolGuid
, NULL
},
1739 {STRING_TOKEN(STR_NET_DNS4_SB
), &gEfiDns4ServiceBindingProtocolGuid
, NULL
},
1740 {STRING_TOKEN(STR_NET_DNS4
), &gEfiDns4ProtocolGuid
, NULL
},
1741 {STRING_TOKEN(STR_NET_DNS6_SB
), &gEfiDns6ServiceBindingProtocolGuid
, NULL
},
1742 {STRING_TOKEN(STR_NET_DNS6
), &gEfiDns6ProtocolGuid
, NULL
},
1743 {STRING_TOKEN(STR_NET_HTTP_SB
), &gEfiHttpServiceBindingProtocolGuid
, NULL
},
1744 {STRING_TOKEN(STR_NET_HTTP
), &gEfiHttpProtocolGuid
, NULL
},
1745 {STRING_TOKEN(STR_NET_HTTP_U
), &gEfiHttpUtilitiesProtocolGuid
, NULL
},
1746 {STRING_TOKEN(STR_REST
), &gEfiRestProtocolGuid
, NULL
},
1749 // UEFI Shell Spec 2.0
1751 {STRING_TOKEN(STR_SHELL_PARAMETERS
), &gEfiShellParametersProtocolGuid
, NULL
},
1752 {STRING_TOKEN(STR_SHELL
), &gEfiShellProtocolGuid
, NULL
},
1755 // UEFI Shell Spec 2.1
1757 {STRING_TOKEN(STR_SHELL_DYNAMIC
), &gEfiShellDynamicCommandProtocolGuid
, NULL
},
1762 {STRING_TOKEN(STR_PCDINFOPROT
), &gGetPcdInfoProtocolGuid
, NULL
},
1767 {STRING_TOKEN(STR_UNKNOWN_DEVICE
), NULL
, NULL
},
1771 Function to get the node for a protocol or struct from it's GUID.
1773 if Guid is NULL, then ASSERT.
1775 @param[in] Guid The GUID to look for the name of.
1779 CONST GUID_INFO_BLOCK
*
1781 InternalShellGetNodeFromGuid(
1782 IN CONST EFI_GUID
* Guid
1785 CONST GUID_INFO_BLOCK
*ListWalker
;
1788 ASSERT(Guid
!= NULL
);
1790 for (LoopCount
= 0, ListWalker
= GuidList
; GuidList
!= NULL
&& LoopCount
< GuidListCount
; LoopCount
++, ListWalker
++) {
1791 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1792 return (ListWalker
);
1796 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
1797 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1798 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1799 return (ListWalker
);
1803 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1804 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1805 return (ListWalker
);
1812 Function to add a new GUID/Name mapping.
1814 @param[in] Guid The Guid
1815 @param[in] NameID The STRING id of the HII string to use
1816 @param[in] DumpFunc The pointer to the dump function
1819 @retval EFI_SUCCESS The operation was sucessful
1820 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1821 @retval EFI_INVALID_PARAMETER Guid NameId was invalid
1825 InsertNewGuidNameMapping(
1826 IN CONST EFI_GUID
*Guid
,
1827 IN CONST EFI_STRING_ID NameID
,
1828 IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
1831 ASSERT(Guid
!= NULL
);
1832 ASSERT(NameID
!= 0);
1834 GuidList
= ReallocatePool(GuidListCount
* sizeof(GUID_INFO_BLOCK
), GuidListCount
+1 * sizeof(GUID_INFO_BLOCK
), GuidList
);
1835 if (GuidList
== NULL
) {
1837 return (EFI_OUT_OF_RESOURCES
);
1841 GuidList
[GuidListCount
- 1].GuidId
= AllocateCopyPool(sizeof(EFI_GUID
), Guid
);
1842 GuidList
[GuidListCount
- 1].StringId
= NameID
;
1843 GuidList
[GuidListCount
- 1].DumpInfo
= DumpFunc
;
1845 if (GuidList
[GuidListCount
- 1].GuidId
== NULL
) {
1846 return (EFI_OUT_OF_RESOURCES
);
1849 return (EFI_SUCCESS
);
1853 Function to add a new GUID/Name mapping.
1855 This cannot overwrite an existing mapping.
1857 @param[in] Guid The Guid
1858 @param[in] TheName The Guid's name
1859 @param[in] Lang RFC4646 language code list or NULL
1861 @retval EFI_SUCCESS The operation was sucessful
1862 @retval EFI_ACCESS_DENIED There was a duplicate
1863 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1864 @retval EFI_INVALID_PARAMETER Guid or TheName was NULL
1868 AddNewGuidNameMapping(
1869 IN CONST EFI_GUID
*Guid
,
1870 IN CONST CHAR16
*TheName
,
1871 IN CONST CHAR8
*Lang OPTIONAL
1874 EFI_STRING_ID NameID
;
1876 HandleParsingHiiInit();
1878 if (Guid
== NULL
|| TheName
== NULL
){
1879 return (EFI_INVALID_PARAMETER
);
1882 if ((InternalShellGetNodeFromGuid(Guid
)) != NULL
) {
1883 return (EFI_ACCESS_DENIED
);
1886 NameID
= HiiSetString(mHandleParsingHiiHandle
, 0, (CHAR16
*)TheName
, Lang
);
1888 return (EFI_OUT_OF_RESOURCES
);
1891 return (InsertNewGuidNameMapping(Guid
, NameID
, NULL
));
1895 Function to get the name of a protocol or struct from it's GUID.
1897 if Guid is NULL, then ASSERT.
1899 @param[in] Guid The GUID to look for the name of.
1900 @param[in] Lang The language to use.
1902 @return pointer to string of the name. The caller
1903 is responsible to free this memory.
1907 GetStringNameFromGuid(
1908 IN CONST EFI_GUID
*Guid
,
1909 IN CONST CHAR8
*Lang OPTIONAL
1912 CONST GUID_INFO_BLOCK
*Id
;
1914 HandleParsingHiiInit();
1916 Id
= InternalShellGetNodeFromGuid(Guid
);
1917 return (HiiGetString(mHandleParsingHiiHandle
, Id
==NULL
?STRING_TOKEN(STR_UNKNOWN_DEVICE
):Id
->StringId
, Lang
));
1921 Function to dump protocol information from a handle.
1923 This function will return a allocated string buffer containing the
1924 information. The caller is responsible for freeing the memory.
1926 If Guid is NULL, ASSERT().
1927 If TheHandle is NULL, ASSERT().
1929 @param[in] TheHandle The handle to dump information from.
1930 @param[in] Guid The GUID of the protocol to dump.
1931 @param[in] Verbose TRUE for extra info. FALSE otherwise.
1933 @return The pointer to string.
1934 @retval NULL An error was encountered.
1938 GetProtocolInformationDump(
1939 IN CONST EFI_HANDLE TheHandle
,
1940 IN CONST EFI_GUID
*Guid
,
1941 IN CONST BOOLEAN Verbose
1944 CONST GUID_INFO_BLOCK
*Id
;
1946 ASSERT(TheHandle
!= NULL
);
1947 ASSERT(Guid
!= NULL
);
1949 if (TheHandle
== NULL
|| Guid
== NULL
) {
1953 Id
= InternalShellGetNodeFromGuid(Guid
);
1954 if (Id
!= NULL
&& Id
->DumpInfo
!= NULL
) {
1955 return (Id
->DumpInfo(TheHandle
, Verbose
));
1961 Function to get the Guid for a protocol or struct based on it's string name.
1963 do not modify the returned Guid.
1965 @param[in] Name The pointer to the string name.
1966 @param[in] Lang The pointer to the language code.
1967 @param[out] Guid The pointer to the Guid.
1969 @retval EFI_SUCCESS The operation was sucessful.
1973 GetGuidFromStringName(
1974 IN CONST CHAR16
*Name
,
1975 IN CONST CHAR8
*Lang OPTIONAL
,
1979 CONST GUID_INFO_BLOCK
*ListWalker
;
1983 HandleParsingHiiInit();
1985 ASSERT(Guid
!= NULL
);
1987 return (EFI_INVALID_PARAMETER
);
1991 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
1992 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1993 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
1994 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
1995 *Guid
= ListWalker
->GuidId
;
1997 SHELL_FREE_NON_NULL(String
);
1998 if (*Guid
!= NULL
) {
1999 return (EFI_SUCCESS
);
2003 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2004 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2005 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2006 *Guid
= ListWalker
->GuidId
;
2008 SHELL_FREE_NON_NULL(String
);
2009 if (*Guid
!= NULL
) {
2010 return (EFI_SUCCESS
);
2014 for (LoopCount
= 0, ListWalker
= GuidList
; GuidList
!= NULL
&& LoopCount
< GuidListCount
; LoopCount
++, ListWalker
++) {
2015 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2016 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2017 *Guid
= ListWalker
->GuidId
;
2019 SHELL_FREE_NON_NULL(String
);
2020 if (*Guid
!= NULL
) {
2021 return (EFI_SUCCESS
);
2025 return (EFI_NOT_FOUND
);
2029 Get best support language for this driver.
2031 First base on the user input language to search, second base on the current
2032 platform used language to search, third get the first language from the
2033 support language list. The caller need to free the buffer of the best language.
2035 @param[in] SupportedLanguages The support languages for this driver.
2036 @param[in] InputLanguage The user input language.
2037 @param[in] Iso639Language Whether get language for ISO639.
2039 @return The best support language for this driver.
2043 GetBestLanguageForDriver (
2044 IN CONST CHAR8
*SupportedLanguages
,
2045 IN CONST CHAR8
*InputLanguage
,
2046 IN BOOLEAN Iso639Language
2049 CHAR8
*LanguageVariable
;
2050 CHAR8
*BestLanguage
;
2052 GetVariable2 (Iso639Language
? L
"Lang" : L
"PlatformLang", &gEfiGlobalVariableGuid
, (VOID
**)&LanguageVariable
, NULL
);
2054 BestLanguage
= GetBestLanguage(
2057 (InputLanguage
!= NULL
) ? InputLanguage
: "",
2058 (LanguageVariable
!= NULL
) ? LanguageVariable
: "",
2063 if (LanguageVariable
!= NULL
) {
2064 FreePool (LanguageVariable
);
2067 return BestLanguage
;
2071 Function to retrieve the driver name (if possible) from the ComponentName or
2072 ComponentName2 protocol
2074 @param[in] TheHandle The driver handle to get the name of.
2075 @param[in] Language The language to use.
2077 @retval NULL The name could not be found.
2078 @return A pointer to the string name. Do not de-allocate the memory.
2082 GetStringNameFromHandle(
2083 IN CONST EFI_HANDLE TheHandle
,
2084 IN CONST CHAR8
*Language
2087 EFI_COMPONENT_NAME2_PROTOCOL
*CompNameStruct
;
2094 Status
= gBS
->OpenProtocol(
2096 &gEfiComponentName2ProtocolGuid
,
2097 (VOID
**)&CompNameStruct
,
2100 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2101 if (!EFI_ERROR(Status
)) {
2102 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2103 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2104 if (BestLang
!= NULL
) {
2105 FreePool (BestLang
);
2108 if (!EFI_ERROR(Status
)) {
2112 Status
= gBS
->OpenProtocol(
2114 &gEfiComponentNameProtocolGuid
,
2115 (VOID
**)&CompNameStruct
,
2118 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2119 if (!EFI_ERROR(Status
)) {
2120 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2121 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2122 if (BestLang
!= NULL
) {
2123 FreePool (BestLang
);
2125 if (!EFI_ERROR(Status
)) {
2133 Function to initialize the file global mHandleList object for use in
2134 vonverting handles to index and index to handle.
2136 @retval EFI_SUCCESS The operation was successful.
2140 InternalShellInitHandleList(
2145 EFI_HANDLE
*HandleBuffer
;
2147 HANDLE_LIST
*ListWalker
;
2149 if (mHandleList
.NextIndex
!= 0) {
2152 InitializeListHead(&mHandleList
.List
.Link
);
2153 mHandleList
.NextIndex
= 1;
2154 Status
= gBS
->LocateHandleBuffer (
2161 ASSERT_EFI_ERROR(Status
);
2162 if (EFI_ERROR(Status
)) {
2165 for (mHandleList
.NextIndex
= 1 ; mHandleList
.NextIndex
<= HandleCount
; mHandleList
.NextIndex
++){
2166 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2167 ASSERT(ListWalker
!= NULL
);
2168 ListWalker
->TheHandle
= HandleBuffer
[mHandleList
.NextIndex
-1];
2169 ListWalker
->TheIndex
= mHandleList
.NextIndex
;
2170 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
2172 FreePool(HandleBuffer
);
2173 return (EFI_SUCCESS
);
2177 Function to retrieve the human-friendly index of a given handle. If the handle
2178 does not have a index one will be automatically assigned. The index value is valid
2179 until the termination of the shell application.
2181 @param[in] TheHandle The handle to retrieve an index for.
2183 @retval 0 A memory allocation failed.
2184 @return The index of the handle.
2189 ConvertHandleToHandleIndex(
2190 IN CONST EFI_HANDLE TheHandle
2194 EFI_GUID
**ProtocolBuffer
;
2195 UINTN ProtocolCount
;
2196 HANDLE_LIST
*ListWalker
;
2198 if (TheHandle
== NULL
) {
2202 InternalShellInitHandleList();
2204 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2205 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2206 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2208 if (ListWalker
->TheHandle
== TheHandle
) {
2210 // Verify that TheHandle is still present in the Handle Database
2212 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2213 if (EFI_ERROR (Status
)) {
2215 // TheHandle is not present in the Handle Database, so delete from the handle list
2217 RemoveEntryList (&ListWalker
->Link
);
2220 FreePool (ProtocolBuffer
);
2221 return (ListWalker
->TheIndex
);
2226 // Verify that TheHandle is valid handle
2228 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2229 if (EFI_ERROR (Status
)) {
2231 // TheHandle is not valid, so do not add to handle list
2235 FreePool (ProtocolBuffer
);
2237 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2238 ASSERT(ListWalker
!= NULL
);
2239 ListWalker
->TheHandle
= TheHandle
;
2240 ListWalker
->TheIndex
= mHandleList
.NextIndex
++;
2241 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
2242 return (ListWalker
->TheIndex
);
2248 Function to retrieve the EFI_HANDLE from the human-friendly index.
2250 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.
2252 @retval NULL The index was invalid.
2253 @return The EFI_HANDLE that index represents.
2258 ConvertHandleIndexToHandle(
2259 IN CONST UINTN TheIndex
2263 EFI_GUID
**ProtocolBuffer
;
2264 UINTN ProtocolCount
;
2265 HANDLE_LIST
*ListWalker
;
2267 InternalShellInitHandleList();
2269 if (TheIndex
>= mHandleList
.NextIndex
) {
2273 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2274 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2275 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2277 if (ListWalker
->TheIndex
== TheIndex
&& ListWalker
->TheHandle
!= NULL
) {
2279 // Verify that LinkWalker->TheHandle is valid handle
2281 Status
= gBS
->ProtocolsPerHandle(ListWalker
->TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2282 if (EFI_ERROR (Status
)) {
2284 // TheHandle is not valid, so do not add to handle list
2286 ListWalker
->TheHandle
= NULL
;
2288 return (ListWalker
->TheHandle
);
2295 Gets all the related EFI_HANDLEs based on the mask supplied.
2297 This function scans all EFI_HANDLES in the UEFI environment's handle database
2298 and returns the ones with the specified relationship (Mask) to the specified
2301 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2302 If MatchingHandleCount is NULL, then ASSERT.
2304 If MatchingHandleBuffer is not NULL upon a successful return the memory must be
2307 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.
2308 @param[in] ControllerHandle The handle with Device Path protocol on it.
2309 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in
2310 MatchingHandleBuffer.
2311 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount
2312 EFI_HANDLEs with a terminating NULL EFI_HANDLE.
2313 @param[out] HandleType An array of type information.
2315 @retval EFI_SUCCESS The operation was successful, and any related handles
2316 are in MatchingHandleBuffer.
2317 @retval EFI_NOT_FOUND No matching handles were found.
2318 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2322 ParseHandleDatabaseByRelationshipWithType (
2323 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
2324 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
2325 IN UINTN
*HandleCount
,
2326 OUT EFI_HANDLE
**HandleBuffer
,
2327 OUT UINTN
**HandleType
2332 EFI_GUID
**ProtocolGuidArray
;
2334 UINTN ProtocolIndex
;
2335 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfo
;
2336 UINTN OpenInfoCount
;
2337 UINTN OpenInfoIndex
;
2339 INTN DriverBindingHandleIndex
;
2341 ASSERT(HandleCount
!= NULL
);
2342 ASSERT(HandleBuffer
!= NULL
);
2343 ASSERT(HandleType
!= NULL
);
2344 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
2347 *HandleBuffer
= NULL
;
2351 // Retrieve the list of all handles from the handle database
2353 Status
= gBS
->LocateHandleBuffer (
2360 if (EFI_ERROR (Status
)) {
2364 *HandleType
= AllocateZeroPool (*HandleCount
* sizeof (UINTN
));
2365 ASSERT(*HandleType
!= NULL
);
2367 DriverBindingHandleIndex
= -1;
2368 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
2369 if (DriverBindingHandle
!= NULL
&& (*HandleBuffer
)[HandleIndex
] == DriverBindingHandle
) {
2370 DriverBindingHandleIndex
= (INTN
)HandleIndex
;
2374 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
2376 // Retrieve the list of all the protocols on each handle
2378 Status
= gBS
->ProtocolsPerHandle (
2379 (*HandleBuffer
)[HandleIndex
],
2383 if (EFI_ERROR (Status
)) {
2387 for (ProtocolIndex
= 0; ProtocolIndex
< ArrayCount
; ProtocolIndex
++) {
2390 // Set the bit describing what this handle has
2392 if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiLoadedImageProtocolGuid
) ) {
2393 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_IMAGE_HANDLE
;
2394 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverBindingProtocolGuid
) ) {
2395 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_BINDING_HANDLE
;
2396 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfiguration2ProtocolGuid
)) {
2397 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
2398 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfigurationProtocolGuid
) ) {
2399 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
2400 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnostics2ProtocolGuid
) ) {
2401 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
2402 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnosticsProtocolGuid
) ) {
2403 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
2404 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentName2ProtocolGuid
) ) {
2405 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
2406 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentNameProtocolGuid
) ) {
2407 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
2408 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDevicePathProtocolGuid
) ) {
2409 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DEVICE_HANDLE
;
2412 ASSERT((*HandleType
)[HandleIndex
] == (*HandleType
)[HandleIndex
]);
2416 // Retrieve the list of agents that have opened each protocol
2418 Status
= gBS
->OpenProtocolInformation (
2419 (*HandleBuffer
)[HandleIndex
],
2420 ProtocolGuidArray
[ProtocolIndex
],
2424 if (EFI_ERROR (Status
)) {
2428 if (ControllerHandle
== NULL
) {
2430 // ControllerHandle == NULL and DriverBindingHandle != NULL.
2431 // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
2433 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2434 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2435 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2436 if (DriverBindingHandleIndex
!= -1) {
2437 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2440 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2441 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2442 if (DriverBindingHandleIndex
!= -1) {
2443 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2445 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2446 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2447 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2453 if (DriverBindingHandle
== NULL
&& ControllerHandle
!= NULL
) {
2454 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
2455 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2456 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2457 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2458 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2459 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2460 (*HandleType
)[ChildIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2464 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2465 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2466 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2467 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2469 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2470 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2476 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2477 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2478 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
2479 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
2485 if (DriverBindingHandle
!= NULL
&& ControllerHandle
!= NULL
) {
2486 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
2487 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2488 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2489 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2490 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
2491 if (DriverBindingHandleIndex
!= -1) {
2492 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2496 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2497 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
2498 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2499 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2500 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2505 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2506 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2507 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2513 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2514 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2515 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
2516 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
2522 FreePool (OpenInfo
);
2524 FreePool (ProtocolGuidArray
);
2530 Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask
2533 This function will scan all EFI_HANDLES in the UEFI environment's handle database
2534 and return all the ones with the specified relationship (Mask) to the specified
2537 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2538 If MatchingHandleCount is NULL, then ASSERT.
2540 If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be
2543 @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol
2545 @param[in] ControllerHandle Handle to a device with Device Path protocol on it.
2546 @param[in] Mask Mask of what relationship(s) is desired.
2547 @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in
2548 MatchingHandleBuffer.
2549 @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount
2550 EFI_HANDLEs and a terminating NULL EFI_HANDLE.
2552 @retval EFI_SUCCESS The operation was sucessful and any related handles
2553 are in MatchingHandleBuffer;
2554 @retval EFI_NOT_FOUND No matching handles were found.
2555 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2559 ParseHandleDatabaseByRelationship (
2560 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
2561 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
2562 IN CONST UINTN Mask
,
2563 IN UINTN
*MatchingHandleCount
,
2564 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2569 EFI_HANDLE
*HandleBuffer
;
2573 ASSERT(MatchingHandleCount
!= NULL
);
2574 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
2576 if ((Mask
& HR_VALID_MASK
) != Mask
) {
2577 return (EFI_INVALID_PARAMETER
);
2580 if ((Mask
& HR_CHILD_HANDLE
) != 0 && DriverBindingHandle
== NULL
) {
2581 return (EFI_INVALID_PARAMETER
);
2584 *MatchingHandleCount
= 0;
2585 if (MatchingHandleBuffer
!= NULL
) {
2586 *MatchingHandleBuffer
= NULL
;
2589 HandleBuffer
= NULL
;
2592 Status
= ParseHandleDatabaseByRelationshipWithType (
2593 DriverBindingHandle
,
2599 if (!EFI_ERROR (Status
)) {
2601 // Count the number of handles that match the attributes in Mask
2603 for (HandleIndex
= 0; HandleIndex
< HandleCount
; HandleIndex
++) {
2604 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
2605 (*MatchingHandleCount
)++;
2609 // If no handles match the attributes in Mask then return EFI_NOT_FOUND
2611 if (*MatchingHandleCount
== 0) {
2612 Status
= EFI_NOT_FOUND
;
2615 if (MatchingHandleBuffer
== NULL
) {
2617 // Someone just wanted the count...
2619 Status
= EFI_SUCCESS
;
2622 // Allocate a handle buffer for the number of handles that matched the attributes in Mask
2624 *MatchingHandleBuffer
= AllocateZeroPool ((*MatchingHandleCount
+1)* sizeof (EFI_HANDLE
));
2625 ASSERT(*MatchingHandleBuffer
!= NULL
);
2627 for (HandleIndex
= 0,*MatchingHandleCount
= 0
2628 ; HandleIndex
< HandleCount
2632 // Fill the allocated buffer with the handles that matched the attributes in Mask
2634 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
2635 (*MatchingHandleBuffer
)[(*MatchingHandleCount
)++] = HandleBuffer
[HandleIndex
];
2640 // Make the last one NULL
2642 (*MatchingHandleBuffer
)[*MatchingHandleCount
] = NULL
;
2644 Status
= EFI_SUCCESS
;
2645 } // MacthingHandleBuffer == NULL (ELSE)
2646 } // *MatchingHandleCount == 0 (ELSE)
2647 } // no error on ParseHandleDatabaseByRelationshipWithType
2649 if (HandleBuffer
!= NULL
) {
2650 FreePool (HandleBuffer
);
2653 if (HandleType
!= NULL
) {
2654 FreePool (HandleType
);
2661 Gets handles for any child controllers of the passed in controller.
2663 @param[in] ControllerHandle The handle of the "parent controller"
2664 @param[in] MatchingHandleCount Pointer to the number of handles in
2665 MatchingHandleBuffer on return.
2666 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2670 @retval EFI_SUCCESS The operation was sucessful.
2674 ParseHandleDatabaseForChildControllers(
2675 IN CONST EFI_HANDLE ControllerHandle
,
2676 IN UINTN
*MatchingHandleCount
,
2677 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2682 UINTN DriverBindingHandleCount
;
2683 EFI_HANDLE
*DriverBindingHandleBuffer
;
2684 UINTN DriverBindingHandleIndex
;
2685 UINTN ChildControllerHandleCount
;
2686 EFI_HANDLE
*ChildControllerHandleBuffer
;
2687 UINTN ChildControllerHandleIndex
;
2688 EFI_HANDLE
*HandleBufferForReturn
;
2690 if (MatchingHandleCount
== NULL
) {
2691 return (EFI_INVALID_PARAMETER
);
2693 *MatchingHandleCount
= 0;
2695 Status
= PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
2697 &DriverBindingHandleCount
,
2698 &DriverBindingHandleBuffer
2700 if (EFI_ERROR (Status
)) {
2705 // Get a buffer big enough for all the controllers.
2707 HandleBufferForReturn
= GetHandleListByProtocol(NULL
);
2708 if (HandleBufferForReturn
== NULL
) {
2709 FreePool (DriverBindingHandleBuffer
);
2710 return (EFI_NOT_FOUND
);
2713 for (DriverBindingHandleIndex
= 0; DriverBindingHandleIndex
< DriverBindingHandleCount
; DriverBindingHandleIndex
++) {
2714 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
2715 DriverBindingHandleBuffer
[DriverBindingHandleIndex
],
2717 &ChildControllerHandleCount
,
2718 &ChildControllerHandleBuffer
2720 if (EFI_ERROR (Status
)) {
2724 for (ChildControllerHandleIndex
= 0;
2725 ChildControllerHandleIndex
< ChildControllerHandleCount
;
2726 ChildControllerHandleIndex
++
2728 for (HandleIndex
= 0; HandleIndex
< *MatchingHandleCount
; HandleIndex
++) {
2729 if (HandleBufferForReturn
[HandleIndex
] == ChildControllerHandleBuffer
[ChildControllerHandleIndex
]) {
2733 if (HandleIndex
>= *MatchingHandleCount
) {
2734 HandleBufferForReturn
[(*MatchingHandleCount
)++] = ChildControllerHandleBuffer
[ChildControllerHandleIndex
];
2738 FreePool (ChildControllerHandleBuffer
);
2741 FreePool (DriverBindingHandleBuffer
);
2743 if (MatchingHandleBuffer
!= NULL
) {
2744 *MatchingHandleBuffer
= HandleBufferForReturn
;
2746 FreePool(HandleBufferForReturn
);
2749 return (EFI_SUCCESS
);
2753 Appends 1 buffer to another buffer. This will re-allocate the destination buffer
2754 if necessary to fit all of the data.
2756 If DestinationBuffer is NULL, then ASSERT().
2758 @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.
2759 @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.
2760 @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.
2761 @param[in] SourceSize The number of bytes of SourceBuffer to append.
2763 @retval NULL A memory allocation failed.
2764 @retval NULL A parameter was invalid.
2765 @return A pointer to (*DestinationBuffer).
2770 IN OUT VOID
**DestinationBuffer
,
2771 IN OUT UINTN
*DestinationSize
,
2772 IN VOID
*SourceBuffer
,
2776 UINTN LocalDestinationSize
;
2777 UINTN LocalDestinationFinalSize
;
2779 ASSERT(DestinationBuffer
!= NULL
);
2781 if (SourceSize
== 0 || SourceBuffer
== NULL
) {
2782 return (*DestinationBuffer
);
2785 if (DestinationSize
== NULL
) {
2786 LocalDestinationSize
= 0;
2788 LocalDestinationSize
= *DestinationSize
;
2791 LocalDestinationFinalSize
= LocalDestinationSize
+ SourceSize
;
2793 if (DestinationSize
!= NULL
) {
2794 *DestinationSize
= LocalDestinationSize
;
2797 if (LocalDestinationSize
== 0) {
2799 *DestinationBuffer
= AllocateZeroPool(LocalDestinationFinalSize
);
2802 *DestinationBuffer
= ReallocatePool(LocalDestinationSize
, LocalDestinationFinalSize
, *DestinationBuffer
);
2805 ASSERT(*DestinationBuffer
!= NULL
);
2808 return (CopyMem(((UINT8
*)(*DestinationBuffer
)) + LocalDestinationSize
, SourceBuffer
, SourceSize
));
2812 Gets handles for any child devices produced by the passed in driver.
2814 @param[in] DriverHandle The handle of the driver.
2815 @param[in] MatchingHandleCount Pointer to the number of handles in
2816 MatchingHandleBuffer on return.
2817 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2819 @retval EFI_SUCCESS The operation was sucessful.
2820 @sa ParseHandleDatabaseByRelationship
2824 ParseHandleDatabaseForChildDevices(
2825 IN CONST EFI_HANDLE DriverHandle
,
2826 IN UINTN
*MatchingHandleCount
,
2827 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2831 EFI_HANDLE
*Buffer2
;
2836 UINTN HandleBufferSize
;
2838 ASSERT(MatchingHandleCount
!= NULL
);
2840 HandleBufferSize
= 0;
2843 *MatchingHandleCount
= 0;
2845 Status
= PARSE_HANDLE_DATABASE_DEVICES (
2850 if (!EFI_ERROR (Status
)) {
2851 for (HandleIndex
= 0; HandleIndex
< Count1
; HandleIndex
++) {
2853 // now find the children
2855 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
2857 Buffer
[HandleIndex
],
2861 if (EFI_ERROR(Status
)) {
2865 // save out required and optional data elements
2867 *MatchingHandleCount
+= Count2
;
2868 if (MatchingHandleBuffer
!= NULL
) {
2869 *MatchingHandleBuffer
= BuffernCatGrow((VOID
**)MatchingHandleBuffer
, &HandleBufferSize
, Buffer2
, Count2
* sizeof(Buffer2
[0]));
2875 if (Buffer2
!= NULL
) {
2881 if (Buffer
!= NULL
) {
2888 Function to get all handles that support a given protocol or all handles.
2890 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL
2891 then the function will return all handles.
2893 @retval NULL A memory allocation failed.
2894 @return A NULL terminated list of handles.
2898 GetHandleListByProtocol (
2899 IN CONST EFI_GUID
*ProtocolGuid OPTIONAL
2902 EFI_HANDLE
*HandleList
;
2910 // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!
2912 if (ProtocolGuid
== NULL
) {
2913 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
2914 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2915 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
2916 if (HandleList
== NULL
) {
2919 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
2920 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
2923 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
2924 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2925 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
2926 if (HandleList
== NULL
) {
2929 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
2930 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
2933 if (EFI_ERROR(Status
)) {
2934 if (HandleList
!= NULL
) {
2935 FreePool(HandleList
);
2939 return (HandleList
);
2943 Function to get all handles that support some protocols.
2945 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
2947 @retval NULL A memory allocation failed.
2948 @retval NULL ProtocolGuids was NULL.
2949 @return A NULL terminated list of EFI_HANDLEs.
2953 GetHandleListByProtocolList (
2954 IN CONST EFI_GUID
**ProtocolGuids
2957 EFI_HANDLE
*HandleList
;
2962 CONST EFI_GUID
**GuidWalker
;
2963 EFI_HANDLE
*HandleWalker1
;
2964 EFI_HANDLE
*HandleWalker2
;
2968 TotalSize
= sizeof(EFI_HANDLE
);
2970 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++,Size
= 0){
2971 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &Size
, NULL
);
2972 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2978 // No handles were found...
2980 if (TotalSize
== sizeof(EFI_HANDLE
)) {
2984 HandleList
= AllocateZeroPool(TotalSize
);
2985 if (HandleList
== NULL
) {
2990 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++){
2991 TempSize
= TotalSize
- Size
;
2992 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &TempSize
, HandleList
+(Size
/sizeof(EFI_HANDLE
)));
2995 // Allow for missing protocols... Only update the 'used' size upon success.
2997 if (!EFI_ERROR(Status
)) {
3001 ASSERT(HandleList
[(TotalSize
/sizeof(EFI_HANDLE
))-1] == NULL
);
3003 for (HandleWalker1
= HandleList
; HandleWalker1
!= NULL
&& *HandleWalker1
!= NULL
; HandleWalker1
++) {
3004 for (HandleWalker2
= HandleWalker1
+ 1; HandleWalker2
!= NULL
&& *HandleWalker2
!= NULL
; HandleWalker2
++) {
3005 if (*HandleWalker1
== *HandleWalker2
) {
3007 // copy memory back 1 handle width.
3009 CopyMem(HandleWalker2
, HandleWalker2
+ 1, TotalSize
- ((HandleWalker2
-HandleList
+1)*sizeof(EFI_HANDLE
)));
3014 return (HandleList
);