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 EfiAdapterInformation Protocol.
943 @param[in] TheHandle The handle that has the protocol installed.
944 @param[in] Verbose TRUE for additional information, FALSE otherwise.
946 @retval A pointer to a string containing the information.
950 AdapterInformationDumpInformation (
951 IN CONST EFI_HANDLE TheHandle
,
952 IN CONST BOOLEAN Verbose
956 EFI_ADAPTER_INFORMATION_PROTOCOL
*EfiAdptrInfoProtocol
;
957 UINTN InfoTypesBufferCount
;
959 EFI_GUID
*InfoTypesBuffer
;
964 VOID
*InformationBlock
;
965 UINTN InformationBlockSize
;
968 return (CatSPrint(NULL
, L
"AdapterInfo"));
971 InfoTypesBuffer
= NULL
;
972 InformationBlock
= NULL
;
975 Status
= gBS
->OpenProtocol (
976 (EFI_HANDLE
) (TheHandle
),
977 &gEfiAdapterInformationProtocolGuid
,
978 (VOID
**) &EfiAdptrInfoProtocol
,
981 EFI_OPEN_PROTOCOL_GET_PROTOCOL
984 if (EFI_ERROR (Status
)) {
989 // Get a list of supported information types for this instance of the protocol.
991 Status
= EfiAdptrInfoProtocol
->GetSupportedTypes (
992 EfiAdptrInfoProtocol
,
994 &InfoTypesBufferCount
997 if (EFI_ERROR (Status
)) {
998 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED
), NULL
);
999 if (TempStr
!= NULL
) {
1000 RetVal
= CatSPrint (NULL
, TempStr
, Status
);
1005 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SUPP_TYPE_HEADER
), NULL
);
1006 if (TempStr
== NULL
) {
1009 RetVal
= CatSPrint (NULL
, TempStr
);
1010 SHELL_FREE_NON_NULL (TempStr
);
1012 for (GuidIndex
= 0; GuidIndex
< InfoTypesBufferCount
; GuidIndex
++) {
1013 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_NUMBER
), NULL
);
1014 if (TempStr
== NULL
) {
1017 TempRetVal
= CatSPrint (RetVal
, TempStr
, (GuidIndex
+ 1), &InfoTypesBuffer
[GuidIndex
]);
1018 SHELL_FREE_NON_NULL (RetVal
);
1019 RetVal
= TempRetVal
;
1020 SHELL_FREE_NON_NULL (TempStr
);
1022 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_STRING
), NULL
);
1023 if (TempStr
== NULL
) {
1027 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
1028 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoMediaStateGuid");
1029 SHELL_FREE_NON_NULL (RetVal
);
1030 RetVal
= TempRetVal
;
1031 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
1032 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoNetworkBootGuid");
1033 SHELL_FREE_NON_NULL (RetVal
);
1034 RetVal
= TempRetVal
;
1035 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
)) {
1036 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoSanMacAddressGuid");
1037 SHELL_FREE_NON_NULL (RetVal
);
1038 RetVal
= TempRetVal
;
1039 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
)) {
1040 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoUndiIpv6SupportGuid");
1041 SHELL_FREE_NON_NULL (RetVal
);
1042 RetVal
= TempRetVal
;
1045 GuidStr
= GetStringNameFromGuid (&InfoTypesBuffer
[GuidIndex
], NULL
);
1046 if (GuidStr
== NULL
) {
1047 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"UnknownInfoType");
1048 SHELL_FREE_NON_NULL (RetVal
);
1049 RetVal
= TempRetVal
;
1051 SHELL_FREE_NON_NULL (TempStr
);
1052 SHELL_FREE_NON_NULL(GuidStr
);
1054 // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
1058 TempRetVal
= CatSPrint (RetVal
, TempStr
, GuidStr
);
1059 SHELL_FREE_NON_NULL (RetVal
);
1060 RetVal
= TempRetVal
;
1061 SHELL_FREE_NON_NULL(GuidStr
);
1065 SHELL_FREE_NON_NULL (TempStr
);
1067 Status
= EfiAdptrInfoProtocol
->GetInformation (
1068 EfiAdptrInfoProtocol
,
1069 &InfoTypesBuffer
[GuidIndex
],
1071 &InformationBlockSize
1074 if (EFI_ERROR (Status
)) {
1075 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GETINFO_FAILED
), NULL
);
1076 if (TempStr
== NULL
) {
1079 TempRetVal
= CatSPrint (RetVal
, TempStr
, Status
);
1080 SHELL_FREE_NON_NULL (RetVal
);
1081 RetVal
= TempRetVal
;
1083 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
1084 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_MEDIA_STATE
), NULL
);
1085 if (TempStr
== NULL
) {
1088 TempRetVal
= CatSPrint (
1091 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
,
1092 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
1094 SHELL_FREE_NON_NULL (RetVal
);
1095 RetVal
= TempRetVal
;
1096 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
1097 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_NETWORK_BOOT_INFO
), NULL
);
1098 if (TempStr
== NULL
) {
1101 TempRetVal
= CatSPrint (
1104 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4BootCapablity
,
1105 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6BootCapablity
,
1106 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBootCapablity
,
1107 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->OffloadCapability
,
1108 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiMpioCapability
,
1109 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4Boot
,
1110 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6Boot
,
1111 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBoot
1113 SHELL_FREE_NON_NULL (RetVal
);
1114 RetVal
= TempRetVal
;
1115 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
) == TRUE
) {
1116 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO
), NULL
);
1117 if (TempStr
== NULL
) {
1120 TempRetVal
= CatSPrint (
1123 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[0],
1124 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[1],
1125 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[2],
1126 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[3],
1127 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[4],
1128 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[5]
1130 SHELL_FREE_NON_NULL (RetVal
);
1131 RetVal
= TempRetVal
;
1132 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoUndiIpv6SupportGuid
) == TRUE
) {
1133 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNDI_IPV6_INFO
), NULL
);
1134 if (TempStr
== NULL
) {
1138 TempRetVal
= CatSPrint (
1141 ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT
*)InformationBlock
)->Ipv6Support
1143 SHELL_FREE_NON_NULL (RetVal
);
1144 RetVal
= TempRetVal
;
1146 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE
), NULL
);
1147 if (TempStr
== NULL
) {
1150 TempRetVal
= CatSPrint (RetVal
, TempStr
, &InfoTypesBuffer
[GuidIndex
]);
1151 SHELL_FREE_NON_NULL (RetVal
);
1152 RetVal
= TempRetVal
;
1155 SHELL_FREE_NON_NULL (TempStr
);
1156 SHELL_FREE_NON_NULL (InformationBlock
);
1160 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1164 SHELL_FREE_NON_NULL (RetVal
);
1165 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
1166 SHELL_FREE_NON_NULL (InformationBlock
);
1171 Function to dump information about EFI_FIRMWARE_MANAGEMENT_PROTOCOL Protocol.
1173 @param[in] TheHandle The handle that has the protocol installed.
1174 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1176 @retval A pointer to a string containing the information.
1180 FirmwareManagementDumpInformation (
1181 IN CONST EFI_HANDLE TheHandle
,
1182 IN CONST BOOLEAN Verbose
1186 EFI_FIRMWARE_MANAGEMENT_PROTOCOL
*EfiFwMgmtProtocol
;
1187 EFI_FIRMWARE_IMAGE_DESCRIPTOR
*ImageInfo
;
1188 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*ImageInfoV1
;
1189 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*ImageInfoV2
;
1190 UINT64 AttributeSetting
;
1191 UINTN ImageInfoSize
;
1192 UINTN DescriptorSize
;
1193 UINT32 DescriptorVersion
;
1194 UINT32 PackageVersion
;
1195 UINT8 DescriptorCount
;
1199 CHAR16
*PackageVersionName
;
1203 CHAR16
*AttributeSettingStr
;
1205 BOOLEAN AttributeSupported
;
1208 // Initialize local variables
1212 AttributeSetting
= 0;
1214 AttributeSupported
= FALSE
;
1218 PackageVersionName
= NULL
;
1222 AttributeSettingStr
= NULL
;
1225 return (CatSPrint(NULL
, L
"FirmwareManagement"));
1228 Status
= gBS
->OpenProtocol (
1229 (EFI_HANDLE
) (TheHandle
),
1230 &gEfiFirmwareManagementProtocolGuid
,
1231 (VOID
**) &EfiFwMgmtProtocol
,
1234 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1237 if (EFI_ERROR (Status
)) {
1241 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1252 if (Status
== EFI_BUFFER_TOO_SMALL
) {
1253 ImageInfo
= AllocateZeroPool (ImageInfoSize
);
1255 if (ImageInfo
== NULL
) {
1256 Status
= EFI_OUT_OF_RESOURCES
;
1258 Status
= EfiFwMgmtProtocol
->GetImageInfo (
1271 if (EFI_ERROR (Status
)) {
1276 // Decode Image Descriptor data only if its version is supported
1278 if (DescriptorVersion
<= EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION
) {
1280 if (ImageInfo
== NULL
) {
1284 ImageInfoV1
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1
*)ImageInfo
;
1285 ImageInfoV2
= (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2
*)ImageInfo
;
1288 // Set ImageInfoSize in return buffer
1290 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_INFO_SIZE
), NULL
);
1291 if (TempStr
== NULL
) {
1294 RetVal
= CatSPrint (NULL
, TempStr
, ImageInfoSize
);
1295 SHELL_FREE_NON_NULL (TempStr
);
1298 // Set DescriptorVersion in return buffer
1300 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_VERSION
), NULL
);
1301 if (TempStr
== NULL
) {
1304 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorVersion
);
1305 SHELL_FREE_NON_NULL (RetVal
);
1306 RetVal
= TempRetVal
;
1307 SHELL_FREE_NON_NULL (TempStr
);
1310 // Set DescriptorCount in return buffer
1312 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_COUNT
), NULL
);
1313 if (TempStr
== NULL
) {
1316 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorCount
);
1317 SHELL_FREE_NON_NULL (RetVal
);
1318 RetVal
= TempRetVal
;
1319 SHELL_FREE_NON_NULL (TempStr
);
1323 // Set DescriptorSize in return buffer
1325 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_DESCRIPTOR_SIZE
), NULL
);
1326 if (TempStr
== NULL
) {
1329 TempRetVal
= CatSPrint (RetVal
, TempStr
, DescriptorSize
);
1330 SHELL_FREE_NON_NULL (RetVal
);
1331 RetVal
= TempRetVal
;
1332 SHELL_FREE_NON_NULL (TempStr
);
1335 // Set PackageVersion in return buffer
1337 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION
), NULL
);
1338 if (TempStr
== NULL
) {
1341 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersion
);
1342 SHELL_FREE_NON_NULL (RetVal
);
1343 RetVal
= TempRetVal
;
1344 SHELL_FREE_NON_NULL (TempStr
);
1347 // Set PackageVersionName in return buffer
1349 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_PACKAGE_VERSION_NAME
), NULL
);
1350 if (TempStr
== NULL
) {
1353 TempRetVal
= CatSPrint (RetVal
, TempStr
, PackageVersionName
);
1354 SHELL_FREE_NON_NULL (RetVal
);
1355 RetVal
= TempRetVal
;
1356 SHELL_FREE_NON_NULL (TempStr
);
1358 for (Index
= 0; Index
< DescriptorCount
; Index
++) {
1360 // First check if Attribute is supported
1361 // and generate a string for AttributeSetting field
1363 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1364 AttributeSupported
= FALSE
;
1365 AttributeSetting
= 0;
1366 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1367 if (ImageInfoV1
[Index
].AttributesSupported
!= 0x0) {
1368 AttributeSupported
= TRUE
;
1369 AttributeSetting
= ImageInfoV1
[Index
].AttributesSetting
;
1371 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1372 if (ImageInfoV2
[Index
].AttributesSupported
!= 0x0) {
1373 AttributeSupported
= TRUE
;
1374 AttributeSetting
= ImageInfoV2
[Index
].AttributesSetting
;
1377 if (ImageInfo
[Index
].AttributesSupported
!= 0x0) {
1378 AttributeSupported
= TRUE
;
1379 AttributeSetting
= ImageInfo
[Index
].AttributesSetting
;
1383 if (!AttributeSupported
) {
1384 AttributeSettingStr
= CatSPrint (NULL
, L
"None");
1386 AttributeSettingStr
= CatSPrint (NULL
, L
"(");
1388 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
) != 0x0) {
1389 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IMAGE_UPDATABLE");
1390 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1391 AttributeSettingStr
= TempRetVal
;
1393 if ((AttributeSetting
& IMAGE_ATTRIBUTE_RESET_REQUIRED
) != 0x0) {
1394 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_RESET_REQUIRED");
1395 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1396 AttributeSettingStr
= TempRetVal
;
1398 if ((AttributeSetting
& IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
) != 0x0) {
1399 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED");
1400 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1401 AttributeSettingStr
= TempRetVal
;
1403 if ((AttributeSetting
& IMAGE_ATTRIBUTE_IN_USE
) != 0x0) {
1404 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_IN_USE");
1405 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1406 AttributeSettingStr
= TempRetVal
;
1408 if ((AttributeSetting
& IMAGE_ATTRIBUTE_UEFI_IMAGE
) != 0x0) {
1409 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" IMAGE_ATTRIBUTE_UEFI_IMAGE");
1410 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1411 AttributeSettingStr
= TempRetVal
;
1413 TempRetVal
= CatSPrint (AttributeSettingStr
, L
" )");
1414 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1415 AttributeSettingStr
= TempRetVal
;
1418 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1419 if (ImageInfoV1
[Index
].ImageIndex
!= 0x0) {
1423 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V1
), NULL
);
1424 if (TempStr
== NULL
) {
1427 TempRetVal
= CatSPrint (
1431 ImageInfoV1
[Index
].ImageIndex
,
1432 &ImageInfoV1
[Index
].ImageTypeId
,
1433 ImageInfoV1
[Index
].ImageId
,
1434 ImageInfoV1
[Index
].ImageIdName
,
1435 ImageInfoV1
[Index
].Version
,
1436 ImageInfoV1
[Index
].VersionName
,
1437 ImageInfoV1
[Index
].Size
,
1438 ImageInfoV1
[Index
].AttributesSupported
,
1439 AttributeSettingStr
,
1440 ImageInfoV1
[Index
].Compatibilities
1442 SHELL_FREE_NON_NULL (RetVal
);
1443 RetVal
= TempRetVal
;
1444 SHELL_FREE_NON_NULL (TempStr
);
1445 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1446 if (ImageInfoV2
[Index
].ImageIndex
!= 0x0) {
1450 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V2
), NULL
);
1451 if (TempStr
== NULL
) {
1454 TempRetVal
= CatSPrint (
1458 ImageInfoV2
[Index
].ImageIndex
,
1459 &ImageInfoV2
[Index
].ImageTypeId
,
1460 ImageInfoV2
[Index
].ImageId
,
1461 ImageInfoV2
[Index
].ImageIdName
,
1462 ImageInfoV2
[Index
].Version
,
1463 ImageInfoV2
[Index
].VersionName
,
1464 ImageInfoV2
[Index
].Size
,
1465 ImageInfoV2
[Index
].AttributesSupported
,
1466 AttributeSettingStr
,
1467 ImageInfoV2
[Index
].Compatibilities
,
1468 ImageInfoV2
[Index
].LowestSupportedImageVersion
1470 SHELL_FREE_NON_NULL (RetVal
);
1471 RetVal
= TempRetVal
;
1472 SHELL_FREE_NON_NULL (TempStr
);
1474 if (ImageInfo
[Index
].ImageIndex
!= 0x0) {
1478 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO
), NULL
);
1479 if (TempStr
== NULL
) {
1482 TempRetVal
= CatSPrint (
1486 ImageInfo
[Index
].ImageIndex
,
1487 &ImageInfo
[Index
].ImageTypeId
,
1488 ImageInfo
[Index
].ImageId
,
1489 ImageInfo
[Index
].ImageIdName
,
1490 ImageInfo
[Index
].Version
,
1491 ImageInfo
[Index
].VersionName
,
1492 ImageInfo
[Index
].Size
,
1493 ImageInfo
[Index
].AttributesSupported
,
1494 AttributeSettingStr
,
1495 ImageInfo
[Index
].Compatibilities
,
1496 ImageInfo
[Index
].LowestSupportedImageVersion
,
1497 ImageInfo
[Index
].LastAttemptVersion
,
1498 ImageInfo
[Index
].LastAttemptStatus
,
1499 ImageInfo
[Index
].HardwareInstance
1501 SHELL_FREE_NON_NULL (RetVal
);
1502 RetVal
= TempRetVal
;
1503 SHELL_FREE_NON_NULL (TempStr
);
1508 if (ImageCount
> 0) {
1509 for (Index
=0; Index
<DescriptorCount
; Index
++) {
1510 for (Index1
=Index
+1; Index1
<DescriptorCount
; Index1
++) {
1511 if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1
) {
1512 if (ImageInfoV1
[Index
].ImageId
== ImageInfoV1
[Index1
].ImageId
) {
1515 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1519 } else if (DescriptorVersion
== EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2
) {
1520 if (ImageInfoV2
[Index
].ImageId
== ImageInfoV2
[Index1
].ImageId
) {
1523 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1528 if (ImageInfo
[Index
].ImageId
== ImageInfo
[Index1
].ImageId
) {
1531 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1542 // Check if ImageId with duplicate value was found
1545 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_FMP_IMAGEID_NON_UNIQUE
), NULL
);
1546 if (TempStr
== NULL
) {
1549 TempRetVal
= CatSPrint (RetVal
, TempStr
);
1550 SHELL_FREE_NON_NULL (RetVal
);
1551 RetVal
= TempRetVal
;
1552 SHELL_FREE_NON_NULL (TempStr
);
1555 SHELL_FREE_NON_NULL (ImageInfo
);
1556 SHELL_FREE_NON_NULL (PackageVersionName
);
1557 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1562 SHELL_FREE_NON_NULL (RetVal
);
1563 SHELL_FREE_NON_NULL (ImageInfo
);
1564 SHELL_FREE_NON_NULL (PackageVersionName
);
1565 SHELL_FREE_NON_NULL (AttributeSettingStr
);
1571 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
1573 #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
1575 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1578 #define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
1580 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1583 #define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
1585 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1587 STATIC CONST EFI_GUID WinNtThunkProtocolGuid
= LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID
;
1588 STATIC CONST EFI_GUID WinNtIoProtocolGuid
= LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID
;
1589 STATIC CONST EFI_GUID WinNtSerialPortGuid
= LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID
;
1592 // Deprecated protocols we dont want to link from IntelFrameworkModulePkg
1594 #define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \
1596 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
1598 #define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \
1600 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \
1602 STATIC CONST EFI_GUID EfiIsaIoProtocolGuid
= LOCAL_EFI_ISA_IO_PROTOCOL_GUID
;
1603 STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid
= LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID
;
1606 STATIC CONST GUID_INFO_BLOCK mGuidStringListNT
[] = {
1607 {STRING_TOKEN(STR_WINNT_THUNK
), (EFI_GUID
*)&WinNtThunkProtocolGuid
, NULL
},
1608 {STRING_TOKEN(STR_WINNT_DRIVER_IO
), (EFI_GUID
*)&WinNtIoProtocolGuid
, NULL
},
1609 {STRING_TOKEN(STR_WINNT_SERIAL_PORT
), (EFI_GUID
*)&WinNtSerialPortGuid
, NULL
},
1613 STATIC CONST GUID_INFO_BLOCK mGuidStringList
[] = {
1614 {STRING_TOKEN(STR_LOADED_IMAGE
), &gEfiLoadedImageProtocolGuid
, LoadedImageProtocolDumpInformation
},
1615 {STRING_TOKEN(STR_DEVICE_PATH
), &gEfiDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
1616 {STRING_TOKEN(STR_IMAGE_PATH
), &gEfiLoadedImageDevicePathProtocolGuid
, LoadedImageDevicePathProtocolDumpInformation
},
1617 {STRING_TOKEN(STR_DEVICE_PATH_UTIL
), &gEfiDevicePathUtilitiesProtocolGuid
, NULL
},
1618 {STRING_TOKEN(STR_DEVICE_PATH_TXT
), &gEfiDevicePathToTextProtocolGuid
, NULL
},
1619 {STRING_TOKEN(STR_DEVICE_PATH_FTXT
), &gEfiDevicePathFromTextProtocolGuid
, NULL
},
1620 {STRING_TOKEN(STR_DEVICE_PATH_PC
), &gEfiPcAnsiGuid
, NULL
},
1621 {STRING_TOKEN(STR_DEVICE_PATH_VT100
), &gEfiVT100Guid
, NULL
},
1622 {STRING_TOKEN(STR_DEVICE_PATH_VT100P
), &gEfiVT100PlusGuid
, NULL
},
1623 {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8
), &gEfiVTUTF8Guid
, NULL
},
1624 {STRING_TOKEN(STR_DRIVER_BINDING
), &gEfiDriverBindingProtocolGuid
, NULL
},
1625 {STRING_TOKEN(STR_PLATFORM_OVERRIDE
), &gEfiPlatformDriverOverrideProtocolGuid
, NULL
},
1626 {STRING_TOKEN(STR_BUS_OVERRIDE
), &gEfiBusSpecificDriverOverrideProtocolGuid
, NULL
},
1627 {STRING_TOKEN(STR_DRIVER_DIAG
), &gEfiDriverDiagnosticsProtocolGuid
, NULL
},
1628 {STRING_TOKEN(STR_DRIVER_DIAG2
), &gEfiDriverDiagnostics2ProtocolGuid
, NULL
},
1629 {STRING_TOKEN(STR_DRIVER_CN
), &gEfiComponentNameProtocolGuid
, NULL
},
1630 {STRING_TOKEN(STR_DRIVER_CN2
), &gEfiComponentName2ProtocolGuid
, NULL
},
1631 {STRING_TOKEN(STR_PLAT_DRV_CFG
), &gEfiPlatformToDriverConfigurationProtocolGuid
, NULL
},
1632 {STRING_TOKEN(STR_DRIVER_VERSION
), &gEfiDriverSupportedEfiVersionProtocolGuid
, DriverEfiVersionProtocolDumpInformation
},
1633 {STRING_TOKEN(STR_TXT_IN
), &gEfiSimpleTextInProtocolGuid
, NULL
},
1634 {STRING_TOKEN(STR_TXT_IN_EX
), &gEfiSimpleTextInputExProtocolGuid
, NULL
},
1635 {STRING_TOKEN(STR_TXT_OUT
), &gEfiSimpleTextOutProtocolGuid
, TxtOutProtocolDumpInformation
},
1636 {STRING_TOKEN(STR_SIM_POINTER
), &gEfiSimplePointerProtocolGuid
, NULL
},
1637 {STRING_TOKEN(STR_ABS_POINTER
), &gEfiAbsolutePointerProtocolGuid
, NULL
},
1638 {STRING_TOKEN(STR_SERIAL_IO
), &gEfiSerialIoProtocolGuid
, NULL
},
1639 {STRING_TOKEN(STR_GRAPHICS_OUTPUT
), &gEfiGraphicsOutputProtocolGuid
, GraphicsOutputProtocolDumpInformation
},
1640 {STRING_TOKEN(STR_EDID_DISCOVERED
), &gEfiEdidDiscoveredProtocolGuid
, EdidDiscoveredProtocolDumpInformation
},
1641 {STRING_TOKEN(STR_EDID_ACTIVE
), &gEfiEdidActiveProtocolGuid
, EdidActiveProtocolDumpInformation
},
1642 {STRING_TOKEN(STR_EDID_OVERRIDE
), &gEfiEdidOverrideProtocolGuid
, NULL
},
1643 {STRING_TOKEN(STR_CON_IN
), &gEfiConsoleInDeviceGuid
, NULL
},
1644 {STRING_TOKEN(STR_CON_OUT
), &gEfiConsoleOutDeviceGuid
, NULL
},
1645 {STRING_TOKEN(STR_STD_ERR
), &gEfiStandardErrorDeviceGuid
, NULL
},
1646 {STRING_TOKEN(STR_LOAD_FILE
), &gEfiLoadFileProtocolGuid
, NULL
},
1647 {STRING_TOKEN(STR_LOAD_FILE2
), &gEfiLoadFile2ProtocolGuid
, NULL
},
1648 {STRING_TOKEN(STR_SIMPLE_FILE_SYS
), &gEfiSimpleFileSystemProtocolGuid
, NULL
},
1649 {STRING_TOKEN(STR_TAPE_IO
), &gEfiTapeIoProtocolGuid
, NULL
},
1650 {STRING_TOKEN(STR_DISK_IO
), &gEfiDiskIoProtocolGuid
, NULL
},
1651 {STRING_TOKEN(STR_BLK_IO
), &gEfiBlockIoProtocolGuid
, NULL
},
1652 {STRING_TOKEN(STR_UC
), &gEfiUnicodeCollationProtocolGuid
, NULL
},
1653 {STRING_TOKEN(STR_UC2
), &gEfiUnicodeCollation2ProtocolGuid
, NULL
},
1654 {STRING_TOKEN(STR_PCIRB_IO
), &gEfiPciRootBridgeIoProtocolGuid
, PciRootBridgeIoDumpInformation
},
1655 {STRING_TOKEN(STR_PCI_IO
), &gEfiPciIoProtocolGuid
, NULL
},
1656 {STRING_TOKEN(STR_SCSI_PT
), &gEfiScsiPassThruProtocolGuid
, NULL
},
1657 {STRING_TOKEN(STR_SCSI_IO
), &gEfiScsiIoProtocolGuid
, NULL
},
1658 {STRING_TOKEN(STR_SCSI_PT_EXT
), &gEfiExtScsiPassThruProtocolGuid
, NULL
},
1659 {STRING_TOKEN(STR_ISCSI
), &gEfiIScsiInitiatorNameProtocolGuid
, NULL
},
1660 {STRING_TOKEN(STR_USB_IO
), &gEfiUsbIoProtocolGuid
, NULL
},
1661 {STRING_TOKEN(STR_USB_HC
), &gEfiUsbHcProtocolGuid
, NULL
},
1662 {STRING_TOKEN(STR_USB_HC2
), &gEfiUsb2HcProtocolGuid
, NULL
},
1663 {STRING_TOKEN(STR_DEBUG_SUPPORT
), &gEfiDebugSupportProtocolGuid
, NULL
},
1664 {STRING_TOKEN(STR_DEBUG_PORT
), &gEfiDebugPortProtocolGuid
, NULL
},
1665 {STRING_TOKEN(STR_DECOMPRESS
), &gEfiDecompressProtocolGuid
, NULL
},
1666 {STRING_TOKEN(STR_ACPI_TABLE
), &gEfiAcpiTableProtocolGuid
, NULL
},
1667 {STRING_TOKEN(STR_EBC_INTERPRETER
), &gEfiEbcProtocolGuid
, NULL
},
1668 {STRING_TOKEN(STR_SNP
), &gEfiSimpleNetworkProtocolGuid
, NULL
},
1669 {STRING_TOKEN(STR_NII
), &gEfiNetworkInterfaceIdentifierProtocolGuid
, NULL
},
1670 {STRING_TOKEN(STR_NII_31
), &gEfiNetworkInterfaceIdentifierProtocolGuid_31
, NULL
},
1671 {STRING_TOKEN(STR_PXE_BC
), &gEfiPxeBaseCodeProtocolGuid
, NULL
},
1672 {STRING_TOKEN(STR_PXE_CB
), &gEfiPxeBaseCodeCallbackProtocolGuid
, NULL
},
1673 {STRING_TOKEN(STR_BIS
), &gEfiBisProtocolGuid
, NULL
},
1674 {STRING_TOKEN(STR_MNP_SB
), &gEfiManagedNetworkServiceBindingProtocolGuid
, NULL
},
1675 {STRING_TOKEN(STR_MNP
), &gEfiManagedNetworkProtocolGuid
, NULL
},
1676 {STRING_TOKEN(STR_ARP_SB
), &gEfiArpServiceBindingProtocolGuid
, NULL
},
1677 {STRING_TOKEN(STR_ARP
), &gEfiArpProtocolGuid
, NULL
},
1678 {STRING_TOKEN(STR_DHCPV4_SB
), &gEfiDhcp4ServiceBindingProtocolGuid
, NULL
},
1679 {STRING_TOKEN(STR_DHCPV4
), &gEfiDhcp4ProtocolGuid
, NULL
},
1680 {STRING_TOKEN(STR_TCPV4_SB
), &gEfiTcp4ServiceBindingProtocolGuid
, NULL
},
1681 {STRING_TOKEN(STR_TCPV4
), &gEfiTcp4ProtocolGuid
, NULL
},
1682 {STRING_TOKEN(STR_IPV4_SB
), &gEfiIp4ServiceBindingProtocolGuid
, NULL
},
1683 {STRING_TOKEN(STR_IPV4
), &gEfiIp4ProtocolGuid
, NULL
},
1684 {STRING_TOKEN(STR_IPV4_CFG
), &gEfiIp4ConfigProtocolGuid
, NULL
},
1685 {STRING_TOKEN(STR_IPV4_CFG2
), &gEfiIp4Config2ProtocolGuid
, NULL
},
1686 {STRING_TOKEN(STR_UDPV4_SB
), &gEfiUdp4ServiceBindingProtocolGuid
, NULL
},
1687 {STRING_TOKEN(STR_UDPV4
), &gEfiUdp4ProtocolGuid
, NULL
},
1688 {STRING_TOKEN(STR_MTFTPV4_SB
), &gEfiMtftp4ServiceBindingProtocolGuid
, NULL
},
1689 {STRING_TOKEN(STR_MTFTPV4
), &gEfiMtftp4ProtocolGuid
, NULL
},
1690 {STRING_TOKEN(STR_AUTH_INFO
), &gEfiAuthenticationInfoProtocolGuid
, NULL
},
1691 {STRING_TOKEN(STR_HASH_SB
), &gEfiHashServiceBindingProtocolGuid
, NULL
},
1692 {STRING_TOKEN(STR_HASH
), &gEfiHashProtocolGuid
, NULL
},
1693 {STRING_TOKEN(STR_HII_FONT
), &gEfiHiiFontProtocolGuid
, NULL
},
1694 {STRING_TOKEN(STR_HII_STRING
), &gEfiHiiStringProtocolGuid
, NULL
},
1695 {STRING_TOKEN(STR_HII_IMAGE
), &gEfiHiiImageProtocolGuid
, NULL
},
1696 {STRING_TOKEN(STR_HII_DATABASE
), &gEfiHiiDatabaseProtocolGuid
, NULL
},
1697 {STRING_TOKEN(STR_HII_CONFIG_ROUT
), &gEfiHiiConfigRoutingProtocolGuid
, NULL
},
1698 {STRING_TOKEN(STR_HII_CONFIG_ACC
), &gEfiHiiConfigAccessProtocolGuid
, NULL
},
1699 {STRING_TOKEN(STR_HII_FORM_BROWSER2
), &gEfiFormBrowser2ProtocolGuid
, NULL
},
1700 {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE
), &gEfiDriverFamilyOverrideProtocolGuid
, NULL
},
1701 {STRING_TOKEN(STR_PCD
), &gPcdProtocolGuid
, NULL
},
1702 {STRING_TOKEN(STR_TCG
), &gEfiTcgProtocolGuid
, NULL
},
1703 {STRING_TOKEN(STR_HII_PACKAGE_LIST
), &gEfiHiiPackageListProtocolGuid
, NULL
},
1706 // the ones under this are deprecated by the current UEFI Spec, but may be found anyways...
1708 {STRING_TOKEN(STR_SHELL_INTERFACE
), &gEfiShellInterfaceGuid
, NULL
},
1709 {STRING_TOKEN(STR_SHELL_ENV2
), &gEfiShellEnvironment2Guid
, NULL
},
1710 {STRING_TOKEN(STR_SHELL_ENV
), &gEfiShellEnvironment2Guid
, NULL
},
1711 {STRING_TOKEN(STR_DEVICE_IO
), &gEfiDeviceIoProtocolGuid
, NULL
},
1712 {STRING_TOKEN(STR_UGA_DRAW
), &gEfiUgaDrawProtocolGuid
, NULL
},
1713 {STRING_TOKEN(STR_UGA_IO
), &gEfiUgaIoProtocolGuid
, NULL
},
1714 {STRING_TOKEN(STR_ESP
), &gEfiPartTypeSystemPartGuid
, NULL
},
1715 {STRING_TOKEN(STR_GPT_NBR
), &gEfiPartTypeLegacyMbrGuid
, NULL
},
1716 {STRING_TOKEN(STR_DRIVER_CONFIG
), &gEfiDriverConfigurationProtocolGuid
, NULL
},
1717 {STRING_TOKEN(STR_DRIVER_CONFIG2
), &gEfiDriverConfiguration2ProtocolGuid
, NULL
},
1720 // these are using local (non-global) definitions to reduce package dependancy.
1722 {STRING_TOKEN(STR_ISA_IO
), (EFI_GUID
*)&EfiIsaIoProtocolGuid
, NULL
},
1723 {STRING_TOKEN(STR_ISA_ACPI
), (EFI_GUID
*)&EfiIsaAcpiProtocolGuid
, NULL
},
1726 // the ones under this are GUID identified structs, not protocols
1728 {STRING_TOKEN(STR_FILE_INFO
), &gEfiFileInfoGuid
, NULL
},
1729 {STRING_TOKEN(STR_FILE_SYS_INFO
), &gEfiFileSystemInfoGuid
, NULL
},
1732 // the ones under this are misc GUIDS.
1734 {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE
), &gEfiGlobalVariableGuid
, NULL
},
1739 {STRING_TOKEN(STR_IP6_SB
), &gEfiIp6ServiceBindingProtocolGuid
, NULL
},
1740 {STRING_TOKEN(STR_IP6
), &gEfiIp6ProtocolGuid
, NULL
},
1741 {STRING_TOKEN(STR_IP6_CONFIG
), &gEfiIp6ConfigProtocolGuid
, NULL
},
1742 {STRING_TOKEN(STR_MTFTP6_SB
), &gEfiMtftp6ServiceBindingProtocolGuid
, NULL
},
1743 {STRING_TOKEN(STR_MTFTP6
), &gEfiMtftp6ProtocolGuid
, NULL
},
1744 {STRING_TOKEN(STR_DHCP6_SB
), &gEfiDhcp6ServiceBindingProtocolGuid
, NULL
},
1745 {STRING_TOKEN(STR_DHCP6
), &gEfiDhcp6ProtocolGuid
, NULL
},
1746 {STRING_TOKEN(STR_UDP6_SB
), &gEfiUdp6ServiceBindingProtocolGuid
, NULL
},
1747 {STRING_TOKEN(STR_UDP6
), &gEfiUdp6ProtocolGuid
, NULL
},
1748 {STRING_TOKEN(STR_TCP6_SB
), &gEfiTcp6ServiceBindingProtocolGuid
, NULL
},
1749 {STRING_TOKEN(STR_TCP6
), &gEfiTcp6ProtocolGuid
, NULL
},
1750 {STRING_TOKEN(STR_VLAN_CONFIG
), &gEfiVlanConfigProtocolGuid
, NULL
},
1751 {STRING_TOKEN(STR_EAP
), &gEfiEapProtocolGuid
, NULL
},
1752 {STRING_TOKEN(STR_EAP_MGMT
), &gEfiEapManagementProtocolGuid
, NULL
},
1753 {STRING_TOKEN(STR_FTP4_SB
), &gEfiFtp4ServiceBindingProtocolGuid
, NULL
},
1754 {STRING_TOKEN(STR_FTP4
), &gEfiFtp4ProtocolGuid
, NULL
},
1755 {STRING_TOKEN(STR_IP_SEC_CONFIG
), &gEfiIpSecConfigProtocolGuid
, NULL
},
1756 {STRING_TOKEN(STR_DH
), &gEfiDriverHealthProtocolGuid
, NULL
},
1757 {STRING_TOKEN(STR_DEF_IMG_LOAD
), &gEfiDeferredImageLoadProtocolGuid
, NULL
},
1758 {STRING_TOKEN(STR_USER_CRED
), &gEfiUserCredentialProtocolGuid
, NULL
},
1759 {STRING_TOKEN(STR_USER_MNGR
), &gEfiUserManagerProtocolGuid
, NULL
},
1760 {STRING_TOKEN(STR_ATA_PASS_THRU
), &gEfiAtaPassThruProtocolGuid
, NULL
},
1765 {STRING_TOKEN(STR_FW_MGMT
), &gEfiFirmwareManagementProtocolGuid
, FirmwareManagementDumpInformation
},
1766 {STRING_TOKEN(STR_IP_SEC
), &gEfiIpSecProtocolGuid
, NULL
},
1767 {STRING_TOKEN(STR_IP_SEC2
), &gEfiIpSec2ProtocolGuid
, NULL
},
1772 {STRING_TOKEN(STR_KMS
), &gEfiKmsProtocolGuid
, NULL
},
1773 {STRING_TOKEN(STR_BLK_IO2
), &gEfiBlockIo2ProtocolGuid
, NULL
},
1774 {STRING_TOKEN(STR_SSC
), &gEfiStorageSecurityCommandProtocolGuid
, NULL
},
1775 {STRING_TOKEN(STR_UCRED2
), &gEfiUserCredential2ProtocolGuid
, NULL
},
1780 {STRING_TOKEN(STR_DISK_IO2
), &gEfiDiskIo2ProtocolGuid
, NULL
},
1781 {STRING_TOKEN(STR_ADAPTER_INFO
), &gEfiAdapterInformationProtocolGuid
, AdapterInformationDumpInformation
},
1786 {STRING_TOKEN(STR_IDE_CONT_INIT
), &gEfiIdeControllerInitProtocolGuid
, NULL
},
1787 {STRING_TOKEN(STR_DISK_INFO
), &gEfiDiskInfoProtocolGuid
, NULL
},
1792 {STRING_TOKEN(STR_BDS_ARCH
), &gEfiBdsArchProtocolGuid
, NULL
},
1793 {STRING_TOKEN(STR_CPU_ARCH
), &gEfiCpuArchProtocolGuid
, NULL
},
1794 {STRING_TOKEN(STR_MET_ARCH
), &gEfiMetronomeArchProtocolGuid
, NULL
},
1795 {STRING_TOKEN(STR_MON_ARCH
), &gEfiMonotonicCounterArchProtocolGuid
, NULL
},
1796 {STRING_TOKEN(STR_RTC_ARCH
), &gEfiRealTimeClockArchProtocolGuid
, NULL
},
1797 {STRING_TOKEN(STR_RESET_ARCH
), &gEfiResetArchProtocolGuid
, NULL
},
1798 {STRING_TOKEN(STR_RT_ARCH
), &gEfiRuntimeArchProtocolGuid
, NULL
},
1799 {STRING_TOKEN(STR_SEC_ARCH
), &gEfiSecurityArchProtocolGuid
, NULL
},
1800 {STRING_TOKEN(STR_TIMER_ARCH
), &gEfiTimerArchProtocolGuid
, NULL
},
1801 {STRING_TOKEN(STR_VAR_ARCH
), &gEfiVariableWriteArchProtocolGuid
, NULL
},
1802 {STRING_TOKEN(STR_V_ARCH
), &gEfiVariableArchProtocolGuid
, NULL
},
1803 {STRING_TOKEN(STR_SECP
), &gEfiSecurityPolicyProtocolGuid
, NULL
},
1804 {STRING_TOKEN(STR_WDT_ARCH
), &gEfiWatchdogTimerArchProtocolGuid
, NULL
},
1805 {STRING_TOKEN(STR_SCR
), &gEfiStatusCodeRuntimeProtocolGuid
, NULL
},
1806 {STRING_TOKEN(STR_SMB_HC
), &gEfiSmbusHcProtocolGuid
, NULL
},
1807 {STRING_TOKEN(STR_FV_2
), &gEfiFirmwareVolume2ProtocolGuid
, NULL
},
1808 {STRING_TOKEN(STR_FV_BLOCK
), &gEfiFirmwareVolumeBlockProtocolGuid
, NULL
},
1809 {STRING_TOKEN(STR_CAP_ARCH
), &gEfiCapsuleArchProtocolGuid
, NULL
},
1810 {STRING_TOKEN(STR_MP_SERVICE
), &gEfiMpServiceProtocolGuid
, NULL
},
1811 {STRING_TOKEN(STR_HBRAP
), &gEfiPciHostBridgeResourceAllocationProtocolGuid
, NULL
},
1812 {STRING_TOKEN(STR_PCIP
), &gEfiPciPlatformProtocolGuid
, NULL
},
1813 {STRING_TOKEN(STR_PCIO
), &gEfiPciOverrideProtocolGuid
, NULL
},
1814 {STRING_TOKEN(STR_PCIE
), &gEfiPciEnumerationCompleteProtocolGuid
, NULL
},
1815 {STRING_TOKEN(STR_IPCID
), &gEfiIncompatiblePciDeviceSupportProtocolGuid
, NULL
},
1816 {STRING_TOKEN(STR_PCIHPI
), &gEfiPciHotPlugInitProtocolGuid
, NULL
},
1817 {STRING_TOKEN(STR_PCIHPR
), &gEfiPciHotPlugRequestProtocolGuid
, NULL
},
1818 {STRING_TOKEN(STR_SMBIOS
), &gEfiSmbiosProtocolGuid
, NULL
},
1819 {STRING_TOKEN(STR_S3_SAVE
), &gEfiS3SaveStateProtocolGuid
, NULL
},
1820 {STRING_TOKEN(STR_S3_S_SMM
), &gEfiS3SmmSaveStateProtocolGuid
, NULL
},
1821 {STRING_TOKEN(STR_RSC
), &gEfiRscHandlerProtocolGuid
, NULL
},
1822 {STRING_TOKEN(STR_S_RSC
), &gEfiSmmRscHandlerProtocolGuid
, NULL
},
1823 {STRING_TOKEN(STR_ACPI_SDT
), &gEfiAcpiSdtProtocolGuid
, NULL
},
1824 {STRING_TOKEN(STR_SIO
), &gEfiSioProtocolGuid
, NULL
},
1825 {STRING_TOKEN(STR_S_CPU2
), &gEfiSmmCpuIo2ProtocolGuid
, NULL
},
1826 {STRING_TOKEN(STR_S_BASE2
), &gEfiSmmBase2ProtocolGuid
, NULL
},
1827 {STRING_TOKEN(STR_S_ACC_2
), &gEfiSmmAccess2ProtocolGuid
, NULL
},
1828 {STRING_TOKEN(STR_S_CON_2
), &gEfiSmmControl2ProtocolGuid
, NULL
},
1829 {STRING_TOKEN(STR_S_CONFIG
), &gEfiSmmConfigurationProtocolGuid
, NULL
},
1830 {STRING_TOKEN(STR_S_RTL
), &gEfiSmmReadyToLockProtocolGuid
, NULL
},
1831 {STRING_TOKEN(STR_DS_RTL
), &gEfiDxeSmmReadyToLockProtocolGuid
, NULL
},
1832 {STRING_TOKEN(STR_S_COMM
), &gEfiSmmCommunicationProtocolGuid
, NULL
},
1833 {STRING_TOKEN(STR_S_STAT
), &gEfiSmmStatusCodeProtocolGuid
, NULL
},
1834 {STRING_TOKEN(STR_S_CPU
), &gEfiSmmCpuProtocolGuid
, NULL
},
1835 {STRING_TOKEN(STR_S_PCIRBIO
), &gEfiPciRootBridgeIoProtocolGuid
, NULL
},
1836 {STRING_TOKEN(STR_S_SWD
), &gEfiSmmSwDispatch2ProtocolGuid
, NULL
},
1837 {STRING_TOKEN(STR_S_SXD
), &gEfiSmmSxDispatch2ProtocolGuid
, NULL
},
1838 {STRING_TOKEN(STR_S_PTD2
), &gEfiSmmPeriodicTimerDispatch2ProtocolGuid
, NULL
},
1839 {STRING_TOKEN(STR_S_UD2
), &gEfiSmmUsbDispatch2ProtocolGuid
, NULL
},
1840 {STRING_TOKEN(STR_S_GD2
), &gEfiSmmGpiDispatch2ProtocolGuid
, NULL
},
1841 {STRING_TOKEN(STR_S_SBD2
), &gEfiSmmStandbyButtonDispatch2ProtocolGuid
, NULL
},
1842 {STRING_TOKEN(STR_S_PBD2
), &gEfiSmmPowerButtonDispatch2ProtocolGuid
, NULL
},
1843 {STRING_TOKEN(STR_S_ITD2
), &gEfiSmmIoTrapDispatch2ProtocolGuid
, NULL
},
1844 {STRING_TOKEN(STR_PCD
), &gEfiPcdProtocolGuid
, NULL
},
1845 {STRING_TOKEN(STR_FVB2
), &gEfiFirmwareVolumeBlock2ProtocolGuid
, NULL
},
1846 {STRING_TOKEN(STR_CPUIO2
), &gEfiCpuIo2ProtocolGuid
, NULL
},
1847 {STRING_TOKEN(STR_LEGACY_R2
), &gEfiLegacyRegion2ProtocolGuid
, NULL
},
1848 {STRING_TOKEN(STR_SAL_MIP
), &gEfiSalMcaInitPmiProtocolGuid
, NULL
},
1849 {STRING_TOKEN(STR_ES_BS
), &gEfiExtendedSalBootServiceProtocolGuid
, NULL
},
1850 {STRING_TOKEN(STR_ES_BIO
), &gEfiExtendedSalBaseIoServicesProtocolGuid
, NULL
},
1851 {STRING_TOKEN(STR_ES_STALL
), &gEfiExtendedSalStallServicesProtocolGuid
, NULL
},
1852 {STRING_TOKEN(STR_ES_RTC
), &gEfiExtendedSalRtcServicesProtocolGuid
, NULL
},
1853 {STRING_TOKEN(STR_ES_VS
), &gEfiExtendedSalVariableServicesProtocolGuid
, NULL
},
1854 {STRING_TOKEN(STR_ES_MTC
), &gEfiExtendedSalMtcServicesProtocolGuid
, NULL
},
1855 {STRING_TOKEN(STR_ES_RESET
), &gEfiExtendedSalResetServicesProtocolGuid
, NULL
},
1856 {STRING_TOKEN(STR_ES_SC
), &gEfiExtendedSalStatusCodeServicesProtocolGuid
, NULL
},
1857 {STRING_TOKEN(STR_ES_FBS
), &gEfiExtendedSalFvBlockServicesProtocolGuid
, NULL
},
1858 {STRING_TOKEN(STR_ES_MP
), &gEfiExtendedSalMpServicesProtocolGuid
, NULL
},
1859 {STRING_TOKEN(STR_ES_PAL
), &gEfiExtendedSalPalServicesProtocolGuid
, NULL
},
1860 {STRING_TOKEN(STR_ES_BASE
), &gEfiExtendedSalBaseServicesProtocolGuid
, NULL
},
1861 {STRING_TOKEN(STR_ES_MCA
), &gEfiExtendedSalMcaServicesProtocolGuid
, NULL
},
1862 {STRING_TOKEN(STR_ES_PCI
), &gEfiExtendedSalPciServicesProtocolGuid
, NULL
},
1863 {STRING_TOKEN(STR_ES_CACHE
), &gEfiExtendedSalCacheServicesProtocolGuid
, NULL
},
1864 {STRING_TOKEN(STR_ES_MCA_LOG
), &gEfiExtendedSalMcaLogServicesProtocolGuid
, NULL
},
1865 {STRING_TOKEN(STR_S2ARCH
), &gEfiSecurity2ArchProtocolGuid
, NULL
},
1866 {STRING_TOKEN(STR_EODXE
), &gEfiSmmEndOfDxeProtocolGuid
, NULL
},
1867 {STRING_TOKEN(STR_ISAHC
), &gEfiIsaHcProtocolGuid
, NULL
},
1868 {STRING_TOKEN(STR_ISAHC_B
), &gEfiIsaHcServiceBindingProtocolGuid
, NULL
},
1869 {STRING_TOKEN(STR_SIO_C
), &gEfiSioControlProtocolGuid
, NULL
},
1870 {STRING_TOKEN(STR_GET_PCD
), &gEfiGetPcdInfoProtocolGuid
, NULL
},
1871 {STRING_TOKEN(STR_I2C_M
), &gEfiI2cMasterProtocolGuid
, NULL
},
1872 {STRING_TOKEN(STR_I2CIO
), &gEfiI2cIoProtocolGuid
, NULL
},
1873 {STRING_TOKEN(STR_I2CEN
), &gEfiI2cEnumerateProtocolGuid
, NULL
},
1874 {STRING_TOKEN(STR_I2C_H
), &gEfiI2cHostProtocolGuid
, NULL
},
1875 {STRING_TOKEN(STR_I2C_BCM
), &gEfiI2cBusConfigurationManagementProtocolGuid
, NULL
},
1876 {STRING_TOKEN(STR_TREE
), &gEfiTrEEProtocolGuid
, NULL
},
1877 {STRING_TOKEN(STR_TCG2
), &gEfiTcg2ProtocolGuid
, NULL
},
1878 {STRING_TOKEN(STR_TIMESTAMP
), &gEfiTimestampProtocolGuid
, NULL
},
1879 {STRING_TOKEN(STR_RNG
), &gEfiRngProtocolGuid
, NULL
},
1880 {STRING_TOKEN(STR_NVMEPT
), &gEfiNvmExpressPassThruProtocolGuid
, NULL
},
1881 {STRING_TOKEN(STR_H2_SB
), &gEfiHash2ServiceBindingProtocolGuid
, NULL
},
1882 {STRING_TOKEN(STR_HASH2
), &gEfiHash2ProtocolGuid
, NULL
},
1883 {STRING_TOKEN(STR_BIO_C
), &gEfiBlockIoCryptoProtocolGuid
, NULL
},
1884 {STRING_TOKEN(STR_SCR
), &gEfiSmartCardReaderProtocolGuid
, NULL
},
1885 {STRING_TOKEN(STR_SCE
), &gEfiSmartCardEdgeProtocolGuid
, NULL
},
1886 {STRING_TOKEN(STR_USB_FIO
), &gEfiUsbFunctionIoProtocolGuid
, NULL
},
1887 {STRING_TOKEN(STR_BC_HC
), &gEfiBluetoothHcProtocolGuid
, NULL
},
1888 {STRING_TOKEN(STR_BC_IO_SB
), &gEfiBluetoothIoServiceBindingProtocolGuid
, NULL
},
1889 {STRING_TOKEN(STR_BC_IO
), &gEfiBluetoothIoProtocolGuid
, NULL
},
1890 {STRING_TOKEN(STR_BC_C
), &gEfiBluetoothConfigProtocolGuid
, NULL
},
1891 {STRING_TOKEN(STR_REG_EXP
), &gEfiRegularExpressionProtocolGuid
, NULL
},
1892 {STRING_TOKEN(STR_B_MGR_P
), &gEfiBootManagerPolicyProtocolGuid
, NULL
},
1893 {STRING_TOKEN(STR_CKH
), &gEfiConfigKeywordHandlerProtocolGuid
, NULL
},
1894 {STRING_TOKEN(STR_WIFI
), &gEfiWiFiProtocolGuid
, NULL
},
1895 {STRING_TOKEN(STR_EAP_M
), &gEfiEapManagement2ProtocolGuid
, NULL
},
1896 {STRING_TOKEN(STR_EAP_C
), &gEfiEapConfigurationProtocolGuid
, NULL
},
1897 {STRING_TOKEN(STR_PKCS7
), &gEfiPkcs7VerifyProtocolGuid
, NULL
},
1898 {STRING_TOKEN(STR_NET_DNS4_SB
), &gEfiDns4ServiceBindingProtocolGuid
, NULL
},
1899 {STRING_TOKEN(STR_NET_DNS4
), &gEfiDns4ProtocolGuid
, NULL
},
1900 {STRING_TOKEN(STR_NET_DNS6_SB
), &gEfiDns6ServiceBindingProtocolGuid
, NULL
},
1901 {STRING_TOKEN(STR_NET_DNS6
), &gEfiDns6ProtocolGuid
, NULL
},
1902 {STRING_TOKEN(STR_NET_HTTP_SB
), &gEfiHttpServiceBindingProtocolGuid
, NULL
},
1903 {STRING_TOKEN(STR_NET_HTTP
), &gEfiHttpProtocolGuid
, NULL
},
1904 {STRING_TOKEN(STR_NET_HTTP_U
), &gEfiHttpUtilitiesProtocolGuid
, NULL
},
1905 {STRING_TOKEN(STR_REST
), &gEfiRestProtocolGuid
, NULL
},
1908 // UEFI Shell Spec 2.0
1910 {STRING_TOKEN(STR_SHELL_PARAMETERS
), &gEfiShellParametersProtocolGuid
, NULL
},
1911 {STRING_TOKEN(STR_SHELL
), &gEfiShellProtocolGuid
, NULL
},
1914 // UEFI Shell Spec 2.1
1916 {STRING_TOKEN(STR_SHELL_DYNAMIC
), &gEfiShellDynamicCommandProtocolGuid
, NULL
},
1921 {STRING_TOKEN(STR_PCDINFOPROT
), &gGetPcdInfoProtocolGuid
, NULL
},
1930 Function to get the node for a protocol or struct from it's GUID.
1932 if Guid is NULL, then ASSERT.
1934 @param[in] Guid The GUID to look for the name of.
1938 CONST GUID_INFO_BLOCK
*
1939 InternalShellGetNodeFromGuid(
1940 IN CONST EFI_GUID
* Guid
1943 CONST GUID_INFO_BLOCK
*ListWalker
;
1946 ASSERT(Guid
!= NULL
);
1948 for (LoopCount
= 0, ListWalker
= mGuidList
; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++, ListWalker
++) {
1949 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1950 return (ListWalker
);
1954 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
1955 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1956 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1957 return (ListWalker
);
1961 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1962 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1963 return (ListWalker
);
1970 Function to add a new GUID/Name mapping.
1972 @param[in] Guid The Guid
1973 @param[in] NameID The STRING id of the HII string to use
1974 @param[in] DumpFunc The pointer to the dump function
1977 @retval EFI_SUCCESS The operation was sucessful
1978 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1979 @retval EFI_INVALID_PARAMETER Guid NameId was invalid
1982 InsertNewGuidNameMapping(
1983 IN CONST EFI_GUID
*Guid
,
1984 IN CONST EFI_STRING_ID NameID
,
1985 IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
1988 ASSERT(Guid
!= NULL
);
1989 ASSERT(NameID
!= 0);
1991 mGuidList
= ReallocatePool(mGuidListCount
* sizeof(GUID_INFO_BLOCK
), mGuidListCount
+1 * sizeof(GUID_INFO_BLOCK
), mGuidList
);
1992 if (mGuidList
== NULL
) {
1994 return (EFI_OUT_OF_RESOURCES
);
1998 mGuidList
[mGuidListCount
- 1].GuidId
= AllocateCopyPool(sizeof(EFI_GUID
), Guid
);
1999 mGuidList
[mGuidListCount
- 1].StringId
= NameID
;
2000 mGuidList
[mGuidListCount
- 1].DumpInfo
= DumpFunc
;
2002 if (mGuidList
[mGuidListCount
- 1].GuidId
== NULL
) {
2003 return (EFI_OUT_OF_RESOURCES
);
2006 return (EFI_SUCCESS
);
2010 Function to add a new GUID/Name mapping.
2012 This cannot overwrite an existing mapping.
2014 @param[in] Guid The Guid
2015 @param[in] TheName The Guid's name
2016 @param[in] Lang RFC4646 language code list or NULL
2018 @retval EFI_SUCCESS The operation was sucessful
2019 @retval EFI_ACCESS_DENIED There was a duplicate
2020 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
2021 @retval EFI_INVALID_PARAMETER Guid or TheName was NULL
2025 AddNewGuidNameMapping(
2026 IN CONST EFI_GUID
*Guid
,
2027 IN CONST CHAR16
*TheName
,
2028 IN CONST CHAR8
*Lang OPTIONAL
2031 EFI_STRING_ID NameID
;
2033 HandleParsingHiiInit();
2035 if (Guid
== NULL
|| TheName
== NULL
){
2036 return (EFI_INVALID_PARAMETER
);
2039 if ((InternalShellGetNodeFromGuid(Guid
)) != NULL
) {
2040 return (EFI_ACCESS_DENIED
);
2043 NameID
= HiiSetString(mHandleParsingHiiHandle
, 0, (CHAR16
*)TheName
, Lang
);
2045 return (EFI_OUT_OF_RESOURCES
);
2048 return (InsertNewGuidNameMapping(Guid
, NameID
, NULL
));
2052 Function to get the name of a protocol or struct from it's GUID.
2054 if Guid is NULL, then ASSERT.
2056 @param[in] Guid The GUID to look for the name of.
2057 @param[in] Lang The language to use.
2059 @return pointer to string of the name. The caller
2060 is responsible to free this memory.
2064 GetStringNameFromGuid(
2065 IN CONST EFI_GUID
*Guid
,
2066 IN CONST CHAR8
*Lang OPTIONAL
2069 CONST GUID_INFO_BLOCK
*Id
;
2071 HandleParsingHiiInit();
2073 Id
= InternalShellGetNodeFromGuid(Guid
);
2077 return HiiGetString (mHandleParsingHiiHandle
, Id
->StringId
, Lang
);
2081 Function to dump protocol information from a handle.
2083 This function will return a allocated string buffer containing the
2084 information. The caller is responsible for freeing the memory.
2086 If Guid is NULL, ASSERT().
2087 If TheHandle is NULL, ASSERT().
2089 @param[in] TheHandle The handle to dump information from.
2090 @param[in] Guid The GUID of the protocol to dump.
2091 @param[in] Verbose TRUE for extra info. FALSE otherwise.
2093 @return The pointer to string.
2094 @retval NULL An error was encountered.
2098 GetProtocolInformationDump(
2099 IN CONST EFI_HANDLE TheHandle
,
2100 IN CONST EFI_GUID
*Guid
,
2101 IN CONST BOOLEAN Verbose
2104 CONST GUID_INFO_BLOCK
*Id
;
2106 ASSERT(TheHandle
!= NULL
);
2107 ASSERT(Guid
!= NULL
);
2109 if (TheHandle
== NULL
|| Guid
== NULL
) {
2113 Id
= InternalShellGetNodeFromGuid(Guid
);
2114 if (Id
!= NULL
&& Id
->DumpInfo
!= NULL
) {
2115 return (Id
->DumpInfo(TheHandle
, Verbose
));
2121 Function to get the Guid for a protocol or struct based on it's string name.
2123 do not modify the returned Guid.
2125 @param[in] Name The pointer to the string name.
2126 @param[in] Lang The pointer to the language code.
2127 @param[out] Guid The pointer to the Guid.
2129 @retval EFI_SUCCESS The operation was sucessful.
2133 GetGuidFromStringName(
2134 IN CONST CHAR16
*Name
,
2135 IN CONST CHAR8
*Lang OPTIONAL
,
2139 CONST GUID_INFO_BLOCK
*ListWalker
;
2143 HandleParsingHiiInit();
2145 ASSERT(Guid
!= NULL
);
2147 return (EFI_INVALID_PARAMETER
);
2151 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
2152 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2153 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2154 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2155 *Guid
= ListWalker
->GuidId
;
2157 SHELL_FREE_NON_NULL(String
);
2158 if (*Guid
!= NULL
) {
2159 return (EFI_SUCCESS
);
2163 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
2164 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2165 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2166 *Guid
= ListWalker
->GuidId
;
2168 SHELL_FREE_NON_NULL(String
);
2169 if (*Guid
!= NULL
) {
2170 return (EFI_SUCCESS
);
2174 for (LoopCount
= 0, ListWalker
= mGuidList
; mGuidList
!= NULL
&& LoopCount
< mGuidListCount
; LoopCount
++, ListWalker
++) {
2175 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
2176 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
2177 *Guid
= ListWalker
->GuidId
;
2179 SHELL_FREE_NON_NULL(String
);
2180 if (*Guid
!= NULL
) {
2181 return (EFI_SUCCESS
);
2185 return (EFI_NOT_FOUND
);
2189 Get best support language for this driver.
2191 First base on the user input language to search, second base on the current
2192 platform used language to search, third get the first language from the
2193 support language list. The caller need to free the buffer of the best language.
2195 @param[in] SupportedLanguages The support languages for this driver.
2196 @param[in] InputLanguage The user input language.
2197 @param[in] Iso639Language Whether get language for ISO639.
2199 @return The best support language for this driver.
2203 GetBestLanguageForDriver (
2204 IN CONST CHAR8
*SupportedLanguages
,
2205 IN CONST CHAR8
*InputLanguage
,
2206 IN BOOLEAN Iso639Language
2209 CHAR8
*LanguageVariable
;
2210 CHAR8
*BestLanguage
;
2212 GetVariable2 (Iso639Language
? L
"Lang" : L
"PlatformLang", &gEfiGlobalVariableGuid
, (VOID
**)&LanguageVariable
, NULL
);
2214 BestLanguage
= GetBestLanguage(
2217 (InputLanguage
!= NULL
) ? InputLanguage
: "",
2218 (LanguageVariable
!= NULL
) ? LanguageVariable
: "",
2223 if (LanguageVariable
!= NULL
) {
2224 FreePool (LanguageVariable
);
2227 return BestLanguage
;
2231 Function to retrieve the driver name (if possible) from the ComponentName or
2232 ComponentName2 protocol
2234 @param[in] TheHandle The driver handle to get the name of.
2235 @param[in] Language The language to use.
2237 @retval NULL The name could not be found.
2238 @return A pointer to the string name. Do not de-allocate the memory.
2242 GetStringNameFromHandle(
2243 IN CONST EFI_HANDLE TheHandle
,
2244 IN CONST CHAR8
*Language
2247 EFI_COMPONENT_NAME2_PROTOCOL
*CompNameStruct
;
2254 Status
= gBS
->OpenProtocol(
2256 &gEfiComponentName2ProtocolGuid
,
2257 (VOID
**)&CompNameStruct
,
2260 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2261 if (!EFI_ERROR(Status
)) {
2262 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2263 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2264 if (BestLang
!= NULL
) {
2265 FreePool (BestLang
);
2268 if (!EFI_ERROR(Status
)) {
2272 Status
= gBS
->OpenProtocol(
2274 &gEfiComponentNameProtocolGuid
,
2275 (VOID
**)&CompNameStruct
,
2278 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
2279 if (!EFI_ERROR(Status
)) {
2280 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
2281 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
2282 if (BestLang
!= NULL
) {
2283 FreePool (BestLang
);
2285 if (!EFI_ERROR(Status
)) {
2293 Function to initialize the file global mHandleList object for use in
2294 vonverting handles to index and index to handle.
2296 @retval EFI_SUCCESS The operation was successful.
2299 InternalShellInitHandleList(
2304 EFI_HANDLE
*HandleBuffer
;
2306 HANDLE_LIST
*ListWalker
;
2308 if (mHandleList
.NextIndex
!= 0) {
2311 InitializeListHead(&mHandleList
.List
.Link
);
2312 mHandleList
.NextIndex
= 1;
2313 Status
= gBS
->LocateHandleBuffer (
2320 ASSERT_EFI_ERROR(Status
);
2321 if (EFI_ERROR(Status
)) {
2324 for (mHandleList
.NextIndex
= 1 ; mHandleList
.NextIndex
<= HandleCount
; mHandleList
.NextIndex
++){
2325 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2326 if (ListWalker
!= NULL
) {
2327 ListWalker
->TheHandle
= HandleBuffer
[mHandleList
.NextIndex
- 1];
2328 ListWalker
->TheIndex
= mHandleList
.NextIndex
;
2329 InsertTailList (&mHandleList
.List
.Link
, &ListWalker
->Link
);
2332 FreePool(HandleBuffer
);
2333 return (EFI_SUCCESS
);
2337 Function to retrieve the human-friendly index of a given handle. If the handle
2338 does not have a index one will be automatically assigned. The index value is valid
2339 until the termination of the shell application.
2341 @param[in] TheHandle The handle to retrieve an index for.
2343 @retval 0 A memory allocation failed.
2344 @return The index of the handle.
2349 ConvertHandleToHandleIndex(
2350 IN CONST EFI_HANDLE TheHandle
2354 EFI_GUID
**ProtocolBuffer
;
2355 UINTN ProtocolCount
;
2356 HANDLE_LIST
*ListWalker
;
2358 if (TheHandle
== NULL
) {
2362 InternalShellInitHandleList();
2364 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2365 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2366 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2368 if (ListWalker
->TheHandle
== TheHandle
) {
2370 // Verify that TheHandle is still present in the Handle Database
2372 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2373 if (EFI_ERROR (Status
)) {
2375 // TheHandle is not present in the Handle Database, so delete from the handle list
2377 RemoveEntryList (&ListWalker
->Link
);
2380 FreePool (ProtocolBuffer
);
2381 return (ListWalker
->TheIndex
);
2386 // Verify that TheHandle is valid handle
2388 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2389 if (EFI_ERROR (Status
)) {
2391 // TheHandle is not valid, so do not add to handle list
2395 FreePool (ProtocolBuffer
);
2397 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
2398 if (ListWalker
== NULL
) {
2401 ListWalker
->TheHandle
= TheHandle
;
2402 ListWalker
->TheIndex
= mHandleList
.NextIndex
++;
2403 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
2404 return (ListWalker
->TheIndex
);
2410 Function to retrieve the EFI_HANDLE from the human-friendly index.
2412 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.
2414 @retval NULL The index was invalid.
2415 @return The EFI_HANDLE that index represents.
2420 ConvertHandleIndexToHandle(
2421 IN CONST UINTN TheIndex
2425 EFI_GUID
**ProtocolBuffer
;
2426 UINTN ProtocolCount
;
2427 HANDLE_LIST
*ListWalker
;
2429 InternalShellInitHandleList();
2431 if (TheIndex
>= mHandleList
.NextIndex
) {
2435 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
2436 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2437 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
2439 if (ListWalker
->TheIndex
== TheIndex
&& ListWalker
->TheHandle
!= NULL
) {
2441 // Verify that LinkWalker->TheHandle is valid handle
2443 Status
= gBS
->ProtocolsPerHandle(ListWalker
->TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
2444 if (!EFI_ERROR (Status
)) {
2445 FreePool (ProtocolBuffer
);
2448 // TheHandle is not valid, so do not add to handle list
2450 ListWalker
->TheHandle
= NULL
;
2452 return (ListWalker
->TheHandle
);
2459 Gets all the related EFI_HANDLEs based on the mask supplied.
2461 This function scans all EFI_HANDLES in the UEFI environment's handle database
2462 and returns the ones with the specified relationship (Mask) to the specified
2465 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2466 If MatchingHandleCount is NULL, then ASSERT.
2468 If MatchingHandleBuffer is not NULL upon a successful return the memory must be
2471 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.
2472 @param[in] ControllerHandle The handle with Device Path protocol on it.
2473 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in
2474 MatchingHandleBuffer.
2475 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount
2476 EFI_HANDLEs with a terminating NULL EFI_HANDLE.
2477 @param[out] HandleType An array of type information.
2479 @retval EFI_SUCCESS The operation was successful, and any related handles
2480 are in MatchingHandleBuffer.
2481 @retval EFI_NOT_FOUND No matching handles were found.
2482 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2486 ParseHandleDatabaseByRelationshipWithType (
2487 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
2488 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
2489 IN UINTN
*HandleCount
,
2490 OUT EFI_HANDLE
**HandleBuffer
,
2491 OUT UINTN
**HandleType
2496 EFI_GUID
**ProtocolGuidArray
;
2498 UINTN ProtocolIndex
;
2499 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfo
;
2500 UINTN OpenInfoCount
;
2501 UINTN OpenInfoIndex
;
2503 INTN DriverBindingHandleIndex
;
2505 ASSERT(HandleCount
!= NULL
);
2506 ASSERT(HandleBuffer
!= NULL
);
2507 ASSERT(HandleType
!= NULL
);
2508 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
2511 *HandleBuffer
= NULL
;
2515 // Retrieve the list of all handles from the handle database
2517 Status
= gBS
->LocateHandleBuffer (
2524 if (EFI_ERROR (Status
)) {
2528 *HandleType
= AllocateZeroPool (*HandleCount
* sizeof (UINTN
));
2529 if (*HandleType
== NULL
) {
2530 SHELL_FREE_NON_NULL (*HandleBuffer
);
2532 return EFI_OUT_OF_RESOURCES
;
2535 DriverBindingHandleIndex
= -1;
2536 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
2537 if (DriverBindingHandle
!= NULL
&& (*HandleBuffer
)[HandleIndex
] == DriverBindingHandle
) {
2538 DriverBindingHandleIndex
= (INTN
)HandleIndex
;
2542 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
2544 // Retrieve the list of all the protocols on each handle
2546 Status
= gBS
->ProtocolsPerHandle (
2547 (*HandleBuffer
)[HandleIndex
],
2551 if (EFI_ERROR (Status
)) {
2555 for (ProtocolIndex
= 0; ProtocolIndex
< ArrayCount
; ProtocolIndex
++) {
2558 // Set the bit describing what this handle has
2560 if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiLoadedImageProtocolGuid
) ) {
2561 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_IMAGE_HANDLE
;
2562 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverBindingProtocolGuid
) ) {
2563 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_BINDING_HANDLE
;
2564 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfiguration2ProtocolGuid
)) {
2565 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
2566 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfigurationProtocolGuid
) ) {
2567 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
2568 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnostics2ProtocolGuid
) ) {
2569 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
2570 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnosticsProtocolGuid
) ) {
2571 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
2572 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentName2ProtocolGuid
) ) {
2573 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
2574 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentNameProtocolGuid
) ) {
2575 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
2576 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDevicePathProtocolGuid
) ) {
2577 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DEVICE_HANDLE
;
2580 // Retrieve the list of agents that have opened each protocol
2582 Status
= gBS
->OpenProtocolInformation (
2583 (*HandleBuffer
)[HandleIndex
],
2584 ProtocolGuidArray
[ProtocolIndex
],
2588 if (EFI_ERROR (Status
)) {
2592 if (ControllerHandle
== NULL
) {
2594 // ControllerHandle == NULL and DriverBindingHandle != NULL.
2595 // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
2597 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2598 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2599 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2600 if (DriverBindingHandleIndex
!= -1) {
2601 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2604 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2605 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2606 if (DriverBindingHandleIndex
!= -1) {
2607 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2609 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2610 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2611 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2617 if (DriverBindingHandle
== NULL
&& ControllerHandle
!= NULL
) {
2618 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
2619 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2620 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2621 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2622 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2623 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2624 (*HandleType
)[ChildIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2628 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2629 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2630 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2631 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2633 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2634 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2640 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2641 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2642 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
2643 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
2649 if (DriverBindingHandle
!= NULL
&& ControllerHandle
!= NULL
) {
2650 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
2651 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
2652 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2653 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
2654 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
2655 if (DriverBindingHandleIndex
!= -1) {
2656 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
2660 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2661 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
2662 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2663 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
2664 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
2669 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
2670 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
2671 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
2677 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
2678 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
2679 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
2680 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
2686 FreePool (OpenInfo
);
2688 FreePool (ProtocolGuidArray
);
2694 Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask
2697 This function will scan all EFI_HANDLES in the UEFI environment's handle database
2698 and return all the ones with the specified relationship (Mask) to the specified
2701 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2702 If MatchingHandleCount is NULL, then ASSERT.
2704 If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be
2707 @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol
2709 @param[in] ControllerHandle Handle to a device with Device Path protocol on it.
2710 @param[in] Mask Mask of what relationship(s) is desired.
2711 @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in
2712 MatchingHandleBuffer.
2713 @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount
2714 EFI_HANDLEs and a terminating NULL EFI_HANDLE.
2716 @retval EFI_SUCCESS The operation was sucessful and any related handles
2717 are in MatchingHandleBuffer;
2718 @retval EFI_NOT_FOUND No matching handles were found.
2719 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2723 ParseHandleDatabaseByRelationship (
2724 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
2725 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
2726 IN CONST UINTN Mask
,
2727 IN UINTN
*MatchingHandleCount
,
2728 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2733 EFI_HANDLE
*HandleBuffer
;
2737 ASSERT(MatchingHandleCount
!= NULL
);
2738 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
2740 if ((Mask
& HR_VALID_MASK
) != Mask
) {
2741 return (EFI_INVALID_PARAMETER
);
2744 if ((Mask
& HR_CHILD_HANDLE
) != 0 && DriverBindingHandle
== NULL
) {
2745 return (EFI_INVALID_PARAMETER
);
2748 *MatchingHandleCount
= 0;
2749 if (MatchingHandleBuffer
!= NULL
) {
2750 *MatchingHandleBuffer
= NULL
;
2753 HandleBuffer
= NULL
;
2756 Status
= ParseHandleDatabaseByRelationshipWithType (
2757 DriverBindingHandle
,
2763 if (!EFI_ERROR (Status
)) {
2765 // Count the number of handles that match the attributes in Mask
2767 for (HandleIndex
= 0; HandleIndex
< HandleCount
; HandleIndex
++) {
2768 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
2769 (*MatchingHandleCount
)++;
2773 // If no handles match the attributes in Mask then return EFI_NOT_FOUND
2775 if (*MatchingHandleCount
== 0) {
2776 Status
= EFI_NOT_FOUND
;
2779 if (MatchingHandleBuffer
== NULL
) {
2781 // Someone just wanted the count...
2783 Status
= EFI_SUCCESS
;
2786 // Allocate a handle buffer for the number of handles that matched the attributes in Mask
2788 *MatchingHandleBuffer
= AllocateZeroPool ((*MatchingHandleCount
+1)* sizeof (EFI_HANDLE
));
2789 if (*MatchingHandleBuffer
== NULL
) {
2790 Status
= EFI_OUT_OF_RESOURCES
;
2792 for (HandleIndex
= 0, *MatchingHandleCount
= 0
2793 ; HandleIndex
< HandleCount
2797 // Fill the allocated buffer with the handles that matched the attributes in Mask
2799 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
2800 (*MatchingHandleBuffer
)[(*MatchingHandleCount
)++] = HandleBuffer
[HandleIndex
];
2805 // Make the last one NULL
2807 (*MatchingHandleBuffer
)[*MatchingHandleCount
] = NULL
;
2809 Status
= EFI_SUCCESS
;
2810 } // *MatchingHandleBuffer == NULL (ELSE)
2811 } // MacthingHandleBuffer == NULL (ELSE)
2812 } // *MatchingHandleCount == 0 (ELSE)
2813 } // no error on ParseHandleDatabaseByRelationshipWithType
2815 if (HandleBuffer
!= NULL
) {
2816 FreePool (HandleBuffer
);
2819 if (HandleType
!= NULL
) {
2820 FreePool (HandleType
);
2823 ASSERT ((MatchingHandleBuffer
== NULL
) ||
2824 (*MatchingHandleCount
== 0 && *MatchingHandleBuffer
== NULL
) ||
2825 (*MatchingHandleCount
!= 0 && *MatchingHandleBuffer
!= NULL
));
2830 Gets handles for any child controllers of the passed in controller.
2832 @param[in] ControllerHandle The handle of the "parent controller"
2833 @param[out] MatchingHandleCount Pointer to the number of handles in
2834 MatchingHandleBuffer on return.
2835 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2839 @retval EFI_SUCCESS The operation was sucessful.
2843 ParseHandleDatabaseForChildControllers(
2844 IN CONST EFI_HANDLE ControllerHandle
,
2845 OUT UINTN
*MatchingHandleCount
,
2846 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2851 UINTN DriverBindingHandleCount
;
2852 EFI_HANDLE
*DriverBindingHandleBuffer
;
2853 UINTN DriverBindingHandleIndex
;
2854 UINTN ChildControllerHandleCount
;
2855 EFI_HANDLE
*ChildControllerHandleBuffer
;
2856 UINTN ChildControllerHandleIndex
;
2857 EFI_HANDLE
*HandleBufferForReturn
;
2859 if (MatchingHandleCount
== NULL
) {
2860 return (EFI_INVALID_PARAMETER
);
2862 *MatchingHandleCount
= 0;
2864 Status
= PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
2866 &DriverBindingHandleCount
,
2867 &DriverBindingHandleBuffer
2869 if (EFI_ERROR (Status
)) {
2874 // Get a buffer big enough for all the controllers.
2876 HandleBufferForReturn
= GetHandleListByProtocol(NULL
);
2877 if (HandleBufferForReturn
== NULL
) {
2878 FreePool (DriverBindingHandleBuffer
);
2879 return (EFI_NOT_FOUND
);
2882 for (DriverBindingHandleIndex
= 0; DriverBindingHandleIndex
< DriverBindingHandleCount
; DriverBindingHandleIndex
++) {
2883 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
2884 DriverBindingHandleBuffer
[DriverBindingHandleIndex
],
2886 &ChildControllerHandleCount
,
2887 &ChildControllerHandleBuffer
2889 if (EFI_ERROR (Status
)) {
2893 for (ChildControllerHandleIndex
= 0;
2894 ChildControllerHandleIndex
< ChildControllerHandleCount
;
2895 ChildControllerHandleIndex
++
2897 for (HandleIndex
= 0; HandleIndex
< *MatchingHandleCount
; HandleIndex
++) {
2898 if (HandleBufferForReturn
[HandleIndex
] == ChildControllerHandleBuffer
[ChildControllerHandleIndex
]) {
2902 if (HandleIndex
>= *MatchingHandleCount
) {
2903 HandleBufferForReturn
[(*MatchingHandleCount
)++] = ChildControllerHandleBuffer
[ChildControllerHandleIndex
];
2907 FreePool (ChildControllerHandleBuffer
);
2910 FreePool (DriverBindingHandleBuffer
);
2912 if (MatchingHandleBuffer
== NULL
|| *MatchingHandleCount
== 0) {
2914 // The caller is not interested in the actual handles, or we've found none.
2916 FreePool (HandleBufferForReturn
);
2917 HandleBufferForReturn
= NULL
;
2920 if (MatchingHandleBuffer
!= NULL
) {
2921 *MatchingHandleBuffer
= HandleBufferForReturn
;
2924 ASSERT ((MatchingHandleBuffer
== NULL
) ||
2925 (*MatchingHandleCount
== 0 && *MatchingHandleBuffer
== NULL
) ||
2926 (*MatchingHandleCount
!= 0 && *MatchingHandleBuffer
!= NULL
));
2928 return (EFI_SUCCESS
);
2932 Appends 1 buffer to another buffer. This will re-allocate the destination buffer
2933 if necessary to fit all of the data.
2935 If DestinationBuffer is NULL, then ASSERT().
2937 @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.
2938 @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.
2939 @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.
2940 @param[in] SourceSize The number of bytes of SourceBuffer to append.
2942 @retval NULL A memory allocation failed.
2943 @retval NULL A parameter was invalid.
2944 @return A pointer to (*DestinationBuffer).
2948 IN OUT VOID
**DestinationBuffer
,
2949 IN OUT UINTN
*DestinationSize
,
2950 IN VOID
*SourceBuffer
,
2954 UINTN LocalDestinationSize
;
2955 UINTN LocalDestinationFinalSize
;
2957 ASSERT(DestinationBuffer
!= NULL
);
2959 if (SourceSize
== 0 || SourceBuffer
== NULL
) {
2960 return (*DestinationBuffer
);
2963 if (DestinationSize
== NULL
) {
2964 LocalDestinationSize
= 0;
2966 LocalDestinationSize
= *DestinationSize
;
2969 LocalDestinationFinalSize
= LocalDestinationSize
+ SourceSize
;
2971 if (DestinationSize
!= NULL
) {
2972 *DestinationSize
= LocalDestinationSize
;
2975 if (LocalDestinationSize
== 0) {
2977 *DestinationBuffer
= AllocateZeroPool(LocalDestinationFinalSize
);
2980 *DestinationBuffer
= ReallocatePool(LocalDestinationSize
, LocalDestinationFinalSize
, *DestinationBuffer
);
2983 ASSERT(*DestinationBuffer
!= NULL
);
2986 return (CopyMem(((UINT8
*)(*DestinationBuffer
)) + LocalDestinationSize
, SourceBuffer
, SourceSize
));
2990 Gets handles for any child devices produced by the passed in driver.
2992 @param[in] DriverHandle The handle of the driver.
2993 @param[in] MatchingHandleCount Pointer to the number of handles in
2994 MatchingHandleBuffer on return.
2995 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2997 @retval EFI_SUCCESS The operation was sucessful.
2998 @sa ParseHandleDatabaseByRelationship
3002 ParseHandleDatabaseForChildDevices(
3003 IN CONST EFI_HANDLE DriverHandle
,
3004 IN UINTN
*MatchingHandleCount
,
3005 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
3009 EFI_HANDLE
*Buffer2
;
3014 UINTN HandleBufferSize
;
3016 ASSERT(MatchingHandleCount
!= NULL
);
3018 HandleBufferSize
= 0;
3021 *MatchingHandleCount
= 0;
3023 Status
= PARSE_HANDLE_DATABASE_DEVICES (
3028 if (!EFI_ERROR (Status
)) {
3029 for (HandleIndex
= 0; HandleIndex
< Count1
; HandleIndex
++) {
3031 // now find the children
3033 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
3035 Buffer
[HandleIndex
],
3039 if (EFI_ERROR(Status
)) {
3043 // save out required and optional data elements
3045 *MatchingHandleCount
+= Count2
;
3046 if (MatchingHandleBuffer
!= NULL
) {
3047 *MatchingHandleBuffer
= BuffernCatGrow((VOID
**)MatchingHandleBuffer
, &HandleBufferSize
, Buffer2
, Count2
* sizeof(Buffer2
[0]));
3053 if (Buffer2
!= NULL
) {
3059 if (Buffer
!= NULL
) {
3066 Function to get all handles that support a given protocol or all handles.
3068 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL
3069 then the function will return all handles.
3071 @retval NULL A memory allocation failed.
3072 @return A NULL terminated list of handles.
3076 GetHandleListByProtocol (
3077 IN CONST EFI_GUID
*ProtocolGuid OPTIONAL
3080 EFI_HANDLE
*HandleList
;
3088 // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!
3090 if (ProtocolGuid
== NULL
) {
3091 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
3092 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3093 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
3094 if (HandleList
== NULL
) {
3097 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
3098 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
3101 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
3102 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3103 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
3104 if (HandleList
== NULL
) {
3107 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
3108 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
3111 if (EFI_ERROR(Status
)) {
3112 if (HandleList
!= NULL
) {
3113 FreePool(HandleList
);
3117 return (HandleList
);
3121 Function to get all handles that support some protocols.
3123 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
3125 @retval NULL A memory allocation failed.
3126 @retval NULL ProtocolGuids was NULL.
3127 @return A NULL terminated list of EFI_HANDLEs.
3131 GetHandleListByProtocolList (
3132 IN CONST EFI_GUID
**ProtocolGuids
3135 EFI_HANDLE
*HandleList
;
3140 CONST EFI_GUID
**GuidWalker
;
3141 EFI_HANDLE
*HandleWalker1
;
3142 EFI_HANDLE
*HandleWalker2
;
3146 TotalSize
= sizeof(EFI_HANDLE
);
3148 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++,Size
= 0){
3149 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &Size
, NULL
);
3150 if (Status
== EFI_BUFFER_TOO_SMALL
) {
3156 // No handles were found...
3158 if (TotalSize
== sizeof(EFI_HANDLE
)) {
3162 HandleList
= AllocateZeroPool(TotalSize
);
3163 if (HandleList
== NULL
) {
3168 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++){
3169 TempSize
= TotalSize
- Size
;
3170 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &TempSize
, HandleList
+(Size
/sizeof(EFI_HANDLE
)));
3173 // Allow for missing protocols... Only update the 'used' size upon success.
3175 if (!EFI_ERROR(Status
)) {
3179 ASSERT(HandleList
[(TotalSize
/sizeof(EFI_HANDLE
))-1] == NULL
);
3181 for (HandleWalker1
= HandleList
; HandleWalker1
!= NULL
&& *HandleWalker1
!= NULL
; HandleWalker1
++) {
3182 for (HandleWalker2
= HandleWalker1
+ 1; HandleWalker2
!= NULL
&& *HandleWalker2
!= NULL
; HandleWalker2
++) {
3183 if (*HandleWalker1
== *HandleWalker2
) {
3185 // copy memory back 1 handle width.
3187 CopyMem(HandleWalker2
, HandleWalker2
+ 1, TotalSize
- ((HandleWalker2
-HandleList
+1)*sizeof(EFI_HANDLE
)));
3192 return (HandleList
);
3196 Return all supported GUIDs.
3198 @param[out] Guids The buffer to return all supported GUIDs.
3199 @param[in, out] Count On input, the count of GUIDs the buffer can hold,
3200 On output, the count of GUIDs to return.
3202 @retval EFI_INVALID_PARAMETER Count is NULL.
3203 @retval EFI_BUFFER_TOO_SMALL Buffer is not enough to hold all GUIDs.
3204 @retval EFI_SUCCESS GUIDs are returned successfully.
3208 GetAllMappingGuids (
3209 OUT EFI_GUID
*Guids
,
3217 if (Count
== NULL
) {
3218 return EFI_INVALID_PARAMETER
;
3222 if (PcdGetBool (PcdShellIncludeNtGuids
)) {
3223 NtGuidCount
= ARRAY_SIZE (mGuidStringListNT
) - 1;
3225 GuidCount
= ARRAY_SIZE (mGuidStringList
) - 1;
3227 if (*Count
< NtGuidCount
+ GuidCount
+ mGuidListCount
) {
3228 *Count
= NtGuidCount
+ GuidCount
+ mGuidListCount
;
3229 return EFI_BUFFER_TOO_SMALL
;
3232 for (Index
= 0; Index
< NtGuidCount
; Index
++) {
3233 CopyGuid (&Guids
[Index
], mGuidStringListNT
[Index
].GuidId
);
3236 for (Index
= 0; Index
< GuidCount
; Index
++) {
3237 CopyGuid (&Guids
[NtGuidCount
+ Index
], mGuidStringList
[Index
].GuidId
);
3240 for (Index
= 0; Index
< mGuidListCount
; Index
++) {
3241 CopyGuid (&Guids
[NtGuidCount
+ GuidCount
+ Index
], mGuidList
[Index
].GuidId
);