2 Provides interface to advanced shell functionality for parsing both handle and protocol database.
4 Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiHandleParsingLib.h"
17 #include "IndustryStandard/Acpi10.h"
19 EFI_HANDLE mHandleParsingHiiHandle
= NULL
;
20 HANDLE_INDEX_LIST mHandleList
= {{{NULL
,NULL
},0,0},0};
21 GUID_INFO_BLOCK
*GuidList
;
24 Function to translate the EFI_MEMORY_TYPE into a string.
26 @param[in] Memory The memory type.
28 @retval A string representation of the type allocated from BS Pool.
33 IN CONST EFI_MEMORY_TYPE Memory
40 case EfiReservedMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiReservedMemoryType", 0); break;
41 case EfiLoaderCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderCode", 0); break;
42 case EfiLoaderData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderData", 0); break;
43 case EfiBootServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesCode", 0); break;
44 case EfiBootServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesData", 0); break;
45 case EfiRuntimeServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesCode", 0); break;
46 case EfiRuntimeServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesData", 0); break;
47 case EfiConventionalMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiConventionalMemory", 0); break;
48 case EfiUnusableMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiUnusableMemory", 0); break;
49 case EfiACPIReclaimMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIReclaimMemory", 0); break;
50 case EfiACPIMemoryNVS
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIMemoryNVS", 0); break;
51 case EfiMemoryMappedIO
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIO", 0); break;
52 case EfiMemoryMappedIOPortSpace
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIOPortSpace", 0); break;
53 case EfiPalCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiPalCode", 0); break;
54 case EfiMaxMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMaxMemoryType", 0); break;
55 default: ASSERT(FALSE
);
61 Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.
63 @param[in] Fmt The format type.
65 @retval A string representation of the type allocated from BS Pool.
70 IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt
77 case PixelRedGreenBlueReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelRedGreenBlueReserved8BitPerColor", 0); break;
78 case PixelBlueGreenRedReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBlueGreenRedReserved8BitPerColor", 0); break;
79 case PixelBitMask
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBitMask", 0); break;
80 case PixelBltOnly
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBltOnly", 0); break;
81 case PixelFormatMax
: StrnCatGrow(&RetVal
, NULL
, L
"PixelFormatMax", 0); break;
82 default: ASSERT(FALSE
);
88 Constructor for the library.
90 @param[in] ImageHandle Ignored.
91 @param[in] SystemTable Ignored.
93 @retval EFI_SUCCESS The operation was successful.
97 HandleParsingLibConstructor (
98 IN EFI_HANDLE ImageHandle
,
99 IN EFI_SYSTEM_TABLE
*SystemTable
106 // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.
108 return (EFI_SUCCESS
);
112 Initialization function for HII packages.
116 HandleParsingHiiInit (VOID
)
118 if (mHandleParsingHiiHandle
== NULL
) {
119 mHandleParsingHiiHandle
= HiiAddPackages (&gHandleParsingHiiGuid
, gImageHandle
, UefiHandleParsingLibStrings
, NULL
);
120 ASSERT (mHandleParsingHiiHandle
!= NULL
);
125 Destructor for the library. free any resources.
127 @param[in] ImageHandle Ignored.
128 @param[in] SystemTable Ignored.
130 @retval EFI_SUCCESS The operation was successful.
134 HandleParsingLibDestructor (
135 IN EFI_HANDLE ImageHandle
,
136 IN EFI_SYSTEM_TABLE
*SystemTable
141 for (LoopCount
= 0; GuidList
!= NULL
&& LoopCount
< GuidListCount
; LoopCount
++) {
142 SHELL_FREE_NON_NULL(GuidList
[LoopCount
].GuidId
);
145 SHELL_FREE_NON_NULL(GuidList
);
146 if (mHandleParsingHiiHandle
!= NULL
) {
147 HiiRemovePackages(mHandleParsingHiiHandle
);
149 return (EFI_SUCCESS
);
153 Function to dump information about LoadedImage.
155 This will allocate the return buffer from boot services pool.
157 @param[in] TheHandle The handle that has LoadedImage installed.
158 @param[in] Verbose TRUE for additional information, FALSE otherwise.
160 @retval A poitner to a string containing the information.
164 LoadedImageProtocolDumpInformation(
165 IN CONST EFI_HANDLE TheHandle
,
166 IN CONST BOOLEAN Verbose
169 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
177 return (CatSPrint(NULL
, L
"LoadedImage"));
180 HandleParsingHiiInit();
182 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_MAIN
), NULL
);
183 RetVal
= AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize
));
184 if (Temp
== NULL
|| RetVal
== NULL
) {
185 SHELL_FREE_NON_NULL(Temp
);
186 SHELL_FREE_NON_NULL(RetVal
);
190 Status
= gBS
->OpenProtocol (
192 &gEfiLoadedImageProtocolGuid
,
193 (VOID
**)&LoadedImage
,
196 EFI_OPEN_PROTOCOL_GET_PROTOCOL
199 if (EFI_ERROR (Status
)) {
200 SHELL_FREE_NON_NULL (Temp
);
201 SHELL_FREE_NON_NULL (RetVal
);
205 DataType
= ConvertMemoryType(LoadedImage
->ImageDataType
);
206 CodeType
= ConvertMemoryType(LoadedImage
->ImageCodeType
);
208 RetVal
= CatSPrint(RetVal
,
210 LoadedImage
->Revision
,
211 LoadedImage
->ParentHandle
,
212 LoadedImage
->SystemTable
,
213 LoadedImage
->DeviceHandle
,
214 LoadedImage
->FilePath
,
215 LoadedImage
->LoadOptionsSize
,
216 LoadedImage
->LoadOptions
,
217 LoadedImage
->ImageBase
,
218 LoadedImage
->ImageSize
,
221 LoadedImage
->Unload
);
224 SHELL_FREE_NON_NULL(Temp
);
225 SHELL_FREE_NON_NULL(CodeType
);
226 SHELL_FREE_NON_NULL(DataType
);
232 Function to dump information about GOP.
234 This will allocate the return buffer from boot services pool.
236 @param[in] TheHandle The handle that has LoadedImage installed.
237 @param[in] Verbose TRUE for additional information, FALSE otherwise.
239 @retval A poitner to a string containing the information.
243 GraphicsOutputProtocolDumpInformation(
244 IN CONST EFI_HANDLE TheHandle
,
245 IN CONST BOOLEAN Verbose
248 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
255 return (CatSPrint(NULL
, L
"GraphicsOutput"));
258 HandleParsingHiiInit();
260 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_GOP_DUMP_MAIN
), NULL
);
261 RetVal
= AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize
));
262 if (Temp
== NULL
|| RetVal
== NULL
) {
263 SHELL_FREE_NON_NULL(Temp
);
264 SHELL_FREE_NON_NULL(RetVal
);
268 Status
= gBS
->OpenProtocol (
270 &gEfiGraphicsOutputProtocolGuid
,
271 (VOID
**)&GraphicsOutput
,
274 EFI_OPEN_PROTOCOL_GET_PROTOCOL
277 if (EFI_ERROR (Status
)) {
278 SHELL_FREE_NON_NULL (Temp
);
279 SHELL_FREE_NON_NULL (RetVal
);
283 Fmt
= ConvertPixelFormat(GraphicsOutput
->Mode
->Info
->PixelFormat
);
285 RetVal
= CatSPrint(RetVal
,
287 GraphicsOutput
->Mode
->MaxMode
,
288 GraphicsOutput
->Mode
->Mode
,
289 GraphicsOutput
->Mode
->FrameBufferBase
,
290 (UINT64
)GraphicsOutput
->Mode
->FrameBufferSize
,
291 (UINT64
)GraphicsOutput
->Mode
->SizeOfInfo
,
292 GraphicsOutput
->Mode
->Info
->Version
,
293 GraphicsOutput
->Mode
->Info
->HorizontalResolution
,
294 GraphicsOutput
->Mode
->Info
->VerticalResolution
,
296 GraphicsOutput
->Mode
->Info
->PixelsPerScanLine
,
297 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.RedMask
,
298 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.GreenMask
,
299 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.BlueMask
302 SHELL_FREE_NON_NULL(Temp
);
303 SHELL_FREE_NON_NULL(Fmt
);
309 Function to dump information about PciRootBridgeIo.
311 This will allocate the return buffer from boot services pool.
313 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
314 @param[in] Verbose TRUE for additional information, FALSE otherwise.
316 @retval A poitner to a string containing the information.
320 PciRootBridgeIoDumpInformation(
321 IN CONST EFI_HANDLE TheHandle
,
322 IN CONST BOOLEAN Verbose
325 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
326 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Configuration
;
337 return (CatSPrint(NULL
, L
"PciRootBridgeIo"));
340 HandleParsingHiiInit();
342 Status
= gBS
->HandleProtocol(
344 &gEfiPciRootBridgeIoProtocolGuid
,
345 (VOID
**)&PciRootBridgeIo
);
347 if (EFI_ERROR(Status
)) {
351 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_PH
), NULL
);
355 Temp2
= CatSPrint(L
"\r\n", Temp
, PciRootBridgeIo
->ParentHandle
);
360 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SEG
), NULL
);
362 SHELL_FREE_NON_NULL(RetVal
);
365 Temp2
= CatSPrint(RetVal
, Temp
, PciRootBridgeIo
->SegmentNumber
);
373 Status
= PciRootBridgeIo
->GetAttributes (PciRootBridgeIo
, &Supports
, &Attributes
);
374 if (!EFI_ERROR(Status
)) {
375 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_ATT
), NULL
);
377 SHELL_FREE_NON_NULL(RetVal
);
380 Temp2
= CatSPrint(RetVal
, Temp
, Attributes
);
386 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS
), NULL
);
388 SHELL_FREE_NON_NULL(RetVal
);
391 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
398 Configuration
= NULL
;
399 Status
= PciRootBridgeIo
->Configuration (PciRootBridgeIo
, (VOID
**) &Configuration
);
400 if (!EFI_ERROR(Status
) && Configuration
!= NULL
) {
401 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_TITLE
), NULL
);
403 SHELL_FREE_NON_NULL(RetVal
);
406 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
411 while (Configuration
->Desc
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
413 switch (Configuration
->ResType
) {
414 case ACPI_ADDRESS_SPACE_TYPE_MEM
:
415 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_MEM
), NULL
);
417 case ACPI_ADDRESS_SPACE_TYPE_IO
:
418 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_IO
), NULL
);
420 case ACPI_ADDRESS_SPACE_TYPE_BUS
:
421 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_BUS
), NULL
);
425 Temp2
= CatSPrint(RetVal
, L
"%s", Temp
);
432 Temp2
= CatSPrint(RetVal
,
433 L
"%H%02x %016lx %016lx %02x%N\r\n",
434 Configuration
->SpecificFlag
,
435 Configuration
->AddrRangeMin
,
436 Configuration
->AddrRangeMax
,
437 Configuration
->AddrSpaceGranularity
449 Function to dump information about SimpleTextOut.
451 This will allocate the return buffer from boot services pool.
453 @param[in] TheHandle The handle that has SimpleTextOut installed.
454 @param[in] Verbose TRUE for additional information, FALSE otherwise.
456 @retval A poitner to a string containing the information.
460 TxtOutProtocolDumpInformation(
461 IN CONST EFI_HANDLE TheHandle
,
462 IN CONST BOOLEAN Verbose
465 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Dev
;
479 HandleParsingHiiInit();
484 Status
= gBS
->HandleProtocol(
486 &gEfiSimpleTextOutProtocolGuid
,
489 ASSERT_EFI_ERROR(Status
);
490 ASSERT (Dev
!= NULL
&& Dev
->Mode
!= NULL
);
492 Size
= (Dev
->Mode
->MaxMode
+ 1) * 80;
493 RetVal
= AllocateZeroPool(Size
);
495 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER
), NULL
);
497 UnicodeSPrint(RetVal
, Size
, Temp
, Dev
, Dev
->Mode
->Attribute
);
504 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE
), NULL
);
505 for (Index
= 0; Index
< Dev
->Mode
->MaxMode
; Index
++) {
506 Status
= Dev
->QueryMode (Dev
, Index
, &Col
, &Row
);
507 NewSize
= Size
- StrSize(RetVal
);
509 RetVal
+ StrLen(RetVal
),
511 Temp
== NULL
?L
"":Temp
,
512 Index
== Dev
->Mode
->Mode
? L
'*' : L
' ',
514 !EFI_ERROR(Status
)?(INTN
)Col
:-1,
515 !EFI_ERROR(Status
)?(INTN
)Row
:-1
522 STATIC CONST UINTN VersionStringSize
= 60;
525 Function to dump information about EfiDriverSupportedEfiVersion protocol.
527 This will allocate the return buffer from boot services pool.
529 @param[in] TheHandle The handle that has the protocol installed.
530 @param[in] Verbose TRUE for additional information, FALSE otherwise.
532 @retval A poitner to a string containing the information.
536 DriverEfiVersionProtocolDumpInformation(
537 IN CONST EFI_HANDLE TheHandle
,
538 IN CONST BOOLEAN Verbose
541 EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL
*DriverEfiVersion
;
545 Status
= gBS
->HandleProtocol(
547 &gEfiDriverSupportedEfiVersionProtocolGuid
,
548 (VOID
**)&DriverEfiVersion
);
550 ASSERT_EFI_ERROR(Status
);
552 RetVal
= AllocateZeroPool(VersionStringSize
);
553 ASSERT(RetVal
!= NULL
);
554 UnicodeSPrint(RetVal
, VersionStringSize
, L
"0x%08x", DriverEfiVersion
->FirmwareVersion
);
559 Function to dump information about DevicePath protocol.
561 This will allocate the return buffer from boot services pool.
563 @param[in] TheHandle The handle that has the protocol installed.
564 @param[in] Verbose TRUE for additional information, FALSE otherwise.
566 @retval A poitner to a string containing the information.
570 DevicePathProtocolDumpInformation(
571 IN CONST EFI_HANDLE TheHandle
,
572 IN CONST BOOLEAN Verbose
575 EFI_DEVICE_PATH_PROTOCOL
*DevPath
;
581 Status
= gBS
->OpenProtocol(TheHandle
, &gEfiDevicePathProtocolGuid
, (VOID
**)&DevPath
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
582 if (!EFI_ERROR(Status
)) {
584 // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
586 Temp
= ConvertDevicePathToText(DevPath
, TRUE
, TRUE
);
587 gBS
->CloseProtocol(TheHandle
, &gEfiDevicePathProtocolGuid
, gImageHandle
, NULL
);
589 if (!Verbose
&& Temp
!= NULL
&& StrLen(Temp
) > 30) {
591 Temp2
= StrnCatGrow(&Temp2
, NULL
, Temp
+(StrLen(Temp
) - 30), 30);
599 Function to dump information about EfiAdapterInformation Protocol.
601 @param[in] TheHandle The handle that has the protocol installed.
602 @param[in] Verbose TRUE for additional information, FALSE otherwise.
604 @retval A pointer to a string containing the information.
608 AdapterInformationDumpInformation (
609 IN CONST EFI_HANDLE TheHandle
,
610 IN CONST BOOLEAN Verbose
614 EFI_ADAPTER_INFORMATION_PROTOCOL
*EfiAdptrInfoProtocol
;
615 UINTN InfoTypesBufferCount
;
617 EFI_GUID
*InfoTypesBuffer
;
621 VOID
*InformationBlock
;
622 UINTN InformationBlockSize
;
625 return (CatSPrint(NULL
, L
"AdapterInfo"));
628 InfoTypesBuffer
= NULL
;
629 InformationBlock
= NULL
;
632 // Allocate print buffer to store data
634 RetVal
= AllocateZeroPool (PcdGet16(PcdShellPrintBufferSize
));
635 if (RetVal
== NULL
) {
639 Status
= gBS
->OpenProtocol (
640 (EFI_HANDLE
) (TheHandle
),
641 &gEfiAdapterInformationProtocolGuid
,
642 (VOID
**) &EfiAdptrInfoProtocol
,
645 EFI_OPEN_PROTOCOL_GET_PROTOCOL
648 if (EFI_ERROR (Status
)) {
649 SHELL_FREE_NON_NULL (RetVal
);
654 // Get a list of supported information types for this instance of the protocol.
656 Status
= EfiAdptrInfoProtocol
->GetSupportedTypes (
657 EfiAdptrInfoProtocol
,
659 &InfoTypesBufferCount
661 if (EFI_ERROR (Status
)) {
662 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED
), NULL
);
663 if (TempStr
!= NULL
) {
664 RetVal
= CatSPrint (RetVal
, TempStr
, Status
);
669 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SUPP_TYPE_HEADER
), NULL
);
670 if (TempStr
== NULL
) {
673 RetVal
= CatSPrint (RetVal
, TempStr
);
674 SHELL_FREE_NON_NULL (TempStr
);
676 for (GuidIndex
= 0; GuidIndex
< InfoTypesBufferCount
; GuidIndex
++) {
677 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_NUMBER
), NULL
);
678 if (TempStr
== NULL
) {
681 RetVal
= CatSPrint (RetVal
, TempStr
, (GuidIndex
+ 1), InfoTypesBuffer
[GuidIndex
]);
682 SHELL_FREE_NON_NULL (TempStr
);
684 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_STRING
), NULL
);
685 if (TempStr
== NULL
) {
689 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
690 RetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoMediaStateGuid");
691 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
692 RetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoNetworkBootGuid");
693 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
)) {
694 RetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoSanMacAddressGuid");
697 GuidStr
= GetStringNameFromGuid (&InfoTypesBuffer
[GuidIndex
], NULL
);
699 if (GuidStr
!= NULL
) {
700 if (StrCmp(GuidStr
, L
"UnknownDevice") == 0) {
701 RetVal
= CatSPrint (RetVal
, TempStr
, L
"UnknownInfoType");
703 SHELL_FREE_NON_NULL (TempStr
);
704 SHELL_FREE_NON_NULL(GuidStr
);
706 // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
710 RetVal
= CatSPrint (RetVal
, TempStr
, GuidStr
);
711 SHELL_FREE_NON_NULL(GuidStr
);
716 SHELL_FREE_NON_NULL (TempStr
);
718 Status
= EfiAdptrInfoProtocol
->GetInformation (
719 EfiAdptrInfoProtocol
,
720 &InfoTypesBuffer
[GuidIndex
],
722 &InformationBlockSize
725 if (EFI_ERROR (Status
)) {
726 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GETINFO_FAILED
), NULL
);
727 if (TempStr
== NULL
) {
730 RetVal
= CatSPrint (RetVal
, TempStr
, Status
);
732 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
733 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_MEDIA_STATE
), NULL
);
734 if (TempStr
== NULL
) {
740 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
,
741 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
743 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
744 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_NETWORK_BOOT_INFO
), NULL
);
745 if (TempStr
== NULL
) {
751 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4BootCapablity
,
752 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6BootCapablity
,
753 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBootCapablity
,
754 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->OffloadCapability
,
755 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiMpioCapability
,
756 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4Boot
,
757 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6Boot
,
758 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBoot
760 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
) == TRUE
) {
761 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO
), NULL
);
762 if (TempStr
== NULL
) {
768 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[0],
769 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[1],
770 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[2],
771 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[3],
772 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[4],
773 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[5]
776 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE
), NULL
);
777 if (TempStr
== NULL
) {
780 RetVal
= CatSPrint (RetVal
, TempStr
, &InfoTypesBuffer
[GuidIndex
]);
783 SHELL_FREE_NON_NULL (TempStr
);
784 SHELL_FREE_NON_NULL (InformationBlock
);
788 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
792 SHELL_FREE_NON_NULL (RetVal
);
793 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
794 SHELL_FREE_NON_NULL (InformationBlock
);
798 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
800 #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
802 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
805 #define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
807 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
810 #define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
812 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
814 STATIC CONST EFI_GUID WinNtThunkProtocolGuid
= LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID
;
815 STATIC CONST EFI_GUID WinNtIoProtocolGuid
= LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID
;
816 STATIC CONST EFI_GUID WinNtSerialPortGuid
= LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID
;
819 // Deprecated protocols we dont want to link from IntelFrameworkModulePkg
821 #define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \
823 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
825 #define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \
827 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \
829 STATIC CONST EFI_GUID EfiIsaIoProtocolGuid
= LOCAL_EFI_ISA_IO_PROTOCOL_GUID
;
830 STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid
= LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID
;
833 STATIC CONST GUID_INFO_BLOCK mGuidStringListNT
[] = {
834 {STRING_TOKEN(STR_WINNT_THUNK
), (EFI_GUID
*)&WinNtThunkProtocolGuid
, NULL
},
835 {STRING_TOKEN(STR_WINNT_DRIVER_IO
), (EFI_GUID
*)&WinNtIoProtocolGuid
, NULL
},
836 {STRING_TOKEN(STR_WINNT_SERIAL_PORT
), (EFI_GUID
*)&WinNtSerialPortGuid
, NULL
},
837 {STRING_TOKEN(STR_UNKNOWN_DEVICE
), NULL
, NULL
},
840 STATIC CONST GUID_INFO_BLOCK mGuidStringList
[] = {
841 {STRING_TOKEN(STR_LOADED_IMAGE
), &gEfiLoadedImageProtocolGuid
, LoadedImageProtocolDumpInformation
},
842 {STRING_TOKEN(STR_DEVICE_PATH
), &gEfiDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
843 {STRING_TOKEN(STR_IMAGE_PATH
), &gEfiLoadedImageDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
844 {STRING_TOKEN(STR_DEVICE_PATH_UTIL
), &gEfiDevicePathUtilitiesProtocolGuid
, NULL
},
845 {STRING_TOKEN(STR_DEVICE_PATH_TXT
), &gEfiDevicePathToTextProtocolGuid
, NULL
},
846 {STRING_TOKEN(STR_DEVICE_PATH_FTXT
), &gEfiDevicePathFromTextProtocolGuid
, NULL
},
847 {STRING_TOKEN(STR_DEVICE_PATH_PC
), &gEfiPcAnsiGuid
, NULL
},
848 {STRING_TOKEN(STR_DEVICE_PATH_VT100
), &gEfiVT100Guid
, NULL
},
849 {STRING_TOKEN(STR_DEVICE_PATH_VT100P
), &gEfiVT100PlusGuid
, NULL
},
850 {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8
), &gEfiVTUTF8Guid
, NULL
},
851 {STRING_TOKEN(STR_DRIVER_BINDING
), &gEfiDriverBindingProtocolGuid
, NULL
},
852 {STRING_TOKEN(STR_PLATFORM_OVERRIDE
), &gEfiPlatformDriverOverrideProtocolGuid
, NULL
},
853 {STRING_TOKEN(STR_BUS_OVERRIDE
), &gEfiBusSpecificDriverOverrideProtocolGuid
, NULL
},
854 {STRING_TOKEN(STR_DRIVER_DIAG
), &gEfiDriverDiagnosticsProtocolGuid
, NULL
},
855 {STRING_TOKEN(STR_DRIVER_DIAG2
), &gEfiDriverDiagnostics2ProtocolGuid
, NULL
},
856 {STRING_TOKEN(STR_DRIVER_CN
), &gEfiComponentNameProtocolGuid
, NULL
},
857 {STRING_TOKEN(STR_DRIVER_CN2
), &gEfiComponentName2ProtocolGuid
, NULL
},
858 {STRING_TOKEN(STR_PLAT_DRV_CFG
), &gEfiPlatformToDriverConfigurationProtocolGuid
, NULL
},
859 {STRING_TOKEN(STR_DRIVER_VERSION
), &gEfiDriverSupportedEfiVersionProtocolGuid
, DriverEfiVersionProtocolDumpInformation
},
860 {STRING_TOKEN(STR_TXT_IN
), &gEfiSimpleTextInProtocolGuid
, NULL
},
861 {STRING_TOKEN(STR_TXT_IN_EX
), &gEfiSimpleTextInputExProtocolGuid
, NULL
},
862 {STRING_TOKEN(STR_TXT_OUT
), &gEfiSimpleTextOutProtocolGuid
, TxtOutProtocolDumpInformation
},
863 {STRING_TOKEN(STR_SIM_POINTER
), &gEfiSimplePointerProtocolGuid
, NULL
},
864 {STRING_TOKEN(STR_ABS_POINTER
), &gEfiAbsolutePointerProtocolGuid
, NULL
},
865 {STRING_TOKEN(STR_SERIAL_IO
), &gEfiSerialIoProtocolGuid
, NULL
},
866 {STRING_TOKEN(STR_GRAPHICS_OUTPUT
), &gEfiGraphicsOutputProtocolGuid
, GraphicsOutputProtocolDumpInformation
},
867 {STRING_TOKEN(STR_EDID_DISCOVERED
), &gEfiEdidDiscoveredProtocolGuid
, NULL
},
868 {STRING_TOKEN(STR_EDID_ACTIVE
), &gEfiEdidActiveProtocolGuid
, NULL
},
869 {STRING_TOKEN(STR_EDID_OVERRIDE
), &gEfiEdidOverrideProtocolGuid
, NULL
},
870 {STRING_TOKEN(STR_CON_IN
), &gEfiConsoleInDeviceGuid
, NULL
},
871 {STRING_TOKEN(STR_CON_OUT
), &gEfiConsoleOutDeviceGuid
, NULL
},
872 {STRING_TOKEN(STR_STD_ERR
), &gEfiStandardErrorDeviceGuid
, NULL
},
873 {STRING_TOKEN(STR_LOAD_FILE
), &gEfiLoadFileProtocolGuid
, NULL
},
874 {STRING_TOKEN(STR_LOAD_FILE2
), &gEfiLoadFile2ProtocolGuid
, NULL
},
875 {STRING_TOKEN(STR_SIMPLE_FILE_SYS
), &gEfiSimpleFileSystemProtocolGuid
, NULL
},
876 {STRING_TOKEN(STR_TAPE_IO
), &gEfiTapeIoProtocolGuid
, NULL
},
877 {STRING_TOKEN(STR_DISK_IO
), &gEfiDiskIoProtocolGuid
, NULL
},
878 {STRING_TOKEN(STR_BLK_IO
), &gEfiBlockIoProtocolGuid
, NULL
},
879 {STRING_TOKEN(STR_UC
), &gEfiUnicodeCollationProtocolGuid
, NULL
},
880 {STRING_TOKEN(STR_UC2
), &gEfiUnicodeCollation2ProtocolGuid
, NULL
},
881 {STRING_TOKEN(STR_PCIRB_IO
), &gEfiPciRootBridgeIoProtocolGuid
, PciRootBridgeIoDumpInformation
},
882 {STRING_TOKEN(STR_PCI_IO
), &gEfiPciIoProtocolGuid
, NULL
},
883 {STRING_TOKEN(STR_SCSI_PT
), &gEfiScsiPassThruProtocolGuid
, NULL
},
884 {STRING_TOKEN(STR_SCSI_IO
), &gEfiScsiIoProtocolGuid
, NULL
},
885 {STRING_TOKEN(STR_SCSI_PT_EXT
), &gEfiExtScsiPassThruProtocolGuid
, NULL
},
886 {STRING_TOKEN(STR_ISCSI
), &gEfiIScsiInitiatorNameProtocolGuid
, NULL
},
887 {STRING_TOKEN(STR_USB_IO
), &gEfiUsbIoProtocolGuid
, NULL
},
888 {STRING_TOKEN(STR_USB_HC
), &gEfiUsbHcProtocolGuid
, NULL
},
889 {STRING_TOKEN(STR_USB_HC2
), &gEfiUsb2HcProtocolGuid
, NULL
},
890 {STRING_TOKEN(STR_DEBUG_SUPPORT
), &gEfiDebugSupportProtocolGuid
, NULL
},
891 {STRING_TOKEN(STR_DEBUG_PORT
), &gEfiDebugPortProtocolGuid
, NULL
},
892 {STRING_TOKEN(STR_DECOMPRESS
), &gEfiDecompressProtocolGuid
, NULL
},
893 {STRING_TOKEN(STR_ACPI_TABLE
), &gEfiAcpiTableProtocolGuid
, NULL
},
894 {STRING_TOKEN(STR_EBC_INTERPRETER
), &gEfiEbcProtocolGuid
, NULL
},
895 {STRING_TOKEN(STR_SNP
), &gEfiSimpleNetworkProtocolGuid
, NULL
},
896 {STRING_TOKEN(STR_NII
), &gEfiNetworkInterfaceIdentifierProtocolGuid
, NULL
},
897 {STRING_TOKEN(STR_NII_31
), &gEfiNetworkInterfaceIdentifierProtocolGuid_31
, NULL
},
898 {STRING_TOKEN(STR_PXE_BC
), &gEfiPxeBaseCodeProtocolGuid
, NULL
},
899 {STRING_TOKEN(STR_PXE_CB
), &gEfiPxeBaseCodeCallbackProtocolGuid
, NULL
},
900 {STRING_TOKEN(STR_BIS
), &gEfiBisProtocolGuid
, NULL
},
901 {STRING_TOKEN(STR_MNP_SB
), &gEfiManagedNetworkServiceBindingProtocolGuid
, NULL
},
902 {STRING_TOKEN(STR_MNP
), &gEfiManagedNetworkProtocolGuid
, NULL
},
903 {STRING_TOKEN(STR_ARP_SB
), &gEfiArpServiceBindingProtocolGuid
, NULL
},
904 {STRING_TOKEN(STR_ARP
), &gEfiArpProtocolGuid
, NULL
},
905 {STRING_TOKEN(STR_DHCPV4_SB
), &gEfiDhcp4ServiceBindingProtocolGuid
, NULL
},
906 {STRING_TOKEN(STR_DHCPV4
), &gEfiDhcp4ProtocolGuid
, NULL
},
907 {STRING_TOKEN(STR_TCPV4_SB
), &gEfiTcp4ServiceBindingProtocolGuid
, NULL
},
908 {STRING_TOKEN(STR_TCPV4
), &gEfiTcp4ProtocolGuid
, NULL
},
909 {STRING_TOKEN(STR_IPV4_SB
), &gEfiIp4ServiceBindingProtocolGuid
, NULL
},
910 {STRING_TOKEN(STR_IPV4
), &gEfiIp4ProtocolGuid
, NULL
},
911 {STRING_TOKEN(STR_IPV4_CFG
), &gEfiIp4ConfigProtocolGuid
, NULL
},
912 {STRING_TOKEN(STR_UDPV4_SB
), &gEfiUdp4ServiceBindingProtocolGuid
, NULL
},
913 {STRING_TOKEN(STR_UDPV4
), &gEfiUdp4ProtocolGuid
, NULL
},
914 {STRING_TOKEN(STR_MTFTPV4_SB
), &gEfiMtftp4ServiceBindingProtocolGuid
, NULL
},
915 {STRING_TOKEN(STR_MTFTPV4
), &gEfiMtftp4ProtocolGuid
, NULL
},
916 {STRING_TOKEN(STR_AUTH_INFO
), &gEfiAuthenticationInfoProtocolGuid
, NULL
},
917 {STRING_TOKEN(STR_HASH_SB
), &gEfiHashServiceBindingProtocolGuid
, NULL
},
918 {STRING_TOKEN(STR_HASH
), &gEfiHashProtocolGuid
, NULL
},
919 {STRING_TOKEN(STR_HII_FONT
), &gEfiHiiFontProtocolGuid
, NULL
},
920 {STRING_TOKEN(STR_HII_STRING
), &gEfiHiiStringProtocolGuid
, NULL
},
921 {STRING_TOKEN(STR_HII_IMAGE
), &gEfiHiiImageProtocolGuid
, NULL
},
922 {STRING_TOKEN(STR_HII_DATABASE
), &gEfiHiiDatabaseProtocolGuid
, NULL
},
923 {STRING_TOKEN(STR_HII_CONFIG_ROUT
), &gEfiHiiConfigRoutingProtocolGuid
, NULL
},
924 {STRING_TOKEN(STR_HII_CONFIG_ACC
), &gEfiHiiConfigAccessProtocolGuid
, NULL
},
925 {STRING_TOKEN(STR_HII_FORM_BROWSER2
), &gEfiFormBrowser2ProtocolGuid
, NULL
},
926 {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE
), &gEfiDriverFamilyOverrideProtocolGuid
, NULL
},
927 {STRING_TOKEN(STR_PCD
), &gPcdProtocolGuid
, NULL
},
928 {STRING_TOKEN(STR_TCG
), &gEfiTcgProtocolGuid
, NULL
},
929 {STRING_TOKEN(STR_HII_PACKAGE_LIST
), &gEfiHiiPackageListProtocolGuid
, NULL
},
932 // the ones under this are deprecated by the current UEFI Spec, but may be found anyways...
934 {STRING_TOKEN(STR_SHELL_INTERFACE
), &gEfiShellInterfaceGuid
, NULL
},
935 {STRING_TOKEN(STR_SHELL_ENV2
), &gEfiShellEnvironment2Guid
, NULL
},
936 {STRING_TOKEN(STR_SHELL_ENV
), &gEfiShellEnvironment2Guid
, NULL
},
937 {STRING_TOKEN(STR_DEVICE_IO
), &gEfiDeviceIoProtocolGuid
, NULL
},
938 {STRING_TOKEN(STR_UGA_DRAW
), &gEfiUgaDrawProtocolGuid
, NULL
},
939 {STRING_TOKEN(STR_UGA_IO
), &gEfiUgaIoProtocolGuid
, NULL
},
940 {STRING_TOKEN(STR_ESP
), &gEfiPartTypeSystemPartGuid
, NULL
},
941 {STRING_TOKEN(STR_GPT_NBR
), &gEfiPartTypeLegacyMbrGuid
, NULL
},
942 {STRING_TOKEN(STR_DRIVER_CONFIG
), &gEfiDriverConfigurationProtocolGuid
, NULL
},
943 {STRING_TOKEN(STR_DRIVER_CONFIG2
), &gEfiDriverConfiguration2ProtocolGuid
, NULL
},
946 // these are using local (non-global) definitions to reduce package dependancy.
948 {STRING_TOKEN(STR_ISA_IO
), (EFI_GUID
*)&EfiIsaIoProtocolGuid
, NULL
},
949 {STRING_TOKEN(STR_ISA_ACPI
), (EFI_GUID
*)&EfiIsaAcpiProtocolGuid
, NULL
},
952 // the ones under this are GUID identified structs, not protocols
954 {STRING_TOKEN(STR_FILE_INFO
), &gEfiFileInfoGuid
, NULL
},
955 {STRING_TOKEN(STR_FILE_SYS_INFO
), &gEfiFileSystemInfoGuid
, NULL
},
958 // the ones under this are misc GUIDS.
960 {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE
), &gEfiGlobalVariableGuid
, NULL
},
965 {STRING_TOKEN(STR_IP6_SB
), &gEfiIp6ServiceBindingProtocolGuid
, NULL
},
966 {STRING_TOKEN(STR_IP6
), &gEfiIp6ProtocolGuid
, NULL
},
967 {STRING_TOKEN(STR_IP6_CONFIG
), &gEfiIp6ConfigProtocolGuid
, NULL
},
968 {STRING_TOKEN(STR_MTFTP6_SB
), &gEfiMtftp6ServiceBindingProtocolGuid
, NULL
},
969 {STRING_TOKEN(STR_MTFTP6
), &gEfiMtftp6ProtocolGuid
, NULL
},
970 {STRING_TOKEN(STR_DHCP6_SB
), &gEfiDhcp6ServiceBindingProtocolGuid
, NULL
},
971 {STRING_TOKEN(STR_DHCP6
), &gEfiDhcp6ProtocolGuid
, NULL
},
972 {STRING_TOKEN(STR_UDP6_SB
), &gEfiUdp6ServiceBindingProtocolGuid
, NULL
},
973 {STRING_TOKEN(STR_UDP6
), &gEfiUdp6ProtocolGuid
, NULL
},
974 {STRING_TOKEN(STR_TCP6_SB
), &gEfiTcp6ServiceBindingProtocolGuid
, NULL
},
975 {STRING_TOKEN(STR_TCP6
), &gEfiTcp6ProtocolGuid
, NULL
},
976 {STRING_TOKEN(STR_VLAN_CONFIG
), &gEfiVlanConfigProtocolGuid
, NULL
},
977 {STRING_TOKEN(STR_EAP
), &gEfiEapProtocolGuid
, NULL
},
978 {STRING_TOKEN(STR_EAP_MGMT
), &gEfiEapManagementProtocolGuid
, NULL
},
979 {STRING_TOKEN(STR_FTP4_SB
), &gEfiFtp4ServiceBindingProtocolGuid
, NULL
},
980 {STRING_TOKEN(STR_FTP4
), &gEfiFtp4ProtocolGuid
, NULL
},
981 {STRING_TOKEN(STR_IP_SEC_CONFIG
), &gEfiIpSecConfigProtocolGuid
, NULL
},
982 {STRING_TOKEN(STR_DH
), &gEfiDriverHealthProtocolGuid
, NULL
},
983 {STRING_TOKEN(STR_DEF_IMG_LOAD
), &gEfiDeferredImageLoadProtocolGuid
, NULL
},
984 {STRING_TOKEN(STR_USER_CRED
), &gEfiUserCredentialProtocolGuid
, NULL
},
985 {STRING_TOKEN(STR_USER_MNGR
), &gEfiUserManagerProtocolGuid
, NULL
},
986 {STRING_TOKEN(STR_ATA_PASS_THRU
), &gEfiAtaPassThruProtocolGuid
, NULL
},
991 {STRING_TOKEN(STR_FW_MGMT
), &gEfiFirmwareManagementProtocolGuid
, NULL
},
992 {STRING_TOKEN(STR_IP_SEC
), &gEfiIpSecProtocolGuid
, NULL
},
993 {STRING_TOKEN(STR_IP_SEC2
), &gEfiIpSec2ProtocolGuid
, NULL
},
998 {STRING_TOKEN(STR_KMS
), &gEfiKmsProtocolGuid
, NULL
},
999 {STRING_TOKEN(STR_BLK_IO2
), &gEfiBlockIo2ProtocolGuid
, NULL
},
1000 {STRING_TOKEN(STR_SSC
), &gEfiStorageSecurityCommandProtocolGuid
, NULL
},
1001 {STRING_TOKEN(STR_UCRED2
), &gEfiUserCredential2ProtocolGuid
, NULL
},
1006 {STRING_TOKEN(STR_DISK_IO2
), &gEfiDiskIo2ProtocolGuid
, NULL
},
1007 {STRING_TOKEN(STR_ADAPTER_INFO
), &gEfiAdapterInformationProtocolGuid
, AdapterInformationDumpInformation
},
1012 {STRING_TOKEN(STR_IDE_CONT_INIT
), &gEfiIdeControllerInitProtocolGuid
, NULL
},
1015 // UEFI Shell Spec 2.0
1017 {STRING_TOKEN(STR_SHELL_PARAMETERS
), &gEfiShellParametersProtocolGuid
, NULL
},
1018 {STRING_TOKEN(STR_SHELL
), &gEfiShellProtocolGuid
, NULL
},
1021 // UEFI Shell Spec 2.1
1023 {STRING_TOKEN(STR_SHELL_DYNAMIC
), &gEfiShellDynamicCommandProtocolGuid
, NULL
},
1028 {STRING_TOKEN(STR_UNKNOWN_DEVICE
), NULL
, NULL
},
1032 Function to get the node for a protocol or struct from it's GUID.
1034 if Guid is NULL, then ASSERT.
1036 @param[in] Guid The GUID to look for the name of.
1040 CONST GUID_INFO_BLOCK
*
1042 InternalShellGetNodeFromGuid(
1043 IN CONST EFI_GUID
* Guid
1046 CONST GUID_INFO_BLOCK
*ListWalker
;
1049 ASSERT(Guid
!= NULL
);
1051 for (LoopCount
= 0, ListWalker
= GuidList
; GuidList
!= NULL
&& LoopCount
< GuidListCount
; LoopCount
++, ListWalker
++) {
1052 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1053 return (ListWalker
);
1057 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
1058 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1059 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1060 return (ListWalker
);
1064 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1065 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1066 return (ListWalker
);
1073 Function to add a new GUID/Name mapping.
1075 @param[in] Guid The Guid
1076 @param[in] NameID The STRING id of the HII string to use
1077 @param[in] DumpFunc The pointer to the dump function
1080 @retval EFI_SUCCESS The operation was sucessful
1081 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1082 @retval EFI_INVALID_PARAMETER Guid NameId was invalid
1086 InsertNewGuidNameMapping(
1087 IN CONST EFI_GUID
*Guid
,
1088 IN CONST EFI_STRING_ID NameID
,
1089 IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
1092 ASSERT(Guid
!= NULL
);
1093 ASSERT(NameID
!= 0);
1095 GuidList
= ReallocatePool(GuidListCount
* sizeof(GUID_INFO_BLOCK
), GuidListCount
+1 * sizeof(GUID_INFO_BLOCK
), GuidList
);
1096 if (GuidList
== NULL
) {
1098 return (EFI_OUT_OF_RESOURCES
);
1102 GuidList
[GuidListCount
- 1].GuidId
= AllocateCopyPool(sizeof(EFI_GUID
), Guid
);
1103 GuidList
[GuidListCount
- 1].StringId
= NameID
;
1104 GuidList
[GuidListCount
- 1].DumpInfo
= DumpFunc
;
1106 if (GuidList
[GuidListCount
- 1].GuidId
== NULL
) {
1107 return (EFI_OUT_OF_RESOURCES
);
1110 return (EFI_SUCCESS
);
1114 Function to add a new GUID/Name mapping.
1116 This cannot overwrite an existing mapping.
1118 @param[in] Guid The Guid
1119 @param[in] TheName The Guid's name
1120 @param[in] Lang RFC4646 language code list or NULL
1122 @retval EFI_SUCCESS The operation was sucessful
1123 @retval EFI_ACCESS_DENIED There was a duplicate
1124 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1125 @retval EFI_INVALID_PARAMETER Guid or TheName was NULL
1129 AddNewGuidNameMapping(
1130 IN CONST EFI_GUID
*Guid
,
1131 IN CONST CHAR16
*TheName
,
1132 IN CONST CHAR8
*Lang OPTIONAL
1135 EFI_STRING_ID NameID
;
1137 HandleParsingHiiInit();
1139 if (Guid
== NULL
|| TheName
== NULL
){
1140 return (EFI_INVALID_PARAMETER
);
1143 if ((InternalShellGetNodeFromGuid(Guid
)) != NULL
) {
1144 return (EFI_ACCESS_DENIED
);
1147 NameID
= HiiSetString(mHandleParsingHiiHandle
, 0, (CHAR16
*)TheName
, Lang
);
1149 return (EFI_OUT_OF_RESOURCES
);
1152 return (InsertNewGuidNameMapping(Guid
, NameID
, NULL
));
1156 Function to get the name of a protocol or struct from it's GUID.
1158 if Guid is NULL, then ASSERT.
1160 @param[in] Guid The GUID to look for the name of.
1161 @param[in] Lang The language to use.
1163 @return pointer to string of the name. The caller
1164 is responsible to free this memory.
1168 GetStringNameFromGuid(
1169 IN CONST EFI_GUID
*Guid
,
1170 IN CONST CHAR8
*Lang OPTIONAL
1173 CONST GUID_INFO_BLOCK
*Id
;
1175 HandleParsingHiiInit();
1177 Id
= InternalShellGetNodeFromGuid(Guid
);
1178 return (HiiGetString(mHandleParsingHiiHandle
, Id
==NULL
?STRING_TOKEN(STR_UNKNOWN_DEVICE
):Id
->StringId
, Lang
));
1182 Function to dump protocol information from a handle.
1184 This function will return a allocated string buffer containing the
1185 information. The caller is responsible for freeing the memory.
1187 If Guid is NULL, ASSERT().
1188 If TheHandle is NULL, ASSERT().
1190 @param[in] TheHandle The handle to dump information from.
1191 @param[in] Guid The GUID of the protocol to dump.
1192 @param[in] Verbose TRUE for extra info. FALSE otherwise.
1194 @return The pointer to string.
1195 @retval NULL An error was encountered.
1199 GetProtocolInformationDump(
1200 IN CONST EFI_HANDLE TheHandle
,
1201 IN CONST EFI_GUID
*Guid
,
1202 IN CONST BOOLEAN Verbose
1205 CONST GUID_INFO_BLOCK
*Id
;
1207 ASSERT(TheHandle
!= NULL
);
1208 ASSERT(Guid
!= NULL
);
1210 if (TheHandle
== NULL
|| Guid
== NULL
) {
1214 Id
= InternalShellGetNodeFromGuid(Guid
);
1215 if (Id
!= NULL
&& Id
->DumpInfo
!= NULL
) {
1216 return (Id
->DumpInfo(TheHandle
, Verbose
));
1222 Function to get the Guid for a protocol or struct based on it's string name.
1224 do not modify the returned Guid.
1226 @param[in] Name The pointer to the string name.
1227 @param[in] Lang The pointer to the language code.
1228 @param[out] Guid The pointer to the Guid.
1230 @retval EFI_SUCCESS The operation was sucessful.
1234 GetGuidFromStringName(
1235 IN CONST CHAR16
*Name
,
1236 IN CONST CHAR8
*Lang OPTIONAL
,
1240 CONST GUID_INFO_BLOCK
*ListWalker
;
1244 HandleParsingHiiInit();
1246 ASSERT(Guid
!= NULL
);
1248 return (EFI_INVALID_PARAMETER
);
1252 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
1253 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1254 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
1255 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
1256 *Guid
= ListWalker
->GuidId
;
1258 SHELL_FREE_NON_NULL(String
);
1259 if (*Guid
!= NULL
) {
1260 return (EFI_SUCCESS
);
1264 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1265 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
1266 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
1267 *Guid
= ListWalker
->GuidId
;
1269 SHELL_FREE_NON_NULL(String
);
1270 if (*Guid
!= NULL
) {
1271 return (EFI_SUCCESS
);
1275 for (LoopCount
= 0, ListWalker
= GuidList
; GuidList
!= NULL
&& LoopCount
< GuidListCount
; LoopCount
++, ListWalker
++) {
1276 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
1277 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
1278 *Guid
= ListWalker
->GuidId
;
1280 SHELL_FREE_NON_NULL(String
);
1281 if (*Guid
!= NULL
) {
1282 return (EFI_SUCCESS
);
1286 return (EFI_NOT_FOUND
);
1290 Get best support language for this driver.
1292 First base on the user input language to search, second base on the current
1293 platform used language to search, third get the first language from the
1294 support language list. The caller need to free the buffer of the best language.
1296 @param[in] SupportedLanguages The support languages for this driver.
1297 @param[in] InputLanguage The user input language.
1298 @param[in] Iso639Language Whether get language for ISO639.
1300 @return The best support language for this driver.
1304 GetBestLanguageForDriver (
1305 IN CONST CHAR8
*SupportedLanguages
,
1306 IN CONST CHAR8
*InputLanguage
,
1307 IN BOOLEAN Iso639Language
1310 CHAR8
*LanguageVariable
;
1311 CHAR8
*BestLanguage
;
1313 LanguageVariable
= GetVariable (Iso639Language
? L
"Lang" : L
"PlatformLang", &gEfiGlobalVariableGuid
);
1315 BestLanguage
= GetBestLanguage(
1318 (InputLanguage
!= NULL
) ? InputLanguage
: "",
1319 (LanguageVariable
!= NULL
) ? LanguageVariable
: "",
1324 if (LanguageVariable
!= NULL
) {
1325 FreePool (LanguageVariable
);
1328 return BestLanguage
;
1332 Function to retrieve the driver name (if possible) from the ComponentName or
1333 ComponentName2 protocol
1335 @param[in] TheHandle The driver handle to get the name of.
1336 @param[in] Language The language to use.
1338 @retval NULL The name could not be found.
1339 @return A pointer to the string name. Do not de-allocate the memory.
1343 GetStringNameFromHandle(
1344 IN CONST EFI_HANDLE TheHandle
,
1345 IN CONST CHAR8
*Language
1348 EFI_COMPONENT_NAME2_PROTOCOL
*CompNameStruct
;
1355 Status
= gBS
->OpenProtocol(
1357 &gEfiComponentName2ProtocolGuid
,
1358 (VOID
**)&CompNameStruct
,
1361 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
1362 if (!EFI_ERROR(Status
)) {
1363 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
1364 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
1365 if (BestLang
!= NULL
) {
1366 FreePool (BestLang
);
1369 if (!EFI_ERROR(Status
)) {
1373 Status
= gBS
->OpenProtocol(
1375 &gEfiComponentNameProtocolGuid
,
1376 (VOID
**)&CompNameStruct
,
1379 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
1380 if (!EFI_ERROR(Status
)) {
1381 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
1382 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
1383 if (BestLang
!= NULL
) {
1384 FreePool (BestLang
);
1386 if (!EFI_ERROR(Status
)) {
1394 Function to initialize the file global mHandleList object for use in
1395 vonverting handles to index and index to handle.
1397 @retval EFI_SUCCESS The operation was successful.
1401 InternalShellInitHandleList(
1406 EFI_HANDLE
*HandleBuffer
;
1408 HANDLE_LIST
*ListWalker
;
1410 if (mHandleList
.NextIndex
!= 0) {
1413 InitializeListHead(&mHandleList
.List
.Link
);
1414 mHandleList
.NextIndex
= 1;
1415 Status
= gBS
->LocateHandleBuffer (
1422 ASSERT_EFI_ERROR(Status
);
1423 if (EFI_ERROR(Status
)) {
1426 for (mHandleList
.NextIndex
= 1 ; mHandleList
.NextIndex
<= HandleCount
; mHandleList
.NextIndex
++){
1427 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
1428 ASSERT(ListWalker
!= NULL
);
1429 ListWalker
->TheHandle
= HandleBuffer
[mHandleList
.NextIndex
-1];
1430 ListWalker
->TheIndex
= mHandleList
.NextIndex
;
1431 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
1433 FreePool(HandleBuffer
);
1434 return (EFI_SUCCESS
);
1438 Function to retrieve the human-friendly index of a given handle. If the handle
1439 does not have a index one will be automatically assigned. The index value is valid
1440 until the termination of the shell application.
1442 @param[in] TheHandle The handle to retrieve an index for.
1444 @retval 0 A memory allocation failed.
1445 @return The index of the handle.
1450 ConvertHandleToHandleIndex(
1451 IN CONST EFI_HANDLE TheHandle
1455 EFI_GUID
**ProtocolBuffer
;
1456 UINTN ProtocolCount
;
1457 HANDLE_LIST
*ListWalker
;
1459 if (TheHandle
== NULL
) {
1463 InternalShellInitHandleList();
1465 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
1466 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
1467 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
1469 if (ListWalker
->TheHandle
== TheHandle
) {
1471 // Verify that TheHandle is still present in the Handle Database
1473 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
1474 if (EFI_ERROR (Status
)) {
1476 // TheHandle is not present in the Handle Database, so delete from the handle list
1478 RemoveEntryList (&ListWalker
->Link
);
1481 FreePool (ProtocolBuffer
);
1482 return (ListWalker
->TheIndex
);
1487 // Verify that TheHandle is valid handle
1489 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
1490 if (EFI_ERROR (Status
)) {
1492 // TheHandle is not valid, so do not add to handle list
1496 FreePool (ProtocolBuffer
);
1498 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
1499 ASSERT(ListWalker
!= NULL
);
1500 ListWalker
->TheHandle
= TheHandle
;
1501 ListWalker
->TheIndex
= mHandleList
.NextIndex
++;
1502 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
1503 return (ListWalker
->TheIndex
);
1509 Function to retrieve the EFI_HANDLE from the human-friendly index.
1511 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.
1513 @retval NULL The index was invalid.
1514 @return The EFI_HANDLE that index represents.
1519 ConvertHandleIndexToHandle(
1520 IN CONST UINTN TheIndex
1524 EFI_GUID
**ProtocolBuffer
;
1525 UINTN ProtocolCount
;
1526 HANDLE_LIST
*ListWalker
;
1528 InternalShellInitHandleList();
1530 if (TheIndex
>= mHandleList
.NextIndex
) {
1534 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
1535 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
1536 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
1538 if (ListWalker
->TheIndex
== TheIndex
&& ListWalker
->TheHandle
!= NULL
) {
1540 // Verify that LinkWalker->TheHandle is valid handle
1542 Status
= gBS
->ProtocolsPerHandle(ListWalker
->TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
1543 if (EFI_ERROR (Status
)) {
1545 // TheHandle is not valid, so do not add to handle list
1547 ListWalker
->TheHandle
= NULL
;
1549 return (ListWalker
->TheHandle
);
1556 Gets all the related EFI_HANDLEs based on the mask supplied.
1558 This function scans all EFI_HANDLES in the UEFI environment's handle database
1559 and returns the ones with the specified relationship (Mask) to the specified
1562 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
1563 If MatchingHandleCount is NULL, then ASSERT.
1565 If MatchingHandleBuffer is not NULL upon a successful return the memory must be
1568 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.
1569 @param[in] ControllerHandle The handle with Device Path protocol on it.
1570 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in
1571 MatchingHandleBuffer.
1572 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount
1573 EFI_HANDLEs with a terminating NULL EFI_HANDLE.
1574 @param[out] HandleType An array of type information.
1576 @retval EFI_SUCCESS The operation was successful, and any related handles
1577 are in MatchingHandleBuffer.
1578 @retval EFI_NOT_FOUND No matching handles were found.
1579 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
1583 ParseHandleDatabaseByRelationshipWithType (
1584 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
1585 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
1586 IN UINTN
*HandleCount
,
1587 OUT EFI_HANDLE
**HandleBuffer
,
1588 OUT UINTN
**HandleType
1593 EFI_GUID
**ProtocolGuidArray
;
1595 UINTN ProtocolIndex
;
1596 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfo
;
1597 UINTN OpenInfoCount
;
1598 UINTN OpenInfoIndex
;
1600 INTN DriverBindingHandleIndex
;
1602 ASSERT(HandleCount
!= NULL
);
1603 ASSERT(HandleBuffer
!= NULL
);
1604 ASSERT(HandleType
!= NULL
);
1605 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
1608 *HandleBuffer
= NULL
;
1612 // Retrieve the list of all handles from the handle database
1614 Status
= gBS
->LocateHandleBuffer (
1621 if (EFI_ERROR (Status
)) {
1625 *HandleType
= AllocateZeroPool (*HandleCount
* sizeof (UINTN
));
1626 ASSERT(*HandleType
!= NULL
);
1628 DriverBindingHandleIndex
= -1;
1629 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
1630 if (DriverBindingHandle
!= NULL
&& (*HandleBuffer
)[HandleIndex
] == DriverBindingHandle
) {
1631 DriverBindingHandleIndex
= (INTN
)HandleIndex
;
1635 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
1637 // Retrieve the list of all the protocols on each handle
1639 Status
= gBS
->ProtocolsPerHandle (
1640 (*HandleBuffer
)[HandleIndex
],
1644 if (EFI_ERROR (Status
)) {
1648 for (ProtocolIndex
= 0; ProtocolIndex
< ArrayCount
; ProtocolIndex
++) {
1651 // Set the bit describing what this handle has
1653 if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiLoadedImageProtocolGuid
) ) {
1654 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_IMAGE_HANDLE
;
1655 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverBindingProtocolGuid
) ) {
1656 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_BINDING_HANDLE
;
1657 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfiguration2ProtocolGuid
)) {
1658 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
1659 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfigurationProtocolGuid
) ) {
1660 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
1661 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnostics2ProtocolGuid
) ) {
1662 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
1663 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnosticsProtocolGuid
) ) {
1664 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
1665 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentName2ProtocolGuid
) ) {
1666 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
1667 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentNameProtocolGuid
) ) {
1668 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
1669 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDevicePathProtocolGuid
) ) {
1670 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DEVICE_HANDLE
;
1673 ASSERT((*HandleType
)[HandleIndex
] == (*HandleType
)[HandleIndex
]);
1677 // Retrieve the list of agents that have opened each protocol
1679 Status
= gBS
->OpenProtocolInformation (
1680 (*HandleBuffer
)[HandleIndex
],
1681 ProtocolGuidArray
[ProtocolIndex
],
1685 if (EFI_ERROR (Status
)) {
1689 if (ControllerHandle
== NULL
) {
1691 // ControllerHandle == NULL and DriverBindingHandle != NULL.
1692 // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
1694 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
1695 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
1696 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
1697 if (DriverBindingHandleIndex
!= -1) {
1698 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
1701 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1702 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
1703 if (DriverBindingHandleIndex
!= -1) {
1704 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
1706 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
1707 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
1708 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
1714 if (DriverBindingHandle
== NULL
&& ControllerHandle
!= NULL
) {
1715 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
1716 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
1717 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
1718 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
1719 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
1720 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
1721 (*HandleType
)[ChildIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
1725 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1726 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
1727 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
1728 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
1730 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
1731 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
1737 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
1738 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1739 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
1740 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
1746 if (DriverBindingHandle
!= NULL
&& ControllerHandle
!= NULL
) {
1747 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
1748 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
1749 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
1750 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
1751 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
1752 if (DriverBindingHandleIndex
!= -1) {
1753 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
1757 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1758 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
1759 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
1760 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
1761 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
1766 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
1767 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
1768 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
1774 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
1775 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1776 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
1777 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
1783 FreePool (OpenInfo
);
1785 FreePool (ProtocolGuidArray
);
1791 Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask
1794 This function will scan all EFI_HANDLES in the UEFI environment's handle database
1795 and return all the ones with the specified relationship (Mask) to the specified
1798 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
1799 If MatchingHandleCount is NULL, then ASSERT.
1801 If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be
1804 @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol
1806 @param[in] ControllerHandle Handle to a device with Device Path protocol on it.
1807 @param[in] Mask Mask of what relationship(s) is desired.
1808 @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in
1809 MatchingHandleBuffer.
1810 @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount
1811 EFI_HANDLEs and a terminating NULL EFI_HANDLE.
1813 @retval EFI_SUCCESS The operation was sucessful and any related handles
1814 are in MatchingHandleBuffer;
1815 @retval EFI_NOT_FOUND No matching handles were found.
1816 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
1820 ParseHandleDatabaseByRelationship (
1821 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
1822 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
1823 IN CONST UINTN Mask
,
1824 IN UINTN
*MatchingHandleCount
,
1825 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
1830 EFI_HANDLE
*HandleBuffer
;
1834 ASSERT(MatchingHandleCount
!= NULL
);
1835 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
1837 if ((Mask
& HR_VALID_MASK
) != Mask
) {
1838 return (EFI_INVALID_PARAMETER
);
1841 if ((Mask
& HR_CHILD_HANDLE
) != 0 && DriverBindingHandle
== NULL
) {
1842 return (EFI_INVALID_PARAMETER
);
1845 *MatchingHandleCount
= 0;
1846 if (MatchingHandleBuffer
!= NULL
) {
1847 *MatchingHandleBuffer
= NULL
;
1850 HandleBuffer
= NULL
;
1853 Status
= ParseHandleDatabaseByRelationshipWithType (
1854 DriverBindingHandle
,
1860 if (!EFI_ERROR (Status
)) {
1862 // Count the number of handles that match the attributes in Mask
1864 for (HandleIndex
= 0; HandleIndex
< HandleCount
; HandleIndex
++) {
1865 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
1866 (*MatchingHandleCount
)++;
1870 // If no handles match the attributes in Mask then return EFI_NOT_FOUND
1872 if (*MatchingHandleCount
== 0) {
1873 Status
= EFI_NOT_FOUND
;
1876 if (MatchingHandleBuffer
== NULL
) {
1878 // Someone just wanted the count...
1880 Status
= EFI_SUCCESS
;
1883 // Allocate a handle buffer for the number of handles that matched the attributes in Mask
1885 *MatchingHandleBuffer
= AllocateZeroPool ((*MatchingHandleCount
+1)* sizeof (EFI_HANDLE
));
1886 ASSERT(*MatchingHandleBuffer
!= NULL
);
1888 for (HandleIndex
= 0,*MatchingHandleCount
= 0
1889 ; HandleIndex
< HandleCount
1893 // Fill the allocated buffer with the handles that matched the attributes in Mask
1895 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
1896 (*MatchingHandleBuffer
)[(*MatchingHandleCount
)++] = HandleBuffer
[HandleIndex
];
1901 // Make the last one NULL
1903 (*MatchingHandleBuffer
)[*MatchingHandleCount
] = NULL
;
1905 Status
= EFI_SUCCESS
;
1906 } // MacthingHandleBuffer == NULL (ELSE)
1907 } // *MatchingHandleCount == 0 (ELSE)
1908 } // no error on ParseHandleDatabaseByRelationshipWithType
1910 if (HandleBuffer
!= NULL
) {
1911 FreePool (HandleBuffer
);
1914 if (HandleType
!= NULL
) {
1915 FreePool (HandleType
);
1922 Gets handles for any child controllers of the passed in controller.
1924 @param[in] ControllerHandle The handle of the "parent controller"
1925 @param[in] MatchingHandleCount Pointer to the number of handles in
1926 MatchingHandleBuffer on return.
1927 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
1931 @retval EFI_SUCCESS The operation was sucessful.
1935 ParseHandleDatabaseForChildControllers(
1936 IN CONST EFI_HANDLE ControllerHandle
,
1937 IN UINTN
*MatchingHandleCount
,
1938 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
1943 UINTN DriverBindingHandleCount
;
1944 EFI_HANDLE
*DriverBindingHandleBuffer
;
1945 UINTN DriverBindingHandleIndex
;
1946 UINTN ChildControllerHandleCount
;
1947 EFI_HANDLE
*ChildControllerHandleBuffer
;
1948 UINTN ChildControllerHandleIndex
;
1949 EFI_HANDLE
*HandleBufferForReturn
;
1951 if (MatchingHandleCount
== NULL
) {
1952 return (EFI_INVALID_PARAMETER
);
1954 *MatchingHandleCount
= 0;
1956 Status
= PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
1958 &DriverBindingHandleCount
,
1959 &DriverBindingHandleBuffer
1961 if (EFI_ERROR (Status
)) {
1966 // Get a buffer big enough for all the controllers.
1968 HandleBufferForReturn
= GetHandleListByProtocol(NULL
);
1969 if (HandleBufferForReturn
== NULL
) {
1970 FreePool (DriverBindingHandleBuffer
);
1971 return (EFI_NOT_FOUND
);
1974 for (DriverBindingHandleIndex
= 0; DriverBindingHandleIndex
< DriverBindingHandleCount
; DriverBindingHandleIndex
++) {
1975 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
1976 DriverBindingHandleBuffer
[DriverBindingHandleIndex
],
1978 &ChildControllerHandleCount
,
1979 &ChildControllerHandleBuffer
1981 if (EFI_ERROR (Status
)) {
1985 for (ChildControllerHandleIndex
= 0;
1986 ChildControllerHandleIndex
< ChildControllerHandleCount
;
1987 ChildControllerHandleIndex
++
1989 for (HandleIndex
= 0; HandleIndex
< *MatchingHandleCount
; HandleIndex
++) {
1990 if (HandleBufferForReturn
[HandleIndex
] == ChildControllerHandleBuffer
[ChildControllerHandleIndex
]) {
1994 if (HandleIndex
>= *MatchingHandleCount
) {
1995 HandleBufferForReturn
[(*MatchingHandleCount
)++] = ChildControllerHandleBuffer
[ChildControllerHandleIndex
];
1999 FreePool (ChildControllerHandleBuffer
);
2002 FreePool (DriverBindingHandleBuffer
);
2004 if (MatchingHandleBuffer
!= NULL
) {
2005 *MatchingHandleBuffer
= HandleBufferForReturn
;
2007 FreePool(HandleBufferForReturn
);
2010 return (EFI_SUCCESS
);
2014 Appends 1 buffer to another buffer. This will re-allocate the destination buffer
2015 if necessary to fit all of the data.
2017 If DestinationBuffer is NULL, then ASSERT().
2019 @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.
2020 @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.
2021 @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.
2022 @param[in] SourceSize The number of bytes of SourceBuffer to append.
2024 @retval NULL A memory allocation failed.
2025 @retval NULL A parameter was invalid.
2026 @return A pointer to (*DestinationBuffer).
2031 IN OUT VOID
**DestinationBuffer
,
2032 IN OUT UINTN
*DestinationSize
,
2033 IN VOID
*SourceBuffer
,
2037 UINTN LocalDestinationSize
;
2038 UINTN LocalDestinationFinalSize
;
2040 ASSERT(DestinationBuffer
!= NULL
);
2042 if (SourceSize
== 0 || SourceBuffer
== NULL
) {
2043 return (*DestinationBuffer
);
2046 if (DestinationSize
== NULL
) {
2047 LocalDestinationSize
= 0;
2049 LocalDestinationSize
= *DestinationSize
;
2052 LocalDestinationFinalSize
= LocalDestinationSize
+ SourceSize
;
2054 if (DestinationSize
!= NULL
) {
2055 *DestinationSize
= LocalDestinationSize
;
2058 if (LocalDestinationSize
== 0) {
2060 *DestinationBuffer
= AllocateZeroPool(LocalDestinationFinalSize
);
2063 *DestinationBuffer
= ReallocatePool(LocalDestinationSize
, LocalDestinationFinalSize
, *DestinationBuffer
);
2066 ASSERT(*DestinationBuffer
!= NULL
);
2069 return (CopyMem(((UINT8
*)(*DestinationBuffer
)) + LocalDestinationSize
, SourceBuffer
, SourceSize
));
2073 Gets handles for any child devices produced by the passed in driver.
2075 @param[in] DriverHandle The handle of the driver.
2076 @param[in] MatchingHandleCount Pointer to the number of handles in
2077 MatchingHandleBuffer on return.
2078 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2080 @retval EFI_SUCCESS The operation was sucessful.
2081 @sa ParseHandleDatabaseByRelationship
2085 ParseHandleDatabaseForChildDevices(
2086 IN CONST EFI_HANDLE DriverHandle
,
2087 IN UINTN
*MatchingHandleCount
,
2088 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2092 EFI_HANDLE
*Buffer2
;
2097 UINTN HandleBufferSize
;
2099 ASSERT(MatchingHandleCount
!= NULL
);
2101 HandleBufferSize
= 0;
2104 *MatchingHandleCount
= 0;
2106 Status
= PARSE_HANDLE_DATABASE_DEVICES (
2111 if (!EFI_ERROR (Status
)) {
2112 for (HandleIndex
= 0; HandleIndex
< Count1
; HandleIndex
++) {
2114 // now find the children
2116 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
2118 Buffer
[HandleIndex
],
2122 if (EFI_ERROR(Status
)) {
2126 // save out required and optional data elements
2128 *MatchingHandleCount
+= Count2
;
2129 if (MatchingHandleBuffer
!= NULL
) {
2130 *MatchingHandleBuffer
= BuffernCatGrow((VOID
**)MatchingHandleBuffer
, &HandleBufferSize
, Buffer2
, Count2
* sizeof(Buffer2
[0]));
2136 if (Buffer2
!= NULL
) {
2142 if (Buffer
!= NULL
) {
2149 Function to get all handles that support a given protocol or all handles.
2151 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL
2152 then the function will return all handles.
2154 @retval NULL A memory allocation failed.
2155 @return A NULL terminated list of handles.
2159 GetHandleListByProtocol (
2160 IN CONST EFI_GUID
*ProtocolGuid OPTIONAL
2163 EFI_HANDLE
*HandleList
;
2171 // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!
2173 if (ProtocolGuid
== NULL
) {
2174 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
2175 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2176 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
2177 if (HandleList
== NULL
) {
2180 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
2181 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
2184 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
2185 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2186 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
2187 if (HandleList
== NULL
) {
2190 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
2191 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
2194 if (EFI_ERROR(Status
)) {
2195 if (HandleList
!= NULL
) {
2196 FreePool(HandleList
);
2200 return (HandleList
);
2204 Function to get all handles that support some protocols.
2206 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
2208 @retval NULL A memory allocation failed.
2209 @retval NULL ProtocolGuids was NULL.
2210 @return A NULL terminated list of EFI_HANDLEs.
2214 GetHandleListByProtocolList (
2215 IN CONST EFI_GUID
**ProtocolGuids
2218 EFI_HANDLE
*HandleList
;
2223 CONST EFI_GUID
**GuidWalker
;
2224 EFI_HANDLE
*HandleWalker1
;
2225 EFI_HANDLE
*HandleWalker2
;
2229 TotalSize
= sizeof(EFI_HANDLE
);
2231 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++,Size
= 0){
2232 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &Size
, NULL
);
2233 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2239 // No handles were found...
2241 if (TotalSize
== sizeof(EFI_HANDLE
)) {
2245 HandleList
= AllocateZeroPool(TotalSize
);
2246 if (HandleList
== NULL
) {
2251 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++){
2252 TempSize
= TotalSize
- Size
;
2253 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &TempSize
, HandleList
+(Size
/sizeof(EFI_HANDLE
)));
2256 // Allow for missing protocols... Only update the 'used' size upon success.
2258 if (!EFI_ERROR(Status
)) {
2262 ASSERT(HandleList
[(TotalSize
/sizeof(EFI_HANDLE
))-1] == NULL
);
2264 for (HandleWalker1
= HandleList
; HandleWalker1
!= NULL
&& *HandleWalker1
!= NULL
; HandleWalker1
++) {
2265 for (HandleWalker2
= HandleWalker1
+ 1; HandleWalker2
!= NULL
&& *HandleWalker2
!= NULL
; HandleWalker2
++) {
2266 if (*HandleWalker1
== *HandleWalker2
) {
2268 // copy memory back 1 handle width.
2270 CopyMem(HandleWalker2
, HandleWalker2
+ 1, TotalSize
- ((HandleWalker2
-HandleList
+1)*sizeof(EFI_HANDLE
)));
2275 return (HandleList
);