+ ASSERT_EFI_ERROR(Status);\r
+ ASSERT (Dev != NULL && Dev->Mode != NULL);\r
+\r
+ Size = (Dev->Mode->MaxMode + 1) * 80;\r
+ RetVal = AllocateZeroPool(Size);\r
+\r
+ Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER), NULL);\r
+ if (Temp != NULL) {\r
+ UnicodeSPrint(RetVal, Size, Temp, Dev, Dev->Mode->Attribute);\r
+ FreePool(Temp);\r
+ }\r
+\r
+ //\r
+ // Dump TextOut Info\r
+ //\r
+ Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE), NULL);\r
+ for (Index = 0; Index < Dev->Mode->MaxMode; Index++) {\r
+ Status = Dev->QueryMode (Dev, Index, &Col, &Row);\r
+ NewSize = Size - StrSize(RetVal);\r
+ UnicodeSPrint(\r
+ RetVal + StrLen(RetVal),\r
+ NewSize,\r
+ Temp == NULL?L"":Temp,\r
+ Index == Dev->Mode->Mode ? L'*' : L' ',\r
+ Index,\r
+ !EFI_ERROR(Status)?(INTN)Col:-1,\r
+ !EFI_ERROR(Status)?(INTN)Row:-1\r
+ );\r
+ }\r
+ FreePool(Temp);\r
+ return (RetVal);\r
+}\r
+\r
+STATIC CONST UINTN VersionStringSize = 60;\r
+\r
+/**\r
+ Function to dump information about EfiDriverSupportedEfiVersion protocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A poitner to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+DriverEfiVersionProtocolDumpInformation(\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *DriverEfiVersion;\r
+ EFI_STATUS Status;\r
+ CHAR16 *RetVal;\r
+\r
+ Status = gBS->HandleProtocol(\r
+ TheHandle,\r
+ &gEfiDriverSupportedEfiVersionProtocolGuid,\r
+ (VOID**)&DriverEfiVersion);\r
+\r
+ ASSERT_EFI_ERROR(Status);\r
+\r
+ RetVal = AllocateZeroPool(VersionStringSize);\r
+ if (RetVal != NULL) {\r
+ UnicodeSPrint (RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);\r
+ }\r
+ return (RetVal);\r
+}\r
+/**\r
+ Function to convert device path to string.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] DevPath Pointer to device path instance.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+ @param[in] Length Maximum allowed text length of the device path.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+ConvertDevicePathToShortText(\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
+ IN CONST BOOLEAN Verbose,\r
+ IN CONST UINTN Length\r
+ )\r
+{\r
+ CHAR16 *Temp;\r
+ CHAR16 *Temp2;\r
+ UINTN Size;\r
+\r
+ //\r
+ // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)\r
+ //\r
+ Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);\r
+ if (!Verbose && Temp != NULL && StrLen(Temp) > Length) {\r
+ Temp2 = NULL;\r
+ Size = 0;\r
+ Temp2 = StrnCatGrow(&Temp2, &Size, L"..", 0);\r
+ Temp2 = StrnCatGrow(&Temp2, &Size, Temp+(StrLen(Temp) - (Length - 2)), 0);\r
+ FreePool(Temp);\r
+ Temp = Temp2;\r
+ }\r
+ return (Temp);\r
+}\r
+\r
+/**\r
+ Function to dump protocol information.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+ @param[in] Protocol The protocol is needed to dump.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+STATIC CHAR16*\r
+EFIAPI\r
+DevicePathProtocolDumpInformationEx (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose,\r
+ IN EFI_GUID *Protocol\r
+)\r
+{\r
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
+ CHAR16 *DevPathStr;\r
+ CHAR16 *DevPathStrTemp;\r
+ UINTN Size;\r
+ EFI_STATUS Status;\r
+ DevPathStr = NULL;\r
+ DevPathStrTemp = NULL;\r
+ Status = gBS->OpenProtocol(TheHandle, Protocol, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
+ if (!EFI_ERROR(Status)) {\r
+ DevPathStr = ConvertDevicePathToShortText (DevPath, Verbose, 30);\r
+ if (Verbose) {\r
+ Size = StrSize(DevPathStr) + sizeof(CHAR16) * 2;\r
+ DevPathStrTemp = AllocateZeroPool (Size);\r
+ if (DevPathStrTemp != NULL) {\r
+ StrnCatS (DevPathStrTemp, Size/sizeof(CHAR16), L" ", 2);\r
+ StrnCatS (DevPathStrTemp, Size/sizeof(CHAR16), DevPathStr, StrLen (DevPathStr));\r
+ }\r
+ FreePool (DevPathStr);\r
+ DevPathStr = DevPathStrTemp;\r
+ }\r
+ gBS->CloseProtocol(TheHandle, Protocol, gImageHandle, NULL);\r
+ }\r
+ return DevPathStr;\r
+}\r
+\r
+/**\r
+ Function to dump information about DevicePath protocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+DevicePathProtocolDumpInformation(\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiDevicePathProtocolGuid);\r
+}\r
+\r
+/**\r
+ Function to dump information about LoadedImageDevicePath protocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+LoadedImageDevicePathProtocolDumpInformation(\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiLoadedImageDevicePathProtocolGuid);\r
+}\r
+\r
+/**\r
+ Function to dump information about BusSpecificDriverOverride protocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+BusSpecificDriverOverrideProtocolDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ CHAR16 *GetString;\r
+ CHAR16 *RetVal;\r
+ CHAR16 *TempRetVal;\r
+ EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;\r
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
+ EFI_HANDLE ImageHandle;\r
+ UINTN Size;\r
+\r
+ if (!Verbose) {\r
+ return NULL;\r
+ }\r
+ Size = 0;\r
+ GetString = NULL;\r
+ RetVal = NULL;\r
+ TempRetVal = NULL;\r
+ ImageHandle = 0;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ TheHandle,\r
+ &gEfiBusSpecificDriverOverrideProtocolGuid,\r
+ (VOID**)&BusSpecificDriverOverride,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+ HandleParsingHiiInit ();\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_BSDO_DUMP_MAIN), NULL);\r
+ if (GetString == NULL) {\r
+ return NULL;\r
+ }\r
+ do {\r
+ Status = BusSpecificDriverOverride->GetDriver (\r
+ BusSpecificDriverOverride,\r
+ &ImageHandle\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = gBS->HandleProtocol (\r
+ ImageHandle,\r
+ &gEfiLoadedImageProtocolGuid,\r
+ (VOID **) &LoadedImage\r
+ );\r
+ if(!EFI_ERROR (Status)) {\r
+ TempRetVal = CatSPrint (\r
+ TempRetVal,\r
+ GetString,\r
+ ConvertHandleToHandleIndex (ImageHandle),\r
+ ConvertDevicePathToText (LoadedImage->FilePath, TRUE, TRUE)\r
+ );\r
+ StrnCatGrow (&RetVal, &Size, TempRetVal, 0);\r
+ SHELL_FREE_NON_NULL (TempRetVal);\r
+ }\r
+ }\r
+ } while (!EFI_ERROR (Status));\r
+\r
+ SHELL_FREE_NON_NULL (GetString);\r
+ return RetVal;\r
+}\r
+\r
+/**\r
+ Function to dump information about BlockIo protocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+BlockIoProtocolDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+ EFI_BLOCK_IO_MEDIA *BlockMedia;\r
+ CHAR16 *GetString;\r
+ CHAR16 *RetVal;\r
+\r
+ if (!Verbose) {\r
+ return NULL;\r
+ }\r
+ GetString = NULL;\r
+ RetVal = NULL;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ TheHandle,\r
+ &gEfiBlockIoProtocolGuid,\r
+ (VOID**)&BlockIo,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+ BlockMedia = BlockIo->Media;\r
+ //\r
+ // Per spec:\r
+ // The function (ReadBlocks) must return EFI_NO_MEDIA or\r
+ // EFI_MEDIA_CHANGED even if LBA, BufferSize, or Buffer are invalid so the caller can probe\r
+ // for changes in media state.\r
+ //\r
+ BlockIo->ReadBlocks (\r
+ BlockIo,\r
+ BlockIo->Media->MediaId,\r
+ 0,\r
+ 0,\r
+ NULL\r
+ );\r
+\r
+ HandleParsingHiiInit ();\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_BLOCKIO_INFO), NULL);\r
+ if (GetString == NULL) {\r
+ return NULL;\r
+ }\r
+ RetVal = CatSPrint (\r
+ RetVal,\r
+ GetString,\r
+ BlockMedia->RemovableMedia ? L"Removable " : L"Fixed ",\r
+ BlockMedia->MediaPresent ? L"" : L"not-present ",\r
+ BlockMedia->MediaId,\r
+ BlockMedia->BlockSize,\r
+ BlockMedia->LastBlock,\r
+ MultU64x32 (BlockMedia->LastBlock + 1, BlockMedia->BlockSize),\r
+ BlockMedia->LogicalPartition ? L"partition" : L"raw",\r
+ BlockMedia->ReadOnly ? L"ro" : L"rw",\r
+ BlockMedia->WriteCaching ? L"cached" : L"!cached"\r
+ );\r
+\r
+ SHELL_FREE_NON_NULL (GetString);\r
+ return RetVal;\r
+}\r
+\r
+/**\r
+ Function to dump information about DebugSupport Protocol.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+DebugSupportProtocolDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;\r
+ CHAR16 *GetString;\r
+ CHAR16 *RetVal;\r
+\r
+ if (!Verbose) {\r
+ return NULL;\r
+ }\r
+ GetString = NULL;\r
+ RetVal = NULL;\r
+ Status = gBS->OpenProtocol (\r
+ TheHandle,\r
+ &gEfiDebugSupportProtocolGuid,\r
+ (VOID**)&DebugSupport,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+ HandleParsingHiiInit ();\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_DEBUGSUPPORT_INFO), NULL);\r
+ if (GetString == NULL) {\r
+ return NULL;\r
+ }\r
+ //\r
+ // Dump Debug support info\r
+ //\r
+ switch (DebugSupport->Isa) {\r
+ case (IsaIa32):\r
+ RetVal = CatSPrint (RetVal, GetString, L"IA-32");\r
+ break;\r
+ case (IsaIpf):\r
+ RetVal = CatSPrint (RetVal, GetString, L"IPF");\r
+ break;\r
+ case (IsaEbc):\r
+ RetVal = CatSPrint (RetVal, GetString, L"EBC");\r
+ break;\r
+ default:\r
+ SHELL_FREE_NON_NULL (GetString);\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_DEBUGSUPPORT_UNKNOWN), NULL);\r
+ RetVal = GetString != NULL ? CatSPrint (RetVal, GetString, DebugSupport->Isa) : NULL;\r
+ break;\r
+ }\r
+\r
+ SHELL_FREE_NON_NULL (GetString);\r
+ return RetVal;\r
+}\r
+\r
+/**\r
+ Function to dump information about PciIoProtocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has PciRootBridgeIo installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A poitner to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+PciIoProtocolDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ PCI_TYPE00 Pci;\r
+ UINTN Segment;\r
+ UINTN Bus;\r
+ UINTN Device;\r
+ UINTN Function;\r
+ UINTN Index;\r
+ CHAR16 *GetString;\r
+ CHAR16 *TempRetVal;\r
+ CHAR16 *RetVal;\r
+\r
+ if (!Verbose) {\r
+ return (NULL);\r
+ }\r
+ RetVal = NULL;\r
+ GetString = NULL;\r
+ TempRetVal = NULL;\r
+ Status = gBS->OpenProtocol (\r
+ TheHandle,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID**)&PciIo,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+\r
+ if (EFI_ERROR(Status)) {\r
+ return NULL;\r
+ }\r
+ PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0, sizeof (Pci), &Pci);\r
+ PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);\r
+ HandleParsingHiiInit ();\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIIO_DUMP_MAIN), NULL);\r
+ if (GetString == NULL) {\r
+ return NULL;\r
+ }\r
+ RetVal = CatSPrint (\r
+ NULL,\r
+ GetString,\r
+ Segment,\r
+ Bus,\r
+ Device,\r
+ Function,\r
+ PciIo->RomSize,\r
+ PciIo->RomImage,\r
+ Pci.Hdr.VendorId,\r
+ Pci.Hdr.DeviceId,\r
+ Pci.Hdr.ClassCode[0],\r
+ Pci.Hdr.ClassCode[1],\r
+ Pci.Hdr.ClassCode[2]\r
+ );\r
+ for (Index = 0; Index < sizeof (Pci); Index ++) {\r
+ if ((Index % 0x10) == 0) {\r
+ TempRetVal = CatSPrint (RetVal, L"\r\n %02x", *((UINT8 *) (&Pci) + Index));\r
+ } else {\r
+ TempRetVal = CatSPrint (RetVal, L"%02x", *((UINT8 *) (&Pci) + Index));\r
+ }\r
+ FreePool (RetVal);\r
+ RetVal = TempRetVal;\r
+ TempRetVal = NULL;\r
+ }\r
+\r
+ FreePool(GetString);\r
+ return RetVal;\r
+}\r
+\r
+/**\r
+ Function to dump information about UsbIoProtocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has PciRootBridgeIo installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A poitner to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+UsbIoProtocolDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_USB_IO_PROTOCOL *UsbIo;\r
+ EFI_USB_INTERFACE_DESCRIPTOR InterfaceDesc;\r
+ CHAR16 *GetString;\r
+ CHAR16 *RetVal;\r
+\r
+ if (!Verbose) {\r
+ return (NULL);\r
+ }\r
+ RetVal = NULL;\r
+ GetString = NULL;\r
+ Status = gBS->OpenProtocol (\r
+ TheHandle,\r
+ &gEfiUsbIoProtocolGuid,\r
+ (VOID**)&UsbIo,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+\r
+ if (EFI_ERROR(Status)) {\r
+ return NULL;\r
+ }\r
+ UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDesc);\r
+ HandleParsingHiiInit ();\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_USBIO_DUMP_MAIN), NULL);\r
+ if (GetString == NULL) {\r
+ return NULL;\r
+ }\r
+ RetVal = CatSPrint (\r
+ NULL,\r
+ GetString,\r
+ InterfaceDesc.InterfaceNumber,\r
+ InterfaceDesc.InterfaceClass,\r
+ InterfaceDesc.InterfaceSubClass,\r
+ InterfaceDesc.InterfaceProtocol\r
+ );\r
+\r
+ FreePool (GetString);\r
+ return RetVal;\r
+}\r
+\r
+/**\r
+ Function to dump information about EfiAdapterInformation Protocol.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+AdapterInformationDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_ADAPTER_INFORMATION_PROTOCOL *EfiAdptrInfoProtocol;\r
+ UINTN InfoTypesBufferCount;\r
+ UINTN GuidIndex;\r
+ EFI_GUID *InfoTypesBuffer;\r
+ CHAR16 *GuidStr;\r
+ CHAR16 *TempStr;\r
+ CHAR16 *RetVal;\r
+ CHAR16 *TempRetVal;\r
+ VOID *InformationBlock;\r
+ UINTN InformationBlockSize;\r
+\r
+ if (!Verbose) {\r
+ return (CatSPrint(NULL, L"AdapterInfo"));\r
+ }\r
+\r
+ InfoTypesBuffer = NULL;\r
+ InformationBlock = NULL;\r
+\r
+\r
+ Status = gBS->OpenProtocol (\r
+ (EFI_HANDLE) (TheHandle),\r
+ &gEfiAdapterInformationProtocolGuid,\r
+ (VOID **) &EfiAdptrInfoProtocol,\r
+ NULL,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+\r
+ //\r
+ // Get a list of supported information types for this instance of the protocol.\r
+ //\r
+ Status = EfiAdptrInfoProtocol->GetSupportedTypes (\r
+ EfiAdptrInfoProtocol,\r
+ &InfoTypesBuffer,\r
+ &InfoTypesBufferCount\r
+ );\r
+ RetVal = NULL;\r
+ if (EFI_ERROR (Status)) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED), NULL);\r
+ if (TempStr != NULL) {\r
+ RetVal = CatSPrint (NULL, TempStr, Status);\r
+ } else {\r
+ goto ERROR_EXIT;\r
+ }\r
+ } else {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SUPP_TYPE_HEADER), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ RetVal = CatSPrint (NULL, TempStr);\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ for (GuidIndex = 0; GuidIndex < InfoTypesBufferCount; GuidIndex++) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_NUMBER), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (RetVal, TempStr, (GuidIndex + 1), &InfoTypesBuffer[GuidIndex]);\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_STRING), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+\r
+ if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {\r
+ TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoMediaStateGuid");\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {\r
+ TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoNetworkBootGuid");\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid)) {\r
+ TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoSanMacAddressGuid");\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoUndiIpv6SupportGuid)) {\r
+ TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoUndiIpv6SupportGuid");\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ } else {\r
+\r
+ GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL);\r
+ if (GuidStr == NULL) {\r
+ TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+ SHELL_FREE_NON_NULL(GuidStr);\r
+ //\r
+ // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP\r
+ //\r
+ continue;\r
+ } else {\r
+ TempRetVal = CatSPrint (RetVal, TempStr, GuidStr);\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ SHELL_FREE_NON_NULL(GuidStr);\r
+ }\r
+ }\r
+\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ Status = EfiAdptrInfoProtocol->GetInformation (\r
+ EfiAdptrInfoProtocol,\r
+ &InfoTypesBuffer[GuidIndex],\r
+ &InformationBlock,\r
+ &InformationBlockSize\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GETINFO_FAILED), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (RetVal, TempStr, Status);\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ } else {\r
+ if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_MEDIA_STATE), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (\r
+ RetVal,\r
+ TempStr,\r
+ ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState,\r
+ ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState\r
+ );\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_NETWORK_BOOT_INFO), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (\r
+ RetVal,\r
+ TempStr,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4BootCapablity,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6BootCapablity,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBootCapablity,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->OffloadCapability,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiMpioCapability,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4Boot,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6Boot,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBoot\r
+ );\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid) == TRUE) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (\r
+ RetVal,\r
+ TempStr,\r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[0],\r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[1],\r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[2],\r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[3],\r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[4],\r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[5]\r
+ );\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoUndiIpv6SupportGuid) == TRUE) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNDI_IPV6_INFO), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+\r
+ TempRetVal = CatSPrint (\r
+ RetVal,\r
+ TempStr,\r
+ ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InformationBlock)->Ipv6Support\r
+ );\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ } else {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (RetVal, TempStr, &InfoTypesBuffer[GuidIndex]);\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ }\r
+ }\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+ SHELL_FREE_NON_NULL (InformationBlock);\r
+ }\r
+ }\r
+\r
+ SHELL_FREE_NON_NULL (InfoTypesBuffer);\r
+ return RetVal;\r
+\r
+ERROR_EXIT:\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ SHELL_FREE_NON_NULL (InfoTypesBuffer);\r
+ SHELL_FREE_NON_NULL (InformationBlock);\r
+ return NULL;\r
+}\r
+\r
+/**\r
+ Function to dump information about EFI_FIRMWARE_MANAGEMENT_PROTOCOL Protocol.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+FirmwareManagementDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *EfiFwMgmtProtocol;\r
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;\r
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1 *ImageInfoV1;\r
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2 *ImageInfoV2;\r
+ UINT64 AttributeSetting;\r
+ UINTN ImageInfoSize;\r
+ UINTN DescriptorSize;\r
+ UINT32 DescriptorVersion;\r
+ UINT32 PackageVersion;\r
+ UINT8 DescriptorCount;\r
+ UINT8 Index;\r
+ UINT8 Index1;\r
+ UINT8 ImageCount;\r
+ CHAR16 *PackageVersionName;\r
+ CHAR16 *TempStr;\r
+ CHAR16 *RetVal;\r
+ CHAR16 *TempRetVal;\r
+ CHAR16 *AttributeSettingStr;\r
+ BOOLEAN Found;\r
+ BOOLEAN AttributeSupported;\r
+\r
+ //\r
+ // Initialize local variables\r
+ //\r
+ ImageCount = 0;\r
+ ImageInfoSize = 1;\r
+ AttributeSetting = 0;\r
+ Found = FALSE;\r
+ AttributeSupported = FALSE;\r
+ ImageInfo = NULL;\r
+ ImageInfoV1 = NULL;\r
+ ImageInfoV2 = NULL;\r
+ PackageVersionName = NULL;\r
+ RetVal = NULL;\r
+ TempRetVal = NULL;\r
+ TempStr = NULL;\r
+ AttributeSettingStr = NULL;\r
+\r
+ if (!Verbose) {\r
+ return (CatSPrint(NULL, L"FirmwareManagement"));\r
+ }\r
+\r
+ Status = gBS->OpenProtocol (\r
+ (EFI_HANDLE) (TheHandle),\r
+ &gEfiFirmwareManagementProtocolGuid,\r
+ (VOID **) &EfiFwMgmtProtocol,\r
+ NULL,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+\r
+ Status = EfiFwMgmtProtocol->GetImageInfo (\r
+ EfiFwMgmtProtocol,\r
+ &ImageInfoSize,\r
+ ImageInfo,\r
+ &DescriptorVersion,\r
+ &DescriptorCount,\r
+ &DescriptorSize,\r
+ &PackageVersion,\r
+ &PackageVersionName\r
+ );\r
+\r
+ if (Status == EFI_BUFFER_TOO_SMALL) {\r
+ ImageInfo = AllocateZeroPool (ImageInfoSize);\r
+\r
+ if (ImageInfo == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ } else {\r
+ Status = EfiFwMgmtProtocol->GetImageInfo (\r
+ EfiFwMgmtProtocol,\r
+ &ImageInfoSize,\r
+ ImageInfo,\r
+ &DescriptorVersion,\r
+ &DescriptorCount,\r
+ &DescriptorSize,\r
+ &PackageVersion,\r
+ &PackageVersionName\r
+ );\r
+ }\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ goto ERROR_EXIT;\r
+ }\r
+\r
+ //\r
+ // Decode Image Descriptor data only if its version is supported\r
+ //\r
+ if (DescriptorVersion <= EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION) {\r
+\r
+ if (ImageInfo == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+\r
+ ImageInfoV1 = (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1 *)ImageInfo;\r
+ ImageInfoV2 = (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2 *)ImageInfo;\r
+\r
+ //\r
+ // Set ImageInfoSize in return buffer\r
+ //\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGE_INFO_SIZE), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ RetVal = CatSPrint (NULL, TempStr, ImageInfoSize);\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ //\r
+ // Set DescriptorVersion in return buffer\r
+ //\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_DESCRIPTOR_VERSION), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (RetVal, TempStr, DescriptorVersion);\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ //\r
+ // Set DescriptorCount in return buffer\r
+ //\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_DESCRIPTOR_COUNT), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (RetVal, TempStr, DescriptorCount);\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+\r
+ //\r
+ // Set DescriptorSize in return buffer\r
+ //\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_DESCRIPTOR_SIZE), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (RetVal, TempStr, DescriptorSize);\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ //\r
+ // Set PackageVersion in return buffer\r
+ //\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_PACKAGE_VERSION), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (RetVal, TempStr, PackageVersion);\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ //\r
+ // Set PackageVersionName in return buffer\r
+ //\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_PACKAGE_VERSION_NAME), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (RetVal, TempStr, PackageVersionName);\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ for (Index = 0; Index < DescriptorCount; Index++) {\r
+ //\r
+ // First check if Attribute is supported\r
+ // and generate a string for AttributeSetting field\r
+ //\r
+ SHELL_FREE_NON_NULL (AttributeSettingStr);\r
+ AttributeSupported = FALSE;\r
+ AttributeSetting = 0;\r
+ if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1) {\r
+ if (ImageInfoV1[Index].AttributesSupported != 0x0) {\r
+ AttributeSupported = TRUE;\r
+ AttributeSetting = ImageInfoV1[Index].AttributesSetting;\r
+ }\r
+ } else if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2) {\r
+ if (ImageInfoV2[Index].AttributesSupported != 0x0) {\r
+ AttributeSupported = TRUE;\r
+ AttributeSetting = ImageInfoV2[Index].AttributesSetting;\r
+ }\r
+ } else {\r
+ if (ImageInfo[Index].AttributesSupported != 0x0) {\r
+ AttributeSupported = TRUE;\r
+ AttributeSetting = ImageInfo[Index].AttributesSetting;\r
+ }\r
+ }\r
+\r
+ if (!AttributeSupported) {\r
+ AttributeSettingStr = CatSPrint (NULL, L"None");\r
+ } else {\r
+ AttributeSettingStr = CatSPrint (NULL, L"(");\r
+\r
+ if ((AttributeSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != 0x0) {\r
+ TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_IMAGE_UPDATABLE");\r
+ SHELL_FREE_NON_NULL (AttributeSettingStr);\r
+ AttributeSettingStr = TempRetVal;\r
+ }\r
+ if ((AttributeSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED) != 0x0) {\r
+ TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_RESET_REQUIRED");\r
+ SHELL_FREE_NON_NULL (AttributeSettingStr);\r
+ AttributeSettingStr = TempRetVal;\r
+ }\r
+ if ((AttributeSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != 0x0) {\r
+ TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED");\r
+ SHELL_FREE_NON_NULL (AttributeSettingStr);\r
+ AttributeSettingStr = TempRetVal;\r
+ }\r
+ if ((AttributeSetting & IMAGE_ATTRIBUTE_IN_USE) != 0x0) {\r
+ TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_IN_USE");\r
+ SHELL_FREE_NON_NULL (AttributeSettingStr);\r
+ AttributeSettingStr = TempRetVal;\r
+ }\r
+ if ((AttributeSetting & IMAGE_ATTRIBUTE_UEFI_IMAGE) != 0x0) {\r
+ TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_UEFI_IMAGE");\r
+ SHELL_FREE_NON_NULL (AttributeSettingStr);\r
+ AttributeSettingStr = TempRetVal;\r
+ }\r
+ TempRetVal = CatSPrint (AttributeSettingStr, L" )");\r
+ SHELL_FREE_NON_NULL (AttributeSettingStr);\r
+ AttributeSettingStr = TempRetVal;\r
+ }\r
+\r
+ if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1) {\r
+ if (ImageInfoV1[Index].ImageIndex != 0x0) {\r
+ ImageCount++;\r
+ }\r
+\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V1), NULL);\r
+ if (TempStr == NULL) {\r
+ goto ERROR_EXIT;\r
+ }\r
+ TempRetVal = CatSPrint (\r
+ RetVal,\r
+ TempStr,\r
+ Index,\r
+ ImageInfoV1[Index].ImageIndex,\r
+ &ImageInfoV1[Index].ImageTypeId,\r
+ ImageInfoV1[Index].ImageId,\r
+ ImageInfoV1[Index].ImageIdName,\r
+ ImageInfoV1[Index].Version,\r
+ ImageInfoV1[Index].VersionName,\r
+ ImageInfoV1[Index].Size,\r
+ ImageInfoV1[Index].AttributesSupported,\r
+ AttributeSettingStr,\r
+ ImageInfoV1[Index].Compatibilities\r
+ );\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+ } else if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2) {\r
+ if (ImageInfoV2[Index].ImageIndex != 0x0) {\r
+ ImageCount++;\r
+ }\r