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 Status
= gBS
->OpenProtocol (
242 &gEfiLoadedImageProtocolGuid
,
243 (VOID
**)&LoadedImage
,
246 EFI_OPEN_PROTOCOL_GET_PROTOCOL
249 if (EFI_ERROR (Status
)) {
253 FileName
= FindLoadedImageFileName(LoadedImage
);
254 FilePath
= ConvertDevicePathToText(LoadedImage
->FilePath
, TRUE
, TRUE
);
256 if (FileName
== NULL
) {
259 SHELL_FREE_NON_NULL(FilePath
);
261 RetVal
= CatSPrint(NULL
, FileName
);
262 SHELL_FREE_NON_NULL(FileName
);
266 HandleParsingHiiInit();
268 if (FileName
!= NULL
) {
269 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_NAME
), NULL
);
272 RetVal
= CatSPrint(NULL
, Temp
, FileName
);
275 SHELL_FREE_NON_NULL(Temp
);
276 SHELL_FREE_NON_NULL(FileName
);
279 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_MAIN
), NULL
);
283 PdbFileName
= PeCoffLoaderGetPdbPointer (LoadedImage
->ImageBase
);
284 DataType
= ConvertMemoryType(LoadedImage
->ImageDataType
);
285 CodeType
= ConvertMemoryType(LoadedImage
->ImageCodeType
);
290 LoadedImage
->Revision
,
291 LoadedImage
->ParentHandle
,
292 LoadedImage
->SystemTable
,
293 LoadedImage
->DeviceHandle
,
296 LoadedImage
->LoadOptionsSize
,
297 LoadedImage
->LoadOptions
,
298 LoadedImage
->ImageBase
,
299 LoadedImage
->ImageSize
,
306 SHELL_FREE_NON_NULL(Temp
);
307 SHELL_FREE_NON_NULL(FilePath
);
308 SHELL_FREE_NON_NULL(CodeType
);
309 SHELL_FREE_NON_NULL(DataType
);
315 Function to dump information about GOP.
317 This will allocate the return buffer from boot services pool.
319 @param[in] TheHandle The handle that has LoadedImage installed.
320 @param[in] Verbose TRUE for additional information, FALSE otherwise.
322 @retval A poitner to a string containing the information.
326 GraphicsOutputProtocolDumpInformation(
327 IN CONST EFI_HANDLE TheHandle
,
328 IN CONST BOOLEAN Verbose
331 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
339 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*GopInfo
;
342 return (CatSPrint(NULL
, L
"GraphicsOutput"));
345 HandleParsingHiiInit();
347 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_GOP_DUMP_MAIN
), NULL
);
352 Status
= gBS
->OpenProtocol (
354 &gEfiGraphicsOutputProtocolGuid
,
355 (VOID
**)&GraphicsOutput
,
358 EFI_OPEN_PROTOCOL_GET_PROTOCOL
361 if (EFI_ERROR (Status
)) {
362 SHELL_FREE_NON_NULL (Temp
);
366 Fmt
= ConvertPixelFormat(GraphicsOutput
->Mode
->Info
->PixelFormat
);
371 GraphicsOutput
->Mode
->MaxMode
,
372 GraphicsOutput
->Mode
->Mode
,
373 GraphicsOutput
->Mode
->FrameBufferBase
,
374 (UINT64
)GraphicsOutput
->Mode
->FrameBufferSize
,
375 (UINT64
)GraphicsOutput
->Mode
->SizeOfInfo
,
376 GraphicsOutput
->Mode
->Info
->Version
,
377 GraphicsOutput
->Mode
->Info
->HorizontalResolution
,
378 GraphicsOutput
->Mode
->Info
->VerticalResolution
,
380 GraphicsOutput
->Mode
->Info
->PixelsPerScanLine
,
381 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.RedMask
,
382 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.GreenMask
,
383 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.BlueMask
386 SHELL_FREE_NON_NULL (Temp
);
388 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_GOP_RES_LIST_MAIN
), NULL
);
390 SHELL_FREE_NON_NULL (RetVal
);
394 TempRetVal
= CatSPrint (RetVal
, Temp
);
395 SHELL_FREE_NON_NULL (RetVal
);
396 if (TempRetVal
== NULL
) {
400 SHELL_FREE_NON_NULL (Temp
);
402 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_GOP_RES_LIST_ENTRY
), NULL
);
404 SHELL_FREE_NON_NULL (RetVal
);
409 for (Mode
= 0; Mode
< GraphicsOutput
->Mode
->MaxMode
; Mode
++) {
410 Status
= GraphicsOutput
->QueryMode (
416 if (EFI_ERROR (Status
)) {
420 TempRetVal
= CatSPrint (
424 GopInfo
->HorizontalResolution
,
425 GopInfo
->VerticalResolution
428 SHELL_FREE_NON_NULL (GopInfo
);
429 SHELL_FREE_NON_NULL (RetVal
);
435 SHELL_FREE_NON_NULL(Temp
);
436 SHELL_FREE_NON_NULL(Fmt
);
442 Function to dump information about EDID Discovered Protocol.
444 This will allocate the return buffer from boot services pool.
446 @param[in] TheHandle The handle that has LoadedImage installed.
447 @param[in] Verbose TRUE for additional information, FALSE otherwise.
449 @retval A pointer to a string containing the information.
453 EdidDiscoveredProtocolDumpInformation (
454 IN CONST EFI_HANDLE TheHandle
,
455 IN CONST BOOLEAN Verbose
458 EFI_EDID_DISCOVERED_PROTOCOL
*EdidDiscovered
;
465 return (CatSPrint (NULL
, L
"EDIDDiscovered"));
468 Status
= gBS
->OpenProtocol (
470 &gEfiEdidDiscoveredProtocolGuid
,
471 (VOID
**)&EdidDiscovered
,
474 EFI_OPEN_PROTOCOL_GET_PROTOCOL
477 if (EFI_ERROR (Status
)) {
481 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_DISCOVERED_MAIN
), NULL
);
486 RetVal
= CatSPrint (NULL
, Temp
, EdidDiscovered
->SizeOfEdid
);
487 SHELL_FREE_NON_NULL (Temp
);
489 if (EdidDiscovered
->SizeOfEdid
!= 0) {
490 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_DISCOVERED_DATA
), NULL
);
492 SHELL_FREE_NON_NULL (RetVal
);
495 TempRetVal
= CatSPrint (RetVal
, Temp
);
496 SHELL_FREE_NON_NULL (RetVal
);
499 TempRetVal
= CatSDumpHex (RetVal
, 7, 0, EdidDiscovered
->SizeOfEdid
, EdidDiscovered
->Edid
);
506 Function to dump information about EDID Active Protocol.
508 This will allocate the return buffer from boot services pool.
510 @param[in] TheHandle The handle that has LoadedImage installed.
511 @param[in] Verbose TRUE for additional information, FALSE otherwise.
513 @retval A pointer to a string containing the information.
517 EdidActiveProtocolDumpInformation (
518 IN CONST EFI_HANDLE TheHandle
,
519 IN CONST BOOLEAN Verbose
522 EFI_EDID_ACTIVE_PROTOCOL
*EdidActive
;
529 return (CatSPrint (NULL
, L
"EDIDActive"));
532 Status
= gBS
->OpenProtocol (
534 &gEfiEdidActiveProtocolGuid
,
538 EFI_OPEN_PROTOCOL_GET_PROTOCOL
541 if (EFI_ERROR (Status
)) {
545 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_ACTIVE_MAIN
), NULL
);
550 RetVal
= CatSPrint (NULL
, Temp
, EdidActive
->SizeOfEdid
);
551 SHELL_FREE_NON_NULL (Temp
);
553 if (EdidActive
->SizeOfEdid
!= 0) {
554 Temp
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN (STR_EDID_ACTIVE_DATA
), NULL
);
556 SHELL_FREE_NON_NULL (RetVal
);
559 TempRetVal
= CatSPrint (RetVal
, Temp
);
560 SHELL_FREE_NON_NULL (RetVal
);
563 TempRetVal
= CatSDumpHex (RetVal
, 7, 0, EdidActive
->SizeOfEdid
, EdidActive
->Edid
);
570 Function to dump information about PciRootBridgeIo.
572 This will allocate the return buffer from boot services pool.
574 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
575 @param[in] Verbose TRUE for additional information, FALSE otherwise.
577 @retval A poitner to a string containing the information.
581 PciRootBridgeIoDumpInformation(
582 IN CONST EFI_HANDLE TheHandle
,
583 IN CONST BOOLEAN Verbose
586 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
587 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Configuration
;
598 return (CatSPrint(NULL
, L
"PciRootBridgeIo"));
601 HandleParsingHiiInit();
603 Status
= gBS
->HandleProtocol(
605 &gEfiPciRootBridgeIoProtocolGuid
,
606 (VOID
**)&PciRootBridgeIo
);
608 if (EFI_ERROR(Status
)) {
612 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_PH
), NULL
);
616 Temp2
= CatSPrint(L
"\r\n", Temp
, PciRootBridgeIo
->ParentHandle
);
621 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SEG
), NULL
);
623 SHELL_FREE_NON_NULL(RetVal
);
626 Temp2
= CatSPrint(RetVal
, Temp
, PciRootBridgeIo
->SegmentNumber
);
634 Status
= PciRootBridgeIo
->GetAttributes (PciRootBridgeIo
, &Supports
, &Attributes
);
635 if (!EFI_ERROR(Status
)) {
636 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_ATT
), NULL
);
638 SHELL_FREE_NON_NULL(RetVal
);
641 Temp2
= CatSPrint(RetVal
, Temp
, Attributes
);
647 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS
), NULL
);
649 SHELL_FREE_NON_NULL(RetVal
);
652 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
659 Configuration
= NULL
;
660 Status
= PciRootBridgeIo
->Configuration (PciRootBridgeIo
, (VOID
**) &Configuration
);
661 if (!EFI_ERROR(Status
) && Configuration
!= NULL
) {
662 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_TITLE
), NULL
);
664 SHELL_FREE_NON_NULL(RetVal
);
667 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
672 while (Configuration
->Desc
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
674 switch (Configuration
->ResType
) {
675 case ACPI_ADDRESS_SPACE_TYPE_MEM
:
676 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_MEM
), NULL
);
678 case ACPI_ADDRESS_SPACE_TYPE_IO
:
679 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_IO
), NULL
);
681 case ACPI_ADDRESS_SPACE_TYPE_BUS
:
682 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_BUS
), NULL
);
686 Temp2
= CatSPrint(RetVal
, L
"%s", Temp
);
693 Temp2
= CatSPrint(RetVal
,
694 L
"%H%02x %016lx %016lx %02x%N\r\n",
695 Configuration
->SpecificFlag
,
696 Configuration
->AddrRangeMin
,
697 Configuration
->AddrRangeMax
,
698 Configuration
->AddrSpaceGranularity
710 Function to dump information about SimpleTextOut.
712 This will allocate the return buffer from boot services pool.
714 @param[in] TheHandle The handle that has SimpleTextOut installed.
715 @param[in] Verbose TRUE for additional information, FALSE otherwise.
717 @retval A poitner to a string containing the information.
721 TxtOutProtocolDumpInformation(
722 IN CONST EFI_HANDLE TheHandle
,
723 IN CONST BOOLEAN Verbose
726 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Dev
;
740 HandleParsingHiiInit();
745 Status
= gBS
->HandleProtocol(
747 &gEfiSimpleTextOutProtocolGuid
,
750 ASSERT_EFI_ERROR(Status
);
751 ASSERT (Dev
!= NULL
&& Dev
->Mode
!= NULL
);
753 Size
= (Dev
->Mode
->MaxMode
+ 1) * 80;
754 RetVal
= AllocateZeroPool(Size
);
756 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER
), NULL
);
758 UnicodeSPrint(RetVal
, Size
, Temp
, Dev
, Dev
->Mode
->Attribute
);
765 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE
), NULL
);
766 for (Index
= 0; Index
< Dev
->Mode
->MaxMode
; Index
++) {
767 Status
= Dev
->QueryMode (Dev
, Index
, &Col
, &Row
);
768 NewSize
= Size
- StrSize(RetVal
);
770 RetVal
+ StrLen(RetVal
),
772 Temp
== NULL
?L
"":Temp
,
773 Index
== Dev
->Mode
->Mode
? L
'*' : L
' ',
775 !EFI_ERROR(Status
)?(INTN
)Col
:-1,
776 !EFI_ERROR(Status
)?(INTN
)Row
:-1
783 STATIC CONST UINTN VersionStringSize
= 60;
786 Function to dump information about EfiDriverSupportedEfiVersion protocol.
788 This will allocate the return buffer from boot services pool.
790 @param[in] TheHandle The handle that has the protocol installed.
791 @param[in] Verbose TRUE for additional information, FALSE otherwise.
793 @retval A poitner to a string containing the information.
797 DriverEfiVersionProtocolDumpInformation(
798 IN CONST EFI_HANDLE TheHandle
,
799 IN CONST BOOLEAN Verbose
802 EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL
*DriverEfiVersion
;
806 Status
= gBS
->HandleProtocol(
808 &gEfiDriverSupportedEfiVersionProtocolGuid
,
809 (VOID
**)&DriverEfiVersion
);
811 ASSERT_EFI_ERROR(Status
);
813 RetVal
= AllocateZeroPool(VersionStringSize
);
814 if (RetVal
!= NULL
) {
815 UnicodeSPrint (RetVal
, VersionStringSize
, L
"0x%08x", DriverEfiVersion
->FirmwareVersion
);
820 Function to convert device path to string.
822 This will allocate the return buffer from boot services pool.
824 @param[in] DevPath Pointer to device path instance.
825 @param[in] Verbose TRUE for additional information, FALSE otherwise.
826 @param[in] Length Maximum allowed text length of the device path.
828 @retval A pointer to a string containing the information.
831 ConvertDevicePathToShortText(
832 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevPath
,
833 IN CONST BOOLEAN Verbose
,
834 IN CONST UINTN Length
842 // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
844 Temp
= ConvertDevicePathToText(DevPath
, TRUE
, TRUE
);
845 if (!Verbose
&& Temp
!= NULL
&& StrLen(Temp
) > Length
) {
848 Temp2
= StrnCatGrow(&Temp2
, &Size
, L
"..", 0);
849 Temp2
= StrnCatGrow(&Temp2
, &Size
, Temp
+(StrLen(Temp
) - (Length
- 2)), 0);
857 Function to dump protocol information.
859 This will allocate the return buffer from boot services pool.
861 @param[in] TheHandle The handle that has the protocol installed.
862 @param[in] Verbose TRUE for additional information, FALSE otherwise.
863 @param[in] Protocol The protocol is needed to dump.
865 @retval A pointer to a string containing the information.
869 DevicePathProtocolDumpInformationEx (
870 IN CONST EFI_HANDLE TheHandle
,
871 IN CONST BOOLEAN Verbose
,
872 IN EFI_GUID
*Protocol
875 EFI_DEVICE_PATH_PROTOCOL
*DevPath
;
877 CHAR16
*DevPathStrTemp
;
881 DevPathStrTemp
= NULL
;
882 Status
= gBS
->OpenProtocol(TheHandle
, Protocol
, (VOID
**)&DevPath
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
883 if (!EFI_ERROR(Status
)) {
884 DevPathStr
= ConvertDevicePathToShortText (DevPath
, Verbose
, 30);
886 Size
= StrSize(DevPathStr
) + sizeof(CHAR16
) * 2;
887 DevPathStrTemp
= AllocateZeroPool (Size
);
888 if (DevPathStrTemp
!= NULL
) {
889 StrnCatS (DevPathStrTemp
, Size
/sizeof(CHAR16
), L
" ", 2);
890 StrnCatS (DevPathStrTemp
, Size
/sizeof(CHAR16
), DevPathStr
, StrLen (DevPathStr
));
892 FreePool (DevPathStr
);
893 DevPathStr
= DevPathStrTemp
;
895 gBS
->CloseProtocol(TheHandle
, Protocol
, gImageHandle
, NULL
);
901 Function to dump information about DevicePath protocol.
903 This will allocate the return buffer from boot services pool.
905 @param[in] TheHandle The handle that has the protocol installed.
906 @param[in] Verbose TRUE for additional information, FALSE otherwise.
908 @retval A pointer to a string containing the information.
912 DevicePathProtocolDumpInformation(
913 IN CONST EFI_HANDLE TheHandle
,
914 IN CONST BOOLEAN Verbose
917 return DevicePathProtocolDumpInformationEx (TheHandle
, Verbose
, &gEfiDevicePathProtocolGuid
);
921 Function to dump information about LoadedImageDevicePath protocol.
923 This will allocate the return buffer from boot services pool.
925 @param[in] TheHandle The handle that has the protocol installed.
926 @param[in] Verbose TRUE for additional information, FALSE otherwise.
928 @retval A pointer to a string containing the information.
932 LoadedImageDevicePathProtocolDumpInformation(
933 IN CONST EFI_HANDLE TheHandle
,
934 IN CONST BOOLEAN Verbose
937 return DevicePathProtocolDumpInformationEx (TheHandle
, Verbose
, &gEfiLoadedImageDevicePathProtocolGuid
);
941 Function to dump information about BusSpecificDriverOverride protocol.
943 This will allocate the return buffer from boot services pool.
945 @param[in] TheHandle The handle that has the protocol installed.
946 @param[in] Verbose TRUE for additional information, FALSE otherwise.
948 @retval A pointer to a string containing the information.
952 BusSpecificDriverOverrideProtocolDumpInformation (
953 IN CONST EFI_HANDLE TheHandle
,
954 IN CONST BOOLEAN Verbose
961 EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL
*BusSpecificDriverOverride
;
962 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
963 EFI_HANDLE ImageHandle
;
975 Status
= gBS
->OpenProtocol (
977 &gEfiBusSpecificDriverOverrideProtocolGuid
,
978 (VOID
**)&BusSpecificDriverOverride
,
981 EFI_OPEN_PROTOCOL_GET_PROTOCOL
983 if (EFI_ERROR (Status
)) {
986 HandleParsingHiiInit ();
987 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_BSDO_DUMP_MAIN
), NULL
);
988 if (GetString
== NULL
) {
992 Status
= BusSpecificDriverOverride
->GetDriver (
993 BusSpecificDriverOverride
,
996 if (!EFI_ERROR (Status
)) {
997 Status
= gBS
->HandleProtocol (
999 &gEfiLoadedImageProtocolGuid
,
1000 (VOID
**) &LoadedImage
1002 if(!EFI_ERROR (Status
)) {
1003 TempRetVal
= CatSPrint (
1006 ConvertHandleToHandleIndex (ImageHandle
),
1007 ConvertDevicePathToText (LoadedImage
->FilePath
, TRUE
, TRUE
)
1009 StrnCatGrow (&RetVal
, &Size
, TempRetVal
, 0);
1010 SHELL_FREE_NON_NULL (TempRetVal
);
1013 } while (!EFI_ERROR (Status
));
1015 SHELL_FREE_NON_NULL (GetString
);
1020 Function to dump information about BlockIo protocol.
1022 This will allocate the return buffer from boot services pool.
1024 @param[in] TheHandle The handle that has the protocol installed.
1025 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1027 @retval A pointer to a string containing the information.
1031 BlockIoProtocolDumpInformation (
1032 IN CONST EFI_HANDLE TheHandle
,
1033 IN CONST BOOLEAN Verbose
1037 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
1038 EFI_BLOCK_IO_MEDIA
*BlockMedia
;
1048 Status
= gBS
->OpenProtocol (
1050 &gEfiBlockIoProtocolGuid
,
1054 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1056 if (EFI_ERROR (Status
)) {
1059 BlockMedia
= BlockIo
->Media
;
1062 // The function (ReadBlocks) must return EFI_NO_MEDIA or
1063 // EFI_MEDIA_CHANGED even if LBA, BufferSize, or Buffer are invalid so the caller can probe
1064 // for changes in media state.
1066 BlockIo
->ReadBlocks (
1068 BlockIo
->Media
->MediaId
,
1074 HandleParsingHiiInit ();
1075 GetString
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_BLOCKIO_INFO
), NULL
);
1076 if (GetString
== NULL
) {
1079 RetVal
= CatSPrint (
1082 BlockMedia
->RemovableMedia
? L
"Removable " : L
"Fixed ",
1083 BlockMedia
->MediaPresent
? L
"" : L
"not-present ",
1084 BlockMedia
->MediaId
,
1085 BlockMedia
->BlockSize
,
1086 BlockMedia
->LastBlock
,
1087 MultU64x32 (BlockMedia
->LastBlock
+ 1, BlockMedia
->BlockSize
),
1088 BlockMedia
->LogicalPartition
? L
"partition" : L
"raw",
1089 BlockMedia
->ReadOnly
? L
"ro" : L
"rw",
1090 BlockMedia
->WriteCaching
? L
"cached" : L
"!cached"
1093 SHELL_FREE_NON_NULL (GetString
);
1098 Function to dump information about EfiAdapterInformation Protocol.
1100 @param[in] TheHandle The handle that has the protocol installed.
1101 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1103 @retval A pointer to a string containing the information.
1107 AdapterInformationDumpInformation (
1108 IN CONST EFI_HANDLE TheHandle
,
1109 IN CONST BOOLEAN Verbose
1113 EFI_ADAPTER_INFORMATION_PROTOCOL
*EfiAdptrInfoProtocol
;
1114 UINTN InfoTypesBufferCount
;
1116 EFI_GUID
*InfoTypesBuffer
;
1121 VOID
*InformationBlock
;
1122 UINTN InformationBlockSize
;
1125 return (CatSPrint(NULL
, L
"AdapterInfo"));
1128 InfoTypesBuffer
= NULL
;
1129 InformationBlock
= NULL
;
1132 Status
= gBS
->OpenProtocol (
1133 (EFI_HANDLE
) (TheHandle
),
1134 &gEfiAdapterInformationProtocolGuid
,
1135 (VOID
**) &EfiAdptrInfoProtocol
,
1138 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1141 if (EFI_ERROR (Status
)) {
1146 // Get a list of supported information types for this instance of the protocol.
1148 Status
= EfiAdptrInfoProtocol
->GetSupportedTypes (
1149 EfiAdptrInfoProtocol
,
1151 &InfoTypesBufferCount
1154 if (EFI_ERROR (Status
)) {
1155 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED
), NULL
);
1156 if (TempStr
!= NULL
) {
1157 RetVal
= CatSPrint (NULL
, TempStr
, Status
);
1162 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SUPP_TYPE_HEADER
), NULL
);
1163 if (TempStr
== NULL
) {
1166 RetVal
= CatSPrint (NULL
, TempStr
);
1167 SHELL_FREE_NON_NULL (TempStr
);
1169 for (GuidIndex
= 0; GuidIndex
< InfoTypesBufferCount
; GuidIndex
++) {
1170 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_NUMBER
), NULL
);
1171 if (TempStr
== NULL
) {
1174 TempRetVal
= CatSPrint (RetVal
, TempStr
, (GuidIndex
+ 1), &InfoTypesBuffer
[GuidIndex
]);
1175 SHELL_FREE_NON_NULL (RetVal
);
1176 RetVal
= TempRetVal
;
1177 SHELL_FREE_NON_NULL (TempStr
);
1179 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_STRING
), NULL
);
1180 if (TempStr
== NULL
) {
1184 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
1185 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoMediaStateGuid");
1186 SHELL_FREE_NON_NULL (RetVal
);
1187 RetVal
= TempRetVal
;
1188 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
1189 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoNetworkBootGuid");
1190 SHELL_FREE_NON_NULL (RetVal
);
1191 RetVal
= TempRetVal
;
1192 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
)) {
1193 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoSanMacAddressGuid");
1194 SHELL_FREE_NON_NULL (RetVal
);
1195 RetVal
= TempRetVal
;
1196 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
)) {
1197 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoUndiIpv6SupportGuid");
1198 SHELL_FREE_NON_NULL (RetVal
);
1199 RetVal
= TempRetVal
;
1202 GuidStr
= GetStringNameFromGuid (&InfoTypesBuffer
[GuidIndex
], NULL
);
1203 if (GuidStr
== NULL
) {
1204 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"UnknownInfoType");
1205 SHELL_FREE_NON_NULL (RetVal
);
1206 RetVal
= TempRetVal
;
1208 SHELL_FREE_NON_NULL (TempStr
);
1209 SHELL_FREE_NON_NULL(GuidStr
);
1211 // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
1215 TempRetVal
= CatSPrint (RetVal
, TempStr
, GuidStr
);
1216 SHELL_FREE_NON_NULL (RetVal
);
1217 RetVal
= TempRetVal
;
1218 SHELL_FREE_NON_NULL(GuidStr
);
1222 SHELL_FREE_NON_NULL (TempStr
);
1224 Status
= EfiAdptrInfoProtocol
->GetInformation (
1225 EfiAdptrInfoProtocol
,
1226 &InfoTypesBuffer
[GuidIndex
],
1228 &InformationBlockSize
1231 if (EFI_ERROR (Status
)) {
1232 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GETINFO_FAILED
), NULL
);
1233 if (TempStr
== NULL
) {
1236 TempRetVal
= CatSPrint (RetVal
, TempStr
, Status
);
1237 SHELL_FREE_NON_NULL (RetVal
);
1238 RetVal
= TempRetVal
;
1240 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
1241 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_MEDIA_STATE
), NULL
);
1242 if (TempStr
== NULL
) {
1245 TempRetVal
= CatSPrint (
1248 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
,
1249 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
1251 SHELL_FREE_NON_NULL (RetVal
);
1252 RetVal
= TempRetVal
;
1253 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
1254 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_NETWORK_BOOT_INFO
), NULL
);
1255 if (TempStr
== NULL
) {
1258 TempRetVal
= CatSPrint (
1261 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4BootCapablity
,
1262 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6BootCapablity
,
1263 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBootCapablity
,
1264 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->OffloadCapability
,
1265 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiMpioCapability
,
1266 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4Boot
,
1267 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6Boot
,
1268 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBoot
1270 SHELL_FREE_NON_NULL (RetVal
);
1271 RetVal
= TempRetVal
;
1272 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
) == TRUE
) {
1273 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO
), NULL
);
1274 if (TempStr
== NULL
) {
1277 TempRetVal
= CatSPrint (
1280 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[0],
1281 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[1],
1282 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[2],
1283 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[3],
1284 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[4],
1285 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[5]
1287 SHELL_FREE_NON_NULL (RetVal
);
1288 RetVal
= TempRetVal
;
1289 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
) == TRUE
) {
1290 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNDI_IPV6_INFO
), NULL
);
1291 if (TempStr
== NULL
) {
1295 TempRetVal
= CatSPrint (
1298 ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT
*)InformationBlock
)->Ipv6Support
1300 SHELL_FREE_NON_NULL (RetVal
);
1301 RetVal
= TempRetVal
;
1303 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE
), NULL
);
1304 if (TempStr
== NULL
) {
1307 TempRetVal
= CatSPrint (RetVal
, TempStr
, &InfoTypesBuffer
[GuidIndex
]);
1308 SHELL_FREE_NON_NULL (RetVal
);
1309 RetVal
= TempRetVal
;
1312 SHELL_FREE_NON_NULL (TempStr
);
1313 SHELL_FREE_NON_NULL (InformationBlock
);
1317 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1321 SHELL_FREE_NON_NULL (RetVal
);
1322 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1323 SHELL_FREE_NON_NULL (InformationBlock
);
1328 Function to dump information about EFI_FIRMWARE_MANAGEMENT_PROTOCOL Protocol.
1330 @param[in] TheHandle The handle that has the protocol installed.
1331 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1333 @retval A pointer to a string containing the information.
1337 FirmwareManagementDumpInformation (
1338 IN CONST EFI_HANDLE TheHandle
,
1339 IN CONST BOOLEAN Verbose
1343 EFI_FIRMWARE_MANAGEMENT_PROTOCOL
*EfiFwMgmtProtocol
;
1344 EFI_FIRMWARE_IMAGE_DESCRIPTOR
*ImageInfo
;
1345 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*ImageInfoV1
;
1346 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*ImageInfoV2
;
1347 UINT64 AttributeSetting
;
1348 UINTN ImageInfoSize
;
1349 UINTN DescriptorSize
;
1350 UINT32 DescriptorVersion
;
1351 UINT32 PackageVersion
;
1352 UINT8 DescriptorCount
;
1356 CHAR16
*PackageVersionName
;
1360 CHAR16
*AttributeSettingStr
;
1362 BOOLEAN AttributeSupported
;
1365 // Initialize local variables
1369 AttributeSetting
= 0;
1371 AttributeSupported
= FALSE
;
1375 PackageVersionName
= NULL
;
1379 AttributeSettingStr
= NULL
;
1382 return (CatSPrint(NULL
, L
"FirmwareManagement"));
1385 Status
= gBS
->OpenProtocol (
1386 (EFI_HANDLE
) (TheHandle
),
1387 &gEfiFirmwareManagementProtocolGuid
,
1388 (VOID
**) &EfiFwMgmtProtocol
,
1391 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1394 if (EFI_ERROR (Status
)) {
1398 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1409 if (Status
== EFI_BUFFER_TOO_SMALL
) {
1410 ImageInfo
= AllocateZeroPool (ImageInfoSize
);
1412 if (ImageInfo
== NULL
) {
1413 Status
= EFI_OUT_OF_RESOURCES
;
1415 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1428 if (EFI_ERROR (Status
)) {
1433 // Decode Image Descriptor data only if its version is supported
1435 if (DescriptorVersion
<= EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION
) {
1437 if (ImageInfo
== NULL
) {
1441 ImageInfoV1
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*)ImageInfo
;
1442 ImageInfoV2
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*)ImageInfo
;
1445 // Set ImageInfoSize in return buffer
1447 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_INFO_SIZE
), NULL
);
1448 if (TempStr
== NULL
) {
1451 RetVal
= CatSPrint (NULL
, TempStr
, ImageInfoSize
);
1452 SHELL_FREE_NON_NULL (TempStr
);
1455 // Set DescriptorVersion in return buffer
1457 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_VERSION
), NULL
);
1458 if (TempStr
== NULL
) {
1461 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorVersion
);
1462 SHELL_FREE_NON_NULL (RetVal
);
1463 RetVal
= TempRetVal
;
1464 SHELL_FREE_NON_NULL (TempStr
);
1467 // Set DescriptorCount in return buffer
1469 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_COUNT
), NULL
);
1470 if (TempStr
== NULL
) {
1473 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorCount
);
1474 SHELL_FREE_NON_NULL (RetVal
);
1475 RetVal
= TempRetVal
;
1476 SHELL_FREE_NON_NULL (TempStr
);
1480 // Set DescriptorSize in return buffer
1482 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_SIZE
), NULL
);
1483 if (TempStr
== NULL
) {
1486 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorSize
);
1487 SHELL_FREE_NON_NULL (RetVal
);
1488 RetVal
= TempRetVal
;
1489 SHELL_FREE_NON_NULL (TempStr
);
1492 // Set PackageVersion in return buffer
1494 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION
), NULL
);
1495 if (TempStr
== NULL
) {
1498 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersion
);
1499 SHELL_FREE_NON_NULL (RetVal
);
1500 RetVal
= TempRetVal
;
1501 SHELL_FREE_NON_NULL (TempStr
);
1504 // Set PackageVersionName in return buffer
1506 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION_NAME
), NULL
);
1507 if (TempStr
== NULL
) {
1510 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersionName
);
1511 SHELL_FREE_NON_NULL (RetVal
);
1512 RetVal
= TempRetVal
;
1513 SHELL_FREE_NON_NULL (TempStr
);
1515 for (Index
= 0; Index
< DescriptorCount
; Index
++) {
1517 // First check if Attribute is supported
1518 // and generate a string for AttributeSetting field
1520 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1521 AttributeSupported
= FALSE
;
1522 AttributeSetting
= 0;
1523 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1524 if (ImageInfoV1
[Index
].AttributesSupported
!= 0x0) {
1525 AttributeSupported
= TRUE
;
1526 AttributeSetting
= ImageInfoV1
[Index
].AttributesSetting
;
1528 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1529 if (ImageInfoV2
[Index
].AttributesSupported
!= 0x0) {
1530 AttributeSupported
= TRUE
;
1531 AttributeSetting
= ImageInfoV2
[Index
].AttributesSetting
;
1534 if (ImageInfo
[Index
].AttributesSupported
!= 0x0) {
1535 AttributeSupported
= TRUE
;
1536 AttributeSetting
= ImageInfo
[Index
].AttributesSetting
;
1540 if (!AttributeSupported
) {
1541 AttributeSettingStr
= CatSPrint (NULL
, L
"None");
1543 AttributeSettingStr
= CatSPrint (NULL
, L
"(");
1545 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
) != 0x0) {
1546 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IMAGE_UPDATABLE");
1547 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1548 AttributeSettingStr
= TempRetVal
;
1550 if ((AttributeSetting
& IMAGE_ATTRIBUTE_RESET_REQUIRED
) != 0x0) {
1551 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_RESET_REQUIRED");
1552 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1553 AttributeSettingStr
= TempRetVal
;
1555 if ((AttributeSetting
& IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
) != 0x0) {
1556 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED");
1557 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1558 AttributeSettingStr
= TempRetVal
;
1560 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IN_USE
) != 0x0) {
1561 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IN_USE");
1562 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1563 AttributeSettingStr
= TempRetVal
;
1565 if ((AttributeSetting
& IMAGE_ATTRIBUTE_UEFI_IMAGE
) != 0x0) {
1566 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_UEFI_IMAGE");
1567 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1568 AttributeSettingStr
= TempRetVal
;
1570 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" )");
1571 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1572 AttributeSettingStr
= TempRetVal
;
1575 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1576 if (ImageInfoV1
[Index
].ImageIndex
!= 0x0) {
1580 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V1
), NULL
);
1581 if (TempStr
== NULL
) {
1584 TempRetVal
= CatSPrint (
1588 ImageInfoV1
[Index
].ImageIndex
,
1589 &ImageInfoV1
[Index
].ImageTypeId
,
1590 ImageInfoV1
[Index
].ImageId
,
1591 ImageInfoV1
[Index
].ImageIdName
,
1592 ImageInfoV1
[Index
].Version
,
1593 ImageInfoV1
[Index
].VersionName
,
1594 ImageInfoV1
[Index
].Size
,
1595 ImageInfoV1
[Index
].AttributesSupported
,
1596 AttributeSettingStr
,
1597 ImageInfoV1
[Index
].Compatibilities
1599 SHELL_FREE_NON_NULL (RetVal
);
1600 RetVal
= TempRetVal
;
1601 SHELL_FREE_NON_NULL (TempStr
);
1602 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1603 if (ImageInfoV2
[Index
].ImageIndex
!= 0x0) {
1607 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V2
), NULL
);
1608 if (TempStr
== NULL
) {
1611 TempRetVal
= CatSPrint (
1615 ImageInfoV2
[Index
].ImageIndex
,
1616 &ImageInfoV2
[Index
].ImageTypeId
,
1617 ImageInfoV2
[Index
].ImageId
,
1618 ImageInfoV2
[Index
].ImageIdName
,
1619 ImageInfoV2
[Index
].Version
,
1620 ImageInfoV2
[Index
].VersionName
,
1621 ImageInfoV2
[Index
].Size
,
1622 ImageInfoV2
[Index
].AttributesSupported
,
1623 AttributeSettingStr
,
1624 ImageInfoV2
[Index
].Compatibilities
,
1625 ImageInfoV2
[Index
].LowestSupportedImageVersion
1627 SHELL_FREE_NON_NULL (RetVal
);
1628 RetVal
= TempRetVal
;
1629 SHELL_FREE_NON_NULL (TempStr
);
1631 if (ImageInfo
[Index
].ImageIndex
!= 0x0) {
1635 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO
), NULL
);
1636 if (TempStr
== NULL
) {
1639 TempRetVal
= CatSPrint (
1643 ImageInfo
[Index
].ImageIndex
,
1644 &ImageInfo
[Index
].ImageTypeId
,
1645 ImageInfo
[Index
].ImageId
,
1646 ImageInfo
[Index
].ImageIdName
,
1647 ImageInfo
[Index
].Version
,
1648 ImageInfo
[Index
].VersionName
,
1649 ImageInfo
[Index
].Size
,
1650 ImageInfo
[Index
].AttributesSupported
,
1651 AttributeSettingStr
,
1652 ImageInfo
[Index
].Compatibilities
,
1653 ImageInfo
[Index
].LowestSupportedImageVersion
,
1654 ImageInfo
[Index
].LastAttemptVersion
,
1655 ImageInfo
[Index
].LastAttemptStatus
,
1656 ImageInfo
[Index
].HardwareInstance
1658 SHELL_FREE_NON_NULL (RetVal
);
1659 RetVal
= TempRetVal
;
1660 SHELL_FREE_NON_NULL (TempStr
);
1665 if (ImageCount
> 0) {
1666 for (Index
=0; Index
<DescriptorCount
; Index
++) {
1667 for (Index1
=Index
+1; Index1
<DescriptorCount
; Index1
++) {
1668 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1669 if (ImageInfoV1
[Index
].ImageId
== ImageInfoV1
[Index1
].ImageId
) {
1672 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1676 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1677 if (ImageInfoV2
[Index
].ImageId
== ImageInfoV2
[Index1
].ImageId
) {
1680 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1685 if (ImageInfo
[Index
].ImageId
== ImageInfo
[Index1
].ImageId
) {
1688 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1699 // Check if ImageId with duplicate value was found
1702 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGEID_NON_UNIQUE
), NULL
);
1703 if (TempStr
== NULL
) {
1706 TempRetVal
= CatSPrint (RetVal
, TempStr
);
1707 SHELL_FREE_NON_NULL (RetVal
);
1708 RetVal
= TempRetVal
;
1709 SHELL_FREE_NON_NULL (TempStr
);
1712 SHELL_FREE_NON_NULL (ImageInfo
);
1713 SHELL_FREE_NON_NULL (PackageVersionName
);
1714 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1719 SHELL_FREE_NON_NULL (RetVal
);
1720 SHELL_FREE_NON_NULL (ImageInfo
);
1721 SHELL_FREE_NON_NULL (PackageVersionName
);
1722 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1728 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
1730 #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
1732 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1735 #define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
1737 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1740 #define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
1742 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1744 STATIC CONST EFI_GUID WinNtThunkProtocolGuid
= LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID
;
1745 STATIC CONST EFI_GUID WinNtIoProtocolGuid
= LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID
;
1746 STATIC CONST EFI_GUID WinNtSerialPortGuid
= LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID
;
1749 // Deprecated protocols we dont want to link from IntelFrameworkModulePkg
1751 #define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \
1753 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
1755 #define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \
1757 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \
1759 STATIC CONST EFI_GUID EfiIsaIoProtocolGuid
= LOCAL_EFI_ISA_IO_PROTOCOL_GUID
;
1760 STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid
= LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID
;
1763 STATIC CONST GUID_INFO_BLOCK mGuidStringListNT
[] = {
1764 {STRING_TOKEN(STR_WINNT_THUNK
), (EFI_GUID
*)&WinNtThunkProtocolGuid
, NULL
},
1765 {STRING_TOKEN(STR_WINNT_DRIVER_IO
), (EFI_GUID
*)&WinNtIoProtocolGuid
, NULL
},
1766 {STRING_TOKEN(STR_WINNT_SERIAL_PORT
), (EFI_GUID
*)&WinNtSerialPortGuid
, NULL
},
1770 STATIC CONST GUID_INFO_BLOCK mGuidStringList
[] = {
1771 {STRING_TOKEN(STR_LOADED_IMAGE
), &gEfiLoadedImageProtocolGuid
, LoadedImageProtocolDumpInformation
},
1772 {STRING_TOKEN(STR_DEVICE_PATH
), &gEfiDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
1773 {STRING_TOKEN(STR_IMAGE_PATH
), &gEfiLoadedImageDevicePathProtocolGuid
, LoadedImageDevicePathProtocolDumpInformation
},
1774 {STRING_TOKEN(STR_DEVICE_PATH_UTIL
), &gEfiDevicePathUtilitiesProtocolGuid
, NULL
},
1775 {STRING_TOKEN(STR_DEVICE_PATH_TXT
), &gEfiDevicePathToTextProtocolGuid
, NULL
},
1776 {STRING_TOKEN(STR_DEVICE_PATH_FTXT
), &gEfiDevicePathFromTextProtocolGuid
, NULL
},
1777 {STRING_TOKEN(STR_DEVICE_PATH_PC
), &gEfiPcAnsiGuid
, NULL
},
1778 {STRING_TOKEN(STR_DEVICE_PATH_VT100
), &gEfiVT100Guid
, NULL
},
1779 {STRING_TOKEN(STR_DEVICE_PATH_VT100P
), &gEfiVT100PlusGuid
, NULL
},
1780 {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8
), &gEfiVTUTF8Guid
, NULL
},
1781 {STRING_TOKEN(STR_DRIVER_BINDING
), &gEfiDriverBindingProtocolGuid
, NULL
},
1782 {STRING_TOKEN(STR_PLATFORM_OVERRIDE
), &gEfiPlatformDriverOverrideProtocolGuid
, NULL
},
1783 {STRING_TOKEN(STR_BUS_OVERRIDE
), &gEfiBusSpecificDriverOverrideProtocolGuid
, BusSpecificDriverOverrideProtocolDumpInformation
},
1784 {STRING_TOKEN(STR_DRIVER_DIAG
), &gEfiDriverDiagnosticsProtocolGuid
, NULL
},
1785 {STRING_TOKEN(STR_DRIVER_DIAG2
), &gEfiDriverDiagnostics2ProtocolGuid
, NULL
},
1786 {STRING_TOKEN(STR_DRIVER_CN
), &gEfiComponentNameProtocolGuid
, NULL
},
1787 {STRING_TOKEN(STR_DRIVER_CN2
), &gEfiComponentName2ProtocolGuid
, NULL
},
1788 {STRING_TOKEN(STR_PLAT_DRV_CFG
), &gEfiPlatformToDriverConfigurationProtocolGuid
, NULL
},
1789 {STRING_TOKEN(STR_DRIVER_VERSION
), &gEfiDriverSupportedEfiVersionProtocolGuid
, DriverEfiVersionProtocolDumpInformation
},
1790 {STRING_TOKEN(STR_TXT_IN
), &gEfiSimpleTextInProtocolGuid
, NULL
},
1791 {STRING_TOKEN(STR_TXT_IN_EX
), &gEfiSimpleTextInputExProtocolGuid
, NULL
},
1792 {STRING_TOKEN(STR_TXT_OUT
), &gEfiSimpleTextOutProtocolGuid
, TxtOutProtocolDumpInformation
},
1793 {STRING_TOKEN(STR_SIM_POINTER
), &gEfiSimplePointerProtocolGuid
, NULL
},
1794 {STRING_TOKEN(STR_ABS_POINTER
), &gEfiAbsolutePointerProtocolGuid
, NULL
},
1795 {STRING_TOKEN(STR_SERIAL_IO
), &gEfiSerialIoProtocolGuid
, NULL
},
1796 {STRING_TOKEN(STR_GRAPHICS_OUTPUT
), &gEfiGraphicsOutputProtocolGuid
, GraphicsOutputProtocolDumpInformation
},
1797 {STRING_TOKEN(STR_EDID_DISCOVERED
), &gEfiEdidDiscoveredProtocolGuid
, EdidDiscoveredProtocolDumpInformation
},
1798 {STRING_TOKEN(STR_EDID_ACTIVE
), &gEfiEdidActiveProtocolGuid
, EdidActiveProtocolDumpInformation
},
1799 {STRING_TOKEN(STR_EDID_OVERRIDE
), &gEfiEdidOverrideProtocolGuid
, NULL
},
1800 {STRING_TOKEN(STR_CON_IN
), &gEfiConsoleInDeviceGuid
, NULL
},
1801 {STRING_TOKEN(STR_CON_OUT
), &gEfiConsoleOutDeviceGuid
, NULL
},
1802 {STRING_TOKEN(STR_STD_ERR
), &gEfiStandardErrorDeviceGuid
, NULL
},
1803 {STRING_TOKEN(STR_LOAD_FILE
), &gEfiLoadFileProtocolGuid
, NULL
},
1804 {STRING_TOKEN(STR_LOAD_FILE2
), &gEfiLoadFile2ProtocolGuid
, NULL
},
1805 {STRING_TOKEN(STR_SIMPLE_FILE_SYS
), &gEfiSimpleFileSystemProtocolGuid
, NULL
},
1806 {STRING_TOKEN(STR_TAPE_IO
), &gEfiTapeIoProtocolGuid
, NULL
},
1807 {STRING_TOKEN(STR_DISK_IO
), &gEfiDiskIoProtocolGuid
, NULL
},
1808 {STRING_TOKEN(STR_BLK_IO
), &gEfiBlockIoProtocolGuid
, BlockIoProtocolDumpInformation
},
1809 {STRING_TOKEN(STR_UC
), &gEfiUnicodeCollationProtocolGuid
, NULL
},
1810 {STRING_TOKEN(STR_UC2
), &gEfiUnicodeCollation2ProtocolGuid
, NULL
},
1811 {STRING_TOKEN(STR_PCIRB_IO
), &gEfiPciRootBridgeIoProtocolGuid
, PciRootBridgeIoDumpInformation
},
1812 {STRING_TOKEN(STR_PCI_IO
), &gEfiPciIoProtocolGuid
, NULL
},
1813 {STRING_TOKEN(STR_SCSI_PT
), &gEfiScsiPassThruProtocolGuid
, NULL
},
1814 {STRING_TOKEN(STR_SCSI_IO
), &gEfiScsiIoProtocolGuid
, NULL
},
1815 {STRING_TOKEN(STR_SCSI_PT_EXT
), &gEfiExtScsiPassThruProtocolGuid
, NULL
},
1816 {STRING_TOKEN(STR_ISCSI
), &gEfiIScsiInitiatorNameProtocolGuid
, NULL
},
1817 {STRING_TOKEN(STR_USB_IO
), &gEfiUsbIoProtocolGuid
, NULL
},
1818 {STRING_TOKEN(STR_USB_HC
), &gEfiUsbHcProtocolGuid
, NULL
},
1819 {STRING_TOKEN(STR_USB_HC2
), &gEfiUsb2HcProtocolGuid
, NULL
},
1820 {STRING_TOKEN(STR_DEBUG_SUPPORT
), &gEfiDebugSupportProtocolGuid
, NULL
},
1821 {STRING_TOKEN(STR_DEBUG_PORT
), &gEfiDebugPortProtocolGuid
, NULL
},
1822 {STRING_TOKEN(STR_DECOMPRESS
), &gEfiDecompressProtocolGuid
, NULL
},
1823 {STRING_TOKEN(STR_ACPI_TABLE
), &gEfiAcpiTableProtocolGuid
, NULL
},
1824 {STRING_TOKEN(STR_EBC_INTERPRETER
), &gEfiEbcProtocolGuid
, NULL
},
1825 {STRING_TOKEN(STR_SNP
), &gEfiSimpleNetworkProtocolGuid
, NULL
},
1826 {STRING_TOKEN(STR_NII
), &gEfiNetworkInterfaceIdentifierProtocolGuid
, NULL
},
1827 {STRING_TOKEN(STR_NII_31
), &gEfiNetworkInterfaceIdentifierProtocolGuid_31
, NULL
},
1828 {STRING_TOKEN(STR_PXE_BC
), &gEfiPxeBaseCodeProtocolGuid
, NULL
},
1829 {STRING_TOKEN(STR_PXE_CB
), &gEfiPxeBaseCodeCallbackProtocolGuid
, NULL
},
1830 {STRING_TOKEN(STR_BIS
), &gEfiBisProtocolGuid
, NULL
},
1831 {STRING_TOKEN(STR_MNP_SB
), &gEfiManagedNetworkServiceBindingProtocolGuid
, NULL
},
1832 {STRING_TOKEN(STR_MNP
), &gEfiManagedNetworkProtocolGuid
, NULL
},
1833 {STRING_TOKEN(STR_ARP_SB
), &gEfiArpServiceBindingProtocolGuid
, NULL
},
1834 {STRING_TOKEN(STR_ARP
), &gEfiArpProtocolGuid
, NULL
},
1835 {STRING_TOKEN(STR_DHCPV4_SB
), &gEfiDhcp4ServiceBindingProtocolGuid
, NULL
},
1836 {STRING_TOKEN(STR_DHCPV4
), &gEfiDhcp4ProtocolGuid
, NULL
},
1837 {STRING_TOKEN(STR_TCPV4_SB
), &gEfiTcp4ServiceBindingProtocolGuid
, NULL
},
1838 {STRING_TOKEN(STR_TCPV4
), &gEfiTcp4ProtocolGuid
, NULL
},
1839 {STRING_TOKEN(STR_IPV4_SB
), &gEfiIp4ServiceBindingProtocolGuid
, NULL
},
1840 {STRING_TOKEN(STR_IPV4
), &gEfiIp4ProtocolGuid
, NULL
},
1841 {STRING_TOKEN(STR_IPV4_CFG
), &gEfiIp4ConfigProtocolGuid
, NULL
},
1842 {STRING_TOKEN(STR_IPV4_CFG2
), &gEfiIp4Config2ProtocolGuid
, NULL
},
1843 {STRING_TOKEN(STR_UDPV4_SB
), &gEfiUdp4ServiceBindingProtocolGuid
, NULL
},
1844 {STRING_TOKEN(STR_UDPV4
), &gEfiUdp4ProtocolGuid
, NULL
},
1845 {STRING_TOKEN(STR_MTFTPV4_SB
), &gEfiMtftp4ServiceBindingProtocolGuid
, NULL
},
1846 {STRING_TOKEN(STR_MTFTPV4
), &gEfiMtftp4ProtocolGuid
, NULL
},
1847 {STRING_TOKEN(STR_AUTH_INFO
), &gEfiAuthenticationInfoProtocolGuid
, NULL
},
1848 {STRING_TOKEN(STR_HASH_SB
), &gEfiHashServiceBindingProtocolGuid
, NULL
},
1849 {STRING_TOKEN(STR_HASH
), &gEfiHashProtocolGuid
, NULL
},
1850 {STRING_TOKEN(STR_HII_FONT
), &gEfiHiiFontProtocolGuid
, NULL
},
1851 {STRING_TOKEN(STR_HII_STRING
), &gEfiHiiStringProtocolGuid
, NULL
},
1852 {STRING_TOKEN(STR_HII_IMAGE
), &gEfiHiiImageProtocolGuid
, NULL
},
1853 {STRING_TOKEN(STR_HII_DATABASE
), &gEfiHiiDatabaseProtocolGuid
, NULL
},
1854 {STRING_TOKEN(STR_HII_CONFIG_ROUT
), &gEfiHiiConfigRoutingProtocolGuid
, NULL
},
1855 {STRING_TOKEN(STR_HII_CONFIG_ACC
), &gEfiHiiConfigAccessProtocolGuid
, NULL
},
1856 {STRING_TOKEN(STR_HII_FORM_BROWSER2
), &gEfiFormBrowser2ProtocolGuid
, NULL
},
1857 {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE
), &gEfiDriverFamilyOverrideProtocolGuid
, NULL
},
1858 {STRING_TOKEN(STR_PCD
), &gPcdProtocolGuid
, NULL
},
1859 {STRING_TOKEN(STR_TCG
), &gEfiTcgProtocolGuid
, NULL
},
1860 {STRING_TOKEN(STR_HII_PACKAGE_LIST
), &gEfiHiiPackageListProtocolGuid
, NULL
},
1863 // the ones under this are deprecated by the current UEFI Spec, but may be found anyways...
1865 {STRING_TOKEN(STR_SHELL_INTERFACE
), &gEfiShellInterfaceGuid
, NULL
},
1866 {STRING_TOKEN(STR_SHELL_ENV2
), &gEfiShellEnvironment2Guid
, NULL
},
1867 {STRING_TOKEN(STR_SHELL_ENV
), &gEfiShellEnvironment2Guid
, NULL
},
1868 {STRING_TOKEN(STR_DEVICE_IO
), &gEfiDeviceIoProtocolGuid
, NULL
},
1869 {STRING_TOKEN(STR_UGA_DRAW
), &gEfiUgaDrawProtocolGuid
, NULL
},
1870 {STRING_TOKEN(STR_UGA_IO
), &gEfiUgaIoProtocolGuid
, NULL
},
1871 {STRING_TOKEN(STR_ESP
), &gEfiPartTypeSystemPartGuid
, NULL
},
1872 {STRING_TOKEN(STR_GPT_NBR
), &gEfiPartTypeLegacyMbrGuid
, NULL
},
1873 {STRING_TOKEN(STR_DRIVER_CONFIG
), &gEfiDriverConfigurationProtocolGuid
, NULL
},
1874 {STRING_TOKEN(STR_DRIVER_CONFIG2
), &gEfiDriverConfiguration2ProtocolGuid
, NULL
},
1877 // these are using local (non-global) definitions to reduce package dependancy.
1879 {STRING_TOKEN(STR_ISA_IO
), (EFI_GUID
*)&EfiIsaIoProtocolGuid
, NULL
},
1880 {STRING_TOKEN(STR_ISA_ACPI
), (EFI_GUID
*)&EfiIsaAcpiProtocolGuid
, NULL
},
1883 // the ones under this are GUID identified structs, not protocols
1885 {STRING_TOKEN(STR_FILE_INFO
), &gEfiFileInfoGuid
, NULL
},
1886 {STRING_TOKEN(STR_FILE_SYS_INFO
), &gEfiFileSystemInfoGuid
, NULL
},
1889 // the ones under this are misc GUIDS.
1891 {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE
), &gEfiGlobalVariableGuid
, NULL
},
1896 {STRING_TOKEN(STR_IP6_SB
), &gEfiIp6ServiceBindingProtocolGuid
, NULL
},
1897 {STRING_TOKEN(STR_IP6
), &gEfiIp6ProtocolGuid
, NULL
},
1898 {STRING_TOKEN(STR_IP6_CONFIG
), &gEfiIp6ConfigProtocolGuid
, NULL
},
1899 {STRING_TOKEN(STR_MTFTP6_SB
), &gEfiMtftp6ServiceBindingProtocolGuid
, NULL
},
1900 {STRING_TOKEN(STR_MTFTP6
), &gEfiMtftp6ProtocolGuid
, NULL
},
1901 {STRING_TOKEN(STR_DHCP6_SB
), &gEfiDhcp6ServiceBindingProtocolGuid
, NULL
},
1902 {STRING_TOKEN(STR_DHCP6
), &gEfiDhcp6ProtocolGuid
, NULL
},
1903 {STRING_TOKEN(STR_UDP6_SB
), &gEfiUdp6ServiceBindingProtocolGuid
, NULL
},
1904 {STRING_TOKEN(STR_UDP6
), &gEfiUdp6ProtocolGuid
, NULL
},
1905 {STRING_TOKEN(STR_TCP6_SB
), &gEfiTcp6ServiceBindingProtocolGuid
, NULL
},
1906 {STRING_TOKEN(STR_TCP6
), &gEfiTcp6ProtocolGuid
, NULL
},
1907 {STRING_TOKEN(STR_VLAN_CONFIG
), &gEfiVlanConfigProtocolGuid
, NULL
},
1908 {STRING_TOKEN(STR_EAP
), &gEfiEapProtocolGuid
, NULL
},
1909 {STRING_TOKEN(STR_EAP_MGMT
), &gEfiEapManagementProtocolGuid
, NULL
},
1910 {STRING_TOKEN(STR_FTP4_SB
), &gEfiFtp4ServiceBindingProtocolGuid
, NULL
},
1911 {STRING_TOKEN(STR_FTP4
), &gEfiFtp4ProtocolGuid
, NULL
},
1912 {STRING_TOKEN(STR_IP_SEC_CONFIG
), &gEfiIpSecConfigProtocolGuid
, NULL
},
1913 {STRING_TOKEN(STR_DH
), &gEfiDriverHealthProtocolGuid
, NULL
},
1914 {STRING_TOKEN(STR_DEF_IMG_LOAD
), &gEfiDeferredImageLoadProtocolGuid
, NULL
},
1915 {STRING_TOKEN(STR_USER_CRED
), &gEfiUserCredentialProtocolGuid
, NULL
},
1916 {STRING_TOKEN(STR_USER_MNGR
), &gEfiUserManagerProtocolGuid
, NULL
},
1917 {STRING_TOKEN(STR_ATA_PASS_THRU
), &gEfiAtaPassThruProtocolGuid
, NULL
},
1922 {STRING_TOKEN(STR_FW_MGMT
), &gEfiFirmwareManagementProtocolGuid
, FirmwareManagementDumpInformation
},
1923 {STRING_TOKEN(STR_IP_SEC
), &gEfiIpSecProtocolGuid
, NULL
},
1924 {STRING_TOKEN(STR_IP_SEC2
), &gEfiIpSec2ProtocolGuid
, NULL
},
1929 {STRING_TOKEN(STR_KMS
), &gEfiKmsProtocolGuid
, NULL
},
1930 {STRING_TOKEN(STR_BLK_IO2
), &gEfiBlockIo2ProtocolGuid
, NULL
},
1931 {STRING_TOKEN(STR_SSC
), &gEfiStorageSecurityCommandProtocolGuid
, NULL
},
1932 {STRING_TOKEN(STR_UCRED2
), &gEfiUserCredential2ProtocolGuid
, NULL
},
1937 {STRING_TOKEN(STR_DISK_IO2
), &gEfiDiskIo2ProtocolGuid
, NULL
},
1938 {STRING_TOKEN(STR_ADAPTER_INFO
), &gEfiAdapterInformationProtocolGuid
, AdapterInformationDumpInformation
},
1943 {STRING_TOKEN(STR_IDE_CONT_INIT
), &gEfiIdeControllerInitProtocolGuid
, NULL
},
1944 {STRING_TOKEN(STR_DISK_INFO
), &gEfiDiskInfoProtocolGuid
, NULL
},
1949 {STRING_TOKEN(STR_BDS_ARCH
), &gEfiBdsArchProtocolGuid
, NULL
},
1950 {STRING_TOKEN(STR_CPU_ARCH
), &gEfiCpuArchProtocolGuid
, NULL
},
1951 {STRING_TOKEN(STR_MET_ARCH
), &gEfiMetronomeArchProtocolGuid
, NULL
},
1952 {STRING_TOKEN(STR_MON_ARCH
), &gEfiMonotonicCounterArchProtocolGuid
, NULL
},
1953 {STRING_TOKEN(STR_RTC_ARCH
), &gEfiRealTimeClockArchProtocolGuid
, NULL
},
1954 {STRING_TOKEN(STR_RESET_ARCH
), &gEfiResetArchProtocolGuid
, NULL
},
1955 {STRING_TOKEN(STR_RT_ARCH
), &gEfiRuntimeArchProtocolGuid
, NULL
},
1956 {STRING_TOKEN(STR_SEC_ARCH
), &gEfiSecurityArchProtocolGuid
, NULL
},
1957 {STRING_TOKEN(STR_TIMER_ARCH
), &gEfiTimerArchProtocolGuid
, NULL
},
1958 {STRING_TOKEN(STR_VAR_ARCH
), &gEfiVariableWriteArchProtocolGuid
, NULL
},
1959 {STRING_TOKEN(STR_V_ARCH
), &gEfiVariableArchProtocolGuid
, NULL
},
1960 {STRING_TOKEN(STR_SECP
), &gEfiSecurityPolicyProtocolGuid
, NULL
},
1961 {STRING_TOKEN(STR_WDT_ARCH
), &gEfiWatchdogTimerArchProtocolGuid
, NULL
},
1962 {STRING_TOKEN(STR_SCR
), &gEfiStatusCodeRuntimeProtocolGuid
, NULL
},
1963 {STRING_TOKEN(STR_SMB_HC
), &gEfiSmbusHcProtocolGuid
, NULL
},
1964 {STRING_TOKEN(STR_FV_2
), &gEfiFirmwareVolume2ProtocolGuid
, NULL
},
1965 {STRING_TOKEN(STR_FV_BLOCK
), &gEfiFirmwareVolumeBlockProtocolGuid
, NULL
},
1966 {STRING_TOKEN(STR_CAP_ARCH
), &gEfiCapsuleArchProtocolGuid
, NULL
},
1967 {STRING_TOKEN(STR_MP_SERVICE
), &gEfiMpServiceProtocolGuid
, NULL
},
1968 {STRING_TOKEN(STR_HBRAP
), &gEfiPciHostBridgeResourceAllocationProtocolGuid
, NULL
},
1969 {STRING_TOKEN(STR_PCIP
), &gEfiPciPlatformProtocolGuid
, NULL
},
1970 {STRING_TOKEN(STR_PCIO
), &gEfiPciOverrideProtocolGuid
, NULL
},
1971 {STRING_TOKEN(STR_PCIE
), &gEfiPciEnumerationCompleteProtocolGuid
, NULL
},
1972 {STRING_TOKEN(STR_IPCID
), &gEfiIncompatiblePciDeviceSupportProtocolGuid
, NULL
},
1973 {STRING_TOKEN(STR_PCIHPI
), &gEfiPciHotPlugInitProtocolGuid
, NULL
},
1974 {STRING_TOKEN(STR_PCIHPR
), &gEfiPciHotPlugRequestProtocolGuid
, NULL
},
1975 {STRING_TOKEN(STR_SMBIOS
), &gEfiSmbiosProtocolGuid
, NULL
},
1976 {STRING_TOKEN(STR_S3_SAVE
), &gEfiS3SaveStateProtocolGuid
, NULL
},
1977 {STRING_TOKEN(STR_S3_S_SMM
), &gEfiS3SmmSaveStateProtocolGuid
, NULL
},
1978 {STRING_TOKEN(STR_RSC
), &gEfiRscHandlerProtocolGuid
, NULL
},
1979 {STRING_TOKEN(STR_S_RSC
), &gEfiSmmRscHandlerProtocolGuid
, NULL
},
1980 {STRING_TOKEN(STR_ACPI_SDT
), &gEfiAcpiSdtProtocolGuid
, NULL
},
1981 {STRING_TOKEN(STR_SIO
), &gEfiSioProtocolGuid
, NULL
},
1982 {STRING_TOKEN(STR_S_CPU2
), &gEfiSmmCpuIo2ProtocolGuid
, NULL
},
1983 {STRING_TOKEN(STR_S_BASE2
), &gEfiSmmBase2ProtocolGuid
, NULL
},
1984 {STRING_TOKEN(STR_S_ACC_2
), &gEfiSmmAccess2ProtocolGuid
, NULL
},
1985 {STRING_TOKEN(STR_S_CON_2
), &gEfiSmmControl2ProtocolGuid
, NULL
},
1986 {STRING_TOKEN(STR_S_CONFIG
), &gEfiSmmConfigurationProtocolGuid
, NULL
},
1987 {STRING_TOKEN(STR_S_RTL
), &gEfiSmmReadyToLockProtocolGuid
, NULL
},
1988 {STRING_TOKEN(STR_DS_RTL
), &gEfiDxeSmmReadyToLockProtocolGuid
, NULL
},
1989 {STRING_TOKEN(STR_S_COMM
), &gEfiSmmCommunicationProtocolGuid
, NULL
},
1990 {STRING_TOKEN(STR_S_STAT
), &gEfiSmmStatusCodeProtocolGuid
, NULL
},
1991 {STRING_TOKEN(STR_S_CPU
), &gEfiSmmCpuProtocolGuid
, NULL
},
1992 {STRING_TOKEN(STR_S_PCIRBIO
), &gEfiPciRootBridgeIoProtocolGuid
, NULL
},
1993 {STRING_TOKEN(STR_S_SWD
), &gEfiSmmSwDispatch2ProtocolGuid
, NULL
},
1994 {STRING_TOKEN(STR_S_SXD
), &gEfiSmmSxDispatch2ProtocolGuid
, NULL
},
1995 {STRING_TOKEN(STR_S_PTD2
), &gEfiSmmPeriodicTimerDispatch2ProtocolGuid
, NULL
},
1996 {STRING_TOKEN(STR_S_UD2
), &gEfiSmmUsbDispatch2ProtocolGuid
, NULL
},
1997 {STRING_TOKEN(STR_S_GD2
), &gEfiSmmGpiDispatch2ProtocolGuid
, NULL
},
1998 {STRING_TOKEN(STR_S_SBD2
), &gEfiSmmStandbyButtonDispatch2ProtocolGuid
, NULL
},
1999 {STRING_TOKEN(STR_S_PBD2
), &gEfiSmmPowerButtonDispatch2ProtocolGuid
, NULL
},
2000 {STRING_TOKEN(STR_S_ITD2
), &gEfiSmmIoTrapDispatch2ProtocolGuid
, NULL
},
2001 {STRING_TOKEN(STR_PCD
), &gEfiPcdProtocolGuid
, NULL
},
2002 {STRING_TOKEN(STR_FVB2
), &gEfiFirmwareVolumeBlock2ProtocolGuid
, NULL
},
2003 {STRING_TOKEN(STR_CPUIO2
), &gEfiCpuIo2ProtocolGuid
, NULL
},
2004 {STRING_TOKEN(STR_LEGACY_R2
), &gEfiLegacyRegion2ProtocolGuid
, NULL
},
2005 {STRING_TOKEN(STR_SAL_MIP
), &gEfiSalMcaInitPmiProtocolGuid
, NULL
},
2006 {STRING_TOKEN(STR_ES_BS
), &gEfiExtendedSalBootServiceProtocolGuid
, NULL
},
2007 {STRING_TOKEN(STR_ES_BIO
), &gEfiExtendedSalBaseIoServicesProtocolGuid
, NULL
},
2008 {STRING_TOKEN(STR_ES_STALL
), &gEfiExtendedSalStallServicesProtocolGuid
, NULL
},
2009 {STRING_TOKEN(STR_ES_RTC
), &gEfiExtendedSalRtcServicesProtocolGuid
, NULL
},
2010 {STRING_TOKEN(STR_ES_VS
), &gEfiExtendedSalVariableServicesProtocolGuid
, NULL
},
2011 {STRING_TOKEN(STR_ES_MTC
), &gEfiExtendedSalMtcServicesProtocolGuid
, NULL
},
2012 {STRING_TOKEN(STR_ES_RESET
), &gEfiExtendedSalResetServicesProtocolGuid
, NULL
},
2013 {STRING_TOKEN(STR_ES_SC
), &gEfiExtendedSalStatusCodeServicesProtocolGuid
, NULL
},
2014 {STRING_TOKEN(STR_ES_FBS
), &gEfiExtendedSalFvBlockServicesProtocolGuid
, NULL
},
2015 {STRING_TOKEN(STR_ES_MP
), &gEfiExtendedSalMpServicesProtocolGuid
, NULL
},
2016 {STRING_TOKEN(STR_ES_PAL
), &gEfiExtendedSalPalServicesProtocolGuid
, NULL
},
2017 {STRING_TOKEN(STR_ES_BASE
), &gEfiExtendedSalBaseServicesProtocolGuid
, NULL
},
2018 {STRING_TOKEN(STR_ES_MCA
), &gEfiExtendedSalMcaServicesProtocolGuid
, NULL
},
2019 {STRING_TOKEN(STR_ES_PCI
), &gEfiExtendedSalPciServicesProtocolGuid
, NULL
},
2020 {STRING_TOKEN(STR_ES_CACHE
), &gEfiExtendedSalCacheServicesProtocolGuid
, NULL
},
2021 {STRING_TOKEN(STR_ES_MCA_LOG
), &gEfiExtendedSalMcaLogServicesProtocolGuid
, NULL
},
2022 {STRING_TOKEN(STR_S2ARCH
), &gEfiSecurity2ArchProtocolGuid
, NULL
},
2023 {STRING_TOKEN(STR_EODXE
), &gEfiSmmEndOfDxeProtocolGuid
, NULL
},
2024 {STRING_TOKEN(STR_ISAHC
), &gEfiIsaHcProtocolGuid
, NULL
},
2025 {STRING_TOKEN(STR_ISAHC_B
), &gEfiIsaHcServiceBindingProtocolGuid
, NULL
},
2026 {STRING_TOKEN(STR_SIO_C
), &gEfiSioControlProtocolGuid
, NULL
},
2027 {STRING_TOKEN(STR_GET_PCD
), &gEfiGetPcdInfoProtocolGuid
, NULL
},
2028 {STRING_TOKEN(STR_I2C_M
), &gEfiI2cMasterProtocolGuid
, NULL
},
2029 {STRING_TOKEN(STR_I2CIO
), &gEfiI2cIoProtocolGuid
, NULL
},
2030 {STRING_TOKEN(STR_I2CEN
), &gEfiI2cEnumerateProtocolGuid
, NULL
},
2031 {STRING_TOKEN(STR_I2C_H
), &gEfiI2cHostProtocolGuid
, NULL
},
2032 {STRING_TOKEN(STR_I2C_BCM
), &gEfiI2cBusConfigurationManagementProtocolGuid
, NULL
},
2033 {STRING_TOKEN(STR_TREE
), &gEfiTrEEProtocolGuid
, NULL
},
2034 {STRING_TOKEN(STR_TCG2
), &gEfiTcg2ProtocolGuid
, NULL
},
2035 {STRING_TOKEN(STR_TIMESTAMP
), &gEfiTimestampProtocolGuid
, NULL
},
2036 {STRING_TOKEN(STR_RNG
), &gEfiRngProtocolGuid
, NULL
},
2037 {STRING_TOKEN(STR_NVMEPT
), &gEfiNvmExpressPassThruProtocolGuid
, NULL
},
2038 {STRING_TOKEN(STR_H2_SB
), &gEfiHash2ServiceBindingProtocolGuid
, NULL
},
2039 {STRING_TOKEN(STR_HASH2
), &gEfiHash2ProtocolGuid
, NULL
},
2040 {STRING_TOKEN(STR_BIO_C
), &gEfiBlockIoCryptoProtocolGuid
, NULL
},
2041 {STRING_TOKEN(STR_SCR
), &gEfiSmartCardReaderProtocolGuid
, NULL
},
2042 {STRING_TOKEN(STR_SCE
), &gEfiSmartCardEdgeProtocolGuid
, NULL
},
2043 {STRING_TOKEN(STR_USB_FIO
), &gEfiUsbFunctionIoProtocolGuid
, NULL
},
2044 {STRING_TOKEN(STR_BC_HC
), &gEfiBluetoothHcProtocolGuid
, NULL
},
2045 {STRING_TOKEN(STR_BC_IO_SB
), &gEfiBluetoothIoServiceBindingProtocolGuid
, NULL
},
2046 {STRING_TOKEN(STR_BC_IO
), &gEfiBluetoothIoProtocolGuid
, NULL
},
2047 {STRING_TOKEN(STR_BC_C
), &gEfiBluetoothConfigProtocolGuid
, NULL
},
2048 {STRING_TOKEN(STR_REG_EXP
), &gEfiRegularExpressionProtocolGuid
, NULL
},
2049 {STRING_TOKEN(STR_B_MGR_P
), &gEfiBootManagerPolicyProtocolGuid
, NULL
},
2050 {STRING_TOKEN(STR_CKH
), &gEfiConfigKeywordHandlerProtocolGuid
, NULL
},
2051 {STRING_TOKEN(STR_WIFI
), &gEfiWiFiProtocolGuid
, NULL
},
2052 {STRING_TOKEN(STR_EAP_M
), &gEfiEapManagement2ProtocolGuid
, NULL
},
2053 {STRING_TOKEN(STR_EAP_C
), &gEfiEapConfigurationProtocolGuid
, NULL
},
2054 {STRING_TOKEN(STR_PKCS7
), &gEfiPkcs7VerifyProtocolGuid
, NULL
},
2055 {STRING_TOKEN(STR_NET_DNS4_SB
), &gEfiDns4ServiceBindingProtocolGuid
, NULL
},
2056 {STRING_TOKEN(STR_NET_DNS4
), &gEfiDns4ProtocolGuid
, NULL
},
2057 {STRING_TOKEN(STR_NET_DNS6_SB
), &gEfiDns6ServiceBindingProtocolGuid
, NULL
},
2058 {STRING_TOKEN(STR_NET_DNS6
), &gEfiDns6ProtocolGuid
, NULL
},
2059 {STRING_TOKEN(STR_NET_HTTP_SB
), &gEfiHttpServiceBindingProtocolGuid
, NULL
},
2060 {STRING_TOKEN(STR_NET_HTTP
), &gEfiHttpProtocolGuid
, NULL
},
2061 {STRING_TOKEN(STR_NET_HTTP_U
), &gEfiHttpUtilitiesProtocolGuid
, NULL
},
2062 {STRING_TOKEN(STR_REST
), &gEfiRestProtocolGuid
, NULL
},
2065 // UEFI Shell Spec 2.0
2067 {STRING_TOKEN(STR_SHELL_PARAMETERS
), &gEfiShellParametersProtocolGuid
, NULL
},
2068 {STRING_TOKEN(STR_SHELL
), &gEfiShellProtocolGuid
, NULL
},
2071 // UEFI Shell Spec 2.1
2073 {STRING_TOKEN(STR_SHELL_DYNAMIC
), &gEfiShellDynamicCommandProtocolGuid
, NULL
},
2078 {STRING_TOKEN(STR_PCDINFOPROT
), &gGetPcdInfoProtocolGuid
, NULL
},
2087 Function to get the node for a protocol or struct from it's GUID.
2089 if Guid is NULL, then ASSERT.
2091 @param[in] Guid The GUID to look for the name of.
2095 CONST GUID_INFO_BLOCK
*
2096 InternalShellGetNodeFromGuid(
2097 IN CONST EFI_GUID
* Guid
2100 CONST GUID_INFO_BLOCK
*ListWalker
;
2103 ASSERT(Guid
!= NULL
);
2105 for (LoopCount
= 0, ListWalker
= mGuidList
; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++, ListWalker
++) {
2106 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
2107 return (ListWalker
);
2111 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
2112 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2113 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
2114 return (ListWalker
);
2118 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2119 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
2120 return (ListWalker
);
2127 Function to add a new GUID/Name mapping.
2129 @param[in] Guid The Guid
2130 @param[in] NameID The STRING id of the HII string to use
2131 @param[in] DumpFunc The pointer to the dump function
2134 @retval EFI_SUCCESS The operation was sucessful
2135 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
2136 @retval EFI_INVALID_PARAMETER Guid NameId was invalid
2139 InsertNewGuidNameMapping(
2140 IN CONST EFI_GUID
*Guid
,
2141 IN CONST EFI_STRING_ID NameID
,
2142 IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
2145 ASSERT(Guid
!= NULL
);
2146 ASSERT(NameID
!= 0);
2148 mGuidList
= ReallocatePool(mGuidListCount
* sizeof(GUID_INFO_BLOCK
), mGuidListCount
+1 * sizeof(GUID_INFO_BLOCK
), mGuidList
);
2149 if (mGuidList
== NULL
) {
2151 return (EFI_OUT_OF_RESOURCES
);
2155 mGuidList
[mGuidListCount
- 1].GuidId
= AllocateCopyPool(sizeof(EFI_GUID
), Guid
);
2156 mGuidList
[mGuidListCount
- 1].StringId
= NameID
;
2157 mGuidList
[mGuidListCount
- 1].DumpInfo
= DumpFunc
;
2159 if (mGuidList
[mGuidListCount
- 1].GuidId
== NULL
) {
2160 return (EFI_OUT_OF_RESOURCES
);
2163 return (EFI_SUCCESS
);
2167 Function to add a new GUID/Name mapping.
2169 This cannot overwrite an existing mapping.
2171 @param[in] Guid The Guid
2172 @param[in] TheName The Guid's name
2173 @param[in] Lang RFC4646 language code list or NULL
2175 @retval EFI_SUCCESS The operation was sucessful
2176 @retval EFI_ACCESS_DENIED There was a duplicate
2177 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
2178 @retval EFI_INVALID_PARAMETER Guid or TheName was NULL
2182 AddNewGuidNameMapping(
2183 IN CONST EFI_GUID
*Guid
,
2184 IN CONST CHAR16
*TheName
,
2185 IN CONST CHAR8
*Lang OPTIONAL
2188 EFI_STRING_ID NameID
;
2190 HandleParsingHiiInit();
2192 if (Guid
== NULL
|| TheName
== NULL
){
2193 return (EFI_INVALID_PARAMETER
);
2196 if ((InternalShellGetNodeFromGuid(Guid
)) != NULL
) {
2197 return (EFI_ACCESS_DENIED
);
2200 NameID
= HiiSetString(mHandleParsingHiiHandle
, 0, (CHAR16
*)TheName
, Lang
);
2202 return (EFI_OUT_OF_RESOURCES
);
2205 return (InsertNewGuidNameMapping(Guid
, NameID
, NULL
));
2209 Function to get the name of a protocol or struct from it's GUID.
2211 if Guid is NULL, then ASSERT.
2213 @param[in] Guid The GUID to look for the name of.
2214 @param[in] Lang The language to use.
2216 @return pointer to string of the name. The caller
2217 is responsible to free this memory.
2221 GetStringNameFromGuid(
2222 IN CONST EFI_GUID
*Guid
,
2223 IN CONST CHAR8
*Lang OPTIONAL
2226 CONST GUID_INFO_BLOCK
*Id
;
2228 HandleParsingHiiInit();
2230 Id
= InternalShellGetNodeFromGuid(Guid
);
2234 return HiiGetString (mHandleParsingHiiHandle
, Id
->StringId
, Lang
);
2238 Function to dump protocol information from a handle.
2240 This function will return a allocated string buffer containing the
2241 information. The caller is responsible for freeing the memory.
2243 If Guid is NULL, ASSERT().
2244 If TheHandle is NULL, ASSERT().
2246 @param[in] TheHandle The handle to dump information from.
2247 @param[in] Guid The GUID of the protocol to dump.
2248 @param[in] Verbose TRUE for extra info. FALSE otherwise.
2250 @return The pointer to string.
2251 @retval NULL An error was encountered.
2255 GetProtocolInformationDump(
2256 IN CONST EFI_HANDLE TheHandle
,
2257 IN CONST EFI_GUID
*Guid
,
2258 IN CONST BOOLEAN Verbose
2261 CONST GUID_INFO_BLOCK
*Id
;
2263 ASSERT(TheHandle
!= NULL
);
2264 ASSERT(Guid
!= NULL
);
2266 if (TheHandle
== NULL
|| Guid
== NULL
) {
2270 Id
= InternalShellGetNodeFromGuid(Guid
);
2271 if (Id
!= NULL
&& Id
->DumpInfo
!= NULL
) {
2272 return (Id
->DumpInfo(TheHandle
, Verbose
));
2278 Function to get the Guid for a protocol or struct based on it's string name.
2280 do not modify the returned Guid.
2282 @param[in] Name The pointer to the string name.
2283 @param[in] Lang The pointer to the language code.
2284 @param[out] Guid The pointer to the Guid.
2286 @retval EFI_SUCCESS The operation was sucessful.
2290 GetGuidFromStringName(
2291 IN CONST CHAR16
*Name
,
2292 IN CONST CHAR8
*Lang OPTIONAL
,
2296 CONST GUID_INFO_BLOCK
*ListWalker
;
2300 HandleParsingHiiInit();
2302 ASSERT(Guid
!= NULL
);
2304 return (EFI_INVALID_PARAMETER
);
2308 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
2309 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2310 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2311 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2312 *Guid
= ListWalker
->GuidId
;
2314 SHELL_FREE_NON_NULL(String
);
2315 if (*Guid
!= NULL
) {
2316 return (EFI_SUCCESS
);
2320 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2321 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2322 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2323 *Guid
= ListWalker
->GuidId
;
2325 SHELL_FREE_NON_NULL(String
);
2326 if (*Guid
!= NULL
) {
2327 return (EFI_SUCCESS
);
2331 for (LoopCount
= 0, ListWalker
= mGuidList
; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++, ListWalker
++) {
2332 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2333 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2334 *Guid
= ListWalker
->GuidId
;
2336 SHELL_FREE_NON_NULL(String
);
2337 if (*Guid
!= NULL
) {
2338 return (EFI_SUCCESS
);
2342 return (EFI_NOT_FOUND
);
2346 Get best support language for this driver.
2348 First base on the user input language to search, second base on the current
2349 platform used language to search, third get the first language from the
2350 support language list. The caller need to free the buffer of the best language.
2352 @param[in] SupportedLanguages The support languages for this driver.
2353 @param[in] InputLanguage The user input language.
2354 @param[in] Iso639Language Whether get language for ISO639.
2356 @return The best support language for this driver.
2360 GetBestLanguageForDriver (
2361 IN CONST CHAR8
*SupportedLanguages
,
2362 IN CONST CHAR8
*InputLanguage
,
2363 IN BOOLEAN Iso639Language
2366 CHAR8
*LanguageVariable
;
2367 CHAR8
*BestLanguage
;
2369 GetVariable2 (Iso639Language
? L
"Lang" : L
"PlatformLang", &gEfiGlobalVariableGuid
, (VOID
**)&LanguageVariable
, NULL
);
2371 BestLanguage
= GetBestLanguage(
2374 (InputLanguage
!= NULL
) ? InputLanguage
: "",
2375 (LanguageVariable
!= NULL
) ? LanguageVariable
: "",
2380 if (LanguageVariable
!= NULL
) {
2381 FreePool (LanguageVariable
);
2384 return BestLanguage
;
2388 Function to retrieve the driver name (if possible) from the ComponentName or
2389 ComponentName2 protocol
2391 @param[in] TheHandle The driver handle to get the name of.
2392 @param[in] Language The language to use.
2394 @retval NULL The name could not be found.
2395 @return A pointer to the string name. Do not de-allocate the memory.
2399 GetStringNameFromHandle(
2400 IN CONST EFI_HANDLE TheHandle
,
2401 IN CONST CHAR8
*Language
2404 EFI_COMPONENT_NAME2_PROTOCOL
*CompNameStruct
;
2411 Status
= gBS
->OpenProtocol(
2413 &gEfiComponentName2ProtocolGuid
,
2414 (VOID
**)&CompNameStruct
,
2417 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2418 if (!EFI_ERROR(Status
)) {
2419 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2420 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2421 if (BestLang
!= NULL
) {
2422 FreePool (BestLang
);
2425 if (!EFI_ERROR(Status
)) {
2429 Status
= gBS
->OpenProtocol(
2431 &gEfiComponentNameProtocolGuid
,
2432 (VOID
**)&CompNameStruct
,
2435 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2436 if (!EFI_ERROR(Status
)) {
2437 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2438 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2439 if (BestLang
!= NULL
) {
2440 FreePool (BestLang
);
2442 if (!EFI_ERROR(Status
)) {
2450 Function to initialize the file global mHandleList object for use in
2451 vonverting handles to index and index to handle.
2453 @retval EFI_SUCCESS The operation was successful.
2456 InternalShellInitHandleList(
2461 EFI_HANDLE
*HandleBuffer
;
2463 HANDLE_LIST
*ListWalker
;
2465 if (mHandleList
.NextIndex
!= 0) {
2468 InitializeListHead(&mHandleList
.List
.Link
);
2469 mHandleList
.NextIndex
= 1;
2470 Status
= gBS
->LocateHandleBuffer (
2477 ASSERT_EFI_ERROR(Status
);
2478 if (EFI_ERROR(Status
)) {
2481 for (mHandleList
.NextIndex
= 1 ; mHandleList
.NextIndex
<= HandleCount
; mHandleList
.NextIndex
++){
2482 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2483 if (ListWalker
!= NULL
) {
2484 ListWalker
->TheHandle
= HandleBuffer
[mHandleList
.NextIndex
- 1];
2485 ListWalker
->TheIndex
= mHandleList
.NextIndex
;
2486 InsertTailList (&mHandleList
.List
.Link
, &ListWalker
->Link
);
2489 FreePool(HandleBuffer
);
2490 return (EFI_SUCCESS
);
2494 Function to retrieve the human-friendly index of a given handle. If the handle
2495 does not have a index one will be automatically assigned. The index value is valid
2496 until the termination of the shell application.
2498 @param[in] TheHandle The handle to retrieve an index for.
2500 @retval 0 A memory allocation failed.
2501 @return The index of the handle.
2506 ConvertHandleToHandleIndex(
2507 IN CONST EFI_HANDLE TheHandle
2511 EFI_GUID
**ProtocolBuffer
;
2512 UINTN ProtocolCount
;
2513 HANDLE_LIST
*ListWalker
;
2515 if (TheHandle
== NULL
) {
2519 InternalShellInitHandleList();
2521 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2522 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2523 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2525 if (ListWalker
->TheHandle
== TheHandle
) {
2527 // Verify that TheHandle is still present in the Handle Database
2529 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2530 if (EFI_ERROR (Status
)) {
2532 // TheHandle is not present in the Handle Database, so delete from the handle list
2534 RemoveEntryList (&ListWalker
->Link
);
2537 FreePool (ProtocolBuffer
);
2538 return (ListWalker
->TheIndex
);
2543 // Verify that TheHandle is valid handle
2545 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2546 if (EFI_ERROR (Status
)) {
2548 // TheHandle is not valid, so do not add to handle list
2552 FreePool (ProtocolBuffer
);
2554 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2555 if (ListWalker
== NULL
) {
2558 ListWalker
->TheHandle
= TheHandle
;
2559 ListWalker
->TheIndex
= mHandleList
.NextIndex
++;
2560 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
2561 return (ListWalker
->TheIndex
);
2567 Function to retrieve the EFI_HANDLE from the human-friendly index.
2569 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.
2571 @retval NULL The index was invalid.
2572 @return The EFI_HANDLE that index represents.
2577 ConvertHandleIndexToHandle(
2578 IN CONST UINTN TheIndex
2582 EFI_GUID
**ProtocolBuffer
;
2583 UINTN ProtocolCount
;
2584 HANDLE_LIST
*ListWalker
;
2586 InternalShellInitHandleList();
2588 if (TheIndex
>= mHandleList
.NextIndex
) {
2592 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2593 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2594 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2596 if (ListWalker
->TheIndex
== TheIndex
&& ListWalker
->TheHandle
!= NULL
) {
2598 // Verify that LinkWalker->TheHandle is valid handle
2600 Status
= gBS
->ProtocolsPerHandle(ListWalker
->TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2601 if (!EFI_ERROR (Status
)) {
2602 FreePool (ProtocolBuffer
);
2605 // TheHandle is not valid, so do not add to handle list
2607 ListWalker
->TheHandle
= NULL
;
2609 return (ListWalker
->TheHandle
);
2616 Gets all the related EFI_HANDLEs based on the mask supplied.
2618 This function scans all EFI_HANDLES in the UEFI environment's handle database
2619 and returns the ones with the specified relationship (Mask) to the specified
2622 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2623 If MatchingHandleCount is NULL, then ASSERT.
2625 If MatchingHandleBuffer is not NULL upon a successful return the memory must be
2628 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.
2629 @param[in] ControllerHandle The handle with Device Path protocol on it.
2630 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in
2631 MatchingHandleBuffer.
2632 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount
2633 EFI_HANDLEs with a terminating NULL EFI_HANDLE.
2634 @param[out] HandleType An array of type information.
2636 @retval EFI_SUCCESS The operation was successful, and any related handles
2637 are in MatchingHandleBuffer.
2638 @retval EFI_NOT_FOUND No matching handles were found.
2639 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2643 ParseHandleDatabaseByRelationshipWithType (
2644 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
2645 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
2646 IN UINTN
*HandleCount
,
2647 OUT EFI_HANDLE
**HandleBuffer
,
2648 OUT UINTN
**HandleType
2653 EFI_GUID
**ProtocolGuidArray
;
2655 UINTN ProtocolIndex
;
2656 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfo
;
2657 UINTN OpenInfoCount
;
2658 UINTN OpenInfoIndex
;
2660 INTN DriverBindingHandleIndex
;
2662 ASSERT(HandleCount
!= NULL
);
2663 ASSERT(HandleBuffer
!= NULL
);
2664 ASSERT(HandleType
!= NULL
);
2665 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
2668 *HandleBuffer
= NULL
;
2672 // Retrieve the list of all handles from the handle database
2674 Status
= gBS
->LocateHandleBuffer (
2681 if (EFI_ERROR (Status
)) {
2685 *HandleType
= AllocateZeroPool (*HandleCount
* sizeof (UINTN
));
2686 if (*HandleType
== NULL
) {
2687 SHELL_FREE_NON_NULL (*HandleBuffer
);
2689 return EFI_OUT_OF_RESOURCES
;
2692 DriverBindingHandleIndex
= -1;
2693 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
2694 if (DriverBindingHandle
!= NULL
&& (*HandleBuffer
)[HandleIndex
] == DriverBindingHandle
) {
2695 DriverBindingHandleIndex
= (INTN
)HandleIndex
;
2699 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
2701 // Retrieve the list of all the protocols on each handle
2703 Status
= gBS
->ProtocolsPerHandle (
2704 (*HandleBuffer
)[HandleIndex
],
2708 if (EFI_ERROR (Status
)) {
2712 for (ProtocolIndex
= 0; ProtocolIndex
< ArrayCount
; ProtocolIndex
++) {
2715 // Set the bit describing what this handle has
2717 if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiLoadedImageProtocolGuid
) ) {
2718 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_IMAGE_HANDLE
;
2719 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverBindingProtocolGuid
) ) {
2720 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_BINDING_HANDLE
;
2721 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfiguration2ProtocolGuid
)) {
2722 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
2723 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfigurationProtocolGuid
) ) {
2724 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
2725 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnostics2ProtocolGuid
) ) {
2726 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
2727 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnosticsProtocolGuid
) ) {
2728 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
2729 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentName2ProtocolGuid
) ) {
2730 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
2731 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentNameProtocolGuid
) ) {
2732 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
2733 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDevicePathProtocolGuid
) ) {
2734 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DEVICE_HANDLE
;
2737 // Retrieve the list of agents that have opened each protocol
2739 Status
= gBS
->OpenProtocolInformation (
2740 (*HandleBuffer
)[HandleIndex
],
2741 ProtocolGuidArray
[ProtocolIndex
],
2745 if (EFI_ERROR (Status
)) {
2749 if (ControllerHandle
== NULL
) {
2751 // ControllerHandle == NULL and DriverBindingHandle != NULL.
2752 // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
2754 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2755 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2756 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2757 if (DriverBindingHandleIndex
!= -1) {
2758 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2761 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2762 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2763 if (DriverBindingHandleIndex
!= -1) {
2764 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2766 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2767 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2768 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2774 if (DriverBindingHandle
== NULL
&& ControllerHandle
!= NULL
) {
2775 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
2776 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2777 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2778 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2779 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2780 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2781 (*HandleType
)[ChildIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2785 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2786 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2787 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2788 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2790 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2791 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2797 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2798 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2799 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
2800 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
2806 if (DriverBindingHandle
!= NULL
&& ControllerHandle
!= NULL
) {
2807 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
2808 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2809 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2810 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2811 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
2812 if (DriverBindingHandleIndex
!= -1) {
2813 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2817 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2818 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
2819 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2820 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2821 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2826 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2827 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2828 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2834 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2835 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2836 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
2837 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
2843 FreePool (OpenInfo
);
2845 FreePool (ProtocolGuidArray
);
2851 Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask
2854 This function will scan all EFI_HANDLES in the UEFI environment's handle database
2855 and return all the ones with the specified relationship (Mask) to the specified
2858 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2859 If MatchingHandleCount is NULL, then ASSERT.
2861 If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be
2864 @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol
2866 @param[in] ControllerHandle Handle to a device with Device Path protocol on it.
2867 @param[in] Mask Mask of what relationship(s) is desired.
2868 @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in
2869 MatchingHandleBuffer.
2870 @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount
2871 EFI_HANDLEs and a terminating NULL EFI_HANDLE.
2873 @retval EFI_SUCCESS The operation was sucessful and any related handles
2874 are in MatchingHandleBuffer;
2875 @retval EFI_NOT_FOUND No matching handles were found.
2876 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2880 ParseHandleDatabaseByRelationship (
2881 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
2882 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
2883 IN CONST UINTN Mask
,
2884 IN UINTN
*MatchingHandleCount
,
2885 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2890 EFI_HANDLE
*HandleBuffer
;
2894 ASSERT(MatchingHandleCount
!= NULL
);
2895 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
2897 if ((Mask
& HR_VALID_MASK
) != Mask
) {
2898 return (EFI_INVALID_PARAMETER
);
2901 if ((Mask
& HR_CHILD_HANDLE
) != 0 && DriverBindingHandle
== NULL
) {
2902 return (EFI_INVALID_PARAMETER
);
2905 *MatchingHandleCount
= 0;
2906 if (MatchingHandleBuffer
!= NULL
) {
2907 *MatchingHandleBuffer
= NULL
;
2910 HandleBuffer
= NULL
;
2913 Status
= ParseHandleDatabaseByRelationshipWithType (
2914 DriverBindingHandle
,
2920 if (!EFI_ERROR (Status
)) {
2922 // Count the number of handles that match the attributes in Mask
2924 for (HandleIndex
= 0; HandleIndex
< HandleCount
; HandleIndex
++) {
2925 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
2926 (*MatchingHandleCount
)++;
2930 // If no handles match the attributes in Mask then return EFI_NOT_FOUND
2932 if (*MatchingHandleCount
== 0) {
2933 Status
= EFI_NOT_FOUND
;
2936 if (MatchingHandleBuffer
== NULL
) {
2938 // Someone just wanted the count...
2940 Status
= EFI_SUCCESS
;
2943 // Allocate a handle buffer for the number of handles that matched the attributes in Mask
2945 *MatchingHandleBuffer
= AllocateZeroPool ((*MatchingHandleCount
+1)* sizeof (EFI_HANDLE
));
2946 if (*MatchingHandleBuffer
== NULL
) {
2947 Status
= EFI_OUT_OF_RESOURCES
;
2949 for (HandleIndex
= 0, *MatchingHandleCount
= 0
2950 ; HandleIndex
< HandleCount
2954 // Fill the allocated buffer with the handles that matched the attributes in Mask
2956 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
2957 (*MatchingHandleBuffer
)[(*MatchingHandleCount
)++] = HandleBuffer
[HandleIndex
];
2962 // Make the last one NULL
2964 (*MatchingHandleBuffer
)[*MatchingHandleCount
] = NULL
;
2966 Status
= EFI_SUCCESS
;
2967 } // *MatchingHandleBuffer == NULL (ELSE)
2968 } // MacthingHandleBuffer == NULL (ELSE)
2969 } // *MatchingHandleCount == 0 (ELSE)
2970 } // no error on ParseHandleDatabaseByRelationshipWithType
2972 if (HandleBuffer
!= NULL
) {
2973 FreePool (HandleBuffer
);
2976 if (HandleType
!= NULL
) {
2977 FreePool (HandleType
);
2980 ASSERT ((MatchingHandleBuffer
== NULL
) ||
2981 (*MatchingHandleCount
== 0 && *MatchingHandleBuffer
== NULL
) ||
2982 (*MatchingHandleCount
!= 0 && *MatchingHandleBuffer
!= NULL
));
2987 Gets handles for any child controllers of the passed in controller.
2989 @param[in] ControllerHandle The handle of the "parent controller"
2990 @param[out] MatchingHandleCount Pointer to the number of handles in
2991 MatchingHandleBuffer on return.
2992 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2996 @retval EFI_SUCCESS The operation was sucessful.
3000 ParseHandleDatabaseForChildControllers(
3001 IN CONST EFI_HANDLE ControllerHandle
,
3002 OUT UINTN
*MatchingHandleCount
,
3003 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
3008 UINTN DriverBindingHandleCount
;
3009 EFI_HANDLE
*DriverBindingHandleBuffer
;
3010 UINTN DriverBindingHandleIndex
;
3011 UINTN ChildControllerHandleCount
;
3012 EFI_HANDLE
*ChildControllerHandleBuffer
;
3013 UINTN ChildControllerHandleIndex
;
3014 EFI_HANDLE
*HandleBufferForReturn
;
3016 if (MatchingHandleCount
== NULL
) {
3017 return (EFI_INVALID_PARAMETER
);
3019 *MatchingHandleCount
= 0;
3021 Status
= PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
3023 &DriverBindingHandleCount
,
3024 &DriverBindingHandleBuffer
3026 if (EFI_ERROR (Status
)) {
3031 // Get a buffer big enough for all the controllers.
3033 HandleBufferForReturn
= GetHandleListByProtocol(NULL
);
3034 if (HandleBufferForReturn
== NULL
) {
3035 FreePool (DriverBindingHandleBuffer
);
3036 return (EFI_NOT_FOUND
);
3039 for (DriverBindingHandleIndex
= 0; DriverBindingHandleIndex
< DriverBindingHandleCount
; DriverBindingHandleIndex
++) {
3040 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
3041 DriverBindingHandleBuffer
[DriverBindingHandleIndex
],
3043 &ChildControllerHandleCount
,
3044 &ChildControllerHandleBuffer
3046 if (EFI_ERROR (Status
)) {
3050 for (ChildControllerHandleIndex
= 0;
3051 ChildControllerHandleIndex
< ChildControllerHandleCount
;
3052 ChildControllerHandleIndex
++
3054 for (HandleIndex
= 0; HandleIndex
< *MatchingHandleCount
; HandleIndex
++) {
3055 if (HandleBufferForReturn
[HandleIndex
] == ChildControllerHandleBuffer
[ChildControllerHandleIndex
]) {
3059 if (HandleIndex
>= *MatchingHandleCount
) {
3060 HandleBufferForReturn
[(*MatchingHandleCount
)++] = ChildControllerHandleBuffer
[ChildControllerHandleIndex
];
3064 FreePool (ChildControllerHandleBuffer
);
3067 FreePool (DriverBindingHandleBuffer
);
3069 if (MatchingHandleBuffer
== NULL
|| *MatchingHandleCount
== 0) {
3071 // The caller is not interested in the actual handles, or we've found none.
3073 FreePool (HandleBufferForReturn
);
3074 HandleBufferForReturn
= NULL
;
3077 if (MatchingHandleBuffer
!= NULL
) {
3078 *MatchingHandleBuffer
= HandleBufferForReturn
;
3081 ASSERT ((MatchingHandleBuffer
== NULL
) ||
3082 (*MatchingHandleCount
== 0 && *MatchingHandleBuffer
== NULL
) ||
3083 (*MatchingHandleCount
!= 0 && *MatchingHandleBuffer
!= NULL
));
3085 return (EFI_SUCCESS
);
3089 Appends 1 buffer to another buffer. This will re-allocate the destination buffer
3090 if necessary to fit all of the data.
3092 If DestinationBuffer is NULL, then ASSERT().
3094 @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.
3095 @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.
3096 @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.
3097 @param[in] SourceSize The number of bytes of SourceBuffer to append.
3099 @retval NULL A memory allocation failed.
3100 @retval NULL A parameter was invalid.
3101 @return A pointer to (*DestinationBuffer).
3105 IN OUT VOID
**DestinationBuffer
,
3106 IN OUT UINTN
*DestinationSize
,
3107 IN VOID
*SourceBuffer
,
3111 UINTN LocalDestinationSize
;
3112 UINTN LocalDestinationFinalSize
;
3114 ASSERT(DestinationBuffer
!= NULL
);
3116 if (SourceSize
== 0 || SourceBuffer
== NULL
) {
3117 return (*DestinationBuffer
);
3120 if (DestinationSize
== NULL
) {
3121 LocalDestinationSize
= 0;
3123 LocalDestinationSize
= *DestinationSize
;
3126 LocalDestinationFinalSize
= LocalDestinationSize
+ SourceSize
;
3128 if (DestinationSize
!= NULL
) {
3129 *DestinationSize
= LocalDestinationSize
;
3132 if (LocalDestinationSize
== 0) {
3134 *DestinationBuffer
= AllocateZeroPool(LocalDestinationFinalSize
);
3137 *DestinationBuffer
= ReallocatePool(LocalDestinationSize
, LocalDestinationFinalSize
, *DestinationBuffer
);
3140 ASSERT(*DestinationBuffer
!= NULL
);
3143 return (CopyMem(((UINT8
*)(*DestinationBuffer
)) + LocalDestinationSize
, SourceBuffer
, SourceSize
));
3147 Gets handles for any child devices produced by the passed in driver.
3149 @param[in] DriverHandle The handle of the driver.
3150 @param[in] MatchingHandleCount Pointer to the number of handles in
3151 MatchingHandleBuffer on return.
3152 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
3154 @retval EFI_SUCCESS The operation was sucessful.
3155 @sa ParseHandleDatabaseByRelationship
3159 ParseHandleDatabaseForChildDevices(
3160 IN CONST EFI_HANDLE DriverHandle
,
3161 IN UINTN
*MatchingHandleCount
,
3162 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
3166 EFI_HANDLE
*Buffer2
;
3171 UINTN HandleBufferSize
;
3173 ASSERT(MatchingHandleCount
!= NULL
);
3175 HandleBufferSize
= 0;
3178 *MatchingHandleCount
= 0;
3180 Status
= PARSE_HANDLE_DATABASE_DEVICES (
3185 if (!EFI_ERROR (Status
)) {
3186 for (HandleIndex
= 0; HandleIndex
< Count1
; HandleIndex
++) {
3188 // now find the children
3190 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
3192 Buffer
[HandleIndex
],
3196 if (EFI_ERROR(Status
)) {
3200 // save out required and optional data elements
3202 *MatchingHandleCount
+= Count2
;
3203 if (MatchingHandleBuffer
!= NULL
) {
3204 *MatchingHandleBuffer
= BuffernCatGrow((VOID
**)MatchingHandleBuffer
, &HandleBufferSize
, Buffer2
, Count2
* sizeof(Buffer2
[0]));
3210 if (Buffer2
!= NULL
) {
3216 if (Buffer
!= NULL
) {
3223 Function to get all handles that support a given protocol or all handles.
3225 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL
3226 then the function will return all handles.
3228 @retval NULL A memory allocation failed.
3229 @return A NULL terminated list of handles.
3233 GetHandleListByProtocol (
3234 IN CONST EFI_GUID
*ProtocolGuid OPTIONAL
3237 EFI_HANDLE
*HandleList
;
3245 // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!
3247 if (ProtocolGuid
== NULL
) {
3248 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
3249 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3250 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
3251 if (HandleList
== NULL
) {
3254 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
3255 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
3258 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
3259 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3260 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
3261 if (HandleList
== NULL
) {
3264 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
3265 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
3268 if (EFI_ERROR(Status
)) {
3269 if (HandleList
!= NULL
) {
3270 FreePool(HandleList
);
3274 return (HandleList
);
3278 Function to get all handles that support some protocols.
3280 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
3282 @retval NULL A memory allocation failed.
3283 @retval NULL ProtocolGuids was NULL.
3284 @return A NULL terminated list of EFI_HANDLEs.
3288 GetHandleListByProtocolList (
3289 IN CONST EFI_GUID
**ProtocolGuids
3292 EFI_HANDLE
*HandleList
;
3297 CONST EFI_GUID
**GuidWalker
;
3298 EFI_HANDLE
*HandleWalker1
;
3299 EFI_HANDLE
*HandleWalker2
;
3303 TotalSize
= sizeof(EFI_HANDLE
);
3305 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++,Size
= 0){
3306 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &Size
, NULL
);
3307 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3313 // No handles were found...
3315 if (TotalSize
== sizeof(EFI_HANDLE
)) {
3319 HandleList
= AllocateZeroPool(TotalSize
);
3320 if (HandleList
== NULL
) {
3325 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++){
3326 TempSize
= TotalSize
- Size
;
3327 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &TempSize
, HandleList
+(Size
/sizeof(EFI_HANDLE
)));
3330 // Allow for missing protocols... Only update the 'used' size upon success.
3332 if (!EFI_ERROR(Status
)) {
3336 ASSERT(HandleList
[(TotalSize
/sizeof(EFI_HANDLE
))-1] == NULL
);
3338 for (HandleWalker1
= HandleList
; HandleWalker1
!= NULL
&& *HandleWalker1
!= NULL
; HandleWalker1
++) {
3339 for (HandleWalker2
= HandleWalker1
+ 1; HandleWalker2
!= NULL
&& *HandleWalker2
!= NULL
; HandleWalker2
++) {
3340 if (*HandleWalker1
== *HandleWalker2
) {
3342 // copy memory back 1 handle width.
3344 CopyMem(HandleWalker2
, HandleWalker2
+ 1, TotalSize
- ((HandleWalker2
-HandleList
+1)*sizeof(EFI_HANDLE
)));
3349 return (HandleList
);
3353 Return all supported GUIDs.
3355 @param[out] Guids The buffer to return all supported GUIDs.
3356 @param[in, out] Count On input, the count of GUIDs the buffer can hold,
3357 On output, the count of GUIDs to return.
3359 @retval EFI_INVALID_PARAMETER Count is NULL.
3360 @retval EFI_BUFFER_TOO_SMALL Buffer is not enough to hold all GUIDs.
3361 @retval EFI_SUCCESS GUIDs are returned successfully.
3365 GetAllMappingGuids (
3366 OUT EFI_GUID
*Guids
,
3374 if (Count
== NULL
) {
3375 return EFI_INVALID_PARAMETER
;
3379 if (PcdGetBool (PcdShellIncludeNtGuids
)) {
3380 NtGuidCount
= ARRAY_SIZE (mGuidStringListNT
) - 1;
3382 GuidCount
= ARRAY_SIZE (mGuidStringList
) - 1;
3384 if (*Count
< NtGuidCount
+ GuidCount
+ mGuidListCount
) {
3385 *Count
= NtGuidCount
+ GuidCount
+ mGuidListCount
;
3386 return EFI_BUFFER_TOO_SMALL
;
3389 for (Index
= 0; Index
< NtGuidCount
; Index
++) {
3390 CopyGuid (&Guids
[Index
], mGuidStringListNT
[Index
].GuidId
);
3393 for (Index
= 0; Index
< GuidCount
; Index
++) {
3394 CopyGuid (&Guids
[NtGuidCount
+ Index
], mGuidStringList
[Index
].GuidId
);
3397 for (Index
= 0; Index
< mGuidListCount
; Index
++) {
3398 CopyGuid (&Guids
[NtGuidCount
+ GuidCount
+ Index
], mGuidList
[Index
].GuidId
);