2 Provides interface to advanced shell functionality for parsing both handle and protocol database.
4 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
5 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
6 Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "UefiHandleParsingLib.h"
18 #include "IndustryStandard/Acpi10.h"
20 EFI_HANDLE mHandleParsingHiiHandle
= NULL
;
21 HANDLE_INDEX_LIST mHandleList
= {{{NULL
,NULL
},0,0},0};
22 GUID_INFO_BLOCK
*GuidList
;
25 Function to translate the EFI_MEMORY_TYPE into a string.
27 @param[in] Memory The memory type.
29 @retval A string representation of the type allocated from BS Pool.
34 IN CONST EFI_MEMORY_TYPE Memory
41 case EfiReservedMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiReservedMemoryType", 0); break;
42 case EfiLoaderCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderCode", 0); break;
43 case EfiLoaderData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiLoaderData", 0); break;
44 case EfiBootServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesCode", 0); break;
45 case EfiBootServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiBootServicesData", 0); break;
46 case EfiRuntimeServicesCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesCode", 0); break;
47 case EfiRuntimeServicesData
: StrnCatGrow(&RetVal
, NULL
, L
"EfiRuntimeServicesData", 0); break;
48 case EfiConventionalMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiConventionalMemory", 0); break;
49 case EfiUnusableMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiUnusableMemory", 0); break;
50 case EfiACPIReclaimMemory
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIReclaimMemory", 0); break;
51 case EfiACPIMemoryNVS
: StrnCatGrow(&RetVal
, NULL
, L
"EfiACPIMemoryNVS", 0); break;
52 case EfiMemoryMappedIO
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIO", 0); break;
53 case EfiMemoryMappedIOPortSpace
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMemoryMappedIOPortSpace", 0); break;
54 case EfiPalCode
: StrnCatGrow(&RetVal
, NULL
, L
"EfiPalCode", 0); break;
55 case EfiMaxMemoryType
: StrnCatGrow(&RetVal
, NULL
, L
"EfiMaxMemoryType", 0); break;
56 default: ASSERT(FALSE
);
62 Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.
64 @param[in] Fmt The format type.
66 @retval A string representation of the type allocated from BS Pool.
71 IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt
78 case PixelRedGreenBlueReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelRedGreenBlueReserved8BitPerColor", 0); break;
79 case PixelBlueGreenRedReserved8BitPerColor
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBlueGreenRedReserved8BitPerColor", 0); break;
80 case PixelBitMask
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBitMask", 0); break;
81 case PixelBltOnly
: StrnCatGrow(&RetVal
, NULL
, L
"PixelBltOnly", 0); break;
82 case PixelFormatMax
: StrnCatGrow(&RetVal
, NULL
, L
"PixelFormatMax", 0); break;
83 default: ASSERT(FALSE
);
89 Constructor for the library.
91 @param[in] ImageHandle Ignored.
92 @param[in] SystemTable Ignored.
94 @retval EFI_SUCCESS The operation was successful.
98 HandleParsingLibConstructor (
99 IN EFI_HANDLE ImageHandle
,
100 IN EFI_SYSTEM_TABLE
*SystemTable
107 // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.
109 return (EFI_SUCCESS
);
113 Initialization function for HII packages.
117 HandleParsingHiiInit (VOID
)
119 if (mHandleParsingHiiHandle
== NULL
) {
120 mHandleParsingHiiHandle
= HiiAddPackages (&gHandleParsingHiiGuid
, gImageHandle
, UefiHandleParsingLibStrings
, NULL
);
121 ASSERT (mHandleParsingHiiHandle
!= NULL
);
126 Destructor for the library. free any resources.
128 @param[in] ImageHandle Ignored.
129 @param[in] SystemTable Ignored.
131 @retval EFI_SUCCESS The operation was successful.
135 HandleParsingLibDestructor (
136 IN EFI_HANDLE ImageHandle
,
137 IN EFI_SYSTEM_TABLE
*SystemTable
142 for (LoopCount
= 0; GuidList
!= NULL
&& LoopCount
< GuidListCount
; LoopCount
++) {
143 SHELL_FREE_NON_NULL(GuidList
[LoopCount
].GuidId
);
146 SHELL_FREE_NON_NULL(GuidList
);
147 if (mHandleParsingHiiHandle
!= NULL
) {
148 HiiRemovePackages(mHandleParsingHiiHandle
);
150 return (EFI_SUCCESS
);
154 Function to dump information about LoadedImage.
156 This will allocate the return buffer from boot services pool.
158 @param[in] TheHandle The handle that has LoadedImage installed.
159 @param[in] Verbose TRUE for additional information, FALSE otherwise.
161 @retval A poitner to a string containing the information.
165 LoadedImageProtocolDumpInformation(
166 IN CONST EFI_HANDLE TheHandle
,
167 IN CONST BOOLEAN Verbose
170 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
178 return (CatSPrint(NULL
, L
"LoadedImage"));
181 HandleParsingHiiInit();
183 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_LI_DUMP_MAIN
), NULL
);
188 Status
= gBS
->OpenProtocol (
190 &gEfiLoadedImageProtocolGuid
,
191 (VOID
**)&LoadedImage
,
194 EFI_OPEN_PROTOCOL_GET_PROTOCOL
197 if (EFI_ERROR (Status
)) {
198 SHELL_FREE_NON_NULL (Temp
);
202 DataType
= ConvertMemoryType(LoadedImage
->ImageDataType
);
203 CodeType
= ConvertMemoryType(LoadedImage
->ImageCodeType
);
208 LoadedImage
->Revision
,
209 LoadedImage
->ParentHandle
,
210 LoadedImage
->SystemTable
,
211 LoadedImage
->DeviceHandle
,
212 LoadedImage
->FilePath
,
213 LoadedImage
->LoadOptionsSize
,
214 LoadedImage
->LoadOptions
,
215 LoadedImage
->ImageBase
,
216 LoadedImage
->ImageSize
,
223 SHELL_FREE_NON_NULL(Temp
);
224 SHELL_FREE_NON_NULL(CodeType
);
225 SHELL_FREE_NON_NULL(DataType
);
231 Function to dump information about GOP.
233 This will allocate the return buffer from boot services pool.
235 @param[in] TheHandle The handle that has LoadedImage installed.
236 @param[in] Verbose TRUE for additional information, FALSE otherwise.
238 @retval A poitner to a string containing the information.
242 GraphicsOutputProtocolDumpInformation(
243 IN CONST EFI_HANDLE TheHandle
,
244 IN CONST BOOLEAN Verbose
247 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
254 return (CatSPrint(NULL
, L
"GraphicsOutput"));
257 HandleParsingHiiInit();
259 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_GOP_DUMP_MAIN
), NULL
);
264 Status
= gBS
->OpenProtocol (
266 &gEfiGraphicsOutputProtocolGuid
,
267 (VOID
**)&GraphicsOutput
,
270 EFI_OPEN_PROTOCOL_GET_PROTOCOL
273 if (EFI_ERROR (Status
)) {
274 SHELL_FREE_NON_NULL (Temp
);
278 Fmt
= ConvertPixelFormat(GraphicsOutput
->Mode
->Info
->PixelFormat
);
283 GraphicsOutput
->Mode
->MaxMode
,
284 GraphicsOutput
->Mode
->Mode
,
285 GraphicsOutput
->Mode
->FrameBufferBase
,
286 (UINT64
)GraphicsOutput
->Mode
->FrameBufferSize
,
287 (UINT64
)GraphicsOutput
->Mode
->SizeOfInfo
,
288 GraphicsOutput
->Mode
->Info
->Version
,
289 GraphicsOutput
->Mode
->Info
->HorizontalResolution
,
290 GraphicsOutput
->Mode
->Info
->VerticalResolution
,
292 GraphicsOutput
->Mode
->Info
->PixelsPerScanLine
,
293 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.RedMask
,
294 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.GreenMask
,
295 GraphicsOutput
->Mode
->Info
->PixelFormat
!=PixelBitMask
?0:GraphicsOutput
->Mode
->Info
->PixelInformation
.BlueMask
298 SHELL_FREE_NON_NULL(Temp
);
299 SHELL_FREE_NON_NULL(Fmt
);
305 Function to dump information about PciRootBridgeIo.
307 This will allocate the return buffer from boot services pool.
309 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
310 @param[in] Verbose TRUE for additional information, FALSE otherwise.
312 @retval A poitner to a string containing the information.
316 PciRootBridgeIoDumpInformation(
317 IN CONST EFI_HANDLE TheHandle
,
318 IN CONST BOOLEAN Verbose
321 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
322 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Configuration
;
333 return (CatSPrint(NULL
, L
"PciRootBridgeIo"));
336 HandleParsingHiiInit();
338 Status
= gBS
->HandleProtocol(
340 &gEfiPciRootBridgeIoProtocolGuid
,
341 (VOID
**)&PciRootBridgeIo
);
343 if (EFI_ERROR(Status
)) {
347 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_PH
), NULL
);
351 Temp2
= CatSPrint(L
"\r\n", Temp
, PciRootBridgeIo
->ParentHandle
);
356 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SEG
), NULL
);
358 SHELL_FREE_NON_NULL(RetVal
);
361 Temp2
= CatSPrint(RetVal
, Temp
, PciRootBridgeIo
->SegmentNumber
);
369 Status
= PciRootBridgeIo
->GetAttributes (PciRootBridgeIo
, &Supports
, &Attributes
);
370 if (!EFI_ERROR(Status
)) {
371 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_ATT
), NULL
);
373 SHELL_FREE_NON_NULL(RetVal
);
376 Temp2
= CatSPrint(RetVal
, Temp
, Attributes
);
382 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS
), NULL
);
384 SHELL_FREE_NON_NULL(RetVal
);
387 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
394 Configuration
= NULL
;
395 Status
= PciRootBridgeIo
->Configuration (PciRootBridgeIo
, (VOID
**) &Configuration
);
396 if (!EFI_ERROR(Status
) && Configuration
!= NULL
) {
397 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_TITLE
), NULL
);
399 SHELL_FREE_NON_NULL(RetVal
);
402 Temp2
= CatSPrint(RetVal
, Temp
, Supports
);
407 while (Configuration
->Desc
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
409 switch (Configuration
->ResType
) {
410 case ACPI_ADDRESS_SPACE_TYPE_MEM
:
411 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_MEM
), NULL
);
413 case ACPI_ADDRESS_SPACE_TYPE_IO
:
414 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_IO
), NULL
);
416 case ACPI_ADDRESS_SPACE_TYPE_BUS
:
417 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_PCIRB_DUMP_BUS
), NULL
);
421 Temp2
= CatSPrint(RetVal
, L
"%s", Temp
);
428 Temp2
= CatSPrint(RetVal
,
429 L
"%H%02x %016lx %016lx %02x%N\r\n",
430 Configuration
->SpecificFlag
,
431 Configuration
->AddrRangeMin
,
432 Configuration
->AddrRangeMax
,
433 Configuration
->AddrSpaceGranularity
445 Function to dump information about SimpleTextOut.
447 This will allocate the return buffer from boot services pool.
449 @param[in] TheHandle The handle that has SimpleTextOut installed.
450 @param[in] Verbose TRUE for additional information, FALSE otherwise.
452 @retval A poitner to a string containing the information.
456 TxtOutProtocolDumpInformation(
457 IN CONST EFI_HANDLE TheHandle
,
458 IN CONST BOOLEAN Verbose
461 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Dev
;
475 HandleParsingHiiInit();
480 Status
= gBS
->HandleProtocol(
482 &gEfiSimpleTextOutProtocolGuid
,
485 ASSERT_EFI_ERROR(Status
);
486 ASSERT (Dev
!= NULL
&& Dev
->Mode
!= NULL
);
488 Size
= (Dev
->Mode
->MaxMode
+ 1) * 80;
489 RetVal
= AllocateZeroPool(Size
);
491 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER
), NULL
);
493 UnicodeSPrint(RetVal
, Size
, Temp
, Dev
, Dev
->Mode
->Attribute
);
500 Temp
= HiiGetString(mHandleParsingHiiHandle
, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE
), NULL
);
501 for (Index
= 0; Index
< Dev
->Mode
->MaxMode
; Index
++) {
502 Status
= Dev
->QueryMode (Dev
, Index
, &Col
, &Row
);
503 NewSize
= Size
- StrSize(RetVal
);
505 RetVal
+ StrLen(RetVal
),
507 Temp
== NULL
?L
"":Temp
,
508 Index
== Dev
->Mode
->Mode
? L
'*' : L
' ',
510 !EFI_ERROR(Status
)?(INTN
)Col
:-1,
511 !EFI_ERROR(Status
)?(INTN
)Row
:-1
518 STATIC CONST UINTN VersionStringSize
= 60;
521 Function to dump information about EfiDriverSupportedEfiVersion protocol.
523 This will allocate the return buffer from boot services pool.
525 @param[in] TheHandle The handle that has the protocol installed.
526 @param[in] Verbose TRUE for additional information, FALSE otherwise.
528 @retval A poitner to a string containing the information.
532 DriverEfiVersionProtocolDumpInformation(
533 IN CONST EFI_HANDLE TheHandle
,
534 IN CONST BOOLEAN Verbose
537 EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL
*DriverEfiVersion
;
541 Status
= gBS
->HandleProtocol(
543 &gEfiDriverSupportedEfiVersionProtocolGuid
,
544 (VOID
**)&DriverEfiVersion
);
546 ASSERT_EFI_ERROR(Status
);
548 RetVal
= AllocateZeroPool(VersionStringSize
);
549 ASSERT(RetVal
!= NULL
);
550 UnicodeSPrint(RetVal
, VersionStringSize
, L
"0x%08x", DriverEfiVersion
->FirmwareVersion
);
555 Function to dump information about DevicePath protocol.
557 This will allocate the return buffer from boot services pool.
559 @param[in] TheHandle The handle that has the protocol installed.
560 @param[in] Verbose TRUE for additional information, FALSE otherwise.
562 @retval A poitner to a string containing the information.
566 DevicePathProtocolDumpInformation(
567 IN CONST EFI_HANDLE TheHandle
,
568 IN CONST BOOLEAN Verbose
571 EFI_DEVICE_PATH_PROTOCOL
*DevPath
;
577 Status
= gBS
->OpenProtocol(TheHandle
, &gEfiDevicePathProtocolGuid
, (VOID
**)&DevPath
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
578 if (!EFI_ERROR(Status
)) {
580 // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
582 Temp
= ConvertDevicePathToText(DevPath
, TRUE
, TRUE
);
583 gBS
->CloseProtocol(TheHandle
, &gEfiDevicePathProtocolGuid
, gImageHandle
, NULL
);
585 if (!Verbose
&& Temp
!= NULL
&& StrLen(Temp
) > 30) {
587 Temp2
= StrnCatGrow(&Temp2
, NULL
, Temp
+(StrLen(Temp
) - 30), 30);
595 Function to dump information about EfiAdapterInformation Protocol.
597 @param[in] TheHandle The handle that has the protocol installed.
598 @param[in] Verbose TRUE for additional information, FALSE otherwise.
600 @retval A pointer to a string containing the information.
604 AdapterInformationDumpInformation (
605 IN CONST EFI_HANDLE TheHandle
,
606 IN CONST BOOLEAN Verbose
610 EFI_ADAPTER_INFORMATION_PROTOCOL
*EfiAdptrInfoProtocol
;
611 UINTN InfoTypesBufferCount
;
613 EFI_GUID
*InfoTypesBuffer
;
618 VOID
*InformationBlock
;
619 UINTN InformationBlockSize
;
622 return (CatSPrint(NULL
, L
"AdapterInfo"));
625 InfoTypesBuffer
= NULL
;
626 InformationBlock
= NULL
;
629 Status
= gBS
->OpenProtocol (
630 (EFI_HANDLE
) (TheHandle
),
631 &gEfiAdapterInformationProtocolGuid
,
632 (VOID
**) &EfiAdptrInfoProtocol
,
635 EFI_OPEN_PROTOCOL_GET_PROTOCOL
638 if (EFI_ERROR (Status
)) {
643 // Get a list of supported information types for this instance of the protocol.
645 Status
= EfiAdptrInfoProtocol
->GetSupportedTypes (
646 EfiAdptrInfoProtocol
,
648 &InfoTypesBufferCount
651 if (EFI_ERROR (Status
)) {
652 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED
), NULL
);
653 if (TempStr
!= NULL
) {
654 RetVal
= CatSPrint (NULL
, TempStr
, Status
);
659 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SUPP_TYPE_HEADER
), NULL
);
660 if (TempStr
== NULL
) {
663 RetVal
= CatSPrint (NULL
, TempStr
);
664 SHELL_FREE_NON_NULL (TempStr
);
666 for (GuidIndex
= 0; GuidIndex
< InfoTypesBufferCount
; GuidIndex
++) {
667 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_NUMBER
), NULL
);
668 if (TempStr
== NULL
) {
671 TempRetVal
= CatSPrint (RetVal
, TempStr
, (GuidIndex
+ 1), InfoTypesBuffer
[GuidIndex
]);
672 SHELL_FREE_NON_NULL (RetVal
);
674 SHELL_FREE_NON_NULL (TempStr
);
676 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GUID_STRING
), NULL
);
677 if (TempStr
== NULL
) {
681 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
682 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoMediaStateGuid");
683 SHELL_FREE_NON_NULL (RetVal
);
685 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
686 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoNetworkBootGuid");
687 SHELL_FREE_NON_NULL (RetVal
);
689 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
)) {
690 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"gEfiAdapterInfoSanMacAddressGuid");
691 SHELL_FREE_NON_NULL (RetVal
);
695 GuidStr
= GetStringNameFromGuid (&InfoTypesBuffer
[GuidIndex
], NULL
);
697 if (GuidStr
!= NULL
) {
698 if (StrCmp(GuidStr
, L
"UnknownDevice") == 0) {
699 TempRetVal
= CatSPrint (RetVal
, TempStr
, L
"UnknownInfoType");
700 SHELL_FREE_NON_NULL (RetVal
);
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 TempRetVal
= CatSPrint (RetVal
, TempStr
, GuidStr
);
711 SHELL_FREE_NON_NULL (RetVal
);
713 SHELL_FREE_NON_NULL(GuidStr
);
718 SHELL_FREE_NON_NULL (TempStr
);
720 Status
= EfiAdptrInfoProtocol
->GetInformation (
721 EfiAdptrInfoProtocol
,
722 &InfoTypesBuffer
[GuidIndex
],
724 &InformationBlockSize
727 if (EFI_ERROR (Status
)) {
728 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_GETINFO_FAILED
), NULL
);
729 if (TempStr
== NULL
) {
732 TempRetVal
= CatSPrint (RetVal
, TempStr
, Status
);
733 SHELL_FREE_NON_NULL (RetVal
);
736 if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoMediaStateGuid
)) {
737 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_MEDIA_STATE
), NULL
);
738 if (TempStr
== NULL
) {
741 TempRetVal
= CatSPrint (
744 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
,
745 ((EFI_ADAPTER_INFO_MEDIA_STATE
*)InformationBlock
)->MediaState
747 SHELL_FREE_NON_NULL (RetVal
);
749 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoNetworkBootGuid
)) {
750 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_NETWORK_BOOT_INFO
), NULL
);
751 if (TempStr
== NULL
) {
754 TempRetVal
= CatSPrint (
757 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4BootCapablity
,
758 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6BootCapablity
,
759 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBootCapablity
,
760 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->OffloadCapability
,
761 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiMpioCapability
,
762 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv4Boot
,
763 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->iScsiIpv6Boot
,
764 ((EFI_ADAPTER_INFO_NETWORK_BOOT
*)InformationBlock
)->FCoeBoot
766 SHELL_FREE_NON_NULL (RetVal
);
768 } else if (CompareGuid (&InfoTypesBuffer
[GuidIndex
], &gEfiAdapterInfoSanMacAddressGuid
) == TRUE
) {
769 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO
), NULL
);
770 if (TempStr
== NULL
) {
773 TempRetVal
= CatSPrint (
776 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[0],
777 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[1],
778 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[2],
779 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[3],
780 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[4],
781 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS
*)InformationBlock
)->SanMacAddress
.Addr
[5]
783 SHELL_FREE_NON_NULL (RetVal
);
786 TempStr
= HiiGetString (mHandleParsingHiiHandle
, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE
), NULL
);
787 if (TempStr
== NULL
) {
790 TempRetVal
= CatSPrint (RetVal
, TempStr
, &InfoTypesBuffer
[GuidIndex
]);
791 SHELL_FREE_NON_NULL (RetVal
);
795 SHELL_FREE_NON_NULL (TempStr
);
796 SHELL_FREE_NON_NULL (InformationBlock
);
800 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
804 SHELL_FREE_NON_NULL (RetVal
);
805 SHELL_FREE_NON_NULL (InfoTypesBuffer
);
806 SHELL_FREE_NON_NULL (InformationBlock
);
810 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
812 #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
814 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
817 #define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
819 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
822 #define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
824 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
826 STATIC CONST EFI_GUID WinNtThunkProtocolGuid
= LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID
;
827 STATIC CONST EFI_GUID WinNtIoProtocolGuid
= LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID
;
828 STATIC CONST EFI_GUID WinNtSerialPortGuid
= LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID
;
831 // Deprecated protocols we dont want to link from IntelFrameworkModulePkg
833 #define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \
835 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
837 #define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \
839 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \
841 STATIC CONST EFI_GUID EfiIsaIoProtocolGuid
= LOCAL_EFI_ISA_IO_PROTOCOL_GUID
;
842 STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid
= LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID
;
845 STATIC CONST GUID_INFO_BLOCK mGuidStringListNT
[] = {
846 {STRING_TOKEN(STR_WINNT_THUNK
), (EFI_GUID
*)&WinNtThunkProtocolGuid
, NULL
},
847 {STRING_TOKEN(STR_WINNT_DRIVER_IO
), (EFI_GUID
*)&WinNtIoProtocolGuid
, NULL
},
848 {STRING_TOKEN(STR_WINNT_SERIAL_PORT
), (EFI_GUID
*)&WinNtSerialPortGuid
, NULL
},
849 {STRING_TOKEN(STR_UNKNOWN_DEVICE
), NULL
, NULL
},
852 STATIC CONST GUID_INFO_BLOCK mGuidStringList
[] = {
853 {STRING_TOKEN(STR_LOADED_IMAGE
), &gEfiLoadedImageProtocolGuid
, LoadedImageProtocolDumpInformation
},
854 {STRING_TOKEN(STR_DEVICE_PATH
), &gEfiDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
855 {STRING_TOKEN(STR_IMAGE_PATH
), &gEfiLoadedImageDevicePathProtocolGuid
, DevicePathProtocolDumpInformation
},
856 {STRING_TOKEN(STR_DEVICE_PATH_UTIL
), &gEfiDevicePathUtilitiesProtocolGuid
, NULL
},
857 {STRING_TOKEN(STR_DEVICE_PATH_TXT
), &gEfiDevicePathToTextProtocolGuid
, NULL
},
858 {STRING_TOKEN(STR_DEVICE_PATH_FTXT
), &gEfiDevicePathFromTextProtocolGuid
, NULL
},
859 {STRING_TOKEN(STR_DEVICE_PATH_PC
), &gEfiPcAnsiGuid
, NULL
},
860 {STRING_TOKEN(STR_DEVICE_PATH_VT100
), &gEfiVT100Guid
, NULL
},
861 {STRING_TOKEN(STR_DEVICE_PATH_VT100P
), &gEfiVT100PlusGuid
, NULL
},
862 {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8
), &gEfiVTUTF8Guid
, NULL
},
863 {STRING_TOKEN(STR_DRIVER_BINDING
), &gEfiDriverBindingProtocolGuid
, NULL
},
864 {STRING_TOKEN(STR_PLATFORM_OVERRIDE
), &gEfiPlatformDriverOverrideProtocolGuid
, NULL
},
865 {STRING_TOKEN(STR_BUS_OVERRIDE
), &gEfiBusSpecificDriverOverrideProtocolGuid
, NULL
},
866 {STRING_TOKEN(STR_DRIVER_DIAG
), &gEfiDriverDiagnosticsProtocolGuid
, NULL
},
867 {STRING_TOKEN(STR_DRIVER_DIAG2
), &gEfiDriverDiagnostics2ProtocolGuid
, NULL
},
868 {STRING_TOKEN(STR_DRIVER_CN
), &gEfiComponentNameProtocolGuid
, NULL
},
869 {STRING_TOKEN(STR_DRIVER_CN2
), &gEfiComponentName2ProtocolGuid
, NULL
},
870 {STRING_TOKEN(STR_PLAT_DRV_CFG
), &gEfiPlatformToDriverConfigurationProtocolGuid
, NULL
},
871 {STRING_TOKEN(STR_DRIVER_VERSION
), &gEfiDriverSupportedEfiVersionProtocolGuid
, DriverEfiVersionProtocolDumpInformation
},
872 {STRING_TOKEN(STR_TXT_IN
), &gEfiSimpleTextInProtocolGuid
, NULL
},
873 {STRING_TOKEN(STR_TXT_IN_EX
), &gEfiSimpleTextInputExProtocolGuid
, NULL
},
874 {STRING_TOKEN(STR_TXT_OUT
), &gEfiSimpleTextOutProtocolGuid
, TxtOutProtocolDumpInformation
},
875 {STRING_TOKEN(STR_SIM_POINTER
), &gEfiSimplePointerProtocolGuid
, NULL
},
876 {STRING_TOKEN(STR_ABS_POINTER
), &gEfiAbsolutePointerProtocolGuid
, NULL
},
877 {STRING_TOKEN(STR_SERIAL_IO
), &gEfiSerialIoProtocolGuid
, NULL
},
878 {STRING_TOKEN(STR_GRAPHICS_OUTPUT
), &gEfiGraphicsOutputProtocolGuid
, GraphicsOutputProtocolDumpInformation
},
879 {STRING_TOKEN(STR_EDID_DISCOVERED
), &gEfiEdidDiscoveredProtocolGuid
, NULL
},
880 {STRING_TOKEN(STR_EDID_ACTIVE
), &gEfiEdidActiveProtocolGuid
, NULL
},
881 {STRING_TOKEN(STR_EDID_OVERRIDE
), &gEfiEdidOverrideProtocolGuid
, NULL
},
882 {STRING_TOKEN(STR_CON_IN
), &gEfiConsoleInDeviceGuid
, NULL
},
883 {STRING_TOKEN(STR_CON_OUT
), &gEfiConsoleOutDeviceGuid
, NULL
},
884 {STRING_TOKEN(STR_STD_ERR
), &gEfiStandardErrorDeviceGuid
, NULL
},
885 {STRING_TOKEN(STR_LOAD_FILE
), &gEfiLoadFileProtocolGuid
, NULL
},
886 {STRING_TOKEN(STR_LOAD_FILE2
), &gEfiLoadFile2ProtocolGuid
, NULL
},
887 {STRING_TOKEN(STR_SIMPLE_FILE_SYS
), &gEfiSimpleFileSystemProtocolGuid
, NULL
},
888 {STRING_TOKEN(STR_TAPE_IO
), &gEfiTapeIoProtocolGuid
, NULL
},
889 {STRING_TOKEN(STR_DISK_IO
), &gEfiDiskIoProtocolGuid
, NULL
},
890 {STRING_TOKEN(STR_BLK_IO
), &gEfiBlockIoProtocolGuid
, NULL
},
891 {STRING_TOKEN(STR_UC
), &gEfiUnicodeCollationProtocolGuid
, NULL
},
892 {STRING_TOKEN(STR_UC2
), &gEfiUnicodeCollation2ProtocolGuid
, NULL
},
893 {STRING_TOKEN(STR_PCIRB_IO
), &gEfiPciRootBridgeIoProtocolGuid
, PciRootBridgeIoDumpInformation
},
894 {STRING_TOKEN(STR_PCI_IO
), &gEfiPciIoProtocolGuid
, NULL
},
895 {STRING_TOKEN(STR_SCSI_PT
), &gEfiScsiPassThruProtocolGuid
, NULL
},
896 {STRING_TOKEN(STR_SCSI_IO
), &gEfiScsiIoProtocolGuid
, NULL
},
897 {STRING_TOKEN(STR_SCSI_PT_EXT
), &gEfiExtScsiPassThruProtocolGuid
, NULL
},
898 {STRING_TOKEN(STR_ISCSI
), &gEfiIScsiInitiatorNameProtocolGuid
, NULL
},
899 {STRING_TOKEN(STR_USB_IO
), &gEfiUsbIoProtocolGuid
, NULL
},
900 {STRING_TOKEN(STR_USB_HC
), &gEfiUsbHcProtocolGuid
, NULL
},
901 {STRING_TOKEN(STR_USB_HC2
), &gEfiUsb2HcProtocolGuid
, NULL
},
902 {STRING_TOKEN(STR_DEBUG_SUPPORT
), &gEfiDebugSupportProtocolGuid
, NULL
},
903 {STRING_TOKEN(STR_DEBUG_PORT
), &gEfiDebugPortProtocolGuid
, NULL
},
904 {STRING_TOKEN(STR_DECOMPRESS
), &gEfiDecompressProtocolGuid
, NULL
},
905 {STRING_TOKEN(STR_ACPI_TABLE
), &gEfiAcpiTableProtocolGuid
, NULL
},
906 {STRING_TOKEN(STR_EBC_INTERPRETER
), &gEfiEbcProtocolGuid
, NULL
},
907 {STRING_TOKEN(STR_SNP
), &gEfiSimpleNetworkProtocolGuid
, NULL
},
908 {STRING_TOKEN(STR_NII
), &gEfiNetworkInterfaceIdentifierProtocolGuid
, NULL
},
909 {STRING_TOKEN(STR_NII_31
), &gEfiNetworkInterfaceIdentifierProtocolGuid_31
, NULL
},
910 {STRING_TOKEN(STR_PXE_BC
), &gEfiPxeBaseCodeProtocolGuid
, NULL
},
911 {STRING_TOKEN(STR_PXE_CB
), &gEfiPxeBaseCodeCallbackProtocolGuid
, NULL
},
912 {STRING_TOKEN(STR_BIS
), &gEfiBisProtocolGuid
, NULL
},
913 {STRING_TOKEN(STR_MNP_SB
), &gEfiManagedNetworkServiceBindingProtocolGuid
, NULL
},
914 {STRING_TOKEN(STR_MNP
), &gEfiManagedNetworkProtocolGuid
, NULL
},
915 {STRING_TOKEN(STR_ARP_SB
), &gEfiArpServiceBindingProtocolGuid
, NULL
},
916 {STRING_TOKEN(STR_ARP
), &gEfiArpProtocolGuid
, NULL
},
917 {STRING_TOKEN(STR_DHCPV4_SB
), &gEfiDhcp4ServiceBindingProtocolGuid
, NULL
},
918 {STRING_TOKEN(STR_DHCPV4
), &gEfiDhcp4ProtocolGuid
, NULL
},
919 {STRING_TOKEN(STR_TCPV4_SB
), &gEfiTcp4ServiceBindingProtocolGuid
, NULL
},
920 {STRING_TOKEN(STR_TCPV4
), &gEfiTcp4ProtocolGuid
, NULL
},
921 {STRING_TOKEN(STR_IPV4_SB
), &gEfiIp4ServiceBindingProtocolGuid
, NULL
},
922 {STRING_TOKEN(STR_IPV4
), &gEfiIp4ProtocolGuid
, NULL
},
923 {STRING_TOKEN(STR_IPV4_CFG
), &gEfiIp4ConfigProtocolGuid
, NULL
},
924 {STRING_TOKEN(STR_IPV4_CFG2
), &gEfiIp4Config2ProtocolGuid
, NULL
},
925 {STRING_TOKEN(STR_UDPV4_SB
), &gEfiUdp4ServiceBindingProtocolGuid
, NULL
},
926 {STRING_TOKEN(STR_UDPV4
), &gEfiUdp4ProtocolGuid
, NULL
},
927 {STRING_TOKEN(STR_MTFTPV4_SB
), &gEfiMtftp4ServiceBindingProtocolGuid
, NULL
},
928 {STRING_TOKEN(STR_MTFTPV4
), &gEfiMtftp4ProtocolGuid
, NULL
},
929 {STRING_TOKEN(STR_AUTH_INFO
), &gEfiAuthenticationInfoProtocolGuid
, NULL
},
930 {STRING_TOKEN(STR_HASH_SB
), &gEfiHashServiceBindingProtocolGuid
, NULL
},
931 {STRING_TOKEN(STR_HASH
), &gEfiHashProtocolGuid
, NULL
},
932 {STRING_TOKEN(STR_HII_FONT
), &gEfiHiiFontProtocolGuid
, NULL
},
933 {STRING_TOKEN(STR_HII_STRING
), &gEfiHiiStringProtocolGuid
, NULL
},
934 {STRING_TOKEN(STR_HII_IMAGE
), &gEfiHiiImageProtocolGuid
, NULL
},
935 {STRING_TOKEN(STR_HII_DATABASE
), &gEfiHiiDatabaseProtocolGuid
, NULL
},
936 {STRING_TOKEN(STR_HII_CONFIG_ROUT
), &gEfiHiiConfigRoutingProtocolGuid
, NULL
},
937 {STRING_TOKEN(STR_HII_CONFIG_ACC
), &gEfiHiiConfigAccessProtocolGuid
, NULL
},
938 {STRING_TOKEN(STR_HII_FORM_BROWSER2
), &gEfiFormBrowser2ProtocolGuid
, NULL
},
939 {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE
), &gEfiDriverFamilyOverrideProtocolGuid
, NULL
},
940 {STRING_TOKEN(STR_PCD
), &gPcdProtocolGuid
, NULL
},
941 {STRING_TOKEN(STR_TCG
), &gEfiTcgProtocolGuid
, NULL
},
942 {STRING_TOKEN(STR_HII_PACKAGE_LIST
), &gEfiHiiPackageListProtocolGuid
, NULL
},
945 // the ones under this are deprecated by the current UEFI Spec, but may be found anyways...
947 {STRING_TOKEN(STR_SHELL_INTERFACE
), &gEfiShellInterfaceGuid
, NULL
},
948 {STRING_TOKEN(STR_SHELL_ENV2
), &gEfiShellEnvironment2Guid
, NULL
},
949 {STRING_TOKEN(STR_SHELL_ENV
), &gEfiShellEnvironment2Guid
, NULL
},
950 {STRING_TOKEN(STR_DEVICE_IO
), &gEfiDeviceIoProtocolGuid
, NULL
},
951 {STRING_TOKEN(STR_UGA_DRAW
), &gEfiUgaDrawProtocolGuid
, NULL
},
952 {STRING_TOKEN(STR_UGA_IO
), &gEfiUgaIoProtocolGuid
, NULL
},
953 {STRING_TOKEN(STR_ESP
), &gEfiPartTypeSystemPartGuid
, NULL
},
954 {STRING_TOKEN(STR_GPT_NBR
), &gEfiPartTypeLegacyMbrGuid
, NULL
},
955 {STRING_TOKEN(STR_DRIVER_CONFIG
), &gEfiDriverConfigurationProtocolGuid
, NULL
},
956 {STRING_TOKEN(STR_DRIVER_CONFIG2
), &gEfiDriverConfiguration2ProtocolGuid
, NULL
},
959 // these are using local (non-global) definitions to reduce package dependancy.
961 {STRING_TOKEN(STR_ISA_IO
), (EFI_GUID
*)&EfiIsaIoProtocolGuid
, NULL
},
962 {STRING_TOKEN(STR_ISA_ACPI
), (EFI_GUID
*)&EfiIsaAcpiProtocolGuid
, NULL
},
965 // the ones under this are GUID identified structs, not protocols
967 {STRING_TOKEN(STR_FILE_INFO
), &gEfiFileInfoGuid
, NULL
},
968 {STRING_TOKEN(STR_FILE_SYS_INFO
), &gEfiFileSystemInfoGuid
, NULL
},
971 // the ones under this are misc GUIDS.
973 {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE
), &gEfiGlobalVariableGuid
, NULL
},
978 {STRING_TOKEN(STR_IP6_SB
), &gEfiIp6ServiceBindingProtocolGuid
, NULL
},
979 {STRING_TOKEN(STR_IP6
), &gEfiIp6ProtocolGuid
, NULL
},
980 {STRING_TOKEN(STR_IP6_CONFIG
), &gEfiIp6ConfigProtocolGuid
, NULL
},
981 {STRING_TOKEN(STR_MTFTP6_SB
), &gEfiMtftp6ServiceBindingProtocolGuid
, NULL
},
982 {STRING_TOKEN(STR_MTFTP6
), &gEfiMtftp6ProtocolGuid
, NULL
},
983 {STRING_TOKEN(STR_DHCP6_SB
), &gEfiDhcp6ServiceBindingProtocolGuid
, NULL
},
984 {STRING_TOKEN(STR_DHCP6
), &gEfiDhcp6ProtocolGuid
, NULL
},
985 {STRING_TOKEN(STR_UDP6_SB
), &gEfiUdp6ServiceBindingProtocolGuid
, NULL
},
986 {STRING_TOKEN(STR_UDP6
), &gEfiUdp6ProtocolGuid
, NULL
},
987 {STRING_TOKEN(STR_TCP6_SB
), &gEfiTcp6ServiceBindingProtocolGuid
, NULL
},
988 {STRING_TOKEN(STR_TCP6
), &gEfiTcp6ProtocolGuid
, NULL
},
989 {STRING_TOKEN(STR_VLAN_CONFIG
), &gEfiVlanConfigProtocolGuid
, NULL
},
990 {STRING_TOKEN(STR_EAP
), &gEfiEapProtocolGuid
, NULL
},
991 {STRING_TOKEN(STR_EAP_MGMT
), &gEfiEapManagementProtocolGuid
, NULL
},
992 {STRING_TOKEN(STR_FTP4_SB
), &gEfiFtp4ServiceBindingProtocolGuid
, NULL
},
993 {STRING_TOKEN(STR_FTP4
), &gEfiFtp4ProtocolGuid
, NULL
},
994 {STRING_TOKEN(STR_IP_SEC_CONFIG
), &gEfiIpSecConfigProtocolGuid
, NULL
},
995 {STRING_TOKEN(STR_DH
), &gEfiDriverHealthProtocolGuid
, NULL
},
996 {STRING_TOKEN(STR_DEF_IMG_LOAD
), &gEfiDeferredImageLoadProtocolGuid
, NULL
},
997 {STRING_TOKEN(STR_USER_CRED
), &gEfiUserCredentialProtocolGuid
, NULL
},
998 {STRING_TOKEN(STR_USER_MNGR
), &gEfiUserManagerProtocolGuid
, NULL
},
999 {STRING_TOKEN(STR_ATA_PASS_THRU
), &gEfiAtaPassThruProtocolGuid
, NULL
},
1004 {STRING_TOKEN(STR_FW_MGMT
), &gEfiFirmwareManagementProtocolGuid
, NULL
},
1005 {STRING_TOKEN(STR_IP_SEC
), &gEfiIpSecProtocolGuid
, NULL
},
1006 {STRING_TOKEN(STR_IP_SEC2
), &gEfiIpSec2ProtocolGuid
, NULL
},
1011 {STRING_TOKEN(STR_KMS
), &gEfiKmsProtocolGuid
, NULL
},
1012 {STRING_TOKEN(STR_BLK_IO2
), &gEfiBlockIo2ProtocolGuid
, NULL
},
1013 {STRING_TOKEN(STR_SSC
), &gEfiStorageSecurityCommandProtocolGuid
, NULL
},
1014 {STRING_TOKEN(STR_UCRED2
), &gEfiUserCredential2ProtocolGuid
, NULL
},
1019 {STRING_TOKEN(STR_DISK_IO2
), &gEfiDiskIo2ProtocolGuid
, NULL
},
1020 {STRING_TOKEN(STR_ADAPTER_INFO
), &gEfiAdapterInformationProtocolGuid
, AdapterInformationDumpInformation
},
1025 {STRING_TOKEN(STR_IDE_CONT_INIT
), &gEfiIdeControllerInitProtocolGuid
, NULL
},
1026 {STRING_TOKEN(STR_DISK_INFO
), &gEfiDiskInfoProtocolGuid
, NULL
},
1029 // UEFI Shell Spec 2.0
1031 {STRING_TOKEN(STR_SHELL_PARAMETERS
), &gEfiShellParametersProtocolGuid
, NULL
},
1032 {STRING_TOKEN(STR_SHELL
), &gEfiShellProtocolGuid
, NULL
},
1035 // UEFI Shell Spec 2.1
1037 {STRING_TOKEN(STR_SHELL_DYNAMIC
), &gEfiShellDynamicCommandProtocolGuid
, NULL
},
1042 {STRING_TOKEN(STR_UNKNOWN_DEVICE
), NULL
, NULL
},
1046 Function to get the node for a protocol or struct from it's GUID.
1048 if Guid is NULL, then ASSERT.
1050 @param[in] Guid The GUID to look for the name of.
1054 CONST GUID_INFO_BLOCK
*
1056 InternalShellGetNodeFromGuid(
1057 IN CONST EFI_GUID
* Guid
1060 CONST GUID_INFO_BLOCK
*ListWalker
;
1063 ASSERT(Guid
!= NULL
);
1065 for (LoopCount
= 0, ListWalker
= GuidList
; GuidList
!= NULL
&& LoopCount
< GuidListCount
; LoopCount
++, ListWalker
++) {
1066 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1067 return (ListWalker
);
1071 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
1072 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1073 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1074 return (ListWalker
);
1078 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1079 if (CompareGuid(ListWalker
->GuidId
, Guid
)) {
1080 return (ListWalker
);
1087 Function to add a new GUID/Name mapping.
1089 @param[in] Guid The Guid
1090 @param[in] NameID The STRING id of the HII string to use
1091 @param[in] DumpFunc The pointer to the dump function
1094 @retval EFI_SUCCESS The operation was sucessful
1095 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1096 @retval EFI_INVALID_PARAMETER Guid NameId was invalid
1100 InsertNewGuidNameMapping(
1101 IN CONST EFI_GUID
*Guid
,
1102 IN CONST EFI_STRING_ID NameID
,
1103 IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
1106 ASSERT(Guid
!= NULL
);
1107 ASSERT(NameID
!= 0);
1109 GuidList
= ReallocatePool(GuidListCount
* sizeof(GUID_INFO_BLOCK
), GuidListCount
+1 * sizeof(GUID_INFO_BLOCK
), GuidList
);
1110 if (GuidList
== NULL
) {
1112 return (EFI_OUT_OF_RESOURCES
);
1116 GuidList
[GuidListCount
- 1].GuidId
= AllocateCopyPool(sizeof(EFI_GUID
), Guid
);
1117 GuidList
[GuidListCount
- 1].StringId
= NameID
;
1118 GuidList
[GuidListCount
- 1].DumpInfo
= DumpFunc
;
1120 if (GuidList
[GuidListCount
- 1].GuidId
== NULL
) {
1121 return (EFI_OUT_OF_RESOURCES
);
1124 return (EFI_SUCCESS
);
1128 Function to add a new GUID/Name mapping.
1130 This cannot overwrite an existing mapping.
1132 @param[in] Guid The Guid
1133 @param[in] TheName The Guid's name
1134 @param[in] Lang RFC4646 language code list or NULL
1136 @retval EFI_SUCCESS The operation was sucessful
1137 @retval EFI_ACCESS_DENIED There was a duplicate
1138 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1139 @retval EFI_INVALID_PARAMETER Guid or TheName was NULL
1143 AddNewGuidNameMapping(
1144 IN CONST EFI_GUID
*Guid
,
1145 IN CONST CHAR16
*TheName
,
1146 IN CONST CHAR8
*Lang OPTIONAL
1149 EFI_STRING_ID NameID
;
1151 HandleParsingHiiInit();
1153 if (Guid
== NULL
|| TheName
== NULL
){
1154 return (EFI_INVALID_PARAMETER
);
1157 if ((InternalShellGetNodeFromGuid(Guid
)) != NULL
) {
1158 return (EFI_ACCESS_DENIED
);
1161 NameID
= HiiSetString(mHandleParsingHiiHandle
, 0, (CHAR16
*)TheName
, Lang
);
1163 return (EFI_OUT_OF_RESOURCES
);
1166 return (InsertNewGuidNameMapping(Guid
, NameID
, NULL
));
1170 Function to get the name of a protocol or struct from it's GUID.
1172 if Guid is NULL, then ASSERT.
1174 @param[in] Guid The GUID to look for the name of.
1175 @param[in] Lang The language to use.
1177 @return pointer to string of the name. The caller
1178 is responsible to free this memory.
1182 GetStringNameFromGuid(
1183 IN CONST EFI_GUID
*Guid
,
1184 IN CONST CHAR8
*Lang OPTIONAL
1187 CONST GUID_INFO_BLOCK
*Id
;
1189 HandleParsingHiiInit();
1191 Id
= InternalShellGetNodeFromGuid(Guid
);
1192 return (HiiGetString(mHandleParsingHiiHandle
, Id
==NULL
?STRING_TOKEN(STR_UNKNOWN_DEVICE
):Id
->StringId
, Lang
));
1196 Function to dump protocol information from a handle.
1198 This function will return a allocated string buffer containing the
1199 information. The caller is responsible for freeing the memory.
1201 If Guid is NULL, ASSERT().
1202 If TheHandle is NULL, ASSERT().
1204 @param[in] TheHandle The handle to dump information from.
1205 @param[in] Guid The GUID of the protocol to dump.
1206 @param[in] Verbose TRUE for extra info. FALSE otherwise.
1208 @return The pointer to string.
1209 @retval NULL An error was encountered.
1213 GetProtocolInformationDump(
1214 IN CONST EFI_HANDLE TheHandle
,
1215 IN CONST EFI_GUID
*Guid
,
1216 IN CONST BOOLEAN Verbose
1219 CONST GUID_INFO_BLOCK
*Id
;
1221 ASSERT(TheHandle
!= NULL
);
1222 ASSERT(Guid
!= NULL
);
1224 if (TheHandle
== NULL
|| Guid
== NULL
) {
1228 Id
= InternalShellGetNodeFromGuid(Guid
);
1229 if (Id
!= NULL
&& Id
->DumpInfo
!= NULL
) {
1230 return (Id
->DumpInfo(TheHandle
, Verbose
));
1236 Function to get the Guid for a protocol or struct based on it's string name.
1238 do not modify the returned Guid.
1240 @param[in] Name The pointer to the string name.
1241 @param[in] Lang The pointer to the language code.
1242 @param[out] Guid The pointer to the Guid.
1244 @retval EFI_SUCCESS The operation was sucessful.
1248 GetGuidFromStringName(
1249 IN CONST CHAR16
*Name
,
1250 IN CONST CHAR8
*Lang OPTIONAL
,
1254 CONST GUID_INFO_BLOCK
*ListWalker
;
1258 HandleParsingHiiInit();
1260 ASSERT(Guid
!= NULL
);
1262 return (EFI_INVALID_PARAMETER
);
1266 if (PcdGetBool(PcdShellIncludeNtGuids
)) {
1267 for (ListWalker
= mGuidStringListNT
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1268 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
1269 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
1270 *Guid
= ListWalker
->GuidId
;
1272 SHELL_FREE_NON_NULL(String
);
1273 if (*Guid
!= NULL
) {
1274 return (EFI_SUCCESS
);
1278 for (ListWalker
= mGuidStringList
; ListWalker
!= NULL
&& ListWalker
->GuidId
!= NULL
; ListWalker
++) {
1279 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
1280 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
1281 *Guid
= ListWalker
->GuidId
;
1283 SHELL_FREE_NON_NULL(String
);
1284 if (*Guid
!= NULL
) {
1285 return (EFI_SUCCESS
);
1289 for (LoopCount
= 0, ListWalker
= GuidList
; GuidList
!= NULL
&& LoopCount
< GuidListCount
; LoopCount
++, ListWalker
++) {
1290 String
= HiiGetString(mHandleParsingHiiHandle
, ListWalker
->StringId
, Lang
);
1291 if (Name
!= NULL
&& String
!= NULL
&& StringNoCaseCompare (&Name
, &String
) == 0) {
1292 *Guid
= ListWalker
->GuidId
;
1294 SHELL_FREE_NON_NULL(String
);
1295 if (*Guid
!= NULL
) {
1296 return (EFI_SUCCESS
);
1300 return (EFI_NOT_FOUND
);
1304 Get best support language for this driver.
1306 First base on the user input language to search, second base on the current
1307 platform used language to search, third get the first language from the
1308 support language list. The caller need to free the buffer of the best language.
1310 @param[in] SupportedLanguages The support languages for this driver.
1311 @param[in] InputLanguage The user input language.
1312 @param[in] Iso639Language Whether get language for ISO639.
1314 @return The best support language for this driver.
1318 GetBestLanguageForDriver (
1319 IN CONST CHAR8
*SupportedLanguages
,
1320 IN CONST CHAR8
*InputLanguage
,
1321 IN BOOLEAN Iso639Language
1324 CHAR8
*LanguageVariable
;
1325 CHAR8
*BestLanguage
;
1327 GetVariable2 (Iso639Language
? L
"Lang" : L
"PlatformLang", &gEfiGlobalVariableGuid
, (VOID
**)&LanguageVariable
, NULL
);
1329 BestLanguage
= GetBestLanguage(
1332 (InputLanguage
!= NULL
) ? InputLanguage
: "",
1333 (LanguageVariable
!= NULL
) ? LanguageVariable
: "",
1338 if (LanguageVariable
!= NULL
) {
1339 FreePool (LanguageVariable
);
1342 return BestLanguage
;
1346 Function to retrieve the driver name (if possible) from the ComponentName or
1347 ComponentName2 protocol
1349 @param[in] TheHandle The driver handle to get the name of.
1350 @param[in] Language The language to use.
1352 @retval NULL The name could not be found.
1353 @return A pointer to the string name. Do not de-allocate the memory.
1357 GetStringNameFromHandle(
1358 IN CONST EFI_HANDLE TheHandle
,
1359 IN CONST CHAR8
*Language
1362 EFI_COMPONENT_NAME2_PROTOCOL
*CompNameStruct
;
1369 Status
= gBS
->OpenProtocol(
1371 &gEfiComponentName2ProtocolGuid
,
1372 (VOID
**)&CompNameStruct
,
1375 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
1376 if (!EFI_ERROR(Status
)) {
1377 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
1378 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
1379 if (BestLang
!= NULL
) {
1380 FreePool (BestLang
);
1383 if (!EFI_ERROR(Status
)) {
1387 Status
= gBS
->OpenProtocol(
1389 &gEfiComponentNameProtocolGuid
,
1390 (VOID
**)&CompNameStruct
,
1393 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
1394 if (!EFI_ERROR(Status
)) {
1395 BestLang
= GetBestLanguageForDriver (CompNameStruct
->SupportedLanguages
, Language
, FALSE
);
1396 Status
= CompNameStruct
->GetDriverName(CompNameStruct
, BestLang
, &RetVal
);
1397 if (BestLang
!= NULL
) {
1398 FreePool (BestLang
);
1400 if (!EFI_ERROR(Status
)) {
1408 Function to initialize the file global mHandleList object for use in
1409 vonverting handles to index and index to handle.
1411 @retval EFI_SUCCESS The operation was successful.
1415 InternalShellInitHandleList(
1420 EFI_HANDLE
*HandleBuffer
;
1422 HANDLE_LIST
*ListWalker
;
1424 if (mHandleList
.NextIndex
!= 0) {
1427 InitializeListHead(&mHandleList
.List
.Link
);
1428 mHandleList
.NextIndex
= 1;
1429 Status
= gBS
->LocateHandleBuffer (
1436 ASSERT_EFI_ERROR(Status
);
1437 if (EFI_ERROR(Status
)) {
1440 for (mHandleList
.NextIndex
= 1 ; mHandleList
.NextIndex
<= HandleCount
; mHandleList
.NextIndex
++){
1441 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
1442 ASSERT(ListWalker
!= NULL
);
1443 ListWalker
->TheHandle
= HandleBuffer
[mHandleList
.NextIndex
-1];
1444 ListWalker
->TheIndex
= mHandleList
.NextIndex
;
1445 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
1447 FreePool(HandleBuffer
);
1448 return (EFI_SUCCESS
);
1452 Function to retrieve the human-friendly index of a given handle. If the handle
1453 does not have a index one will be automatically assigned. The index value is valid
1454 until the termination of the shell application.
1456 @param[in] TheHandle The handle to retrieve an index for.
1458 @retval 0 A memory allocation failed.
1459 @return The index of the handle.
1464 ConvertHandleToHandleIndex(
1465 IN CONST EFI_HANDLE TheHandle
1469 EFI_GUID
**ProtocolBuffer
;
1470 UINTN ProtocolCount
;
1471 HANDLE_LIST
*ListWalker
;
1473 if (TheHandle
== NULL
) {
1477 InternalShellInitHandleList();
1479 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
1480 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
1481 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
1483 if (ListWalker
->TheHandle
== TheHandle
) {
1485 // Verify that TheHandle is still present in the Handle Database
1487 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
1488 if (EFI_ERROR (Status
)) {
1490 // TheHandle is not present in the Handle Database, so delete from the handle list
1492 RemoveEntryList (&ListWalker
->Link
);
1495 FreePool (ProtocolBuffer
);
1496 return (ListWalker
->TheIndex
);
1501 // Verify that TheHandle is valid handle
1503 Status
= gBS
->ProtocolsPerHandle(TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
1504 if (EFI_ERROR (Status
)) {
1506 // TheHandle is not valid, so do not add to handle list
1510 FreePool (ProtocolBuffer
);
1512 ListWalker
= AllocateZeroPool(sizeof(HANDLE_LIST
));
1513 ASSERT(ListWalker
!= NULL
);
1514 ListWalker
->TheHandle
= TheHandle
;
1515 ListWalker
->TheIndex
= mHandleList
.NextIndex
++;
1516 InsertTailList(&mHandleList
.List
.Link
,&ListWalker
->Link
);
1517 return (ListWalker
->TheIndex
);
1523 Function to retrieve the EFI_HANDLE from the human-friendly index.
1525 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.
1527 @retval NULL The index was invalid.
1528 @return The EFI_HANDLE that index represents.
1533 ConvertHandleIndexToHandle(
1534 IN CONST UINTN TheIndex
1538 EFI_GUID
**ProtocolBuffer
;
1539 UINTN ProtocolCount
;
1540 HANDLE_LIST
*ListWalker
;
1542 InternalShellInitHandleList();
1544 if (TheIndex
>= mHandleList
.NextIndex
) {
1548 for (ListWalker
= (HANDLE_LIST
*)GetFirstNode(&mHandleList
.List
.Link
)
1549 ; !IsNull(&mHandleList
.List
.Link
,&ListWalker
->Link
)
1550 ; ListWalker
= (HANDLE_LIST
*)GetNextNode(&mHandleList
.List
.Link
,&ListWalker
->Link
)
1552 if (ListWalker
->TheIndex
== TheIndex
&& ListWalker
->TheHandle
!= NULL
) {
1554 // Verify that LinkWalker->TheHandle is valid handle
1556 Status
= gBS
->ProtocolsPerHandle(ListWalker
->TheHandle
, &ProtocolBuffer
, &ProtocolCount
);
1557 if (EFI_ERROR (Status
)) {
1559 // TheHandle is not valid, so do not add to handle list
1561 ListWalker
->TheHandle
= NULL
;
1563 return (ListWalker
->TheHandle
);
1570 Gets all the related EFI_HANDLEs based on the mask supplied.
1572 This function scans all EFI_HANDLES in the UEFI environment's handle database
1573 and returns the ones with the specified relationship (Mask) to the specified
1576 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
1577 If MatchingHandleCount is NULL, then ASSERT.
1579 If MatchingHandleBuffer is not NULL upon a successful return the memory must be
1582 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.
1583 @param[in] ControllerHandle The handle with Device Path protocol on it.
1584 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in
1585 MatchingHandleBuffer.
1586 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount
1587 EFI_HANDLEs with a terminating NULL EFI_HANDLE.
1588 @param[out] HandleType An array of type information.
1590 @retval EFI_SUCCESS The operation was successful, and any related handles
1591 are in MatchingHandleBuffer.
1592 @retval EFI_NOT_FOUND No matching handles were found.
1593 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
1597 ParseHandleDatabaseByRelationshipWithType (
1598 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
1599 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
1600 IN UINTN
*HandleCount
,
1601 OUT EFI_HANDLE
**HandleBuffer
,
1602 OUT UINTN
**HandleType
1607 EFI_GUID
**ProtocolGuidArray
;
1609 UINTN ProtocolIndex
;
1610 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfo
;
1611 UINTN OpenInfoCount
;
1612 UINTN OpenInfoIndex
;
1614 INTN DriverBindingHandleIndex
;
1616 ASSERT(HandleCount
!= NULL
);
1617 ASSERT(HandleBuffer
!= NULL
);
1618 ASSERT(HandleType
!= NULL
);
1619 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
1622 *HandleBuffer
= NULL
;
1626 // Retrieve the list of all handles from the handle database
1628 Status
= gBS
->LocateHandleBuffer (
1635 if (EFI_ERROR (Status
)) {
1639 *HandleType
= AllocateZeroPool (*HandleCount
* sizeof (UINTN
));
1640 ASSERT(*HandleType
!= NULL
);
1642 DriverBindingHandleIndex
= -1;
1643 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
1644 if (DriverBindingHandle
!= NULL
&& (*HandleBuffer
)[HandleIndex
] == DriverBindingHandle
) {
1645 DriverBindingHandleIndex
= (INTN
)HandleIndex
;
1649 for (HandleIndex
= 0; HandleIndex
< *HandleCount
; HandleIndex
++) {
1651 // Retrieve the list of all the protocols on each handle
1653 Status
= gBS
->ProtocolsPerHandle (
1654 (*HandleBuffer
)[HandleIndex
],
1658 if (EFI_ERROR (Status
)) {
1662 for (ProtocolIndex
= 0; ProtocolIndex
< ArrayCount
; ProtocolIndex
++) {
1665 // Set the bit describing what this handle has
1667 if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiLoadedImageProtocolGuid
) ) {
1668 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_IMAGE_HANDLE
;
1669 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverBindingProtocolGuid
) ) {
1670 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_BINDING_HANDLE
;
1671 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfiguration2ProtocolGuid
)) {
1672 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
1673 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverConfigurationProtocolGuid
) ) {
1674 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_CONFIGURATION_HANDLE
;
1675 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnostics2ProtocolGuid
) ) {
1676 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
1677 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDriverDiagnosticsProtocolGuid
) ) {
1678 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DRIVER_DIAGNOSTICS_HANDLE
;
1679 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentName2ProtocolGuid
) ) {
1680 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
1681 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiComponentNameProtocolGuid
) ) {
1682 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_COMPONENT_NAME_HANDLE
;
1683 } else if (CompareGuid (ProtocolGuidArray
[ProtocolIndex
], &gEfiDevicePathProtocolGuid
) ) {
1684 (*HandleType
)[HandleIndex
] |= (UINTN
)HR_DEVICE_HANDLE
;
1687 ASSERT((*HandleType
)[HandleIndex
] == (*HandleType
)[HandleIndex
]);
1691 // Retrieve the list of agents that have opened each protocol
1693 Status
= gBS
->OpenProtocolInformation (
1694 (*HandleBuffer
)[HandleIndex
],
1695 ProtocolGuidArray
[ProtocolIndex
],
1699 if (EFI_ERROR (Status
)) {
1703 if (ControllerHandle
== NULL
) {
1705 // ControllerHandle == NULL and DriverBindingHandle != NULL.
1706 // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
1708 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
1709 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
1710 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
1711 if (DriverBindingHandleIndex
!= -1) {
1712 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
1715 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
&& (OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1716 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
1717 if (DriverBindingHandleIndex
!= -1) {
1718 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
1720 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
1721 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
1722 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
1728 if (DriverBindingHandle
== NULL
&& ControllerHandle
!= NULL
) {
1729 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
1730 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
1731 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
1732 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
1733 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
1734 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
1735 (*HandleType
)[ChildIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
1739 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1740 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
1741 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
1742 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
1744 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
1745 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
1751 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
1752 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1753 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
1754 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
1760 if (DriverBindingHandle
!= NULL
&& ControllerHandle
!= NULL
) {
1761 if (ControllerHandle
== (*HandleBuffer
)[HandleIndex
]) {
1762 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CONTROLLER_HANDLE
);
1763 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
1764 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) != 0) {
1765 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
1766 if (DriverBindingHandleIndex
!= -1) {
1767 (*HandleType
)[DriverBindingHandleIndex
] |= (UINTN
)HR_DEVICE_DRIVER
;
1771 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1772 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== DriverBindingHandle
) {
1773 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
1774 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== (*HandleBuffer
)[ChildIndex
]) {
1775 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_CHILD_HANDLE
);
1780 for (ChildIndex
= 0; ChildIndex
< *HandleCount
; ChildIndex
++) {
1781 if (OpenInfo
[OpenInfoIndex
].AgentHandle
== (*HandleBuffer
)[ChildIndex
]) {
1782 (*HandleType
)[ChildIndex
] |= (UINTN
)(HR_BUS_DRIVER
| HR_DEVICE_DRIVER
);
1788 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++) {
1789 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1790 if (OpenInfo
[OpenInfoIndex
].ControllerHandle
== ControllerHandle
) {
1791 (*HandleType
)[HandleIndex
] |= (UINTN
)(HR_DEVICE_HANDLE
| HR_PARENT_HANDLE
);
1797 FreePool (OpenInfo
);
1799 FreePool (ProtocolGuidArray
);
1805 Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask
1808 This function will scan all EFI_HANDLES in the UEFI environment's handle database
1809 and return all the ones with the specified relationship (Mask) to the specified
1812 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
1813 If MatchingHandleCount is NULL, then ASSERT.
1815 If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be
1818 @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol
1820 @param[in] ControllerHandle Handle to a device with Device Path protocol on it.
1821 @param[in] Mask Mask of what relationship(s) is desired.
1822 @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in
1823 MatchingHandleBuffer.
1824 @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount
1825 EFI_HANDLEs and a terminating NULL EFI_HANDLE.
1827 @retval EFI_SUCCESS The operation was sucessful and any related handles
1828 are in MatchingHandleBuffer;
1829 @retval EFI_NOT_FOUND No matching handles were found.
1830 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
1834 ParseHandleDatabaseByRelationship (
1835 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL
,
1836 IN CONST EFI_HANDLE ControllerHandle OPTIONAL
,
1837 IN CONST UINTN Mask
,
1838 IN UINTN
*MatchingHandleCount
,
1839 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
1844 EFI_HANDLE
*HandleBuffer
;
1848 ASSERT(MatchingHandleCount
!= NULL
);
1849 ASSERT(DriverBindingHandle
!= NULL
|| ControllerHandle
!= NULL
);
1851 if ((Mask
& HR_VALID_MASK
) != Mask
) {
1852 return (EFI_INVALID_PARAMETER
);
1855 if ((Mask
& HR_CHILD_HANDLE
) != 0 && DriverBindingHandle
== NULL
) {
1856 return (EFI_INVALID_PARAMETER
);
1859 *MatchingHandleCount
= 0;
1860 if (MatchingHandleBuffer
!= NULL
) {
1861 *MatchingHandleBuffer
= NULL
;
1864 HandleBuffer
= NULL
;
1867 Status
= ParseHandleDatabaseByRelationshipWithType (
1868 DriverBindingHandle
,
1874 if (!EFI_ERROR (Status
)) {
1876 // Count the number of handles that match the attributes in Mask
1878 for (HandleIndex
= 0; HandleIndex
< HandleCount
; HandleIndex
++) {
1879 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
1880 (*MatchingHandleCount
)++;
1884 // If no handles match the attributes in Mask then return EFI_NOT_FOUND
1886 if (*MatchingHandleCount
== 0) {
1887 Status
= EFI_NOT_FOUND
;
1890 if (MatchingHandleBuffer
== NULL
) {
1892 // Someone just wanted the count...
1894 Status
= EFI_SUCCESS
;
1897 // Allocate a handle buffer for the number of handles that matched the attributes in Mask
1899 *MatchingHandleBuffer
= AllocateZeroPool ((*MatchingHandleCount
+1)* sizeof (EFI_HANDLE
));
1900 ASSERT(*MatchingHandleBuffer
!= NULL
);
1902 for (HandleIndex
= 0,*MatchingHandleCount
= 0
1903 ; HandleIndex
< HandleCount
1907 // Fill the allocated buffer with the handles that matched the attributes in Mask
1909 if ((HandleType
[HandleIndex
] & Mask
) == Mask
) {
1910 (*MatchingHandleBuffer
)[(*MatchingHandleCount
)++] = HandleBuffer
[HandleIndex
];
1915 // Make the last one NULL
1917 (*MatchingHandleBuffer
)[*MatchingHandleCount
] = NULL
;
1919 Status
= EFI_SUCCESS
;
1920 } // MacthingHandleBuffer == NULL (ELSE)
1921 } // *MatchingHandleCount == 0 (ELSE)
1922 } // no error on ParseHandleDatabaseByRelationshipWithType
1924 if (HandleBuffer
!= NULL
) {
1925 FreePool (HandleBuffer
);
1928 if (HandleType
!= NULL
) {
1929 FreePool (HandleType
);
1936 Gets handles for any child controllers of the passed in controller.
1938 @param[in] ControllerHandle The handle of the "parent controller"
1939 @param[in] MatchingHandleCount Pointer to the number of handles in
1940 MatchingHandleBuffer on return.
1941 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
1945 @retval EFI_SUCCESS The operation was sucessful.
1949 ParseHandleDatabaseForChildControllers(
1950 IN CONST EFI_HANDLE ControllerHandle
,
1951 IN UINTN
*MatchingHandleCount
,
1952 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
1957 UINTN DriverBindingHandleCount
;
1958 EFI_HANDLE
*DriverBindingHandleBuffer
;
1959 UINTN DriverBindingHandleIndex
;
1960 UINTN ChildControllerHandleCount
;
1961 EFI_HANDLE
*ChildControllerHandleBuffer
;
1962 UINTN ChildControllerHandleIndex
;
1963 EFI_HANDLE
*HandleBufferForReturn
;
1965 if (MatchingHandleCount
== NULL
) {
1966 return (EFI_INVALID_PARAMETER
);
1968 *MatchingHandleCount
= 0;
1970 Status
= PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
1972 &DriverBindingHandleCount
,
1973 &DriverBindingHandleBuffer
1975 if (EFI_ERROR (Status
)) {
1980 // Get a buffer big enough for all the controllers.
1982 HandleBufferForReturn
= GetHandleListByProtocol(NULL
);
1983 if (HandleBufferForReturn
== NULL
) {
1984 FreePool (DriverBindingHandleBuffer
);
1985 return (EFI_NOT_FOUND
);
1988 for (DriverBindingHandleIndex
= 0; DriverBindingHandleIndex
< DriverBindingHandleCount
; DriverBindingHandleIndex
++) {
1989 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
1990 DriverBindingHandleBuffer
[DriverBindingHandleIndex
],
1992 &ChildControllerHandleCount
,
1993 &ChildControllerHandleBuffer
1995 if (EFI_ERROR (Status
)) {
1999 for (ChildControllerHandleIndex
= 0;
2000 ChildControllerHandleIndex
< ChildControllerHandleCount
;
2001 ChildControllerHandleIndex
++
2003 for (HandleIndex
= 0; HandleIndex
< *MatchingHandleCount
; HandleIndex
++) {
2004 if (HandleBufferForReturn
[HandleIndex
] == ChildControllerHandleBuffer
[ChildControllerHandleIndex
]) {
2008 if (HandleIndex
>= *MatchingHandleCount
) {
2009 HandleBufferForReturn
[(*MatchingHandleCount
)++] = ChildControllerHandleBuffer
[ChildControllerHandleIndex
];
2013 FreePool (ChildControllerHandleBuffer
);
2016 FreePool (DriverBindingHandleBuffer
);
2018 if (MatchingHandleBuffer
!= NULL
) {
2019 *MatchingHandleBuffer
= HandleBufferForReturn
;
2021 FreePool(HandleBufferForReturn
);
2024 return (EFI_SUCCESS
);
2028 Appends 1 buffer to another buffer. This will re-allocate the destination buffer
2029 if necessary to fit all of the data.
2031 If DestinationBuffer is NULL, then ASSERT().
2033 @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.
2034 @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.
2035 @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.
2036 @param[in] SourceSize The number of bytes of SourceBuffer to append.
2038 @retval NULL A memory allocation failed.
2039 @retval NULL A parameter was invalid.
2040 @return A pointer to (*DestinationBuffer).
2045 IN OUT VOID
**DestinationBuffer
,
2046 IN OUT UINTN
*DestinationSize
,
2047 IN VOID
*SourceBuffer
,
2051 UINTN LocalDestinationSize
;
2052 UINTN LocalDestinationFinalSize
;
2054 ASSERT(DestinationBuffer
!= NULL
);
2056 if (SourceSize
== 0 || SourceBuffer
== NULL
) {
2057 return (*DestinationBuffer
);
2060 if (DestinationSize
== NULL
) {
2061 LocalDestinationSize
= 0;
2063 LocalDestinationSize
= *DestinationSize
;
2066 LocalDestinationFinalSize
= LocalDestinationSize
+ SourceSize
;
2068 if (DestinationSize
!= NULL
) {
2069 *DestinationSize
= LocalDestinationSize
;
2072 if (LocalDestinationSize
== 0) {
2074 *DestinationBuffer
= AllocateZeroPool(LocalDestinationFinalSize
);
2077 *DestinationBuffer
= ReallocatePool(LocalDestinationSize
, LocalDestinationFinalSize
, *DestinationBuffer
);
2080 ASSERT(*DestinationBuffer
!= NULL
);
2083 return (CopyMem(((UINT8
*)(*DestinationBuffer
)) + LocalDestinationSize
, SourceBuffer
, SourceSize
));
2087 Gets handles for any child devices produced by the passed in driver.
2089 @param[in] DriverHandle The handle of the driver.
2090 @param[in] MatchingHandleCount Pointer to the number of handles in
2091 MatchingHandleBuffer on return.
2092 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2094 @retval EFI_SUCCESS The operation was sucessful.
2095 @sa ParseHandleDatabaseByRelationship
2099 ParseHandleDatabaseForChildDevices(
2100 IN CONST EFI_HANDLE DriverHandle
,
2101 IN UINTN
*MatchingHandleCount
,
2102 OUT EFI_HANDLE
**MatchingHandleBuffer OPTIONAL
2106 EFI_HANDLE
*Buffer2
;
2111 UINTN HandleBufferSize
;
2113 ASSERT(MatchingHandleCount
!= NULL
);
2115 HandleBufferSize
= 0;
2118 *MatchingHandleCount
= 0;
2120 Status
= PARSE_HANDLE_DATABASE_DEVICES (
2125 if (!EFI_ERROR (Status
)) {
2126 for (HandleIndex
= 0; HandleIndex
< Count1
; HandleIndex
++) {
2128 // now find the children
2130 Status
= PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
2132 Buffer
[HandleIndex
],
2136 if (EFI_ERROR(Status
)) {
2140 // save out required and optional data elements
2142 *MatchingHandleCount
+= Count2
;
2143 if (MatchingHandleBuffer
!= NULL
) {
2144 *MatchingHandleBuffer
= BuffernCatGrow((VOID
**)MatchingHandleBuffer
, &HandleBufferSize
, Buffer2
, Count2
* sizeof(Buffer2
[0]));
2150 if (Buffer2
!= NULL
) {
2156 if (Buffer
!= NULL
) {
2163 Function to get all handles that support a given protocol or all handles.
2165 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL
2166 then the function will return all handles.
2168 @retval NULL A memory allocation failed.
2169 @return A NULL terminated list of handles.
2173 GetHandleListByProtocol (
2174 IN CONST EFI_GUID
*ProtocolGuid OPTIONAL
2177 EFI_HANDLE
*HandleList
;
2185 // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!
2187 if (ProtocolGuid
== NULL
) {
2188 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
2189 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2190 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
2191 if (HandleList
== NULL
) {
2194 Status
= gBS
->LocateHandle(AllHandles
, NULL
, NULL
, &Size
, HandleList
);
2195 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
2198 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
2199 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2200 HandleList
= AllocateZeroPool(Size
+ sizeof(EFI_HANDLE
));
2201 if (HandleList
== NULL
) {
2204 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)ProtocolGuid
, NULL
, &Size
, HandleList
);
2205 HandleList
[Size
/sizeof(EFI_HANDLE
)] = NULL
;
2208 if (EFI_ERROR(Status
)) {
2209 if (HandleList
!= NULL
) {
2210 FreePool(HandleList
);
2214 return (HandleList
);
2218 Function to get all handles that support some protocols.
2220 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
2222 @retval NULL A memory allocation failed.
2223 @retval NULL ProtocolGuids was NULL.
2224 @return A NULL terminated list of EFI_HANDLEs.
2228 GetHandleListByProtocolList (
2229 IN CONST EFI_GUID
**ProtocolGuids
2232 EFI_HANDLE
*HandleList
;
2237 CONST EFI_GUID
**GuidWalker
;
2238 EFI_HANDLE
*HandleWalker1
;
2239 EFI_HANDLE
*HandleWalker2
;
2243 TotalSize
= sizeof(EFI_HANDLE
);
2245 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++,Size
= 0){
2246 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &Size
, NULL
);
2247 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2253 // No handles were found...
2255 if (TotalSize
== sizeof(EFI_HANDLE
)) {
2259 HandleList
= AllocateZeroPool(TotalSize
);
2260 if (HandleList
== NULL
) {
2265 for (GuidWalker
= ProtocolGuids
; GuidWalker
!= NULL
&& *GuidWalker
!= NULL
; GuidWalker
++){
2266 TempSize
= TotalSize
- Size
;
2267 Status
= gBS
->LocateHandle(ByProtocol
, (EFI_GUID
*)(*GuidWalker
), NULL
, &TempSize
, HandleList
+(Size
/sizeof(EFI_HANDLE
)));
2270 // Allow for missing protocols... Only update the 'used' size upon success.
2272 if (!EFI_ERROR(Status
)) {
2276 ASSERT(HandleList
[(TotalSize
/sizeof(EFI_HANDLE
))-1] == NULL
);
2278 for (HandleWalker1
= HandleList
; HandleWalker1
!= NULL
&& *HandleWalker1
!= NULL
; HandleWalker1
++) {
2279 for (HandleWalker2
= HandleWalker1
+ 1; HandleWalker2
!= NULL
&& *HandleWalker2
!= NULL
; HandleWalker2
++) {
2280 if (*HandleWalker1
== *HandleWalker2
) {
2282 // copy memory back 1 handle width.
2284 CopyMem(HandleWalker2
, HandleWalker2
+ 1, TotalSize
- ((HandleWalker2
-HandleList
+1)*sizeof(EFI_HANDLE
)));
2289 return (HandleList
);