X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiHandleParsingLib%2FUefiHandleParsingLib.c;h=b375e06fd38163c65a2d19013050cc863ed51d60;hp=45ee9bd5d00164ff7f7cfbcf19a0b1fed062ce65;hb=c011b6c9e2baf57fc0557117e9875ceb3dca55a3;hpb=28981267c53451651743a04b132c48e2399fcddf diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index 45ee9bd5d0..b375e06fd3 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -1,7 +1,8 @@ /** @file Provides interface to advanced shell functionality for parsing both handle and protocol database. - Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
+ (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -15,8 +16,73 @@ #include "UefiHandleParsingLib.h" #include "IndustryStandard/Acpi10.h" -EFI_HANDLE mHandleParsingHiiHandle; +EFI_HANDLE mHandleParsingHiiHandle = NULL; HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0}; +GUID_INFO_BLOCK *GuidList; +UINTN GuidListCount; +/** + Function to translate the EFI_MEMORY_TYPE into a string. + + @param[in] Memory The memory type. + + @retval A string representation of the type allocated from BS Pool. +**/ +CHAR16* +EFIAPI +ConvertMemoryType ( + IN CONST EFI_MEMORY_TYPE Memory + ) +{ + CHAR16 *RetVal; + RetVal = NULL; + + switch (Memory) { + case EfiReservedMemoryType: StrnCatGrow(&RetVal, NULL, L"EfiReservedMemoryType", 0); break; + case EfiLoaderCode: StrnCatGrow(&RetVal, NULL, L"EfiLoaderCode", 0); break; + case EfiLoaderData: StrnCatGrow(&RetVal, NULL, L"EfiLoaderData", 0); break; + case EfiBootServicesCode: StrnCatGrow(&RetVal, NULL, L"EfiBootServicesCode", 0); break; + case EfiBootServicesData: StrnCatGrow(&RetVal, NULL, L"EfiBootServicesData", 0); break; + case EfiRuntimeServicesCode: StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesCode", 0); break; + case EfiRuntimeServicesData: StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesData", 0); break; + case EfiConventionalMemory: StrnCatGrow(&RetVal, NULL, L"EfiConventionalMemory", 0); break; + case EfiUnusableMemory: StrnCatGrow(&RetVal, NULL, L"EfiUnusableMemory", 0); break; + case EfiACPIReclaimMemory: StrnCatGrow(&RetVal, NULL, L"EfiACPIReclaimMemory", 0); break; + case EfiACPIMemoryNVS: StrnCatGrow(&RetVal, NULL, L"EfiACPIMemoryNVS", 0); break; + case EfiMemoryMappedIO: StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIO", 0); break; + case EfiMemoryMappedIOPortSpace: StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIOPortSpace", 0); break; + case EfiPalCode: StrnCatGrow(&RetVal, NULL, L"EfiPalCode", 0); break; + case EfiMaxMemoryType: StrnCatGrow(&RetVal, NULL, L"EfiMaxMemoryType", 0); break; + default: ASSERT(FALSE); + } + return (RetVal); +} + +/** + Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string. + + @param[in] Fmt The format type. + + @retval A string representation of the type allocated from BS Pool. +**/ +CHAR16* +EFIAPI +ConvertPixelFormat ( + IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt + ) +{ + CHAR16 *RetVal; + RetVal = NULL; + + switch (Fmt) { + case PixelRedGreenBlueReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelRedGreenBlueReserved8BitPerColor", 0); break; + case PixelBlueGreenRedReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelBlueGreenRedReserved8BitPerColor", 0); break; + case PixelBitMask: StrnCatGrow(&RetVal, NULL, L"PixelBitMask", 0); break; + case PixelBltOnly: StrnCatGrow(&RetVal, NULL, L"PixelBltOnly", 0); break; + case PixelFormatMax: StrnCatGrow(&RetVal, NULL, L"PixelFormatMax", 0); break; + default: ASSERT(FALSE); + } + return (RetVal); +} /** Constructor for the library. @@ -33,14 +99,28 @@ HandleParsingLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { - mHandleParsingHiiHandle = HiiAddPackages (&gHandleParsingHiiGuid, gImageHandle, UefiHandleParsingLibStrings, NULL); - if (mHandleParsingHiiHandle == NULL) { - return (EFI_DEVICE_ERROR); - } + GuidListCount = 0; + GuidList = NULL; + // + // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed. + // return (EFI_SUCCESS); } +/** + Initialization function for HII packages. + +**/ +VOID +HandleParsingHiiInit (VOID) +{ + if (mHandleParsingHiiHandle == NULL) { + mHandleParsingHiiHandle = HiiAddPackages (&gHandleParsingHiiGuid, gImageHandle, UefiHandleParsingLibStrings, NULL); + ASSERT (mHandleParsingHiiHandle != NULL); + } +} + /** Destructor for the library. free any resources. @@ -56,13 +136,29 @@ HandleParsingLibDestructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { + UINTN LoopCount; + + for (LoopCount = 0; GuidList != NULL && LoopCount < GuidListCount; LoopCount++) { + SHELL_FREE_NON_NULL(GuidList[LoopCount].GuidId); + } + + SHELL_FREE_NON_NULL(GuidList); if (mHandleParsingHiiHandle != NULL) { HiiRemovePackages(mHandleParsingHiiHandle); } return (EFI_SUCCESS); } -/* +/** + Function to dump information about LoadedImage. + + This will allocate the return buffer from boot services pool. + + @param[in] TheHandle The handle that has LoadedImage installed. + @param[in] Verbose TRUE for additional information, FALSE otherwise. + + @retval A poitner to a string containing the information. +**/ CHAR16* EFIAPI LoadedImageProtocolDumpInformation( @@ -70,96 +166,144 @@ LoadedImageProtocolDumpInformation( IN CONST BOOLEAN Verbose ) { - EFI_LOADED_IMAGE_PROTOCOL *Image; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *DevPath; - EFI_DEVICE_PATH_PROTOCOL *DevPathNode; - VOID *Buffer; - UINTN BufferSize; - UINT32 AuthenticationStatus; - EFI_GUID *NameGuid; - EFI_FIRMWARE_VOLUME_PROTOCOL *FV; - EFI_FIRMWARE_VOLUME2_PROTOCOL *FV2; - - FV = NULL; - FV2 = NULL; - Buffer = NULL; - BufferSize = 0; - - Status = HandleProtocol ( - TheHandle, - &gEfiLoadedImageProtocolGuid, - &Image); - ASSERT_EFI_ERROR(Status); + CHAR16 *RetVal; + CHAR16 *Temp; + CHAR16 *CodeType; + CHAR16 *DataType; + + if (!Verbose) { + return (CatSPrint(NULL, L"LoadedImage")); + } - DevPath = UnpackDevicePath (Image->FilePath); + HandleParsingHiiInit(); - if (DevPath == NULL) { + Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL); + RetVal = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize)); + if (Temp == NULL || RetVal == NULL) { + SHELL_FREE_NON_NULL(Temp); + SHELL_FREE_NON_NULL(RetVal); return NULL; } - DevPathNode = DevPath; + Status = gBS->OpenProtocol ( + TheHandle, + &gEfiLoadedImageProtocolGuid, + (VOID**)&LoadedImage, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); - while (!IsDevicePathEnd (DevPathNode)) { - // - // Find the Fv File path - // - NameGuid = GetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevPathNode); - if (NameGuid != NULL) { - Status = BS->HandleProtocol ( - Image->DeviceHandle, - &gEfiFirmwareVolumeProtocolGuid, - &FV - ); - if (!EFI_ERROR (Status)) { - Status = FV->ReadSection ( - FV, - NameGuid, - EFI_SECTION_USER_INTERFACE, - 0, - &Buffer, - &BufferSize, - &AuthenticationStatus - ); - if (!EFI_ERROR (Status)) { - break; - } + if (EFI_ERROR (Status)) { + SHELL_FREE_NON_NULL (Temp); + SHELL_FREE_NON_NULL (RetVal); + return NULL; + } - Buffer = NULL; - } else { - Status = BS->HandleProtocol ( - Image->DeviceHandle, - &gEfiFirmwareVolume2ProtocolGuid, - &FV2 - ); - if (!EFI_ERROR (Status)) { - Status = FV2->ReadSection ( - FV2, - NameGuid, - EFI_SECTION_USER_INTERFACE, - 0, - &Buffer, - &BufferSize, - &AuthenticationStatus - ); - if (!EFI_ERROR (Status)) { - break; - } + DataType = ConvertMemoryType(LoadedImage->ImageDataType); + CodeType = ConvertMemoryType(LoadedImage->ImageCodeType); + + RetVal = CatSPrint(RetVal, + Temp, + LoadedImage->Revision, + LoadedImage->ParentHandle, + LoadedImage->SystemTable, + LoadedImage->DeviceHandle, + LoadedImage->FilePath, + LoadedImage->LoadOptionsSize, + LoadedImage->LoadOptions, + LoadedImage->ImageBase, + LoadedImage->ImageSize, + CodeType, + DataType, + LoadedImage->Unload); - Buffer = NULL; - } - } - } - // - // Next device path node - // - DevPathNode = NextDevicePathNode (DevPathNode); + + SHELL_FREE_NON_NULL(Temp); + SHELL_FREE_NON_NULL(CodeType); + SHELL_FREE_NON_NULL(DataType); + + return RetVal; +} + +/** + Function to dump information about GOP. + + This will allocate the return buffer from boot services pool. + + @param[in] TheHandle The handle that has LoadedImage installed. + @param[in] Verbose TRUE for additional information, FALSE otherwise. + + @retval A poitner to a string containing the information. +**/ +CHAR16* +EFIAPI +GraphicsOutputProtocolDumpInformation( + IN CONST EFI_HANDLE TheHandle, + IN CONST BOOLEAN Verbose + ) +{ + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; + EFI_STATUS Status; + CHAR16 *RetVal; + CHAR16 *Temp; + CHAR16 *Fmt; + + if (!Verbose) { + return (CatSPrint(NULL, L"GraphicsOutput")); } - FreePool (DevPath); - return Buffer; + HandleParsingHiiInit(); + + Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_GOP_DUMP_MAIN), NULL); + RetVal = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize)); + if (Temp == NULL || RetVal == NULL) { + SHELL_FREE_NON_NULL(Temp); + SHELL_FREE_NON_NULL(RetVal); + return NULL; + } + + Status = gBS->OpenProtocol ( + TheHandle, + &gEfiGraphicsOutputProtocolGuid, + (VOID**)&GraphicsOutput, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + + if (EFI_ERROR (Status)) { + SHELL_FREE_NON_NULL (Temp); + SHELL_FREE_NON_NULL (RetVal); + return NULL; + } + + Fmt = ConvertPixelFormat(GraphicsOutput->Mode->Info->PixelFormat); + + RetVal = CatSPrint(RetVal, + Temp, + GraphicsOutput->Mode->MaxMode, + GraphicsOutput->Mode->Mode, + GraphicsOutput->Mode->FrameBufferBase, + (UINT64)GraphicsOutput->Mode->FrameBufferSize, + (UINT64)GraphicsOutput->Mode->SizeOfInfo, + GraphicsOutput->Mode->Info->Version, + GraphicsOutput->Mode->Info->HorizontalResolution, + GraphicsOutput->Mode->Info->VerticalResolution, + Fmt, + GraphicsOutput->Mode->Info->PixelsPerScanLine, + GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.RedMask, + GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.GreenMask, + GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.BlueMask + ); + + SHELL_FREE_NON_NULL(Temp); + SHELL_FREE_NON_NULL(Fmt); + + return RetVal; } -*/ /** Function to dump information about PciRootBridgeIo. @@ -193,6 +337,8 @@ PciRootBridgeIoDumpInformation( return (CatSPrint(NULL, L"PciRootBridgeIo")); } + HandleParsingHiiInit(); + Status = gBS->HandleProtocol( TheHandle, &gEfiPciRootBridgeIoProtocolGuid, @@ -203,14 +349,19 @@ PciRootBridgeIoDumpInformation( } Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_PH), NULL); - ASSERT (Temp != NULL); + if (Temp == NULL) { + return NULL; + } Temp2 = CatSPrint(L"\r\n", Temp, PciRootBridgeIo->ParentHandle); FreePool(Temp); RetVal = Temp2; Temp2 = NULL; Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_SEG), NULL); - ASSERT (Temp != NULL); + if (Temp == NULL) { + SHELL_FREE_NON_NULL(RetVal); + return NULL; + } Temp2 = CatSPrint(RetVal, Temp, PciRootBridgeIo->SegmentNumber); FreePool(Temp); FreePool(RetVal); @@ -222,7 +373,10 @@ PciRootBridgeIoDumpInformation( Status = PciRootBridgeIo->GetAttributes (PciRootBridgeIo, &Supports, &Attributes); if (!EFI_ERROR(Status)) { Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_ATT), NULL); - ASSERT (Temp != NULL); + if (Temp == NULL) { + SHELL_FREE_NON_NULL(RetVal); + return NULL; + } Temp2 = CatSPrint(RetVal, Temp, Attributes); FreePool(Temp); FreePool(RetVal); @@ -230,7 +384,10 @@ PciRootBridgeIoDumpInformation( Temp2 = NULL; Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS), NULL); - ASSERT (Temp != NULL); + if (Temp == NULL) { + SHELL_FREE_NON_NULL(RetVal); + return NULL; + } Temp2 = CatSPrint(RetVal, Temp, Supports); FreePool(Temp); FreePool(RetVal); @@ -242,7 +399,10 @@ PciRootBridgeIoDumpInformation( Status = PciRootBridgeIo->Configuration (PciRootBridgeIo, (VOID **) &Configuration); if (!EFI_ERROR(Status) && Configuration != NULL) { Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_TITLE), NULL); - ASSERT (Temp != NULL); + if (Temp == NULL) { + SHELL_FREE_NON_NULL(RetVal); + return NULL; + } Temp2 = CatSPrint(RetVal, Temp, Supports); FreePool(Temp); FreePool(RetVal); @@ -316,6 +476,8 @@ TxtOutProtocolDumpInformation( return (NULL); } + HandleParsingHiiInit(); + RetVal = NULL; Size = 0; @@ -414,19 +576,15 @@ DevicePathProtocolDumpInformation( CHAR16 *Temp; CHAR16 *Temp2; EFI_STATUS Status; - EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText; Temp = NULL; - Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID**)&DevPathToText); + Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (!EFI_ERROR(Status)) { - Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (!EFI_ERROR(Status)) { - // - // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line) - // - Temp = DevPathToText->ConvertDevicePathToText(DevPath, TRUE, TRUE); - gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL); - } + // + // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line) + // + Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE); + gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL); } if (!Verbose && Temp != NULL && StrLen(Temp) > 30) { Temp2 = NULL; @@ -437,6 +595,205 @@ DevicePathProtocolDumpInformation( return (Temp); } +/** + Function to dump information about EfiAdapterInformation Protocol. + + @param[in] TheHandle The handle that has the protocol installed. + @param[in] Verbose TRUE for additional information, FALSE otherwise. + + @retval A pointer to a string containing the information. +**/ +CHAR16* +EFIAPI +AdapterInformationDumpInformation ( + IN CONST EFI_HANDLE TheHandle, + IN CONST BOOLEAN Verbose + ) +{ + EFI_STATUS Status; + EFI_ADAPTER_INFORMATION_PROTOCOL *EfiAdptrInfoProtocol; + UINTN InfoTypesBufferCount; + UINTN GuidIndex; + EFI_GUID *InfoTypesBuffer; + CHAR16 *GuidStr; + CHAR16 *TempStr; + CHAR16 *RetVal; + VOID *InformationBlock; + UINTN InformationBlockSize; + + if (!Verbose) { + return (CatSPrint(NULL, L"AdapterInfo")); + } + + InfoTypesBuffer = NULL; + InformationBlock = NULL; + + // + // Allocate print buffer to store data + // + RetVal = AllocateZeroPool (PcdGet16(PcdShellPrintBufferSize)); + if (RetVal == NULL) { + return NULL; + } + + Status = gBS->OpenProtocol ( + (EFI_HANDLE) (TheHandle), + &gEfiAdapterInformationProtocolGuid, + (VOID **) &EfiAdptrInfoProtocol, + NULL, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + + if (EFI_ERROR (Status)) { + SHELL_FREE_NON_NULL (RetVal); + return NULL; + } + + // + // Get a list of supported information types for this instance of the protocol. + // + Status = EfiAdptrInfoProtocol->GetSupportedTypes ( + EfiAdptrInfoProtocol, + &InfoTypesBuffer, + &InfoTypesBufferCount + ); + if (EFI_ERROR (Status)) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED), NULL); + if (TempStr != NULL) { + RetVal = CatSPrint (RetVal, TempStr, Status); + } else { + goto ERROR_EXIT; + } + } else { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SUPP_TYPE_HEADER), NULL); + if (TempStr == NULL) { + goto ERROR_EXIT; + } + RetVal = CatSPrint (RetVal, TempStr); + SHELL_FREE_NON_NULL (TempStr); + + for (GuidIndex = 0; GuidIndex < InfoTypesBufferCount; GuidIndex++) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_NUMBER), NULL); + if (TempStr == NULL) { + goto ERROR_EXIT; + } + RetVal = CatSPrint (RetVal, TempStr, (GuidIndex + 1), InfoTypesBuffer[GuidIndex]); + SHELL_FREE_NON_NULL (TempStr); + + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_STRING), NULL); + if (TempStr == NULL) { + goto ERROR_EXIT; + } + + if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) { + RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoMediaStateGuid"); + } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) { + RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoNetworkBootGuid"); + } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid)) { + RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoSanMacAddressGuid"); + } else { + + GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL); + + if (GuidStr != NULL) { + if (StrCmp(GuidStr, L"UnknownDevice") == 0) { + RetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType"); + + SHELL_FREE_NON_NULL (TempStr); + SHELL_FREE_NON_NULL(GuidStr); + // + // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP + // + continue; + } else { + RetVal = CatSPrint (RetVal, TempStr, GuidStr); + SHELL_FREE_NON_NULL(GuidStr); + } + } + } + + SHELL_FREE_NON_NULL (TempStr); + + Status = EfiAdptrInfoProtocol->GetInformation ( + EfiAdptrInfoProtocol, + &InfoTypesBuffer[GuidIndex], + &InformationBlock, + &InformationBlockSize + ); + + if (EFI_ERROR (Status)) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GETINFO_FAILED), NULL); + if (TempStr == NULL) { + goto ERROR_EXIT; + } + RetVal = CatSPrint (RetVal, TempStr, Status); + } else { + if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_MEDIA_STATE), NULL); + if (TempStr == NULL) { + goto ERROR_EXIT; + } + RetVal = CatSPrint ( + RetVal, + TempStr, + ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState, + ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState + ); + } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_NETWORK_BOOT_INFO), NULL); + if (TempStr == NULL) { + goto ERROR_EXIT; + } + RetVal = CatSPrint ( + RetVal, + TempStr, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4BootCapablity, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6BootCapablity, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBootCapablity, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->OffloadCapability, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiMpioCapability, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4Boot, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6Boot, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBoot + ); + } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid) == TRUE) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO), NULL); + if (TempStr == NULL) { + goto ERROR_EXIT; + } + RetVal = CatSPrint ( + RetVal, + TempStr, + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[0], + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[1], + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[2], + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[3], + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[4], + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[5] + ); + } else { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE), NULL); + if (TempStr == NULL) { + goto ERROR_EXIT; + } + RetVal = CatSPrint (RetVal, TempStr, &InfoTypesBuffer[GuidIndex]); + } + } + SHELL_FREE_NON_NULL (TempStr); + SHELL_FREE_NON_NULL (InformationBlock); + } + } + + SHELL_FREE_NON_NULL (InfoTypesBuffer); + return RetVal; + +ERROR_EXIT: + SHELL_FREE_NON_NULL (RetVal); + SHELL_FREE_NON_NULL (InfoTypesBuffer); + SHELL_FREE_NON_NULL (InformationBlock); + return NULL; +} // // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg // @@ -458,6 +815,21 @@ STATIC CONST EFI_GUID WinNtThunkProtocolGuid = LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_G STATIC CONST EFI_GUID WinNtIoProtocolGuid = LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID; STATIC CONST EFI_GUID WinNtSerialPortGuid = LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID; +// +// Deprecated protocols we dont want to link from IntelFrameworkModulePkg +// +#define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \ + { \ + 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ + } +#define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \ + { \ + 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \ + } +STATIC CONST EFI_GUID EfiIsaIoProtocolGuid = LOCAL_EFI_ISA_IO_PROTOCOL_GUID; +STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid = LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID; + + STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = { {STRING_TOKEN(STR_WINNT_THUNK), (EFI_GUID*)&WinNtThunkProtocolGuid, NULL}, {STRING_TOKEN(STR_WINNT_DRIVER_IO), (EFI_GUID*)&WinNtIoProtocolGuid, NULL}, @@ -466,7 +838,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = { }; STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { - {STRING_TOKEN(STR_LOADED_IMAGE), &gEfiLoadedImageProtocolGuid, NULL}, + {STRING_TOKEN(STR_LOADED_IMAGE), &gEfiLoadedImageProtocolGuid, LoadedImageProtocolDumpInformation}, {STRING_TOKEN(STR_DEVICE_PATH), &gEfiDevicePathProtocolGuid, DevicePathProtocolDumpInformation}, {STRING_TOKEN(STR_IMAGE_PATH), &gEfiLoadedImageDevicePathProtocolGuid, DevicePathProtocolDumpInformation}, {STRING_TOKEN(STR_DEVICE_PATH_UTIL), &gEfiDevicePathUtilitiesProtocolGuid, NULL}, @@ -491,7 +863,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { {STRING_TOKEN(STR_SIM_POINTER), &gEfiSimplePointerProtocolGuid, NULL}, {STRING_TOKEN(STR_ABS_POINTER), &gEfiAbsolutePointerProtocolGuid, NULL}, {STRING_TOKEN(STR_SERIAL_IO), &gEfiSerialIoProtocolGuid, NULL}, - {STRING_TOKEN(STR_GRAPHICS_OUTPUT), &gEfiGraphicsOutputProtocolGuid, NULL}, + {STRING_TOKEN(STR_GRAPHICS_OUTPUT), &gEfiGraphicsOutputProtocolGuid, GraphicsOutputProtocolDumpInformation}, {STRING_TOKEN(STR_EDID_DISCOVERED), &gEfiEdidDiscoveredProtocolGuid, NULL}, {STRING_TOKEN(STR_EDID_ACTIVE), &gEfiEdidActiveProtocolGuid, NULL}, {STRING_TOKEN(STR_EDID_OVERRIDE), &gEfiEdidOverrideProtocolGuid, NULL}, @@ -537,8 +909,6 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { {STRING_TOKEN(STR_IPV4_SB), &gEfiIp4ServiceBindingProtocolGuid, NULL}, {STRING_TOKEN(STR_IPV4), &gEfiIp4ProtocolGuid, NULL}, {STRING_TOKEN(STR_IPV4_CFG), &gEfiIp4ConfigProtocolGuid, NULL}, - {STRING_TOKEN(STR_SHELL_PARAMETERS), &gEfiShellParametersProtocolGuid, NULL}, - {STRING_TOKEN(STR_SHELL), &gEfiShellProtocolGuid, NULL}, {STRING_TOKEN(STR_UDPV4_SB), &gEfiUdp4ServiceBindingProtocolGuid, NULL}, {STRING_TOKEN(STR_UDPV4), &gEfiUdp4ProtocolGuid, NULL}, {STRING_TOKEN(STR_MTFTPV4_SB), &gEfiMtftp4ServiceBindingProtocolGuid, NULL}, @@ -572,6 +942,12 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { {STRING_TOKEN(STR_DRIVER_CONFIG), &gEfiDriverConfigurationProtocolGuid, NULL}, {STRING_TOKEN(STR_DRIVER_CONFIG2), &gEfiDriverConfiguration2ProtocolGuid, NULL}, +// +// these are using local (non-global) definitions to reduce package dependancy. +// + {STRING_TOKEN(STR_ISA_IO), (EFI_GUID*)&EfiIsaIoProtocolGuid, NULL}, + {STRING_TOKEN(STR_ISA_ACPI), (EFI_GUID*)&EfiIsaAcpiProtocolGuid, NULL}, + // // the ones under this are GUID identified structs, not protocols // @@ -622,7 +998,29 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { {STRING_TOKEN(STR_KMS), &gEfiKmsProtocolGuid, NULL}, {STRING_TOKEN(STR_BLK_IO2), &gEfiBlockIo2ProtocolGuid, NULL}, {STRING_TOKEN(STR_SSC), &gEfiStorageSecurityCommandProtocolGuid, NULL}, - {STRING_TOKEN(STR_UC2), &gEfiUserCredential2ProtocolGuid, NULL}, + {STRING_TOKEN(STR_UCRED2), &gEfiUserCredential2ProtocolGuid, NULL}, + +// +// UEFI 2.4 +// + {STRING_TOKEN(STR_DISK_IO2), &gEfiDiskIo2ProtocolGuid, NULL}, + {STRING_TOKEN(STR_ADAPTER_INFO), &gEfiAdapterInformationProtocolGuid, AdapterInformationDumpInformation}, + +// +// PI Spec ones +// + {STRING_TOKEN(STR_IDE_CONT_INIT), &gEfiIdeControllerInitProtocolGuid, NULL}, + +// +// UEFI Shell Spec 2.0 +// + {STRING_TOKEN(STR_SHELL_PARAMETERS), &gEfiShellParametersProtocolGuid, NULL}, + {STRING_TOKEN(STR_SHELL), &gEfiShellProtocolGuid, NULL}, + +// +// UEFI Shell Spec 2.1 +// + {STRING_TOKEN(STR_SHELL_DYNAMIC), &gEfiShellDynamicCommandProtocolGuid, NULL}, // // terminator @@ -646,9 +1044,16 @@ InternalShellGetNodeFromGuid( ) { CONST GUID_INFO_BLOCK *ListWalker; + UINTN LoopCount; ASSERT(Guid != NULL); + for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) { + if (CompareGuid(ListWalker->GuidId, Guid)) { + return (ListWalker); + } + } + if (PcdGetBool(PcdShellIncludeNtGuids)) { for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) { if (CompareGuid(ListWalker->GuidId, Guid)) { @@ -661,7 +1066,90 @@ InternalShellGetNodeFromGuid( return (ListWalker); } } - return (ListWalker); + return (NULL); +} + +/** +Function to add a new GUID/Name mapping. + +@param[in] Guid The Guid +@param[in] NameID The STRING id of the HII string to use +@param[in] DumpFunc The pointer to the dump function + + +@retval EFI_SUCCESS The operation was sucessful +@retval EFI_OUT_OF_RESOURCES A memory allocation failed +@retval EFI_INVALID_PARAMETER Guid NameId was invalid +**/ +EFI_STATUS +EFIAPI +InsertNewGuidNameMapping( + IN CONST EFI_GUID *Guid, + IN CONST EFI_STRING_ID NameID, + IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL + ) +{ + ASSERT(Guid != NULL); + ASSERT(NameID != 0); + + GuidList = ReallocatePool(GuidListCount * sizeof(GUID_INFO_BLOCK), GuidListCount+1 * sizeof(GUID_INFO_BLOCK), GuidList); + if (GuidList == NULL) { + GuidListCount = 0; + return (EFI_OUT_OF_RESOURCES); + } + GuidListCount++; + + GuidList[GuidListCount - 1].GuidId = AllocateCopyPool(sizeof(EFI_GUID), Guid); + GuidList[GuidListCount - 1].StringId = NameID; + GuidList[GuidListCount - 1].DumpInfo = DumpFunc; + + if (GuidList[GuidListCount - 1].GuidId == NULL) { + return (EFI_OUT_OF_RESOURCES); + } + + return (EFI_SUCCESS); +} + +/** + Function to add a new GUID/Name mapping. + + This cannot overwrite an existing mapping. + + @param[in] Guid The Guid + @param[in] TheName The Guid's name + @param[in] Lang RFC4646 language code list or NULL + + @retval EFI_SUCCESS The operation was sucessful + @retval EFI_ACCESS_DENIED There was a duplicate + @retval EFI_OUT_OF_RESOURCES A memory allocation failed + @retval EFI_INVALID_PARAMETER Guid or TheName was NULL +**/ +EFI_STATUS +EFIAPI +AddNewGuidNameMapping( + IN CONST EFI_GUID *Guid, + IN CONST CHAR16 *TheName, + IN CONST CHAR8 *Lang OPTIONAL + ) +{ + EFI_STRING_ID NameID; + + HandleParsingHiiInit(); + + if (Guid == NULL || TheName == NULL){ + return (EFI_INVALID_PARAMETER); + } + + if ((InternalShellGetNodeFromGuid(Guid)) != NULL) { + return (EFI_ACCESS_DENIED); + } + + NameID = HiiSetString(mHandleParsingHiiHandle, 0, (CHAR16*)TheName, Lang); + if (NameID == 0) { + return (EFI_OUT_OF_RESOURCES); + } + + return (InsertNewGuidNameMapping(Guid, NameID, NULL)); } /** @@ -684,8 +1172,10 @@ GetStringNameFromGuid( { CONST GUID_INFO_BLOCK *Id; + HandleParsingHiiInit(); + Id = InternalShellGetNodeFromGuid(Guid); - return (HiiGetString(mHandleParsingHiiHandle, Id->StringId, Lang)); + return (HiiGetString(mHandleParsingHiiHandle, Id==NULL?STRING_TOKEN(STR_UNKNOWN_DEVICE):Id->StringId, Lang)); } /** @@ -731,9 +1221,11 @@ GetProtocolInformationDump( /** Function to get the Guid for a protocol or struct based on it's string name. + do not modify the returned Guid. + @param[in] Name The pointer to the string name. @param[in] Lang The pointer to the language code. - @param[in] Guid The pointer to the Guid. + @param[out] Guid The pointer to the Guid. @retval EFI_SUCCESS The operation was sucessful. **/ @@ -742,11 +1234,14 @@ EFIAPI GetGuidFromStringName( IN CONST CHAR16 *Name, IN CONST CHAR8 *Lang OPTIONAL, - IN EFI_GUID **Guid + OUT EFI_GUID **Guid ) { CONST GUID_INFO_BLOCK *ListWalker; CHAR16 *String; + UINTN LoopCount; + + HandleParsingHiiInit(); ASSERT(Guid != NULL); if (Guid == NULL) { @@ -757,7 +1252,7 @@ GetGuidFromStringName( if (PcdGetBool(PcdShellIncludeNtGuids)) { for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) { String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang); - if (Name != NULL && String != NULL && StrCmp(Name, String)==0) { + if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) { *Guid = ListWalker->GuidId; } SHELL_FREE_NON_NULL(String); @@ -768,7 +1263,7 @@ GetGuidFromStringName( } for (ListWalker = mGuidStringList ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) { String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang); - if (Name != NULL && String != NULL && StrCmp(Name, String)==0) { + if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) { *Guid = ListWalker->GuidId; } SHELL_FREE_NON_NULL(String); @@ -776,24 +1271,39 @@ GetGuidFromStringName( return (EFI_SUCCESS); } } + + for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) { + String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang); + if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) { + *Guid = ListWalker->GuidId; + } + SHELL_FREE_NON_NULL(String); + if (*Guid != NULL) { + return (EFI_SUCCESS); + } + } + return (EFI_NOT_FOUND); } /** Get best support language for this driver. - First base on the current platform used language to search,Second base on the - default language to search. The caller need to free the buffer of the best - language. + First base on the user input language to search, second base on the current + platform used language to search, third get the first language from the + support language list. The caller need to free the buffer of the best language. @param[in] SupportedLanguages The support languages for this driver. + @param[in] InputLanguage The user input language. @param[in] Iso639Language Whether get language for ISO639. @return The best support language for this driver. **/ CHAR8 * +EFIAPI GetBestLanguageForDriver ( - IN CONST CHAR8 *SupportedLanguages, + IN CONST CHAR8 *SupportedLanguages, + IN CONST CHAR8 *InputLanguage, IN BOOLEAN Iso639Language ) { @@ -805,8 +1315,9 @@ GetBestLanguageForDriver ( BestLanguage = GetBestLanguage( SupportedLanguages, Iso639Language, + (InputLanguage != NULL) ? InputLanguage : "", (LanguageVariable != NULL) ? LanguageVariable : "", - Iso639Language ? "en" : "en-US", + SupportedLanguages, NULL ); @@ -849,12 +1360,8 @@ GetStringNameFromHandle( NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (!EFI_ERROR(Status)) { - if (Language == NULL) { - BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, FALSE); - Language = BestLang; - } - Status = CompNameStruct->GetDriverName(CompNameStruct, (CHAR8*)Language, &RetVal); - + BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE); + Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal); if (BestLang != NULL) { FreePool (BestLang); BestLang = NULL; @@ -871,12 +1378,8 @@ GetStringNameFromHandle( NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (!EFI_ERROR(Status)) { - if (Language == NULL) { - BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, FALSE); - Language = BestLang; - } - Status = CompNameStruct->GetDriverName(CompNameStruct, (CHAR8*)Language, &RetVal); - + BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE); + Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal); if (BestLang != NULL) { FreePool (BestLang); } @@ -1148,23 +1651,23 @@ ParseHandleDatabaseByRelationshipWithType ( // Set the bit describing what this handle has // if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid) ) { - (*HandleType)[HandleIndex] |= HR_IMAGE_HANDLE; + (*HandleType)[HandleIndex] |= (UINTN)HR_IMAGE_HANDLE; } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid) ) { - (*HandleType)[HandleIndex] |= HR_DRIVER_BINDING_HANDLE; + (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_BINDING_HANDLE; } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfiguration2ProtocolGuid)) { - (*HandleType)[HandleIndex] |= HR_DRIVER_CONFIGURATION_HANDLE; + (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_CONFIGURATION_HANDLE; } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid) ) { - (*HandleType)[HandleIndex] |= HR_DRIVER_CONFIGURATION_HANDLE; + (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_CONFIGURATION_HANDLE; } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnostics2ProtocolGuid) ) { - (*HandleType)[HandleIndex] |= HR_DRIVER_DIAGNOSTICS_HANDLE; + (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_DIAGNOSTICS_HANDLE; } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid) ) { - (*HandleType)[HandleIndex] |= HR_DRIVER_DIAGNOSTICS_HANDLE; + (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_DIAGNOSTICS_HANDLE; } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid) ) { - (*HandleType)[HandleIndex] |= HR_COMPONENT_NAME_HANDLE; + (*HandleType)[HandleIndex] |= (UINTN)HR_COMPONENT_NAME_HANDLE; } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) { - (*HandleType)[HandleIndex] |= HR_COMPONENT_NAME_HANDLE; + (*HandleType)[HandleIndex] |= (UINTN)HR_COMPONENT_NAME_HANDLE; } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid) ) { - (*HandleType)[HandleIndex] |= HR_DEVICE_HANDLE; + (*HandleType)[HandleIndex] |= (UINTN)HR_DEVICE_HANDLE; } else { DEBUG_CODE_BEGIN(); ASSERT((*HandleType)[HandleIndex] == (*HandleType)[HandleIndex]); @@ -1190,19 +1693,19 @@ ParseHandleDatabaseByRelationshipWithType ( // for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) { if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) { - (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE); + (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE); if (DriverBindingHandleIndex != -1) { - (*HandleType)[DriverBindingHandleIndex] |= HR_DEVICE_DRIVER; + (*HandleType)[DriverBindingHandleIndex] |= (UINTN)HR_DEVICE_DRIVER; } } if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { - (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE); + (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE); if (DriverBindingHandleIndex != -1) { - (*HandleType)[DriverBindingHandleIndex] |= (HR_BUS_DRIVER | HR_DEVICE_DRIVER); + (*HandleType)[DriverBindingHandleIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER); } for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) { if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) { - (*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE); + (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE); } } } @@ -1210,22 +1713,22 @@ ParseHandleDatabaseByRelationshipWithType ( } if (DriverBindingHandle == NULL && ControllerHandle != NULL) { if (ControllerHandle == (*HandleBuffer)[HandleIndex]) { - (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE); + (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE); for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) { if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) { for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) { if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) { - (*HandleType)[ChildIndex] |= HR_DEVICE_DRIVER; + (*HandleType)[ChildIndex] |= (UINTN)HR_DEVICE_DRIVER; } } } if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) { if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) { - (*HandleType)[ChildIndex] |= (HR_BUS_DRIVER | HR_DEVICE_DRIVER); + (*HandleType)[ChildIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER); } if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) { - (*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE); + (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE); } } } @@ -1234,7 +1737,7 @@ ParseHandleDatabaseByRelationshipWithType ( for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) { if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) { - (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_PARENT_HANDLE); + (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_PARENT_HANDLE); } } } @@ -1242,12 +1745,12 @@ ParseHandleDatabaseByRelationshipWithType ( } if (DriverBindingHandle != NULL && ControllerHandle != NULL) { if (ControllerHandle == (*HandleBuffer)[HandleIndex]) { - (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE); + (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE); for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) { if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) { if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) { if (DriverBindingHandleIndex != -1) { - (*HandleType)[DriverBindingHandleIndex] |= HR_DEVICE_DRIVER; + (*HandleType)[DriverBindingHandleIndex] |= (UINTN)HR_DEVICE_DRIVER; } } } @@ -1255,14 +1758,14 @@ ParseHandleDatabaseByRelationshipWithType ( if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) { for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) { if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) { - (*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE); + (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE); } } } for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) { if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) { - (*HandleType)[ChildIndex] |= (HR_BUS_DRIVER | HR_DEVICE_DRIVER); + (*HandleType)[ChildIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER); } } } @@ -1271,7 +1774,7 @@ ParseHandleDatabaseByRelationshipWithType ( for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) { if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) { - (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_PARENT_HANDLE); + (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_PARENT_HANDLE); } } }