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"
20 #include <Protocol/FirmwareVolume2.h>
22 EFI_HANDLE mHandleParsingHiiHandle
= NULL
;
23 HANDLE_INDEX_LIST mHandleList
= {{{NULL
,NULL
},0,0},0};
24 GUID_INFO_BLOCK
*mGuidList
;
28 Function to find the file name associated with a LoadedImageProtocol.
30 @param[in] LoadedImage An instance of LoadedImageProtocol.
32 @retval A string representation of the file name associated
33 with LoadedImage, or NULL if no name can be found.
36 FindLoadedImageFileName (
37 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
42 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
45 UINT32 AuthenticationStatus
;
47 if ((LoadedImage
== NULL
) || (LoadedImage
->FilePath
== NULL
)) {
51 NameGuid
= EfiGetNameGuidFromFwVolDevicePathNode((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*)LoadedImage
->FilePath
);
53 if (NameGuid
== NULL
) {
58 // Get the FirmwareVolume2Protocol of the device handle that this image was loaded from.
60 Status
= gBS
->HandleProtocol (LoadedImage
->DeviceHandle
, &gEfiFirmwareVolume2ProtocolGuid
, (VOID
**) &Fv
);
63 // FirmwareVolume2Protocol is PI, and is not required to be available.
65 if (EFI_ERROR (Status
)) {
70 // Read the user interface section of the image.
73 Status
= Fv
->ReadSection(Fv
, NameGuid
, EFI_SECTION_USER_INTERFACE
, 0, &Buffer
, &BufferSize
, &AuthenticationStatus
);
75 if (EFI_ERROR (Status
)) {
80 // ReadSection returns just the section data, without any section header. For
81 // a user interface section, the only data is the file name.
87 Function to translate the EFI_MEMORY_TYPE into a string.
89 @param[in] Memory The memory type.
91 @retval A string representation of the type allocated from BS Pool.
95 IN CONST EFI_MEMORY_TYPE Memory
102 case EfiReservedMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiReservedMemoryType", 0); break;
103 case EfiLoaderCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderCode", 0); break;
104 case EfiLoaderData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderData", 0); break;
105 case EfiBootServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesCode", 0); break;
106 case EfiBootServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesData", 0); break;
107 case EfiRuntimeServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesCode", 0); break;
108 case EfiRuntimeServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesData", 0); break;
109 case EfiConventionalMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiConventionalMemory", 0); break;
110 case EfiUnusableMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiUnusableMemory", 0); break;
111 case EfiACPIReclaimMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIReclaimMemory", 0); break;
112 case EfiACPIMemoryNVS
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIMemoryNVS", 0); break;
113 case EfiMemoryMappedIO
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIO", 0); break;
114 case EfiMemoryMappedIOPortSpace
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIOPortSpace", 0); break;
115 case EfiPalCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiPalCode", 0); break;
116 case EfiMaxMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMaxMemoryType", 0); break;
117 default: ASSERT(FALSE
);
123 Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.
125 @param[in] Fmt The format type.
127 @retval A string representation of the type allocated from BS Pool.
131 IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt
138 case PixelRedGreenBlueReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelRedGreenBlueReserved8BitPerColor", 0); break;
139 case PixelBlueGreenRedReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBlueGreenRedReserved8BitPerColor", 0); break;
140 case PixelBitMask
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBitMask", 0); break;
141 case PixelBltOnly
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBltOnly", 0); break;
142 case PixelFormatMax
: StrnCatGrow(&RetVal
, NULL
, L
"PixelFormatMax", 0); break;
143 default: ASSERT(FALSE
);
149 Constructor for the library.
151 @param[in] ImageHandle Ignored.
152 @param[in] SystemTable Ignored.
154 @retval EFI_SUCCESS The operation was successful.
158 HandleParsingLibConstructor (
159 IN EFI_HANDLE ImageHandle
,
160 IN EFI_SYSTEM_TABLE
*SystemTable
167 // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.
169 return (EFI_SUCCESS
);
173 Initialization function for HII packages.
177 HandleParsingHiiInit (VOID
)
179 if (mHandleParsingHiiHandle
== NULL
) {
180 mHandleParsingHiiHandle
= HiiAddPackages (&gHandleParsingHiiGuid
, gImageHandle
, UefiHandleParsingLibStrings
, NULL
);
181 ASSERT (mHandleParsingHiiHandle
!= NULL
);
186 Destructor for the library. free any resources.
188 @param[in] ImageHandle Ignored.
189 @param[in] SystemTable Ignored.
191 @retval EFI_SUCCESS The operation was successful.
195 HandleParsingLibDestructor (
196 IN EFI_HANDLE ImageHandle
,
197 IN EFI_SYSTEM_TABLE
*SystemTable
202 for (LoopCount
= 0; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++) {
203 SHELL_FREE_NON_NULL(mGuidList
[LoopCount
].GuidId
);
206 SHELL_FREE_NON_NULL(mGuidList
);
207 if (mHandleParsingHiiHandle
!= NULL
) {
208 HiiRemovePackages(mHandleParsingHiiHandle
);
210 return (EFI_SUCCESS
);
214 Function to dump information about LoadedImage.
216 This will allocate the return buffer from boot services pool.
218 @param[in] TheHandle The handle that has LoadedImage installed.
219 @param[in] Verbose TRUE for additional information, FALSE otherwise.
221 @retval A poitner to a string containing the information.
225 LoadedImageProtocolDumpInformation(
226 IN CONST EFI_HANDLE TheHandle
,
227 IN CONST BOOLEAN Verbose
230 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
240 return (CatSPrint(NULL
, L
"LoadedImage"));
243 Status
= gBS
->OpenProtocol (
245 &gEfiLoadedImageProtocolGuid
,
246 (VOID
**)&LoadedImage
,
249 EFI_OPEN_PROTOCOL_GET_PROTOCOL
252 if (EFI_ERROR (Status
)) {
256 HandleParsingHiiInit();
258 FileName
= FindLoadedImageFileName(LoadedImage
);
261 if (FileName
!= NULL
) {
262 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_NAME
), NULL
);
265 RetVal
= CatSPrint(NULL
, Temp
, FileName
);
268 SHELL_FREE_NON_NULL(Temp
);
269 SHELL_FREE_NON_NULL(FileName
);
272 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_MAIN
), NULL
);
277 FilePath
= ConvertDevicePathToText(LoadedImage
->FilePath
, TRUE
, TRUE
);
279 DataType
= ConvertMemoryType(LoadedImage
->ImageDataType
);
280 CodeType
= ConvertMemoryType(LoadedImage
->ImageCodeType
);
285 LoadedImage
->Revision
,
286 LoadedImage
->ParentHandle
,
287 LoadedImage
->SystemTable
,
288 LoadedImage
->DeviceHandle
,
290 LoadedImage
->LoadOptionsSize
,
291 LoadedImage
->LoadOptions
,
292 LoadedImage
->ImageBase
,
293 LoadedImage
->ImageSize
,
300 SHELL_FREE_NON_NULL(Temp
);
301 SHELL_FREE_NON_NULL(FilePath
);
302 SHELL_FREE_NON_NULL(CodeType
);
303 SHELL_FREE_NON_NULL(DataType
);
309 Function to dump information about GOP.
311 This will allocate the return buffer from boot services pool.
313 @param[in] TheHandle The handle that has LoadedImage installed.
314 @param[in] Verbose TRUE for additional information, FALSE otherwise.
316 @retval A poitner to a string containing the information.
320 GraphicsOutputProtocolDumpInformation(
321 IN CONST EFI_HANDLE TheHandle
,
322 IN CONST BOOLEAN Verbose
325 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
333 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*GopInfo
;
336 return (CatSPrint(NULL
, L
"GraphicsOutput"));
339 HandleParsingHiiInit();
341 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_GOP_DUMP_MAIN
), NULL
);
346 Status
= gBS
->OpenProtocol (
348 &gEfiGraphicsOutputProtocolGuid
,
349 (VOID
**)&GraphicsOutput
,
352 EFI_OPEN_PROTOCOL_GET_PROTOCOL
355 if (EFI_ERROR (Status
)) {
356 SHELL_FREE_NON_NULL (Temp
);
360 Fmt
= ConvertPixelFormat(GraphicsOutput
->Mode
->Info
->PixelFormat
);
365 GraphicsOutput
->Mode
->MaxMode
,
366 GraphicsOutput
->Mode
->Mode
,
367 GraphicsOutput
->Mode
->FrameBufferBase
,
368 (UINT64
)GraphicsOutput
->Mode
->FrameBufferSize
,
369 (UINT64
)GraphicsOutput
->Mode
->SizeOfInfo
,
370 GraphicsOutput
->Mode
->Info
->Version
,
371 GraphicsOutput
->Mode
->Info
->HorizontalResolution
,
372 GraphicsOutput
->Mode
->Info
->VerticalResolution
,
374 GraphicsOutput
->Mode
->Info
->PixelsPerScanLine
,
375 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.RedMask
,
376 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.GreenMask
,
377 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.BlueMask
380 SHELL_FREE_NON_NULL (Temp
);
382 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_GOP_RES_LIST_MAIN
), NULL
);
384 SHELL_FREE_NON_NULL (RetVal
);
388 TempRetVal
= CatSPrint (RetVal
, Temp
);
389 SHELL_FREE_NON_NULL (RetVal
);
390 if (TempRetVal
== NULL
) {
394 SHELL_FREE_NON_NULL (Temp
);
396 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_GOP_RES_LIST_ENTRY
), NULL
);
398 SHELL_FREE_NON_NULL (RetVal
);
403 for (Mode
= 0; Mode
< GraphicsOutput
->Mode
->MaxMode
; Mode
++) {
404 Status
= GraphicsOutput
->QueryMode (
410 if (EFI_ERROR (Status
)) {
414 TempRetVal
= CatSPrint (
418 GopInfo
->HorizontalResolution
,
419 GopInfo
->VerticalResolution
422 SHELL_FREE_NON_NULL (GopInfo
);
423 SHELL_FREE_NON_NULL (RetVal
);
429 SHELL_FREE_NON_NULL(Temp
);
430 SHELL_FREE_NON_NULL(Fmt
);
436 Function to dump information about EDID Discovered Protocol.
438 This will allocate the return buffer from boot services pool.
440 @param[in] TheHandle The handle that has LoadedImage installed.
441 @param[in] Verbose TRUE for additional information, FALSE otherwise.
443 @retval A pointer to a string containing the information.
447 EdidDiscoveredProtocolDumpInformation (
448 IN CONST EFI_HANDLE TheHandle
,
449 IN CONST BOOLEAN Verbose
452 EFI_EDID_DISCOVERED_PROTOCOL
*EdidDiscovered
;
459 return (CatSPrint (NULL
, L
"EDIDDiscovered"));
462 Status
= gBS
->OpenProtocol (
464 &gEfiEdidDiscoveredProtocolGuid
,
465 (VOID
**)&EdidDiscovered
,
468 EFI_OPEN_PROTOCOL_GET_PROTOCOL
471 if (EFI_ERROR (Status
)) {
475 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_DISCOVERED_MAIN
), NULL
);
480 RetVal
= CatSPrint (NULL
, Temp
, EdidDiscovered
->SizeOfEdid
);
481 SHELL_FREE_NON_NULL (Temp
);
483 if (EdidDiscovered
->SizeOfEdid
!= 0) {
484 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_DISCOVERED_DATA
), NULL
);
486 SHELL_FREE_NON_NULL (RetVal
);
489 TempRetVal
= CatSPrint (RetVal
, Temp
);
490 SHELL_FREE_NON_NULL (RetVal
);
493 TempRetVal
= CatSDumpHex (RetVal
, 7, 0, EdidDiscovered
->SizeOfEdid
, EdidDiscovered
->Edid
);
500 Function to dump information about EDID Active Protocol.
502 This will allocate the return buffer from boot services pool.
504 @param[in] TheHandle The handle that has LoadedImage installed.
505 @param[in] Verbose TRUE for additional information, FALSE otherwise.
507 @retval A pointer to a string containing the information.
511 EdidActiveProtocolDumpInformation (
512 IN CONST EFI_HANDLE TheHandle
,
513 IN CONST BOOLEAN Verbose
516 EFI_EDID_ACTIVE_PROTOCOL
*EdidActive
;
523 return (CatSPrint (NULL
, L
"EDIDActive"));
526 Status
= gBS
->OpenProtocol (
528 &gEfiEdidActiveProtocolGuid
,
532 EFI_OPEN_PROTOCOL_GET_PROTOCOL
535 if (EFI_ERROR (Status
)) {
539 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_ACTIVE_MAIN
), NULL
);
544 RetVal
= CatSPrint (NULL
, Temp
, EdidActive
->SizeOfEdid
);
545 SHELL_FREE_NON_NULL (Temp
);
547 if (EdidActive
->SizeOfEdid
!= 0) {
548 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_ACTIVE_DATA
), NULL
);
550 SHELL_FREE_NON_NULL (RetVal
);
553 TempRetVal
= CatSPrint (RetVal
, Temp
);
554 SHELL_FREE_NON_NULL (RetVal
);
557 TempRetVal
= CatSDumpHex (RetVal
, 7, 0, EdidActive
->SizeOfEdid
, EdidActive
->Edid
);
564 Function to dump information about PciRootBridgeIo.
566 This will allocate the return buffer from boot services pool.
568 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
569 @param[in] Verbose TRUE for additional information, FALSE otherwise.
571 @retval A poitner to a string containing the information.
575 PciRootBridgeIoDumpInformation(
576 IN CONST EFI_HANDLE TheHandle
,
577 IN CONST BOOLEAN Verbose
580 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
581 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Configuration
;
592 return (CatSPrint(NULL
, L
"PciRootBridgeIo"));
595 HandleParsingHiiInit();
597 Status
= gBS
->HandleProtocol(
599 &gEfiPciRootBridgeIoProtocolGuid
,
600 (VOID
**)&PciRootBridgeIo
);
602 if (EFI_ERROR(Status
)) {
606 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_PH
), NULL
);
610 Temp2
= CatSPrint(L
"\r\n", Temp
, PciRootBridgeIo
->ParentHandle
);
615 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SEG
), NULL
);
617 SHELL_FREE_NON_NULL(RetVal
);
620 Temp2
= CatSPrint(RetVal
, Temp
, PciRootBridgeIo
->SegmentNumber
);
628 Status
= PciRootBridgeIo
->GetAttributes (PciRootBridgeIo
, &Supports
, &Attributes
);
629 if (!EFI_ERROR(Status
)) {
630 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_ATT
), NULL
);
632 SHELL_FREE_NON_NULL(RetVal
);
635 Temp2
= CatSPrint(RetVal
, Temp
, Attributes
);
641 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS
), NULL
);
643 SHELL_FREE_NON_NULL(RetVal
);
646 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
653 Configuration
= NULL
;
654 Status
= PciRootBridgeIo
->Configuration (PciRootBridgeIo
, (VOID
**) &Configuration
);
655 if (!EFI_ERROR(Status
) && Configuration
!= NULL
) {
656 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_TITLE
), NULL
);
658 SHELL_FREE_NON_NULL(RetVal
);
661 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
666 while (Configuration
->Desc
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
668 switch (Configuration
->ResType
) {
669 case ACPI_ADDRESS_SPACE_TYPE_MEM
:
670 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_MEM
), NULL
);
672 case ACPI_ADDRESS_SPACE_TYPE_IO
:
673 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_IO
), NULL
);
675 case ACPI_ADDRESS_SPACE_TYPE_BUS
:
676 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_BUS
), NULL
);
680 Temp2
= CatSPrint(RetVal
, L
"%s", Temp
);
687 Temp2
= CatSPrint(RetVal
,
688 L
"%H%02x %016lx %016lx %02x%N\r\n",
689 Configuration
->SpecificFlag
,
690 Configuration
->AddrRangeMin
,
691 Configuration
->AddrRangeMax
,
692 Configuration
->AddrSpaceGranularity
704 Function to dump information about SimpleTextOut.
706 This will allocate the return buffer from boot services pool.
708 @param[in] TheHandle The handle that has SimpleTextOut installed.
709 @param[in] Verbose TRUE for additional information, FALSE otherwise.
711 @retval A poitner to a string containing the information.
715 TxtOutProtocolDumpInformation(
716 IN CONST EFI_HANDLE TheHandle
,
717 IN CONST BOOLEAN Verbose
720 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Dev
;
734 HandleParsingHiiInit();
739 Status
= gBS
->HandleProtocol(
741 &gEfiSimpleTextOutProtocolGuid
,
744 ASSERT_EFI_ERROR(Status
);
745 ASSERT (Dev
!= NULL
&& Dev
->Mode
!= NULL
);
747 Size
= (Dev
->Mode
->MaxMode
+ 1) * 80;
748 RetVal
= AllocateZeroPool(Size
);
750 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER
), NULL
);
752 UnicodeSPrint(RetVal
, Size
, Temp
, Dev
, Dev
->Mode
->Attribute
);
759 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE
), NULL
);
760 for (Index
= 0; Index
< Dev
->Mode
->MaxMode
; Index
++) {
761 Status
= Dev
->QueryMode (Dev
, Index
, &Col
, &Row
);
762 NewSize
= Size
- StrSize(RetVal
);
764 RetVal
+ StrLen(RetVal
),
766 Temp
== NULL
?L
"":Temp
,
767 Index
== Dev
->Mode
->Mode
? L
'*' : L
' ',
769 !EFI_ERROR(Status
)?(INTN
)Col
:-1,
770 !EFI_ERROR(Status
)?(INTN
)Row
:-1
777 STATIC CONST UINTN VersionStringSize
= 60;
780 Function to dump information about EfiDriverSupportedEfiVersion protocol.
782 This will allocate the return buffer from boot services pool.
784 @param[in] TheHandle The handle that has the protocol installed.
785 @param[in] Verbose TRUE for additional information, FALSE otherwise.
787 @retval A poitner to a string containing the information.
791 DriverEfiVersionProtocolDumpInformation(
792 IN CONST EFI_HANDLE TheHandle
,
793 IN CONST BOOLEAN Verbose
796 EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL
*DriverEfiVersion
;
800 Status
= gBS
->HandleProtocol(
802 &gEfiDriverSupportedEfiVersionProtocolGuid
,
803 (VOID
**)&DriverEfiVersion
);
805 ASSERT_EFI_ERROR(Status
);
807 RetVal
= AllocateZeroPool(VersionStringSize
);
808 if (RetVal
!= NULL
) {
809 UnicodeSPrint (RetVal
, VersionStringSize
, L
"0x%08x", DriverEfiVersion
->FirmwareVersion
);
814 Function to convert device path to string.
816 This will allocate the return buffer from boot services pool.
818 @param[in] DevPath Pointer to device path instance.
819 @param[in] Verbose TRUE for additional information, FALSE otherwise.
820 @param[in] Length Maximum allowed text length of the device path.
822 @retval A pointer to a string containing the information.
825 ConvertDevicePathToShortText(
826 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevPath
,
827 IN CONST BOOLEAN Verbose
,
828 IN CONST UINTN Length
836 // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
838 Temp
= ConvertDevicePathToText(DevPath
, TRUE
, TRUE
);
839 if (!Verbose
&& Temp
!= NULL
&& StrLen(Temp
) > Length
) {
842 Temp2
= StrnCatGrow(&Temp2
, &Size
, L
"..", 0);
843 Temp2
= StrnCatGrow(&Temp2
, &Size
, Temp
+(StrLen(Temp
) - (Length
- 2)), 0);
851 Function to dump information about DevicePath protocol.
853 This will allocate the return buffer from boot services pool.
855 @param[in] TheHandle The handle that has the protocol installed.
856 @param[in] Verbose TRUE for additional information, FALSE otherwise.
858 @retval A pointer to a string containing the information.
862 DevicePathProtocolDumpInformation(
863 IN CONST EFI_HANDLE TheHandle
,
864 IN CONST BOOLEAN Verbose
867 EFI_DEVICE_PATH_PROTOCOL
*DevPath
;
872 Status
= gBS
->OpenProtocol(TheHandle
, &gEfiDevicePathProtocolGuid
, (VOID
**)&DevPath
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
873 if (!EFI_ERROR(Status
)) {
874 Temp
= ConvertDevicePathToShortText (DevPath
, Verbose
, 30);
875 gBS
->CloseProtocol(TheHandle
, &gEfiDevicePathProtocolGuid
, gImageHandle
, NULL
);
881 Function to dump information about LoadedImageDevicePath protocol.
883 This will allocate the return buffer from boot services pool.
885 @param[in] TheHandle The handle that has the protocol installed.
886 @param[in] Verbose TRUE for additional information, FALSE otherwise.
888 @retval A pointer to a string containing the information.
892 LoadedImageDevicePathProtocolDumpInformation(
893 IN CONST EFI_HANDLE TheHandle
,
894 IN CONST BOOLEAN Verbose
897 EFI_DEVICE_PATH_PROTOCOL
*DevPath
;
902 Status
= gBS
->OpenProtocol(TheHandle
, &gEfiLoadedImageDevicePathProtocolGuid
, (VOID
**)&DevPath
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
903 if (!EFI_ERROR(Status
)) {
904 Temp
= ConvertDevicePathToShortText (DevPath
, Verbose
, 30);
905 gBS
->CloseProtocol(TheHandle
, &gEfiDevicePathProtocolGuid
, gImageHandle
, NULL
);
911 Function to dump information about EfiAdapterInformation Protocol.
913 @param[in] TheHandle The handle that has the protocol installed.
914 @param[in] Verbose TRUE for additional information, FALSE otherwise.
916 @retval A pointer to a string containing the information.
920 AdapterInformationDumpInformation (
921 IN CONST EFI_HANDLE TheHandle
,
922 IN CONST BOOLEAN Verbose
926 EFI_ADAPTER_INFORMATION_PROTOCOL
*EfiAdptrInfoProtocol
;
927 UINTN InfoTypesBufferCount
;
929 EFI_GUID
*InfoTypesBuffer
;
934 VOID
*InformationBlock
;
935 UINTN InformationBlockSize
;
938 return (CatSPrint(NULL
, L
"AdapterInfo"));
941 InfoTypesBuffer
= NULL
;
942 InformationBlock
= NULL
;
945 Status
= gBS
->OpenProtocol (
946 (EFI_HANDLE
) (TheHandle
),
947 &gEfiAdapterInformationProtocolGuid
,
948 (VOID
**) &EfiAdptrInfoProtocol
,
951 EFI_OPEN_PROTOCOL_GET_PROTOCOL
954 if (EFI_ERROR (Status
)) {
959 // Get a list of supported information types for this instance of the protocol.
961 Status
= EfiAdptrInfoProtocol
->GetSupportedTypes (
962 EfiAdptrInfoProtocol
,
964 &InfoTypesBufferCount
967 if (EFI_ERROR (Status
)) {
968 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED
), NULL
);
969 if (TempStr
!= NULL
) {
970 RetVal
= CatSPrint (NULL
, TempStr
, Status
);
975 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SUPP_TYPE_HEADER
), NULL
);
976 if (TempStr
== NULL
) {
979 RetVal
= CatSPrint (NULL
, TempStr
);
980 SHELL_FREE_NON_NULL (TempStr
);
982 for (GuidIndex
= 0; GuidIndex
< InfoTypesBufferCount
; GuidIndex
++) {
983 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_NUMBER
), NULL
);
984 if (TempStr
== NULL
) {
987 TempRetVal
= CatSPrint (RetVal
, TempStr
, (GuidIndex
+ 1), &InfoTypesBuffer
[GuidIndex
]);
988 SHELL_FREE_NON_NULL (RetVal
);
990 SHELL_FREE_NON_NULL (TempStr
);
992 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_STRING
), NULL
);
993 if (TempStr
== NULL
) {
997 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
998 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoMediaStateGuid");
999 SHELL_FREE_NON_NULL (RetVal
);
1000 RetVal
= TempRetVal
;
1001 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
1002 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoNetworkBootGuid");
1003 SHELL_FREE_NON_NULL (RetVal
);
1004 RetVal
= TempRetVal
;
1005 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
)) {
1006 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoSanMacAddressGuid");
1007 SHELL_FREE_NON_NULL (RetVal
);
1008 RetVal
= TempRetVal
;
1009 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
)) {
1010 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoUndiIpv6SupportGuid");
1011 SHELL_FREE_NON_NULL (RetVal
);
1012 RetVal
= TempRetVal
;
1015 GuidStr
= GetStringNameFromGuid (&InfoTypesBuffer
[GuidIndex
], NULL
);
1016 if (GuidStr
== NULL
) {
1017 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"UnknownInfoType");
1018 SHELL_FREE_NON_NULL (RetVal
);
1019 RetVal
= TempRetVal
;
1021 SHELL_FREE_NON_NULL (TempStr
);
1022 SHELL_FREE_NON_NULL(GuidStr
);
1024 // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
1028 TempRetVal
= CatSPrint (RetVal
, TempStr
, GuidStr
);
1029 SHELL_FREE_NON_NULL (RetVal
);
1030 RetVal
= TempRetVal
;
1031 SHELL_FREE_NON_NULL(GuidStr
);
1035 SHELL_FREE_NON_NULL (TempStr
);
1037 Status
= EfiAdptrInfoProtocol
->GetInformation (
1038 EfiAdptrInfoProtocol
,
1039 &InfoTypesBuffer
[GuidIndex
],
1041 &InformationBlockSize
1044 if (EFI_ERROR (Status
)) {
1045 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GETINFO_FAILED
), NULL
);
1046 if (TempStr
== NULL
) {
1049 TempRetVal
= CatSPrint (RetVal
, TempStr
, Status
);
1050 SHELL_FREE_NON_NULL (RetVal
);
1051 RetVal
= TempRetVal
;
1053 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
1054 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_MEDIA_STATE
), NULL
);
1055 if (TempStr
== NULL
) {
1058 TempRetVal
= CatSPrint (
1061 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
,
1062 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
1064 SHELL_FREE_NON_NULL (RetVal
);
1065 RetVal
= TempRetVal
;
1066 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
1067 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_NETWORK_BOOT_INFO
), NULL
);
1068 if (TempStr
== NULL
) {
1071 TempRetVal
= CatSPrint (
1074 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4BootCapablity
,
1075 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6BootCapablity
,
1076 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBootCapablity
,
1077 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->OffloadCapability
,
1078 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiMpioCapability
,
1079 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4Boot
,
1080 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6Boot
,
1081 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBoot
1083 SHELL_FREE_NON_NULL (RetVal
);
1084 RetVal
= TempRetVal
;
1085 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
) == TRUE
) {
1086 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO
), NULL
);
1087 if (TempStr
== NULL
) {
1090 TempRetVal
= CatSPrint (
1093 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[0],
1094 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[1],
1095 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[2],
1096 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[3],
1097 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[4],
1098 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[5]
1100 SHELL_FREE_NON_NULL (RetVal
);
1101 RetVal
= TempRetVal
;
1102 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
) == TRUE
) {
1103 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNDI_IPV6_INFO
), NULL
);
1104 if (TempStr
== NULL
) {
1108 TempRetVal
= CatSPrint (
1111 ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT
*)InformationBlock
)->Ipv6Support
1113 SHELL_FREE_NON_NULL (RetVal
);
1114 RetVal
= TempRetVal
;
1116 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE
), NULL
);
1117 if (TempStr
== NULL
) {
1120 TempRetVal
= CatSPrint (RetVal
, TempStr
, &InfoTypesBuffer
[GuidIndex
]);
1121 SHELL_FREE_NON_NULL (RetVal
);
1122 RetVal
= TempRetVal
;
1125 SHELL_FREE_NON_NULL (TempStr
);
1126 SHELL_FREE_NON_NULL (InformationBlock
);
1130 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1134 SHELL_FREE_NON_NULL (RetVal
);
1135 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1136 SHELL_FREE_NON_NULL (InformationBlock
);
1141 Function to dump information about EFI_FIRMWARE_MANAGEMENT_PROTOCOL Protocol.
1143 @param[in] TheHandle The handle that has the protocol installed.
1144 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1146 @retval A pointer to a string containing the information.
1150 FirmwareManagementDumpInformation (
1151 IN CONST EFI_HANDLE TheHandle
,
1152 IN CONST BOOLEAN Verbose
1156 EFI_FIRMWARE_MANAGEMENT_PROTOCOL
*EfiFwMgmtProtocol
;
1157 EFI_FIRMWARE_IMAGE_DESCRIPTOR
*ImageInfo
;
1158 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*ImageInfoV1
;
1159 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*ImageInfoV2
;
1160 UINT64 AttributeSetting
;
1161 UINTN ImageInfoSize
;
1162 UINTN DescriptorSize
;
1163 UINT32 DescriptorVersion
;
1164 UINT32 PackageVersion
;
1165 UINT8 DescriptorCount
;
1169 CHAR16
*PackageVersionName
;
1173 CHAR16
*AttributeSettingStr
;
1175 BOOLEAN AttributeSupported
;
1178 // Initialize local variables
1182 AttributeSetting
= 0;
1184 AttributeSupported
= FALSE
;
1188 PackageVersionName
= NULL
;
1192 AttributeSettingStr
= NULL
;
1195 return (CatSPrint(NULL
, L
"FirmwareManagement"));
1198 Status
= gBS
->OpenProtocol (
1199 (EFI_HANDLE
) (TheHandle
),
1200 &gEfiFirmwareManagementProtocolGuid
,
1201 (VOID
**) &EfiFwMgmtProtocol
,
1204 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1207 if (EFI_ERROR (Status
)) {
1211 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1222 if (Status
== EFI_BUFFER_TOO_SMALL
) {
1223 ImageInfo
= AllocateZeroPool (ImageInfoSize
);
1225 if (ImageInfo
== NULL
) {
1226 Status
= EFI_OUT_OF_RESOURCES
;
1228 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1241 if (EFI_ERROR (Status
)) {
1246 // Decode Image Descriptor data only if its version is supported
1248 if (DescriptorVersion
<= EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION
) {
1250 if (ImageInfo
== NULL
) {
1254 ImageInfoV1
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*)ImageInfo
;
1255 ImageInfoV2
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*)ImageInfo
;
1258 // Set ImageInfoSize in return buffer
1260 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_INFO_SIZE
), NULL
);
1261 if (TempStr
== NULL
) {
1264 RetVal
= CatSPrint (NULL
, TempStr
, ImageInfoSize
);
1265 SHELL_FREE_NON_NULL (TempStr
);
1268 // Set DescriptorVersion in return buffer
1270 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_VERSION
), NULL
);
1271 if (TempStr
== NULL
) {
1274 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorVersion
);
1275 SHELL_FREE_NON_NULL (RetVal
);
1276 RetVal
= TempRetVal
;
1277 SHELL_FREE_NON_NULL (TempStr
);
1280 // Set DescriptorCount in return buffer
1282 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_COUNT
), NULL
);
1283 if (TempStr
== NULL
) {
1286 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorCount
);
1287 SHELL_FREE_NON_NULL (RetVal
);
1288 RetVal
= TempRetVal
;
1289 SHELL_FREE_NON_NULL (TempStr
);
1293 // Set DescriptorSize in return buffer
1295 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_SIZE
), NULL
);
1296 if (TempStr
== NULL
) {
1299 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorSize
);
1300 SHELL_FREE_NON_NULL (RetVal
);
1301 RetVal
= TempRetVal
;
1302 SHELL_FREE_NON_NULL (TempStr
);
1305 // Set PackageVersion in return buffer
1307 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION
), NULL
);
1308 if (TempStr
== NULL
) {
1311 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersion
);
1312 SHELL_FREE_NON_NULL (RetVal
);
1313 RetVal
= TempRetVal
;
1314 SHELL_FREE_NON_NULL (TempStr
);
1317 // Set PackageVersionName in return buffer
1319 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION_NAME
), NULL
);
1320 if (TempStr
== NULL
) {
1323 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersionName
);
1324 SHELL_FREE_NON_NULL (RetVal
);
1325 RetVal
= TempRetVal
;
1326 SHELL_FREE_NON_NULL (TempStr
);
1328 for (Index
= 0; Index
< DescriptorCount
; Index
++) {
1330 // First check if Attribute is supported
1331 // and generate a string for AttributeSetting field
1333 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1334 AttributeSupported
= FALSE
;
1335 AttributeSetting
= 0;
1336 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1337 if (ImageInfoV1
[Index
].AttributesSupported
!= 0x0) {
1338 AttributeSupported
= TRUE
;
1339 AttributeSetting
= ImageInfoV1
[Index
].AttributesSetting
;
1341 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1342 if (ImageInfoV2
[Index
].AttributesSupported
!= 0x0) {
1343 AttributeSupported
= TRUE
;
1344 AttributeSetting
= ImageInfoV2
[Index
].AttributesSetting
;
1347 if (ImageInfo
[Index
].AttributesSupported
!= 0x0) {
1348 AttributeSupported
= TRUE
;
1349 AttributeSetting
= ImageInfo
[Index
].AttributesSetting
;
1353 if (!AttributeSupported
) {
1354 AttributeSettingStr
= CatSPrint (NULL
, L
"None");
1356 AttributeSettingStr
= CatSPrint (NULL
, L
"(");
1358 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
) != 0x0) {
1359 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IMAGE_UPDATABLE");
1360 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1361 AttributeSettingStr
= TempRetVal
;
1363 if ((AttributeSetting
& IMAGE_ATTRIBUTE_RESET_REQUIRED
) != 0x0) {
1364 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_RESET_REQUIRED");
1365 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1366 AttributeSettingStr
= TempRetVal
;
1368 if ((AttributeSetting
& IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
) != 0x0) {
1369 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED");
1370 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1371 AttributeSettingStr
= TempRetVal
;
1373 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IN_USE
) != 0x0) {
1374 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IN_USE");
1375 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1376 AttributeSettingStr
= TempRetVal
;
1378 if ((AttributeSetting
& IMAGE_ATTRIBUTE_UEFI_IMAGE
) != 0x0) {
1379 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_UEFI_IMAGE");
1380 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1381 AttributeSettingStr
= TempRetVal
;
1383 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" )");
1384 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1385 AttributeSettingStr
= TempRetVal
;
1388 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1389 if (ImageInfoV1
[Index
].ImageIndex
!= 0x0) {
1393 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V1
), NULL
);
1394 if (TempStr
== NULL
) {
1397 TempRetVal
= CatSPrint (
1401 ImageInfoV1
[Index
].ImageIndex
,
1402 &ImageInfoV1
[Index
].ImageTypeId
,
1403 ImageInfoV1
[Index
].ImageId
,
1404 ImageInfoV1
[Index
].ImageIdName
,
1405 ImageInfoV1
[Index
].Version
,
1406 ImageInfoV1
[Index
].VersionName
,
1407 ImageInfoV1
[Index
].Size
,
1408 ImageInfoV1
[Index
].AttributesSupported
,
1409 AttributeSettingStr
,
1410 ImageInfoV1
[Index
].Compatibilities
1412 SHELL_FREE_NON_NULL (RetVal
);
1413 RetVal
= TempRetVal
;
1414 SHELL_FREE_NON_NULL (TempStr
);
1415 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1416 if (ImageInfoV2
[Index
].ImageIndex
!= 0x0) {
1420 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V2
), NULL
);
1421 if (TempStr
== NULL
) {
1424 TempRetVal
= CatSPrint (
1428 ImageInfoV2
[Index
].ImageIndex
,
1429 &ImageInfoV2
[Index
].ImageTypeId
,
1430 ImageInfoV2
[Index
].ImageId
,
1431 ImageInfoV2
[Index
].ImageIdName
,
1432 ImageInfoV2
[Index
].Version
,
1433 ImageInfoV2
[Index
].VersionName
,
1434 ImageInfoV2
[Index
].Size
,
1435 ImageInfoV2
[Index
].AttributesSupported
,
1436 AttributeSettingStr
,
1437 ImageInfoV2
[Index
].Compatibilities
,
1438 ImageInfoV2
[Index
].LowestSupportedImageVersion
1440 SHELL_FREE_NON_NULL (RetVal
);
1441 RetVal
= TempRetVal
;
1442 SHELL_FREE_NON_NULL (TempStr
);
1444 if (ImageInfo
[Index
].ImageIndex
!= 0x0) {
1448 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO
), NULL
);
1449 if (TempStr
== NULL
) {
1452 TempRetVal
= CatSPrint (
1456 ImageInfo
[Index
].ImageIndex
,
1457 &ImageInfo
[Index
].ImageTypeId
,
1458 ImageInfo
[Index
].ImageId
,
1459 ImageInfo
[Index
].ImageIdName
,
1460 ImageInfo
[Index
].Version
,
1461 ImageInfo
[Index
].VersionName
,
1462 ImageInfo
[Index
].Size
,
1463 ImageInfo
[Index
].AttributesSupported
,
1464 AttributeSettingStr
,
1465 ImageInfo
[Index
].Compatibilities
,
1466 ImageInfo
[Index
].LowestSupportedImageVersion
,
1467 ImageInfo
[Index
].LastAttemptVersion
,
1468 ImageInfo
[Index
].LastAttemptStatus
,
1469 ImageInfo
[Index
].HardwareInstance
1471 SHELL_FREE_NON_NULL (RetVal
);
1472 RetVal
= TempRetVal
;
1473 SHELL_FREE_NON_NULL (TempStr
);
1478 if (ImageCount
> 0) {
1479 for (Index
=0; Index
<DescriptorCount
; Index
++) {
1480 for (Index1
=Index
+1; Index1
<DescriptorCount
; Index1
++) {
1481 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1482 if (ImageInfoV1
[Index
].ImageId
== ImageInfoV1
[Index1
].ImageId
) {
1485 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1489 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1490 if (ImageInfoV2
[Index
].ImageId
== ImageInfoV2
[Index1
].ImageId
) {
1493 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1498 if (ImageInfo
[Index
].ImageId
== ImageInfo
[Index1
].ImageId
) {
1501 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1512 // Check if ImageId with duplicate value was found
1515 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGEID_NON_UNIQUE
), NULL
);
1516 if (TempStr
== NULL
) {
1519 TempRetVal
= CatSPrint (RetVal
, TempStr
);
1520 SHELL_FREE_NON_NULL (RetVal
);
1521 RetVal
= TempRetVal
;
1522 SHELL_FREE_NON_NULL (TempStr
);
1525 SHELL_FREE_NON_NULL (ImageInfo
);
1526 SHELL_FREE_NON_NULL (PackageVersionName
);
1527 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1532 SHELL_FREE_NON_NULL (RetVal
);
1533 SHELL_FREE_NON_NULL (ImageInfo
);
1534 SHELL_FREE_NON_NULL (PackageVersionName
);
1535 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1541 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
1543 #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
1545 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1548 #define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
1550 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1553 #define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
1555 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1557 STATIC CONST EFI_GUID WinNtThunkProtocolGuid
= LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID
;
1558 STATIC CONST EFI_GUID WinNtIoProtocolGuid
= LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID
;
1559 STATIC CONST EFI_GUID WinNtSerialPortGuid
= LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID
;
1562 // Deprecated protocols we dont want to link from IntelFrameworkModulePkg
1564 #define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \
1566 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
1568 #define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \
1570 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \
1572 STATIC CONST EFI_GUID EfiIsaIoProtocolGuid
= LOCAL_EFI_ISA_IO_PROTOCOL_GUID
;
1573 STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid
= LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID
;
1576 STATIC CONST GUID_INFO_BLOCK mGuidStringListNT
[] = {
1577 {STRING_TOKEN(STR_WINNT_THUNK
), (EFI_GUID
*)&WinNtThunkProtocolGuid
, NULL
},
1578 {STRING_TOKEN(STR_WINNT_DRIVER_IO
), (EFI_GUID
*)&WinNtIoProtocolGuid
, NULL
},
1579 {STRING_TOKEN(STR_WINNT_SERIAL_PORT
), (EFI_GUID
*)&WinNtSerialPortGuid
, NULL
},
1583 STATIC CONST GUID_INFO_BLOCK mGuidStringList
[] = {
1584 {STRING_TOKEN(STR_LOADED_IMAGE
), &gEfiLoadedImageProtocolGuid
, LoadedImageProtocolDumpInformation
},
1585 {STRING_TOKEN(STR_DEVICE_PATH
), &gEfiDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
1586 {STRING_TOKEN(STR_IMAGE_PATH
), &gEfiLoadedImageDevicePathProtocolGuid
, LoadedImageDevicePathProtocolDumpInformation
},
1587 {STRING_TOKEN(STR_DEVICE_PATH_UTIL
), &gEfiDevicePathUtilitiesProtocolGuid
, NULL
},
1588 {STRING_TOKEN(STR_DEVICE_PATH_TXT
), &gEfiDevicePathToTextProtocolGuid
, NULL
},
1589 {STRING_TOKEN(STR_DEVICE_PATH_FTXT
), &gEfiDevicePathFromTextProtocolGuid
, NULL
},
1590 {STRING_TOKEN(STR_DEVICE_PATH_PC
), &gEfiPcAnsiGuid
, NULL
},
1591 {STRING_TOKEN(STR_DEVICE_PATH_VT100
), &gEfiVT100Guid
, NULL
},
1592 {STRING_TOKEN(STR_DEVICE_PATH_VT100P
), &gEfiVT100PlusGuid
, NULL
},
1593 {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8
), &gEfiVTUTF8Guid
, NULL
},
1594 {STRING_TOKEN(STR_DRIVER_BINDING
), &gEfiDriverBindingProtocolGuid
, NULL
},
1595 {STRING_TOKEN(STR_PLATFORM_OVERRIDE
), &gEfiPlatformDriverOverrideProtocolGuid
, NULL
},
1596 {STRING_TOKEN(STR_BUS_OVERRIDE
), &gEfiBusSpecificDriverOverrideProtocolGuid
, NULL
},
1597 {STRING_TOKEN(STR_DRIVER_DIAG
), &gEfiDriverDiagnosticsProtocolGuid
, NULL
},
1598 {STRING_TOKEN(STR_DRIVER_DIAG2
), &gEfiDriverDiagnostics2ProtocolGuid
, NULL
},
1599 {STRING_TOKEN(STR_DRIVER_CN
), &gEfiComponentNameProtocolGuid
, NULL
},
1600 {STRING_TOKEN(STR_DRIVER_CN2
), &gEfiComponentName2ProtocolGuid
, NULL
},
1601 {STRING_TOKEN(STR_PLAT_DRV_CFG
), &gEfiPlatformToDriverConfigurationProtocolGuid
, NULL
},
1602 {STRING_TOKEN(STR_DRIVER_VERSION
), &gEfiDriverSupportedEfiVersionProtocolGuid
, DriverEfiVersionProtocolDumpInformation
},
1603 {STRING_TOKEN(STR_TXT_IN
), &gEfiSimpleTextInProtocolGuid
, NULL
},
1604 {STRING_TOKEN(STR_TXT_IN_EX
), &gEfiSimpleTextInputExProtocolGuid
, NULL
},
1605 {STRING_TOKEN(STR_TXT_OUT
), &gEfiSimpleTextOutProtocolGuid
, TxtOutProtocolDumpInformation
},
1606 {STRING_TOKEN(STR_SIM_POINTER
), &gEfiSimplePointerProtocolGuid
, NULL
},
1607 {STRING_TOKEN(STR_ABS_POINTER
), &gEfiAbsolutePointerProtocolGuid
, NULL
},
1608 {STRING_TOKEN(STR_SERIAL_IO
), &gEfiSerialIoProtocolGuid
, NULL
},
1609 {STRING_TOKEN(STR_GRAPHICS_OUTPUT
), &gEfiGraphicsOutputProtocolGuid
, GraphicsOutputProtocolDumpInformation
},
1610 {STRING_TOKEN(STR_EDID_DISCOVERED
), &gEfiEdidDiscoveredProtocolGuid
, EdidDiscoveredProtocolDumpInformation
},
1611 {STRING_TOKEN(STR_EDID_ACTIVE
), &gEfiEdidActiveProtocolGuid
, EdidActiveProtocolDumpInformation
},
1612 {STRING_TOKEN(STR_EDID_OVERRIDE
), &gEfiEdidOverrideProtocolGuid
, NULL
},
1613 {STRING_TOKEN(STR_CON_IN
), &gEfiConsoleInDeviceGuid
, NULL
},
1614 {STRING_TOKEN(STR_CON_OUT
), &gEfiConsoleOutDeviceGuid
, NULL
},
1615 {STRING_TOKEN(STR_STD_ERR
), &gEfiStandardErrorDeviceGuid
, NULL
},
1616 {STRING_TOKEN(STR_LOAD_FILE
), &gEfiLoadFileProtocolGuid
, NULL
},
1617 {STRING_TOKEN(STR_LOAD_FILE2
), &gEfiLoadFile2ProtocolGuid
, NULL
},
1618 {STRING_TOKEN(STR_SIMPLE_FILE_SYS
), &gEfiSimpleFileSystemProtocolGuid
, NULL
},
1619 {STRING_TOKEN(STR_TAPE_IO
), &gEfiTapeIoProtocolGuid
, NULL
},
1620 {STRING_TOKEN(STR_DISK_IO
), &gEfiDiskIoProtocolGuid
, NULL
},
1621 {STRING_TOKEN(STR_BLK_IO
), &gEfiBlockIoProtocolGuid
, NULL
},
1622 {STRING_TOKEN(STR_UC
), &gEfiUnicodeCollationProtocolGuid
, NULL
},
1623 {STRING_TOKEN(STR_UC2
), &gEfiUnicodeCollation2ProtocolGuid
, NULL
},
1624 {STRING_TOKEN(STR_PCIRB_IO
), &gEfiPciRootBridgeIoProtocolGuid
, PciRootBridgeIoDumpInformation
},
1625 {STRING_TOKEN(STR_PCI_IO
), &gEfiPciIoProtocolGuid
, NULL
},
1626 {STRING_TOKEN(STR_SCSI_PT
), &gEfiScsiPassThruProtocolGuid
, NULL
},
1627 {STRING_TOKEN(STR_SCSI_IO
), &gEfiScsiIoProtocolGuid
, NULL
},
1628 {STRING_TOKEN(STR_SCSI_PT_EXT
), &gEfiExtScsiPassThruProtocolGuid
, NULL
},
1629 {STRING_TOKEN(STR_ISCSI
), &gEfiIScsiInitiatorNameProtocolGuid
, NULL
},
1630 {STRING_TOKEN(STR_USB_IO
), &gEfiUsbIoProtocolGuid
, NULL
},
1631 {STRING_TOKEN(STR_USB_HC
), &gEfiUsbHcProtocolGuid
, NULL
},
1632 {STRING_TOKEN(STR_USB_HC2
), &gEfiUsb2HcProtocolGuid
, NULL
},
1633 {STRING_TOKEN(STR_DEBUG_SUPPORT
), &gEfiDebugSupportProtocolGuid
, NULL
},
1634 {STRING_TOKEN(STR_DEBUG_PORT
), &gEfiDebugPortProtocolGuid
, NULL
},
1635 {STRING_TOKEN(STR_DECOMPRESS
), &gEfiDecompressProtocolGuid
, NULL
},
1636 {STRING_TOKEN(STR_ACPI_TABLE
), &gEfiAcpiTableProtocolGuid
, NULL
},
1637 {STRING_TOKEN(STR_EBC_INTERPRETER
), &gEfiEbcProtocolGuid
, NULL
},
1638 {STRING_TOKEN(STR_SNP
), &gEfiSimpleNetworkProtocolGuid
, NULL
},
1639 {STRING_TOKEN(STR_NII
), &gEfiNetworkInterfaceIdentifierProtocolGuid
, NULL
},
1640 {STRING_TOKEN(STR_NII_31
), &gEfiNetworkInterfaceIdentifierProtocolGuid_31
, NULL
},
1641 {STRING_TOKEN(STR_PXE_BC
), &gEfiPxeBaseCodeProtocolGuid
, NULL
},
1642 {STRING_TOKEN(STR_PXE_CB
), &gEfiPxeBaseCodeCallbackProtocolGuid
, NULL
},
1643 {STRING_TOKEN(STR_BIS
), &gEfiBisProtocolGuid
, NULL
},
1644 {STRING_TOKEN(STR_MNP_SB
), &gEfiManagedNetworkServiceBindingProtocolGuid
, NULL
},
1645 {STRING_TOKEN(STR_MNP
), &gEfiManagedNetworkProtocolGuid
, NULL
},
1646 {STRING_TOKEN(STR_ARP_SB
), &gEfiArpServiceBindingProtocolGuid
, NULL
},
1647 {STRING_TOKEN(STR_ARP
), &gEfiArpProtocolGuid
, NULL
},
1648 {STRING_TOKEN(STR_DHCPV4_SB
), &gEfiDhcp4ServiceBindingProtocolGuid
, NULL
},
1649 {STRING_TOKEN(STR_DHCPV4
), &gEfiDhcp4ProtocolGuid
, NULL
},
1650 {STRING_TOKEN(STR_TCPV4_SB
), &gEfiTcp4ServiceBindingProtocolGuid
, NULL
},
1651 {STRING_TOKEN(STR_TCPV4
), &gEfiTcp4ProtocolGuid
, NULL
},
1652 {STRING_TOKEN(STR_IPV4_SB
), &gEfiIp4ServiceBindingProtocolGuid
, NULL
},
1653 {STRING_TOKEN(STR_IPV4
), &gEfiIp4ProtocolGuid
, NULL
},
1654 {STRING_TOKEN(STR_IPV4_CFG
), &gEfiIp4ConfigProtocolGuid
, NULL
},
1655 {STRING_TOKEN(STR_IPV4_CFG2
), &gEfiIp4Config2ProtocolGuid
, NULL
},
1656 {STRING_TOKEN(STR_UDPV4_SB
), &gEfiUdp4ServiceBindingProtocolGuid
, NULL
},
1657 {STRING_TOKEN(STR_UDPV4
), &gEfiUdp4ProtocolGuid
, NULL
},
1658 {STRING_TOKEN(STR_MTFTPV4_SB
), &gEfiMtftp4ServiceBindingProtocolGuid
, NULL
},
1659 {STRING_TOKEN(STR_MTFTPV4
), &gEfiMtftp4ProtocolGuid
, NULL
},
1660 {STRING_TOKEN(STR_AUTH_INFO
), &gEfiAuthenticationInfoProtocolGuid
, NULL
},
1661 {STRING_TOKEN(STR_HASH_SB
), &gEfiHashServiceBindingProtocolGuid
, NULL
},
1662 {STRING_TOKEN(STR_HASH
), &gEfiHashProtocolGuid
, NULL
},
1663 {STRING_TOKEN(STR_HII_FONT
), &gEfiHiiFontProtocolGuid
, NULL
},
1664 {STRING_TOKEN(STR_HII_STRING
), &gEfiHiiStringProtocolGuid
, NULL
},
1665 {STRING_TOKEN(STR_HII_IMAGE
), &gEfiHiiImageProtocolGuid
, NULL
},
1666 {STRING_TOKEN(STR_HII_DATABASE
), &gEfiHiiDatabaseProtocolGuid
, NULL
},
1667 {STRING_TOKEN(STR_HII_CONFIG_ROUT
), &gEfiHiiConfigRoutingProtocolGuid
, NULL
},
1668 {STRING_TOKEN(STR_HII_CONFIG_ACC
), &gEfiHiiConfigAccessProtocolGuid
, NULL
},
1669 {STRING_TOKEN(STR_HII_FORM_BROWSER2
), &gEfiFormBrowser2ProtocolGuid
, NULL
},
1670 {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE
), &gEfiDriverFamilyOverrideProtocolGuid
, NULL
},
1671 {STRING_TOKEN(STR_PCD
), &gPcdProtocolGuid
, NULL
},
1672 {STRING_TOKEN(STR_TCG
), &gEfiTcgProtocolGuid
, NULL
},
1673 {STRING_TOKEN(STR_HII_PACKAGE_LIST
), &gEfiHiiPackageListProtocolGuid
, NULL
},
1676 // the ones under this are deprecated by the current UEFI Spec, but may be found anyways...
1678 {STRING_TOKEN(STR_SHELL_INTERFACE
), &gEfiShellInterfaceGuid
, NULL
},
1679 {STRING_TOKEN(STR_SHELL_ENV2
), &gEfiShellEnvironment2Guid
, NULL
},
1680 {STRING_TOKEN(STR_SHELL_ENV
), &gEfiShellEnvironment2Guid
, NULL
},
1681 {STRING_TOKEN(STR_DEVICE_IO
), &gEfiDeviceIoProtocolGuid
, NULL
},
1682 {STRING_TOKEN(STR_UGA_DRAW
), &gEfiUgaDrawProtocolGuid
, NULL
},
1683 {STRING_TOKEN(STR_UGA_IO
), &gEfiUgaIoProtocolGuid
, NULL
},
1684 {STRING_TOKEN(STR_ESP
), &gEfiPartTypeSystemPartGuid
, NULL
},
1685 {STRING_TOKEN(STR_GPT_NBR
), &gEfiPartTypeLegacyMbrGuid
, NULL
},
1686 {STRING_TOKEN(STR_DRIVER_CONFIG
), &gEfiDriverConfigurationProtocolGuid
, NULL
},
1687 {STRING_TOKEN(STR_DRIVER_CONFIG2
), &gEfiDriverConfiguration2ProtocolGuid
, NULL
},
1690 // these are using local (non-global) definitions to reduce package dependancy.
1692 {STRING_TOKEN(STR_ISA_IO
), (EFI_GUID
*)&EfiIsaIoProtocolGuid
, NULL
},
1693 {STRING_TOKEN(STR_ISA_ACPI
), (EFI_GUID
*)&EfiIsaAcpiProtocolGuid
, NULL
},
1696 // the ones under this are GUID identified structs, not protocols
1698 {STRING_TOKEN(STR_FILE_INFO
), &gEfiFileInfoGuid
, NULL
},
1699 {STRING_TOKEN(STR_FILE_SYS_INFO
), &gEfiFileSystemInfoGuid
, NULL
},
1702 // the ones under this are misc GUIDS.
1704 {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE
), &gEfiGlobalVariableGuid
, NULL
},
1709 {STRING_TOKEN(STR_IP6_SB
), &gEfiIp6ServiceBindingProtocolGuid
, NULL
},
1710 {STRING_TOKEN(STR_IP6
), &gEfiIp6ProtocolGuid
, NULL
},
1711 {STRING_TOKEN(STR_IP6_CONFIG
), &gEfiIp6ConfigProtocolGuid
, NULL
},
1712 {STRING_TOKEN(STR_MTFTP6_SB
), &gEfiMtftp6ServiceBindingProtocolGuid
, NULL
},
1713 {STRING_TOKEN(STR_MTFTP6
), &gEfiMtftp6ProtocolGuid
, NULL
},
1714 {STRING_TOKEN(STR_DHCP6_SB
), &gEfiDhcp6ServiceBindingProtocolGuid
, NULL
},
1715 {STRING_TOKEN(STR_DHCP6
), &gEfiDhcp6ProtocolGuid
, NULL
},
1716 {STRING_TOKEN(STR_UDP6_SB
), &gEfiUdp6ServiceBindingProtocolGuid
, NULL
},
1717 {STRING_TOKEN(STR_UDP6
), &gEfiUdp6ProtocolGuid
, NULL
},
1718 {STRING_TOKEN(STR_TCP6_SB
), &gEfiTcp6ServiceBindingProtocolGuid
, NULL
},
1719 {STRING_TOKEN(STR_TCP6
), &gEfiTcp6ProtocolGuid
, NULL
},
1720 {STRING_TOKEN(STR_VLAN_CONFIG
), &gEfiVlanConfigProtocolGuid
, NULL
},
1721 {STRING_TOKEN(STR_EAP
), &gEfiEapProtocolGuid
, NULL
},
1722 {STRING_TOKEN(STR_EAP_MGMT
), &gEfiEapManagementProtocolGuid
, NULL
},
1723 {STRING_TOKEN(STR_FTP4_SB
), &gEfiFtp4ServiceBindingProtocolGuid
, NULL
},
1724 {STRING_TOKEN(STR_FTP4
), &gEfiFtp4ProtocolGuid
, NULL
},
1725 {STRING_TOKEN(STR_IP_SEC_CONFIG
), &gEfiIpSecConfigProtocolGuid
, NULL
},
1726 {STRING_TOKEN(STR_DH
), &gEfiDriverHealthProtocolGuid
, NULL
},
1727 {STRING_TOKEN(STR_DEF_IMG_LOAD
), &gEfiDeferredImageLoadProtocolGuid
, NULL
},
1728 {STRING_TOKEN(STR_USER_CRED
), &gEfiUserCredentialProtocolGuid
, NULL
},
1729 {STRING_TOKEN(STR_USER_MNGR
), &gEfiUserManagerProtocolGuid
, NULL
},
1730 {STRING_TOKEN(STR_ATA_PASS_THRU
), &gEfiAtaPassThruProtocolGuid
, NULL
},
1735 {STRING_TOKEN(STR_FW_MGMT
), &gEfiFirmwareManagementProtocolGuid
, FirmwareManagementDumpInformation
},
1736 {STRING_TOKEN(STR_IP_SEC
), &gEfiIpSecProtocolGuid
, NULL
},
1737 {STRING_TOKEN(STR_IP_SEC2
), &gEfiIpSec2ProtocolGuid
, NULL
},
1742 {STRING_TOKEN(STR_KMS
), &gEfiKmsProtocolGuid
, NULL
},
1743 {STRING_TOKEN(STR_BLK_IO2
), &gEfiBlockIo2ProtocolGuid
, NULL
},
1744 {STRING_TOKEN(STR_SSC
), &gEfiStorageSecurityCommandProtocolGuid
, NULL
},
1745 {STRING_TOKEN(STR_UCRED2
), &gEfiUserCredential2ProtocolGuid
, NULL
},
1750 {STRING_TOKEN(STR_DISK_IO2
), &gEfiDiskIo2ProtocolGuid
, NULL
},
1751 {STRING_TOKEN(STR_ADAPTER_INFO
), &gEfiAdapterInformationProtocolGuid
, AdapterInformationDumpInformation
},
1756 {STRING_TOKEN(STR_IDE_CONT_INIT
), &gEfiIdeControllerInitProtocolGuid
, NULL
},
1757 {STRING_TOKEN(STR_DISK_INFO
), &gEfiDiskInfoProtocolGuid
, NULL
},
1762 {STRING_TOKEN(STR_BDS_ARCH
), &gEfiBdsArchProtocolGuid
, NULL
},
1763 {STRING_TOKEN(STR_CPU_ARCH
), &gEfiCpuArchProtocolGuid
, NULL
},
1764 {STRING_TOKEN(STR_MET_ARCH
), &gEfiMetronomeArchProtocolGuid
, NULL
},
1765 {STRING_TOKEN(STR_MON_ARCH
), &gEfiMonotonicCounterArchProtocolGuid
, NULL
},
1766 {STRING_TOKEN(STR_RTC_ARCH
), &gEfiRealTimeClockArchProtocolGuid
, NULL
},
1767 {STRING_TOKEN(STR_RESET_ARCH
), &gEfiResetArchProtocolGuid
, NULL
},
1768 {STRING_TOKEN(STR_RT_ARCH
), &gEfiRuntimeArchProtocolGuid
, NULL
},
1769 {STRING_TOKEN(STR_SEC_ARCH
), &gEfiSecurityArchProtocolGuid
, NULL
},
1770 {STRING_TOKEN(STR_TIMER_ARCH
), &gEfiTimerArchProtocolGuid
, NULL
},
1771 {STRING_TOKEN(STR_VAR_ARCH
), &gEfiVariableWriteArchProtocolGuid
, NULL
},
1772 {STRING_TOKEN(STR_V_ARCH
), &gEfiVariableArchProtocolGuid
, NULL
},
1773 {STRING_TOKEN(STR_SECP
), &gEfiSecurityPolicyProtocolGuid
, NULL
},
1774 {STRING_TOKEN(STR_WDT_ARCH
), &gEfiWatchdogTimerArchProtocolGuid
, NULL
},
1775 {STRING_TOKEN(STR_SCR
), &gEfiStatusCodeRuntimeProtocolGuid
, NULL
},
1776 {STRING_TOKEN(STR_SMB_HC
), &gEfiSmbusHcProtocolGuid
, NULL
},
1777 {STRING_TOKEN(STR_FV_2
), &gEfiFirmwareVolume2ProtocolGuid
, NULL
},
1778 {STRING_TOKEN(STR_FV_BLOCK
), &gEfiFirmwareVolumeBlockProtocolGuid
, NULL
},
1779 {STRING_TOKEN(STR_CAP_ARCH
), &gEfiCapsuleArchProtocolGuid
, NULL
},
1780 {STRING_TOKEN(STR_MP_SERVICE
), &gEfiMpServiceProtocolGuid
, NULL
},
1781 {STRING_TOKEN(STR_HBRAP
), &gEfiPciHostBridgeResourceAllocationProtocolGuid
, NULL
},
1782 {STRING_TOKEN(STR_PCIP
), &gEfiPciPlatformProtocolGuid
, NULL
},
1783 {STRING_TOKEN(STR_PCIO
), &gEfiPciOverrideProtocolGuid
, NULL
},
1784 {STRING_TOKEN(STR_PCIE
), &gEfiPciEnumerationCompleteProtocolGuid
, NULL
},
1785 {STRING_TOKEN(STR_IPCID
), &gEfiIncompatiblePciDeviceSupportProtocolGuid
, NULL
},
1786 {STRING_TOKEN(STR_PCIHPI
), &gEfiPciHotPlugInitProtocolGuid
, NULL
},
1787 {STRING_TOKEN(STR_PCIHPR
), &gEfiPciHotPlugRequestProtocolGuid
, NULL
},
1788 {STRING_TOKEN(STR_SMBIOS
), &gEfiSmbiosProtocolGuid
, NULL
},
1789 {STRING_TOKEN(STR_S3_SAVE
), &gEfiS3SaveStateProtocolGuid
, NULL
},
1790 {STRING_TOKEN(STR_S3_S_SMM
), &gEfiS3SmmSaveStateProtocolGuid
, NULL
},
1791 {STRING_TOKEN(STR_RSC
), &gEfiRscHandlerProtocolGuid
, NULL
},
1792 {STRING_TOKEN(STR_S_RSC
), &gEfiSmmRscHandlerProtocolGuid
, NULL
},
1793 {STRING_TOKEN(STR_ACPI_SDT
), &gEfiAcpiSdtProtocolGuid
, NULL
},
1794 {STRING_TOKEN(STR_SIO
), &gEfiSioProtocolGuid
, NULL
},
1795 {STRING_TOKEN(STR_S_CPU2
), &gEfiSmmCpuIo2ProtocolGuid
, NULL
},
1796 {STRING_TOKEN(STR_S_BASE2
), &gEfiSmmBase2ProtocolGuid
, NULL
},
1797 {STRING_TOKEN(STR_S_ACC_2
), &gEfiSmmAccess2ProtocolGuid
, NULL
},
1798 {STRING_TOKEN(STR_S_CON_2
), &gEfiSmmControl2ProtocolGuid
, NULL
},
1799 {STRING_TOKEN(STR_S_CONFIG
), &gEfiSmmConfigurationProtocolGuid
, NULL
},
1800 {STRING_TOKEN(STR_S_RTL
), &gEfiSmmReadyToLockProtocolGuid
, NULL
},
1801 {STRING_TOKEN(STR_DS_RTL
), &gEfiDxeSmmReadyToLockProtocolGuid
, NULL
},
1802 {STRING_TOKEN(STR_S_COMM
), &gEfiSmmCommunicationProtocolGuid
, NULL
},
1803 {STRING_TOKEN(STR_S_STAT
), &gEfiSmmStatusCodeProtocolGuid
, NULL
},
1804 {STRING_TOKEN(STR_S_CPU
), &gEfiSmmCpuProtocolGuid
, NULL
},
1805 {STRING_TOKEN(STR_S_PCIRBIO
), &gEfiPciRootBridgeIoProtocolGuid
, NULL
},
1806 {STRING_TOKEN(STR_S_SWD
), &gEfiSmmSwDispatch2ProtocolGuid
, NULL
},
1807 {STRING_TOKEN(STR_S_SXD
), &gEfiSmmSxDispatch2ProtocolGuid
, NULL
},
1808 {STRING_TOKEN(STR_S_PTD2
), &gEfiSmmPeriodicTimerDispatch2ProtocolGuid
, NULL
},
1809 {STRING_TOKEN(STR_S_UD2
), &gEfiSmmUsbDispatch2ProtocolGuid
, NULL
},
1810 {STRING_TOKEN(STR_S_GD2
), &gEfiSmmGpiDispatch2ProtocolGuid
, NULL
},
1811 {STRING_TOKEN(STR_S_SBD2
), &gEfiSmmStandbyButtonDispatch2ProtocolGuid
, NULL
},
1812 {STRING_TOKEN(STR_S_PBD2
), &gEfiSmmPowerButtonDispatch2ProtocolGuid
, NULL
},
1813 {STRING_TOKEN(STR_S_ITD2
), &gEfiSmmIoTrapDispatch2ProtocolGuid
, NULL
},
1814 {STRING_TOKEN(STR_PCD
), &gEfiPcdProtocolGuid
, NULL
},
1815 {STRING_TOKEN(STR_FVB2
), &gEfiFirmwareVolumeBlock2ProtocolGuid
, NULL
},
1816 {STRING_TOKEN(STR_CPUIO2
), &gEfiCpuIo2ProtocolGuid
, NULL
},
1817 {STRING_TOKEN(STR_LEGACY_R2
), &gEfiLegacyRegion2ProtocolGuid
, NULL
},
1818 {STRING_TOKEN(STR_SAL_MIP
), &gEfiSalMcaInitPmiProtocolGuid
, NULL
},
1819 {STRING_TOKEN(STR_ES_BS
), &gEfiExtendedSalBootServiceProtocolGuid
, NULL
},
1820 {STRING_TOKEN(STR_ES_BIO
), &gEfiExtendedSalBaseIoServicesProtocolGuid
, NULL
},
1821 {STRING_TOKEN(STR_ES_STALL
), &gEfiExtendedSalStallServicesProtocolGuid
, NULL
},
1822 {STRING_TOKEN(STR_ES_RTC
), &gEfiExtendedSalRtcServicesProtocolGuid
, NULL
},
1823 {STRING_TOKEN(STR_ES_VS
), &gEfiExtendedSalVariableServicesProtocolGuid
, NULL
},
1824 {STRING_TOKEN(STR_ES_MTC
), &gEfiExtendedSalMtcServicesProtocolGuid
, NULL
},
1825 {STRING_TOKEN(STR_ES_RESET
), &gEfiExtendedSalResetServicesProtocolGuid
, NULL
},
1826 {STRING_TOKEN(STR_ES_SC
), &gEfiExtendedSalStatusCodeServicesProtocolGuid
, NULL
},
1827 {STRING_TOKEN(STR_ES_FBS
), &gEfiExtendedSalFvBlockServicesProtocolGuid
, NULL
},
1828 {STRING_TOKEN(STR_ES_MP
), &gEfiExtendedSalMpServicesProtocolGuid
, NULL
},
1829 {STRING_TOKEN(STR_ES_PAL
), &gEfiExtendedSalPalServicesProtocolGuid
, NULL
},
1830 {STRING_TOKEN(STR_ES_BASE
), &gEfiExtendedSalBaseServicesProtocolGuid
, NULL
},
1831 {STRING_TOKEN(STR_ES_MCA
), &gEfiExtendedSalMcaServicesProtocolGuid
, NULL
},
1832 {STRING_TOKEN(STR_ES_PCI
), &gEfiExtendedSalPciServicesProtocolGuid
, NULL
},
1833 {STRING_TOKEN(STR_ES_CACHE
), &gEfiExtendedSalCacheServicesProtocolGuid
, NULL
},
1834 {STRING_TOKEN(STR_ES_MCA_LOG
), &gEfiExtendedSalMcaLogServicesProtocolGuid
, NULL
},
1835 {STRING_TOKEN(STR_S2ARCH
), &gEfiSecurity2ArchProtocolGuid
, NULL
},
1836 {STRING_TOKEN(STR_EODXE
), &gEfiSmmEndOfDxeProtocolGuid
, NULL
},
1837 {STRING_TOKEN(STR_ISAHC
), &gEfiIsaHcProtocolGuid
, NULL
},
1838 {STRING_TOKEN(STR_ISAHC_B
), &gEfiIsaHcServiceBindingProtocolGuid
, NULL
},
1839 {STRING_TOKEN(STR_SIO_C
), &gEfiSioControlProtocolGuid
, NULL
},
1840 {STRING_TOKEN(STR_GET_PCD
), &gEfiGetPcdInfoProtocolGuid
, NULL
},
1841 {STRING_TOKEN(STR_I2C_M
), &gEfiI2cMasterProtocolGuid
, NULL
},
1842 {STRING_TOKEN(STR_I2CIO
), &gEfiI2cIoProtocolGuid
, NULL
},
1843 {STRING_TOKEN(STR_I2CEN
), &gEfiI2cEnumerateProtocolGuid
, NULL
},
1844 {STRING_TOKEN(STR_I2C_H
), &gEfiI2cHostProtocolGuid
, NULL
},
1845 {STRING_TOKEN(STR_I2C_BCM
), &gEfiI2cBusConfigurationManagementProtocolGuid
, NULL
},
1846 {STRING_TOKEN(STR_TREE
), &gEfiTrEEProtocolGuid
, NULL
},
1847 {STRING_TOKEN(STR_TCG2
), &gEfiTcg2ProtocolGuid
, NULL
},
1848 {STRING_TOKEN(STR_TIMESTAMP
), &gEfiTimestampProtocolGuid
, NULL
},
1849 {STRING_TOKEN(STR_RNG
), &gEfiRngProtocolGuid
, NULL
},
1850 {STRING_TOKEN(STR_NVMEPT
), &gEfiNvmExpressPassThruProtocolGuid
, NULL
},
1851 {STRING_TOKEN(STR_H2_SB
), &gEfiHash2ServiceBindingProtocolGuid
, NULL
},
1852 {STRING_TOKEN(STR_HASH2
), &gEfiHash2ProtocolGuid
, NULL
},
1853 {STRING_TOKEN(STR_BIO_C
), &gEfiBlockIoCryptoProtocolGuid
, NULL
},
1854 {STRING_TOKEN(STR_SCR
), &gEfiSmartCardReaderProtocolGuid
, NULL
},
1855 {STRING_TOKEN(STR_SCE
), &gEfiSmartCardEdgeProtocolGuid
, NULL
},
1856 {STRING_TOKEN(STR_USB_FIO
), &gEfiUsbFunctionIoProtocolGuid
, NULL
},
1857 {STRING_TOKEN(STR_BC_HC
), &gEfiBluetoothHcProtocolGuid
, NULL
},
1858 {STRING_TOKEN(STR_BC_IO_SB
), &gEfiBluetoothIoServiceBindingProtocolGuid
, NULL
},
1859 {STRING_TOKEN(STR_BC_IO
), &gEfiBluetoothIoProtocolGuid
, NULL
},
1860 {STRING_TOKEN(STR_BC_C
), &gEfiBluetoothConfigProtocolGuid
, NULL
},
1861 {STRING_TOKEN(STR_REG_EXP
), &gEfiRegularExpressionProtocolGuid
, NULL
},
1862 {STRING_TOKEN(STR_B_MGR_P
), &gEfiBootManagerPolicyProtocolGuid
, NULL
},
1863 {STRING_TOKEN(STR_CKH
), &gEfiConfigKeywordHandlerProtocolGuid
, NULL
},
1864 {STRING_TOKEN(STR_WIFI
), &gEfiWiFiProtocolGuid
, NULL
},
1865 {STRING_TOKEN(STR_EAP_M
), &gEfiEapManagement2ProtocolGuid
, NULL
},
1866 {STRING_TOKEN(STR_EAP_C
), &gEfiEapConfigurationProtocolGuid
, NULL
},
1867 {STRING_TOKEN(STR_PKCS7
), &gEfiPkcs7VerifyProtocolGuid
, NULL
},
1868 {STRING_TOKEN(STR_NET_DNS4_SB
), &gEfiDns4ServiceBindingProtocolGuid
, NULL
},
1869 {STRING_TOKEN(STR_NET_DNS4
), &gEfiDns4ProtocolGuid
, NULL
},
1870 {STRING_TOKEN(STR_NET_DNS6_SB
), &gEfiDns6ServiceBindingProtocolGuid
, NULL
},
1871 {STRING_TOKEN(STR_NET_DNS6
), &gEfiDns6ProtocolGuid
, NULL
},
1872 {STRING_TOKEN(STR_NET_HTTP_SB
), &gEfiHttpServiceBindingProtocolGuid
, NULL
},
1873 {STRING_TOKEN(STR_NET_HTTP
), &gEfiHttpProtocolGuid
, NULL
},
1874 {STRING_TOKEN(STR_NET_HTTP_U
), &gEfiHttpUtilitiesProtocolGuid
, NULL
},
1875 {STRING_TOKEN(STR_REST
), &gEfiRestProtocolGuid
, NULL
},
1878 // UEFI Shell Spec 2.0
1880 {STRING_TOKEN(STR_SHELL_PARAMETERS
), &gEfiShellParametersProtocolGuid
, NULL
},
1881 {STRING_TOKEN(STR_SHELL
), &gEfiShellProtocolGuid
, NULL
},
1884 // UEFI Shell Spec 2.1
1886 {STRING_TOKEN(STR_SHELL_DYNAMIC
), &gEfiShellDynamicCommandProtocolGuid
, NULL
},
1891 {STRING_TOKEN(STR_PCDINFOPROT
), &gGetPcdInfoProtocolGuid
, NULL
},
1900 Function to get the node for a protocol or struct from it's GUID.
1902 if Guid is NULL, then ASSERT.
1904 @param[in] Guid The GUID to look for the name of.
1908 CONST GUID_INFO_BLOCK
*
1909 InternalShellGetNodeFromGuid(
1910 IN CONST EFI_GUID
* Guid
1913 CONST GUID_INFO_BLOCK
*ListWalker
;
1916 ASSERT(Guid
!= NULL
);
1918 for (LoopCount
= 0, ListWalker
= mGuidList
; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++, ListWalker
++) {
1919 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1920 return (ListWalker
);
1924 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
1925 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1926 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1927 return (ListWalker
);
1931 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1932 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1933 return (ListWalker
);
1940 Function to add a new GUID/Name mapping.
1942 @param[in] Guid The Guid
1943 @param[in] NameID The STRING id of the HII string to use
1944 @param[in] DumpFunc The pointer to the dump function
1947 @retval EFI_SUCCESS The operation was sucessful
1948 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1949 @retval EFI_INVALID_PARAMETER Guid NameId was invalid
1952 InsertNewGuidNameMapping(
1953 IN CONST EFI_GUID
*Guid
,
1954 IN CONST EFI_STRING_ID NameID
,
1955 IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
1958 ASSERT(Guid
!= NULL
);
1959 ASSERT(NameID
!= 0);
1961 mGuidList
= ReallocatePool(mGuidListCount
* sizeof(GUID_INFO_BLOCK
), mGuidListCount
+1 * sizeof(GUID_INFO_BLOCK
), mGuidList
);
1962 if (mGuidList
== NULL
) {
1964 return (EFI_OUT_OF_RESOURCES
);
1968 mGuidList
[mGuidListCount
- 1].GuidId
= AllocateCopyPool(sizeof(EFI_GUID
), Guid
);
1969 mGuidList
[mGuidListCount
- 1].StringId
= NameID
;
1970 mGuidList
[mGuidListCount
- 1].DumpInfo
= DumpFunc
;
1972 if (mGuidList
[mGuidListCount
- 1].GuidId
== NULL
) {
1973 return (EFI_OUT_OF_RESOURCES
);
1976 return (EFI_SUCCESS
);
1980 Function to add a new GUID/Name mapping.
1982 This cannot overwrite an existing mapping.
1984 @param[in] Guid The Guid
1985 @param[in] TheName The Guid's name
1986 @param[in] Lang RFC4646 language code list or NULL
1988 @retval EFI_SUCCESS The operation was sucessful
1989 @retval EFI_ACCESS_DENIED There was a duplicate
1990 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1991 @retval EFI_INVALID_PARAMETER Guid or TheName was NULL
1995 AddNewGuidNameMapping(
1996 IN CONST EFI_GUID
*Guid
,
1997 IN CONST CHAR16
*TheName
,
1998 IN CONST CHAR8
*Lang OPTIONAL
2001 EFI_STRING_ID NameID
;
2003 HandleParsingHiiInit();
2005 if (Guid
== NULL
|| TheName
== NULL
){
2006 return (EFI_INVALID_PARAMETER
);
2009 if ((InternalShellGetNodeFromGuid(Guid
)) != NULL
) {
2010 return (EFI_ACCESS_DENIED
);
2013 NameID
= HiiSetString(mHandleParsingHiiHandle
, 0, (CHAR16
*)TheName
, Lang
);
2015 return (EFI_OUT_OF_RESOURCES
);
2018 return (InsertNewGuidNameMapping(Guid
, NameID
, NULL
));
2022 Function to get the name of a protocol or struct from it's GUID.
2024 if Guid is NULL, then ASSERT.
2026 @param[in] Guid The GUID to look for the name of.
2027 @param[in] Lang The language to use.
2029 @return pointer to string of the name. The caller
2030 is responsible to free this memory.
2034 GetStringNameFromGuid(
2035 IN CONST EFI_GUID
*Guid
,
2036 IN CONST CHAR8
*Lang OPTIONAL
2039 CONST GUID_INFO_BLOCK
*Id
;
2041 HandleParsingHiiInit();
2043 Id
= InternalShellGetNodeFromGuid(Guid
);
2047 return HiiGetString (mHandleParsingHiiHandle
, Id
->StringId
, Lang
);
2051 Function to dump protocol information from a handle.
2053 This function will return a allocated string buffer containing the
2054 information. The caller is responsible for freeing the memory.
2056 If Guid is NULL, ASSERT().
2057 If TheHandle is NULL, ASSERT().
2059 @param[in] TheHandle The handle to dump information from.
2060 @param[in] Guid The GUID of the protocol to dump.
2061 @param[in] Verbose TRUE for extra info. FALSE otherwise.
2063 @return The pointer to string.
2064 @retval NULL An error was encountered.
2068 GetProtocolInformationDump(
2069 IN CONST EFI_HANDLE TheHandle
,
2070 IN CONST EFI_GUID
*Guid
,
2071 IN CONST BOOLEAN Verbose
2074 CONST GUID_INFO_BLOCK
*Id
;
2076 ASSERT(TheHandle
!= NULL
);
2077 ASSERT(Guid
!= NULL
);
2079 if (TheHandle
== NULL
|| Guid
== NULL
) {
2083 Id
= InternalShellGetNodeFromGuid(Guid
);
2084 if (Id
!= NULL
&& Id
->DumpInfo
!= NULL
) {
2085 return (Id
->DumpInfo(TheHandle
, Verbose
));
2091 Function to get the Guid for a protocol or struct based on it's string name.
2093 do not modify the returned Guid.
2095 @param[in] Name The pointer to the string name.
2096 @param[in] Lang The pointer to the language code.
2097 @param[out] Guid The pointer to the Guid.
2099 @retval EFI_SUCCESS The operation was sucessful.
2103 GetGuidFromStringName(
2104 IN CONST CHAR16
*Name
,
2105 IN CONST CHAR8
*Lang OPTIONAL
,
2109 CONST GUID_INFO_BLOCK
*ListWalker
;
2113 HandleParsingHiiInit();
2115 ASSERT(Guid
!= NULL
);
2117 return (EFI_INVALID_PARAMETER
);
2121 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
2122 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2123 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2124 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2125 *Guid
= ListWalker
->GuidId
;
2127 SHELL_FREE_NON_NULL(String
);
2128 if (*Guid
!= NULL
) {
2129 return (EFI_SUCCESS
);
2133 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2134 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2135 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2136 *Guid
= ListWalker
->GuidId
;
2138 SHELL_FREE_NON_NULL(String
);
2139 if (*Guid
!= NULL
) {
2140 return (EFI_SUCCESS
);
2144 for (LoopCount
= 0, ListWalker
= mGuidList
; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++, ListWalker
++) {
2145 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2146 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2147 *Guid
= ListWalker
->GuidId
;
2149 SHELL_FREE_NON_NULL(String
);
2150 if (*Guid
!= NULL
) {
2151 return (EFI_SUCCESS
);
2155 return (EFI_NOT_FOUND
);
2159 Get best support language for this driver.
2161 First base on the user input language to search, second base on the current
2162 platform used language to search, third get the first language from the
2163 support language list. The caller need to free the buffer of the best language.
2165 @param[in] SupportedLanguages The support languages for this driver.
2166 @param[in] InputLanguage The user input language.
2167 @param[in] Iso639Language Whether get language for ISO639.
2169 @return The best support language for this driver.
2173 GetBestLanguageForDriver (
2174 IN CONST CHAR8
*SupportedLanguages
,
2175 IN CONST CHAR8
*InputLanguage
,
2176 IN BOOLEAN Iso639Language
2179 CHAR8
*LanguageVariable
;
2180 CHAR8
*BestLanguage
;
2182 GetVariable2 (Iso639Language
? L
"Lang" : L
"PlatformLang", &gEfiGlobalVariableGuid
, (VOID
**)&LanguageVariable
, NULL
);
2184 BestLanguage
= GetBestLanguage(
2187 (InputLanguage
!= NULL
) ? InputLanguage
: "",
2188 (LanguageVariable
!= NULL
) ? LanguageVariable
: "",
2193 if (LanguageVariable
!= NULL
) {
2194 FreePool (LanguageVariable
);
2197 return BestLanguage
;
2201 Function to retrieve the driver name (if possible) from the ComponentName or
2202 ComponentName2 protocol
2204 @param[in] TheHandle The driver handle to get the name of.
2205 @param[in] Language The language to use.
2207 @retval NULL The name could not be found.
2208 @return A pointer to the string name. Do not de-allocate the memory.
2212 GetStringNameFromHandle(
2213 IN CONST EFI_HANDLE TheHandle
,
2214 IN CONST CHAR8
*Language
2217 EFI_COMPONENT_NAME2_PROTOCOL
*CompNameStruct
;
2224 Status
= gBS
->OpenProtocol(
2226 &gEfiComponentName2ProtocolGuid
,
2227 (VOID
**)&CompNameStruct
,
2230 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2231 if (!EFI_ERROR(Status
)) {
2232 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2233 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2234 if (BestLang
!= NULL
) {
2235 FreePool (BestLang
);
2238 if (!EFI_ERROR(Status
)) {
2242 Status
= gBS
->OpenProtocol(
2244 &gEfiComponentNameProtocolGuid
,
2245 (VOID
**)&CompNameStruct
,
2248 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2249 if (!EFI_ERROR(Status
)) {
2250 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2251 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2252 if (BestLang
!= NULL
) {
2253 FreePool (BestLang
);
2255 if (!EFI_ERROR(Status
)) {
2263 Function to initialize the file global mHandleList object for use in
2264 vonverting handles to index and index to handle.
2266 @retval EFI_SUCCESS The operation was successful.
2269 InternalShellInitHandleList(
2274 EFI_HANDLE
*HandleBuffer
;
2276 HANDLE_LIST
*ListWalker
;
2278 if (mHandleList
.NextIndex
!= 0) {
2281 InitializeListHead(&mHandleList
.List
.Link
);
2282 mHandleList
.NextIndex
= 1;
2283 Status
= gBS
->LocateHandleBuffer (
2290 ASSERT_EFI_ERROR(Status
);
2291 if (EFI_ERROR(Status
)) {
2294 for (mHandleList
.NextIndex
= 1 ; mHandleList
.NextIndex
<= HandleCount
; mHandleList
.NextIndex
++){
2295 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2296 if (ListWalker
!= NULL
) {
2297 ListWalker
->TheHandle
= HandleBuffer
[mHandleList
.NextIndex
- 1];
2298 ListWalker
->TheIndex
= mHandleList
.NextIndex
;
2299 InsertTailList (&mHandleList
.List
.Link
, &ListWalker
->Link
);
2302 FreePool(HandleBuffer
);
2303 return (EFI_SUCCESS
);
2307 Function to retrieve the human-friendly index of a given handle. If the handle
2308 does not have a index one will be automatically assigned. The index value is valid
2309 until the termination of the shell application.
2311 @param[in] TheHandle The handle to retrieve an index for.
2313 @retval 0 A memory allocation failed.
2314 @return The index of the handle.
2319 ConvertHandleToHandleIndex(
2320 IN CONST EFI_HANDLE TheHandle
2324 EFI_GUID
**ProtocolBuffer
;
2325 UINTN ProtocolCount
;
2326 HANDLE_LIST
*ListWalker
;
2328 if (TheHandle
== NULL
) {
2332 InternalShellInitHandleList();
2334 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2335 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2336 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2338 if (ListWalker
->TheHandle
== TheHandle
) {
2340 // Verify that TheHandle is still present in the Handle Database
2342 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2343 if (EFI_ERROR (Status
)) {
2345 // TheHandle is not present in the Handle Database, so delete from the handle list
2347 RemoveEntryList (&ListWalker
->Link
);
2350 FreePool (ProtocolBuffer
);
2351 return (ListWalker
->TheIndex
);
2356 // Verify that TheHandle is valid handle
2358 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2359 if (EFI_ERROR (Status
)) {
2361 // TheHandle is not valid, so do not add to handle list
2365 FreePool (ProtocolBuffer
);
2367 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2368 if (ListWalker
== NULL
) {
2371 ListWalker
->TheHandle
= TheHandle
;
2372 ListWalker
->TheIndex
= mHandleList
.NextIndex
++;
2373 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
2374 return (ListWalker
->TheIndex
);
2380 Function to retrieve the EFI_HANDLE from the human-friendly index.
2382 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.
2384 @retval NULL The index was invalid.
2385 @return The EFI_HANDLE that index represents.
2390 ConvertHandleIndexToHandle(
2391 IN CONST UINTN TheIndex
2395 EFI_GUID
**ProtocolBuffer
;
2396 UINTN ProtocolCount
;
2397 HANDLE_LIST
*ListWalker
;
2399 InternalShellInitHandleList();
2401 if (TheIndex
>= mHandleList
.NextIndex
) {
2405 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2406 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2407 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2409 if (ListWalker
->TheIndex
== TheIndex
&& ListWalker
->TheHandle
!= NULL
) {
2411 // Verify that LinkWalker->TheHandle is valid handle
2413 Status
= gBS
->ProtocolsPerHandle(ListWalker
->TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2414 if (!EFI_ERROR (Status
)) {
2415 FreePool (ProtocolBuffer
);
2418 // TheHandle is not valid, so do not add to handle list
2420 ListWalker
->TheHandle
= NULL
;
2422 return (ListWalker
->TheHandle
);
2429 Gets all the related EFI_HANDLEs based on the mask supplied.
2431 This function scans all EFI_HANDLES in the UEFI environment's handle database
2432 and returns the ones with the specified relationship (Mask) to the specified
2435 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2436 If MatchingHandleCount is NULL, then ASSERT.
2438 If MatchingHandleBuffer is not NULL upon a successful return the memory must be
2441 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.
2442 @param[in] ControllerHandle The handle with Device Path protocol on it.
2443 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in
2444 MatchingHandleBuffer.
2445 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount
2446 EFI_HANDLEs with a terminating NULL EFI_HANDLE.
2447 @param[out] HandleType An array of type information.
2449 @retval EFI_SUCCESS The operation was successful, and any related handles
2450 are in MatchingHandleBuffer.
2451 @retval EFI_NOT_FOUND No matching handles were found.
2452 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2456 ParseHandleDatabaseByRelationshipWithType (
2457 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
2458 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
2459 IN UINTN
*HandleCount
,
2460 OUT EFI_HANDLE
**HandleBuffer
,
2461 OUT UINTN
**HandleType
2466 EFI_GUID
**ProtocolGuidArray
;
2468 UINTN ProtocolIndex
;
2469 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfo
;
2470 UINTN OpenInfoCount
;
2471 UINTN OpenInfoIndex
;
2473 INTN DriverBindingHandleIndex
;
2475 ASSERT(HandleCount
!= NULL
);
2476 ASSERT(HandleBuffer
!= NULL
);
2477 ASSERT(HandleType
!= NULL
);
2478 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
2481 *HandleBuffer
= NULL
;
2485 // Retrieve the list of all handles from the handle database
2487 Status
= gBS
->LocateHandleBuffer (
2494 if (EFI_ERROR (Status
)) {
2498 *HandleType
= AllocateZeroPool (*HandleCount
* sizeof (UINTN
));
2499 if (*HandleType
== NULL
) {
2500 SHELL_FREE_NON_NULL (*HandleBuffer
);
2502 return EFI_OUT_OF_RESOURCES
;
2505 DriverBindingHandleIndex
= -1;
2506 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
2507 if (DriverBindingHandle
!= NULL
&& (*HandleBuffer
)[HandleIndex
] == DriverBindingHandle
) {
2508 DriverBindingHandleIndex
= (INTN
)HandleIndex
;
2512 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
2514 // Retrieve the list of all the protocols on each handle
2516 Status
= gBS
->ProtocolsPerHandle (
2517 (*HandleBuffer
)[HandleIndex
],
2521 if (EFI_ERROR (Status
)) {
2525 for (ProtocolIndex
= 0; ProtocolIndex
< ArrayCount
; ProtocolIndex
++) {
2528 // Set the bit describing what this handle has
2530 if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiLoadedImageProtocolGuid
) ) {
2531 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_IMAGE_HANDLE
;
2532 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverBindingProtocolGuid
) ) {
2533 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_BINDING_HANDLE
;
2534 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfiguration2ProtocolGuid
)) {
2535 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
2536 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfigurationProtocolGuid
) ) {
2537 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
2538 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnostics2ProtocolGuid
) ) {
2539 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
2540 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnosticsProtocolGuid
) ) {
2541 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
2542 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentName2ProtocolGuid
) ) {
2543 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
2544 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentNameProtocolGuid
) ) {
2545 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
2546 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDevicePathProtocolGuid
) ) {
2547 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DEVICE_HANDLE
;
2550 // Retrieve the list of agents that have opened each protocol
2552 Status
= gBS
->OpenProtocolInformation (
2553 (*HandleBuffer
)[HandleIndex
],
2554 ProtocolGuidArray
[ProtocolIndex
],
2558 if (EFI_ERROR (Status
)) {
2562 if (ControllerHandle
== NULL
) {
2564 // ControllerHandle == NULL and DriverBindingHandle != NULL.
2565 // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
2567 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2568 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2569 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2570 if (DriverBindingHandleIndex
!= -1) {
2571 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2574 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2575 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2576 if (DriverBindingHandleIndex
!= -1) {
2577 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2579 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2580 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2581 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2587 if (DriverBindingHandle
== NULL
&& ControllerHandle
!= NULL
) {
2588 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
2589 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2590 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2591 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2592 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2593 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2594 (*HandleType
)[ChildIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2598 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2599 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2600 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2601 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2603 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2604 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2610 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2611 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2612 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
2613 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
2619 if (DriverBindingHandle
!= NULL
&& ControllerHandle
!= NULL
) {
2620 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
2621 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2622 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2623 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2624 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
2625 if (DriverBindingHandleIndex
!= -1) {
2626 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2630 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2631 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
2632 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2633 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2634 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2639 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2640 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2641 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2647 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2648 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2649 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
2650 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
2656 FreePool (OpenInfo
);
2658 FreePool (ProtocolGuidArray
);
2664 Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask
2667 This function will scan all EFI_HANDLES in the UEFI environment's handle database
2668 and return all the ones with the specified relationship (Mask) to the specified
2671 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2672 If MatchingHandleCount is NULL, then ASSERT.
2674 If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be
2677 @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol
2679 @param[in] ControllerHandle Handle to a device with Device Path protocol on it.
2680 @param[in] Mask Mask of what relationship(s) is desired.
2681 @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in
2682 MatchingHandleBuffer.
2683 @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount
2684 EFI_HANDLEs and a terminating NULL EFI_HANDLE.
2686 @retval EFI_SUCCESS The operation was sucessful and any related handles
2687 are in MatchingHandleBuffer;
2688 @retval EFI_NOT_FOUND No matching handles were found.
2689 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2693 ParseHandleDatabaseByRelationship (
2694 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
2695 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
2696 IN CONST UINTN Mask
,
2697 IN UINTN
*MatchingHandleCount
,
2698 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2703 EFI_HANDLE
*HandleBuffer
;
2707 ASSERT(MatchingHandleCount
!= NULL
);
2708 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
2710 if ((Mask
& HR_VALID_MASK
) != Mask
) {
2711 return (EFI_INVALID_PARAMETER
);
2714 if ((Mask
& HR_CHILD_HANDLE
) != 0 && DriverBindingHandle
== NULL
) {
2715 return (EFI_INVALID_PARAMETER
);
2718 *MatchingHandleCount
= 0;
2719 if (MatchingHandleBuffer
!= NULL
) {
2720 *MatchingHandleBuffer
= NULL
;
2723 HandleBuffer
= NULL
;
2726 Status
= ParseHandleDatabaseByRelationshipWithType (
2727 DriverBindingHandle
,
2733 if (!EFI_ERROR (Status
)) {
2735 // Count the number of handles that match the attributes in Mask
2737 for (HandleIndex
= 0; HandleIndex
< HandleCount
; HandleIndex
++) {
2738 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
2739 (*MatchingHandleCount
)++;
2743 // If no handles match the attributes in Mask then return EFI_NOT_FOUND
2745 if (*MatchingHandleCount
== 0) {
2746 Status
= EFI_NOT_FOUND
;
2749 if (MatchingHandleBuffer
== NULL
) {
2751 // Someone just wanted the count...
2753 Status
= EFI_SUCCESS
;
2756 // Allocate a handle buffer for the number of handles that matched the attributes in Mask
2758 *MatchingHandleBuffer
= AllocateZeroPool ((*MatchingHandleCount
+1)* sizeof (EFI_HANDLE
));
2759 if (*MatchingHandleBuffer
== NULL
) {
2760 Status
= EFI_OUT_OF_RESOURCES
;
2762 for (HandleIndex
= 0, *MatchingHandleCount
= 0
2763 ; HandleIndex
< HandleCount
2767 // Fill the allocated buffer with the handles that matched the attributes in Mask
2769 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
2770 (*MatchingHandleBuffer
)[(*MatchingHandleCount
)++] = HandleBuffer
[HandleIndex
];
2775 // Make the last one NULL
2777 (*MatchingHandleBuffer
)[*MatchingHandleCount
] = NULL
;
2779 Status
= EFI_SUCCESS
;
2780 } // *MatchingHandleBuffer == NULL (ELSE)
2781 } // MacthingHandleBuffer == NULL (ELSE)
2782 } // *MatchingHandleCount == 0 (ELSE)
2783 } // no error on ParseHandleDatabaseByRelationshipWithType
2785 if (HandleBuffer
!= NULL
) {
2786 FreePool (HandleBuffer
);
2789 if (HandleType
!= NULL
) {
2790 FreePool (HandleType
);
2793 ASSERT ((MatchingHandleBuffer
== NULL
) ||
2794 (*MatchingHandleCount
== 0 && *MatchingHandleBuffer
== NULL
) ||
2795 (*MatchingHandleCount
!= 0 && *MatchingHandleBuffer
!= NULL
));
2800 Gets handles for any child controllers of the passed in controller.
2802 @param[in] ControllerHandle The handle of the "parent controller"
2803 @param[out] MatchingHandleCount Pointer to the number of handles in
2804 MatchingHandleBuffer on return.
2805 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2809 @retval EFI_SUCCESS The operation was sucessful.
2813 ParseHandleDatabaseForChildControllers(
2814 IN CONST EFI_HANDLE ControllerHandle
,
2815 OUT UINTN
*MatchingHandleCount
,
2816 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2821 UINTN DriverBindingHandleCount
;
2822 EFI_HANDLE
*DriverBindingHandleBuffer
;
2823 UINTN DriverBindingHandleIndex
;
2824 UINTN ChildControllerHandleCount
;
2825 EFI_HANDLE
*ChildControllerHandleBuffer
;
2826 UINTN ChildControllerHandleIndex
;
2827 EFI_HANDLE
*HandleBufferForReturn
;
2829 if (MatchingHandleCount
== NULL
) {
2830 return (EFI_INVALID_PARAMETER
);
2832 *MatchingHandleCount
= 0;
2834 Status
= PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
2836 &DriverBindingHandleCount
,
2837 &DriverBindingHandleBuffer
2839 if (EFI_ERROR (Status
)) {
2844 // Get a buffer big enough for all the controllers.
2846 HandleBufferForReturn
= GetHandleListByProtocol(NULL
);
2847 if (HandleBufferForReturn
== NULL
) {
2848 FreePool (DriverBindingHandleBuffer
);
2849 return (EFI_NOT_FOUND
);
2852 for (DriverBindingHandleIndex
= 0; DriverBindingHandleIndex
< DriverBindingHandleCount
; DriverBindingHandleIndex
++) {
2853 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
2854 DriverBindingHandleBuffer
[DriverBindingHandleIndex
],
2856 &ChildControllerHandleCount
,
2857 &ChildControllerHandleBuffer
2859 if (EFI_ERROR (Status
)) {
2863 for (ChildControllerHandleIndex
= 0;
2864 ChildControllerHandleIndex
< ChildControllerHandleCount
;
2865 ChildControllerHandleIndex
++
2867 for (HandleIndex
= 0; HandleIndex
< *MatchingHandleCount
; HandleIndex
++) {
2868 if (HandleBufferForReturn
[HandleIndex
] == ChildControllerHandleBuffer
[ChildControllerHandleIndex
]) {
2872 if (HandleIndex
>= *MatchingHandleCount
) {
2873 HandleBufferForReturn
[(*MatchingHandleCount
)++] = ChildControllerHandleBuffer
[ChildControllerHandleIndex
];
2877 FreePool (ChildControllerHandleBuffer
);
2880 FreePool (DriverBindingHandleBuffer
);
2882 if (MatchingHandleBuffer
== NULL
|| *MatchingHandleCount
== 0) {
2884 // The caller is not interested in the actual handles, or we've found none.
2886 FreePool (HandleBufferForReturn
);
2887 HandleBufferForReturn
= NULL
;
2890 if (MatchingHandleBuffer
!= NULL
) {
2891 *MatchingHandleBuffer
= HandleBufferForReturn
;
2894 ASSERT ((MatchingHandleBuffer
== NULL
) ||
2895 (*MatchingHandleCount
== 0 && *MatchingHandleBuffer
== NULL
) ||
2896 (*MatchingHandleCount
!= 0 && *MatchingHandleBuffer
!= NULL
));
2898 return (EFI_SUCCESS
);
2902 Appends 1 buffer to another buffer. This will re-allocate the destination buffer
2903 if necessary to fit all of the data.
2905 If DestinationBuffer is NULL, then ASSERT().
2907 @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.
2908 @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.
2909 @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.
2910 @param[in] SourceSize The number of bytes of SourceBuffer to append.
2912 @retval NULL A memory allocation failed.
2913 @retval NULL A parameter was invalid.
2914 @return A pointer to (*DestinationBuffer).
2918 IN OUT VOID
**DestinationBuffer
,
2919 IN OUT UINTN
*DestinationSize
,
2920 IN VOID
*SourceBuffer
,
2924 UINTN LocalDestinationSize
;
2925 UINTN LocalDestinationFinalSize
;
2927 ASSERT(DestinationBuffer
!= NULL
);
2929 if (SourceSize
== 0 || SourceBuffer
== NULL
) {
2930 return (*DestinationBuffer
);
2933 if (DestinationSize
== NULL
) {
2934 LocalDestinationSize
= 0;
2936 LocalDestinationSize
= *DestinationSize
;
2939 LocalDestinationFinalSize
= LocalDestinationSize
+ SourceSize
;
2941 if (DestinationSize
!= NULL
) {
2942 *DestinationSize
= LocalDestinationSize
;
2945 if (LocalDestinationSize
== 0) {
2947 *DestinationBuffer
= AllocateZeroPool(LocalDestinationFinalSize
);
2950 *DestinationBuffer
= ReallocatePool(LocalDestinationSize
, LocalDestinationFinalSize
, *DestinationBuffer
);
2953 ASSERT(*DestinationBuffer
!= NULL
);
2956 return (CopyMem(((UINT8
*)(*DestinationBuffer
)) + LocalDestinationSize
, SourceBuffer
, SourceSize
));
2960 Gets handles for any child devices produced by the passed in driver.
2962 @param[in] DriverHandle The handle of the driver.
2963 @param[in] MatchingHandleCount Pointer to the number of handles in
2964 MatchingHandleBuffer on return.
2965 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2967 @retval EFI_SUCCESS The operation was sucessful.
2968 @sa ParseHandleDatabaseByRelationship
2972 ParseHandleDatabaseForChildDevices(
2973 IN CONST EFI_HANDLE DriverHandle
,
2974 IN UINTN
*MatchingHandleCount
,
2975 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2979 EFI_HANDLE
*Buffer2
;
2984 UINTN HandleBufferSize
;
2986 ASSERT(MatchingHandleCount
!= NULL
);
2988 HandleBufferSize
= 0;
2991 *MatchingHandleCount
= 0;
2993 Status
= PARSE_HANDLE_DATABASE_DEVICES (
2998 if (!EFI_ERROR (Status
)) {
2999 for (HandleIndex
= 0; HandleIndex
< Count1
; HandleIndex
++) {
3001 // now find the children
3003 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
3005 Buffer
[HandleIndex
],
3009 if (EFI_ERROR(Status
)) {
3013 // save out required and optional data elements
3015 *MatchingHandleCount
+= Count2
;
3016 if (MatchingHandleBuffer
!= NULL
) {
3017 *MatchingHandleBuffer
= BuffernCatGrow((VOID
**)MatchingHandleBuffer
, &HandleBufferSize
, Buffer2
, Count2
* sizeof(Buffer2
[0]));
3023 if (Buffer2
!= NULL
) {
3029 if (Buffer
!= NULL
) {
3036 Function to get all handles that support a given protocol or all handles.
3038 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL
3039 then the function will return all handles.
3041 @retval NULL A memory allocation failed.
3042 @return A NULL terminated list of handles.
3046 GetHandleListByProtocol (
3047 IN CONST EFI_GUID
*ProtocolGuid OPTIONAL
3050 EFI_HANDLE
*HandleList
;
3058 // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!
3060 if (ProtocolGuid
== NULL
) {
3061 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
3062 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3063 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
3064 if (HandleList
== NULL
) {
3067 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
3068 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
3071 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
3072 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3073 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
3074 if (HandleList
== NULL
) {
3077 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
3078 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
3081 if (EFI_ERROR(Status
)) {
3082 if (HandleList
!= NULL
) {
3083 FreePool(HandleList
);
3087 return (HandleList
);
3091 Function to get all handles that support some protocols.
3093 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
3095 @retval NULL A memory allocation failed.
3096 @retval NULL ProtocolGuids was NULL.
3097 @return A NULL terminated list of EFI_HANDLEs.
3101 GetHandleListByProtocolList (
3102 IN CONST EFI_GUID
**ProtocolGuids
3105 EFI_HANDLE
*HandleList
;
3110 CONST EFI_GUID
**GuidWalker
;
3111 EFI_HANDLE
*HandleWalker1
;
3112 EFI_HANDLE
*HandleWalker2
;
3116 TotalSize
= sizeof(EFI_HANDLE
);
3118 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++,Size
= 0){
3119 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &Size
, NULL
);
3120 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3126 // No handles were found...
3128 if (TotalSize
== sizeof(EFI_HANDLE
)) {
3132 HandleList
= AllocateZeroPool(TotalSize
);
3133 if (HandleList
== NULL
) {
3138 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++){
3139 TempSize
= TotalSize
- Size
;
3140 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &TempSize
, HandleList
+(Size
/sizeof(EFI_HANDLE
)));
3143 // Allow for missing protocols... Only update the 'used' size upon success.
3145 if (!EFI_ERROR(Status
)) {
3149 ASSERT(HandleList
[(TotalSize
/sizeof(EFI_HANDLE
))-1] == NULL
);
3151 for (HandleWalker1
= HandleList
; HandleWalker1
!= NULL
&& *HandleWalker1
!= NULL
; HandleWalker1
++) {
3152 for (HandleWalker2
= HandleWalker1
+ 1; HandleWalker2
!= NULL
&& *HandleWalker2
!= NULL
; HandleWalker2
++) {
3153 if (*HandleWalker1
== *HandleWalker2
) {
3155 // copy memory back 1 handle width.
3157 CopyMem(HandleWalker2
, HandleWalker2
+ 1, TotalSize
- ((HandleWalker2
-HandleList
+1)*sizeof(EFI_HANDLE
)));
3162 return (HandleList
);
3166 Return all supported GUIDs.
3168 @param[out] Guids The buffer to return all supported GUIDs.
3169 @param[in, out] Count On input, the count of GUIDs the buffer can hold,
3170 On output, the count of GUIDs to return.
3172 @retval EFI_INVALID_PARAMETER Count is NULL.
3173 @retval EFI_BUFFER_TOO_SMALL Buffer is not enough to hold all GUIDs.
3174 @retval EFI_SUCCESS GUIDs are returned successfully.
3178 GetAllMappingGuids (
3179 OUT EFI_GUID
*Guids
,
3187 if (Count
== NULL
) {
3188 return EFI_INVALID_PARAMETER
;
3192 if (PcdGetBool (PcdShellIncludeNtGuids
)) {
3193 NtGuidCount
= ARRAY_SIZE (mGuidStringListNT
) - 1;
3195 GuidCount
= ARRAY_SIZE (mGuidStringList
) - 1;
3197 if (*Count
< NtGuidCount
+ GuidCount
+ mGuidListCount
) {
3198 *Count
= NtGuidCount
+ GuidCount
+ mGuidListCount
;
3199 return EFI_BUFFER_TOO_SMALL
;
3202 for (Index
= 0; Index
< NtGuidCount
; Index
++) {
3203 CopyGuid (&Guids
[Index
], mGuidStringListNT
[Index
].GuidId
);
3206 for (Index
= 0; Index
< GuidCount
; Index
++) {
3207 CopyGuid (&Guids
[NtGuidCount
+ Index
], mGuidStringList
[Index
].GuidId
);
3210 for (Index
= 0; Index
< mGuidListCount
; Index
++) {
3211 CopyGuid (&Guids
[NtGuidCount
+ GuidCount
+ Index
], mGuidList
[Index
].GuidId
);