From 5d73d92f560b079f41f62e91d15ddc1fda897867 Mon Sep 17 00:00:00 2001 From: jcarsey Date: Tue, 16 Nov 2010 22:36:37 +0000 Subject: [PATCH] Add "Debug1" profile (all but Edit and HexEdit commands) git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11068 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/UefiShellDebug1CommandsLib/Bcfg.c | 798 +++ .../Library/UefiShellDebug1CommandsLib/Comp.c | 255 + .../UefiShellDebug1CommandsLib/Compress.c | 1711 +++++++ .../UefiShellDebug1CommandsLib/Compress.h | 40 + .../Library/UefiShellDebug1CommandsLib/Dblk.c | 151 + .../Library/UefiShellDebug1CommandsLib/Dmem.c | 149 + .../UefiShellDebug1CommandsLib/DmpStore.c | 228 + .../UefiShellDebug1CommandsLib/EfiCompress.c | 140 + .../EfiDecompress.c | 163 + .../UefiShellDebug1CommandsLib/LoadPciRom.c | 428 ++ .../UefiShellDebug1CommandsLib/MemMap.c | 240 + .../Library/UefiShellDebug1CommandsLib/Mm.c | 602 +++ .../Library/UefiShellDebug1CommandsLib/Mode.c | 121 + .../Library/UefiShellDebug1CommandsLib/Pci.c | 4532 +++++++++++++++++ .../Library/UefiShellDebug1CommandsLib/Pci.h | 460 ++ .../UefiShellDebug1CommandsLib/SerMode.c | 344 ++ .../UefiShellDebug1CommandsLib/SetSize.c | 90 + .../UefiShellDebug1CommandsLib/SetVar.c | 228 + .../SmbiosView/EventLogInfo.c | 394 ++ .../SmbiosView/EventLogInfo.h | 117 + .../SmbiosView/LibSmbios.h | 638 +++ .../SmbiosView/LibSmbiosView.c | 349 ++ .../SmbiosView/LibSmbiosView.h | 120 + .../SmbiosView/PrintInfo.c | 2679 ++++++++++ .../SmbiosView/PrintInfo.h | 192 + .../SmbiosView/QueryTable.c | 3798 ++++++++++++++ .../SmbiosView/QueryTable.h | 430 ++ .../SmbiosView/Smbios.c | 126 + .../SmbiosView/SmbiosView.c | 547 ++ .../SmbiosView/SmbiosViewStrings.uni | Bin 0 -> 93278 bytes .../SmbiosView/smbiosview.h | 91 + .../UefiShellDebug1CommandsLib.c | 309 ++ .../UefiShellDebug1CommandsLib.h | 332 ++ .../UefiShellDebug1CommandsLib.inf | 84 + .../UefiShellDebug1CommandsLib.uni | Bin 0 -> 59886 bytes 35 files changed, 20886 insertions(+) create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.h create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbios.h create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.h create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.h create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/Smbios.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/smbiosview.h create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf create mode 100644 ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c new file mode 100644 index 0000000000..4c2eb3c1a8 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c @@ -0,0 +1,798 @@ +/** @file + Main file for bcfg shell install1 function. + + Copyright (c) 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" +#include +#include +#include +#include + +typedef enum { + BCFG_TARGET_BOOT_ORDER = 0, + BCFG_TARGET_DRIVER_ORDER = 1, + BCFG_TARGET_MAX = 2 +} BCFG_OPERATION_TARGET; + +typedef enum { + BCFG_TYPE_DUMP = 0, + BCFG_TYPE_ADD = 1, + BCFG_TYPE_ADDP = 2, + BCFG_TYPE_ADDH = 3, + BCFG_TYPE_RM = 4, + BCFG_TYPE_MV = 5, + BCFG_TYPE_OPT = 6, + BCFG_TYPE_MAX = 7 +} BCFG_OPERATION_TYPE; + +typedef struct { + BCFG_OPERATION_TARGET Target; + BCFG_OPERATION_TYPE Type; + UINT16 Number1; + UINT16 Number2; + UINTN HandleIndex; + CHAR16 *FileName; + CHAR16 *Description; + UINT16 *Order; + CONST CHAR16 *OptData; +} BGFG_OPERATION; + +SHELL_STATUS +EFIAPI +BcfgAdd ( + IN UINTN Position, + IN CONST CHAR16 *File, + IN CONST CHAR16 *Desc, + IN CONST UINT16 *CurrentOrder, + IN CONST UINTN OrderCount, + IN CONST BCFG_OPERATION_TARGET Target, + IN CONST BOOLEAN UseHandle, + IN CONST BOOLEAN UsePath, + IN CONST UINTN HandleNumber + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *DevicePath, *FilePath, *FileNode, *DevPath; + CHAR16 *Str; + CONST CHAR16 *p; + UINT8 *p8; + EFI_SHELL_FILE_INFO *Arg; + EFI_SHELL_FILE_INFO *FileList; + CHAR16 OptionStr[40]; + UINTN DescSize, FilePathSize; + BOOLEAN Found; + UINTN TargetLocation; + UINTN Index; + EFI_HANDLE *Handles; + EFI_HANDLE CurHandle; + UINTN DriverBindingHandleCount; + UINTN ParentControllerHandleCount; + UINTN ChildControllerHandleCount; + SHELL_STATUS ShellStatus; + UINT16 *NewOrder; + + if (!UseHandle) { + ASSERT(File != NULL); + ASSERT(Desc != NULL); + } else { + ASSERT(HandleNumber != 0); + } + + ASSERT(Position <= (OrderCount+1)); + + Str = NULL; + FilePath = NULL; + FileNode = NULL; + FileList = NULL; + Handles = NULL; + ShellStatus = SHELL_SUCCESS; + TargetLocation = 0xFFFF; + +// if (Position > 0) { +// Position--; +// } + + if (UseHandle) { + CurHandle = ConvertHandleIndexToHandle(StrHexToUintn(File)); + if (CurHandle == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, File); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + // + //Make sure that the handle should point to a real controller + // + Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS ( + CurHandle, + &DriverBindingHandleCount, + NULL); + + Status = PARSE_HANDLE_DATABASE_PARENTS ( + CurHandle, + &ParentControllerHandleCount, + NULL); + + Status = ParseHandleDatabaseForChildControllers ( + CurHandle, + &ChildControllerHandleCount, + NULL); + + if (DriverBindingHandleCount > 0 + || ParentControllerHandleCount > 0 + || ChildControllerHandleCount > 0) { + FilePath = NULL; + Status = gBS->HandleProtocol ( + CurHandle, + &gEfiDevicePathProtocolGuid, + (VOID**)&FilePath); + } + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_HANDLE), gShellDebug1HiiHandle, StrHexToUintn(File)); + ShellStatus = SHELL_INVALID_PARAMETER; + } + } + } else { + // + // Get file info + // + ShellOpenFileMetaArg ((CHAR16*)File, EFI_FILE_MODE_READ, &FileList); + + // + // If filename expanded to multiple names, fail + // + if (FileList == NULL || FileList->Link.ForwardLink != FileList->Link.BackLink) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE), gShellDebug1HiiHandle, File); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + Arg = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link); + if (EFI_ERROR(Arg->Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE_OPEN), gShellDebug1HiiHandle, File, Arg->Status); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + // + // Build FilePath to the filename + // + + // + // get the device path + // + DevicePath = mEfiShellProtocol->GetDevicePathFromFilePath(Arg->FullName); + if (DevicePath != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE_DP), gShellDebug1HiiHandle, Arg->FullName); + ShellStatus = SHELL_UNSUPPORTED; + } else { + if (UsePath) { + DevPath = DevicePath; + while (!IsDevicePathEnd(DevPath)) { + if ((DevicePathType(DevPath) == MEDIA_DEVICE_PATH) && + (DevicePathSubType(DevPath) == MEDIA_HARDDRIVE_DP)) { + + // + // If we find it use it instead + // + DevicePath = DevPath; + break; + } + DevPath = NextDevicePathNode(DevPath); + } + // + // append the file + // + for(p=Arg->FullName; *p != CHAR_NULL && *p != ':'; p++); + FileNode = FileDevicePath(NULL, p+1); + FilePath = AppendDevicePath(DevicePath, FileNode); + FreePool(FileNode); + } else { + FilePath = DuplicateDevicePath(DevicePath); + } + + FreePool(DevicePath); + } + } + } + } + + + if (ShellStatus == SHELL_SUCCESS) { + // + // Find a free target ,a brute force implementation + // + Found = FALSE; + for (TargetLocation=1; TargetLocation < 0xFFFF; TargetLocation++) { + Found = TRUE; + for (Index=0; Index < OrderCount; Index++) { + if (CurrentOrder[Index] == TargetLocation) { + Found = FALSE; + break; + } + } + + if (Found) { + break; + } + } + + if (TargetLocation == 0xFFFF) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_TARGET_NF), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_TARGET), gShellDebug1HiiHandle, TargetLocation); + } + } + + if (ShellStatus == SHELL_SUCCESS) { + // + // Add the option + // + DescSize = StrSize(Desc); + FilePathSize = GetDevicePathSize (FilePath); + + p8 = AllocatePool(sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize); + *((UINT32 *) p8) = LOAD_OPTION_ACTIVE; // Attributes + p8 += sizeof (UINT32); + + *((UINT16 *) p8) = (UINT16)FilePathSize; // FilePathListLength + p8 += sizeof (UINT16); + + CopyMem (p8, Desc, DescSize); + p8 += DescSize; + CopyMem (p8, FilePath, FilePathSize); + + UnicodeSPrint (OptionStr, sizeof(OptionStr), L"%s%04x", Target == BCFG_TARGET_BOOT_ORDER?L"Boot":L"Driver", TargetLocation); + Status = gRT->SetVariable ( + OptionStr, + &gEfiGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize, + p8 + ); + + FreePool(p8); + + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellDebug1HiiHandle, OptionStr, Status); + } else { + NewOrder = AllocatePool((OrderCount+1)*sizeof(NewOrder[0])); + ASSERT(NewOrder != NULL); + CopyMem(NewOrder, CurrentOrder, (OrderCount)*sizeof(NewOrder[0])); + + // + // Insert target into order list + // + for (Index=OrderCount; Index > Position; Index--) { + NewOrder[Index] = NewOrder[Index-1]; + } + + NewOrder[Position] = (UINT16) TargetLocation; + Status = gRT->SetVariable ( + Target == BCFG_TARGET_BOOT_ORDER?L"BootOrder":L"DriverOrder", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + (OrderCount+1) * sizeof(UINT16), + NewOrder + ); + + FreePool(NewOrder); + + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BCFG_TARGET_BOOT_ORDER?L"BootOrder":L"DriverOrder", Status); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + Print (L"bcfg: Add %s as %x\n", OptionStr, Position); + } + } + } + if (FileNode != NULL) { + FreePool (FileNode); + } + +// +//If always Free FilePath, will free devicepath in system when use "addh" +// + + if (FilePath!=NULL && !UseHandle) { + FreePool (FilePath); + } + + if (Str != NULL) { + FreePool(Str); + } + + if (Handles != NULL) { + FreePool (Handles); + } + + if (FileList != NULL) { + ShellCloseFileMetaArg (&FileList); + } + + return (ShellStatus); +} + +SHELL_STATUS +EFIAPI +BcfgRemove( + IN CONST BCFG_OPERATION_TARGET Target, + IN CONST UINT16 *CurrentOrder, + IN CONST UINTN OrderCount, + IN CONST UINT16 Location + ) +{ + CHAR16 VariableName[12]; + UINT16 *NewOrder; + EFI_STATUS Status; + UINTN LoopVar; + UINTN NewCount; + + UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Target == BCFG_TARGET_BOOT_ORDER?L"Boot":L"Driver", Location); + Status = gRT->SetVariable( + VariableName, + (EFI_GUID*)&gEfiGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + 0, + NULL); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, VariableName, Status); + return (SHELL_INVALID_PARAMETER); + } + NewOrder = AllocatePool(OrderCount*sizeof(CurrentOrder[0])); + NewCount = OrderCount; + CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0])); + for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++){ + if (NewOrder[LoopVar] == Location) { + CopyMem(NewOrder+LoopVar, NewOrder+LoopVar+1, (OrderCount - LoopVar - 1)*sizeof(CurrentOrder[0])); + NewCount--; + } + } + Status = gRT->SetVariable( + Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", + (EFI_GUID*)&gEfiGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + NewCount*sizeof(NewOrder[0]), + NewOrder); + FreePool(NewOrder); + + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", Status); + return (SHELL_INVALID_PARAMETER); + } + return (SHELL_SUCCESS); +} + +SHELL_STATUS +EFIAPI +BcfgMove( + IN CONST BCFG_OPERATION_TARGET Target, + IN CONST UINT16 *CurrentOrder, + IN CONST UINTN OrderCount, + IN CONST UINT16 OldLocation, + IN CONST UINT16 NewLocation + ) +{ + UINT16 *NewOrder; + EFI_STATUS Status; + UINT16 Temp; + + NewOrder = AllocatePool(OrderCount*sizeof(CurrentOrder[0])); + ASSERT(NewOrder != NULL); + + Temp = CurrentOrder[OldLocation]; + CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0])); + CopyMem(NewOrder+OldLocation, NewOrder+OldLocation+1, (OrderCount - OldLocation - 1)*sizeof(CurrentOrder[0])); + CopyMem(NewOrder+NewLocation+1, NewOrder+NewLocation, (OrderCount - NewLocation - 1)*sizeof(CurrentOrder[0])); + NewOrder[NewLocation] = Temp; + + + Status = gRT->SetVariable( + Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", + (EFI_GUID*)&gEfiGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + OrderCount*sizeof(CurrentOrder[0]), + NewOrder); + + FreePool(NewOrder); + + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", Status); + return (SHELL_INVALID_PARAMETER); + } + return (SHELL_SUCCESS); +} + +SHELL_STATUS +EFIAPI +BcfgDisplayDump( + IN CONST CHAR16 *Op, + IN CONST UINTN OrderCount, + IN CONST BOOLEAN VerboseOutput + ) +{ + EFI_STATUS Status; + UINT8 *Buffer; + UINTN BufferSize; + CHAR16 VariableName[12]; + UINTN LoopVar; + UINTN LoopVar2; + CHAR16 *DevPathString; + VOID *DevPath; + + for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++) { + Buffer = NULL; + BufferSize = 0; + UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Op, LoopVar); + + Status = gRT->GetVariable( + VariableName, + (EFI_GUID*)&gEfiGlobalVariableGuid, + NULL, + &BufferSize, + Buffer); + if (Status == EFI_BUFFER_TOO_SMALL) { + Buffer = AllocatePool(BufferSize); + Status = gRT->GetVariable( + VariableName, + (EFI_GUID*)&gEfiGlobalVariableGuid, + NULL, + &BufferSize, + Buffer); + } + + if (EFI_ERROR(Status) || Buffer == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_READ_FAIL), gShellDebug1HiiHandle, VariableName, Status); + return (SHELL_INVALID_PARAMETER); + } + + DevPath = AllocatePool(*(UINT16*)(Buffer+4)); + CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4)); + DevPathString = gDevPathToText->ConvertDevicePathToText(DevPath, TRUE, FALSE); + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN(STR_BCFG_LOAD_OPTIONS), + gShellDebug1HiiHandle, + VariableName, + (CHAR16*)(Buffer+6), + DevPathString, + (StrSize((CHAR16*)(Buffer+6)) + *(UINT16*)(Buffer+4) + 6) <= BufferSize?L'N':L'Y'); + if (VerboseOutput) { + for (LoopVar2 = (StrSize((CHAR16*)(Buffer+6)) + *(UINT16*)(Buffer+4) + 6);LoopVar2Target = BCFG_TARGET_MAX; + Struct->Type = BCFG_TYPE_MAX; + Struct->Number1 = 0; + Struct->Number2 = 0; + Struct->HandleIndex = 0; + Struct->FileName = NULL; + Struct->Description = NULL; + Struct->Order = NULL; + Struct->OptData = NULL; +} + + +STATIC CONST SHELL_PARAM_ITEM ParamList[] = { + {L"-v", TypeFlag}, + {L"-opt", TypeMaxValue}, + {NULL, TypeMax} + }; + +/** + Function for 'bcfg' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunBcfg ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + UINTN ParamNumber; + CONST CHAR16 *CurrentParam; + BGFG_OPERATION CurrentOperation; + UINTN Length; + + Length = 0; + ProblemParam = NULL; + Package = NULL; + ShellStatus = SHELL_SUCCESS; + + InitBcfgStruct(&CurrentOperation); + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + // + // small block to read the target of the operation + // + if (ShellCommandLineGetCount(Package) < 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)ShellCommandLineGetRawValue(Package, 1), L"driver") == 0) { + CurrentOperation.Target = BCFG_TARGET_DRIVER_ORDER; + } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)ShellCommandLineGetRawValue(Package, 1), L"boot") == 0) { + CurrentOperation.Target = BCFG_TARGET_BOOT_ORDER; + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_DRIVER_BOOT), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } + + // + // Read in if we are doing -OPT + // + if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BCFG_TARGET_MAX && ShellCommandLineGetFlag(Package, L"-opt")) { + CurrentOperation.OptData = ShellCommandLineGetValue(Package, L"-opt"); + CurrentOperation.Type = BCFG_TYPE_OPT; + } + + // + // Read in the boot or driver order environment variable (not needed for opt) + // + if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BCFG_TARGET_MAX && CurrentOperation.Type != BCFG_TYPE_OPT) { + Length = 0; + Status = gRT->GetVariable( + CurrentOperation.Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", + (EFI_GUID*)&gEfiGlobalVariableGuid, + NULL, + &Length, + CurrentOperation.Order); + if (Status == EFI_BUFFER_TOO_SMALL) { + CurrentOperation.Order = AllocatePool(Length+(4*sizeof(CurrentOperation.Order[0]))); + Status = gRT->GetVariable( + CurrentOperation.Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", + (EFI_GUID*)&gEfiGlobalVariableGuid, + NULL, + &Length, + CurrentOperation.Order); + } + } + + // + // large block to read the type of operation and verify parameter types for the info. + // + if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BCFG_TARGET_MAX) { + for (ParamNumber = 2 ; ParamNumber < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS; ParamNumber++) { + CurrentParam = ShellCommandLineGetRawValue(Package, ParamNumber); + if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"dump") == 0) { + CurrentOperation.Type = BCFG_TYPE_DUMP; + } else if (ShellCommandLineGetFlag(Package, L"-v")) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"-v (without dump)"); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"add") == 0) { + if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } + CurrentOperation.Type = BCFG_TYPE_ADD; + CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); + if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + CurrentOperation.Number1 = (UINT16)StrHexToUintn(CurrentParam); + ASSERT(CurrentOperation.FileName == NULL); + CurrentOperation.FileName = StrnCatGrow(&CurrentOperation.FileName , NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0); + ASSERT(CurrentOperation.Description == NULL); + CurrentOperation.Description = StrnCatGrow(&CurrentOperation.Description, NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0); + } + } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"addp") == 0) { + if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } + CurrentOperation.Type = BCFG_TYPE_ADDP; + CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); + if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + CurrentOperation.Number1 = (UINT16)StrHexToUintn(CurrentParam); + ASSERT(CurrentOperation.FileName == NULL); + CurrentOperation.FileName = StrnCatGrow(&CurrentOperation.FileName , NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0); + ASSERT(CurrentOperation.Description == NULL); + CurrentOperation.Description = StrnCatGrow(&CurrentOperation.Description, NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0); + } + } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"addh") == 0) { + if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } + CurrentOperation.Type = BCFG_TYPE_ADDH; + CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); + if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + CurrentOperation.Number1 = (UINT16)StrHexToUintn(CurrentParam); + CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); + if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + CurrentOperation.HandleIndex = (UINT16)StrHexToUintn(CurrentParam); + ASSERT(CurrentOperation.Description == NULL); + CurrentOperation.Description = StrnCatGrow(&CurrentOperation.Description, NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0); + } + } + } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"rm") == 0) { + if ((ParamNumber + 1) >= ShellCommandLineGetCount(Package)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } + CurrentOperation.Type = BCFG_TYPE_RM; + CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); + if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + CurrentOperation.Number1 = (UINT16)StrHexToUintn(CurrentParam); + if (CurrentOperation.Number1 > (Length / sizeof(CurrentOperation.Order[0]))){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellDebug1HiiHandle, Length / sizeof(CurrentOperation.Order[0])); + ShellStatus = SHELL_INVALID_PARAMETER; + } + } + } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"mv") == 0) { + if ((ParamNumber + 2) >= ShellCommandLineGetCount(Package)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } + CurrentOperation.Type = BCFG_TYPE_MV; + CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); + if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + CurrentOperation.Number1 = (UINT16)StrHexToUintn(CurrentParam); + if (CurrentOperation.Number1 > (Length / sizeof(CurrentOperation.Order[0]))){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellDebug1HiiHandle, Length / sizeof(CurrentOperation.Order[0])); + ShellStatus = SHELL_INVALID_PARAMETER; + } + CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); + if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + CurrentOperation.Number2 = (UINT16)StrHexToUintn(CurrentParam); + } + if (CurrentOperation.Number2 == CurrentOperation.Number1 + ||CurrentOperation.Number1 > (Length / sizeof(CurrentOperation.Order[0])) + ||CurrentOperation.Number2 > (Length / sizeof(CurrentOperation.Order[0])) + ){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellDebug1HiiHandle, Length / sizeof(CurrentOperation.Order[0])); + ShellStatus = SHELL_INVALID_PARAMETER; + } + } + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } + } + } + if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BCFG_TARGET_MAX && CurrentOperation.Type < BCFG_TYPE_MAX) { + // + // we have all the info. Do the work + // + switch (CurrentOperation.Type) { + case BCFG_TYPE_DUMP: + ShellStatus = BcfgDisplayDump( + CurrentOperation.Target == BCFG_TARGET_BOOT_ORDER?L"Boot":L"Driver", + Length / sizeof(CurrentOperation.Order[0]), + ShellCommandLineGetFlag(Package, L"-v")); + break; + case BCFG_TYPE_MV: + ShellStatus = BcfgMove( + CurrentOperation.Target, + CurrentOperation.Order, + Length / sizeof(CurrentOperation.Order[0]), + CurrentOperation.Number1, + CurrentOperation.Number2); + break; + case BCFG_TYPE_RM: + ShellStatus = BcfgRemove( + CurrentOperation.Target, + CurrentOperation.Order, + Length / sizeof(CurrentOperation.Order[0]), + CurrentOperation.Number1); + break; + case BCFG_TYPE_ADD: + case BCFG_TYPE_ADDP: + case BCFG_TYPE_ADDH: + ShellStatus = BcfgAdd( + CurrentOperation.Number1, + CurrentOperation.FileName, + CurrentOperation.Description, + CurrentOperation.Order, + Length, + CurrentOperation.Target, + (BOOLEAN)(CurrentOperation.Type == BCFG_TYPE_ADDH), + (BOOLEAN)(CurrentOperation.Type == BCFG_TYPE_ADDP), + CurrentOperation.HandleIndex); + break; + case BCFG_TYPE_OPT: + default: + ASSERT(FALSE); + } + } + } + + if (Package != NULL) { + ShellCommandLineFreeVarList (Package); + } + if (CurrentOperation.FileName != NULL) { + FreePool(CurrentOperation.FileName); + } + if (CurrentOperation.Description != NULL) { + FreePool(CurrentOperation.Description); + } + if (CurrentOperation.Order != NULL) { + FreePool(CurrentOperation.Order); + } + + return (ShellStatus); +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c new file mode 100644 index 0000000000..c6933e6095 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c @@ -0,0 +1,255 @@ +/** @file + Main file for Comp shell Debug1 function. + + Copyright (c) 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" + +SHELL_STATUS +EFIAPI +ShellCommandRunComp ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + UINTN LoopVar; + SHELL_FILE_HANDLE FileHandle1; + SHELL_FILE_HANDLE FileHandle2; + UINT8 ErrorCount; + UINT64 Size1; + UINT64 Size2; + UINT8 DataFromFile1; + UINT8 DataFromFile2; + UINT8 ADF_File11; + UINT8 ADF_File12; + UINT8 ADF_File13; + UINT8 ADF_File21; + UINT8 ADF_File22; + UINT8 ADF_File23; + UINTN DataSizeFromFile1; + UINTN DataSizeFromFile2; + CHAR16 *FileName1; + CHAR16 *FileName2; + + ErrorCount = 0; + ShellStatus = SHELL_SUCCESS; + Status = EFI_SUCCESS; + FileName1 = NULL; + FileName2 = NULL; + FileHandle1 = NULL; + FileHandle2 = NULL; + Size1 = 0; + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) > 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (ShellCommandLineGetCount(Package) < 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + FileName1 = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 1)); + FileName2 = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 2)); + Status = ShellOpenFileByName(FileName1, &FileHandle1, EFI_FILE_MODE_READ, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status); + ShellStatus = SHELL_NOT_FOUND; + } + Status = ShellOpenFileByName(FileName2, &FileHandle2, EFI_FILE_MODE_READ, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status); + ShellStatus = SHELL_NOT_FOUND; + } + if (FileHandleIsDirectory(FileHandle1) == EFI_SUCCESS){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, FileName1); + ShellStatus = SHELL_INVALID_PARAMETER; + } + if (FileHandleIsDirectory(FileHandle2) == EFI_SUCCESS){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, FileName2); + ShellStatus = SHELL_INVALID_PARAMETER; + } + if (ShellStatus == SHELL_SUCCESS) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_HEADER), gShellDebug1HiiHandle, FileName1, FileName2); + Status = gEfiShellProtocol->GetFileSize(FileHandle1, &Size1); + ASSERT_EFI_ERROR(Status); + Status = gEfiShellProtocol->GetFileSize(FileHandle2, &Size2); + ASSERT_EFI_ERROR(Status); + if (Size1 != Size2) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_SIZE_FAIL), gShellDebug1HiiHandle); + ErrorCount++; + ShellStatus = SHELL_NOT_EQUAL; + } + } + if (ShellStatus == SHELL_SUCCESS) { + for (LoopVar = 0 ; LoopVar < Size1 && ErrorCount <= 10 ; LoopVar++) { + DataSizeFromFile1 = 1; + DataSizeFromFile2 = 1; + Status = gEfiShellProtocol->ReadFile(FileHandle1, &DataSizeFromFile1, &DataFromFile1); + ASSERT_EFI_ERROR(Status); + Status = gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFromFile2, &DataFromFile2); + ASSERT_EFI_ERROR(Status); + if (DataFromFile1 != DataFromFile2) { + ADF_File11 = 0; + ADF_File12 = 0; + ADF_File13 = 0; + ADF_File21 = 0; + ADF_File22 = 0; + ADF_File23 = 0; + if (LoopVar + 1 < Size1) { + LoopVar++; + DataSizeFromFile1 = 1; + DataSizeFromFile2 = 1; + Status = gEfiShellProtocol->ReadFile(FileHandle1, &DataSizeFromFile1, &ADF_File11); + ASSERT_EFI_ERROR(Status); + Status = gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFromFile2, &ADF_File21); + ASSERT_EFI_ERROR(Status); + if (LoopVar + 1 < Size1) { + LoopVar++; + DataSizeFromFile1 = 1; + DataSizeFromFile2 = 1; + Status = gEfiShellProtocol->ReadFile(FileHandle1, &DataSizeFromFile1, &ADF_File12); + ASSERT_EFI_ERROR(Status); + Status = gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFromFile2, &ADF_File22); + ASSERT_EFI_ERROR(Status); + if (LoopVar + 1 < Size1) { + LoopVar++; + DataSizeFromFile1 = 1; + DataSizeFromFile2 = 1; + Status = gEfiShellProtocol->ReadFile(FileHandle1, &DataSizeFromFile1, &ADF_File13); + ASSERT_EFI_ERROR(Status); + Status = gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFromFile2, &ADF_File23); + ASSERT_EFI_ERROR(Status); + } + } + } + if (ADF_File13 != ADF_File23) { + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_COMP_SPOT_FAIL4), + gShellDebug1HiiHandle, + ++ErrorCount, + FileName1, + LoopVar, + DataFromFile1, ADF_File11, ADF_File12, ADF_File13, + DataFromFile1, ADF_File11, ADF_File12, ADF_File13, + FileName2, + LoopVar, + DataFromFile2, ADF_File21, ADF_File22, ADF_File23, + DataFromFile2, ADF_File21, ADF_File22, ADF_File23 + ); + } else if (ADF_File12 != ADF_File22) { + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_COMP_SPOT_FAIL3), + gShellDebug1HiiHandle, + ++ErrorCount, + FileName1, + LoopVar, + DataFromFile1, ADF_File11, ADF_File12, + DataFromFile1, ADF_File11, ADF_File12, + FileName2, + LoopVar, + DataFromFile2, ADF_File21, ADF_File22, + DataFromFile2, ADF_File21, ADF_File22 + ); + } else if (ADF_File11 != ADF_File21) { + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_COMP_SPOT_FAIL2), + gShellDebug1HiiHandle, + ++ErrorCount, + FileName1, + LoopVar, + DataFromFile1, ADF_File11, + DataFromFile1, ADF_File11, + FileName2, + LoopVar, + DataFromFile2, ADF_File21, + DataFromFile2, ADF_File21 + ); + } else { + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_COMP_SPOT_FAIL1), + gShellDebug1HiiHandle, + ++ErrorCount, + FileName1, + LoopVar, + DataFromFile1, + DataFromFile1, + FileName2, + LoopVar, + DataFromFile2, + DataFromFile2 + ); + } + ShellStatus = SHELL_NOT_EQUAL; + } + } + } + if (ErrorCount == 0) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_FAIL), gShellDebug1HiiHandle); + } + } + + ShellCommandLineFreeVarList (Package); + } + if (FileName1 != NULL) { + FreePool(FileName1); + } + if (FileName2 != NULL) { + FreePool(FileName2); + } + if (FileHandle1 != NULL) { + gEfiShellProtocol->CloseFile(FileHandle1); + } + if (FileHandle2 != NULL) { + gEfiShellProtocol->CloseFile(FileHandle2); + } + + return (ShellStatus); +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c new file mode 100644 index 0000000000..9e880e6d6b --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c @@ -0,0 +1,1711 @@ +/** @file + Main file for compression routine. + + Compression routine. The compression algorithm is a mixture of + LZ77 and Huffman coding. LZ77 transforms the source data into a + sequence of Original Characters and Pointers to repeated strings. + This sequence is further divided into Blocks and Huffman codings + are applied to each Block. + + Copyright (c) 2007 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include + +// +// Macro Definitions +// +typedef INT16 NODE; +#define UINT8_MAX 0xff +#define UINT8_BIT 8 +#define THRESHOLD 3 +#define INIT_CRC 0 +#define WNDBIT 13 +#define WNDSIZ (1U << WNDBIT) +#define MAXMATCH 256 +#define BLKSIZ (1U << 14) // 16 * 1024U +#define PERC_FLAG 0x8000U +#define CODE_BIT 16 +#define NIL 0 +#define MAX_HASH_VAL (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX) +#define HASH(p, c) ((p) + ((c) << (WNDBIT - 9)) + WNDSIZ * 2) +#define CRCPOLY 0xA001 +#define UPDATE_CRC(c) mCrc = mCrcTable[(mCrc ^ (c)) & 0xFF] ^ (mCrc >> UINT8_BIT) + +// +// C: the Char&Len Set; P: the Position Set; T: the exTra Set +// +#define NC (UINT8_MAX + MAXMATCH + 2 - THRESHOLD) +#define CBIT 9 +#define NP (WNDBIT + 1) +#define PBIT 4 +#define NT (CODE_BIT + 3) +#define TBIT 5 +#if NT > NP + #define NPT NT +#else + #define NPT NP +#endif +// +// Function Prototypes +// + +/** + Put a dword to output stream + + @param[in] Data The dword to put. +**/ +VOID +EFIAPI +PutDword( + IN UINT32 Data + ); + +EFI_STATUS +EFIAPI +AllocateMemory ( + VOID + ); + +VOID +EFIAPI +FreeMemory ( + VOID + ); + +VOID +EFIAPI +InitSlide ( + VOID + ); + +NODE +EFIAPI +Child ( + IN NODE q, + IN UINT8 c + ); + +VOID +EFIAPI +MakeChild ( + IN NODE q, + IN UINT8 c, + IN NODE r + ); + +VOID +EFIAPI +Split ( + IN NODE Old + ); + +VOID +EFIAPI +InsertNode ( + VOID + ); + +VOID +EFIAPI +DeleteNode ( + VOID + ); + +VOID +EFIAPI +GetNextMatch ( + VOID + ); + +EFI_STATUS +EFIAPI +Encode ( + VOID + ); + +VOID +EFIAPI +CountTFreq ( + VOID + ); + +VOID +EFIAPI +WritePTLen ( + IN INT32 n, + IN INT32 nbit, + IN INT32 Special + ); + +VOID +EFIAPI +WriteCLen ( + VOID + ); + +VOID +EFIAPI +EncodeC ( + IN INT32 c + ); + +VOID +EFIAPI +EncodeP ( + IN UINT32 p + ); + +VOID +EFIAPI +SendBlock ( + VOID + ); + +VOID +EFIAPI +CompressOutput ( + IN UINT32 c, + IN UINT32 p + ); + +VOID +EFIAPI +HufEncodeStart ( + VOID + ); + +VOID +EFIAPI +HufEncodeEnd ( + VOID + ); + +VOID +EFIAPI +MakeCrcTable ( + VOID + ); + +VOID +EFIAPI +PutBits ( + IN INT32 n, + IN UINT32 x + ); + +INT32 +EFIAPI +FreadCrc ( + OUT UINT8 *p, + IN INT32 n + ); + +VOID +EFIAPI +InitPutBits ( + VOID + ); + +VOID +EFIAPI +CountLen ( + IN INT32 i + ); + +VOID +EFIAPI +MakeLen ( + IN INT32 Root + ); + +VOID +EFIAPI +DownHeap ( + IN INT32 i + ); + +VOID +EFIAPI +MakeCode ( + IN INT32 n, + IN UINT8 Len[ ], + OUT UINT16 Code[ ] + ); + +INT32 +EFIAPI +MakeTree ( + IN INT32 NParm, + IN UINT16 FreqParm[ ], + OUT UINT8 LenParm[ ], + OUT UINT16 CodeParm[ ] + ); + +// +// Global Variables +// +STATIC UINT8 *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit; + +STATIC UINT8 *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen; +STATIC INT16 mHeap[NC + 1]; +STATIC INT32 mRemainder, mMatchLen, mBitCount, mHeapSize, mN; +STATIC UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc; +STATIC UINT32 mCompSize, mOrigSize; + +STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1], + mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1], mCTable[4096], mCCode[NC], + mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1]; + +STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL; + +// +// functions +// +/** + The compression routine. + + @param[in] SrcBuffer The buffer containing the source data. + @param[in] SrcSizae Number of bytes in SrcBuffer. + @param[in] DstBuffer The buffer to put the compressed image in. + @param[in,out] DstSize On input the size (in bytes) of DstBuffer, on + return the number of bytes placed in DstBuffer. + + @retval EFI_SUCCESS The compression was sucessful. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. DstSize is required. +**/ +EFI_STATUS +EFIAPI +Compress ( + IN VOID *SrcBuffer, + IN UINT64 SrcSize, + IN VOID *DstBuffer, + IN OUT UINT64 *DstSize + ) +{ + EFI_STATUS Status; + + // + // Initializations + // + mBufSiz = 0; + mBuf = NULL; + mText = NULL; + mLevel = NULL; + mChildCount = NULL; + mPosition = NULL; + mParent = NULL; + mPrev = NULL; + mNext = NULL; + + mSrc = SrcBuffer; + mSrcUpperLimit = mSrc + SrcSize; + mDst = DstBuffer; + mDstUpperLimit = mDst +*DstSize; + + PutDword (0L); + PutDword (0L); + + MakeCrcTable (); + + mOrigSize = mCompSize = 0; + mCrc = INIT_CRC; + + // + // Compress it + // + Status = Encode (); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + // + // Null terminate the compressed data + // + if (mDst < mDstUpperLimit) { + *mDst++ = 0; + } + // + // Fill in compressed size and original size + // + mDst = DstBuffer; + PutDword (mCompSize + 1); + PutDword (mOrigSize); + + // + // Return + // + if (mCompSize + 1 + 8 > *DstSize) { + *DstSize = mCompSize + 1 + 8; + return EFI_BUFFER_TOO_SMALL; + } else { + *DstSize = mCompSize + 1 + 8; + return EFI_SUCCESS; + } + +} + +/** + Put a dword to output stream + + @param[in] Data The dword to put. +**/ +VOID +EFIAPI +PutDword ( + IN UINT32 Data + ) +{ + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8) (((UINT8) (Data)) & 0xff); + } + + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8) (((UINT8) (Data >> 0x08)) & 0xff); + } + + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8) (((UINT8) (Data >> 0x10)) & 0xff); + } + + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8) (((UINT8) (Data >> 0x18)) & 0xff); + } +} + +EFI_STATUS +EFIAPI +AllocateMemory ( + VOID + ) +/*++ + +Routine Description: + + Allocate memory spaces for data structures used in compression process + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Memory is allocated successfully + EFI_OUT_OF_RESOURCES - Allocation fails + +**/ +{ + mText = AllocateZeroPool (WNDSIZ * 2 + MAXMATCH); + mLevel = AllocatePool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel)); + mChildCount = AllocatePool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount)); + mPosition = AllocatePool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition)); + mParent = AllocatePool (WNDSIZ * 2 * sizeof (*mParent)); + mPrev = AllocatePool (WNDSIZ * 2 * sizeof (*mPrev)); + mNext = AllocatePool ((MAX_HASH_VAL + 1) * sizeof (*mNext)); + + mBufSiz = BLKSIZ; + mBuf = AllocatePool (mBufSiz); + while (mBuf == NULL) { + mBufSiz = (mBufSiz / 10U) * 9U; + if (mBufSiz < 4 * 1024U) { + return EFI_OUT_OF_RESOURCES; + } + + mBuf = AllocatePool (mBufSiz); + } + + mBuf[0] = 0; + + return EFI_SUCCESS; +} + +VOID +EFIAPI +FreeMemory ( + VOID + ) +/*++ + +Routine Description: + + Called when compression is completed to free memory previously allocated. + +Arguments: (VOID) + +Returns: (VOID) + +**/ +{ + SHELL_FREE_NON_NULL (mText); + SHELL_FREE_NON_NULL (mLevel); + SHELL_FREE_NON_NULL (mChildCount); + SHELL_FREE_NON_NULL (mPosition); + SHELL_FREE_NON_NULL (mParent); + SHELL_FREE_NON_NULL (mPrev); + SHELL_FREE_NON_NULL (mNext); + SHELL_FREE_NON_NULL (mBuf); +} + +VOID +EFIAPI +InitSlide ( + VOID + ) +/*++ + +Routine Description: + + Initialize String Info Log data structures + +Arguments: (VOID) + +Returns: (VOID) + +**/ +{ + NODE i; + + SetMem (mLevel + WNDSIZ, (UINT8_MAX + 1) * sizeof (UINT8), 1); + SetMem (mPosition + WNDSIZ, (UINT8_MAX + 1) * sizeof (NODE), 0); + + SetMem (mParent + WNDSIZ, WNDSIZ * sizeof (NODE), 0); + + mAvail = 1; + for (i = 1; i < WNDSIZ - 1; i++) { + mNext[i] = (NODE) (i + 1); + } + + mNext[WNDSIZ - 1] = NIL; + SetMem (mNext + WNDSIZ * 2, (MAX_HASH_VAL - WNDSIZ * 2 + 1) * sizeof (NODE), 0); +} + +NODE +EFIAPI +Child ( + IN NODE q, + IN UINT8 c + ) +/*++ + +Routine Description: + + Find child node given the parent node and the edge character + +Arguments: + + q - the parent node + c - the edge character + +Returns: + + The child node (NIL if not found) + +**/ +{ + NODE r; + + r = mNext[HASH (q, c)]; + mParent[NIL] = q; /* sentinel */ + while (mParent[r] != q) { + r = mNext[r]; + } + + return r; +} + +VOID +EFIAPI +MakeChild ( + IN NODE q, + IN UINT8 c, + IN NODE r + ) +/*++ + +Routine Description: + + Create a new child for a given parent node. + +Arguments: + + q - the parent node + c - the edge character + r - the child node + +Returns: (VOID) + +**/ +{ + NODE h; + + NODE t; + + h = (NODE) HASH (q, c); + t = mNext[h]; + mNext[h] = r; + mNext[r] = t; + mPrev[t] = r; + mPrev[r] = h; + mParent[r] = q; + mChildCount[q]++; +} + +VOID +EFIAPI +Split ( + NODE Old + ) +/*++ + +Routine Description: + + Split a node. + +Arguments: + + Old - the node to split + +Returns: (VOID) + +**/ +{ + NODE New; + + NODE t; + + New = mAvail; + mAvail = mNext[New]; + mChildCount[New] = 0; + t = mPrev[Old]; + mPrev[New] = t; + mNext[t] = New; + t = mNext[Old]; + mNext[New] = t; + mPrev[t] = New; + mParent[New] = mParent[Old]; + mLevel[New] = (UINT8) mMatchLen; + mPosition[New] = mPos; + MakeChild (New, mText[mMatchPos + mMatchLen], Old); + MakeChild (New, mText[mPos + mMatchLen], mPos); +} + +VOID +EFIAPI +InsertNode ( + VOID + ) +/*++ + +Routine Description: + + Insert string info for current position into the String Info Log + +Arguments: (VOID) + +Returns: (VOID) + +**/ +{ + NODE q; + + NODE r; + + NODE j; + + NODE t; + UINT8 c; + UINT8 *t1; + UINT8 *t2; + + if (mMatchLen >= 4) { + // + // We have just got a long match, the target tree + // can be located by MatchPos + 1. Travese the tree + // from bottom up to get to a proper starting point. + // The usage of PERC_FLAG ensures proper node deletion + // in DeleteNode() later. + // + mMatchLen--; + r = (NODE) ((mMatchPos + 1) | WNDSIZ); + q = mParent[r]; + while (q == NIL) { + r = mNext[r]; + q = mParent[r]; + } + + while (mLevel[q] >= mMatchLen) { + r = q; + q = mParent[q]; + } + + t = q; + while (mPosition[t] < 0) { + mPosition[t] = mPos; + t = mParent[t]; + } + + if (t < WNDSIZ) { + mPosition[t] = (NODE) (mPos | PERC_FLAG); + } + } else { + // + // Locate the target tree + // + q = (NODE) (mText[mPos] + WNDSIZ); + c = mText[mPos + 1]; + r = Child (q, c); + if (r == NIL) { + MakeChild (q, c, mPos); + mMatchLen = 1; + return ; + } + + mMatchLen = 2; + } + // + // Traverse down the tree to find a match. + // Update Position value along the route. + // Node split or creation is involved. + // + for (;;) { + if (r >= WNDSIZ) { + j = MAXMATCH; + mMatchPos = r; + } else { + j = mLevel[r]; + mMatchPos = (NODE) (mPosition[r] & ~PERC_FLAG); + } + + if (mMatchPos >= mPos) { + mMatchPos -= WNDSIZ; + } + + t1 = &mText[mPos + mMatchLen]; + t2 = &mText[mMatchPos + mMatchLen]; + while (mMatchLen < j) { + if (*t1 != *t2) { + Split (r); + return ; + } + + mMatchLen++; + t1++; + t2++; + } + + if (mMatchLen >= MAXMATCH) { + break; + } + + mPosition[r] = mPos; + q = r; + r = Child (q, *t1); + if (r == NIL) { + MakeChild (q, *t1, mPos); + return ; + } + + mMatchLen++; + } + + t = mPrev[r]; + mPrev[mPos] = t; + mNext[t] = mPos; + t = mNext[r]; + mNext[mPos] = t; + mPrev[t] = mPos; + mParent[mPos] = q; + mParent[r] = NIL; + + // + // Special usage of 'next' + // + mNext[r] = mPos; + +} + +VOID +EFIAPI +DeleteNode ( + VOID + ) +/*++ + +Routine Description: + + Delete outdated string info. (The Usage of PERC_FLAG + ensures a clean deletion) + +Arguments: (VOID) + +Returns: (VOID) + +**/ +{ + NODE q; + + NODE r; + + NODE s; + + NODE t; + + NODE u; + + if (mParent[mPos] == NIL) { + return ; + } + + r = mPrev[mPos]; + s = mNext[mPos]; + mNext[r] = s; + mPrev[s] = r; + r = mParent[mPos]; + mParent[mPos] = NIL; + if (r >= WNDSIZ) { + return ; + } + + mChildCount[r]--; + if (mChildCount[r] > 1) { + return ; + } + + t = (NODE) (mPosition[r] & ~PERC_FLAG); + if (t >= mPos) { + t -= WNDSIZ; + } + + s = t; + q = mParent[r]; + u = mPosition[q]; + while ((u & PERC_FLAG) != 0){ + u &= ~PERC_FLAG; + if (u >= mPos) { + u -= WNDSIZ; + } + + if (u > s) { + s = u; + } + + mPosition[q] = (NODE) (s | WNDSIZ); + q = mParent[q]; + u = mPosition[q]; + } + + if (q < WNDSIZ) { + if (u >= mPos) { + u -= WNDSIZ; + } + + if (u > s) { + s = u; + } + + mPosition[q] = (NODE) (s | WNDSIZ | PERC_FLAG); + } + + s = Child (r, mText[t + mLevel[r]]); + t = mPrev[s]; + u = mNext[s]; + mNext[t] = u; + mPrev[u] = t; + t = mPrev[r]; + mNext[t] = s; + mPrev[s] = t; + t = mNext[r]; + mPrev[t] = s; + mNext[s] = t; + mParent[s] = mParent[r]; + mParent[r] = NIL; + mNext[r] = mAvail; + mAvail = r; +} + +VOID +EFIAPI +GetNextMatch ( + VOID + ) +/*++ + +Routine Description: + + Advance the current position (read in new data if needed). + Delete outdated string info. Find a match string for current position. + +Arguments: (VOID) + +Returns: (VOID) + +**/ +{ + INT32 n; + VOID *Temp; + + mRemainder--; + mPos++; + if (mPos == WNDSIZ * 2) { + Temp = AllocatePool (WNDSIZ + MAXMATCH); + CopyMem (Temp, &mText[WNDSIZ], WNDSIZ + MAXMATCH); + CopyMem (&mText[0], Temp, WNDSIZ + MAXMATCH); + FreePool (Temp); + n = FreadCrc (&mText[WNDSIZ + MAXMATCH], WNDSIZ); + mRemainder += n; + mPos = WNDSIZ; + } + + DeleteNode (); + InsertNode (); +} + +EFI_STATUS +EFIAPI +Encode ( + VOID + ) +/*++ + +Routine Description: + + The main controlling routine for compression process. + +Arguments: (VOID) + +Returns: + + EFI_SUCCESS - The compression is successful + EFI_OUT_0F_RESOURCES - Not enough memory for compression process + +**/ +{ + EFI_STATUS Status; + INT32 LastMatchLen; + NODE LastMatchPos; + + Status = AllocateMemory (); + if (EFI_ERROR (Status)) { + FreeMemory (); + return Status; + } + + InitSlide (); + + HufEncodeStart (); + + mRemainder = FreadCrc (&mText[WNDSIZ], WNDSIZ + MAXMATCH); + + mMatchLen = 0; + mPos = WNDSIZ; + InsertNode (); + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } + + while (mRemainder > 0) { + LastMatchLen = mMatchLen; + LastMatchPos = mMatchPos; + GetNextMatch (); + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } + + if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) { + // + // Not enough benefits are gained by outputting a pointer, + // so just output the original character + // + CompressOutput(mText[mPos - 1], 0); + } else { + // + // Outputting a pointer is beneficial enough, do it. + // + + CompressOutput(LastMatchLen + (UINT8_MAX + 1 - THRESHOLD), + (mPos - LastMatchPos - 2) & (WNDSIZ - 1)); + LastMatchLen--; + while (LastMatchLen > 0) { + GetNextMatch (); + LastMatchLen--; + } + + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } + } + } + + HufEncodeEnd (); + FreeMemory (); + return EFI_SUCCESS; +} + +VOID +EFIAPI +CountTFreq ( + VOID + ) +/*++ + +Routine Description: + + Count the frequencies for the Extra Set + +Arguments: (VOID) + +Returns: (VOID) + +**/ +{ + INT32 i; + + INT32 k; + + INT32 n; + + INT32 Count; + + for (i = 0; i < NT; i++) { + mTFreq[i] = 0; + } + + n = NC; + while (n > 0 && mCLen[n - 1] == 0) { + n--; + } + + i = 0; + while (i < n) { + k = mCLen[i++]; + if (k == 0) { + Count = 1; + while (i < n && mCLen[i] == 0) { + i++; + Count++; + } + + if (Count <= 2) { + mTFreq[0] = (UINT16) (mTFreq[0] + Count); + } else if (Count <= 18) { + mTFreq[1]++; + } else if (Count == 19) { + mTFreq[0]++; + mTFreq[1]++; + } else { + mTFreq[2]++; + } + } else { + ASSERT((k+2)<(2 * NT - 1)); + mTFreq[k + 2]++; + } + } +} + +VOID +EFIAPI +WritePTLen ( + IN INT32 n, + IN INT32 nbit, + IN INT32 Special + ) +/*++ + +Routine Description: + + Outputs the code length array for the Extra Set or the Position Set. + +Arguments: + + n - the number of symbols + nbit - the number of bits needed to represent 'n' + Special - the special symbol that needs to be take care of + +Returns: (VOID) + +**/ +{ + INT32 i; + + INT32 k; + + while (n > 0 && mPTLen[n - 1] == 0) { + n--; + } + + PutBits (nbit, n); + i = 0; + while (i < n) { + k = mPTLen[i++]; + if (k <= 6) { + PutBits (3, k); + } else { + PutBits (k - 3, (1U << (k - 3)) - 2); + } + + if (i == Special) { + while (i < 6 && mPTLen[i] == 0) { + i++; + } + + PutBits (2, (i - 3) & 3); + } + } +} + +VOID +EFIAPI +WriteCLen ( + VOID + ) +/*++ + +Routine Description: + + Outputs the code length array for Char&Length Set + +Arguments: (VOID) + +Returns: (VOID) + +**/ +{ + INT32 i; + + INT32 k; + + INT32 n; + + INT32 Count; + + n = NC; + while (n > 0 && mCLen[n - 1] == 0) { + n--; + } + + PutBits (CBIT, n); + i = 0; + while (i < n) { + k = mCLen[i++]; + if (k == 0) { + Count = 1; + while (i < n && mCLen[i] == 0) { + i++; + Count++; + } + + if (Count <= 2) { + for (k = 0; k < Count; k++) { + PutBits (mPTLen[0], mPTCode[0]); + } + } else if (Count <= 18) { + PutBits (mPTLen[1], mPTCode[1]); + PutBits (4, Count - 3); + } else if (Count == 19) { + PutBits (mPTLen[0], mPTCode[0]); + PutBits (mPTLen[1], mPTCode[1]); + PutBits (4, 15); + } else { + PutBits (mPTLen[2], mPTCode[2]); + PutBits (CBIT, Count - 20); + } + } else { + ASSERT((k+2)>= 1; + c++; + } + + PutBits (mPTLen[c], mPTCode[c]); + if (c > 1) { + PutBits(c - 1, p & (0xFFFFU >> (17 - c))); + } +} + +VOID +EFIAPI +SendBlock ( + VOID + ) +/*++ + +Routine Description: + + Huffman code the block and output it. + +Arguments: + + None + +Returns: + + None + +**/ +{ + UINT32 i; + + UINT32 k; + + UINT32 Flags; + + UINT32 Root; + + UINT32 Pos; + + UINT32 Size; + Flags = 0; + + Root = MakeTree (NC, mCFreq, mCLen, mCCode); + Size = mCFreq[Root]; + PutBits (16, Size); + if (Root >= NC) { + CountTFreq (); + Root = MakeTree (NT, mTFreq, mPTLen, mPTCode); + if (Root >= NT) { + WritePTLen (NT, TBIT, 3); + } else { + PutBits (TBIT, 0); + PutBits (TBIT, Root); + } + + WriteCLen (); + } else { + PutBits (TBIT, 0); + PutBits (TBIT, 0); + PutBits (CBIT, 0); + PutBits (CBIT, Root); + } + + Root = MakeTree (NP, mPFreq, mPTLen, mPTCode); + if (Root >= NP) { + WritePTLen (NP, PBIT, -1); + } else { + PutBits (PBIT, 0); + PutBits (PBIT, Root); + } + + Pos = 0; + for (i = 0; i < Size; i++) { + if (i % UINT8_BIT == 0) { + Flags = mBuf[Pos++]; + } else { + Flags <<= 1; + } + if ((Flags & (1U << (UINT8_BIT - 1))) != 0){ + EncodeC(mBuf[Pos++] + (1U << UINT8_BIT)); + k = mBuf[Pos++] << UINT8_BIT; + k += mBuf[Pos++]; + + EncodeP (k); + } else { + EncodeC (mBuf[Pos++]); + } + } + + SetMem (mCFreq, NC * sizeof (UINT16), 0); + SetMem (mPFreq, NP * sizeof (UINT16), 0); +} + +VOID +EFIAPI +CompressOutput ( + IN UINT32 c, + IN UINT32 p + ) +/*++ + +Routine Description: + + Outputs an Original Character or a Pointer + +Arguments: + + c - The original character or the 'String Length' element of a Pointer + p - The 'Position' field of a Pointer + +Returns: (VOID) + +**/ +{ + STATIC UINT32 CPos; + + if ((mOutputMask >>= 1) == 0) { + mOutputMask = 1U << (UINT8_BIT - 1); + if (mOutputPos >= mBufSiz - 3 * UINT8_BIT) { + SendBlock (); + mOutputPos = 0; + } + + CPos = mOutputPos++; + mBuf[CPos] = 0; + } + mBuf[mOutputPos++] = (UINT8) c; + mCFreq[c]++; + if (c >= (1U << UINT8_BIT)) { + mBuf[CPos] = (UINT8)(mBuf[CPos]|mOutputMask); + mBuf[mOutputPos++] = (UINT8)(p >> UINT8_BIT); + mBuf[mOutputPos++] = (UINT8) p; + c = 0; + while (p!=0) { + p >>= 1; + c++; + } + mPFreq[c]++; + } +} + +VOID +EFIAPI +HufEncodeStart ( + VOID + ) +{ + SetMem (mCFreq, NC * sizeof (UINT16), 0); + SetMem (mPFreq, NP * sizeof (UINT16), 0); + + mOutputPos = mOutputMask = 0; + InitPutBits (); + return ; +} + +VOID +EFIAPI +HufEncodeEnd ( + VOID + ) +{ + SendBlock (); + + // + // Flush remaining bits + // + PutBits (UINT8_BIT - 1, 0); + + return ; +} + +VOID +EFIAPI +MakeCrcTable ( + VOID + ) +{ + UINT32 i; + + UINT32 j; + + UINT32 r; + + for (i = 0; i <= UINT8_MAX; i++) { + r = i; + for (j = 0; j < UINT8_BIT; j++) { + if ((r & 1) != 0) { + r = (r >> 1) ^ CRCPOLY; + } else { + r >>= 1; + } + } + + mCrcTable[i] = (UINT16) r; + } +} + +VOID +EFIAPI +PutBits ( + IN INT32 n, + IN UINT32 x + ) +/*++ + +Routine Description: + + Outputs rightmost n bits of x + +Arguments: + + n - the rightmost n bits of the data is used + x - the data + +Returns: + + None + +**/ +{ + UINT8 Temp; + + if (n < mBitCount) { + mSubBitBuf |= x << (mBitCount -= n); + } else { + + Temp = (UINT8)(mSubBitBuf | (x >> (n -= mBitCount))); + if (mDst < mDstUpperLimit) { + *mDst++ = Temp; + } + mCompSize++; + + if (n < UINT8_BIT) { + mSubBitBuf = x << (mBitCount = UINT8_BIT - n); + } else { + + Temp = (UINT8)(x >> (n - UINT8_BIT)); + if (mDst < mDstUpperLimit) { + *mDst++ = Temp; + } + mCompSize++; + + mSubBitBuf = x << (mBitCount = 2 * UINT8_BIT - n); + } + } +} + +INT32 +EFIAPI +FreadCrc ( + OUT UINT8 *p, + IN INT32 n + ) +/*++ + +Routine Description: + + Read in source data + +Arguments: + + p - the buffer to hold the data + n - number of bytes to read + +Returns: + + number of bytes actually read + +**/ +{ + INT32 i; + + for (i = 0; mSrc < mSrcUpperLimit && i < n; i++) { + *p++ = *mSrc++; + } + + n = i; + + p -= n; + mOrigSize += n; + i--; + while (i >= 0) { + UPDATE_CRC (*p++); + i--; + } + + return n; +} + +VOID +EFIAPI +InitPutBits ( + VOID + ) +{ + mBitCount = UINT8_BIT; + mSubBitBuf = 0; +} + +VOID +EFIAPI +CountLen ( + IN INT32 i + ) +/*++ + +Routine Description: + + Count the number of each code length for a Huffman tree. + +Arguments: + + i - the top node + +Returns: (VOID) + +**/ +{ + STATIC INT32 Depth = 0; + + if (i < mN) { + mLenCnt[(Depth < 16) ? Depth : 16]++; + } else { + Depth++; + CountLen (mLeft[i]); + CountLen (mRight[i]); + Depth--; + } +} + +VOID +EFIAPI +MakeLen ( + IN INT32 Root + ) +/*++ + +Routine Description: + + Create code length array for a Huffman tree + +Arguments: + + Root - the root of the tree + +Returns: + + None + +**/ +{ + INT32 i; + + INT32 k; + UINT32 Cum; + + for (i = 0; i <= 16; i++) { + mLenCnt[i] = 0; + } + + CountLen (Root); + + // + // Adjust the length count array so that + // no code will be generated longer than its designated length + // + Cum = 0; + for (i = 16; i > 0; i--) { + Cum += mLenCnt[i] << (16 - i); + } + + while (Cum != (1U << 16)) { + mLenCnt[16]--; + for (i = 15; i > 0; i--) { + if (mLenCnt[i] != 0) { + mLenCnt[i]--; + mLenCnt[i + 1] += 2; + break; + } + } + + Cum--; + } + + for (i = 16; i > 0; i--) { + k = mLenCnt[i]; + k--; + while (k >= 0) { + mLen[*mSortPtr++] = (UINT8) i; + k--; + } + } +} + +VOID +EFIAPI +DownHeap ( + IN INT32 i + ) +{ + INT32 j; + + INT32 k; + + // + // priority queue: send i-th entry down heap + // + k = mHeap[i]; + j = 2 * i; + while (j <= mHeapSize) { + if (j < mHeapSize && mFreq[mHeap[j]] > mFreq[mHeap[j + 1]]) { + j++; + } + + if (mFreq[k] <= mFreq[mHeap[j]]) { + break; + } + + mHeap[i] = mHeap[j]; + i = j; + j = 2 * i; + } + + mHeap[i] = (INT16) k; +} + +VOID +EFIAPI +MakeCode ( + IN INT32 n, + IN UINT8 Len[ ], + OUT UINT16 Code[ ] + ) +/*++ + +Routine Description: + + Assign code to each symbol based on the code length array + +Arguments: + + n - number of symbols + Len - the code length array + Code - stores codes for each symbol + +Returns: + + None + +**/ +{ + INT32 i; + UINT16 Start[18]; + + Start[1] = 0; + for (i = 1; i <= 16; i++) { + Start[i + 1] = (UINT16) ((Start[i] + mLenCnt[i]) << 1); + } + + for (i = 0; i < n; i++) { + Code[i] = Start[Len[i]]++; + } +} + +INT32 +EFIAPI +MakeTree ( + IN INT32 NParm, + IN UINT16 FreqParm[ ], + OUT UINT8 LenParm[ ], + OUT UINT16 CodeParm[ ] + ) +/*++ + +Routine Description: + + Generates Huffman codes given a frequency distribution of symbols + +Arguments: + + NParm - number of symbols + FreqParm - frequency of each symbol + LenParm - code length for each symbol + CodeParm - code for each symbol + +Returns: + + Root of the Huffman tree. + +**/ +{ + INT32 i; + + INT32 j; + + INT32 k; + + INT32 Avail; + + // + // make tree, calculate len[], return root + // + mN = NParm; + mFreq = FreqParm; + mLen = LenParm; + Avail = mN; + mHeapSize = 0; + mHeap[1] = 0; + for (i = 0; i < mN; i++) { + mLen[i] = 0; + if ((mFreq[i]) != 0) { + mHeapSize++; + mHeap[mHeapSize] = (INT16) i; + } + } + + if (mHeapSize < 2) { + CodeParm[mHeap[1]] = 0; + return mHeap[1]; + } + + for (i = mHeapSize / 2; i >= 1; i--) { + // + // make priority queue + // + DownHeap (i); + } + + mSortPtr = CodeParm; + do { + i = mHeap[1]; + if (i < mN) { + *mSortPtr++ = (UINT16) i; + } + + mHeap[1] = mHeap[mHeapSize--]; + DownHeap (1); + j = mHeap[1]; + if (j < mN) { + *mSortPtr++ = (UINT16) j; + } + + k = Avail++; + mFreq[k] = (UINT16) (mFreq[i] + mFreq[j]); + mHeap[1] = (INT16) k; + DownHeap (1); + mLeft[k] = (UINT16) i; + mRight[k] = (UINT16) j; + } while (mHeapSize > 1); + + mSortPtr = CodeParm; + MakeLen (k); + MakeCode (NParm, LenParm, CodeParm); + + // + // return root + // + return k; +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h new file mode 100644 index 0000000000..29f0a53fe3 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h @@ -0,0 +1,40 @@ +/** @file + Header file for compression routine. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _EFI_SHELL_COMPRESS_H_ +#define _EFI_SHELL_COMPRESS_H_ + +/** + The compression routine. + + @param[in] SrcBuffer The buffer containing the source data. + @param[in] SrcSizae Number of bytes in SrcBuffer. + @param[in] DstBuffer The buffer to put the compressed image in. + @param[in,out] DstSize On input the size (in bytes) of DstBuffer, on + return the number of bytes placed in DstBuffer. + + @retval EFI_SUCCESS The compression was sucessful. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. DstSize is required. +**/ +EFI_STATUS +EFIAPI +Compress ( + IN VOID *SrcBuffer, + IN UINT64 SrcSize, + IN VOID *DstBuffer, + IN OUT UINT64 *DstSize + ); + +#endif + diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c new file mode 100644 index 0000000000..96da304483 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c @@ -0,0 +1,151 @@ +/** @file + Main file for Dblk shell Debug1 function. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" +#include + +SHELL_STATUS +EFIAPI +DisplayTheBlocks( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath, + IN CONST UINT64 Lba, + IN CONST UINT8 BlockCount + ) +{ + EFI_BLOCK_IO_PROTOCOL *BlockIo; + EFI_DEVICE_PATH_PROTOCOL *Copy; + EFI_HANDLE BlockIoHandle; + EFI_STATUS Status; + SHELL_STATUS ShellStatus; + UINT8 *Buffer; + UINTN BufferSize; + + ShellStatus = SHELL_SUCCESS; + Copy = (EFI_DEVICE_PATH_PROTOCOL *)DevPath; + + Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &Copy, &BlockIoHandle); + ASSERT_EFI_ERROR(Status); + + Status = gBS->OpenProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, (VOID**)&BlockIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); + ASSERT_EFI_ERROR(Status); + + BufferSize = BlockIo->Media->BlockSize * BlockCount; + if (BufferSize > 0) { + Buffer = AllocatePool(BufferSize); + } else { + Buffer = NULL; + } + + Status = BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, Lba, BufferSize, Buffer); + if (!EFI_ERROR(Status) && Buffer != NULL) { + DumpHex(2,0,BufferSize,Buffer); + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_READ_FAIL), gShellDebug1HiiHandle, L"BlockIo", Status); + ShellStatus = SHELL_DEVICE_ERROR; + } + + if (Buffer != NULL) { + FreePool(Buffer); + } + + gBS->CloseProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, gImageHandle, NULL); + return (ShellStatus); +} + +SHELL_STATUS +EFIAPI +ShellCommandRunDblk ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + CONST CHAR16 *BlockName; + CONST CHAR16 *LbaString; + CONST CHAR16 *BlockCountString; + UINT64 Lba; + UINT8 BlockCount; + + ShellStatus = SHELL_SUCCESS; + Status = EFI_SUCCESS; + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) > 4) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (ShellCommandLineGetCount(Package) < 2) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + // + // Parse the params + // + BlockName = ShellCommandLineGetRawValue(Package, 1); + LbaString = ShellCommandLineGetRawValue(Package, 2); + BlockCountString = ShellCommandLineGetRawValue(Package, 3); + + if (LbaString == NULL) { + Lba = 0; + } else { + Lba = (UINT64)StrHexToUintn(LbaString); + } + + if (BlockCountString == NULL) { + BlockCount = 1; + } else { + BlockCount = (UINT8)StrHexToUintn(BlockCountString); + if (BlockCount > 0x10) { + BlockCount = 0x10; + } + } + + // + // do the work if we have a valid block identifier + // + if (mEfiShellProtocol->GetDevicePathFromMap(BlockName) == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, BlockName); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ShellStatus = DisplayTheBlocks(mEfiShellProtocol->GetDevicePathFromMap(BlockName), Lba, BlockCount); + } + } + + ShellCommandLineFreeVarList (Package); + } + return (ShellStatus); +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c new file mode 100644 index 0000000000..b8ab9c69e6 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c @@ -0,0 +1,149 @@ +/** @file + Main file for Dmem shell Debug1 function. + + Copyright (c) 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" +#include + +CHAR16 +MakePrintable( + IN CONST CHAR16 Char + ) +{ + if ((Char < 0x20 && Char > 0)||(Char > 126)) { + return (L'?'); + } + return (Char); +} + +SHELL_STATUS +EFIAPI +DisplayMmioMemory( + IN CONST VOID *Address, + IN CONST UINTN Size + ) +{ + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRbIo; + EFI_STATUS Status; + VOID *Buffer; + SHELL_STATUS ShellStatus; + + ShellStatus = SHELL_SUCCESS; + + Status = gBS->LocateProtocol(&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID**)&PciRbIo); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_NF), gShellDebug1HiiHandle); + return (SHELL_NOT_FOUND); + } + Buffer = AllocateZeroPool(Size); + ASSERT(Buffer != NULL); + + Status = PciRbIo->Mem.Read(PciRbIo, EfiPciWidthUint8, (UINT64)Address, Size, Buffer); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_ER), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_NOT_FOUND; + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMEM_MMIO_HEADER_ROW), gShellDebug1HiiHandle, (UINT64)Address, Size); + DumpHex(2,0,Size,Buffer); + } + + FreePool(Buffer); + return (ShellStatus); +} + +STATIC CONST SHELL_PARAM_ITEM ParamList[] = { + {L"-mmio", TypeFlag}, + {NULL, TypeMax} + }; + +SHELL_STATUS +EFIAPI +ShellCommandRunDmem ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + VOID *Address; + UINTN Size; + CONST CHAR16 *Temp1; + + ShellStatus = SHELL_SUCCESS; + Status = EFI_SUCCESS; + Address = NULL; + Size = 0; + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + Temp1 = ShellCommandLineGetRawValue(Package, 1); + if (Temp1 == NULL) { + Address = gST; + Size = 512; + } else { + if (!ShellIsHexOrDecimalNumber(Temp1, TRUE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp1); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + Address = (VOID*)StrHexToUintn(Temp1); + } + Temp1 = ShellCommandLineGetRawValue(Package, 2); + if (Temp1 == NULL) { + Size = 512; + } else { + if (!ShellIsHexOrDecimalNumber(Temp1, FALSE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp1); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + Size = ShellStrToUintn(Temp1); + } + } + } + + if (ShellStatus == SHELL_SUCCESS) { + if (!ShellCommandLineGetFlag(Package, L"-mmio")) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMEM_HEADER_ROW), gShellDebug1HiiHandle, (UINT64)Address, Size); + DumpHex(2,0,Size,Address); + } else { + ShellStatus = DisplayMmioMemory(Address, Size); + } + } + + + ShellCommandLineFreeVarList (Package); + } + + return (ShellStatus); +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c new file mode 100644 index 0000000000..0a586591be --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c @@ -0,0 +1,228 @@ +/** @file + Main file for DmpStore shell Debug1 function. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" + +STATIC CHAR16 *AttrType[] = { + L"invalid", // 000 + L"invalid", // 001 + L"BS", // 010 + L"NV+BS", // 011 + L"RT+BS", // 100 + L"NV+RT+BS", // 101 + L"RT+BS", // 110 + L"NV+RT+BS", // 111 +}; + +SHELL_STATUS +EFIAPI +ProcessVariables ( + IN CONST CHAR16 *VariableName OPTIONAL, + IN CONST EFI_GUID *Guid OPTIONAL, + IN BOOLEAN Delete + ) +{ + EFI_STATUS Status; + UINT64 MaxStorSize; + UINT64 RemStorSize; + UINT64 MaxVarSize; + CHAR16 *FoundVarName; + UINTN Size; + EFI_GUID FoundVarGuid; + UINT8 *DataBuffer; + UINTN DataSize; + UINT32 Atts; + SHELL_STATUS ShellStatus; + + ShellStatus = SHELL_SUCCESS; + Size = PcdGet16(PcdShellFileOperationSize); + FoundVarName = AllocatePool(Size); + + if (FoundVarName == NULL) { + return (SHELL_OUT_OF_RESOURCES); + } + FoundVarName[0] = CHAR_NULL; + + Status = gRT->QueryVariableInfo(EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS|EFI_VARIABLE_NON_VOLATILE, &MaxStorSize, &RemStorSize, &MaxVarSize); + ASSERT_EFI_ERROR(Status); + + DataSize = (UINTN)MaxVarSize; + DataBuffer = AllocatePool(DataSize); + if (DataBuffer == NULL) { + FreePool(FoundVarName); + return (SHELL_OUT_OF_RESOURCES); + } + + for (;;){ + if (ShellGetExecutionBreakFlag()) { + ShellStatus = SHELL_ABORTED; + break; + } + Size = (UINTN)PcdGet16(PcdShellFileOperationSize); + DataSize = (UINTN)MaxVarSize; + + Status = gRT->GetNextVariableName(&Size, FoundVarName, &FoundVarGuid); + if (Status == EFI_NOT_FOUND) { + break; + } + ASSERT_EFI_ERROR(Status); + + Status = gRT->GetVariable(FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer); + ASSERT_EFI_ERROR(Status); + + // + // Check if it matches + // + if (VariableName != NULL) { + if (!gUnicodeCollation->MetaiMatch(gUnicodeCollation, FoundVarName, (CHAR16*)VariableName)) { + continue; + } + } + if (Guid != NULL) { + if (!CompareGuid(&FoundVarGuid, Guid)) { + continue; + } + } + + // + // do the print or delete + // + if (!Delete) { + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN(STR_DMPSTORE_HEADER_LINE), + gShellDebug1HiiHandle, + AttrType[Atts & 7], + &FoundVarGuid, + FoundVarName, + DataSize); + DumpHex(2, 0, DataSize, DataBuffer); + } else { + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN(STR_DMPSTORE_DELETE_LINE), + gShellDebug1HiiHandle, + &FoundVarGuid, + FoundVarName); + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN(STR_DMPSTORE_DELETE_DONE), + gShellDebug1HiiHandle, + gRT->SetVariable(FoundVarName, &FoundVarGuid, Atts, 0, NULL)); + } + } + + if (FoundVarName != NULL) { + FreePool(FoundVarName); + } + if (DataBuffer != NULL) { + FreePool(DataBuffer); + } + + return (SHELL_UNSUPPORTED); +} + +STATIC CONST SHELL_PARAM_ITEM ParamList[] = { + {L"-d", TypeFlag}, + {L"-l", TypeFlag}, + {L"-s", TypeFlag}, + {L"-all", TypeFlag}, + {L"-guid", TypeValue}, + {NULL, TypeMax} + }; + +SHELL_STATUS +EFIAPI +ShellCommandRunDmpStore ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + CONST CHAR16 *Temp; + EFI_GUID *Guid; + EFI_GUID GuidData; + CONST CHAR16 *VariableName; + + ShellStatus = SHELL_SUCCESS; + Package = NULL; + + Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) < 1) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (ShellCommandLineGetCount(Package) > 2) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (ShellCommandLineGetFlag(Package, L"-all") && ShellCommandLineGetFlag(Package, L"-guid")) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"-all", L"-guid"); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if ((ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-l")) && ShellCommandLineGetFlag(Package, L"-d")) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"-l or -s", L"-d"); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + if (!ShellCommandLineGetFlag(Package, L"-all")) { + Temp = ShellCommandLineGetValue(Package, L"-guid"); + if (Temp != NULL) { + Status = ConvertStringToGuid(Temp, &GuidData); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"-guid"); + ShellStatus = SHELL_INVALID_PARAMETER; + } + Guid = &GuidData; + } else { + Guid = &gEfiGlobalVariableGuid; + } + VariableName = ShellCommandLineGetRawValue(Package, 2); + } else { + VariableName = NULL; + Guid = NULL; + } + if (ShellStatus == SHELL_SUCCESS) { + if (ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-l")) { + ///@todo fix this after Jordan makes lib... + ShellPrintEx(-1, -1, L"Not implemeneted yet (ASSERT follows).\r\n"); + ShellStatus = SHELL_INVALID_PARAMETER; + ASSERT(FALSE); + } else { + ShellStatus = ProcessVariables (VariableName, Guid, ShellCommandLineGetFlag(Package, L"-d")); + } + } + } + } + + if (Package != NULL) { + ShellCommandLineFreeVarList (Package); + } + return ShellStatus; +} + diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c new file mode 100644 index 0000000000..8d5aabdafc --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c @@ -0,0 +1,140 @@ +/** @file + Main file for EfiCompress shell Debug1 function. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" +#include "Compress.h" + +SHELL_STATUS +EFIAPI +ShellCommandRunEfiCompress ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + SHELL_FILE_HANDLE InShellFileHandle; + SHELL_FILE_HANDLE OutShellFileHandle; + UINT64 OutSize; + VOID *OutBuffer; + UINT64 InSize; + VOID *InBuffer; + CHAR16 *InFileName; + CONST CHAR16 *OutFileName; + + InFileName = NULL; + OutFileName = NULL; + OutSize = 0; + ShellStatus = SHELL_SUCCESS; + Status = EFI_SUCCESS; + OutBuffer = NULL; + InShellFileHandle = NULL; + OutShellFileHandle = NULL; + InBuffer = NULL; + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) > 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (ShellCommandLineGetCount(Package) < 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + InFileName = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 1)); + OutFileName = ShellCommandLineGetRawValue(Package, 2); + Status = ShellOpenFileByName(InFileName, &InShellFileHandle, EFI_FILE_MODE_READ, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status); + ShellStatus = SHELL_NOT_FOUND; + } + Status = ShellOpenFileByName(OutFileName, &OutShellFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status); + ShellStatus = SHELL_NOT_FOUND; + } + if (FileHandleIsDirectory(InShellFileHandle) == EFI_SUCCESS){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, InFileName); + ShellStatus = SHELL_INVALID_PARAMETER; + } + if (FileHandleIsDirectory(OutShellFileHandle) == EFI_SUCCESS){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, OutFileName); + ShellStatus = SHELL_INVALID_PARAMETER; + } + Status = gEfiShellProtocol->GetFileSize(InShellFileHandle, &InSize); + ASSERT_EFI_ERROR(Status); + InBuffer = AllocateZeroPool((UINTN)InSize); + ASSERT(InBuffer != NULL); + Status = gEfiShellProtocol->ReadFile(InShellFileHandle, &((UINTN)InSize), InBuffer); + ASSERT_EFI_ERROR(Status); + Status = Compress(InBuffer, InSize, OutBuffer, &OutSize); + if (Status == EFI_BUFFER_TOO_SMALL) { + OutBuffer = AllocateZeroPool((UINTN)OutSize); + ASSERT(OutBuffer != NULL); + Status = Compress(InBuffer, InSize, OutBuffer, &OutSize); + } + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_COMPRESS_FAIL), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_DEVICE_ERROR; + } else { + Status = gEfiShellProtocol->WriteFile(OutShellFileHandle, &((UINTN)OutSize), OutBuffer); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, OutFileName, Status); + ShellStatus = SHELL_DEVICE_ERROR; + } + } + } + + ShellCommandLineFreeVarList (Package); + } + if (InFileName != NULL) { + FreePool(InFileName); + } + if (InShellFileHandle != NULL) { + gEfiShellProtocol->CloseFile(InShellFileHandle); + } + if (OutShellFileHandle != NULL) { + gEfiShellProtocol->CloseFile(OutShellFileHandle); + } + if (InBuffer != NULL) { + FreePool(InBuffer); + } + if (OutBuffer != NULL) { + FreePool(OutBuffer); + } + + return (ShellStatus); +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c new file mode 100644 index 0000000000..3d01515f05 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c @@ -0,0 +1,163 @@ +/** @file + Main file for EfiDecompress shell Debug1 function. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" +#include + + +SHELL_STATUS +EFIAPI +ShellCommandRunEfiDecompress ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + SHELL_FILE_HANDLE InFileHandle; + SHELL_FILE_HANDLE OutFileHandle; + UINT32 OutSize; + UINTN OutSizeTemp; + VOID *OutBuffer; + UINTN InSize; + VOID *InBuffer; + CHAR16 *InFileName; + CONST CHAR16 *OutFileName; + UINT64 temp; + UINT32 ScratchSize; + VOID *ScratchBuffer; + EFI_DECOMPRESS_PROTOCOL *Decompress; + + InFileName = NULL; + OutFileName = NULL; + OutSize = 0; + ShellStatus = SHELL_SUCCESS; + Status = EFI_SUCCESS; + OutBuffer = NULL; + InBuffer = NULL; + ScratchBuffer = NULL; + InFileHandle = NULL; + OutFileHandle = NULL; + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) > 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (ShellCommandLineGetCount(Package) < 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + InFileName = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 1)); + OutFileName = ShellCommandLineGetRawValue(Package, 2); + Status = ShellOpenFileByName(InFileName, &InFileHandle, EFI_FILE_MODE_READ, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status); + ShellStatus = SHELL_NOT_FOUND; + } + Status = ShellOpenFileByName(OutFileName, &OutFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status); + ShellStatus = SHELL_NOT_FOUND; + } + if (FileHandleIsDirectory(InFileHandle) == EFI_SUCCESS){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, InFileName); + ShellStatus = SHELL_INVALID_PARAMETER; + } + if (FileHandleIsDirectory(OutFileHandle) == EFI_SUCCESS){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, OutFileName); + ShellStatus = SHELL_INVALID_PARAMETER; + } + Status = FileHandleGetSize(InFileHandle, &temp); + ASSERT(temp <= (UINT32)(-1)); + InSize = (UINTN)temp; + ASSERT_EFI_ERROR(Status); + InBuffer = AllocatePool(InSize); + ASSERT(InBuffer != NULL); + Status = gEfiShellProtocol->ReadFile(InFileHandle, &InSize, InBuffer); + ASSERT_EFI_ERROR(Status); + + Status = gBS->LocateProtocol(&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress); + ASSERT_EFI_ERROR(Status); + + Status = Decompress->GetInfo(Decompress, InBuffer, (UINT32)InSize, &OutSize, &ScratchSize); + ASSERT_EFI_ERROR(Status); + + OutBuffer = AllocatePool(OutSize); + ScratchBuffer = AllocatePool(ScratchSize); + ASSERT(OutBuffer != NULL); + ASSERT(ScratchBuffer != NULL); + + Status = Decompress->Decompress(Decompress, InBuffer, (UINT32)InSize, OutBuffer, OutSize, ScratchBuffer, ScratchSize); + ASSERT_EFI_ERROR(Status); + + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_FAIL), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_DEVICE_ERROR; + } else { + OutSizeTemp = OutSize; + Status = gEfiShellProtocol->WriteFile(OutFileHandle, &OutSizeTemp, OutBuffer); + OutSize = (UINT32)OutSizeTemp; + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, OutFileName, Status); + ShellStatus = SHELL_DEVICE_ERROR; + } + } + } + + ShellCommandLineFreeVarList (Package); + } + if (InFileName != NULL) { + FreePool(InFileName); + } + if (InFileHandle != NULL) { + gEfiShellProtocol->CloseFile(InFileHandle); + } + if (OutFileHandle != NULL) { + gEfiShellProtocol->CloseFile(OutFileHandle); + } + if (InBuffer != NULL) { + FreePool(InBuffer); + } + if (OutBuffer != NULL) { + FreePool(OutBuffer); + } + if (ScratchBuffer != NULL) { + FreePool(ScratchBuffer); + } + + return (ShellStatus); +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c new file mode 100644 index 0000000000..0084f87ca1 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c @@ -0,0 +1,428 @@ +/** @file + Main file for LoadPciRom shell Debug1 function. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +LoadPciRomConnectAllDriversToAllControllers ( + VOID + ); + +EFI_STATUS +EFIAPI +InitializeLoadPciRom ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +EFI_STATUS +EFIAPI +LoadEfiDriversFromRomImage ( + VOID *RomBar, + UINTN RomSize, + CONST CHAR16 *FileName + ); + +STATIC CONST SHELL_PARAM_ITEM ParamList[] = { + {L"-nc", TypeFlag}, + {NULL, TypeMax} + }; + +SHELL_STATUS +EFIAPI +ShellCommandRunLoadPciRom ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_SHELL_FILE_INFO *FileList; + UINTN SourceSize; + UINT8 *File1Buffer; + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + BOOLEAN Connect; + CONST CHAR16 *Param; + UINTN ParamCount; + EFI_SHELL_FILE_INFO *Node; + // + // Local variable initializations + // + File1Buffer = NULL; + ShellStatus = SHELL_SUCCESS; + FileList = NULL; + + + // + // verify number of arguments + // + Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) < 1) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + if (!ShellCommandLineGetFlag(Package, L"-nc")) { + Connect = FALSE; + } else { + Connect = TRUE; + } + + // + // get a list with each file specified by parameters + // if parameter is a directory then add all the files below it to the list + // + for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount) + ; Param != NULL + ; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount) + ){ + Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList); + if (EFI_ERROR(Status)) { + ShellStatus = SHELL_ACCESS_DENIED; + break; + } + } + if (FileList == NULL || IsListEmpty(&FileList->Link)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle); + } else if (ShellStatus == SHELL_SUCCESS) { + + + // + // loop through the list and make sure we are not aborting... + // + for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link) + ; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag() + ; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link) + ){ + if (EFI_ERROR(Node->Status)){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, Node->FullName); + ShellStatus = SHELL_INVALID_PARAMETER; + continue; + } + if (FileHandleIsDirectory(Node->Handle) == EFI_SUCCESS) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, Node->FullName); + ShellStatus = SHELL_INVALID_PARAMETER; + continue; + } + SourceSize = (UINTN) Node->Info->FileSize; + File1Buffer = AllocatePool (SourceSize); + ASSERT(File1Buffer != NULL); + Status = gEfiShellProtocol->ReadFile(Node->Handle, &SourceSize, File1Buffer); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_READ_FAIL), gShellDebug1HiiHandle, Node->FullName); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + Status = LoadEfiDriversFromRomImage ( + File1Buffer, + SourceSize, + Node->FullName + ); + + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_PCI_ROM_RES), gShellDebug1HiiHandle, Node->FullName, Status); + } + FreePool(File1Buffer); + } + } + if (FileList != NULL && !IsListEmpty(&FileList->Link)) { + Status = ShellCloseFileMetaArg(&FileList); + } + FileList = NULL; + + if (Connect) { + Status = LoadPciRomConnectAllDriversToAllControllers (); + } + } + } + + return (ShellStatus); +} + +EFI_STATUS +LoadEfiDriversFromRomImage ( + VOID *RomBar, + UINTN RomSize, + CONST CHAR16 *FileName + ) +/*++ + +Routine Description: + Command entry point. + +Arguments: + + RomBar - Rom + RomSize - Rom size + FileName - The file name + +Returns: + EFI_SUCCESS - The command completed successfully + EFI_INVALID_PARAMETER - Command usage error + EFI_UNSUPPORTED - Protocols unsupported + EFI_OUT_OF_RESOURCES - Out of memory + Other value - Unknown error + +**/ +{ + EFI_PCI_EXPANSION_ROM_HEADER *EfiRomHeader; + PCI_DATA_STRUCTURE *Pcir; + UINTN ImageIndex; + UINTN RomBarOffset; + UINT32 ImageSize; + UINT16 ImageOffset; + EFI_HANDLE ImageHandle; + EFI_STATUS Status; + EFI_STATUS retStatus; + CHAR16 RomFileName[280]; + EFI_DEVICE_PATH_PROTOCOL *FilePath; + BOOLEAN SkipImage; + UINT32 DestinationSize; + UINT32 ScratchSize; + UINT8 *Scratch; + VOID *ImageBuffer; + VOID *DecompressedImageBuffer; + UINT32 ImageLength; + EFI_DECOMPRESS_PROTOCOL *Decompress; + + ImageIndex = 0; + retStatus = EFI_NOT_FOUND; + RomBarOffset = (UINTN) RomBar; + + do { + + EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) (UINTN) RomBarOffset; + + if (EfiRomHeader->Signature != 0xaa55) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_CORRUPT), gShellDebug1HiiHandle, FileName, ImageIndex); +// PrintToken (STRING_TOKEN (STR_LOADPCIROM_IMAGE_CORRUPT), HiiHandle, ImageIndex); + return retStatus; + } + + Pcir = (PCI_DATA_STRUCTURE *) (UINTN) (RomBarOffset + EfiRomHeader->PcirOffset); + ImageSize = Pcir->ImageLength * 512; + + if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) && + (EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) + ) { + + if ((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) || + (EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) + ) { + ImageOffset = EfiRomHeader->EfiImageHeaderOffset; + ImageSize = EfiRomHeader->InitializationSize * 512; + + ImageBuffer = (VOID *) (UINTN) (RomBarOffset + ImageOffset); + ImageLength = ImageSize - ImageOffset; + DecompressedImageBuffer = NULL; + + // + // decompress here if needed + // + SkipImage = FALSE; + if (EfiRomHeader->CompressionType > EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) { + SkipImage = TRUE; + } + + if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) { + Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress); + ASSERT_EFI_ERROR(Status); + if (EFI_ERROR (Status)) { + SkipImage = TRUE; + } else { + SkipImage = TRUE; + Status = Decompress->GetInfo ( + Decompress, + ImageBuffer, + ImageLength, + &DestinationSize, + &ScratchSize + ); + if (!EFI_ERROR (Status)) { + DecompressedImageBuffer = AllocatePool (DestinationSize); + if (ImageBuffer != NULL) { + Scratch = AllocatePool (ScratchSize); + if (Scratch != NULL) { + Status = Decompress->Decompress ( + Decompress, + ImageBuffer, + ImageLength, + DecompressedImageBuffer, + DestinationSize, + Scratch, + ScratchSize + ); + if (!EFI_ERROR (Status)) { + ImageBuffer = DecompressedImageBuffer; + ImageLength = DestinationSize; + SkipImage = FALSE; + } + + FreePool (Scratch); + } + } + } + } + } + + if (!SkipImage) { + // + // load image and start image + // + UnicodeSPrint (RomFileName, sizeof (RomFileName), L"%s[%d]", FileName, ImageIndex); + FilePath = FileDevicePath (NULL, RomFileName); + + Status = gBS->LoadImage ( + TRUE, + gImageHandle, + FilePath, + ImageBuffer, + ImageLength, + &ImageHandle + ); + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_LOAD_FAIL), gShellDebug1HiiHandle, FileName, ImageIndex, Status); +// PrintToken (STRING_TOKEN (STR_LOADPCIROM_LOAD_IMAGE_ERROR), HiiHandle, ImageIndex, Status); + } else { + Status = gBS->StartImage (ImageHandle, NULL, NULL); + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_START_FAIL), gShellDebug1HiiHandle, FileName, ImageIndex, Status); +// PrintToken (STRING_TOKEN (STR_LOADPCIROM_START_IMAGE), HiiHandle, ImageIndex, Status); + } else { + retStatus = Status; + } + } + } + + if (DecompressedImageBuffer != NULL) { + FreePool (DecompressedImageBuffer); + } + + } + } + + RomBarOffset = RomBarOffset + ImageSize; + ImageIndex++; + } while (((Pcir->Indicator & 0x80) == 0x00) && ((RomBarOffset - (UINTN) RomBar) < RomSize)); + + return retStatus; +} + +EFI_STATUS +LoadPciRomConnectAllDriversToAllControllers ( + VOID + ) + +{ + EFI_STATUS Status; + UINTN AllHandleCount; + EFI_HANDLE *AllHandleBuffer; + UINTN Index; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + UINTN *HandleType; + UINTN HandleIndex; + BOOLEAN Parent; + BOOLEAN Device; + + Status = gBS->LocateHandleBuffer( + AllHandles, + NULL, + NULL, + &AllHandleCount, + &AllHandleBuffer + ); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index = 0; Index < AllHandleCount; Index++) { + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + goto Done; + } + // + // Scan the handle database + // + Status = ParseHandleDatabaseByRelationshipWithType( + NULL, + AllHandleBuffer[Index], + &HandleCount, + &HandleBuffer, + &HandleType + ); +/* + Status = LibScanHandleDatabase ( + NULL, + NULL, + AllHandleBuffer[Index], + NULL, + &HandleCount, + &HandleBuffer, + &HandleType + ); +*/ + if (EFI_ERROR (Status)) { + goto Done; + } + + Device = TRUE; + if ((HandleType[Index] & HR_DRIVER_BINDING_HANDLE) != 0) { + Device = FALSE; + } + + if ((HandleType[Index] & HR_IMAGE_HANDLE) != 0) { + Device = FALSE; + } + + if (Device) { + Parent = FALSE; + for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) { + if ((HandleType[HandleIndex] & HR_PARENT_HANDLE) != 0) { + Parent = TRUE; + } + } + + if (!Parent) { + if ((HandleType[Index] & HR_DEVICE_HANDLE) != 0) { + Status = gBS->ConnectController ( + AllHandleBuffer[Index], + NULL, + NULL, + TRUE + ); + } + } + } + + FreePool (HandleBuffer); + FreePool (HandleType); + } + +Done: + FreePool (AllHandleBuffer); + return Status; +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c new file mode 100644 index 0000000000..653c7f2d9e --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c @@ -0,0 +1,240 @@ +/** @file + Main file for Mode shell Debug1 function. + + Copyright (c) 2010, Intel Corporation. All rights reserved.
+ This program and the acModeanying materials + are licensed and made available under the terms and conditions of the BSD License + which acModeanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +STATIC CONST CHAR16 strNameEfiReservedMemoryType[] = L"Reserved"; +STATIC CONST CHAR16 strNameEfiLoaderCode[] = L"LoadCode"; +STATIC CONST CHAR16 strNameEfiLoaderData[] = L"LoadData"; +STATIC CONST CHAR16 strNameEfiBootServicesCode[] = L"BSCode"; +STATIC CONST CHAR16 strNameEfiBootServicesData[] = L"BSData"; +STATIC CONST CHAR16 strNameEfiRuntimeServicesCode[] = L"RTCode"; +STATIC CONST CHAR16 strNameEfiRuntimeServicesData[] = L"RTData"; +STATIC CONST CHAR16 strNameEfiConventionalMemory[] = L"Conv"; +STATIC CONST CHAR16 strNameEfiUnusableMemory[] = L"Unusable"; +STATIC CONST CHAR16 strNameEfiACPIReclaimMemory[] = L"ACPIRec"; +STATIC CONST CHAR16 strNameEfiACPIMemoryNVS[] = L"ACPI_NVS"; +STATIC CONST CHAR16 strNameEfiMemoryMappedIO[] = L"MMIO"; +STATIC CONST CHAR16 strNameEfiMemoryMappedIOPortSpace[] = L"MMIOPort"; +STATIC CONST CHAR16 strNameEfiPalCode[] = L"PalCode"; + +#include "UefiShellDebug1CommandsLib.h" + +SHELL_STATUS +EFIAPI +ShellCommandRunMemMap ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + UINTN Size; + EFI_MEMORY_DESCRIPTOR *Buffer; + UINTN MapKey; + UINTN ItemSize; + UINT32 Version; + UINT8 *Walker; + UINT64 ReservedPages; + UINT64 LoadCodePages; + UINT64 LoadDataPages; + UINT64 BSCodePages; + UINT64 BSDataPages; + UINT64 RTDataPages; + UINT64 RTCodePages; + UINT64 AvailPages; + UINT64 TotalPages; + UINT64 ReservedPagesSize; + UINT64 LoadCodePagesSize; + UINT64 LoadDataPagesSize; + UINT64 BSCodePagesSize; + UINT64 BSDataPagesSize; + UINT64 RTDataPagesSize; + UINT64 RTCodePagesSize; + UINT64 AvailPagesSize; + UINT64 TotalPagesSize; + BOOLEAN Sfo; + + TotalPages = 0; + ReservedPages = 0; + LoadCodePages = 0; + LoadDataPages = 0; + BSCodePages = 0; + BSDataPages = 0; + RTDataPages = 0; + RTCodePages = 0; + AvailPages = 0; + Size = 0; + Buffer = NULL; + ShellStatus = SHELL_SUCCESS; + Status = EFI_SUCCESS; + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) > 1) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version); + if (Status == EFI_BUFFER_TOO_SMALL){ + Size += SIZE_1KB; + Buffer = AllocatePool(Size); + Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version); + } + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_ACCESS_DENIED; + } else { + ASSERT(Version == EFI_MEMORY_DESCRIPTOR_VERSION); + Sfo = ShellCommandLineGetFlag(Package, L"-sfo"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_HEAD), gShellDebug1HiiHandle); + for (Walker = (UINT8*)Buffer; Walker < (((UINT8*)Buffer)+Size) && Walker != NULL; Walker += ItemSize){ + switch (((EFI_MEMORY_DESCRIPTOR*)Walker)->Type) { + // replaced ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages) with 0000 + case EfiReservedMemoryType: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiReservedMemoryType, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ReservedPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiLoaderCode: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiLoaderCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + LoadCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiLoaderData: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiLoaderData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + LoadDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiBootServicesCode: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiBootServicesCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + BSCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiBootServicesData: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiBootServicesData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + BSDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiRuntimeServicesCode: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiRuntimeServicesCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + RTCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiRuntimeServicesData: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiRuntimeServicesData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + RTDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiConventionalMemory: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiConventionalMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + AvailPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiUnusableMemory: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiUnusableMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiACPIReclaimMemory: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiACPIReclaimMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiACPIMemoryNVS: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiACPIMemoryNVS, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiMemoryMappedIO: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiMemoryMappedIO, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiMemoryMappedIOPortSpace: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiMemoryMappedIOPortSpace, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + case EfiPalCode: + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiPalCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + break; + default: + ASSERT(FALSE); + } + } + // + // print the summary + // + ReservedPagesSize = MultU64x64(SIZE_4KB,ReservedPages); + LoadCodePagesSize = MultU64x64(SIZE_4KB,LoadCodePages); + LoadDataPagesSize = MultU64x64(SIZE_4KB,LoadDataPages); + BSCodePagesSize = MultU64x64(SIZE_4KB,BSCodePages); + BSDataPagesSize = MultU64x64(SIZE_4KB,BSDataPages); + RTDataPagesSize = MultU64x64(SIZE_4KB,RTDataPages); + RTCodePagesSize = MultU64x64(SIZE_4KB,RTCodePages); + AvailPagesSize = MultU64x64(SIZE_4KB,AvailPages); + TotalPagesSize = MultU64x64(SIZE_4KB,TotalPages); + if (!Sfo) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM), gShellDebug1HiiHandle, + ReservedPages, ReservedPagesSize, + LoadCodePages, LoadCodePagesSize, + LoadDataPages, LoadDataPagesSize, + BSCodePages, BSCodePagesSize, + BSDataPages, BSDataPagesSize, + RTDataPages, RTDataPagesSize, + AvailPages, AvailPagesSize, + DivU64x32(MultU64x64(SIZE_4KB,TotalPages), SIZE_1MB), TotalPagesSize + ); + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO), gShellDebug1HiiHandle, + TotalPagesSize, + MultU64x64(SIZE_4KB,ReservedPages), + BSCodePagesSize, + BSDataPagesSize, + RTCodePagesSize, + RTDataPagesSize, + LoadCodePagesSize, + LoadDataPagesSize, + AvailPages, AvailPagesSize + ); + } + } + } + ShellCommandLineFreeVarList (Package); + } + + if (Buffer != NULL) { + FreePool(Buffer); + } + + return (ShellStatus); +} + diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c new file mode 100644 index 0000000000..a9be4950c8 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c @@ -0,0 +1,602 @@ +/** @file + Main file for Mm shell Debug1 function. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" +#include +#include +#include + +typedef enum { + EfiMemory, + EFIMemoryMappedIo, + EfiIo, + EfiPciConfig, + EfiPciEConfig +} EFI_ACCESS_TYPE; + +EFI_STATUS +EFIAPI +DumpIoModify ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +VOID +EFIAPI +ReadMem ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Size, + IN VOID *Buffer + ); + +VOID +EFIAPI +WriteMem ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Size, + IN VOID *Buffer + ); + +BOOLEAN +EFIAPI +GetHex ( + IN UINT16 *str, + OUT UINT64 *data + ); + +STATIC CONST SHELL_PARAM_ITEM ParamList[] = { + {L"-mmio", TypeFlag}, + {L"-mem", TypeFlag}, + {L"-io", TypeFlag}, + {L"-pci", TypeFlag}, + {L"-pcie", TypeFlag}, + {L"-n", TypeFlag}, + {L"-w", TypeValue}, + {NULL, TypeMax} + }; + +STATIC CONST UINT64 MaxNum[9] = { 0xff, 0xffff, 0xffffffff, 0xffffffffffffffff }; + +/** + Get the PCI-E Address from a PCI address format 0x0000ssbbddffrrr + where ss is SEGMENT, bb is BUS, dd is DEVICE, ff is FUNCTION + and rrr is REGISTER (extension format for PCI-E). + + @param[in] InputAddress PCI address format on input. + @param[out]PciEAddress PCI-E address extention format. +**/ +VOID +EFIAPI +GetPciEAddressFromInputAddress ( + IN UINT64 InputAddress, + OUT UINT64 *PciEAddress + ) +{ + *PciEAddress = RShiftU64(InputAddress & ~(UINT64) 0xFFF, 4); + *PciEAddress += LShiftU64((UINT16) InputAddress & 0x0FFF, 32); +} + +/** + Function for 'mm' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunMm ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev; + UINT64 Address; + UINT64 PciEAddress; + UINT64 Value; + UINT32 SegmentNumber; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width; + EFI_ACCESS_TYPE AccessType; + UINT64 Buffer; + UINTN Index; + UINTN Size; + CHAR16 *AddressStr; +// CHAR16 *ValueStr; + BOOLEAN Complete; + CHAR16 *InputStr; + BOOLEAN Interactive; + EFI_HANDLE *HandleBuffer; + UINTN BufferSize; + UINTN ItemValue; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + CONST CHAR16 *Temp; + + Address = 0; + PciEAddress = 0; + IoDev = NULL; + HandleBuffer = NULL; + BufferSize = 0; + SegmentNumber = 0; + ShellStatus = SHELL_SUCCESS; + InputStr = NULL; + + // + // Parse arguments + // + Width = EfiPciWidthUint8; + Size = 1; + AccessType = EfiMemory; + AddressStr = NULL; +// ValueStr = NULL; + Interactive = TRUE; + Package = NULL; + + Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) < 1) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } else if (ShellCommandLineGetCount(Package) > 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } else { + if (ShellCommandLineGetFlag(Package, L"-mmio")) { + AccessType = EFIMemoryMappedIo; + } else if (ShellCommandLineGetFlag(Package, L"-mem")) { + AccessType = EfiMemory; + } else if (ShellCommandLineGetFlag(Package, L"-io")) { + AccessType = EfiIo; + } else if (ShellCommandLineGetFlag(Package, L"-pci")) { + AccessType = EfiPciConfig; + } else if (ShellCommandLineGetFlag(Package, L"-pcie")) { + AccessType = EfiPciEConfig; + } + } + + if (ShellCommandLineGetFlag (Package, L"-n")) { + Interactive = FALSE; + } + + Temp = ShellCommandLineGetValue(Package, L"-w"); + if (Temp != NULL) { + ItemValue = StrDecimalToUintn (Temp); + + switch (ItemValue) { + case 1: + Width = EfiPciWidthUint8; + Size = 1; + break; + + case 2: + Width = EfiPciWidthUint16; + Size = 2; + break; + + case 4: + Width = EfiPciWidthUint32; + Size = 4; + break; + + case 8: + Width = EfiPciWidthUint64; + Size = 8; + break; + + default: + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"-w"); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + } + + Temp = ShellCommandLineGetRawValue(Package, 1); + if (Temp != NULL) { + Address = StrHexToUint64(Temp); + } + + Temp = ShellCommandLineGetRawValue(Package, 2); + if (Temp != NULL) { + Value = StrHexToUint64(Temp); + switch (Size) { + case 1: + if (Value > 0xFF) { + ShellStatus = SHELL_INVALID_PARAMETER; + } + break; + + case 2: + if (Value > 0xFFFF) { + ShellStatus = SHELL_INVALID_PARAMETER; + } + break; + + case 4: + if (Value > 0xFFFFFFFF) { + ShellStatus = SHELL_INVALID_PARAMETER; + } + break; + + default: + break; + } + + if (ShellStatus != SHELL_SUCCESS) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + } + + if ((Address & (Size - 1)) != 0) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_NOT_ALIGNED), gShellDebug1HiiHandle, Address); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + // + // locate DeviceIO protocol interface + // + if (AccessType != EfiMemory) { + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiPciRootBridgeIoProtocolGuid, + NULL, + &BufferSize, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_NF), gShellDebug1HiiHandle); + ShellStatus = SHELL_NOT_FOUND; + goto Done; + } + // + // In the case of PCI or PCIE + // Get segment number and mask the segment bits in Address + // + if (AccessType == EfiPciEConfig) { + SegmentNumber = (UINT32) RShiftU64 (Address, 36) & 0xff; + Address &= 0xfffffffff; + } else { + if (AccessType == EfiPciConfig) { + SegmentNumber = (UINT32) RShiftU64 (Address, 32) & 0xff; + Address &= 0xffffffff; + } + } + // + // Find the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL of the specified segment number + // + for (Index = 0; Index < BufferSize; Index++) { + Status = gBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiPciRootBridgeIoProtocolGuid, + (VOID *) &IoDev + ); + if (EFI_ERROR (Status)) { + continue; + } + if (IoDev->SegmentNumber != SegmentNumber) { + IoDev = NULL; + } + } + if (IoDev == NULL) { + // TODO add token + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_SEGMENT_NOT_FOUND), gShellDebug1HiiHandle, SegmentNumber); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + } + + if (AccessType == EfiIo && Address + Size > 0x10000) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS_RANGE), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + + if (AccessType == EfiPciEConfig) { + GetPciEAddressFromInputAddress (Address, &PciEAddress); + } + +// // +// // Set value +// // +// if (ValueStr != NULL) { +// if (AccessType == EFIMemoryMappedIo) { +// IoDev->Mem.Write (IoDev, Width, Address, 1, &Value); +// } else if (AccessType == EfiIo) { +// IoDev->Io.Write (IoDev, Width, Address, 1, &Value); +// } else if (AccessType == EfiPciConfig) { +// IoDev->Pci.Write (IoDev, Width, Address, 1, &Value); +// } else if (AccessType == EfiPciEConfig) { +// IoDev->Pci.Write (IoDev, Width, PciEAddress, 1, &Buffer); +// } else { +// WriteMem (Width, Address, 1, &Value); +// } +// +// ASSERT(ShellStatus == SHELL_SUCCESS); +// goto Done; +// } + + + // + // non-interactive mode + // + if (!Interactive) { + Buffer = 0; + if (AccessType == EFIMemoryMappedIo) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MMIO), gShellDebug1HiiHandle); + IoDev->Mem.Read (IoDev, Width, Address, 1, &Buffer); + } else if (AccessType == EfiIo) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_IO), gShellDebug1HiiHandle); + IoDev->Io.Read (IoDev, Width, Address, 1, &Buffer); + } else if (AccessType == EfiPciConfig) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCI), gShellDebug1HiiHandle); + IoDev->Pci.Read (IoDev, Width, Address, 1, &Buffer); + } else if (AccessType == EfiPciEConfig) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE), gShellDebug1HiiHandle); + IoDev->Pci.Read (IoDev, Width, PciEAddress, 1, &Buffer); + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MEM), gShellDebug1HiiHandle); + ReadMem (Width, Address, 1, &Buffer); + } + + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS), gShellDebug1HiiHandle, Address); + if (Size == 1) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF2), gShellDebug1HiiHandle, Buffer); + } else if (Size == 2) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF4), gShellDebug1HiiHandle, Buffer); + } else if (Size == 4) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF8), gShellDebug1HiiHandle, Buffer); + } else if (Size == 8) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF16), gShellDebug1HiiHandle, Buffer); + } + + ShellPrintEx(-1, -1, L"\r\n"); + + ASSERT(ShellStatus == SHELL_SUCCESS); + goto Done; + } + // + // interactive mode + // + Complete = FALSE; + do { + if (AccessType == EfiIo && Address + Size > 0x10000) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS_RANGE2), gShellDebug1HiiHandle); + // PrintToken (STRING_TOKEN (STR_IOMOD_IO_ADDRESS_2), HiiHandle, L"mm"); + break; + } + + Buffer = 0; + if (AccessType == EFIMemoryMappedIo) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MMIO), gShellDebug1HiiHandle); + // PrintToken (STRING_TOKEN (STR_IOMOD_HMMIO), HiiHandle); + IoDev->Mem.Read (IoDev, Width, Address, 1, &Buffer); + } else if (AccessType == EfiIo) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_IO), gShellDebug1HiiHandle); + // PrintToken (STRING_TOKEN (STR_IOMOD_HIO), HiiHandle); + IoDev->Io.Read (IoDev, Width, Address, 1, &Buffer); + } else if (AccessType == EfiPciConfig) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCI), gShellDebug1HiiHandle); + // PrintToken (STRING_TOKEN (STR_IOMOD_HPCI), HiiHandle); + IoDev->Pci.Read (IoDev, Width, Address, 1, &Buffer); + } else if (AccessType == EfiPciEConfig) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE), gShellDebug1HiiHandle); + // PrintToken (STRING_TOKEN (STR_IOMOD_HPCIE), HiiHandle); + IoDev->Pci.Read (IoDev, Width, PciEAddress, 1, &Buffer); + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MEM), gShellDebug1HiiHandle); + // PrintToken (STRING_TOKEN (STR_IOMOD_HMEM), HiiHandle); + ReadMem (Width, Address, 1, &Buffer); + } + + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS), gShellDebug1HiiHandle, Address); + // PrintToken (STRING_TOKEN (STR_IOMOD_ADDRESS), HiiHandle, Address); + + if (Size == 1) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF2), gShellDebug1HiiHandle, Buffer); + // PrintToken (STRING_TOKEN (STR_IOMOD_BUFFER_2), HiiHandle, Buffer); + } else if (Size == 2) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF4), gShellDebug1HiiHandle, Buffer); + // PrintToken (STRING_TOKEN (STR_IOMOD_BUFFER_4), HiiHandle, Buffer); + } else if (Size == 4) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF8), gShellDebug1HiiHandle, Buffer); + // PrintToken (STRING_TOKEN (STR_IOMOD_BUFFER_8), HiiHandle, Buffer); + } else if (Size == 8) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF16), gShellDebug1HiiHandle, Buffer); + // PrintToken (STRING_TOKEN (STR_IOMOD_BUFFER_16), HiiHandle, Buffer); + } + // + // wait user input to modify + // + if (InputStr != NULL) { + FreePool(InputStr); + } + ShellPromptForResponse(ShellPromptResponseTypeFreeform, NULL, (VOID**)&InputStr); + + // + // skip space characters + // + for (Index = 0; InputStr[Index] == ' '; Index++); + + // + // parse input string + // + if (InputStr[Index] == '.' || InputStr[Index] == 'q' || InputStr[Index] == 'Q') { + Complete = TRUE; + } else if (InputStr[Index] == CHAR_NULL) { + // + // Continue to next address + // + } else if (GetHex (InputStr + Index, &Buffer) && Buffer <= MaxNum[Width]) { + if (AccessType == EFIMemoryMappedIo) { + IoDev->Mem.Write (IoDev, Width, Address, 1, &Buffer); + } else if (AccessType == EfiIo) { + IoDev->Io.Write (IoDev, Width, Address, 1, &Buffer); + } else if (AccessType == EfiPciConfig) { + IoDev->Pci.Write (IoDev, Width, Address, 1, &Buffer); + } else if (AccessType == EfiPciEConfig) { + IoDev->Pci.Write (IoDev, Width, PciEAddress, 1, &Buffer); + } else { + WriteMem (Width, Address, 1, &Buffer); + } + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ERROR), gShellDebug1HiiHandle); + // PrintToken (STRING_TOKEN (STR_IOMOD_ERROR), HiiHandle); + continue; + } + + Address += Size; + if (AccessType == EfiPciEConfig) { + GetPciEAddressFromInputAddress (Address, &PciEAddress); + } + ShellPrintEx(-1, -1, L"\r\n"); + // Print (L"\n"); + } while (!Complete); + } + ASSERT(ShellStatus == SHELL_SUCCESS); +Done: + + if (InputStr != NULL) { + FreePool(InputStr); + } + if (HandleBuffer != NULL) { + FreePool (HandleBuffer); + } + if (Package != NULL) { + ShellCommandLineFreeVarList (Package); + } + return ShellStatus; +} + + +VOID +EFIAPI +ReadMem ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Size, + IN VOID *Buffer + ) +{ + do { + if (Width == EfiPciWidthUint8) { + *(UINT8 *) Buffer = *(UINT8 *) (UINTN) Address; + Address -= 1; + } else if (Width == EfiPciWidthUint16) { + *(UINT16 *) Buffer = *(UINT16 *) (UINTN) Address; + Address -= 2; + } else if (Width == EfiPciWidthUint32) { + *(UINT32 *) Buffer = *(UINT32 *) (UINTN) Address; + Address -= 4; + } else if (Width == EfiPciWidthUint64) { + *(UINT64 *) Buffer = *(UINT64 *) (UINTN) Address; + Address -= 8; + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_READ_ERROR), gShellDebug1HiiHandle); +// PrintToken (STRING_TOKEN (STR_IOMOD_READ_MEM_ERROR), HiiHandle); + break; + } + // + // + // + Size--; + } while (Size > 0); +} + +VOID +EFIAPI +WriteMem ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Size, + IN VOID *Buffer + ) +{ + do { + if (Width == EfiPciWidthUint8) { + *(UINT8 *) (UINTN) Address = *(UINT8 *) Buffer; + Address += 1; + } else if (Width == EfiPciWidthUint16) { + *(UINT16 *) (UINTN) Address = *(UINT16 *) Buffer; + Address += 2; + } else if (Width == EfiPciWidthUint32) { + *(UINT32 *) (UINTN) Address = *(UINT32 *) Buffer; + Address += 4; + } else if (Width == EfiPciWidthUint64) { + *(UINT64 *) (UINTN) Address = *(UINT64 *) Buffer; + Address += 8; + } else { + ASSERT (FALSE); + } + // + // + // + Size--; + } while (Size > 0); +} + +BOOLEAN +EFIAPI +GetHex ( + IN UINT16 *str, + OUT UINT64 *data + ) +{ + UINTN u; + CHAR16 c; + BOOLEAN Find; + + Find = FALSE; + // + // convert hex digits + // + u = 0; + c = *(str++); + while (c != CHAR_NULL) { + if (c >= 'a' && c <= 'f') { + c -= 'a' - 'A'; + } + + if (c == ' ') { + break; + } + + if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) { + u = u << 4 | c - (c >= 'A' ? 'A' - 10 : '0'); + + Find = TRUE; + } else { + return FALSE; + } + + c = *(str++); + } + + *data = u; + return Find; +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c new file mode 100644 index 0000000000..53ba0b6cd4 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c @@ -0,0 +1,121 @@ +/** @file + Main file for Mode shell Debug1 function. + + Copyright (c) 2010, Intel Corporation. All rights reserved.
+ This program and the acModeanying materials + are licensed and made available under the terms and conditions of the BSD License + which acModeanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" + +SHELL_STATUS +EFIAPI +ShellCommandRunMode ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + UINTN NewCol; + UINTN NewRow; + UINTN Col; + UINTN Row; + CONST CHAR16 *Temp; + BOOLEAN Done; + INT32 LoopVar; + + ShellStatus = SHELL_SUCCESS; + Status = EFI_SUCCESS; + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) > 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (ShellCommandLineGetCount(Package) == 2) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (ShellCommandLineGetCount(Package) == 3) { + Temp = ShellCommandLineGetRawValue(Package, 1); + if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + } + NewCol = ShellStrToUintn(Temp); + Temp = ShellCommandLineGetRawValue(Package, 2); + if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + } + NewRow = ShellStrToUintn(Temp); + + for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) { + Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row); + if (EFI_ERROR(Status)) { + continue; + } + if (Col == NewCol && Row == NewRow) { + Status = gST->ConOut->SetMode(gST->ConOut, LoopVar); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_SET_FAIL), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_DEVICE_ERROR; + } else { + // worked fine... + Done = TRUE; + } + break; + } + } + + if (!Done) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_NO_MATCH), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } + + } else if (ShellCommandLineGetCount(Package) == 1) { + // + // print out valid + // + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_HEAD), gShellDebug1HiiHandle); + for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) { + Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row); + if (EFI_ERROR(Status)) { + continue; + } + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_ITEM), gShellDebug1HiiHandle, Col, Row, LoopVar == gST->ConOut->Mode->Mode?L'*':L' '); + } + } + ShellCommandLineFreeVarList (Package); + } + + return (ShellStatus); +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c new file mode 100644 index 0000000000..56d5f7fd6f --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c @@ -0,0 +1,4532 @@ +/** @file + Main file for Pci shell Debug1 function. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" +#include +#include +#include +#include +#include "Pci.h" + +#define PCI_CLASS_STRING_LIMIT 54 +// +// Printable strings for Pci class code +// +typedef struct { + CHAR16 *BaseClass; // Pointer to the PCI base class string + CHAR16 *SubClass; // Pointer to the PCI sub class string + CHAR16 *PIFClass; // Pointer to the PCI programming interface string +} PCI_CLASS_STRINGS; + +// +// a structure holding a single entry, which also points to its lower level +// class +// +typedef struct PCI_CLASS_ENTRY_TAG { + UINT8 Code; // Class, subclass or I/F code + CHAR16 *DescText; // Description string + struct PCI_CLASS_ENTRY_TAG *LowerLevelClass; // Subclass or I/F if any +} PCI_CLASS_ENTRY; + +// +// Declarations of entries which contain printable strings for class codes +// in PCI configuration space +// +PCI_CLASS_ENTRY PCIBlankEntry[]; +PCI_CLASS_ENTRY PCISubClass_00[]; +PCI_CLASS_ENTRY PCISubClass_01[]; +PCI_CLASS_ENTRY PCISubClass_02[]; +PCI_CLASS_ENTRY PCISubClass_03[]; +PCI_CLASS_ENTRY PCISubClass_04[]; +PCI_CLASS_ENTRY PCISubClass_05[]; +PCI_CLASS_ENTRY PCISubClass_06[]; +PCI_CLASS_ENTRY PCISubClass_07[]; +PCI_CLASS_ENTRY PCISubClass_08[]; +PCI_CLASS_ENTRY PCISubClass_09[]; +PCI_CLASS_ENTRY PCISubClass_0a[]; +PCI_CLASS_ENTRY PCISubClass_0b[]; +PCI_CLASS_ENTRY PCISubClass_0c[]; +PCI_CLASS_ENTRY PCISubClass_0d[]; +PCI_CLASS_ENTRY PCISubClass_0e[]; +PCI_CLASS_ENTRY PCISubClass_0f[]; +PCI_CLASS_ENTRY PCISubClass_10[]; +PCI_CLASS_ENTRY PCISubClass_11[]; +PCI_CLASS_ENTRY PCIPIFClass_0101[]; +PCI_CLASS_ENTRY PCIPIFClass_0300[]; +PCI_CLASS_ENTRY PCIPIFClass_0604[]; +PCI_CLASS_ENTRY PCIPIFClass_0700[]; +PCI_CLASS_ENTRY PCIPIFClass_0701[]; +PCI_CLASS_ENTRY PCIPIFClass_0703[]; +PCI_CLASS_ENTRY PCIPIFClass_0800[]; +PCI_CLASS_ENTRY PCIPIFClass_0801[]; +PCI_CLASS_ENTRY PCIPIFClass_0802[]; +PCI_CLASS_ENTRY PCIPIFClass_0803[]; +PCI_CLASS_ENTRY PCIPIFClass_0904[]; +PCI_CLASS_ENTRY PCIPIFClass_0c00[]; +PCI_CLASS_ENTRY PCIPIFClass_0c03[]; +PCI_CLASS_ENTRY PCIPIFClass_0e00[]; + +// +// Base class strings entries +// +PCI_CLASS_ENTRY gClassStringList[] = { + { + 0x00, + L"Pre 2.0 device", + PCISubClass_00 + }, + { + 0x01, + L"Mass Storage Controller", + PCISubClass_01 + }, + { + 0x02, + L"Network Controller", + PCISubClass_02 + }, + { + 0x03, + L"Display Controller", + PCISubClass_03 + }, + { + 0x04, + L"Multimedia Device", + PCISubClass_04 + }, + { + 0x05, + L"Memory Controller", + PCISubClass_05 + }, + { + 0x06, + L"Bridge Device", + PCISubClass_06 + }, + { + 0x07, + L"Simple Communications Controllers", + PCISubClass_07 + }, + { + 0x08, + L"Base System Peripherals", + PCISubClass_08 + }, + { + 0x09, + L"Input Devices", + PCISubClass_09 + }, + { + 0x0a, + L"Docking Stations", + PCISubClass_0a + }, + { + 0x0b, + L"Processors", + PCISubClass_0b + }, + { + 0x0c, + L"Serial Bus Controllers", + PCISubClass_0c + }, + { + 0x0d, + L"Wireless Controllers", + PCISubClass_0d + }, + { + 0x0e, + L"Intelligent IO Controllers", + PCISubClass_0e + }, + { + 0x0f, + L"Satellite Communications Controllers", + PCISubClass_0f + }, + { + 0x10, + L"Encryption/Decryption Controllers", + PCISubClass_10 + }, + { + 0x11, + L"Data Acquisition & Signal Processing Controllers", + PCISubClass_11 + }, + { + 0xff, + L"Device does not fit in any defined classes", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +// +// Subclass strings entries +// +PCI_CLASS_ENTRY PCIBlankEntry[] = { + { + 0x00, + L"", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_00[] = { + { + 0x00, + L"All devices other than VGA", + PCIBlankEntry + }, + { + 0x01, + L"VGA-compatible devices", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_01[] = { + { + 0x00, + L"SCSI controller", + PCIBlankEntry + }, + { + 0x01, + L"IDE controller", + PCIPIFClass_0101 + }, + { + 0x02, + L"Floppy disk controller", + PCIBlankEntry + }, + { + 0x03, + L"IPI controller", + PCIBlankEntry + }, + { + 0x04, + L"RAID controller", + PCIBlankEntry + }, + { + 0x80, + L"Other mass storage controller", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_02[] = { + { + 0x00, + L"Ethernet controller", + PCIBlankEntry + }, + { + 0x01, + L"Token ring controller", + PCIBlankEntry + }, + { + 0x02, + L"FDDI controller", + PCIBlankEntry + }, + { + 0x03, + L"ATM controller", + PCIBlankEntry + }, + { + 0x04, + L"ISDN controller", + PCIBlankEntry + }, + { + 0x80, + L"Other network controller", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_03[] = { + { + 0x00, + L"VGA/8514 controller", + PCIPIFClass_0300 + }, + { + 0x01, + L"XGA controller", + PCIBlankEntry + }, + { + 0x02, + L"3D controller", + PCIBlankEntry + }, + { + 0x80, + L"Other display controller", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */PCIBlankEntry + } +}; + +PCI_CLASS_ENTRY PCISubClass_04[] = { + { + 0x00, + L"Video device", + PCIBlankEntry + }, + { + 0x01, + L"Audio device", + PCIBlankEntry + }, + { + 0x02, + L"Computer Telephony device", + PCIBlankEntry + }, + { + 0x80, + L"Other multimedia device", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_05[] = { + { + 0x00, + L"RAM memory controller", + PCIBlankEntry + }, + { + 0x01, + L"Flash memory controller", + PCIBlankEntry + }, + { + 0x80, + L"Other memory controller", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_06[] = { + { + 0x00, + L"Host/PCI bridge", + PCIBlankEntry + }, + { + 0x01, + L"PCI/ISA bridge", + PCIBlankEntry + }, + { + 0x02, + L"PCI/EISA bridge", + PCIBlankEntry + }, + { + 0x03, + L"PCI/Micro Channel bridge", + PCIBlankEntry + }, + { + 0x04, + L"PCI/PCI bridge", + PCIPIFClass_0604 + }, + { + 0x05, + L"PCI/PCMCIA bridge", + PCIBlankEntry + }, + { + 0x06, + L"NuBus bridge", + PCIBlankEntry + }, + { + 0x07, + L"CardBus bridge", + PCIBlankEntry + }, + { + 0x08, + L"RACEway bridge", + PCIBlankEntry + }, + { + 0x80, + L"Other bridge type", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_07[] = { + { + 0x00, + L"Serial controller", + PCIPIFClass_0700 + }, + { + 0x01, + L"Parallel port", + PCIPIFClass_0701 + }, + { + 0x02, + L"Multiport serial controller", + PCIBlankEntry + }, + { + 0x03, + L"Modem", + PCIPIFClass_0703 + }, + { + 0x80, + L"Other communication device", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_08[] = { + { + 0x00, + L"PIC", + PCIPIFClass_0800 + }, + { + 0x01, + L"DMA controller", + PCIPIFClass_0801 + }, + { + 0x02, + L"System timer", + PCIPIFClass_0802 + }, + { + 0x03, + L"RTC controller", + PCIPIFClass_0803 + }, + { + 0x04, + L"Generic PCI Hot-Plug controller", + PCIBlankEntry + }, + { + 0x80, + L"Other system peripheral", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_09[] = { + { + 0x00, + L"Keyboard controller", + PCIBlankEntry + }, + { + 0x01, + L"Digitizer (pen)", + PCIBlankEntry + }, + { + 0x02, + L"Mouse controller", + PCIBlankEntry + }, + { + 0x03, + L"Scanner controller", + PCIBlankEntry + }, + { + 0x04, + L"Gameport controller", + PCIPIFClass_0904 + }, + { + 0x80, + L"Other input controller", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_0a[] = { + { + 0x00, + L"Generic docking station", + PCIBlankEntry + }, + { + 0x80, + L"Other type of docking station", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_0b[] = { + { + 0x00, + L"386", + PCIBlankEntry + }, + { + 0x01, + L"486", + PCIBlankEntry + }, + { + 0x02, + L"Pentium", + PCIBlankEntry + }, + { + 0x10, + L"Alpha", + PCIBlankEntry + }, + { + 0x20, + L"PowerPC", + PCIBlankEntry + }, + { + 0x30, + L"MIPS", + PCIBlankEntry + }, + { + 0x40, + L"Co-processor", + PCIBlankEntry + }, + { + 0x80, + L"Other processor", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_0c[] = { + { + 0x00, + L"Firewire(IEEE 1394)", + PCIPIFClass_0c03 + }, + { + 0x01, + L"ACCESS.bus", + PCIBlankEntry + }, + { + 0x02, + L"SSA", + PCIBlankEntry + }, + { + 0x03, + L"USB", + PCIPIFClass_0c00 + }, + { + 0x04, + L"Fibre Channel", + PCIBlankEntry + }, + { + 0x05, + L"System Management Bus", + PCIBlankEntry + }, + { + 0x80, + L"Other bus type", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_0d[] = { + { + 0x00, + L"iRDA compatible controller", + PCIBlankEntry + }, + { + 0x01, + L"Consumer IR controller", + PCIBlankEntry + }, + { + 0x10, + L"RF controller", + PCIBlankEntry + }, + { + 0x80, + L"Other type of wireless controller", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_0e[] = { + { + 0x00, + L"I2O Architecture", + PCIPIFClass_0e00 + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_0f[] = { + { + 0x00, + L"TV", + PCIBlankEntry + }, + { + 0x01, + L"Audio", + PCIBlankEntry + }, + { + 0x02, + L"Voice", + PCIBlankEntry + }, + { + 0x03, + L"Data", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_10[] = { + { + 0x00, + L"Network & computing Encrypt/Decrypt", + PCIBlankEntry + }, + { + 0x01, + L"Entertainment Encrypt/Decrypt", + PCIBlankEntry + }, + { + 0x80, + L"Other Encrypt/Decrypt", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCISubClass_11[] = { + { + 0x00, + L"DPIO modules", + PCIBlankEntry + }, + { + 0x80, + L"Other DAQ & SP controllers", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +// +// Programming Interface entries +// +PCI_CLASS_ENTRY PCIPIFClass_0101[] = { + { + 0x00, + L"", + PCIBlankEntry + }, + { + 0x01, + L"OM-primary", + PCIBlankEntry + }, + { + 0x02, + L"PI-primary", + PCIBlankEntry + }, + { + 0x03, + L"OM/PI-primary", + PCIBlankEntry + }, + { + 0x04, + L"OM-secondary", + PCIBlankEntry + }, + { + 0x05, + L"OM-primary, OM-secondary", + PCIBlankEntry + }, + { + 0x06, + L"PI-primary, OM-secondary", + PCIBlankEntry + }, + { + 0x07, + L"OM/PI-primary, OM-secondary", + PCIBlankEntry + }, + { + 0x08, + L"OM-secondary", + PCIBlankEntry + }, + { + 0x09, + L"OM-primary, PI-secondary", + PCIBlankEntry + }, + { + 0x0a, + L"PI-primary, PI-secondary", + PCIBlankEntry + }, + { + 0x0b, + L"OM/PI-primary, PI-secondary", + PCIBlankEntry + }, + { + 0x0c, + L"OM-secondary", + PCIBlankEntry + }, + { + 0x0d, + L"OM-primary, OM/PI-secondary", + PCIBlankEntry + }, + { + 0x0e, + L"PI-primary, OM/PI-secondary", + PCIBlankEntry + }, + { + 0x0f, + L"OM/PI-primary, OM/PI-secondary", + PCIBlankEntry + }, + { + 0x80, + L"Master", + PCIBlankEntry + }, + { + 0x81, + L"Master, OM-primary", + PCIBlankEntry + }, + { + 0x82, + L"Master, PI-primary", + PCIBlankEntry + }, + { + 0x83, + L"Master, OM/PI-primary", + PCIBlankEntry + }, + { + 0x84, + L"Master, OM-secondary", + PCIBlankEntry + }, + { + 0x85, + L"Master, OM-primary, OM-secondary", + PCIBlankEntry + }, + { + 0x86, + L"Master, PI-primary, OM-secondary", + PCIBlankEntry + }, + { + 0x87, + L"Master, OM/PI-primary, OM-secondary", + PCIBlankEntry + }, + { + 0x88, + L"Master, OM-secondary", + PCIBlankEntry + }, + { + 0x89, + L"Master, OM-primary, PI-secondary", + PCIBlankEntry + }, + { + 0x8a, + L"Master, PI-primary, PI-secondary", + PCIBlankEntry + }, + { + 0x8b, + L"Master, OM/PI-primary, PI-secondary", + PCIBlankEntry + }, + { + 0x8c, + L"Master, OM-secondary", + PCIBlankEntry + }, + { + 0x8d, + L"Master, OM-primary, OM/PI-secondary", + PCIBlankEntry + }, + { + 0x8e, + L"Master, PI-primary, OM/PI-secondary", + PCIBlankEntry + }, + { + 0x8f, + L"Master, OM/PI-primary, OM/PI-secondary", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0300[] = { + { + 0x00, + L"VGA compatible", + PCIBlankEntry + }, + { + 0x01, + L"8514 compatible", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0604[] = { + { + 0x00, + L"", + PCIBlankEntry + }, + { + 0x01, + L"Subtractive decode", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0700[] = { + { + 0x00, + L"Generic XT-compatible", + PCIBlankEntry + }, + { + 0x01, + L"16450-compatible", + PCIBlankEntry + }, + { + 0x02, + L"16550-compatible", + PCIBlankEntry + }, + { + 0x03, + L"16650-compatible", + PCIBlankEntry + }, + { + 0x04, + L"16750-compatible", + PCIBlankEntry + }, + { + 0x05, + L"16850-compatible", + PCIBlankEntry + }, + { + 0x06, + L"16950-compatible", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0701[] = { + { + 0x00, + L"", + PCIBlankEntry + }, + { + 0x01, + L"Bi-directional", + PCIBlankEntry + }, + { + 0x02, + L"ECP 1.X-compliant", + PCIBlankEntry + }, + { + 0x03, + L"IEEE 1284", + PCIBlankEntry + }, + { + 0xfe, + L"IEEE 1284 target (not a controller)", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0703[] = { + { + 0x00, + L"Generic", + PCIBlankEntry + }, + { + 0x01, + L"Hayes-compatible 16450", + PCIBlankEntry + }, + { + 0x02, + L"Hayes-compatible 16550", + PCIBlankEntry + }, + { + 0x03, + L"Hayes-compatible 16650", + PCIBlankEntry + }, + { + 0x04, + L"Hayes-compatible 16750", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0800[] = { + { + 0x00, + L"Generic 8259", + PCIBlankEntry + }, + { + 0x01, + L"ISA", + PCIBlankEntry + }, + { + 0x02, + L"EISA", + PCIBlankEntry + }, + { + 0x10, + L"IO APIC", + PCIBlankEntry + }, + { + 0x20, + L"IO(x) APIC interrupt controller", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0801[] = { + { + 0x00, + L"Generic 8237", + PCIBlankEntry + }, + { + 0x01, + L"ISA", + PCIBlankEntry + }, + { + 0x02, + L"EISA", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0802[] = { + { + 0x00, + L"Generic 8254", + PCIBlankEntry + }, + { + 0x01, + L"ISA", + PCIBlankEntry + }, + { + 0x02, + L"EISA", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0803[] = { + { + 0x00, + L"Generic", + PCIBlankEntry + }, + { + 0x01, + L"ISA", + PCIBlankEntry + }, + { + 0x02, + L"EISA", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0904[] = { + { + 0x00, + L"Generic", + PCIBlankEntry + }, + { + 0x10, + L"", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0c00[] = { + { + 0x00, + L"Universal Host Controller spec", + PCIBlankEntry + }, + { + 0x10, + L"Open Host Controller spec", + PCIBlankEntry + }, + { + 0x80, + L"No specific programming interface", + PCIBlankEntry + }, + { + 0xfe, + L"(Not Host Controller)", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0c03[] = { + { + 0x00, + L"", + PCIBlankEntry + }, + { + 0x10, + L"Using 1394 OpenHCI spec", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +PCI_CLASS_ENTRY PCIPIFClass_0e00[] = { + { + 0x00, + L"Message FIFO at offset 40h", + PCIBlankEntry + }, + { + 0x01, + L"", + PCIBlankEntry + }, + { + 0x00, + NULL, + /* null string ends the list */NULL + } +}; + +#define EFI_HEX_DISP_SIZE 32 +BOOLEAN +PrivateDumpHex ( + IN UINTN Indent, + IN UINTN Offset, + IN UINTN DataSize, + IN VOID *UserData + ) +/*++ + +Routine Description: + + Add page break feature to the DumpHex + +Arguments: + Indent - The indent space + + Offset - The offset + + DataSize - The data size + + UserData - The data + +Returns: + + TRUE - The dump is broke + FALSE - The dump is completed + +**/ +{ + UINTN DispSize; + UINT8 *DispData; + + DispSize = EFI_HEX_DISP_SIZE; + DispData = (UINT8 *) UserData; + + while (DataSize!=0) { + if (ShellGetExecutionBreakFlag ()) { + return TRUE; + } + + if (DataSize > EFI_HEX_DISP_SIZE) { + DataSize -= EFI_HEX_DISP_SIZE; + } else { + DispSize = DataSize; + DataSize = 0; + } + + DumpHex (Indent, Offset + DispData - (UINT8 *) UserData, DispSize, DispData); + DispData += DispSize; + } + + return FALSE; +} + +// +// Implemetations +// +VOID +PciGetClassStrings ( + IN UINT32 ClassCode, + IN OUT PCI_CLASS_STRINGS *ClassStrings + ) +/*++ +Routine Description: + + Generates printable Unicode strings that represent PCI device class, + subclass and programmed I/F based on a value passed to the function. + +Arguments: + + ClassCode Value representing the PCI "Class Code" register read from a + PCI device. The encodings are: + bits 23:16 - Base Class Code + bits 15:8 - Sub-Class Code + bits 7:0 - Programming Interface + ClassStrings Pointer of PCI_CLASS_STRINGS structure, which contains + printable class strings corresponding to ClassCode. The + caller must not modify the strings that are pointed by + the fields in ClassStrings. +Returns: + + None +**/ +{ + INTN Index; + UINT8 Code; + PCI_CLASS_ENTRY *CurrentClass; + + // + // Assume no strings found + // + ClassStrings->BaseClass = L"UNDEFINED"; + ClassStrings->SubClass = L"UNDEFINED"; + ClassStrings->PIFClass = L"UNDEFINED"; + + CurrentClass = gClassStringList; + Code = (UINT8) (ClassCode >> 16); + Index = 0; + + // + // Go through all entries of the base class, until the entry with a matching + // base class code is found. If reaches an entry with a null description + // text, the last entry is met, which means no text for the base class was + // found, so no more action is needed. + // + while (Code != CurrentClass[Index].Code) { + if (NULL == CurrentClass[Index].DescText) { + return ; + } + + Index++; + } + // + // A base class was found. Assign description, and check if this class has + // sub-class defined. If sub-class defined, no more action is needed, + // otherwise, continue to find description for the sub-class code. + // + ClassStrings->BaseClass = CurrentClass[Index].DescText; + if (NULL == CurrentClass[Index].LowerLevelClass) { + return ; + } + // + // find Subclass entry + // + CurrentClass = CurrentClass[Index].LowerLevelClass; + Code = (UINT8) (ClassCode >> 8); + Index = 0; + + // + // Go through all entries of the sub-class, until the entry with a matching + // sub-class code is found. If reaches an entry with a null description + // text, the last entry is met, which means no text for the sub-class was + // found, so no more action is needed. + // + while (Code != CurrentClass[Index].Code) { + if (NULL == CurrentClass[Index].DescText) { + return ; + } + + Index++; + } + // + // A class was found for the sub-class code. Assign description, and check if + // this sub-class has programming interface defined. If no, no more action is + // needed, otherwise, continue to find description for the programming + // interface. + // + ClassStrings->SubClass = CurrentClass[Index].DescText; + if (NULL == CurrentClass[Index].LowerLevelClass) { + return ; + } + // + // Find programming interface entry + // + CurrentClass = CurrentClass[Index].LowerLevelClass; + Code = (UINT8) ClassCode; + Index = 0; + + // + // Go through all entries of the I/F entries, until the entry with a + // matching I/F code is found. If reaches an entry with a null description + // text, the last entry is met, which means no text was found, so no more + // action is needed. + // + while (Code != CurrentClass[Index].Code) { + if (NULL == CurrentClass[Index].DescText) { + return ; + } + + Index++; + } + // + // A class was found for the I/F code. Assign description, done! + // + ClassStrings->PIFClass = CurrentClass[Index].DescText; + return ; +} + +VOID +PciPrintClassCode ( + IN UINT8 *ClassCodePtr, + IN BOOLEAN IncludePIF + ) +/*++ +Routine Description: + + Print strings that represent PCI device class, subclass and programmed I/F + +Arguments: + + ClassCodePtr Points to the memory which stores register Class Code in PCI + configuation space. + IncludePIF If the printed string should include the programming I/F part +Returns: + + None +**/ +{ + UINT32 ClassCode; + PCI_CLASS_STRINGS ClassStrings; + CHAR16 OutputString[PCI_CLASS_STRING_LIMIT + 1]; + + ClassCode = 0; + ClassCode |= ClassCodePtr[0]; + ClassCode |= (ClassCodePtr[1] << 8); + ClassCode |= (ClassCodePtr[2] << 16); + + // + // Get name from class code + // + PciGetClassStrings (ClassCode, &ClassStrings); + + if (IncludePIF) { + // + // Only print base class and sub class name + // + ShellPrintEx(-1,-1, L"%s - %s - %s", + ClassStrings.BaseClass, + ClassStrings.SubClass, + ClassStrings.PIFClass + ); + + } else { + // + // Print base class, sub class, and programming inferface name + // + UnicodeSPrint ( + OutputString, + PCI_CLASS_STRING_LIMIT * sizeof (CHAR16), + L"%s - %s", + ClassStrings.BaseClass, + ClassStrings.SubClass + ); + + OutputString[PCI_CLASS_STRING_LIMIT] = 0; + ShellPrintEx(-1,-1, L"%s", OutputString); + } +} + +EFI_STATUS +PciDump ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +EFI_STATUS +PciFindProtocolInterface ( + IN EFI_HANDLE *HandleBuf, + IN UINTN HandleCount, + IN UINT16 Segment, + IN UINT16 Bus, + OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev + ); + +EFI_STATUS +PciGetProtocolAndResource ( + IN EFI_HANDLE Handle, + OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev, + OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors + ); + +EFI_STATUS +PciGetNextBusRange ( + IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors, + OUT UINT16 *MinBus, + OUT UINT16 *MaxBus, + OUT BOOLEAN *IsEnd + ); + +EFI_STATUS +PciExplainData ( + IN PCI_CONFIG_SPACE *ConfigSpace, + IN UINT64 Address, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev + ); + +EFI_STATUS +PciExplainDeviceData ( + IN PCI_DEVICE_HEADER *Device, + IN UINT64 Address, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev + ); + +EFI_STATUS +PciExplainBridgeData ( + IN PCI_BRIDGE_HEADER *Bridge, + IN UINT64 Address, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev + ); + +EFI_STATUS +PciExplainBar ( + IN UINT32 *Bar, + IN UINT16 *Command, + IN UINT64 Address, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev, + IN OUT UINTN *Index + ); + +EFI_STATUS +PciExplainCardBusData ( + IN PCI_CARDBUS_HEADER *CardBus, + IN UINT64 Address, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev + ); + +EFI_STATUS +PciExplainStatus ( + IN UINT16 *Status, + IN BOOLEAN MainStatus, + IN PCI_HEADER_TYPE HeaderType + ); + +EFI_STATUS +PciExplainCommand ( + IN UINT16 *Command + ); + +EFI_STATUS +PciExplainBridgeControl ( + IN UINT16 *BridgeControl, + IN PCI_HEADER_TYPE HeaderType + ); + +EFI_STATUS +PciExplainCapabilityStruct ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev, + IN UINT64 Address, + IN UINT8 CapPtr + ); + +EFI_STATUS +PciExplainPciExpress ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev, + IN UINT64 Address, + IN UINT8 CapabilityPtr + ); + +EFI_STATUS +ExplainPcieCapReg ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieDeviceCap ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieDeviceControl ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieDeviceStatus ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieLinkCap ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieLinkControl ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieLinkStatus ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieSlotCap ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieSlotControl ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieSlotStatus ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieRootControl ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieRootCap ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +EFI_STATUS +ExplainPcieRootStatus ( + IN PCIE_CAP_STURCTURE *PciExpressCap +); + +typedef EFI_STATUS (*PCIE_EXPLAIN_FUNCTION) (IN PCIE_CAP_STURCTURE *PciExpressCap); + +typedef enum { + FieldWidthUINT8, + FieldWidthUINT16, + FieldWidthUINT32 +} PCIE_CAPREG_FIELD_WIDTH; + +typedef enum { + PcieExplainTypeCommon, + PcieExplainTypeDevice, + PcieExplainTypeLink, + PcieExplainTypeSlot, + PcieExplainTypeRoot, + PcieExplainTypeMax +} PCIE_EXPLAIN_TYPE; + +typedef struct +{ + UINT16 Token; + UINTN Offset; + PCIE_CAPREG_FIELD_WIDTH Width; + PCIE_EXPLAIN_FUNCTION Func; + PCIE_EXPLAIN_TYPE Type; +} PCIE_EXPLAIN_STRUCT; + +PCIE_EXPLAIN_STRUCT PcieExplainList[] = { + { + STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID), + 0x00, + FieldWidthUINT8, + NULL, + PcieExplainTypeCommon + }, + { + STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR), + 0x01, + FieldWidthUINT8, + NULL, + PcieExplainTypeCommon + }, + { + STRING_TOKEN (STR_PCIEX_CAP_REGISTER), + 0x02, + FieldWidthUINT16, + ExplainPcieCapReg, + PcieExplainTypeCommon + }, + { + STRING_TOKEN (STR_PCIEX_DEVICE_CAP), + 0x04, + FieldWidthUINT32, + ExplainPcieDeviceCap, + PcieExplainTypeDevice + }, + { + STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL), + 0x08, + FieldWidthUINT16, + ExplainPcieDeviceControl, + PcieExplainTypeDevice + }, + { + STRING_TOKEN (STR_PCIEX_DEVICE_STATUS), + 0x0a, + FieldWidthUINT16, + ExplainPcieDeviceStatus, + PcieExplainTypeDevice + }, + { + STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES), + 0x0c, + FieldWidthUINT32, + ExplainPcieLinkCap, + PcieExplainTypeLink + }, + { + STRING_TOKEN (STR_PCIEX_LINK_CONTROL), + 0x10, + FieldWidthUINT16, + ExplainPcieLinkControl, + PcieExplainTypeLink + }, + { + STRING_TOKEN (STR_PCIEX_LINK_STATUS), + 0x12, + FieldWidthUINT16, + ExplainPcieLinkStatus, + PcieExplainTypeLink + }, + { + STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES), + 0x14, + FieldWidthUINT32, + ExplainPcieSlotCap, + PcieExplainTypeSlot + }, + { + STRING_TOKEN (STR_PCIEX_SLOT_CONTROL), + 0x18, + FieldWidthUINT16, + ExplainPcieSlotControl, + PcieExplainTypeSlot + }, + { + STRING_TOKEN (STR_PCIEX_SLOT_STATUS), + 0x1a, + FieldWidthUINT16, + ExplainPcieSlotStatus, + PcieExplainTypeSlot + }, + { + STRING_TOKEN (STR_PCIEX_ROOT_CONTROL), + 0x1c, + FieldWidthUINT16, + ExplainPcieRootControl, + PcieExplainTypeRoot + }, + { + STRING_TOKEN (STR_PCIEX_RSVDP), + 0x1e, + FieldWidthUINT16, + ExplainPcieRootCap, + PcieExplainTypeRoot + }, + { + STRING_TOKEN (STR_PCIEX_ROOT_STATUS), + 0x20, + FieldWidthUINT32, + ExplainPcieRootStatus, + PcieExplainTypeRoot + }, + { + 0, + 0, + (PCIE_CAPREG_FIELD_WIDTH)0, + NULL, + PcieExplainTypeMax + } +}; + +// +// Global Variables +// +PCI_CONFIG_SPACE *mConfigSpace = NULL; +STATIC CONST SHELL_PARAM_ITEM ParamList[] = { + {L"-s", TypeValue}, + {L"-i", TypeFlag}, + {NULL, TypeMax} + }; + +CHAR16 *DevicePortTypeTable[] = { + L"PCI Express Endpoint", + L"Legacy PCI Express Endpoint", + L"Unknown Type", + L"Unknonw Type", + L"Root Port of PCI Express Root Complex", + L"Upstream Port of PCI Express Switch", + L"Downstream Port of PCI Express Switch", + L"PCI Express to PCI/PCI-X Bridge", + L"PCI/PCI-X to PCI Express Bridge", + L"Root Complex Integrated Endpoint", + L"Root Complex Event Collector" +}; + +CHAR16 *L0sLatencyStrTable[] = { + L"Less than 64ns", + L"64ns to less than 128ns", + L"128ns to less than 256ns", + L"256ns to less than 512ns", + L"512ns to less than 1us", + L"1us to less than 2us", + L"2us-4us", + L"More than 4us" +}; + +CHAR16 *L1LatencyStrTable[] = { + L"Less than 1us", + L"1us to less than 2us", + L"2us to less than 4us", + L"4us to less than 8us", + L"8us to less than 16us", + L"16us to less than 32us", + L"32us-64us", + L"More than 64us" +}; + +CHAR16 *ASPMCtrlStrTable[] = { + L"Disabled", + L"L0s Entry Enabled", + L"L1 Entry Enabled", + L"L0s and L1 Entry Enabled" +}; + +CHAR16 *SlotPwrLmtScaleTable[] = { + L"1.0x", + L"0.1x", + L"0.01x", + L"0.001x" +}; + +CHAR16 *IndicatorTable[] = { + L"Reserved", + L"On", + L"Blink", + L"Off" +}; + + +SHELL_STATUS +EFIAPI +ShellCommandRunPci ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + UINT16 Segment; + UINT16 Bus; + UINT16 Device; + UINT16 Func; + UINT64 Address; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev; + EFI_STATUS Status; + PCI_COMMON_HEADER PciHeader; + PCI_CONFIG_SPACE ConfigSpace; + UINTN ScreenCount; + UINTN TempColumn; + UINTN ScreenSize; + BOOLEAN ExplainData; + UINTN Index; + UINTN SizeOfHeader; + BOOLEAN PrintTitle; + UINTN HandleBufSize; + EFI_HANDLE *HandleBuf; + UINTN HandleCount; + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors; + UINT16 MinBus; + UINT16 MaxBus; + BOOLEAN IsEnd; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + UINTN Size; + CONST CHAR16 *Temp; + + ShellStatus = SHELL_SUCCESS; + Status = EFI_SUCCESS; + Address = 0; + Size = 0; + IoDev = NULL; + HandleBuf = NULL; + Package = NULL; + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + + + // + // Get all instances of PciRootBridgeIo. Allocate space for 1 EFI_HANDLE and + // call LibLocateHandle(), if EFI_BUFFER_TOO_SMALL is returned, allocate enough + // space for handles and call it again. + // + HandleBufSize = sizeof (EFI_HANDLE); + HandleBuf = (EFI_HANDLE *) AllocatePool (HandleBufSize); + if (HandleBuf == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle); + ShellStatus = SHELL_OUT_OF_RESOURCES; + goto Done; + } + + Status = gBS->LocateHandle ( + ByProtocol, + &gEfiPciRootBridgeIoProtocolGuid, + NULL, + &HandleBufSize, + HandleBuf + ); + + if (Status == EFI_BUFFER_TOO_SMALL) { + HandleBuf = ReallocatePool (sizeof (EFI_HANDLE), HandleBufSize, HandleBuf); + if (HandleBuf == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle); + ShellStatus = SHELL_OUT_OF_RESOURCES; + goto Done; + } + + Status = gBS->LocateHandle ( + ByProtocol, + &gEfiPciRootBridgeIoProtocolGuid, + NULL, + &HandleBufSize, + HandleBuf + ); + } + + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_NF), gShellDebug1HiiHandle); + ShellStatus = SHELL_NOT_FOUND; + goto Done; + } + + HandleCount = HandleBufSize / sizeof (EFI_HANDLE); + // + // Argument Count == 1(no other argument): enumerate all pci functions + // + if (ShellCommandLineGetCount(Package) == 0) { + gST->ConOut->QueryMode ( + gST->ConOut, + gST->ConOut->Mode->Mode, + &TempColumn, + &ScreenSize + ); + + ScreenCount = 0; + ScreenSize -= 4; + if ((ScreenSize & 1) == 1) { + ScreenSize -= 1; + } + + PrintTitle = TRUE; + + // + // For each handle, which decides a segment and a bus number range, + // enumerate all devices on it. + // + for (Index = 0; Index < HandleCount; Index++) { + Status = PciGetProtocolAndResource ( + HandleBuf[Index], + &IoDev, + &Descriptors + ); + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_HANDLE_CFG_ERR), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_NOT_FOUND; + goto Done; + } + // + // No document say it's impossible for a RootBridgeIo protocol handle + // to have more than one address space descriptors, so find out every + // bus range and for each of them do device enumeration. + // + while (TRUE) { + Status = PciGetNextBusRange (&Descriptors, &MinBus, &MaxBus, &IsEnd); + + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_BUS_RANGE_ERR), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_NOT_FOUND; + goto Done; + } + + if (IsEnd) { + break; + } + + for (Bus = MinBus; Bus <= MaxBus; Bus++) { + // + // For each devices, enumerate all functions it contains + // + for (Device = 0; Device <= PCI_MAX_DEVICE; Device++) { + // + // For each function, read its configuration space and print summary + // + for (Func = 0; Func <= PCI_MAX_FUNC; Func++) { + if (ShellGetExecutionBreakFlag ()) { + ShellStatus = SHELL_ABORTED; + goto Done; + } + Address = CALC_EFI_PCI_ADDRESS (Bus, Device, Func, 0); + IoDev->Pci.Read ( + IoDev, + EfiPciWidthUint16, + Address, + 1, + &PciHeader.VendorId + ); + + // + // If VendorId = 0xffff, there does not exist a device at this + // location. For each device, if there is any function on it, + // there must be 1 function at Function 0. So if Func = 0, there + // will be no more functions in the same device, so we can break + // loop to deal with the next device. + // + if (PciHeader.VendorId == 0xffff && Func == 0) { + break; + } + + if (PciHeader.VendorId != 0xffff) { + + if (PrintTitle) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_TITLE), gShellDebug1HiiHandle); + PrintTitle = FALSE; + } + + IoDev->Pci.Read ( + IoDev, + EfiPciWidthUint32, + Address, + sizeof (PciHeader) / sizeof (UINT32), + &PciHeader + ); + + ShellPrintHiiEx( + -1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_P1), gShellDebug1HiiHandle, + IoDev->SegmentNumber, + Bus, + Device, + Func + ); + + PciPrintClassCode (PciHeader.ClassCode, FALSE); + ShellPrintHiiEx( + -1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_P2), gShellDebug1HiiHandle, + PciHeader.VendorId, + PciHeader.DeviceId, + PciHeader.ClassCode[0] + ); + + ScreenCount += 2; + if (ScreenCount >= ScreenSize && ScreenSize != 0) { + // + // If ScreenSize == 0 we have the console redirected so don't + // block updates + // + ScreenCount = 0; + } + // + // If this is not a multi-function device, we can leave the loop + // to deal with the next device. + // + if (Func == 0 && ((PciHeader.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00)) { + break; + } + } + } + } + } + // + // If Descriptor is NULL, Configuration() returns EFI_UNSUPPRORED, + // we assume the bus range is 0~PCI_MAX_BUS. After enumerated all + // devices on all bus, we can leave loop. + // + if (Descriptors == NULL) { + break; + } + } + } + + Status = EFI_SUCCESS; + goto Done; + } + + if (ShellCommandLineGetCount(Package) == 1) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + // + // Arg count >= 3, dump binary of specified function, interpret if necessary + // + if (ShellCommandLineGetCount(Package) > 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + + ExplainData = FALSE; + Segment = 0; + Bus = 0; + Device = 0; + Func = 0; + if (ShellCommandLineGetFlag(Package, L"-i")) { + ExplainData = TRUE; + } + + Temp = ShellCommandLineGetValue(Package, L"-s"); + if (Temp != NULL) { + Segment = (UINT16) StrHexToUintn (Temp); + } + + // + // The first Argument(except "-i") is assumed to be Bus number, second + // to be Device number, and third to be Func number. + // + Temp = ShellCommandLineGetRawValue(Package, 1); + if (Temp != NULL) { + Bus = (UINT16)StrHexToUintn(Temp); + if (Bus > MAX_BUS_NUMBER) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + } + Temp = ShellCommandLineGetRawValue(Package, 2); + if (Temp != NULL) { + Device = (UINT16) StrHexToUintn(Temp); + if (Device > MAX_DEVICE_NUMBER){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + } + + Temp = ShellCommandLineGetRawValue(Package, 3); + if (Temp != NULL) { + Func = (UINT16) StrHexToUintn(Temp); + if (Func > MAX_FUNCTION_NUMBER){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + } + + // + // Find the protocol interface who's in charge of current segment, and its + // bus range covers the current bus + // + Status = PciFindProtocolInterface ( + HandleBuf, + HandleCount, + Segment, + Bus, + &IoDev + ); + + if (EFI_ERROR (Status)) { + ShellPrintHiiEx( + -1, -1, NULL, STRING_TOKEN (STR_PCI_NO_FIND), gShellDebug1HiiHandle, + gShellDebug1HiiHandle, + Segment, + Bus + ); + ShellStatus = SHELL_NOT_FOUND; + goto Done; + } + + Address = CALC_EFI_PCI_ADDRESS (Bus, Device, Func, 0); + Status = IoDev->Pci.Read ( + IoDev, + EfiPciWidthUint8, + Address, + sizeof (ConfigSpace), + &ConfigSpace + ); + + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_NO_CFG), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_ACCESS_DENIED; + goto Done; + } + + mConfigSpace = &ConfigSpace; + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_PCI_INFO), + gShellDebug1HiiHandle, + Segment, + Bus, + Device, + Func, + Segment, + Bus, + Device, + Func + ); + + // + // Dump standard header of configuration space + // + SizeOfHeader = sizeof (ConfigSpace.Common) + sizeof (ConfigSpace.NonCommon); + + PrivateDumpHex (2, 0, SizeOfHeader, &ConfigSpace); + ShellPrintEx(-1,-1, L"\r\n"); + + // + // Dump device dependent Part of configuration space + // + PrivateDumpHex ( + 2, + SizeOfHeader, + sizeof (ConfigSpace) - SizeOfHeader, + ConfigSpace.Data + ); + + // + // If "-i" appears in command line, interpret data in configuration space + // + if (ExplainData) { + Status = PciExplainData (&ConfigSpace, Address, IoDev); + } + } +Done: + if (HandleBuf != NULL) { + FreePool (HandleBuf); + } + if (Package != NULL) { + ShellCommandLineFreeVarList (Package); + } + mConfigSpace = NULL; + return ShellStatus; +} + +EFI_STATUS +PciFindProtocolInterface ( + IN EFI_HANDLE *HandleBuf, + IN UINTN HandleCount, + IN UINT16 Segment, + IN UINT16 Bus, + OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev + ) +/*++ + +Routine Description: + + This function finds out the protocol which is in charge of the given + segment, and its bus range covers the current bus number. It lookes + each instances of RootBridgeIoProtocol handle, until the one meets the + criteria is found. + +Arguments: + + HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles + HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles + Segment Segment number of device we are dealing with + Bus Bus number of device we are dealing with + IoDev Handle used to access configuration space of PCI device + +Returns: + + EFI_SUCCESS - The command completed successfully + EFI_INVALID_PARAMETER - Invalid parameter + +**/ +{ + UINTN Index; + EFI_STATUS Status; + BOOLEAN FoundInterface; + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors; + UINT16 MinBus; + UINT16 MaxBus; + BOOLEAN IsEnd; + + FoundInterface = FALSE; + // + // Go through all handles, until the one meets the criteria is found + // + for (Index = 0; Index < HandleCount; Index++) { + Status = PciGetProtocolAndResource (HandleBuf[Index], IoDev, &Descriptors); + if (EFI_ERROR (Status)) { + return Status; + } + // + // When Descriptors == NULL, the Configuration() is not implemented, + // so we only check the Segment number + // + if (Descriptors == NULL && Segment == (*IoDev)->SegmentNumber) { + return EFI_SUCCESS; + } + + if ((*IoDev)->SegmentNumber != Segment) { + continue; + } + + while (TRUE) { + Status = PciGetNextBusRange (&Descriptors, &MinBus, &MaxBus, &IsEnd); + if (EFI_ERROR (Status)) { + return Status; + } + + if (IsEnd) { + break; + } + + if (MinBus <= Bus && MaxBus >= Bus) { + FoundInterface = TRUE; + break; + } + } + } + + if (FoundInterface) { + return EFI_SUCCESS; + } else { + return EFI_INVALID_PARAMETER; + } +} + +EFI_STATUS +PciGetProtocolAndResource ( + IN EFI_HANDLE Handle, + OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev, + OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors + ) +/*++ + +Routine Description: + + This function gets the protocol interface from the given handle, and + obtains its address space descriptors. + +Arguments: + + Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle + IoDev Handle used to access configuration space of PCI device + Descriptors Points to the address space descriptors + +Returns: + + EFI_SUCCESS The command completed successfully + +**/ +{ + EFI_STATUS Status; + + // + // Get inferface from protocol + // + Status = gBS->HandleProtocol ( + Handle, + &gEfiPciRootBridgeIoProtocolGuid, + (VOID**)IoDev + ); + + if (EFI_ERROR (Status)) { + return Status; + } + // + // Call Configuration() to get address space descriptors + // + Status = (*IoDev)->Configuration (*IoDev, (VOID**)Descriptors); + if (Status == EFI_UNSUPPORTED) { + *Descriptors = NULL; + return EFI_SUCCESS; + + } else { + return Status; + } +} + +EFI_STATUS +PciGetNextBusRange ( + IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors, + OUT UINT16 *MinBus, + OUT UINT16 *MaxBus, + OUT BOOLEAN *IsEnd + ) +/*++ + +Routine Description: + + This function get the next bus range of given address space descriptors. + It also moves the pointer backward a node, to get prepared to be called + again. + +Arguments: + + Descriptors points to current position of a serial of address space + descriptors + MinBus The lower range of bus number + ManBus The upper range of bus number + IsEnd Meet end of the serial of descriptors + +Returns: + + EFI_SUCCESS The command completed successfully + +**/ +{ + *IsEnd = FALSE; + + // + // When *Descriptors is NULL, Configuration() is not implemented, so assume + // range is 0~PCI_MAX_BUS + // + if ((*Descriptors) == NULL) { + *MinBus = 0; + *MaxBus = PCI_MAX_BUS; + return EFI_SUCCESS; + } + // + // *Descriptors points to one or more address space descriptors, which + // ends with a end tagged descriptor. Examine each of the descriptors, + // if a bus typed one is found and its bus range covers bus, this handle + // is the handle we are looking for. + // + if ((*Descriptors)->Desc == ACPI_END_TAG_DESCRIPTOR) { + *IsEnd = TRUE; + } + + while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) { + if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) { + *MinBus = (UINT16) (*Descriptors)->AddrRangeMin; + *MaxBus = (UINT16) (*Descriptors)->AddrRangeMax; + (*Descriptors)++; + break; + } + + (*Descriptors)++; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +PciExplainData ( + IN PCI_CONFIG_SPACE *ConfigSpace, + IN UINT64 Address, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev + ) +/*++ + +Routine Description: + + Explain the data in PCI configuration space. The part which is common for + PCI device and bridge is interpreted in this function. It calls other + functions to interpret data unique for device or bridge. + +Arguments: + + ConfigSpace Data in PCI configuration space + Address Address used to access configuration space of this PCI device + IoDev Handle used to access configuration space of PCI device + +Returns: + + EFI_SUCCESS The command completed successfully + +**/ +{ + PCI_COMMON_HEADER *Common; + PCI_HEADER_TYPE HeaderType; + EFI_STATUS Status; + UINT8 CapPtr; + + Common = &(ConfigSpace->Common); + + Print (L"\n"); + + // + // Print Vendor Id and Device Id + // + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_VID_DID), gShellDebug1HiiHandle, + INDEX_OF (&(Common->VendorId)), + Common->VendorId, + INDEX_OF (&(Common->DeviceId)), + Common->DeviceId + ); + + // + // Print register Command + // + PciExplainCommand (&(Common->Command)); + + // + // Print register Status + // + PciExplainStatus (&(Common->Status), TRUE, PciUndefined); + + // + // Print register Revision ID + // + ShellPrintEx(-1, -1, L"/r/n"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_RID), gShellDebug1HiiHandle, + INDEX_OF (&(Common->RevisionId)), + Common->RevisionId + ); + + // + // Print register BIST + // + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_BIST), gShellDebug1HiiHandle, INDEX_OF (&(Common->BIST))); + if ((Common->BIST & PCI_BIT_7) != 0) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_CAP), gShellDebug1HiiHandle, 0x0f & Common->BIST); + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_CAP_NO), gShellDebug1HiiHandle); + } + // + // Print register Cache Line Size + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_CACHE_LINE_SIZE), + gShellDebug1HiiHandle, + INDEX_OF (&(Common->CacheLineSize)), + Common->CacheLineSize + ); + + // + // Print register Latency Timer + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_LATENCY_TIMER), + gShellDebug1HiiHandle, + INDEX_OF (&(Common->PrimaryLatencyTimer)), + Common->PrimaryLatencyTimer + ); + + // + // Print register Header Type + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_HEADER_TYPE), + gShellDebug1HiiHandle, + INDEX_OF (&(Common->HeaderType)), + Common->HeaderType + ); + + if ((Common->HeaderType & PCI_BIT_7) != 0) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MULTI_FUNCTION), gShellDebug1HiiHandle); + + } else { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_SINGLE_FUNCTION), gShellDebug1HiiHandle); + } + + HeaderType = (PCI_HEADER_TYPE)(UINT8) (Common->HeaderType & 0x7f); + switch (HeaderType) { + case PciDevice: + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_PCI_DEVICE), gShellDebug1HiiHandle); + break; + + case PciP2pBridge: + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_P2P_BRIDGE), gShellDebug1HiiHandle); + break; + + case PciCardBusBridge: + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_BRIDGE), gShellDebug1HiiHandle); + break; + + default: + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESERVED), gShellDebug1HiiHandle); + HeaderType = PciUndefined; + } + + // + // Print register Class Code + // + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CLASS), gShellDebug1HiiHandle); + PciPrintClassCode ((UINT8 *) Common->ClassCode, TRUE); + Print (L"\n"); + + if (ShellGetExecutionBreakFlag()) { + return EFI_SUCCESS; + } + + // + // Interpret remaining part of PCI configuration header depending on + // HeaderType + // + CapPtr = 0; + Status = EFI_SUCCESS; + switch (HeaderType) { + case PciDevice: + Status = PciExplainDeviceData ( + &(ConfigSpace->NonCommon.Device), + Address, + IoDev + ); + CapPtr = ConfigSpace->NonCommon.Device.CapabilitiesPtr; + break; + + case PciP2pBridge: + Status = PciExplainBridgeData ( + &(ConfigSpace->NonCommon.Bridge), + Address, + IoDev + ); + CapPtr = ConfigSpace->NonCommon.Bridge.CapabilitiesPtr; + break; + + case PciCardBusBridge: + Status = PciExplainCardBusData ( + &(ConfigSpace->NonCommon.CardBus), + Address, + IoDev + ); + CapPtr = ConfigSpace->NonCommon.CardBus.CapabilitiesPtr; + break; + } + // + // If Status bit4 is 1, dump or explain capability structure + // + if ((Common->Status) & EFI_PCI_STATUS_CAPABILITY) { + PciExplainCapabilityStruct (IoDev, Address, CapPtr); + } + + return Status; +} + +EFI_STATUS +PciExplainDeviceData ( + IN PCI_DEVICE_HEADER *Device, + IN UINT64 Address, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev + ) +/*++ + +Routine Description: + + Explain the device specific part of data in PCI configuration space. + +Arguments: + + Device Data in PCI configuration space + Address Address used to access configuration space of this PCI device + IoDev Handle used to access configuration space of PCI device + +Returns: + + EFI_SUCCESS The command completed successfully + +**/ +{ + UINTN Index; + BOOLEAN BarExist; + EFI_STATUS Status; + UINTN BarCount; + + // + // Print Base Address Registers(Bar). When Bar = 0, this Bar does not + // exist. If these no Bar for this function, print "none", otherwise + // list detail information about this Bar. + // + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BASE_ADDR), gShellDebug1HiiHandle, INDEX_OF (Device->Bar)); + + BarExist = FALSE; + BarCount = sizeof (Device->Bar) / sizeof (Device->Bar[0]); + for (Index = 0; Index < BarCount; Index++) { + if (Device->Bar[Index] == 0) { + continue; + } + + if (!BarExist) { + BarExist = TRUE; + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_START_TYPE), gShellDebug1HiiHandle); + Print (L" --------------------------------------------------------------------------"); + } + + Status = PciExplainBar ( + &(Device->Bar[Index]), + &(mConfigSpace->Common.Command), + Address, + IoDev, + &Index + ); + + if (EFI_ERROR (Status)) { + break; + } + } + + if (!BarExist) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NONE), gShellDebug1HiiHandle); + + } else { + Print (L"\n --------------------------------------------------------------------------"); + } + + // + // Print register Expansion ROM Base Address + // + if ((Device->ROMBar & PCI_BIT_0) == 0) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_EXPANSION_ROM_DISABLED), gShellDebug1HiiHandle, INDEX_OF (&(Device->ROMBar))); + + } else { + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE), + gShellDebug1HiiHandle, + INDEX_OF (&(Device->ROMBar)), + Device->ROMBar + ); + } + // + // Print register Cardbus CIS ptr + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_CARDBUS_CIS), + gShellDebug1HiiHandle, + INDEX_OF (&(Device->CardBusCISPtr)), + Device->CardBusCISPtr + ); + + // + // Print register Sub-vendor ID and subsystem ID + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID), + gShellDebug1HiiHandle, + INDEX_OF (&(Device->SubVendorId)), + Device->SubVendorId + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SUBSYSTEM_ID), + gShellDebug1HiiHandle, + INDEX_OF (&(Device->SubSystemId)), + Device->SubSystemId + ); + + // + // Print register Capabilities Ptr + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR), + gShellDebug1HiiHandle, + INDEX_OF (&(Device->CapabilitiesPtr)), + Device->CapabilitiesPtr + ); + + // + // Print register Interrupt Line and interrupt pin + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_INTERRUPT_LINE), + gShellDebug1HiiHandle, + INDEX_OF (&(Device->InterruptLine)), + Device->InterruptLine + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_INTERRUPT_PIN), + gShellDebug1HiiHandle, + INDEX_OF (&(Device->InterruptPin)), + Device->InterruptPin + ); + + // + // Print register Min_Gnt and Max_Lat + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_MIN_GNT), + gShellDebug1HiiHandle, + INDEX_OF (&(Device->MinGnt)), + Device->MinGnt + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_MAX_LAT), + gShellDebug1HiiHandle, + INDEX_OF (&(Device->MaxLat)), + Device->MaxLat + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +PciExplainBridgeData ( + IN PCI_BRIDGE_HEADER *Bridge, + IN UINT64 Address, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev + ) +/*++ + +Routine Description: + + Explain the bridge specific part of data in PCI configuration space. + +Arguments: + + Bridge Bridge specific data region in PCI configuration space + Address Address used to access configuration space of this PCI device + IoDev Handle used to access configuration space of PCI device + +Returns: + + EFI_SUCCESS The command completed successfully + +**/ +{ + UINTN Index; + BOOLEAN BarExist; + UINTN BarCount; + UINT32 IoAddress32; + EFI_STATUS Status; + + // + // Print Base Address Registers. When Bar = 0, this Bar does not + // exist. If these no Bar for this function, print "none", otherwise + // list detail information about this Bar. + // + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BASE_ADDRESS), gShellDebug1HiiHandle, INDEX_OF (&(Bridge->Bar))); + + BarExist = FALSE; + BarCount = sizeof (Bridge->Bar) / sizeof (Bridge->Bar[0]); + + for (Index = 0; Index < BarCount; Index++) { + if (Bridge->Bar[Index] == 0) { + continue; + } + + if (!BarExist) { + BarExist = TRUE; + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_START_TYPE_2), gShellDebug1HiiHandle); + Print (L" --------------------------------------------------------------------------"); + } + + Status = PciExplainBar ( + &(Bridge->Bar[Index]), + &(mConfigSpace->Common.Command), + Address, + IoDev, + &Index + ); + + if (EFI_ERROR (Status)) { + break; + } + } + + if (!BarExist) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NONE), gShellDebug1HiiHandle); + } else { + Print (L"\n --------------------------------------------------------------------------"); + } + + // + // Expansion register ROM Base Address + // + if ((Bridge->ROMBar & PCI_BIT_0) == 0) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NO_EXPANSION_ROM), gShellDebug1HiiHandle, INDEX_OF (&(Bridge->ROMBar))); + + } else { + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE_2), + gShellDebug1HiiHandle, + INDEX_OF (&(Bridge->ROMBar)), + Bridge->ROMBar + ); + } + // + // Print Bus Numbers(Primary, Secondary, and Subordinate + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_BUS_NUMBERS), + gShellDebug1HiiHandle, + INDEX_OF (&(Bridge->PrimaryBus)), + INDEX_OF (&(Bridge->SecondaryBus)), + INDEX_OF (&(Bridge->SubordinateBus)) + ); + + Print (L" ------------------------------------------------------\n"); + + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->PrimaryBus); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->SecondaryBus); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->SubordinateBus); + + // + // Print register Secondary Latency Timer + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SECONDARY_TIMER), + gShellDebug1HiiHandle, + INDEX_OF (&(Bridge->SecondaryLatencyTimer)), + Bridge->SecondaryLatencyTimer + ); + + // + // Print register Secondary Status + // + PciExplainStatus (&(Bridge->SecondaryStatus), FALSE, PciP2pBridge); + + // + // Print I/O and memory ranges this bridge forwards. There are 3 resource + // types: I/O, memory, and pre-fetchable memory. For each resource type, + // base and limit address are listed. + // + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE), gShellDebug1HiiHandle); + Print (L"----------------------------------------------------------------------\n"); + + // + // IO Base & Limit + // + IoAddress32 = (Bridge->IoBaseUpper << 16 | Bridge->IoBase << 8); + IoAddress32 &= 0xfffff000; + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_TWO_VARS), + gShellDebug1HiiHandle, + INDEX_OF (&(Bridge->IoBase)), + IoAddress32 + ); + + IoAddress32 = (Bridge->IoLimitUpper << 16 | Bridge->IoLimit << 8); + IoAddress32 |= 0x00000fff; + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR), gShellDebug1HiiHandle, IoAddress32); + + // + // Memory Base & Limit + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_MEMORY), + gShellDebug1HiiHandle, + INDEX_OF (&(Bridge->MemoryBase)), + (Bridge->MemoryBase << 16) & 0xfff00000 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_ONE_VAR), + gShellDebug1HiiHandle, + (Bridge->MemoryLimit << 16) | 0x000fffff + ); + + // + // Pre-fetch-able Memory Base & Limit + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_PREFETCHABLE), + gShellDebug1HiiHandle, + INDEX_OF (&(Bridge->PrefetchableMemBase)), + Bridge->PrefetchableBaseUpper, + (Bridge->PrefetchableMemBase << 16) & 0xfff00000 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_TWO_VARS_2), + gShellDebug1HiiHandle, + Bridge->PrefetchableLimitUpper, + (Bridge->PrefetchableMemLimit << 16) | 0x000fffff + ); + + // + // Print register Capabilities Pointer + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR_2), + gShellDebug1HiiHandle, + INDEX_OF (&(Bridge->CapabilitiesPtr)), + Bridge->CapabilitiesPtr + ); + + // + // Print register Bridge Control + // + PciExplainBridgeControl (&(Bridge->BridgeControl), PciP2pBridge); + + // + // Print register Interrupt Line & PIN + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_2), + gShellDebug1HiiHandle, + INDEX_OF (&(Bridge->InterruptLine)), + Bridge->InterruptLine + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_INTERRUPT_PIN), + gShellDebug1HiiHandle, + INDEX_OF (&(Bridge->InterruptPin)), + Bridge->InterruptPin + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +PciExplainBar ( + IN UINT32 *Bar, + IN UINT16 *Command, + IN UINT64 Address, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev, + IN OUT UINTN *Index + ) +/*++ + +Routine Description: + + Explain the Base Address Register(Bar) in PCI configuration space. + +Arguments: + + Bar Points to the Base Address Register intended to interpret + Command Points to the register Command + Address Address used to access configuration space of this PCI device + IoDev Handle used to access configuration space of PCI device + Index The Index + +Returns: + + EFI_SUCCESS The command completed successfully + +**/ +{ + UINT16 OldCommand; + UINT16 NewCommand; + UINT64 Bar64; + UINT32 OldBar32; + UINT32 NewBar32; + UINT64 OldBar64; + UINT64 NewBar64; + BOOLEAN IsMem; + BOOLEAN IsBar32; + UINT64 RegAddress; + + IsBar32 = TRUE; + Bar64 = 0; + NewBar32 = 0; + NewBar64 = 0; + + // + // According the bar type, list detail about this bar, for example: 32 or + // 64 bits; pre-fetchable or not. + // + if ((*Bar & PCI_BIT_0) == 0) { + // + // This bar is of memory type + // + IsMem = TRUE; + + if ((*Bar & PCI_BIT_1) == 0 && (*Bar & PCI_BIT_2) == 0) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BAR), gShellDebug1HiiHandle, *Bar & 0xfffffff0); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEM), gShellDebug1HiiHandle); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_32_BITS), gShellDebug1HiiHandle); + + } else if ((*Bar & PCI_BIT_1) == 0 && (*Bar & PCI_BIT_2) != 0) { + Bar64 = 0x0; + CopyMem (&Bar64, Bar, sizeof (UINT64)); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_2), gShellDebug1HiiHandle, RShiftU64 ((Bar64 & 0xfffffffffffffff0), 32)); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_3), gShellDebug1HiiHandle, (UINT32) (Bar64 & 0xfffffffffffffff0)); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEM), gShellDebug1HiiHandle); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_64_BITS), gShellDebug1HiiHandle); + IsBar32 = FALSE; + *Index += 1; + + } else { + // + // Reserved + // + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BAR), gShellDebug1HiiHandle, *Bar & 0xfffffff0); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEM_2), gShellDebug1HiiHandle); + } + + if ((*Bar & PCI_BIT_3) == 0) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NO), gShellDebug1HiiHandle); + + } else { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_YES), gShellDebug1HiiHandle); + } + + } else { + // + // This bar is of io type + // + IsMem = FALSE; + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_4), gShellDebug1HiiHandle, *Bar & 0xfffffffc); + Print (L"I/O "); + } + + // + // Get BAR length(or the amount of resource this bar demands for). To get + // Bar length, first we should temporarily disable I/O and memory access + // of this function(by set bits in the register Command), then write all + // "1"s to this bar. The bar value read back is the amount of resource + // this bar demands for. + // + // + // Disable io & mem access + // + OldCommand = *Command; + NewCommand = (UINT16) (OldCommand & 0xfffc); + RegAddress = Address | INDEX_OF (Command); + IoDev->Pci.Write (IoDev, EfiPciWidthUint16, RegAddress, 1, &NewCommand); + + RegAddress = Address | INDEX_OF (Bar); + + // + // Read after write the BAR to get the size + // + if (IsBar32) { + OldBar32 = *Bar; + NewBar32 = 0xffffffff; + + IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 1, &NewBar32); + IoDev->Pci.Read (IoDev, EfiPciWidthUint32, RegAddress, 1, &NewBar32); + IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 1, &OldBar32); + + if (IsMem) { + NewBar32 = NewBar32 & 0xfffffff0; + NewBar32 = (~NewBar32) + 1; + + } else { + NewBar32 = NewBar32 & 0xfffffffc; + NewBar32 = (~NewBar32) + 1; + NewBar32 = NewBar32 & 0x0000ffff; + } + } else { + + OldBar64 = 0x0; + CopyMem (&OldBar64, Bar, sizeof (UINT64)); + NewBar64 = 0xffffffffffffffff; + + IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 2, &NewBar64); + IoDev->Pci.Read (IoDev, EfiPciWidthUint32, RegAddress, 2, &NewBar64); + IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 2, &OldBar64); + + if (IsMem) { + NewBar64 = NewBar64 & 0xfffffffffffffff0; + NewBar64 = (~NewBar64) + 1; + + } else { + NewBar64 = NewBar64 & 0xfffffffffffffffc; + NewBar64 = (~NewBar64) + 1; + NewBar64 = NewBar64 & 0x000000000000ffff; + } + } + // + // Enable io & mem access + // + RegAddress = Address | INDEX_OF (Command); + IoDev->Pci.Write (IoDev, EfiPciWidthUint16, RegAddress, 1, &OldCommand); + + if (IsMem) { + if (IsBar32) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32), gShellDebug1HiiHandle, NewBar32); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32_2), gShellDebug1HiiHandle, NewBar32 + (*Bar & 0xfffffff0) - 1); + + } else { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, RShiftU64 (NewBar64, 32)); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) NewBar64); + Print (L" "); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_RSHIFT), + gShellDebug1HiiHandle, + RShiftU64 ((NewBar64 + (Bar64 & 0xfffffffffffffff0) - 1), 32) + ); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) (NewBar64 + (Bar64 & 0xfffffffffffffff0) - 1)); + + } + } else { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32_3), gShellDebug1HiiHandle, NewBar32); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32_4), gShellDebug1HiiHandle, NewBar32 + (*Bar & 0xfffffffc) - 1); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +PciExplainCardBusData ( + IN PCI_CARDBUS_HEADER *CardBus, + IN UINT64 Address, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev + ) +/*++ + +Routine Description: + + Explain the cardbus specific part of data in PCI configuration space. + +Arguments: + + CardBus CardBus specific region of PCI configuration space + Address Address used to access configuration space of this PCI device + IoDev Handle used to access configuration space of PCI device + +Returns: + + EFI_SUCCESS The command completed successfully + +**/ +{ + BOOLEAN Io32Bit; + PCI_CARDBUS_DATA *CardBusData; + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_CARDBUS_SOCKET), + gShellDebug1HiiHandle, + INDEX_OF (&(CardBus->CardBusSocketReg)), + CardBus->CardBusSocketReg + ); + + // + // Print Secondary Status + // + PciExplainStatus (&(CardBus->SecondaryStatus), FALSE, PciCardBusBridge); + + // + // Print Bus Numbers(Primary bus number, CardBus bus number, and + // Subordinate bus number + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_BUS_NUMBERS_2), + gShellDebug1HiiHandle, + INDEX_OF (&(CardBus->PciBusNumber)), + INDEX_OF (&(CardBus->CardBusBusNumber)), + INDEX_OF (&(CardBus->SubordinateBusNumber)) + ); + + Print (L" ------------------------------------------------------\n"); + + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS), gShellDebug1HiiHandle, CardBus->PciBusNumber); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_2), gShellDebug1HiiHandle, CardBus->CardBusBusNumber); + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_3), gShellDebug1HiiHandle, CardBus->SubordinateBusNumber); + + // + // Print CardBus Latency Timer + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_CARDBUS_LATENCY), + gShellDebug1HiiHandle, + INDEX_OF (&(CardBus->CardBusLatencyTimer)), + CardBus->CardBusLatencyTimer + ); + + // + // Print Memory/Io ranges this cardbus bridge forwards + // + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE_2), gShellDebug1HiiHandle); + Print (L"----------------------------------------------------------------------\n"); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_MEM_3), + gShellDebug1HiiHandle, + INDEX_OF (&(CardBus->MemoryBase0)), + CardBus->BridgeControl & PCI_BIT_8 ? L" Prefetchable" : L"Non-Prefetchable", + CardBus->MemoryBase0 & 0xfffff000, + CardBus->MemoryLimit0 | 0x00000fff + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_MEM_3), + gShellDebug1HiiHandle, + INDEX_OF (&(CardBus->MemoryBase1)), + CardBus->BridgeControl & PCI_BIT_9 ? L" Prefetchable" : L"Non-Prefetchable", + CardBus->MemoryBase1 & 0xfffff000, + CardBus->MemoryLimit1 | 0x00000fff + ); + + Io32Bit = (BOOLEAN) (CardBus->IoBase0 & PCI_BIT_0); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_IO_2), + gShellDebug1HiiHandle, + INDEX_OF (&(CardBus->IoBase0)), + Io32Bit ? L" 32 bit" : L" 16 bit", + CardBus->IoBase0 & (Io32Bit ? 0xfffffffc : 0x0000fffc), + CardBus->IoLimit0 & (Io32Bit ? 0xffffffff : 0x0000ffff) | 0x00000003 + ); + + Io32Bit = (BOOLEAN) (CardBus->IoBase1 & PCI_BIT_0); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_IO_2), + gShellDebug1HiiHandle, + INDEX_OF (&(CardBus->IoBase1)), + Io32Bit ? L" 32 bit" : L" 16 bit", + CardBus->IoBase1 & (Io32Bit ? 0xfffffffc : 0x0000fffc), + CardBus->IoLimit1 & (Io32Bit ? 0xffffffff : 0x0000ffff) | 0x00000003 + ); + + // + // Print register Interrupt Line & PIN + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_3), + gShellDebug1HiiHandle, + INDEX_OF (&(CardBus->InterruptLine)), + CardBus->InterruptLine, + INDEX_OF (&(CardBus->InterruptPin)), + CardBus->InterruptPin + ); + + // + // Print register Bridge Control + // + PciExplainBridgeControl (&(CardBus->BridgeControl), PciCardBusBridge); + + // + // Print some registers in data region of PCI configuration space for cardbus + // bridge. Fields include: Sub VendorId, Subsystem ID, and Legacy Mode Base + // Address. + // + CardBusData = (PCI_CARDBUS_DATA *) ((UINT8 *) CardBus + sizeof (PCI_CARDBUS_HEADER)); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID_2), + gShellDebug1HiiHandle, + INDEX_OF (&(CardBusData->SubVendorId)), + CardBusData->SubVendorId, + INDEX_OF (&(CardBusData->SubSystemId)), + CardBusData->SubSystemId + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_OPTIONAL), + gShellDebug1HiiHandle, + INDEX_OF (&(CardBusData->LegacyBase)), + CardBusData->LegacyBase + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +PciExplainStatus ( + IN UINT16 *Status, + IN BOOLEAN MainStatus, + IN PCI_HEADER_TYPE HeaderType + ) +/*++ + +Routine Description: + + Explain each meaningful bit of register Status. The definition of Status is + slightly different depending on the PCI header type. + +Arguments: + + Status Points to the content of register Status + MainStatus Indicates if this register is main status(not secondary + status) + HeaderType Header type of this PCI device + +Returns: + + EFI_SUCCESS The command completed successfully + +**/ +{ + if (MainStatus) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_STATUS), gShellDebug1HiiHandle, INDEX_OF (Status), *Status); + + } else { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_SECONDARY_STATUS), gShellDebug1HiiHandle, INDEX_OF (Status), *Status); + } + + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEW_CAPABILITIES), gShellDebug1HiiHandle, (*Status & PCI_BIT_4) != 0); + + // + // Bit 5 is meaningless for CardBus Bridge + // + if (HeaderType == PciCardBusBridge) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_66_CAPABLE), gShellDebug1HiiHandle, (*Status & PCI_BIT_5) != 0); + + } else { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_66_CAPABLE_2), gShellDebug1HiiHandle, (*Status & PCI_BIT_5) != 0); + } + + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_FAST_BACK), gShellDebug1HiiHandle, (*Status & PCI_BIT_7) != 0); + + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MASTER_DATA), gShellDebug1HiiHandle, (*Status & PCI_BIT_8) != 0); + // + // Bit 9 and bit 10 together decides the DEVSEL timing + // + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_DEVSEL_TIMING), gShellDebug1HiiHandle); + if ((*Status & PCI_BIT_9) == 0 && (*Status & PCI_BIT_10) == 0) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_FAST), gShellDebug1HiiHandle); + + } else if ((*Status & PCI_BIT_9) != 0 && (*Status & PCI_BIT_10) == 0) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEDIUM), gShellDebug1HiiHandle); + + } else if ((*Status & PCI_BIT_9) == 0 && (*Status & PCI_BIT_10) != 0) { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_SLOW), gShellDebug1HiiHandle); + + } else { + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESERVED_2), gShellDebug1HiiHandle); + } + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SIGNALED_TARGET), + gShellDebug1HiiHandle, + (*Status & PCI_BIT_11) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_RECEIVED_TARGET), + gShellDebug1HiiHandle, + (*Status & PCI_BIT_12) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_RECEIVED_MASTER), + gShellDebug1HiiHandle, + (*Status & PCI_BIT_13) != 0 + ); + + if (MainStatus) { + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SIGNALED_ERROR), + gShellDebug1HiiHandle, + (*Status & PCI_BIT_14) != 0 + ); + + } else { + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_RECEIVED_ERROR), + gShellDebug1HiiHandle, + (*Status & PCI_BIT_14) != 0 + ); + } + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_DETECTED_ERROR), + gShellDebug1HiiHandle, + (*Status & PCI_BIT_15) != 0 + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +PciExplainCommand ( + IN UINT16 *Command + ) +/*++ + +Routine Description: + + Explain each meaningful bit of register Command. + +Arguments: + + Command Points to the content of register Command + +Returns: + + EFI_SUCCESS The command completed successfully + +**/ +{ + // + // Print the binary value of register Command + // + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_COMMAND), gShellDebug1HiiHandle, INDEX_OF (Command), *Command); + + // + // Explain register Command bit by bit + // + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SPACE_ACCESS_DENIED), + gShellDebug1HiiHandle, + (*Command & PCI_BIT_0) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_MEMORY_SPACE), + gShellDebug1HiiHandle, + (*Command & PCI_BIT_1) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_BEHAVE_BUS_MASTER), + gShellDebug1HiiHandle, + (*Command & PCI_BIT_2) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_MONITOR_SPECIAL_CYCLE), + gShellDebug1HiiHandle, + (*Command & PCI_BIT_3) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_MEM_WRITE_INVALIDATE), + gShellDebug1HiiHandle, + (*Command & PCI_BIT_4) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_PALETTE_SNOOPING), + gShellDebug1HiiHandle, + (*Command & PCI_BIT_5) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_ASSERT_PERR), + gShellDebug1HiiHandle, + (*Command & PCI_BIT_6) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_DO_ADDR_STEPPING), + gShellDebug1HiiHandle, + (*Command & PCI_BIT_7) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SERR_DRIVER), + gShellDebug1HiiHandle, + (*Command & PCI_BIT_8) != 0 + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_FAST_BACK_2), + gShellDebug1HiiHandle, + (*Command & PCI_BIT_9) != 0 + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +PciExplainBridgeControl ( + IN UINT16 *BridgeControl, + IN PCI_HEADER_TYPE HeaderType + ) +/*++ + +Routine Description: + + Explain each meaningful bit of register Bridge Control. + +Arguments: + + BridgeControl Points to the content of register Bridge Control + HeaderType The headertype + +Returns: + + EFI_SUCCESS The command completed successfully + +**/ +{ + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_BRIDGE_CONTROL), + gShellDebug1HiiHandle, + INDEX_OF (BridgeControl), + *BridgeControl + ); + + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_PARITY_ERROR), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_0) != 0 + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SERR_ENABLE), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_1) != 0 + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_ISA_ENABLE), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_2) != 0 + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_VGA_ENABLE), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_3) != 0 + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_MASTER_ABORT), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_5) != 0 + ); + + // + // Register Bridge Control has some slight differences between P2P bridge + // and Cardbus bridge from bit 6 to bit 11. + // + if (HeaderType == PciP2pBridge) { + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SECONDARY_BUS_RESET), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_6) != 0 + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_FAST_ENABLE), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_7) != 0 + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_PRIMARY_DISCARD_TIMER), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_8)!=0 ? L"2^10" : L"2^15" + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_SECONDARY_DISCARD_TIMER), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_9)!=0 ? L"2^10" : L"2^15" + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_DISCARD_TIMER_STATUS), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_10) != 0 + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_DISCARD_TIMER_SERR), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_11) != 0 + ); + + } else { + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_CARDBUS_RESET), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_6) != 0 + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_IREQ_ENABLE), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_7) != 0 + ); + ShellPrintHiiEx(-1, -1, NULL, + STRING_TOKEN (STR_PCI2_WRITE_POSTING_ENABLE), + gShellDebug1HiiHandle, + (*BridgeControl & PCI_BIT_10) != 0 + ); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +PciExplainCapabilityStruct ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev, + IN UINT64 Address, + IN UINT8 CapPtr + ) +{ + UINT8 CapabilityPtr; + UINT16 CapabilityEntry; + UINT8 CapabilityID; + UINT64 RegAddress; + + CapabilityPtr = CapPtr; + + // + // Go through the Capability list + // + while ((CapabilityPtr >= 0x40) && ((CapabilityPtr & 0x03) == 0x00)) { + RegAddress = Address + CapabilityPtr; + IoDev->Pci.Read (IoDev, EfiPciWidthUint16, RegAddress, 1, &CapabilityEntry); + + CapabilityID = (UINT8) CapabilityEntry; + + // + // Explain PciExpress data + // + if (EFI_PCI_CAPABILITY_ID_PCIEXP == CapabilityID) { + PciExplainPciExpress (IoDev, Address, CapabilityPtr); + return EFI_SUCCESS; + } + // + // Explain other capabilities here + // + CapabilityPtr = (UINT8) (CapabilityEntry >> 8); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieCapReg ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT16 PcieCapReg; + CHAR16 *DevicePortType; + + PcieCapReg = PciExpressCap->PcieCapReg; + Print ( + L" Capability Version(3:0): %E0x%04x%N\n", + PCIE_CAP_VERSION (PcieCapReg) + ); + if ((UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) < PCIE_DEVICE_PORT_TYPE_MAX) { + DevicePortType = DevicePortTypeTable[PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg)]; + } else { + DevicePortType = L"Unknown Type"; + } + Print ( + L" Device/PortType(7:4): %E%s%N\n", + DevicePortType + ); + // + // 'Slot Implemented' is only valid for: + // a) Root Port of PCI Express Root Complex, or + // b) Downstream Port of PCI Express Switch + // + if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_ROOT_COMPLEX_ROOT_PORT || + PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_SWITCH_DOWNSTREAM_PORT) { + Print ( + L" Slot Implemented(8): %E%d%N\n", + PCIE_CAP_SLOT_IMPLEMENTED (PcieCapReg) + ); + } + Print ( + L" Interrupt Message Number(13:9): %E0x%05x%N\n", + PCIE_CAP_INT_MSG_NUM (PcieCapReg) + ); + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieDeviceCap ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT16 PcieCapReg; + UINT32 PcieDeviceCap; + UINT8 DevicePortType; + UINT8 L0sLatency; + UINT8 L1Latency; + + PcieCapReg = PciExpressCap->PcieCapReg; + PcieDeviceCap = PciExpressCap->PcieDeviceCap; + DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg); + Print (L" Max_Payload_Size Supported(2:0): "); + if (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) < 6) { + Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) + 7)); + } else { + Print (L"%EUnknown%N\n"); + } + Print ( + L" Phantom Functions Supported(4:3): %E%d%N\n", + PCIE_CAP_PHANTOM_FUNC (PcieDeviceCap) + ); + Print ( + L" Extended Tag Field Supported(5): %E%d-bit Tag field supported%N\n", + PCIE_CAP_EXTENDED_TAG (PcieDeviceCap) ? 8 : 5 + ); + // + // Endpoint L0s and L1 Acceptable Latency is only valid for Endpoint + // + if (IS_PCIE_ENDPOINT (DevicePortType)) { + L0sLatency = (UINT8) PCIE_CAP_L0sLatency (PcieDeviceCap); + L1Latency = (UINT8) PCIE_CAP_L1Latency (PcieDeviceCap); + Print (L" Endpoint L0s Acceptable Latency(8:6): "); + if (L0sLatency < 4) { + Print (L"%EMaximum of %d ns%N\n", 1 << (L0sLatency + 6)); + } else { + if (L0sLatency < 7) { + Print (L"%EMaximum of %d us%N\n", 1 << (L0sLatency - 3)); + } else { + Print (L"%ENo limit%N\n"); + } + } + Print (L" Endpoint L1 Acceptable Latency(11:9): "); + if (L1Latency < 7) { + Print (L"%EMaximum of %d us%N\n", 1 << (L1Latency + 1)); + } else { + Print (L"%ENo limit%N\n"); + } + } + Print ( + L" Role-based Error Reporting(15): %E%d%N\n", + PCIE_CAP_ERR_REPORTING (PcieDeviceCap) + ); + // + // Only valid for Upstream Port: + // a) Captured Slot Power Limit Value + // b) Captured Slot Power Scale + // + if (DevicePortType == PCIE_SWITCH_UPSTREAM_PORT) { + Print ( + L" Captured Slot Power Limit Value(25:18): %E0x%02x%N\n", + PCIE_CAP_SLOT_POWER_VALUE (PcieDeviceCap) + ); + Print ( + L" Captured Slot Power Limit Scale(27:26): %E%s%N\n", + SlotPwrLmtScaleTable[PCIE_CAP_SLOT_POWER_SCALE (PcieDeviceCap)] + ); + } + // + // Function Level Reset Capability is only valid for Endpoint + // + if (IS_PCIE_ENDPOINT (DevicePortType)) { + Print ( + L" Function Level Reset Capability(28): %E%d%N\n", + PCIE_CAP_FUNC_LEVEL_RESET (PcieDeviceCap) + ); + } + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieDeviceControl ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT16 PcieCapReg; + UINT16 PcieDeviceControl; + + PcieCapReg = PciExpressCap->PcieCapReg; + PcieDeviceControl = PciExpressCap->DeviceControl; + Print ( + L" Correctable Error Reporting Enable(0): %E%d%N\n", + PCIE_CAP_COR_ERR_REPORTING_ENABLE (PcieDeviceControl) + ); + Print ( + L" Non-Fatal Error Reporting Enable(1): %E%d%N\n", + PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE (PcieDeviceControl) + ); + Print ( + L" Fatal Error Reporting Enable(2): %E%d%N\n", + PCIE_CAP_FATAL_ERR_REPORTING_ENABLE (PcieDeviceControl) + ); + Print ( + L" Unsupported Request Reporting Enable(3): %E%d%N\n", + PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE (PcieDeviceControl) + ); + Print ( + L" Enable Relaxed Ordering(4): %E%d%N\n", + PCIE_CAP_RELAXED_ORDERING_ENABLE (PcieDeviceControl) + ); + Print (L" Max_Payload_Size(7:5): "); + if (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) < 6) { + Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) + 7)); + } else { + Print (L"%EUnknown%N\n"); + } + Print ( + L" Extended Tag Field Enable(8): %E%d%N\n", + PCIE_CAP_EXTENDED_TAG_ENABLE (PcieDeviceControl) + ); + Print ( + L" Phantom Functions Enable(9): %E%d%N\n", + PCIE_CAP_PHANTOM_FUNC_ENABLE (PcieDeviceControl) + ); + Print ( + L" Auxiliary (AUX) Power PM Enable(10): %E%d%N\n", + PCIE_CAP_AUX_PM_ENABLE (PcieDeviceControl) + ); + Print ( + L" Enable No Snoop(11): %E%d%N\n", + PCIE_CAP_NO_SNOOP_ENABLE (PcieDeviceControl) + ); + Print (L" Max_Read_Request_Size(14:12): "); + if (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) < 6) { + Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) + 7)); + } else { + Print (L"%EUnknown%N\n"); + } + // + // Read operation is only valid for PCI Express to PCI/PCI-X Bridges + // + if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_PCIE_TO_PCIX_BRIDGE) { + Print ( + L" Bridge Configuration Retry Enable(15): %E%d%N\n", + PCIE_CAP_BRG_CONF_RETRY (PcieDeviceControl) + ); + } + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieDeviceStatus ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT16 PcieDeviceStatus; + + PcieDeviceStatus = PciExpressCap->DeviceStatus; + Print ( + L" Correctable Error Detected(0): %E%d%N\n", + PCIE_CAP_COR_ERR_DETECTED (PcieDeviceStatus) + ); + Print ( + L" Non-Fatal Error Detected(1): %E%d%N\n", + PCIE_CAP_NONFAT_ERR_DETECTED (PcieDeviceStatus) + ); + Print ( + L" Fatal Error Detected(2): %E%d%N\n", + PCIE_CAP_FATAL_ERR_DETECTED (PcieDeviceStatus) + ); + Print ( + L" Unsupported Request Detected(3): %E%d%N\n", + PCIE_CAP_UNSUP_REQ_DETECTED (PcieDeviceStatus) + ); + Print ( + L" AUX Power Detected(4): %E%d%N\n", + PCIE_CAP_AUX_POWER_DETECTED (PcieDeviceStatus) + ); + Print ( + L" Transactions Pending(5): %E%d%N\n", + PCIE_CAP_TRANSACTION_PENDING (PcieDeviceStatus) + ); + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieLinkCap ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT32 PcieLinkCap; + CHAR16 *SupLinkSpeeds; + CHAR16 *ASPM; + + PcieLinkCap = PciExpressCap->LinkCap; + switch (PCIE_CAP_SUP_LINK_SPEEDS (PcieLinkCap)) { + case 1: + SupLinkSpeeds = L"2.5 GT/s"; + break; + case 2: + SupLinkSpeeds = L"5.0 GT/s and 2.5 GT/s"; + break; + default: + SupLinkSpeeds = L"Unknown"; + break; + } + Print ( + L" Supported Link Speeds(3:0): %E%s supported%N\n", + SupLinkSpeeds + ); + Print ( + L" Maximum Link Width(9:4): %Ex%d%N\n", + PCIE_CAP_MAX_LINK_WIDTH (PcieLinkCap) + ); + switch (PCIE_CAP_ASPM_SUPPORT (PcieLinkCap)) { + case 1: + ASPM = L"L0s Entry"; + break; + case 3: + ASPM = L"L0s and L1"; + break; + default: + ASPM = L"Reserved"; + break; + } + Print ( + L" Active State Power Management Support(11:10): %E%s Supported%N\n", + ASPM + ); + Print ( + L" L0s Exit Latency(14:12): %E%s%N\n", + L0sLatencyStrTable[PCIE_CAP_L0s_LATENCY (PcieLinkCap)] + ); + Print ( + L" L1 Exit Latency(17:15): %E%s%N\n", + L1LatencyStrTable[PCIE_CAP_L0s_LATENCY (PcieLinkCap)] + ); + Print ( + L" Clock Power Management(18): %E%d%N\n", + PCIE_CAP_CLOCK_PM (PcieLinkCap) + ); + Print ( + L" Surprise Down Error Reporting Capable(19): %E%d%N\n", + PCIE_CAP_SUP_DOWN_ERR_REPORTING (PcieLinkCap) + ); + Print ( + L" Data Link Layer Link Active Reporting Capable(20): %E%d%N\n", + PCIE_CAP_LINK_ACTIVE_REPORTING (PcieLinkCap) + ); + Print ( + L" Link Bandwidth Notification Capability(21): %E%d%N\n", + PCIE_CAP_LINK_BWD_NOTIF_CAP (PcieLinkCap) + ); + Print ( + L" Port Number(31:24): %E0x%02x%N\n", + PCIE_CAP_PORT_NUMBER (PcieLinkCap) + ); + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieLinkControl ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT16 PcieLinkControl; + UINT8 DevicePortType; + + PcieLinkControl = PciExpressCap->LinkControl; + DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap->PcieCapReg); + Print ( + L" Active State Power Management Control(1:0): %E%s%N\n", + ASPMCtrlStrTable[PCIE_CAP_ASPM_CONTROL (PcieLinkControl)] + ); + // + // RCB is not applicable to switches + // + if (!IS_PCIE_SWITCH(DevicePortType)) { + Print ( + L" Read Completion Boundary (RCB)(3): %E%d byte%N\n", + 1 << (PCIE_CAP_RCB (PcieLinkControl) + 6) + ); + } + // + // Link Disable is reserved on + // a) Endpoints + // b) PCI Express to PCI/PCI-X bridges + // c) Upstream Ports of Switches + // + if (!IS_PCIE_ENDPOINT (DevicePortType) && + DevicePortType != PCIE_SWITCH_UPSTREAM_PORT && + DevicePortType != PCIE_PCIE_TO_PCIX_BRIDGE) { + Print ( + L" Link Disable(4): %E%d%N\n", + PCIE_CAP_LINK_DISABLE (PcieLinkControl) + ); + } + Print ( + L" Common Clock Configuration(6): %E%d%N\n", + PCIE_CAP_COMMON_CLK_CONF (PcieLinkControl) + ); + Print ( + L" Extended Synch(7): %E%d%N\n", + PCIE_CAP_EXT_SYNC (PcieLinkControl) + ); + Print ( + L" Enable Clock Power Management(8): %E%d%N\n", + PCIE_CAP_CLK_PWR_MNG (PcieLinkControl) + ); + Print ( + L" Hardware Autonomous Width Disable(9): %E%d%N\n", + PCIE_CAP_HW_AUTO_WIDTH_DISABLE (PcieLinkControl) + ); + Print ( + L" Link Bandwidth Management Interrupt Enable(10): %E%d%N\n", + PCIE_CAP_LINK_BDW_MNG_INT_EN (PcieLinkControl) + ); + Print ( + L" Link Autonomous Bandwidth Interrupt Enable(11): %E%d%N\n", + PCIE_CAP_LINK_AUTO_BDW_INT_EN (PcieLinkControl) + ); + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieLinkStatus ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT16 PcieLinkStatus; + CHAR16 *SupLinkSpeeds; + + PcieLinkStatus = PciExpressCap->LinkStatus; + switch (PCIE_CAP_CUR_LINK_SPEED (PcieLinkStatus)) { + case 1: + SupLinkSpeeds = L"2.5 GT/s"; + break; + case 2: + SupLinkSpeeds = L"5.0 GT/s"; + break; + default: + SupLinkSpeeds = L"Reserved"; + break; + } + Print ( + L" Current Link Speed(3:0): %E%s%N\n", + SupLinkSpeeds + ); + Print ( + L" Negotiated Link Width(9:4): %Ex%d%N\n", + PCIE_CAP_NEGO_LINK_WIDTH (PcieLinkStatus) + ); + Print ( + L" Link Training(11): %E%d%N\n", + PCIE_CAP_LINK_TRAINING (PcieLinkStatus) + ); + Print ( + L" Slot Clock Configuration(12): %E%d%N\n", + PCIE_CAP_SLOT_CLK_CONF (PcieLinkStatus) + ); + Print ( + L" Data Link Layer Link Active(13): %E%d%N\n", + PCIE_CAP_DATA_LINK_ACTIVE (PcieLinkStatus) + ); + Print ( + L" Link Bandwidth Management Status(14): %E%d%N\n", + PCIE_CAP_LINK_BDW_MNG_STAT (PcieLinkStatus) + ); + Print ( + L" Link Autonomous Bandwidth Status(15): %E%d%N\n", + PCIE_CAP_LINK_AUTO_BDW_STAT (PcieLinkStatus) + ); + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieSlotCap ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT32 PcieSlotCap; + + PcieSlotCap = PciExpressCap->SlotCap; + + Print ( + L" Attention Button Present(0): %E%d%N\n", + PCIE_CAP_ATT_BUT_PRESENT (PcieSlotCap) + ); + Print ( + L" Power Controller Present(1): %E%d%N\n", + PCIE_CAP_PWR_CTRLLER_PRESENT (PcieSlotCap) + ); + Print ( + L" MRL Sensor Present(2): %E%d%N\n", + PCIE_CAP_MRL_SENSOR_PRESENT (PcieSlotCap) + ); + Print ( + L" Attention Indicator Present(3): %E%d%N\n", + PCIE_CAP_ATT_IND_PRESENT (PcieSlotCap) + ); + Print ( + L" Power Indicator Present(4): %E%d%N\n", + PCIE_CAP_PWD_IND_PRESENT (PcieSlotCap) + ); + Print ( + L" Hot-Plug Surprise(5): %E%d%N\n", + PCIE_CAP_HOTPLUG_SUPPRISE (PcieSlotCap) + ); + Print ( + L" Hot-Plug Capable(6): %E%d%N\n", + PCIE_CAP_HOTPLUG_CAPABLE (PcieSlotCap) + ); + Print ( + L" Slot Power Limit Value(14:7): %E0x%02x%N\n", + PCIE_CAP_SLOT_PWR_LIMIT_VALUE (PcieSlotCap) + ); + Print ( + L" Slot Power Limit Scale(16:15): %E%s%N\n", + SlotPwrLmtScaleTable[PCIE_CAP_SLOT_PWR_LIMIT_SCALE (PcieSlotCap)] + ); + Print ( + L" Electromechanical Interlock Present(17): %E%d%N\n", + PCIE_CAP_ELEC_INTERLOCK_PRESENT (PcieSlotCap) + ); + Print ( + L" No Command Completed Support(18): %E%d%N\n", + PCIE_CAP_NO_COMM_COMPLETED_SUP (PcieSlotCap) + ); + Print ( + L" Physical Slot Number(31:19): %E%d%N\n", + PCIE_CAP_PHY_SLOT_NUM (PcieSlotCap) + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieSlotControl ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT16 PcieSlotControl; + + PcieSlotControl = PciExpressCap->SlotControl; + Print ( + L" Attention Button Pressed Enable(0): %E%d%N\n", + PCIE_CAP_ATT_BUT_ENABLE (PcieSlotControl) + ); + Print ( + L" Power Fault Detected Enable(1): %E%d%N\n", + PCIE_CAP_PWR_FLT_DETECT_ENABLE (PcieSlotControl) + ); + Print ( + L" MRL Sensor Changed Enable(2): %E%d%N\n", + PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE (PcieSlotControl) + ); + Print ( + L" Presence Detect Changed Enable(3): %E%d%N\n", + PCIE_CAP_PRES_DETECT_CHANGE_ENABLE (PcieSlotControl) + ); + Print ( + L" Command Completed Interrupt Enable(4): %E%d%N\n", + PCIE_CAP_COMM_CMPL_INT_ENABLE (PcieSlotControl) + ); + Print ( + L" Hot-Plug Interrupt Enable(5): %E%d%N\n", + PCIE_CAP_HOTPLUG_INT_ENABLE (PcieSlotControl) + ); + Print ( + L" Attention Indicator Control(7:6): %E%s%N\n", + IndicatorTable[PCIE_CAP_ATT_IND_CTRL (PcieSlotControl)] + ); + Print ( + L" Power Indicator Control(9:8): %E%s%N\n", + IndicatorTable[PCIE_CAP_PWR_IND_CTRL (PcieSlotControl)] + ); + Print (L" Power Controller Control(10): %EPower "); + if (PCIE_CAP_PWR_CTRLLER_CTRL (PcieSlotControl)) { + Print (L"Off%N\n"); + } else { + Print (L"On%N\n"); + } + Print ( + L" Electromechanical Interlock Control(11): %E%d%N\n", + PCIE_CAP_ELEC_INTERLOCK_CTRL (PcieSlotControl) + ); + Print ( + L" Data Link Layer State Changed Enable(12): %E%d%N\n", + PCIE_CAP_DLINK_STAT_CHANGE_ENABLE (PcieSlotControl) + ); + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieSlotStatus ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT16 PcieSlotStatus; + + PcieSlotStatus = PciExpressCap->SlotStatus; + + Print ( + L" Attention Button Pressed(0): %E%d%N\n", + PCIE_CAP_ATT_BUT_PRESSED (PcieSlotStatus) + ); + Print ( + L" Power Fault Detected(1): %E%d%N\n", + PCIE_CAP_PWR_FLT_DETECTED (PcieSlotStatus) + ); + Print ( + L" MRL Sensor Changed(2): %E%d%N\n", + PCIE_CAP_MRL_SENSOR_CHANGED (PcieSlotStatus) + ); + Print ( + L" Presence Detect Changed(3): %E%d%N\n", + PCIE_CAP_PRES_DETECT_CHANGED (PcieSlotStatus) + ); + Print ( + L" Command Completed(4): %E%d%N\n", + PCIE_CAP_COMM_COMPLETED (PcieSlotStatus) + ); + Print (L" MRL Sensor State(5): %EMRL "); + if (PCIE_CAP_MRL_SENSOR_STATE (PcieSlotStatus)) { + Print (L" Opened%N\n"); + } else { + Print (L" Closed%N\n"); + } + Print (L" Presence Detect State(6): "); + if (PCIE_CAP_PRES_DETECT_STATE (PcieSlotStatus)) { + Print (L"%ECard Present in slot%N\n"); + } else { + Print (L"%ESlot Empty%N\n"); + } + Print (L" Electromechanical Interlock Status(7): %EElectromechanical Interlock "); + if (PCIE_CAP_ELEC_INTERLOCK_STATE (PcieSlotStatus)) { + Print (L"Engaged%N\n"); + } else { + Print (L"Disengaged%N\n"); + } + Print ( + L" Data Link Layer State Changed(8): %E%d%N\n", + PCIE_CAP_DLINK_STAT_CHANGED (PcieSlotStatus) + ); + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieRootControl ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT16 PcieRootControl; + + PcieRootControl = PciExpressCap->RootControl; + + Print ( + L" System Error on Correctable Error Enable(0): %E%d%N\n", + PCIE_CAP_SYSERR_ON_CORERR_EN (PcieRootControl) + ); + Print ( + L" System Error on Non-Fatal Error Enable(1): %E%d%N\n", + PCIE_CAP_SYSERR_ON_NONFATERR_EN (PcieRootControl) + ); + Print ( + L" System Error on Fatal Error Enable(2): %E%d%N\n", + PCIE_CAP_SYSERR_ON_FATERR_EN (PcieRootControl) + ); + Print ( + L" PME Interrupt Enable(3): %E%d%N\n", + PCIE_CAP_PME_INT_ENABLE (PcieRootControl) + ); + Print ( + L" CRS Software Visibility Enable(4): %E%d%N\n", + PCIE_CAP_CRS_SW_VIS_ENABLE (PcieRootControl) + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieRootCap ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT16 PcieRootCap; + + PcieRootCap = PciExpressCap->RsvdP; + + Print ( + L" CRS Software Visibility(0): %E%d%N\n", + PCIE_CAP_CRS_SW_VIS (PcieRootCap) + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +ExplainPcieRootStatus ( + IN PCIE_CAP_STURCTURE *PciExpressCap +) +{ + UINT32 PcieRootStatus; + + PcieRootStatus = PciExpressCap->RootStatus; + + Print ( + L" PME Requester ID(15:0): %E0x%04x%N\n", + PCIE_CAP_PME_REQ_ID (PcieRootStatus) + ); + Print ( + L" PME Status(16): %E%d%N\n", + PCIE_CAP_PME_STATUS (PcieRootStatus) + ); + Print ( + L" PME Pending(17): %E%d%N\n", + PCIE_CAP_PME_PENDING (PcieRootStatus) + ); + return EFI_SUCCESS; +} + +EFI_STATUS +PciExplainPciExpress ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev, + IN UINT64 Address, + IN UINT8 CapabilityPtr + ) +{ + + PCIE_CAP_STURCTURE PciExpressCap; + EFI_STATUS Status; + UINT64 CapRegAddress; + UINT8 Bus; + UINT8 Dev; + UINT8 Func; + UINT8 *ExRegBuffer; + UINTN ExtendRegSize; + UINT64 Pciex_Address; + UINT8 DevicePortType; + UINTN Index; + UINT8 *RegAddr; + UINTN RegValue; + + CapRegAddress = Address + CapabilityPtr; + IoDev->Pci.Read ( + IoDev, + EfiPciWidthUint32, + CapRegAddress, + sizeof (PciExpressCap) / sizeof (UINT32), + &PciExpressCap + ); + + DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap.PcieCapReg); + + Print (L"\nPci Express device capability structure:\n"); + + for (Index = 0; PcieExplainList[Index].Type < PcieExplainTypeMax; Index++) { + if (ShellGetExecutionBreakFlag()) { + goto Done; + } + RegAddr = ((UINT8 *) &PciExpressCap) + PcieExplainList[Index].Offset; + switch (PcieExplainList[Index].Width) { + case FieldWidthUINT8: + RegValue = *(UINT8 *) RegAddr; + break; + case FieldWidthUINT16: + RegValue = *(UINT16 *) RegAddr; + break; + case FieldWidthUINT32: + RegValue = *(UINT32 *) RegAddr; + break; + default: + RegValue = 0; + break; + } + ShellPrintHiiEx(-1, -1, NULL, + PcieExplainList[Index].Token, + gShellDebug1HiiHandle, + PcieExplainList[Index].Offset, + RegValue + ); + if (PcieExplainList[Index].Func == NULL) { + continue; + } + switch (PcieExplainList[Index].Type) { + case PcieExplainTypeLink: + // + // Link registers should not be used by + // a) Root Complex Integrated Endpoint + // b) Root Complex Event Collector + // + if (DevicePortType == PCIE_ROOT_COMPLEX_INTEGRATED_PORT || + DevicePortType == PCIE_ROOT_COMPLEX_EVENT_COLLECTOR) { + continue; + } + break; + case PcieExplainTypeSlot: + // + // Slot registers are only valid for + // a) Root Port of PCI Express Root Complex + // b) Downstream Port of PCI Express Switch + // and when SlotImplemented bit is set in PCIE cap register. + // + if ((DevicePortType != PCIE_ROOT_COMPLEX_ROOT_PORT && + DevicePortType != PCIE_SWITCH_DOWNSTREAM_PORT) || + !PCIE_CAP_SLOT_IMPLEMENTED (PciExpressCap.PcieCapReg)) { + continue; + } + break; + case PcieExplainTypeRoot: + // + // Root registers are only valid for + // Root Port of PCI Express Root Complex + // + if (DevicePortType != PCIE_ROOT_COMPLEX_ROOT_PORT) { + continue; + } + break; + default: + break; + } + PcieExplainList[Index].Func (&PciExpressCap); + } + + Bus = (UINT8) (RShiftU64 (Address, 24)); + Dev = (UINT8) (RShiftU64 (Address, 16)); + Func = (UINT8) (RShiftU64 (Address, 8)); + + Pciex_Address = CALC_EFI_PCIEX_ADDRESS (Bus, Dev, Func, 0x100); + + ExtendRegSize = 0x1000 - 0x100; + + ExRegBuffer = (UINT8 *) AllocatePool (ExtendRegSize); + + // + // PciRootBridgeIo protocol should support pci express extend space IO + // (Begins at offset 0x100) + // + Status = IoDev->Pci.Read ( + IoDev, + EfiPciWidthUint32, + Pciex_Address, + (ExtendRegSize) / sizeof (UINT32), + (VOID *) (ExRegBuffer) + ); + if (EFI_ERROR (Status)) { + FreePool ((VOID *) ExRegBuffer); + return EFI_UNSUPPORTED; + } + // + // Start outputing PciEx extend space( 0xFF-0xFFF) + // + Print (L"\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\n\n"); + + PrivateDumpHex ( + 2, + 0x100, + ExtendRegSize, + (VOID *) (ExRegBuffer) + ); + + FreePool ((VOID *) ExRegBuffer); + +Done: + return EFI_SUCCESS; +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h new file mode 100644 index 0000000000..cbc1b0235a --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h @@ -0,0 +1,460 @@ +/** @file + Header file for Pci shell Debug1 function. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _EFI_SHELL_PCI_H_ +#define _EFI_SHELL_PCI_H_ + +typedef enum { + PciDevice, + PciP2pBridge, + PciCardBusBridge, + PciUndefined +} PCI_HEADER_TYPE; + +#define HEADER_TYPE_MULTI_FUNCTION 0x80 + +#define MAX_BUS_NUMBER 255 +#define MAX_DEVICE_NUMBER 31 +#define MAX_FUNCTION_NUMBER 7 + +#define EFI_PCI_CAPABILITY_ID_PCIEXP 0x10 +#define EFI_PCI_CAPABILITY_ID_PCIX 0x07 + +#define CALC_EFI_PCI_ADDRESS(Bus, Dev, Func, Reg) \ + ((UINT64) ((((UINTN) Bus) << 24) + (((UINTN) Dev) << 16) + (((UINTN) Func) << 8) + ((UINTN) Reg))) + +#define CALC_EFI_PCIEX_ADDRESS(Bus, Dev, Func, ExReg) ( \ + (UINT64) ((((UINTN) Bus) << 24) + (((UINTN) Dev) << 16) + (((UINTN) Func) << 8) + (LShiftU64 ((UINT64) ExReg, 32))) \ + ); + +#define INDEX_OF(Field) ((UINT8 *) (Field) - (UINT8 *) mConfigSpace) + +#define PCI_BIT_0 0x00000001 +#define PCI_BIT_1 0x00000002 +#define PCI_BIT_2 0x00000004 +#define PCI_BIT_3 0x00000008 +#define PCI_BIT_4 0x00000010 +#define PCI_BIT_5 0x00000020 +#define PCI_BIT_6 0x00000040 +#define PCI_BIT_7 0x00000080 +#define PCI_BIT_8 0x00000100 +#define PCI_BIT_9 0x00000200 +#define PCI_BIT_10 0x00000400 +#define PCI_BIT_11 0x00000800 +#define PCI_BIT_12 0x00001000 +#define PCI_BIT_13 0x00002000 +#define PCI_BIT_14 0x00004000 +#define PCI_BIT_15 0x00008000 + +// +// PCIE device/port types +// +#define PCIE_PCIE_ENDPOINT 0 +#define PCIE_LEGACY_PCIE_ENDPOINT 1 +#define PCIE_ROOT_COMPLEX_ROOT_PORT 4 +#define PCIE_SWITCH_UPSTREAM_PORT 5 +#define PCIE_SWITCH_DOWNSTREAM_PORT 6 +#define PCIE_PCIE_TO_PCIX_BRIDGE 7 +#define PCIE_PCIX_TO_PCIE_BRIDGE 8 +#define PCIE_ROOT_COMPLEX_INTEGRATED_PORT 9 +#define PCIE_ROOT_COMPLEX_EVENT_COLLECTOR 10 +#define PCIE_DEVICE_PORT_TYPE_MAX 11 + +#define IS_PCIE_ENDPOINT(DevicePortType) \ + ((DevicePortType) == PCIE_PCIE_ENDPOINT || \ + (DevicePortType) == PCIE_LEGACY_PCIE_ENDPOINT || \ + (DevicePortType) == PCIE_ROOT_COMPLEX_INTEGRATED_PORT) + +#define IS_PCIE_SWITCH(DevicePortType) \ + ((DevicePortType == PCIE_SWITCH_UPSTREAM_PORT) || \ + (DevicePortType == PCIE_SWITCH_DOWNSTREAM_PORT)) + +// +// Capabilities Register +// +#define PCIE_CAP_VERSION(PcieCapReg) \ + ((PcieCapReg) & 0x0f) +#define PCIE_CAP_DEVICEPORT_TYPE(PcieCapReg) \ + (((PcieCapReg) >> 4) & 0x0f) +#define PCIE_CAP_SLOT_IMPLEMENTED(PcieCapReg) \ + (((PcieCapReg) >> 8) & 0x1) +#define PCIE_CAP_INT_MSG_NUM(PcieCapReg) \ + (((PcieCapReg) >> 9) & 0x1f) +// +// Device Capabilities Register +// +#define PCIE_CAP_MAX_PAYLOAD(PcieDeviceCap) \ + ((PcieDeviceCap) & 0x7) +#define PCIE_CAP_PHANTOM_FUNC(PcieDeviceCap) \ + (((PcieDeviceCap) >> 3) & 0x3) +#define PCIE_CAP_EXTENDED_TAG(PcieDeviceCap) \ + (((PcieDeviceCap) >> 5) & 0x1) +#define PCIE_CAP_L0sLatency(PcieDeviceCap) \ + (((PcieDeviceCap) >> 6) & 0x7) +#define PCIE_CAP_L1Latency(PcieDeviceCap) \ + (((PcieDeviceCap) >> 9) & 0x7) +#define PCIE_CAP_ERR_REPORTING(PcieDeviceCap) \ + (((PcieDeviceCap) >> 15) & 0x1) +#define PCIE_CAP_SLOT_POWER_VALUE(PcieDeviceCap) \ + (((PcieDeviceCap) >> 18) & 0x0ff) +#define PCIE_CAP_SLOT_POWER_SCALE(PcieDeviceCap) \ + (((PcieDeviceCap) >> 26) & 0x3) +#define PCIE_CAP_FUNC_LEVEL_RESET(PcieDeviceCap) \ + (((PcieDeviceCap) >> 28) & 0x1) +// +// Device Control Register +// +#define PCIE_CAP_COR_ERR_REPORTING_ENABLE(PcieDeviceControl) \ + ((PcieDeviceControl) & 0x1) +#define PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE(PcieDeviceControl) \ + (((PcieDeviceControl) >> 1) & 0x1) +#define PCIE_CAP_FATAL_ERR_REPORTING_ENABLE(PcieDeviceControl) \ + (((PcieDeviceControl) >> 2) & 0x1) +#define PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE(PcieDeviceControl) \ + (((PcieDeviceControl) >> 3) & 0x1) +#define PCIE_CAP_RELAXED_ORDERING_ENABLE(PcieDeviceControl) \ + (((PcieDeviceControl) >> 4) & 0x1) +#define PCIE_CAP_MAX_PAYLOAD_SIZE(PcieDeviceControl) \ + (((PcieDeviceControl) >> 5) & 0x7) +#define PCIE_CAP_EXTENDED_TAG_ENABLE(PcieDeviceControl) \ + (((PcieDeviceControl) >> 8) & 0x1) +#define PCIE_CAP_PHANTOM_FUNC_ENABLE(PcieDeviceControl) \ + (((PcieDeviceControl) >> 9) & 0x1) +#define PCIE_CAP_AUX_PM_ENABLE(PcieDeviceControl) \ + (((PcieDeviceControl) >> 10) & 0x1) +#define PCIE_CAP_NO_SNOOP_ENABLE(PcieDeviceControl) \ + (((PcieDeviceControl) >> 11) & 0x1) +#define PCIE_CAP_MAX_READ_REQ_SIZE(PcieDeviceControl) \ + (((PcieDeviceControl) >> 12) & 0x7) +#define PCIE_CAP_BRG_CONF_RETRY(PcieDeviceControl) \ + (((PcieDeviceControl) >> 15) & 0x1) +// +// Device Status Register +// +#define PCIE_CAP_COR_ERR_DETECTED(PcieDeviceStatus) \ + ((PcieDeviceStatus) & 0x1) +#define PCIE_CAP_NONFAT_ERR_DETECTED(PcieDeviceStatus) \ + (((PcieDeviceStatus) >> 1) & 0x1) +#define PCIE_CAP_FATAL_ERR_DETECTED(PcieDeviceStatus) \ + (((PcieDeviceStatus) >> 2) & 0x1) +#define PCIE_CAP_UNSUP_REQ_DETECTED(PcieDeviceStatus) \ + (((PcieDeviceStatus) >> 3) & 0x1) +#define PCIE_CAP_AUX_POWER_DETECTED(PcieDeviceStatus) \ + (((PcieDeviceStatus) >> 4) & 0x1) +#define PCIE_CAP_TRANSACTION_PENDING(PcieDeviceStatus) \ + (((PcieDeviceStatus) >> 5) & 0x1) +// +// Link Capabilities Register +// +#define PCIE_CAP_SUP_LINK_SPEEDS(PcieLinkCap) \ + ((PcieLinkCap) & 0x0f) +#define PCIE_CAP_MAX_LINK_WIDTH(PcieLinkCap) \ + (((PcieLinkCap) >> 4) & 0x3f) +#define PCIE_CAP_ASPM_SUPPORT(PcieLinkCap) \ + (((PcieLinkCap) >> 10) & 0x3) +#define PCIE_CAP_L0s_LATENCY(PcieLinkCap) \ + (((PcieLinkCap) >> 12) & 0x7) +#define PCIE_CAP_L1_LATENCY(PcieLinkCap) \ + (((PcieLinkCap) >> 15) & 0x7) +#define PCIE_CAP_CLOCK_PM(PcieLinkCap) \ + (((PcieLinkCap) >> 18) & 0x1) +#define PCIE_CAP_SUP_DOWN_ERR_REPORTING(PcieLinkCap) \ + (((PcieLinkCap) >> 19) & 0x1) +#define PCIE_CAP_LINK_ACTIVE_REPORTING(PcieLinkCap) \ + (((PcieLinkCap) >> 20) & 0x1) +#define PCIE_CAP_LINK_BWD_NOTIF_CAP(PcieLinkCap) \ + (((PcieLinkCap) >> 21) & 0x1) +#define PCIE_CAP_PORT_NUMBER(PcieLinkCap) \ + (((PcieLinkCap) >> 24) & 0x0ff) +// +// Link Control Register +// +#define PCIE_CAP_ASPM_CONTROL(PcieLinkControl) \ + ((PcieLinkControl) & 0x3) +#define PCIE_CAP_RCB(PcieLinkControl) \ + (((PcieLinkControl) >> 3) & 0x1) +#define PCIE_CAP_LINK_DISABLE(PcieLinkControl) \ + (((PcieLinkControl) >> 4) & 0x1) +#define PCIE_CAP_COMMON_CLK_CONF(PcieLinkControl) \ + (((PcieLinkControl) >> 6) & 0x1) +#define PCIE_CAP_EXT_SYNC(PcieLinkControl) \ + (((PcieLinkControl) >> 7) & 0x1) +#define PCIE_CAP_CLK_PWR_MNG(PcieLinkControl) \ + (((PcieLinkControl) >> 8) & 0x1) +#define PCIE_CAP_HW_AUTO_WIDTH_DISABLE(PcieLinkControl) \ + (((PcieLinkControl) >> 9) & 0x1) +#define PCIE_CAP_LINK_BDW_MNG_INT_EN(PcieLinkControl) \ + (((PcieLinkControl) >> 10) & 0x1) +#define PCIE_CAP_LINK_AUTO_BDW_INT_EN(PcieLinkControl) \ + (((PcieLinkControl) >> 11) & 0x1) +// +// Link Status Register +// +#define PCIE_CAP_CUR_LINK_SPEED(PcieLinkStatus) \ + ((PcieLinkStatus) & 0x0f) +#define PCIE_CAP_NEGO_LINK_WIDTH(PcieLinkStatus) \ + (((PcieLinkStatus) >> 4) & 0x3f) +#define PCIE_CAP_LINK_TRAINING(PcieLinkStatus) \ + (((PcieLinkStatus) >> 11) & 0x1) +#define PCIE_CAP_SLOT_CLK_CONF(PcieLinkStatus) \ + (((PcieLinkStatus) >> 12) & 0x1) +#define PCIE_CAP_DATA_LINK_ACTIVE(PcieLinkStatus) \ + (((PcieLinkStatus) >> 13) & 0x1) +#define PCIE_CAP_LINK_BDW_MNG_STAT(PcieLinkStatus) \ + (((PcieLinkStatus) >> 14) & 0x1) +#define PCIE_CAP_LINK_AUTO_BDW_STAT(PcieLinkStatus) \ + (((PcieLinkStatus) >> 15) & 0x1) +// +// Slot Capabilities Register +// +#define PCIE_CAP_ATT_BUT_PRESENT(PcieSlotCap) \ + ((PcieSlotCap) & 0x1) +#define PCIE_CAP_PWR_CTRLLER_PRESENT(PcieSlotCap) \ + (((PcieSlotCap) >> 1) & 0x1) +#define PCIE_CAP_MRL_SENSOR_PRESENT(PcieSlotCap) \ + (((PcieSlotCap) >> 2) & 0x1) +#define PCIE_CAP_ATT_IND_PRESENT(PcieSlotCap) \ + (((PcieSlotCap) >> 3) & 0x1) +#define PCIE_CAP_PWD_IND_PRESENT(PcieSlotCap) \ + (((PcieSlotCap) >> 4) & 0x1) +#define PCIE_CAP_HOTPLUG_SUPPRISE(PcieSlotCap) \ + (((PcieSlotCap) >> 5) & 0x1) +#define PCIE_CAP_HOTPLUG_CAPABLE(PcieSlotCap) \ + (((PcieSlotCap) >> 6) & 0x1) +#define PCIE_CAP_SLOT_PWR_LIMIT_VALUE(PcieSlotCap) \ + (((PcieSlotCap) >> 7) & 0x0ff) +#define PCIE_CAP_SLOT_PWR_LIMIT_SCALE(PcieSlotCap) \ + (((PcieSlotCap) >> 15) & 0x3) +#define PCIE_CAP_ELEC_INTERLOCK_PRESENT(PcieSlotCap) \ + (((PcieSlotCap) >> 17) & 0x1) +#define PCIE_CAP_NO_COMM_COMPLETED_SUP(PcieSlotCap) \ + (((PcieSlotCap) >> 18) & 0x1) +#define PCIE_CAP_PHY_SLOT_NUM(PcieSlotCap) \ + (((PcieSlotCap) >> 19) & 0x1fff) +// +// Slot Control Register +// +#define PCIE_CAP_ATT_BUT_ENABLE(PcieSlotControl) \ + ((PcieSlotControl) & 0x1) +#define PCIE_CAP_PWR_FLT_DETECT_ENABLE(PcieSlotControl) \ + (((PcieSlotControl) >> 1) & 0x1) +#define PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE(PcieSlotControl) \ + (((PcieSlotControl) >> 2) & 0x1) +#define PCIE_CAP_PRES_DETECT_CHANGE_ENABLE(PcieSlotControl) \ + (((PcieSlotControl) >> 3) & 0x1) +#define PCIE_CAP_COMM_CMPL_INT_ENABLE(PcieSlotControl) \ + (((PcieSlotControl) >> 4) & 0x1) +#define PCIE_CAP_HOTPLUG_INT_ENABLE(PcieSlotControl) \ + (((PcieSlotControl) >> 5) & 0x1) +#define PCIE_CAP_ATT_IND_CTRL(PcieSlotControl) \ + (((PcieSlotControl) >> 6) & 0x3) +#define PCIE_CAP_PWR_IND_CTRL(PcieSlotControl) \ + (((PcieSlotControl) >> 8) & 0x3) +#define PCIE_CAP_PWR_CTRLLER_CTRL(PcieSlotControl) \ + (((PcieSlotControl) >> 10) & 0x1) +#define PCIE_CAP_ELEC_INTERLOCK_CTRL(PcieSlotControl) \ + (((PcieSlotControl) >> 11) & 0x1) +#define PCIE_CAP_DLINK_STAT_CHANGE_ENABLE(PcieSlotControl) \ + (((PcieSlotControl) >> 12) & 0x1) +// +// Slot Status Register +// +#define PCIE_CAP_ATT_BUT_PRESSED(PcieSlotStatus) \ + ((PcieSlotStatus) & 0x1) +#define PCIE_CAP_PWR_FLT_DETECTED(PcieSlotStatus) \ + (((PcieSlotStatus) >> 1) & 0x1) +#define PCIE_CAP_MRL_SENSOR_CHANGED(PcieSlotStatus) \ + (((PcieSlotStatus) >> 2) & 0x1) +#define PCIE_CAP_PRES_DETECT_CHANGED(PcieSlotStatus) \ + (((PcieSlotStatus) >> 3) & 0x1) +#define PCIE_CAP_COMM_COMPLETED(PcieSlotStatus) \ + (((PcieSlotStatus) >> 4) & 0x1) +#define PCIE_CAP_MRL_SENSOR_STATE(PcieSlotStatus) \ + (((PcieSlotStatus) >> 5) & 0x1) +#define PCIE_CAP_PRES_DETECT_STATE(PcieSlotStatus) \ + (((PcieSlotStatus) >> 6) & 0x1) +#define PCIE_CAP_ELEC_INTERLOCK_STATE(PcieSlotStatus) \ + (((PcieSlotStatus) >> 7) & 0x1) +#define PCIE_CAP_DLINK_STAT_CHANGED(PcieSlotStatus) \ + (((PcieSlotStatus) >> 8) & 0x1) +// +// Root Control Register +// +#define PCIE_CAP_SYSERR_ON_CORERR_EN(PcieRootControl) \ + ((PcieRootControl) & 0x1) +#define PCIE_CAP_SYSERR_ON_NONFATERR_EN(PcieRootControl) \ + (((PcieRootControl) >> 1) & 0x1) +#define PCIE_CAP_SYSERR_ON_FATERR_EN(PcieRootControl) \ + (((PcieRootControl) >> 2) & 0x1) +#define PCIE_CAP_PME_INT_ENABLE(PcieRootControl) \ + (((PcieRootControl) >> 3) & 0x1) +#define PCIE_CAP_CRS_SW_VIS_ENABLE(PcieRootControl) \ + (((PcieRootControl) >> 4) & 0x1) +// +// Root Capabilities Register +// +#define PCIE_CAP_CRS_SW_VIS(PcieRootCap) \ + ((PcieRootCap) & 0x1) +// +// Root Status Register +// +#define PCIE_CAP_PME_REQ_ID(PcieRootStatus) \ + ((PcieRootStatus) & 0x0ffff) +#define PCIE_CAP_PME_STATUS(PcieRootStatus) \ + (((PcieRootStatus) >> 16) & 0x1) +#define PCIE_CAP_PME_PENDING(PcieRootStatus) \ + (((PcieRootStatus) >> 17) & 0x1) + +#pragma pack(1) +// +// Common part of the PCI configuration space header for devices, P2P bridges, +// and cardbus bridges +// +typedef struct { + UINT16 VendorId; + UINT16 DeviceId; + + UINT16 Command; + UINT16 Status; + + UINT8 RevisionId; + UINT8 ClassCode[3]; + + UINT8 CacheLineSize; + UINT8 PrimaryLatencyTimer; + UINT8 HeaderType; + UINT8 BIST; + +} PCI_COMMON_HEADER; + +// +// PCI configuration space header for devices(after the common part) +// +typedef struct { + UINT32 Bar[6]; // Base Address Registers + UINT32 CardBusCISPtr; // CardBus CIS Pointer + UINT16 SubVendorId; // Subsystem Vendor ID + UINT16 SubSystemId; // Subsystem ID + UINT32 ROMBar; // Expansion ROM Base Address + UINT8 CapabilitiesPtr; // Capabilities Pointer + UINT8 Reserved[3]; + + UINT32 Reserved1; + + UINT8 InterruptLine; // Interrupt Line + UINT8 InterruptPin; // Interrupt Pin + UINT8 MinGnt; // Min_Gnt + UINT8 MaxLat; // Max_Lat +} PCI_DEVICE_HEADER; + +// +// PCI configuration space header for pci-to-pci bridges(after the common part) +// +typedef struct { + UINT32 Bar[2]; // Base Address Registers + UINT8 PrimaryBus; // Primary Bus Number + UINT8 SecondaryBus; // Secondary Bus Number + UINT8 SubordinateBus; // Subordinate Bus Number + UINT8 SecondaryLatencyTimer; // Secondary Latency Timer + UINT8 IoBase; // I/O Base + UINT8 IoLimit; // I/O Limit + UINT16 SecondaryStatus; // Secondary Status + UINT16 MemoryBase; // Memory Base + UINT16 MemoryLimit; // Memory Limit + UINT16 PrefetchableMemBase; // Pre-fetchable Memory Base + UINT16 PrefetchableMemLimit; // Pre-fetchable Memory Limit + UINT32 PrefetchableBaseUpper; // Pre-fetchable Base Upper 32 bits + UINT32 PrefetchableLimitUpper; // Pre-fetchable Limit Upper 32 bits + UINT16 IoBaseUpper; // I/O Base Upper 16 bits + UINT16 IoLimitUpper; // I/O Limit Upper 16 bits + UINT8 CapabilitiesPtr; // Capabilities Pointer + UINT8 Reserved[3]; + + UINT32 ROMBar; // Expansion ROM Base Address + UINT8 InterruptLine; // Interrupt Line + UINT8 InterruptPin; // Interrupt Pin + UINT16 BridgeControl; // Bridge Control +} PCI_BRIDGE_HEADER; + +// +// PCI configuration space header for cardbus bridges(after the common part) +// +typedef struct { + UINT32 CardBusSocketReg; // Cardus Socket/ExCA Base + // Address Register + // + UINT8 CapabilitiesPtr; // 14h in pci-cardbus bridge. + UINT8 Reserved; + UINT16 SecondaryStatus; // Secondary Status + UINT8 PciBusNumber; // PCI Bus Number + UINT8 CardBusBusNumber; // CardBus Bus Number + UINT8 SubordinateBusNumber; // Subordinate Bus Number + UINT8 CardBusLatencyTimer; // CardBus Latency Timer + UINT32 MemoryBase0; // Memory Base Register 0 + UINT32 MemoryLimit0; // Memory Limit Register 0 + UINT32 MemoryBase1; + UINT32 MemoryLimit1; + UINT32 IoBase0; + UINT32 IoLimit0; // I/O Base Register 0 + UINT32 IoBase1; // I/O Limit Register 0 + UINT32 IoLimit1; + + UINT8 InterruptLine; // Interrupt Line + UINT8 InterruptPin; // Interrupt Pin + UINT16 BridgeControl; // Bridge Control +} PCI_CARDBUS_HEADER; + +// +// Data region after PCI configuration header(for cardbus bridge) +// +typedef struct { + UINT16 SubVendorId; // Subsystem Vendor ID + UINT16 SubSystemId; // Subsystem ID + UINT32 LegacyBase; // Optional 16-Bit PC Card Legacy + // Mode Base Address + // + UINT32 Data[46]; +} PCI_CARDBUS_DATA; + +typedef struct { + PCI_COMMON_HEADER Common; + union { + PCI_DEVICE_HEADER Device; + PCI_BRIDGE_HEADER Bridge; + PCI_CARDBUS_HEADER CardBus; + } NonCommon; + UINT32 Data[48]; +} PCI_CONFIG_SPACE; + +typedef struct { + UINT8 PcieCapId; + UINT8 NextCapPtr; + UINT16 PcieCapReg; + UINT32 PcieDeviceCap; + UINT16 DeviceControl; + UINT16 DeviceStatus; + UINT32 LinkCap; + UINT16 LinkControl; + UINT16 LinkStatus; + UINT32 SlotCap; + UINT16 SlotControl; + UINT16 SlotStatus; + UINT16 RsvdP; + UINT16 RootControl; + UINT32 RootStatus; +} PCIE_CAP_STURCTURE; + +#pragma pack() + +#endif // _PCI_H_ diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c new file mode 100644 index 0000000000..f86e8ba968 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c @@ -0,0 +1,344 @@ +/** @file + Main file for SerMode shell Debug1 function. + + Copyright (c) 20052010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" +#include +#include + +SHELL_STATUS +EFIAPI +iDisplaySettings ( + IN UINTN HandleIdx, + IN BOOLEAN HandleValid + ) +{ + EFI_SERIAL_IO_PROTOCOL *SerialIo; + UINTN NoHandles; + EFI_HANDLE *Handles; + EFI_STATUS Status; + UINTN Index; + CHAR16 *StopBits; + CHAR16 Parity; + SHELL_STATUS ShellStatus; + + Handles = NULL; + StopBits = NULL; + + ShellStatus = SHELL_SUCCESS; + + Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiSerialIoProtocolGuid, NULL, &NoHandles, &Handles); + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle); + return SHELL_INVALID_PARAMETER; + } + + for (Index = 0; Index < NoHandles; Index++) { + if (HandleValid) { + if (ConvertHandleIndexToHandle(HandleIdx) != Handles[Index]) { + continue; + } + } + + Status = gBS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID**)&SerialIo); + if (!EFI_ERROR (Status)) { + switch (SerialIo->Mode->Parity) { + case DefaultParity: + + Parity = 'D'; + break; + + case NoParity: + + Parity = 'N'; + break; + + case EvenParity: + + Parity = 'E'; + break; + + case OddParity: + + Parity = 'O'; + break; + + case MarkParity: + + Parity = 'M'; + break; + + case SpaceParity: + + Parity = 'S'; + break; + + default: + + Parity = 'U'; + } + + switch (SerialIo->Mode->StopBits) { + case DefaultStopBits: + + StopBits = L"Default"; + break; + + case OneStopBit: + + StopBits = L"1"; + break; + + case TwoStopBits: + + StopBits = L"2"; + break; + + case OneFiveStopBits: + + StopBits = L"1.5"; + break; + + default: + + StopBits = L"Unknown"; + } + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_SERMODE_DISPLAY), + gShellDebug1HiiHandle, + ConvertHandleToHandleIndex (Handles[Index]), + Handles[Index], + SerialIo->Mode->BaudRate, + Parity, + SerialIo->Mode->DataBits, + StopBits + ); + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle); + ShellStatus = SHELL_NOT_FOUND; + break; + } + + if (HandleValid) { + break; + } + } + + if (Index == NoHandles) { + if ((NoHandles != 0 && HandleValid) || 0 == NoHandles) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NOT_FOUND), gShellDebug1HiiHandle); + ShellStatus = SHELL_NOT_FOUND; + } + } + + return ShellStatus; +} + +SHELL_STATUS +EFIAPI +ShellCommandRunSerMode ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + SHELL_STATUS ShellStatus; + UINTN Index; + UINTN NoHandles; + EFI_HANDLE *Handles; + EFI_PARITY_TYPE Parity; + EFI_STOP_BITS_TYPE StopBits; + UINTN HandleIdx; + UINTN BaudRate; + UINTN DataBits; + UINTN Value; + EFI_SERIAL_IO_PROTOCOL *SerialIo; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + CONST CHAR16 *Temp; + + ShellStatus = SHELL_SUCCESS; + HandleIdx = 0; + Parity = DefaultParity; + Handles = NULL; + NoHandles = 0; + Index = 0; + Package = NULL; + + Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) < 5 && ShellCommandLineGetCount(Package) > 1) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (ShellCommandLineGetCount(Package) > 5) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + Temp = ShellCommandLineGetRawValue(Package, 1); + if (Temp != NULL) { + HandleIdx = StrHexToUintn(Temp); + Temp = ShellCommandLineGetRawValue(Package, 2); + if (Temp == NULL) { + ShellStatus = iDisplaySettings (HandleIdx, TRUE); + goto Done; + } + } else { + ShellStatus = iDisplaySettings (0, FALSE); + goto Done; + } + Temp = ShellCommandLineGetRawValue(Package, 2); + if (Temp != NULL) { + BaudRate = StrHexToUintn(Temp); + } else { + ASSERT(FALSE); + BaudRate = 0; + } + Temp = ShellCommandLineGetRawValue(Package, 3); + if (Temp == NULL || StrLen(Temp)>1) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + switch(Temp[0]){ + case 'd': + case 'D': + Parity = DefaultParity; + break; + case 'n': + case 'N': + Parity = NoParity; + break; + case 'e': + case 'E': + Parity = EvenParity; + break; + case 'o': + case 'O': + Parity = OddParity; + break; + case 'm': + case 'M': + Parity = MarkParity; + break; + case 's': + case 'S': + Parity = SpaceParity; + break; + default: + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + } + Temp = ShellCommandLineGetRawValue(Package, 4); + if (Temp != NULL) { + DataBits = StrHexToUintn(Temp); + } else { + // + // make sure this is some number not in the list below. + // + DataBits = 0; + } + switch (DataBits) { + case 4: + case 7: + case 8: + break; + default: + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + Temp = ShellCommandLineGetRawValue(Package, 5); + Value = StrHexToUintn(Temp); + switch (Value) { + case 0: + StopBits = DefaultStopBits; + break; + + case 1: + StopBits = OneStopBit; + break; + + case 2: + StopBits = TwoStopBits; + break; + + case 15: + StopBits = OneFiveStopBits; + break; + + default: + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSerialIoProtocolGuid, NULL, &NoHandles, &Handles); + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + + for (Index = 0; Index < NoHandles; Index++) { + if (ConvertHandleIndexToHandle (HandleIdx) != Handles[Index]) { + continue; + } + + Status = gBS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID**)&SerialIo); + if (!EFI_ERROR (Status)) { + Status = SerialIo->SetAttributes ( + SerialIo, + (UINT64) BaudRate, + SerialIo->Mode->ReceiveFifoDepth, + SerialIo->Mode->Timeout, + Parity, + (UINT8) DataBits, + StopBits + ); + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_FAIL), gShellDebug1HiiHandle, ConvertHandleToHandleIndex(Handles[Index]), Status); + ShellStatus = SHELL_ACCESS_DENIED; + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_HANDLE), gShellDebug1HiiHandle, ConvertHandleToHandleIndex(Handles[Index])); + } + break; + } + } + } + } + + if (Index == NoHandles) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_BAD_HANDLE), gShellDebug1HiiHandle, HandleIdx); + ShellStatus = SHELL_INVALID_PARAMETER; + } + +Done: + if (Package != NULL) { + ShellCommandLineFreeVarList (Package); + } + if (Handles != NULL) { + FreePool (Handles); + } + return ShellStatus; +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c new file mode 100644 index 0000000000..30a382fb04 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c @@ -0,0 +1,90 @@ +/** @file + Main file for SetSize shell Debug1 function. + + Copyright (c) 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" + +SHELL_STATUS +EFIAPI +ShellCommandRunSetSize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + CONST CHAR16 *Temp1; + UINTN NewSize; + UINTN LoopVar; + SHELL_FILE_HANDLE FileHandle; + + ShellStatus = SHELL_SUCCESS; + Status = EFI_SUCCESS; + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + Temp1 = ShellCommandLineGetRawValue(Package, 1); + if (Temp1 == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SIZE_NOT_SPEC), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + NewSize = 0; + } else { + NewSize = ShellStrToUintn(Temp1); + } + for (LoopVar = 2 ; LoopVar < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS ; LoopVar++) { + Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); + if (EFI_ERROR(Status) && LoopVar == 2) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (EFI_ERROR(Status)) { + break; + } else { + Status = FileHandleSetSize(FileHandle, NewSize); + if (Status == EFI_VOLUME_FULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_VOLUME_FULL), gShellDebug1HiiHandle); + ShellStatus = SHELL_VOLUME_FULL; + } else if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, LoopVar), Status); + ShellStatus = SHELL_INVALID_PARAMETER; + } + ShellCloseFile(&FileHandle); + } + } + + ShellCommandLineFreeVarList (Package); + } + + return (ShellStatus); +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c new file mode 100644 index 0000000000..f8c6dd2e30 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c @@ -0,0 +1,228 @@ +/** @file + Main file for SetVar shell Debug1 function. + + Copyright (c) 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" + +STATIC CONST SHELL_PARAM_ITEM ParamList[] = { + {L"-guid", TypeValue}, + {L"-bs", TypeFlag}, + {L"-rt", TypeFlag}, + {L"-nv", TypeFlag}, + {NULL, TypeMax} + }; + +SHELL_STATUS +EFIAPI +ShellCommandRunSetVar ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + CONST CHAR16 *VariableName; + CONST CHAR16 *Data; + EFI_GUID Guid; + CONST CHAR16 *StringGuid; + UINT32 Attributes; + VOID *Buffer; + UINTN Size; + UINTN LoopVar; + EFI_DEVICE_PATH_PROTOCOL *DevPath; + EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DevPathFromText; + + ShellStatus = SHELL_SUCCESS; + Status = EFI_SUCCESS; + Buffer = NULL; + Size = 0; + Attributes = 0; + DevPath = NULL; + + // + // initialize the shell lib (we must be in non-auto-init...) + // + Status = ShellInitialize(); + ASSERT_EFI_ERROR(Status); + + Status = CommandInit(); + ASSERT_EFI_ERROR(Status); + + // + // parse the command line + // + Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) < 2) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (ShellCommandLineGetCount(Package) > 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + VariableName = ShellCommandLineGetRawValue(Package, 1); + Data = ShellCommandLineGetRawValue(Package, 2); + if (!ShellCommandLineGetFlag(Package, L"-guid")){ + CopyGuid(&Guid, &gEfiGlobalVariableGuid); + } else { + StringGuid = ShellCommandLineGetValue(Package, L"-guid"); + Status = ConvertStringToGuid(StringGuid, &Guid); + if (EFI_ERROR(Status)) { + ShellStatus = SHELL_NOT_FOUND; + } + } + if (Data == NULL) { + // + // Display what's there + // + Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer); + if (Status == EFI_BUFFER_TOO_SMALL) { + Buffer = AllocatePool(Size); + Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer); + } + if (!EFI_ERROR(Status)&& Buffer != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_PRINT), gShellDebug1HiiHandle, &Guid, VariableName, Size); + for (LoopVar = 0 ; LoopVar < Size ; LoopVar++) { + ShellPrintEx(-1, -1, L"%02x ", ((UINT8*)Buffer)[LoopVar]); + } + ShellPrintEx(-1, -1, L"\r\n"); + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_GET), gShellDebug1HiiHandle, &Guid, VariableName, Status); + ShellStatus = SHELL_ACCESS_DENIED; + } + } else if (StrCmp(Data, L"=") == 0) { + // + // Delete what's there! + // + Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, 0, NULL); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status); + ShellStatus = SHELL_ACCESS_DENIED; + } else { + ASSERT(ShellStatus == SHELL_SUCCESS); + } + } else { + if (Data[0] == L'=') { + Data++; + } + // + // Change what's there + // + if (ShellCommandLineGetFlag(Package, L"-bs")) { + Attributes |= EFI_VARIABLE_BOOTSERVICE_ACCESS; + } + if (ShellCommandLineGetFlag(Package, L"-rt")) { + Attributes |= EFI_VARIABLE_RUNTIME_ACCESS; + } + if (ShellCommandLineGetFlag(Package, L"-nv")) { + Attributes |= EFI_VARIABLE_NON_VOLATILE; + } + if (ShellIsHexOrDecimalNumber(Data, TRUE, FALSE)) { + // + // arbitrary buffer + // + Buffer = AllocateZeroPool((StrLen(Data) / 2)); + for (LoopVar = 0 ; LoopVar < (StrLen(Data) / 2) ; LoopVar++) { + ((UINT8*)Buffer)[LoopVar] = (UINT8)(HexCharToUintn(Data[LoopVar*2]) * 16); + ((UINT8*)Buffer)[LoopVar] = (UINT8)(((UINT8*)Buffer)[LoopVar] + HexCharToUintn(Data[LoopVar*2+1])); + } + Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, StrLen(Data) / 2, Buffer); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status); + ShellStatus = SHELL_ACCESS_DENIED; + } else { + ASSERT(ShellStatus == SHELL_SUCCESS); + } + } else if (StrnCmp(Data, L"\"", 1) == 0) { + // + // ascii text + // + Data++; + Buffer = AllocateZeroPool(StrSize(Data) / 2); + AsciiSPrint(Buffer, StrSize(Data) / 2, "%s", Data); + ((CHAR8*)Buffer)[AsciiStrLen(Buffer)-1] = CHAR_NULL; + + Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, AsciiStrSize(Buffer)-sizeof(CHAR8), Buffer); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status); + ShellStatus = SHELL_ACCESS_DENIED; + } else { + ASSERT(ShellStatus == SHELL_SUCCESS); + } + } else if (StrnCmp(Data, L"L\"", 2) == 0) { + // + // ucs2 text + // + Data++; + Data++; + Buffer = AllocateZeroPool(StrSize(Data)); + UnicodeSPrint(Buffer, StrSize(Data), L"%s", Data); + ((CHAR16*)Buffer)[StrLen(Buffer)-1] = CHAR_NULL; + + Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, StrSize(Buffer)-sizeof(CHAR16), Buffer); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status); + ShellStatus = SHELL_ACCESS_DENIED; + } else { + ASSERT(ShellStatus == SHELL_SUCCESS); + } + } else if (StrnCmp(Data, L"--", 2) == 0) { + // + // device path in text format + // + Data++; + Data++; + Status = gBS->LocateProtocol(&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID**)&DevPathFromText); + ASSERT_EFI_ERROR(Status); + DevPath = DevPathFromText->ConvertTextToDevicePath(Data); + if (DevPath == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_DPFT), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, GetDevicePathSize(DevPath), DevPath); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status); + ShellStatus = SHELL_ACCESS_DENIED; + } else { + ASSERT(ShellStatus == SHELL_SUCCESS); + } + } + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Data); + ShellStatus = SHELL_INVALID_PARAMETER; + } + } + } + ShellCommandLineFreeVarList (Package); + } + + if (Buffer != NULL) { + FreePool(Buffer); + } + + if (DevPath != NULL) { + FreePool(DevPath); + } + + return (ShellStatus); +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.c new file mode 100644 index 0000000000..f0a9d54b73 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.c @@ -0,0 +1,394 @@ +/** + Module for clarifying the content of the smbios structure element info. + + Copyright (c) 2005-2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "../UefiShellDebug1CommandsLib.h" +#include "PrintInfo.h" +#include "QueryTable.h" +#include "EventLogInfo.h" + +/** + Function to display system event log access information. + + @param[in] Key Additional information to print. + @param[in] Option Whether to print the additional information. +**/ +VOID +EFIAPI +DisplaySELAccessMethod ( + IN CONST UINT8 Key, + IN CONST UINT8 Option + ) +{ + // + // Print prompt + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ACCESS_METHOD), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + + // + // Print value info + // + switch (Key) { + case 0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_EIGHT_BIT), gShellDebug1HiiHandle); + break; + + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TWO_EIGHT_BITS), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_SIXTEEN_BIT), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MEM_MAPPED_PHYS), gShellDebug1HiiHandle); + break; + + case 4: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_VIA_GENERAL), gShellDebug1HiiHandle); + break; + + default: + if (Key <= 0x7f) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_FUTURE_ASSIGN), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR_OEM), gShellDebug1HiiHandle); + } + } +} + +/** + Function to display system event log status information. + + @param[in] Key Additional information to print. + @param[in] Option Whether to print the additional information. +**/ +VOID +EFIAPI +DisplaySELLogStatus ( + UINT8 Key, + UINT8 Option + ) +{ + // + // Print prompt + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_STATUS), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + + // + // Print value info + // + if ((Key & 0x01) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_VALID), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_VALID), gShellDebug1HiiHandle); + } + + if ((Key & 0x02) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_FULL), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_NOT_FULL), gShellDebug1HiiHandle); + } + + if ((Key & 0xFC) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_RES_BITS_NOT_ZERO), gShellDebug1HiiHandle, Key & 0xFC); + } +} + +/** + Function to display system event log header format information. + + @param[in] Key Additional information to print. + @param[in] Option Whether to print the additional information. +**/ +VOID +EFIAPI +DisplaySysEventLogHeaderFormat ( + UINT8 Key, + UINT8 Option + ) +{ + // + // Print prompt + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER_FORMAT), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + + // + // Print value info + // + if (Key == 0x00) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_HEADER), gShellDebug1HiiHandle); + } else if (Key == 0x01) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TYPE_LOG_HEADER), gShellDebug1HiiHandle); + } else if (Key <= 0x7f) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_FUTURE), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR), gShellDebug1HiiHandle); + } +} + +VOID +DisplaySELLogHeaderLen ( + UINT8 Key, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER_LEN), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_VAR_D), gShellDebug1HiiHandle, Key & 0x7F); + + // + // The most-significant bit of the field specifies + // whether (0) or not (1) the record has been read + // + if ((Key & 0x80) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_THIS_RECORD_READ), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_THIS_RECORD_NOT_READ), gShellDebug1HiiHandle); + } +} + +VOID +DisplaySysEventLogHeaderType1 ( + UINT8 *LogHeader + ) +{ + LOG_HEADER_TYPE1_FORMAT *Header; + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SYSTEM_EVENT_LOG), gShellDebug1HiiHandle); + + // + // Print Log Header Type1 Format info + // + Header = (LOG_HEADER_TYPE1_FORMAT *) (LogHeader); + + ShellPrintHiiEx(-1,-1,NULL, + STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_OEM_RESERVED), + gShellDebug1HiiHandle, + Header->OEMReserved[0], + Header->OEMReserved[1], + Header->OEMReserved[2], + Header->OEMReserved[3], + Header->OEMReserved[4] + ); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULTIPLE_EVENT_TIME), gShellDebug1HiiHandle, Header->METW); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULTIPLE_EVENT_COUNT), gShellDebug1HiiHandle, Header->MECI); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_PREBOOT_ADDRESS), gShellDebug1HiiHandle, Header->CMOSAddress); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_PREBOOT_INDEX), gShellDebug1HiiHandle, Header->CMOSBitIndex); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_CHECKSUM_STARTING_OFF), gShellDebug1HiiHandle, Header->StartingOffset); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_CHECKSUN_BYTE_COUNT), gShellDebug1HiiHandle, Header->ChecksumOffset); + ShellPrintHiiEx(-1,-1,NULL, + STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_RESERVED), + gShellDebug1HiiHandle, + Header->OEMReserved[0], + Header->OEMReserved[1], + Header->OEMReserved[2] + ); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_HEADER_REVISION), gShellDebug1HiiHandle, Header->HeaderRevision); +} + +/** + Function to display system event log header information. + + @param[in] LogHeaderFormat Format identifier. + @param[in] LogHeader Format informcation. +**/ +VOID +EFIAPI +DisplaySysEventLogHeader ( + UINT8 LogHeaderFormat, + UINT8 *LogHeader + ) +{ + // + // Print prompt + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER), gShellDebug1HiiHandle); + + // + // Print value info + // + if (LogHeaderFormat == 0x00) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_HEADER), gShellDebug1HiiHandle); + } else if (LogHeaderFormat == 0x01) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TYPE_LOG_HEADER), gShellDebug1HiiHandle); + DisplaySysEventLogHeaderType1 (LogHeader); + } else if (LogHeaderFormat <= 0x7f) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FUTURE_ASSIGN), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR), gShellDebug1HiiHandle); + } +} + +VOID +DisplayElVdfInfo ( + UINT8 ElVdfType, + UINT8 *VarData + ) +{ + UINT16 *Word; + UINT32 *Dword; + + // + // Display Type Name + // + DisplaySELVarDataFormatType (ElVdfType, SHOW_DETAIL); + + // + // Display Type description + // + switch (ElVdfType) { + case 0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_STD_FORMAT), gShellDebug1HiiHandle); + break; + + case 1: + Word = (UINT16 *) (VarData + 1); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SMBIOS_STRUCT_ASSOC), gShellDebug1HiiHandle); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, *Word); + break; + + case 2: + Dword = (UINT32 *) (VarData + 1); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword); + break; + + case 3: + Word = (UINT16 *) (VarData + 1); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SMBIOS_STRUCT_ASSOC), gShellDebug1HiiHandle); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, *Word); + // + // Followed by a multiple-event counter + // + Dword = (UINT32 *) (VarData + 1); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword); + break; + + case 4: + Dword = (UINT32 *) (VarData + 1); + DisplayPostResultsBitmapDw1 (*Dword, SHOW_DETAIL); + Dword++; + DisplayPostResultsBitmapDw2 (*Dword, SHOW_DETAIL); + break; + + case 5: + Dword = (UINT32 *) (VarData + 1); + DisplaySELSysManagementTypes (*Dword, SHOW_DETAIL); + break; + + case 6: + Dword = (UINT32 *) (VarData + 1); + DisplaySELSysManagementTypes (*Dword, SHOW_DETAIL); + // + // Followed by a multiple-event counter + // + Dword = (UINT32 *) (VarData + 1); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword); + break; + + default: + if (ElVdfType <= 0x7F) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_UNUSED_AVAIL_FOR_ASSIGN), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_SYSTEM), gShellDebug1HiiHandle); + } + } +} + +/** + Function to display system event log data. + + @param[in] LogData The data information. + @param[in] LogAreaLength Length of the data. +**/ +VOID +EFIAPI +DisplaySysEventLogData ( + UINT8 *LogData, + UINT16 LogAreaLength + ) +{ + LOG_RECORD_FORMAT *Log; + UINT8 ElVdfType; + // + // Event Log Variable Data Format Types + // + UINTN Offset; + + // + // Print prompt + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SYSTEM_EVENT_LOG_2), gShellDebug1HiiHandle); + + // + // Print Log info + // + Offset = 0; + Log = (LOG_RECORD_FORMAT *) LogData; + while (Log->Type != END_OF_LOG && Offset < LogAreaLength) { + // + // Get a Event Log Record + // + Log = (LOG_RECORD_FORMAT *) (LogData + Offset); + + // + // Display Event Log Record Information + // + DisplaySELVarDataFormatType (Log->Type, SHOW_DETAIL); + DisplaySELLogHeaderLen (Log->Length, SHOW_DETAIL); + + Offset += Log->Length; + + // + // Display Log Header Date/Time Fields + // These fields contain the BCD representation of the date and time + // (as read from CMOS) of the occurrence of the event + // So Print as hex and represent decimal + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle); + if (Log != NULL && Log->Year >= 80 && Log->Year <= 99) { + Print (L"19"); + } else if (Log != NULL && Log->Year <= 79) { + Print (L"20"); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle); + continue; + } + + ShellPrintHiiEx(-1,-1,NULL, + STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TIME_SIX_VARS), + gShellDebug1HiiHandle, + Log->Year, + Log->Month, + Log->Day, + Log->Hour, + Log->Minute, + Log->Second + ); + + // + // Display Variable Data Format + // + if (Log->Length <= (sizeof (LOG_RECORD_FORMAT) - 1)) { + continue; + } + + ElVdfType = Log->LogVariableData[0]; + DisplayElVdfInfo (ElVdfType, Log->LogVariableData); + } +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.h new file mode 100644 index 0000000000..62d7d77fdf --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.h @@ -0,0 +1,117 @@ +/** + Module to clarify system event log of smbios structure. + + Copyright (c) 2005-2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMBIOS_EVENT_LOG_INFO_H +#define _SMBIOS_EVENT_LOG_INFO_H + +#define END_OF_LOG 0xFF + +#pragma pack(1) + +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 Year; + UINT8 Month; + UINT8 Day; + UINT8 Hour; + UINT8 Minute; + UINT8 Second; + UINT8 LogVariableData[1]; +} LOG_RECORD_FORMAT; + +typedef struct { + UINT8 OEMReserved[5]; + UINT8 METW; // Multiple Event Time Window + UINT8 MECI; // Multiple Event Count Increment + UINT8 CMOSAddress; // Pre-boot Event Log Reset - CMOS Address + UINT8 CMOSBitIndex; // Pre-boot Event Log Reset - CMOS Bit Index + UINT8 StartingOffset; // CMOS Checksum - Starting Offset + UINT8 ByteCount; // CMOS Checksum - Byte Count + UINT8 ChecksumOffset; // CMOS Checksum - Checksum Offset + UINT8 Reserved[3]; + UINT8 HeaderRevision; +} LOG_HEADER_TYPE1_FORMAT; + +#pragma pack() +// +// System Event Log (Type 15) +// + +/** + Function to display system event log access information. + + @param[in] Key Additional information to print. + @param[in] Option Whether to print the additional information. +**/ +VOID +EFIAPI +DisplaySELAccessMethod ( + IN CONST UINT8 Key, + IN CONST UINT8 Option + ); + +/** + Function to display system event log status information. + + @param[in] Key Additional information to print. + @param[in] Option Whether to print the additional information. +**/ +VOID +EFIAPI +DisplaySELLogStatus ( + UINT8 Key, + UINT8 Option + ); + +/** + Function to display system event log header format information. + + @param[in] Key Additional information to print. + @param[in] Option Whether to print the additional information. +**/ +VOID +EFIAPI +DisplaySysEventLogHeaderFormat ( + UINT8 Key, + UINT8 Option + ); + +/** + Function to display system event log header information. + + @param[in] LogHeaderFormat Format identifier. + @param[in] LogHeader Format informcation. +**/ +VOID +EFIAPI +DisplaySysEventLogHeader ( + UINT8 LogHeaderFormat, + UINT8 *LogHeader + ); + +/** + Function to display system event log data. + + @param[in] LogData The data information. + @param[in] LogAreaLength Length of the data. +**/ +VOID +EFIAPI +DisplaySysEventLogData ( + UINT8 *LogData, + UINT16 LogAreaLength + ); + +#endif diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbios.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbios.h new file mode 100644 index 0000000000..d1ecc858ac --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbios.h @@ -0,0 +1,638 @@ +/** @file + Lib include for SMBIOS services. Used to get system serial number and GUID + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _LIB_SMBIOS_H +#define _LIB_SMBIOS_H + +// +// Define SMBIOS tables. +// +#pragma pack(1) + +typedef UINT8 SMBIOS_STRING; + +typedef struct { + UINT8 AnchorString[4]; + UINT8 EntryPointStructureChecksum; + UINT8 EntryPointLength; + UINT8 MajorVersion; + UINT8 MinorVersion; + UINT16 MaxStructureSize; + UINT8 EntryPointRevision; + UINT8 FormattedArea[5]; + UINT8 IntermediateAnchorString[5]; + UINT8 IntermediateChecksum; + UINT16 TableLength; + UINT32 TableAddress; + UINT16 NumberOfSmbiosStructures; + UINT8 SmbiosBcdRevision; +} SMBIOS_STRUCTURE_TABLE; + +// +// Please note that SMBIOS structures can be odd byte aligned since the +// unformated section of each record is a set of arbitrary size strings. +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Handle; +} SMBIOS_HEADER; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Vendor; + SMBIOS_STRING BiosVersion; + UINT16 BiosSegment; + SMBIOS_STRING BiosReleaseDate; + UINT8 BiosSize; + UINT64 BiosCharacteristics; + UINT8 BIOSCharacteristicsExtensionBytes[2]; + UINT8 SystemBiosMajorRelease; + UINT8 SystemBiosMinorRelease; + UINT8 EmbeddedControllerFirmwareMajorRelease; + UINT8 EmbeddedControllerFirmwareMinorRelease; +} SMBIOS_TYPE0; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Manufacturer; + SMBIOS_STRING ProductName; + SMBIOS_STRING Version; + SMBIOS_STRING SerialNumber; + EFI_GUID Uuid; + UINT8 WakeUpType; + SMBIOS_STRING SKUNumber; + SMBIOS_STRING Family; +} SMBIOS_TYPE1; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Manufacturer; + SMBIOS_STRING ProductName; + SMBIOS_STRING Version; + SMBIOS_STRING SerialNumber; + SMBIOS_STRING AssetTag; + UINT8 FeatureFlag; + SMBIOS_STRING LocationInChassis; + UINT16 ChassisHandle; + UINT8 BoardType; + UINT8 NumberOfContainedObjectHandles; + UINT16 ContainedObjectHandles[1]; +} SMBIOS_TYPE2; + +typedef struct { + UINT8 ContainedElementType; + UINT8 ContainedElementMinimum; + UINT8 ContainedElementMaximum; +} CONTAINED_ELEMENT; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Manufacturer; + UINT8 Type; + SMBIOS_STRING Version; + SMBIOS_STRING SerialNumber; + SMBIOS_STRING AssetTag; + UINT8 BootupState; + UINT8 PowerSupplyState; + UINT8 ThermalState; + UINT8 SecurityStatus; + UINT8 OemDefined[4]; + UINT8 Height; + UINT8 NumberofPowerCords; + UINT8 ContainedElementCount; + UINT8 ContainedElementRecordLength; + CONTAINED_ELEMENT ContainedElements[1]; +} SMBIOS_TYPE3; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 Socket; + UINT8 ProcessorType; + UINT8 ProcessorFamily; + SMBIOS_STRING ProcessorManufacture; + UINT8 ProcessorId[8]; + SMBIOS_STRING ProcessorVersion; + UINT8 Voltage; + UINT16 ExternalClock; + UINT16 MaxSpeed; + UINT16 CurrentSpeed; + UINT8 Status; + UINT8 ProcessorUpgrade; + UINT16 L1CacheHandle; + UINT16 L2CacheHandle; + UINT16 L3CacheHandle; + SMBIOS_STRING SerialNumber; + SMBIOS_STRING AssetTag; + SMBIOS_STRING PartNumber; + // + // Add for smbios 2.5 + // + UINT8 CoreCount; + UINT8 EnabledCoreCount; + UINT8 ThreadCount; + UINT16 ProcessorCharacteristics; + // + // Add for smbios 2.6 + // + UINT16 ProcessorFamily2; +} SMBIOS_TYPE4; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 ErrDetectMethod; + UINT8 ErrCorrectCapability; + UINT8 SupportInterleave; + UINT8 CurrentInterleave; + UINT8 MaxMemoryModuleSize; + UINT16 SupportSpeed; + UINT16 SupportMemoryType; + UINT8 MemoryModuleVoltage; + UINT8 AssociatedMemorySlotNum; + UINT16 MemoryModuleConfigHandles[1]; +} SMBIOS_TYPE5; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING SocketDesignation; + UINT8 BankConnections; + UINT8 CurrentSpeed; + UINT16 CurrentMemoryType; + UINT8 InstalledSize; + UINT8 EnabledSize; + UINT8 ErrorStatus; +} SMBIOS_TYPE6; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING SocketDesignation; + UINT16 CacheConfiguration; + UINT16 MaximumCacheSize; + UINT16 InstalledSize; + UINT16 SupportedSRAMType; + UINT16 CurrentSRAMType; + UINT8 CacheSpeed; + UINT8 ErrorCorrectionType; + UINT8 SystemCacheType; + UINT8 Associativity; +} SMBIOS_TYPE7; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING InternalReferenceDesignator; + UINT8 InternalConnectorType; + SMBIOS_STRING ExternalReferenceDesignator; + UINT8 ExternalConnectorType; + UINT8 PortType; +} SMBIOS_TYPE8; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING SlotDesignation; + UINT8 SlotType; + UINT8 SlotDataBusWidth; + UINT8 CurrentUsage; + UINT8 SlotLength; + UINT16 SlotID; + UINT8 SlotCharacteristics1; + UINT8 SlotCharacteristics2; + // + // Add for smbios 2.6 + // + UINT16 SegmentGroupNum; + UINT8 BusNum; + UINT8 DevFuncNum; +} SMBIOS_TYPE9; + +typedef struct DeviceStruct { + UINT8 DeviceType; + SMBIOS_STRING DescriptionString; +} DeviceStruct; + +typedef struct { + SMBIOS_HEADER Hdr; + DeviceStruct Device[1]; +} SMBIOS_TYPE10; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 StringCount; +} SMBIOS_TYPE11; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 StringCount; +} SMBIOS_TYPE12; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 InstallableLanguages; + UINT8 Flags; + UINT8 reserved[15]; + SMBIOS_STRING CurrentLanguages; +} SMBIOS_TYPE13; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING GroupName; + UINT8 ItemType; + UINT16 ItemHandle; +} SMBIOS_TYPE14; + +typedef struct EVENTLOGTYPE { + UINT8 LogType; + UINT8 DataFormatType; +} EVENTLOGTYPE; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT16 LogAreaLength; + UINT16 LogHeaderStartOffset; + UINT16 LogDataStartOffset; + UINT8 AccessMethod; + UINT8 LogStatus; + UINT32 LogChangeToken; + UINT32 AccessMethodAddress; + UINT8 LogHeaderFormat; + UINT8 NumberOfSupportedLogTypeDescriptors; + UINT8 LengthOfLogTypeDescriptor; + EVENTLOGTYPE EventLogTypeDescriptors[1]; +} SMBIOS_TYPE15; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 Location; + UINT8 Use; + UINT8 MemoryErrorCorrection; + UINT32 MaximumCapacity; + UINT16 MemoryErrorInformationHandle; + UINT16 NumberOfMemoryDevices; +} SMBIOS_TYPE16; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT16 MemoryArrayHandle; + UINT16 MemoryErrorInformationHandle; + UINT16 TotalWidth; + UINT16 DataWidth; + UINT16 Size; + UINT8 FormFactor; + UINT8 DeviceSet; + SMBIOS_STRING DeviceLocator; + SMBIOS_STRING BankLocator; + UINT8 MemoryType; + UINT16 TypeDetail; + UINT16 Speed; + SMBIOS_STRING Manufacturer; + SMBIOS_STRING SerialNumber; + SMBIOS_STRING AssetTag; + SMBIOS_STRING PartNumber; + // + // Add for smbios 2.6 + // + UINT8 Attributes; +} SMBIOS_TYPE17; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 ErrorType; + UINT8 ErrorGranularity; + UINT8 ErrorOperation; + UINT32 VendorSyndrome; + UINT32 MemoryArrayErrorAddress; + UINT32 DeviceErrorAddress; + UINT32 ErrorResolution; +} SMBIOS_TYPE18; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT32 StartingAddress; + UINT32 EndingAddress; + UINT16 MemoryArrayHandle; + UINT8 PartitionWidth; +} SMBIOS_TYPE19; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT32 StartingAddress; + UINT32 EndingAddress; + UINT16 MemoryDeviceHandle; + UINT16 MemoryArrayMappedAddressHandle; + UINT8 PartitionRowPosition; + UINT8 InterleavePosition; + UINT8 InterleavedDataDepth; +} SMBIOS_TYPE20; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 Type; + UINT8 Interface; + UINT8 NumberOfButtons; +} SMBIOS_TYPE21; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Location; + SMBIOS_STRING Manufacturer; + SMBIOS_STRING ManufactureDate; + SMBIOS_STRING SerialNumber; + SMBIOS_STRING DeviceName; + UINT8 DeviceChemistry; + UINT16 DeviceCapacity; + UINT16 DesignVoltage; + SMBIOS_STRING SBDSVersionNumber; + UINT8 MaximumErrorInBatteryData; + UINT16 SBDSSerialNumber; + UINT16 SBDSManufactureDate; + SMBIOS_STRING SBDSDeviceChemistry; + UINT8 DesignCapacityMultiplier; + UINT32 OEMSpecific; +} SMBIOS_TYPE22; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 Capabilities; + UINT16 ResetCount; + UINT16 ResetLimit; + UINT16 TimerInterval; + UINT16 Timeout; +} SMBIOS_TYPE23; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 HardwareSecuritySettings; +} SMBIOS_TYPE24; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 NextScheduledPowerOnMonth; + UINT8 NextScheduledPowerOnDayOfMonth; + UINT8 NextScheduledPowerOnHour; + UINT8 NextScheduledPowerOnMinute; + UINT8 NextScheduledPowerOnSecond; +} SMBIOS_TYPE25; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Description; + UINT8 LocationAndStatus; + UINT16 MaximumValue; + UINT16 MinimumValue; + UINT16 Resolution; + UINT16 Tolerance; + UINT16 Accuracy; + UINT32 OEMDefined; + UINT16 NominalValue; +} SMBIOS_TYPE26; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT16 TemperatureProbeHandle; + UINT8 DeviceTypeAndStatus; + UINT8 CoolingUnitGroup; + UINT32 OEMDefined; + UINT16 NominalSpeed; +} SMBIOS_TYPE27; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Description; + UINT8 LocationAndStatus; + UINT16 MaximumValue; + UINT16 MinimumValue; + UINT16 Resolution; + UINT16 Tolerance; + UINT16 Accuracy; + UINT32 OEMDefined; + UINT16 NominalValue; +} SMBIOS_TYPE28; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Description; + UINT8 LocationAndStatus; + UINT16 MaximumValue; + UINT16 MinimumValue; + UINT16 Resolution; + UINT16 Tolerance; + UINT16 Accuracy; + UINT32 OEMDefined; + UINT16 NominalValue; +} SMBIOS_TYPE29; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING ManufacturerName; + UINT8 Connections; +} SMBIOS_TYPE30; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 Checksum; + UINT8 Reserved1; + UINT16 Reserved2; + UINT32 BisEntry16; + UINT32 BisEntry32; + UINT64 Reserved3; + UINT32 Reserved4; +} SMBIOS_TYPE31; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 Reserved[6]; + UINT8 BootStatus[1]; +} SMBIOS_TYPE32; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 ErrorType; + UINT8 ErrorGranularity; + UINT8 ErrorOperation; + UINT32 VendorSyndrome; + UINT64 MemoryArrayErrorAddress; + UINT64 DeviceErrorAddress; + UINT32 ErrorResolution; +} SMBIOS_TYPE33; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Description; + UINT8 Type; + UINT32 Address; + UINT8 AddressType; +} SMBIOS_TYPE34; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Description; + UINT16 ManagementDeviceHandle; + UINT16 ComponentHandle; + UINT16 ThresholdHandle; +} SMBIOS_TYPE35; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT16 LowerThresholdNonCritical; + UINT16 UpperThresholdNonCritical; + UINT16 LowerThresholdCritical; + UINT16 UpperThresholdCritical; + UINT16 LowerThresholdNonRecoverable; + UINT16 UpperThresholdNonRecoverable; +} SMBIOS_TYPE36; + +typedef struct MEMORYDEVICE { + UINT8 DeviceLoad; + UINT16 DeviceHandle; +} MEMORYDEVICE; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 ChannelType; + UINT8 MaximumChannelLoad; + UINT8 MemoryDeviceCount; + MEMORYDEVICE MemoryDevice[1]; +} SMBIOS_TYPE37; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 InterfaceType; + UINT8 IPMISpecificationRevision; + UINT8 I2CSlaveAddress; + UINT8 NVStorageDeviceAddress; + UINT64 BaseAddress; +} SMBIOS_TYPE38; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 PowerUnitGroup; + SMBIOS_STRING Location; + SMBIOS_STRING DeviceName; + SMBIOS_STRING Manufacturer; + SMBIOS_STRING SerialNumber; + SMBIOS_STRING AssetTagNumber; + SMBIOS_STRING ModelPartNumber; + SMBIOS_STRING RevisionLevel; + UINT16 MaxPowerCapacity; + UINT16 PowerSupplyCharacteristics; + UINT16 InputVoltageProbeHandle; + UINT16 CoolingDeviceHandle; + UINT16 InputCurrentProbeHandle; +} SMBIOS_TYPE39; + +// +// Add type 40 and type 41 for smbios 2.6 +// +typedef struct { + UINT8 EntryLength; + UINT16 ReferencedHandle; + UINT8 ReferencedOffset; + SMBIOS_STRING EntryString; + UINT8 Value[1]; +} ADDITIONAL_INFORMATION_ENTRY; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 NumberOfAdditionalInformationEntries; + ADDITIONAL_INFORMATION_ENTRY AdditionalInfoEntries[1]; +} SMBIOS_TYPE40; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING ReferenceDesignation; + UINT8 DeviceType; + UINT8 DeviceTypeInstance; + UINT16 SegmentGroupNum; + UINT8 BusNum; + UINT8 DevFuncNum; +} SMBIOS_TYPE41; + +typedef struct { + SMBIOS_HEADER Hdr; +} SMBIOS_TYPE126; + +typedef struct { + SMBIOS_HEADER Hdr; +} SMBIOS_TYPE127; + +/* + Notes: + Among the following 42 type of structues for SMBIOS Stucture table, + There are only 11 Types(0,1,3,4,7,9,16,17,19,20,32) are required, + The other types is optional. +*/ +typedef union { + SMBIOS_HEADER *Hdr; + SMBIOS_TYPE0 *Type0; + SMBIOS_TYPE1 *Type1; + SMBIOS_TYPE2 *Type2; + SMBIOS_TYPE3 *Type3; + SMBIOS_TYPE4 *Type4; + SMBIOS_TYPE5 *Type5; + SMBIOS_TYPE6 *Type6; + SMBIOS_TYPE7 *Type7; + SMBIOS_TYPE8 *Type8; + SMBIOS_TYPE9 *Type9; + SMBIOS_TYPE10 *Type10; + SMBIOS_TYPE11 *Type11; + SMBIOS_TYPE12 *Type12; + SMBIOS_TYPE13 *Type13; + SMBIOS_TYPE14 *Type14; + SMBIOS_TYPE15 *Type15; + SMBIOS_TYPE16 *Type16; + SMBIOS_TYPE17 *Type17; + SMBIOS_TYPE18 *Type18; + SMBIOS_TYPE19 *Type19; + SMBIOS_TYPE20 *Type20; + SMBIOS_TYPE21 *Type21; + SMBIOS_TYPE22 *Type22; + SMBIOS_TYPE23 *Type23; + SMBIOS_TYPE24 *Type24; + SMBIOS_TYPE25 *Type25; + SMBIOS_TYPE26 *Type26; + SMBIOS_TYPE27 *Type27; + SMBIOS_TYPE28 *Type28; + SMBIOS_TYPE29 *Type29; + SMBIOS_TYPE30 *Type30; + SMBIOS_TYPE31 *Type31; + SMBIOS_TYPE32 *Type32; + SMBIOS_TYPE33 *Type33; + SMBIOS_TYPE34 *Type34; + SMBIOS_TYPE35 *Type35; + SMBIOS_TYPE36 *Type36; + SMBIOS_TYPE37 *Type37; + SMBIOS_TYPE38 *Type38; + SMBIOS_TYPE39 *Type39; + SMBIOS_TYPE40 *Type40; + SMBIOS_TYPE41 *Type41; + SMBIOS_TYPE126 *Type126; + SMBIOS_TYPE127 *Type127; + UINT8 *Raw; +} SMBIOS_STRUCTURE_POINTER; + +#pragma pack() + +CHAR8 * +LibGetSmbiosString ( + IN SMBIOS_STRUCTURE_POINTER *Smbios, + IN UINT16 StringNumber + ); + +EFI_STATUS +LibGetSmbiosSystemGuidAndSerialNumber ( + IN EFI_GUID *SystemGuid, + OUT CHAR8 **SystemSerialNumber + ); + + +#endif diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.c new file mode 100644 index 0000000000..22a8065a01 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.c @@ -0,0 +1,349 @@ +/** @file + API for SMBIOS table. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + + +#include "../UefiShellDebug1CommandsLib.h" +#include +#include "LIbSmbios.h" +#include "LibSmbiosView.h" +#include "smbiosview.h" + +STATIC UINT8 mInit = 0; +STATIC SMBIOS_STRUCTURE_TABLE *mSmbiosTable = NULL; +STATIC SMBIOS_STRUCTURE_POINTER m_SmbiosStruct; +STATIC SMBIOS_STRUCTURE_POINTER *mSmbiosStruct = &m_SmbiosStruct; + +EFI_STATUS +LibSmbiosInit ( + VOID + ) +/*++ + +Routine Description: + Init the SMBIOS VIEW API's environment. + + Arguments: + None + +Returns: + EFI_SUCCESS - Successful to init the SMBIOS VIEW Lib + Others - Cannot get SMBIOS Table + +**/ +{ + EFI_STATUS Status; + + // + // Init only once + // + if (mInit == 1) { + return EFI_SUCCESS; + } + // + // Get SMBIOS table from System Configure table + // + Status = GetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID**)&mSmbiosTable); + + if (mSmbiosTable == NULL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_CANNOT_GET_TABLE), gShellDebug1HiiHandle); + return EFI_NOT_FOUND; + } + + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_GET_TABLE_ERROR), gShellDebug1HiiHandle, Status); + return Status; + } + // + // Init SMBIOS structure table address + // + mSmbiosStruct->Raw = (UINT8 *) (UINTN) (mSmbiosTable->TableAddress); + + mInit = 1; + return EFI_SUCCESS; +} + +VOID +LibSmbiosCleanup ( + VOID + ) +{ + // + // Release resources + // + if (mSmbiosTable != NULL) { + mSmbiosTable = NULL; + } + + mInit = 0; +} + +VOID +LibSmbiosGetEPS ( + SMBIOS_STRUCTURE_TABLE **pEntryPointStructure + ) +{ + // + // return SMBIOS Table address + // + *pEntryPointStructure = mSmbiosTable; +} + +VOID +LibSmbiosGetStructHead ( + SMBIOS_STRUCTURE_POINTER *pHead + ) +{ + // + // return SMBIOS structure table address + // + pHead = mSmbiosStruct; +} + +EFI_STATUS +LibGetSmbiosInfo ( + OUT CHAR8 *dmiBIOSRevision, + OUT UINT16 *NumStructures, + OUT UINT16 *StructureSize, + OUT UINT32 *dmiStorageBase, + OUT UINT16 *dmiStorageSize + ) +/*++ + +Routine Description: + Get SMBIOS Information. + + Arguments: + dmiBIOSRevision - Revision of the SMBIOS Extensions. + NumStructures - Max. Number of Structures the BIOS will return. + StructureSize - Size of largest SMBIOS Structure. + dmiStorageBase - 32-bit physical base address for memory mapped SMBIOS data. + dmiStorageSize - Size of the memory-mapped SMBIOS data. + + Returns: + DMI_SUCCESS - successful. + DMI_FUNCTION_NOT_SUPPORTED - Does not support SMBIOS calling interface capability. + +**/ +{ + // + // If no SMIBOS table, unsupported. + // + if (mSmbiosTable == NULL) { + return DMI_FUNCTION_NOT_SUPPORTED; + } + + *dmiBIOSRevision = mSmbiosTable->SmbiosBcdRevision; + *NumStructures = mSmbiosTable->NumberOfSmbiosStructures; + *StructureSize = mSmbiosTable->MaxStructureSize; + *dmiStorageBase = mSmbiosTable->TableAddress; + *dmiStorageSize = mSmbiosTable->TableLength; + + return DMI_SUCCESS; +} + +EFI_STATUS +LibGetSmbiosStructure ( + IN OUT UINT16 *Handle, + IN OUT UINT8 *Buffer, + OUT UINT16 *Length + ) +/*++ + + Routine Description: + Get SMBIOS structure given the Handle,copy data to the Buffer, + Handle is changed to the next handle or 0xFFFF when the end is + reached or the handle is not found. + + Arguments: + Handle: - 0xFFFF: get the first structure + - Others: get a structure according to this value. + Buffter: - The pointer to the caller's memory buffer. + Length: - Length of return buffer in bytes. + + Returns: + DMI_SUCCESS - Buffer contains the required structure data + - Handle is updated with next structure handle or + 0xFFFF(end-of-list). + + DMI_INVALID_HANDLE - Buffer not contain the requiring structure data + - Handle is updated with next structure handle or + 0xFFFF(end-of-list). +**/ +{ + SMBIOS_STRUCTURE_POINTER Smbios; + SMBIOS_STRUCTURE_POINTER SmbiosEnd; + UINT8 *Raw; + + if (*Handle == INVALIDE_HANDLE) { + *Handle = mSmbiosStruct->Hdr->Handle; + return DMI_INVALID_HANDLE; + } + + if (Buffer == NULL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_NO_BUFF_SPEC), gShellDebug1HiiHandle); + return DMI_INVALID_HANDLE; + } + + *Length = 0; + Smbios.Hdr = mSmbiosStruct->Hdr; + SmbiosEnd.Raw = Smbios.Raw + mSmbiosTable->TableLength; + while (Smbios.Raw < SmbiosEnd.Raw) { + if (Smbios.Hdr->Handle == *Handle) { + Raw = Smbios.Raw; + // + // Walk to next structure + // + LibGetSmbiosString (&Smbios, (UINT16) (-1)); + // + // Length = Next structure head - this structure head + // + *Length = (UINT16) (Smbios.Raw - Raw); + CopyMem (Buffer, Raw, *Length); + // + // update with the next structure handle. + // + if (Smbios.Raw < SmbiosEnd.Raw) { + *Handle = Smbios.Hdr->Handle; + } else { + *Handle = INVALIDE_HANDLE; + } + return DMI_SUCCESS; + } + // + // Walk to next structure + // + LibGetSmbiosString (&Smbios, (UINT16) (-1)); + } + + *Handle = INVALIDE_HANDLE; + return DMI_INVALID_HANDLE; +} + +EFI_STATUS +SmbiosCheckStructure ( + IN SMBIOS_STRUCTURE_POINTER *Smbios + ) +/*++ + + Routine Description: + Check the structure to see if it is legal. + + Arguments: + Smbios - Pointer to the structure that will be checked. + + Returns: + DMI_SUCCESS - Structure data is legal. + DMI_BAD_PARAMETER - Structure data contains bad parameter + +**/ +{ + // + // If key != value, then error. + // +#define CHECK_VALUE(key, value) (((key) == (value)) ? EFI_SUCCESS : DMI_BAD_PARAMETER) + + EFI_STATUS Status; + // + // Assume staus is EFI_SUCCESS, + // but if check is error, then EFI_ERROR. + // + Status = EFI_SUCCESS; + + switch (Smbios->Hdr->Type) { + case 0: + break; + + case 1: + if (Smbios->Type1->Hdr.Length == 0x08 || Smbios->Type0->Hdr.Length == 0x19) { + Status = EFI_SUCCESS; + } else { + Status = DMI_BAD_PARAMETER; + } + break; + + case 2: + Status = CHECK_VALUE (Smbios->Type2->Hdr.Length, 0x08); + break; + + case 6: + Status = CHECK_VALUE (Smbios->Type6->Hdr.Length, 0x0C); + break; + + case 11: + Status = CHECK_VALUE (Smbios->Type11->Hdr.Length, 0x05); + break; + + case 12: + Status = CHECK_VALUE (Smbios->Type12->Hdr.Length, 0x05); + break; + + case 13: + Status = CHECK_VALUE (Smbios->Type13->Hdr.Length, 0x16); + break; + + case 16: + Status = CHECK_VALUE (Smbios->Type16->Hdr.Length, 0x0F); + break; + + case 19: + Status = CHECK_VALUE (Smbios->Type19->Hdr.Length, 0x0F); + break; + + case 20: + Status = CHECK_VALUE (Smbios->Type20->Hdr.Length, 0x13); + break; + + case 32: + // + // Because EFI_SUCCESS == 0, + // So errors added up is also error. + // + Status = CHECK_VALUE (Smbios->Type32->Reserved[0], 0x00) + + CHECK_VALUE (Smbios->Type32->Reserved[1], 0x00) + + CHECK_VALUE (Smbios->Type32->Reserved[2], 0x00) + + CHECK_VALUE (Smbios->Type32->Reserved[3], 0x00) + + CHECK_VALUE (Smbios->Type32->Reserved[4], 0x00) + + CHECK_VALUE (Smbios->Type32->Reserved[5], 0x00); + break; + + default: + Status = DMI_BAD_PARAMETER; + } + + return Status; +} + +VOID +SmbiosGetPendingString ( + IN SMBIOS_STRUCTURE_POINTER *Smbios, + IN UINT16 StringNumber, + OUT CHAR8 *Buffer + ) +{ + CHAR8 *String; + if (Buffer == NULL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_NO_BUF_SPEC_WHEN_STRUCT), gShellDebug1HiiHandle); + return ; + } + // + // Get string and copy to buffer. + // Caller should provide the buffer. + // + String = LibGetSmbiosString (Smbios, StringNumber); + if (String != NULL) { + CopyMem (Buffer, String, AsciiStrLen(String)); + } else { + Buffer = NULL; + } +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.h new file mode 100644 index 0000000000..7ef341b0d6 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.h @@ -0,0 +1,120 @@ +/** @file + API for SMBIOS Plug and Play functions, access to SMBIOS table and structures. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _LIB_SMBIOS_VIEW_H +#define _LIB_SMBIOS_VIEW_H + +#include "LibSmbios.h" + +#define DMI_SUCCESS 0x00 +#define DMI_UNKNOWN_FUNCTION 0x81 +#define DMI_FUNCTION_NOT_SUPPORTED 0x82 +#define DMI_INVALID_HANDLE 0x83 +#define DMI_BAD_PARAMETER 0x84 +#define DMI_INVALID_SUBFUNCTION 0x85 +#define DMI_NO_CHANGE 0x86 +#define DMI_ADD_STRUCTURE_FAILED 0x87 +#define DMI_READ_ONLY 0x8D +#define DMI_LOCK_NOT_SUPPORTED 0x90 +#define DMI_CURRENTLY_LOCKED 0x91 +#define DMI_INVALID_LOCK 0x92 + +#define INVALIDE_HANDLE (UINT16) (-1) + +#define EFI_SMBIOSERR(val) EFIERR (0x30000 | val) + +#define EFI_SMBIOSERR_FAILURE EFI_SMBIOSERR (1) +#define EFI_SMBIOSERR_STRUCT_NOT_FOUND EFI_SMBIOSERR (2) +#define EFI_SMBIOSERR_TYPE_UNKNOWN EFI_SMBIOSERR (3) +#define EFI_SMBIOSERR_UNSUPPORTED EFI_SMBIOSERR (4) + +EFI_STATUS +LibSmbiosInit ( + VOID + ); + +VOID +LibSmbiosCleanup ( + VOID + ); + +VOID +LibSmbiosGetEPS ( + SMBIOS_STRUCTURE_TABLE **pEntryPointStructure + ); + +VOID +LibSmbiosGetStructHead ( + SMBIOS_STRUCTURE_POINTER *pHead + ); + +EFI_STATUS +LibGetSmbiosInfo ( + OUT CHAR8 *dmiBIOSRevision, + OUT UINT16 *NumStructures, + OUT UINT16 *StructureSize, + OUT UINT32 *dmiStorageBase, + OUT UINT16 *dmiStorageSize + ); + +/*++ + Description: + Get SMBIOS Information. + + Arguments: + dmiBIOSRevision - Revision of the SMBIOS Extensions. + NumStructures - Max. Number of Structures the BIOS will return. + StructureSize - Size of largest SMBIOS Structure. + dmiStorageBase - 32-bit physical base address for memory mapped SMBIOS data. + dmiStorageSize - Size of the memory-mapped SMBIOS data. + + Returns: + DMI_SUCCESS - successful. + DMI_FUNCTION_NOT_SUPPORTED - Does not support SMBIOS calling interface capability. +**/ +EFI_STATUS +LibGetSmbiosStructure ( + IN OUT UINT16 *Handle, + IN OUT UINT8 *Buffer, + OUT UINT16 *Length + ); + +/*++ + Description: + Get SMBIOS structure given the Handle,copy data to the Buffer,Handle is then the next. + + Arguments: + Handle: - 0x0: get the first structure + - Others: get a certain structure according to this value. + Buffter: - contains the pointer to the caller's memory buffer. + + Returns: + DMI_SUCCESS - Buffer contains the required structure data + - Handle is updated with next structure handle or 0xFFFF(end-of-list). + DMI_INVALID_HANDLE - Buffer not contain the requiring structure data + - Handle is updated with next structure handle or 0xFFFF(end-of-list). +**/ +VOID +SmbiosGetPendingString ( + IN SMBIOS_STRUCTURE_POINTER *Smbios, + IN UINT16 StringNumber, + OUT CHAR8 *Buffer + ); + +EFI_STATUS +SmbiosCheckStructure ( + IN SMBIOS_STRUCTURE_POINTER *Smbios + ); + +#endif diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c new file mode 100644 index 0000000000..91835106d5 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c @@ -0,0 +1,2679 @@ +/** @file + Module for clarifying the content of the smbios structure element information. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "../UefiShellDebug1CommandsLib.h" +#include "PrintInfo.h" +#include "LibSmbiosView.h" +#include "QueryTable.h" +#include "EventLogInfo.h" + + +// +// Get the certain bit of 'value' +// +#define BIT(value, bit) ((value) & ((UINT64) 1) << (bit)) + +// +////////////////////////////////////////////////////////// +// Macros of print structure element, simplify coding. +// +#define PrintPendingString(pStruct, type, element) \ + do { \ + CHAR8 StringBuf[64]; \ + SetMem (StringBuf, sizeof (StringBuf), 0x00); \ + SmbiosGetPendingString ((pStruct), (pStruct->type->element), StringBuf); \ + ShellPrintEx(-1,-1,L"%a",#element); \ + ShellPrintEx(-1,-1,L": %a\n", StringBuf); \ + } while (0); + +#define PrintSmbiosString(pStruct, stringnumber, element) \ + do { \ + CHAR8 StringBuf[64]; \ + SetMem (StringBuf, sizeof (StringBuf), 0x00); \ + SmbiosGetPendingString ((pStruct), (stringnumber), StringBuf); \ + ShellPrintEx(-1,-1,L"%a",#element); \ + ShellPrintEx(-1,-1,L": %a\n", StringBuf); \ + } while (0); + +#define PrintStructValue(pStruct, type, element) \ + do { \ + ShellPrintEx(-1,-1,L"%a",#element); \ + ShellPrintEx(-1,-1,L": %d\n", (pStruct->type->element)); \ + } while (0); + +#define PrintStructValueH(pStruct, type, element) \ + do { \ + ShellPrintEx(-1,-1,L"%a",#element); \ + ShellPrintEx(-1,-1,L": 0x%x\n", (pStruct->type->element)); \ + } while (0); + +#define PrintBitField(pStruct, type, element, size) \ + do { \ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DUMP), gShellDebug1HiiHandle); \ + ShellPrintEx(-1,-1,L"%a",#element); \ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SIZE), gShellDebug1HiiHandle, size); \ + DumpHex (0, 0, size, &(pStruct->type->element)); \ + } while (0); + +#define PrintSmbiosBitField(pStruct, startaddress, element, size) \ + do { \ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DUMP), gShellDebug1HiiHandle); \ + ShellPrintEx(-1,-1,L"%a",#element); \ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SIZE), gShellDebug1HiiHandle, size); \ + DumpHex (0, 0, size, startaddress); \ + } while (0); + +// +///////////////////////////////////////// +// +VOID +MemToString ( + IN OUT VOID *Dest, + IN VOID *Src, + IN UINTN Length + ) +/*++ + +Routine Description: + Copy Length of Src buffer to Dest buffer, + add a NULL termination to Dest buffer. + +Arguments: + Dest - Destination buffer head + Src - Source buffer head + Length - Length of buffer to be copied + +Returns: + None. + +**/ +{ + UINT8 *SrcBuffer; + UINT8 *DestBuffer; + SrcBuffer = (UINT8 *) Src; + DestBuffer = (UINT8 *) Dest; + // + // copy byte by byte + // + while ((Length--)!=0) { + *DestBuffer++ = *SrcBuffer++; + } + // + // append a NULL terminator + // + *DestBuffer = '\0'; +} + +// +////////////////////////////////////////////// +// +// Functions below is to show the information +// +VOID +SmbiosPrintEPSInfo ( + IN SMBIOS_STRUCTURE_TABLE *SmbiosTable, + IN UINT8 Option + ) +/*++ + +Routine Description: + Print the info of EPS(Entry Point Structure) + +Arguments: + SmbiosTable - Pointer to the SMBIOS table entry point + Option - Display option + +Returns: None + +**/ +{ + UINT8 Anchor[5]; + UINT8 InAnchor[6]; + + if (SmbiosTable == NULL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SMBIOSTABLE_NULL), gShellDebug1HiiHandle); + return ; + } + + if (Option == SHOW_NONE) { + return ; + } + + if (Option >= SHOW_NORMAL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_SIGN), gShellDebug1HiiHandle); + MemToString (Anchor, SmbiosTable->AnchorString, 4); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle, Anchor); + ShellPrintHiiEx(-1,-1,NULL, + STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_EPS_CHECKSUM), + gShellDebug1HiiHandle, + SmbiosTable->EntryPointStructureChecksum + ); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_LEN), gShellDebug1HiiHandle, SmbiosTable->EntryPointLength); + ShellPrintHiiEx(-1,-1,NULL, + STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VERSION), + gShellDebug1HiiHandle, + SmbiosTable->MajorVersion, + SmbiosTable->MinorVersion + ); + ShellPrintHiiEx(-1,-1,NULL, + STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NUMBER_STRUCT), + gShellDebug1HiiHandle, + SmbiosTable->NumberOfSmbiosStructures + ); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MAX_STRUCT_SIZE), gShellDebug1HiiHandle, SmbiosTable->MaxStructureSize); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_TABLE_ADDR), gShellDebug1HiiHandle, SmbiosTable->TableAddress); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_TABLE_LENGTH), gShellDebug1HiiHandle, SmbiosTable->TableLength); + + } + // + // If SHOW_ALL, also print followings. + // + if (Option >= SHOW_DETAIL) { + ShellPrintHiiEx(-1,-1,NULL, + STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_REVISION), + gShellDebug1HiiHandle, + SmbiosTable->EntryPointRevision + ); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BCD_REVISION), gShellDebug1HiiHandle, SmbiosTable->SmbiosBcdRevision); + // + // Since raw data is not string, add a NULL terminater. + // + MemToString (InAnchor, SmbiosTable->IntermediateAnchorString, 5); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTER_ACHOR), gShellDebug1HiiHandle, InAnchor); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTER_CHECKSUM), gShellDebug1HiiHandle, SmbiosTable->IntermediateChecksum); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FORMATTED_AREA), gShellDebug1HiiHandle); + DumpHex (2, 0, 5, SmbiosTable->FormattedArea); + } + + Print (L"\n"); +} + +EFI_STATUS +SmbiosPrintStructure ( + IN SMBIOS_STRUCTURE_POINTER *pStruct, + IN UINT8 Option + ) +/*++ + +Routine Description: + This function print the content of the structure pointed by pStruct + +Arguments: + pStruct - point to the structure to be printed + Option - print option of information detail + +Returns: + EFI_SUCCESS - Successfully Printing this function + EFI_INVALID_PARAMETER - Invalid Structure + EFI_UNSUPPORTED - Unsupported + +**/ +{ + UINT8 Index; + UINT8 *Buffer; + + Buffer = (UINT8 *) (UINTN) (pStruct->Raw); + + if (pStruct == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (Option == SHOW_NONE) { + return EFI_SUCCESS; + } + // + // Display structure header + // + DisplayStructureTypeInfo (pStruct->Hdr->Type, SHOW_DETAIL); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FORMAT_PART_LEN), gShellDebug1HiiHandle, pStruct->Hdr->Length); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, pStruct->Hdr->Handle); + + if (Option == SHOW_OUTLINE) { + return EFI_SUCCESS; + } + + switch (pStruct->Hdr->Type) { + // + // + // + case 0: + PrintPendingString (pStruct, Type0, Vendor); + PrintPendingString (pStruct, Type0, BiosVersion); + PrintStructValue (pStruct, Type0, BiosSegment); + PrintPendingString (pStruct, Type0, BiosReleaseDate); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_SIZE), gShellDebug1HiiHandle, 64 * (pStruct->Type0->BiosSize + 1)); + + if (Option < SHOW_DETAIL) { + PrintStructValueH (pStruct, Type0, BiosCharacteristics); + } else { + DisplayBiosCharacteristics (pStruct->Type0->BiosCharacteristics, Option); + + // + // The length of above format part is 0x12 bytes, + // Ext bytes are following, size = 'len-0x12'. + // If len-0x12 > 0, then + // there are extension bytes (byte1, byte2, byte3...) + // And byte3 not stated in spec, so dump all extension bytes(1, 2, 3..) + // + if ((Buffer[1] - (CHAR8) 0x12) > 0) { + DisplayBiosCharacteristicsExt1 (Buffer[0x12], Option); + } + + if ((Buffer[1] - (CHAR8) 0x12) > 1) { + DisplayBiosCharacteristicsExt2 (Buffer[0x13], Option); + } + + if ((Buffer[1] - (CHAR8) 0x12) > 2) { + PrintBitField ( + pStruct, + Type0, + BiosCharacteristics, + Buffer[1] - (CHAR8) 0x12 + ); + } + } + break; + + // + // System Information (Type 1) + // + case 1: + PrintPendingString (pStruct, Type1, Manufacturer); + PrintPendingString (pStruct, Type1, ProductName); + PrintPendingString (pStruct, Type1, Version); + PrintPendingString (pStruct, Type1, SerialNumber); + PrintBitField (pStruct, Type1, Uuid, 16); + DisplaySystemWakeupType (pStruct->Type1->WakeUpType, Option); + break; + + case 2: + PrintPendingString (pStruct, Type2, Manufacturer); + PrintPendingString (pStruct, Type2, ProductName); + PrintPendingString (pStruct, Type2, Version); + PrintPendingString (pStruct, Type2, SerialNumber); + break; + + // + // System Enclosure (Type 3) + // + case 3: + PrintPendingString (pStruct, Type3, Manufacturer); + PrintStructValue (pStruct, Type3, Type); + DisplaySystemEnclosureType (pStruct->Type3->Type, Option); + PrintPendingString (pStruct, Type3, Version); + PrintPendingString (pStruct, Type3, SerialNumber); + PrintPendingString (pStruct, Type3, AssetTag); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BOOTUP_STATE), gShellDebug1HiiHandle); + DisplaySystemEnclosureStatus (pStruct->Type3->BootupState, Option); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_STATE), gShellDebug1HiiHandle); + DisplaySystemEnclosureStatus (pStruct->Type3->PowerSupplyState, Option); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_THERMAL_STATE), gShellDebug1HiiHandle); + DisplaySystemEnclosureStatus (pStruct->Type3->ThermalState, Option); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SECURITY_STATUS), gShellDebug1HiiHandle); + DisplaySESecurityStatus (pStruct->Type3->SecurityStatus, Option); + PrintBitField (pStruct, Type3, OemDefined, 4); + break; + + // + // Processor Information (Type 4) + // + case 4: + PrintStructValue (pStruct, Type4, Socket); + DisplayProcessorType (pStruct->Type4->ProcessorType, Option); + if ((SmbiosMajorVersion > 0x2 || (SmbiosMajorVersion == 0x2 && SmbiosMinorVersion >= 0x6)) && + (pStruct->Type4->ProcessorFamily == 0xFE)) { + // + // Get family from ProcessorFamily2 field + // + DisplayProcessorFamily2 (pStruct->Type4->ProcessorFamily2, Option); + } else { + DisplayProcessorFamily (pStruct->Type4->ProcessorFamily, Option); + } + PrintPendingString (pStruct, Type4, ProcessorManufacture); + PrintBitField (pStruct, Type4, ProcessorId, 8); + PrintPendingString (pStruct, Type4, ProcessorVersion); + DisplayProcessorVoltage (pStruct->Type4->Voltage, Option); + PrintStructValue (pStruct, Type4, ExternalClock); + PrintStructValue (pStruct, Type4, MaxSpeed); + PrintStructValue (pStruct, Type4, CurrentSpeed); + DisplayProcessorStatus (pStruct->Type4->Status, Option); + DisplayProcessorUpgrade (pStruct->Type4->ProcessorUpgrade, Option); + PrintStructValueH (pStruct, Type4, L1CacheHandle); + PrintStructValueH (pStruct, Type4, L2CacheHandle); + PrintStructValueH (pStruct, Type4, L3CacheHandle); + PrintPendingString (pStruct, Type4, SerialNumber); + PrintPendingString (pStruct, Type4, AssetTag); + PrintPendingString (pStruct, Type4, PartNumber); + if (SmbiosMajorVersion > 0x2 || (SmbiosMajorVersion == 0x2 && SmbiosMinorVersion >= 0x5)) { + PrintStructValue (pStruct, Type4, CoreCount); + PrintStructValue (pStruct, Type4, EnabledCoreCount); + PrintStructValue (pStruct, Type4, ThreadCount); + PrintStructValueH (pStruct, Type4, ProcessorCharacteristics); + } + break; + + // + // Memory Controller Information (Type 5) + // + case 5: + { + UINT8 SlotNum; + SlotNum = pStruct->Type5->AssociatedMemorySlotNum; + + DisplayMcErrorDetectMethod (pStruct->Type5->ErrDetectMethod, Option); + DisplayMcErrorCorrectCapability (pStruct->Type5->ErrCorrectCapability, Option); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SUPOPRT), gShellDebug1HiiHandle); + DisplayMcInterleaveSupport (pStruct->Type5->SupportInterleave, Option); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CURRENT), gShellDebug1HiiHandle); + DisplayMcInterleaveSupport (pStruct->Type5->CurrentInterleave, Option); + DisplayMaxMemoryModuleSize (pStruct->Type5->MaxMemoryModuleSize, SlotNum, Option); + DisplayMcMemorySpeeds (pStruct->Type5->SupportSpeed, Option); + DisplayMmMemoryType (pStruct->Type5->SupportMemoryType, Option); + DisplayMemoryModuleVoltage (pStruct->Type5->MemoryModuleVoltage, Option); + PrintStructValue (pStruct, Type5, AssociatedMemorySlotNum); + // + // According to SMBIOS Specification, offset 0x0F + // + DisplayMemoryModuleConfigHandles ((UINT16 *) (&Buffer[0x0F]), SlotNum, Option); + DisplayMcErrorCorrectCapability (Buffer[0x0F + 2 * SlotNum], Option); + } + break; + + // + // Memory Module Information (Type 6) + // + case 6: + PrintPendingString (pStruct, Type6, SocketDesignation); + DisplayMmBankConnections (pStruct->Type6->BankConnections, Option); + PrintStructValue (pStruct, Type6, CurrentSpeed); + DisplayMmMemoryType (pStruct->Type6->CurrentMemoryType, Option); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INSTALLED), gShellDebug1HiiHandle); + DisplayMmMemorySize (pStruct->Type6->InstalledSize, Option); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED), gShellDebug1HiiHandle); + DisplayMmMemorySize (pStruct->Type6->EnabledSize, Option); + DisplayMmErrorStatus (pStruct->Type6->ErrorStatus, Option); + break; + + // + // Cache Information (Type 7) + // + case 7: + PrintPendingString (pStruct, Type7, SocketDesignation); + PrintStructValueH (pStruct, Type7, CacheConfiguration); + PrintStructValueH (pStruct, Type7, MaximumCacheSize); + PrintStructValueH (pStruct, Type7, InstalledSize); + PrintStructValueH (pStruct, Type7, SupportedSRAMType); + PrintStructValueH (pStruct, Type7, CurrentSRAMType); + DisplayCacheSRAMType (pStruct->Type7->CurrentSRAMType, Option); + PrintStructValueH (pStruct, Type7, CacheSpeed); + DisplayCacheErrCorrectingType (pStruct->Type7->ErrorCorrectionType, Option); + DisplayCacheSystemCacheType (pStruct->Type7->SystemCacheType, Option); + DisplayCacheAssociativity (pStruct->Type7->Associativity, Option); + break; + + // + // Port Connector Information (Type 8) + // + case 8: + PrintPendingString (pStruct, Type8, InternalReferenceDesignator); + Print (L"Internal "); + DisplayPortConnectorType (pStruct->Type8->InternalConnectorType, Option); + PrintPendingString (pStruct, Type8, ExternalReferenceDesignator); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_EXTERNAL), gShellDebug1HiiHandle); + DisplayPortConnectorType (pStruct->Type8->ExternalConnectorType, Option); + DisplayPortType (pStruct->Type8->PortType, Option); + break; + + // + // System Slots (Type 9) + // + case 9: + PrintPendingString (pStruct, Type9, SlotDesignation); + DisplaySystemSlotType (pStruct->Type9->SlotType, Option); + DisplaySystemSlotDataBusWidth (pStruct->Type9->SlotDataBusWidth, Option); + DisplaySystemSlotCurrentUsage (pStruct->Type9->CurrentUsage, Option); + DisplaySystemSlotLength (pStruct->Type9->SlotLength, Option); + DisplaySystemSlotId ( + pStruct->Type9->SlotID, + pStruct->Type9->SlotType, + Option + ); + DisplaySlotCharacteristics1 (pStruct->Type9->SlotCharacteristics1, Option); + DisplaySlotCharacteristics2 (pStruct->Type9->SlotCharacteristics2, Option); + if (SmbiosMajorVersion > 0x2 || (SmbiosMajorVersion == 0x2 && SmbiosMinorVersion >= 0x6)) { + PrintStructValueH (pStruct, Type9, SegmentGroupNum); + PrintStructValueH (pStruct, Type9, BusNum); + PrintStructValueH (pStruct, Type9, DevFuncNum); + } + break; + + // + // On Board Devices Information (Type 10) + // + case 10: + { + UINTN NumOfDevice; + NumOfDevice = (pStruct->Type10->Hdr.Length - sizeof (SMBIOS_HEADER)) / (2 * sizeof (UINT8)); + for (Index = 0; Index < NumOfDevice; Index++) { + DisplayOnboardDeviceTypes (pStruct->Type10->Device[Index].DeviceType, Option); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DESC_STRING), gShellDebug1HiiHandle); + ShellPrintEx(-1,-1,L"%a",LibGetSmbiosString (pStruct, pStruct->Type10->Device[Index].DescriptionString)); + } + } + break; + + case 11: + PrintStructValue (pStruct, Type11, StringCount); + for (Index = 1; Index <= pStruct->Type11->StringCount; Index++) { + ShellPrintEx(-1,-1,L"%a\n", LibGetSmbiosString (pStruct, Index)); + } + break; + + case 12: + PrintStructValue (pStruct, Type12, StringCount); + for (Index = 1; Index <= pStruct->Type12->StringCount; Index++) { + ShellPrintEx(-1,-1,L"%a\n", LibGetSmbiosString (pStruct, Index)); + } + break; + + case 13: + PrintStructValue (pStruct, Type13, InstallableLanguages); + PrintStructValue (pStruct, Type13, Flags); + PrintBitField (pStruct, Type13, reserved, 15); + PrintPendingString (pStruct, Type13, CurrentLanguages); + break; + + case 14: + PrintPendingString (pStruct, Type14, GroupName); + PrintStructValue (pStruct, Type14, ItemType); + PrintStructValue (pStruct, Type14, ItemHandle); + break; + + // + // System Event Log (Type 15) + // + case 15: + { + EVENTLOGTYPE *Ptr; + UINT8 Count; + UINT8 *AccessMethodAddress; + + PrintStructValueH (pStruct, Type15, LogAreaLength); + PrintStructValueH (pStruct, Type15, LogHeaderStartOffset); + PrintStructValueH (pStruct, Type15, LogDataStartOffset); + DisplaySELAccessMethod (pStruct->Type15->AccessMethod, Option); + PrintStructValueH (pStruct, Type15, AccessMethodAddress); + DisplaySELLogStatus (pStruct->Type15->LogStatus, Option); + PrintStructValueH (pStruct, Type15, LogChangeToken); + DisplaySysEventLogHeaderFormat (pStruct->Type15->LogHeaderFormat, Option); + PrintStructValueH (pStruct, Type15, NumberOfSupportedLogTypeDescriptors); + PrintStructValueH (pStruct, Type15, LengthOfLogTypeDescriptor); + + Count = pStruct->Type15->NumberOfSupportedLogTypeDescriptors; + if (Count > 0) { + Ptr = pStruct->Type15->EventLogTypeDescriptors; + + // + // Display all Event Log type descriptors supported by system + // + for (Index = 0; Index < Count; Index++, Ptr++) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SUPOPRTED_EVENT), gShellDebug1HiiHandle, Index + 1); + DisplaySELTypes (Ptr->LogType, Option); + DisplaySELVarDataFormatType (Ptr->DataFormatType, Option); + } + + if (Option >= SHOW_DETAIL) { + switch (pStruct->Type15->AccessMethod) { + case 03: + AccessMethodAddress = (UINT8 *) (UINTN) (pStruct->Type15->AccessMethodAddress); + break; + + case 00: + case 01: + case 02: + case 04: + default: + ShellPrintHiiEx(-1,-1,NULL, + STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ACCESS_METHOD_NOT_SUPOPRTED), + gShellDebug1HiiHandle, + pStruct->Type15->AccessMethod + ); + return EFI_UNSUPPORTED; + } + // + // Display Event Log Header + // + // Starting offset (or index) within the nonvolatile storage + // of the event-log's header, from the Access Method Address + // + DisplaySysEventLogHeader ( + pStruct->Type15->LogHeaderFormat, + AccessMethodAddress + pStruct->Type15->LogHeaderStartOffset + ); + + // + // Display all Event Log data + // + // Starting offset (or index) within the nonvolatile storage + // of the event-log's first data byte, from the Access Method Address(0x14) + // + DisplaySysEventLogData ( + AccessMethodAddress + pStruct->Type15->LogDataStartOffset, + (UINT16) + ( + pStruct->Type15->LogAreaLength - + (pStruct->Type15->LogDataStartOffset - pStruct->Type15->LogDataStartOffset) + ) + ); + } + + } + } + break; + + // + // Physical Memory Array (Type 16) + // + case 16: + DisplayPMALocation (pStruct->Type16->Location, Option); + DisplayPMAUse (pStruct->Type16->Use, Option); + DisplayPMAErrorCorrectionTypes ( + pStruct->Type16->MemoryErrorCorrection, + Option + ); + PrintStructValueH (pStruct, Type16, MaximumCapacity); + PrintStructValueH (pStruct, Type16, MemoryErrorInformationHandle); + PrintStructValueH (pStruct, Type16, NumberOfMemoryDevices); + break; + + // + // Memory Device (Type 17) + // + case 17: + PrintStructValueH (pStruct, Type17, MemoryArrayHandle); + PrintStructValueH (pStruct, Type17, MemoryErrorInformationHandle); + PrintStructValue (pStruct, Type17, TotalWidth); + PrintStructValue (pStruct, Type17, DataWidth); + PrintStructValue (pStruct, Type17, Size); + DisplayMemoryDeviceFormFactor (pStruct->Type17->FormFactor, Option); + PrintStructValueH (pStruct, Type17, DeviceSet); + PrintPendingString (pStruct, Type17, DeviceLocator); + PrintPendingString (pStruct, Type17, BankLocator); + DisplayMemoryDeviceType (pStruct->Type17->MemoryType, Option); + DisplayMemoryDeviceTypeDetail (pStruct->Type17->TypeDetail, Option); + PrintStructValueH (pStruct, Type17, Speed); + PrintPendingString (pStruct, Type17, Manufacturer); + PrintPendingString (pStruct, Type17, SerialNumber); + PrintPendingString (pStruct, Type17, AssetTag); + PrintPendingString (pStruct, Type17, PartNumber); + if (SmbiosMajorVersion > 0x2 || (SmbiosMajorVersion == 0x2 && SmbiosMinorVersion >= 0x6)) { + PrintStructValueH (pStruct, Type17, Attributes); + } + break; + + // + // 32-bit Memory Error Information (Type 18) + // + case 18: + DisplayMemoryErrorType (pStruct->Type18->ErrorType, Option); + DisplayMemoryErrorGranularity ( + pStruct->Type18->ErrorGranularity, + Option + ); + DisplayMemoryErrorOperation (pStruct->Type18->ErrorOperation, Option); + PrintStructValueH (pStruct, Type18, VendorSyndrome); + PrintStructValueH (pStruct, Type18, MemoryArrayErrorAddress); + PrintStructValueH (pStruct, Type18, DeviceErrorAddress); + PrintStructValueH (pStruct, Type18, ErrorResolution); + break; + + // + // Memory Array Mapped Address (Type 19) + // + case 19: + PrintStructValueH (pStruct, Type19, StartingAddress); + PrintStructValueH (pStruct, Type19, EndingAddress); + PrintStructValueH (pStruct, Type19, MemoryArrayHandle); + PrintStructValueH (pStruct, Type19, PartitionWidth); + break; + + // + // Memory Device Mapped Address (Type 20) + // + case 20: + PrintStructValueH (pStruct, Type20, StartingAddress); + PrintStructValueH (pStruct, Type20, EndingAddress); + PrintStructValueH (pStruct, Type20, MemoryDeviceHandle); + PrintStructValueH (pStruct, Type20, MemoryArrayMappedAddressHandle); + PrintStructValueH (pStruct, Type20, PartitionRowPosition); + PrintStructValueH (pStruct, Type20, InterleavePosition); + PrintStructValueH (pStruct, Type20, InterleavedDataDepth); + break; + + // + // Built-in Pointing Device (Type 21) + // + case 21: + DisplayPointingDeviceType (pStruct->Type21->Type, Option); + DisplayPointingDeviceInterface (pStruct->Type21->Interface, Option); + PrintStructValue (pStruct, Type21, NumberOfButtons); + break; + + // + // Portable Battery (Type 22) + // + case 22: + PrintPendingString (pStruct, Type22, Location); + PrintPendingString (pStruct, Type22, Manufacturer); + PrintPendingString (pStruct, Type22, ManufactureDate); + PrintPendingString (pStruct, Type22, SerialNumber); + PrintPendingString (pStruct, Type22, DeviceName); + DisplayPBDeviceChemistry ( + pStruct->Type22->DeviceChemistry, + Option + ); + PrintStructValueH (pStruct, Type22, DeviceCapacity); + PrintStructValueH (pStruct, Type22, DesignVoltage); + PrintPendingString (pStruct, Type22, SBDSVersionNumber); + PrintStructValueH (pStruct, Type22, MaximumErrorInBatteryData); + PrintStructValueH (pStruct, Type22, SBDSSerialNumber); + DisplaySBDSManufactureDate ( + pStruct->Type22->SBDSManufactureDate, + Option + ); + PrintPendingString (pStruct, Type22, SBDSDeviceChemistry); + PrintStructValueH (pStruct, Type22, DesignCapacityMultiplier); + PrintStructValueH (pStruct, Type22, OEMSpecific); + break; + + case 23: + DisplaySystemResetCapabilities ( + pStruct->Type23->Capabilities, + Option + ); + PrintStructValueH (pStruct, Type23, ResetCount); + PrintStructValueH (pStruct, Type23, ResetLimit); + PrintStructValueH (pStruct, Type23, TimerInterval); + PrintStructValueH (pStruct, Type23, Timeout); + break; + + case 24: + DisplayHardwareSecuritySettings ( + pStruct->Type24->HardwareSecuritySettings, + Option + ); + break; + + case 25: + PrintStructValueH (pStruct, Type25, NextScheduledPowerOnMonth); + PrintStructValueH (pStruct, Type25, NextScheduledPowerOnDayOfMonth); + PrintStructValueH (pStruct, Type25, NextScheduledPowerOnHour); + PrintStructValueH (pStruct, Type25, NextScheduledPowerOnMinute); + PrintStructValueH (pStruct, Type25, NextScheduledPowerOnSecond); + break; + + case 26: + PrintPendingString (pStruct, Type26, Description); + DisplayVPLocation (pStruct->Type26->LocationAndStatus, Option); + DisplayVPStatus (pStruct->Type26->LocationAndStatus, Option); + PrintStructValueH (pStruct, Type26, MaximumValue); + PrintStructValueH (pStruct, Type26, MinimumValue); + PrintStructValueH (pStruct, Type26, Resolution); + PrintStructValueH (pStruct, Type26, Tolerance); + PrintStructValueH (pStruct, Type26, Accuracy); + PrintStructValueH (pStruct, Type26, OEMDefined); + PrintStructValueH (pStruct, Type26, NominalValue); + break; + + case 27: + PrintStructValueH (pStruct, Type27, TemperatureProbeHandle); + DisplayCoolingDeviceStatus (pStruct->Type27->DeviceTypeAndStatus, Option); + DisplayCoolingDeviceType (pStruct->Type27->DeviceTypeAndStatus, Option); + PrintStructValueH (pStruct, Type27, CoolingUnitGroup); + PrintStructValueH (pStruct, Type27, OEMDefined); + PrintStructValueH (pStruct, Type27, NominalSpeed); + break; + + case 28: + PrintPendingString (pStruct, Type28, Description); + DisplayTemperatureProbeStatus (pStruct->Type28->LocationAndStatus, Option); + DisplayTemperatureProbeLoc (pStruct->Type28->LocationAndStatus, Option); + PrintStructValueH (pStruct, Type28, MaximumValue); + PrintStructValueH (pStruct, Type28, MinimumValue); + PrintStructValueH (pStruct, Type28, Resolution); + PrintStructValueH (pStruct, Type28, Tolerance); + PrintStructValueH (pStruct, Type28, Accuracy); + PrintStructValueH (pStruct, Type28, OEMDefined); + PrintStructValueH (pStruct, Type28, NominalValue); + break; + + case 29: + PrintPendingString (pStruct, Type29, Description); + DisplayECPStatus (pStruct->Type29->LocationAndStatus, Option); + DisplayECPLoc (pStruct->Type29->LocationAndStatus, Option); + PrintStructValueH (pStruct, Type29, MaximumValue); + PrintStructValueH (pStruct, Type29, MinimumValue); + PrintStructValueH (pStruct, Type29, Resolution); + PrintStructValueH (pStruct, Type29, Tolerance); + PrintStructValueH (pStruct, Type29, Accuracy); + PrintStructValueH (pStruct, Type29, OEMDefined); + PrintStructValueH (pStruct, Type29, NominalValue); + break; + + case 30: + PrintPendingString (pStruct, Type30, ManufacturerName); + DisplayOBRAConnections (pStruct->Type30->Connections, Option); + break; + + case 31: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_STRUCT_TYPE31), gShellDebug1HiiHandle); + break; + + case 32: + PrintBitField (pStruct, Type32, Reserved, 6); + DisplaySystemBootStatus (pStruct->Type32->BootStatus[0], Option); + break; + + case 33: + DisplayMemoryErrorType (pStruct->Type33->ErrorType, Option); + DisplayMemoryErrorGranularity ( + pStruct->Type33->ErrorGranularity, + Option + ); + DisplayMemoryErrorOperation (pStruct->Type33->ErrorOperation, Option); + PrintStructValueH (pStruct, Type33, VendorSyndrome); + PrintStructValueH (pStruct, Type33, MemoryArrayErrorAddress); + PrintStructValueH (pStruct, Type33, DeviceErrorAddress); + PrintStructValueH (pStruct, Type33, ErrorResolution); + break; + + // + // Management Device (Type 34) + // + case 34: + PrintPendingString (pStruct, Type34, Description); + DisplayMDType (pStruct->Type34->Type, Option); + PrintStructValueH (pStruct, Type34, Address); + PrintStructValueH (pStruct, Type34, AddressType); + break; + + case 35: + PrintPendingString (pStruct, Type35, Description); + PrintStructValueH (pStruct, Type35, ManagementDeviceHandle); + PrintStructValueH (pStruct, Type35, ComponentHandle); + PrintStructValueH (pStruct, Type35, ThresholdHandle); + break; + + case 36: + PrintStructValueH (pStruct, Type36, LowerThresholdNonCritical); + PrintStructValueH (pStruct, Type36, UpperThresholdNonCritical); + PrintStructValueH (pStruct, Type36, LowerThresholdCritical); + PrintStructValueH (pStruct, Type36, UpperThresholdCritical); + PrintStructValueH (pStruct, Type36, LowerThresholdNonRecoverable); + PrintStructValueH (pStruct, Type36, UpperThresholdNonRecoverable); + break; + + // + // Memory Channel (Type 37) + // + case 37: + { + UINT8 Count; + MEMORYDEVICE *Ptr; + DisplayMemoryChannelType (pStruct->Type37->ChannelType, Option); + PrintStructValueH (pStruct, Type37, MaximumChannelLoad); + PrintStructValueH (pStruct, Type37, MemoryDeviceCount); + + Count = pStruct->Type37->MemoryDeviceCount; + Ptr = pStruct->Type37->MemoryDevice; + for (Index = 0; Index < Count; Index++) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEM_DEVICE), gShellDebug1HiiHandle, Index + 1); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DEV_LOAD), gShellDebug1HiiHandle, Ptr->DeviceLoad); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DEV_HANDLE), gShellDebug1HiiHandle, Ptr->DeviceHandle); + } + } + break; + + // + // IPMI Device Information (Type 38) + // + case 38: + DisplayIPMIDIBMCInterfaceType (pStruct->Type38->InterfaceType, Option); + PrintStructValueH (pStruct, Type38, IPMISpecificationRevision); + PrintStructValueH (pStruct, Type38, I2CSlaveAddress); + PrintStructValueH (pStruct, Type38, NVStorageDeviceAddress); + PrintStructValueH (pStruct, Type38, BaseAddress); + break; + + // + // System Power Supply (Type 39) + // + case 39: + PrintStructValueH (pStruct, Type39, PowerUnitGroup); + PrintPendingString (pStruct, Type39, Location); + PrintPendingString (pStruct, Type39, DeviceName); + PrintPendingString (pStruct, Type39, Manufacturer); + PrintPendingString (pStruct, Type39, SerialNumber); + PrintPendingString (pStruct, Type39, AssetTagNumber); + PrintPendingString (pStruct, Type39, ModelPartNumber); + PrintPendingString (pStruct, Type39, RevisionLevel); + PrintStructValueH (pStruct, Type39, MaxPowerCapacity); + DisplaySPSCharacteristics ( + pStruct->Type39->PowerSupplyCharacteristics, + Option + ); + PrintStructValueH (pStruct, Type39, InputVoltageProbeHandle); + PrintStructValueH (pStruct, Type39, CoolingDeviceHandle); + PrintStructValueH (pStruct, Type39, InputCurrentProbeHandle); + break; + + // + // Additional Information (Type 40) + // + case 40: + { + UINT8 NumberOfEntries; + UINT8 EntryLength; + ADDITIONAL_INFORMATION_ENTRY *Entries; + + EntryLength = 0; + Entries = pStruct->Type40->AdditionalInfoEntries; + NumberOfEntries = pStruct->Type40->NumberOfAdditionalInformationEntries; + + PrintStructValueH (pStruct, Type40, NumberOfAdditionalInformationEntries); + + for (Index = 0; Index < NumberOfEntries; Index++) { + EntryLength = Entries->EntryLength; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTRYLEN), gShellDebug1HiiHandle, EntryLength); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_REFERENCEDHANDLE), gShellDebug1HiiHandle, Entries->ReferencedHandle); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_REFERENCEDOFFSET), gShellDebug1HiiHandle, Entries->ReferencedOffset); + PrintSmbiosString (pStruct, Entries->EntryString, String); + PrintSmbiosBitField (pStruct, Entries->Value, Value, EntryLength - 5); + Entries = (ADDITIONAL_INFORMATION_ENTRY *) ((UINT8 *)Entries + EntryLength); + } + } + break; + + // + // Onboard Devices Extended Information (Type 41) + // + case 41: + PrintPendingString (pStruct, Type41, ReferenceDesignation); + PrintStructValueH (pStruct, Type41, DeviceType); + PrintStructValueH (pStruct, Type41, DeviceTypeInstance); + PrintStructValueH (pStruct, Type41, SegmentGroupNum); + PrintStructValueH (pStruct, Type41, BusNum); + PrintStructValueH (pStruct, Type41, DevFuncNum); + break; + + case 126: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INACTIVE_STRUCT), gShellDebug1HiiHandle); + break; + + case 127: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_THIS_STRUCT_END_TABLE), gShellDebug1HiiHandle); + break; + + default: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_STRUCT_TYPE_UNDEFINED), gShellDebug1HiiHandle); + break; + } + + return EFI_SUCCESS; +} + +VOID +DisplayBiosCharacteristics ( + UINT64 chara, + UINT8 Option + ) +{ + // + // Print header + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_CHAR), gShellDebug1HiiHandle); + // + // print option + // + PRINT_INFO_OPTION (chara, Option); + + // + // Check all the bits and print information + // This function does not use Table because table of bits + // are designed not to deal with UINT64 + // + if (BIT (chara, 0) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED_BIT), gShellDebug1HiiHandle); + } + + if (BIT (chara, 1) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED_BIT), gShellDebug1HiiHandle); + } + + if (BIT (chara, 2) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN_BIT), gShellDebug1HiiHandle); + } + + if (BIT (chara, 3) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_CHAR_NOT_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 4) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ISA_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 5) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MSA_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 6) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_EISA_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 7) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PCI_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 8) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PC_CARD_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 9) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PLUG_PLAY_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 10) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_APM_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 11) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_UPGRADEABLE), gShellDebug1HiiHandle); + } + + if (BIT (chara, 12) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_SHADOWING), gShellDebug1HiiHandle); + } + + if (BIT (chara, 13) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VESA_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 14) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ECSD_SUPPORT), gShellDebug1HiiHandle); + } + + if (BIT (chara, 15) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BOOT_FORM_CD_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 16) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SELECTED_BOOT_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 17) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_ROM_SOCKETED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 18) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BOOT_FROM_PC_CARD), gShellDebug1HiiHandle); + } + + if (BIT (chara, 19) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_EDD_ENHANCED_DRIVER), gShellDebug1HiiHandle); + } + + if (BIT (chara, 20) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_JAPANESE_FLOPPY_NEC), gShellDebug1HiiHandle); + } + + if (BIT (chara, 21) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_JAPANESE_FLOPPY_TOSHIBA), gShellDebug1HiiHandle); + } + + if (BIT (chara, 22) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FLOPPY_SERVICES_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (chara, 23) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_POINT_TWO_MB), gShellDebug1HiiHandle); + } + + if (BIT (chara, 24) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_720_KB), gShellDebug1HiiHandle); + } + + if (BIT (chara, 25) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_TWO_POINT_EIGHT_EIGHT_MB), gShellDebug1HiiHandle); + } + + if (BIT (chara, 26) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PRINT_SCREEN_SUPPORT), gShellDebug1HiiHandle); + } + + if (BIT (chara, 27) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_KEYBOARD_SERV_SUPPORT), gShellDebug1HiiHandle); + } + + if (BIT (chara, 28) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SERIAL_SERVICES_SUPPORT), gShellDebug1HiiHandle); + } + + if (BIT (chara, 29) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PRINTER_SERVICES_SUPPORT), gShellDebug1HiiHandle); + } + + if (BIT (chara, 30) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MONO_VIDEO_SUPPORT), gShellDebug1HiiHandle); + } + + if (BIT (chara, 31) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NEC_PC_98), gShellDebug1HiiHandle); + } + // + // Just print the reserved + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_32_47), gShellDebug1HiiHandle); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_48_64), gShellDebug1HiiHandle); +} + +VOID +DisplayBiosCharacteristicsExt1 ( + UINT8 byte1, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_CHAR_EXTENSION), gShellDebug1HiiHandle); + // + // Print option + // + PRINT_INFO_OPTION (byte1, Option); + + // + // check bit and print + // + if (BIT (byte1, 0) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ACPI_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (byte1, 1) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_USB_LEGACY_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (byte1, 2) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AGP_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (byte1, 3) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_I2O_BOOT_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (byte1, 4) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_LS_120_BOOT_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (byte1, 5) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ATAPI_ZIP_DRIVE), gShellDebug1HiiHandle); + } + + if (BIT (byte1, 6) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_1394_BOOT_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (byte1, 7) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SMART_BATTERY_SUPPORTED), gShellDebug1HiiHandle); + } +} + +VOID +DisplayBiosCharacteristicsExt2 ( + UINT8 byte2, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_CHAR_EXTENSION_2), gShellDebug1HiiHandle); + // + // Print option + // + PRINT_INFO_OPTION (byte2, Option); + + if (BIT (byte2, 0) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_BOOT_SPEC_SUPP), gShellDebug1HiiHandle); + } + + if (BIT (byte2, 1) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FUNCTION_KEY_INIT), gShellDebug1HiiHandle); + } + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_RSVD_FOR_FUTURE), gShellDebug1HiiHandle); +} + +VOID +DisplayProcessorFamily ( + UINT8 Family, + UINT8 Option + ) +{ + // + // Print prompt message + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROCESSOR_FAMILY), gShellDebug1HiiHandle); + // + // Print option + // + PRINT_INFO_OPTION (Family, Option); + + // + // Use switch to check + // + switch (Family) { + case 0x01: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTHER), gShellDebug1HiiHandle); + break; + + case 0x02: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle); + break; + + case 0x03: + Print (L"8086\n"); + break; + + case 0x04: + Print (L"80286\n"); + break; + + case 0x05: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL386_PROCESSOR), gShellDebug1HiiHandle); + break; + + case 0x06: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL486_PROCESSOR), gShellDebug1HiiHandle); + break; + + case 0x07: + Print (L"8087\n"); + break; + + case 0x08: + Print (L"80287\n"); + break; + + case 0x09: + Print (L"80387\n"); + break; + + case 0x0A: + Print (L"80487\n"); + break; + + case 0x0B: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_PROC_FAMILY), gShellDebug1HiiHandle); + break; + + case 0x0C: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_PRO_PROC), gShellDebug1HiiHandle); + break; + + case 0x0D: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_II_PROC), gShellDebug1HiiHandle); + break; + + case 0x0E: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_PROC_MMX), gShellDebug1HiiHandle); + break; + + case 0x0F: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CELERON_PROC), gShellDebug1HiiHandle); + break; + + case 0x10: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_XEON_PROC), gShellDebug1HiiHandle); + break; + + case 0x11: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_III_PROC), gShellDebug1HiiHandle); + break; + + case 0x12: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_M1_FAMILY), gShellDebug1HiiHandle); + break; + + case 0x18: + Print (L"AMD Duron\n"); + break; + + case 0x19: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_K5_FAMILY), gShellDebug1HiiHandle); + break; + + case 0x20: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_FAMILY), gShellDebug1HiiHandle); + break; + + case 0x21: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_601), gShellDebug1HiiHandle); + break; + + case 0x22: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_603), gShellDebug1HiiHandle); + break; + + case 0x23: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_603_PLUS), gShellDebug1HiiHandle); + break; + + case 0x24: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_604), gShellDebug1HiiHandle); + break; + + case 0x25: + Print (L"Power PC 620\n"); + break; + + case 0x26: + Print (L"Power PC 704\n"); + break; + + case 0x27: + Print (L"Power PC 750\n"); + break; + + case 0x28: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE_DUO), gShellDebug1HiiHandle); + break; + + case 0x29: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE_DUO_MOBILE), gShellDebug1HiiHandle); + break; + + case 0x2A: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE_SOLO_MOBILE), gShellDebug1HiiHandle); + break; + + case 0x2B: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_ATOM), gShellDebug1HiiHandle); + break; + + case 0x30: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ALPHA_FAMILY_2), gShellDebug1HiiHandle); + break; + + case 0x31: + Print (L"Alpha 21064\n"); + break; + + case 0x32: + Print (L"Alpha 21066\n"); + break; + + case 0x33: + Print (L"Alpha 21164\n"); + break; + + case 0x34: + Print (L"Alpha 21164PC\n"); + break; + + case 0x35: + Print (L"Alpha 21164a\n"); + break; + + case 0x36: + Print (L"Alpha 21264\n"); + break; + + case 0x37: + Print (L"Alpha 21364\n"); + break; + + case 0x40: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MIPS_FAMILY), gShellDebug1HiiHandle); + break; + + case 0x41: + Print (L"MIPS R4000\n"); + break; + + case 0x42: + Print (L"MIPS R4200\n"); + break; + + case 0x43: + Print (L"MIPS R4400\n"); + break; + + case 0x44: + Print (L"MIPS R4600\n"); + break; + + case 0x45: + Print (L"MIPS R10000\n"); + break; + + case 0x50: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SPARC_FAMILY), gShellDebug1HiiHandle); + break; + + case 0x51: + Print (L"SuperSparc\n"); + break; + + case 0x52: + Print (L"microSparc II\n"); + break; + + case 0x53: + Print (L"microSparc IIep\n"); + break; + + case 0x54: + Print (L"UltraSparc\n"); + break; + + case 0x55: + Print (L"UltraSparc II\n"); + break; + + case 0x56: + Print (L"UltraSparcIIi\n"); + break; + + case 0x57: + Print (L"UltraSparcIII\n"); + break; + + case 0x58: + Print (L"UltraSparcIIIi\n"); + break; + + case 0x60: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_68040_FAMILY), gShellDebug1HiiHandle); + break; + + case 0x61: + Print (L"68xx\n"); + break; + + case 0x62: + Print (L"68000\n"); + break; + + case 0x63: + Print (L"68010\n"); + break; + + case 0x64: + Print (L"68020\n"); + break; + + case 0x65: + Print (L"68030\n"); + break; + + case 0x70: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HOBBIT_FAMILY), gShellDebug1HiiHandle); + break; + + case 0x78: + Print (L"Crusoe TM5000\n"); + break; + + case 0x79: + Print (L"Crusoe TM3000\n"); + break; + + case 0x7A: + Print (L"Efficeon TM8000\n"); + break; + + case 0x80: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_WEITEK), gShellDebug1HiiHandle); + break; + + case 0x82: + Print (L"Itanium\n"); + break; + + case 0x83: + Print (L"AMD Athlon64\n"); + break; + + case 0x84: + Print (L"AMD Opteron\n"); + break; + + case 0x85: + Print (L"AMD Sempron\n"); + break; + + case 0x86: + Print (L"AMD Turion64 Mobile\n"); + break; + + case 0x87: + Print (L"Dual-Core AMD Opteron\n"); + break; + + case 0x88: + Print (L"AMD Athlon 64X2 DualCore\n"); + break; + + case 0x89: + Print (L"AMD Turion 64X2 Mobile\n"); + break; + + case 0x8A: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_OPTERON_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0x8B: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_OPTERON_THIRD_GENERATION), gShellDebug1HiiHandle); + break; + + case 0x8C: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_PHENOM_FX_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0x8D: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_PHENOM_X4_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0x8E: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_PHENOM_X2_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0x8F: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_ATHLON_X2_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0x90: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PA_RISC_FAMILY), gShellDebug1HiiHandle); + break; + + case 0xA0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_V30_FAMILY), gShellDebug1HiiHandle); + break; + + case 0xA1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_3200_SERIES_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0xA2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_3000_SERIES_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xA3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5300_SERIES_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0xA4: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5100_SERIES_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xA5: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5000_SERIES_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xA6: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_LV_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xA7: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_ULV_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xA8: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7100_SERIES_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xA9: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5400_SERIES_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0xAA: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0xAB: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5200_SERIES_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xAC: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7200_SERIES_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xAD: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7300_SERIES_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0xAE: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7400_SERIES_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0xAF: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7400_SERIES_MULTI_CORE), gShellDebug1HiiHandle); + break; + + case 0xB0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_III_XEON), gShellDebug1HiiHandle); + break; + + case 0xC0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_SOLO), gShellDebug1HiiHandle); + break; + + case 0xC1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_EXTREME), gShellDebug1HiiHandle); + break; + + case 0xC2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_QUAD), gShellDebug1HiiHandle); + break; + + case 0xC3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_EXTREME), gShellDebug1HiiHandle); + break; + + case 0xC4: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_DUO_MOBILE), gShellDebug1HiiHandle); + break; + + case 0xC5: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_SOLO_MOBILE), gShellDebug1HiiHandle); + break; + + case 0xC6: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE_I7), gShellDebug1HiiHandle); + break; + + case 0xC7: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CELERON_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xC8: + Print (L"IBM 390\n"); + break; + + case 0xC9: + Print (L"G4\n"); + break; + + case 0xCA: + Print (L"G5\n"); + break; + + case 0xCB: + Print (L"G6\n"); + break; + + case 0xCC: + Print (L"zArchitectur\n"); + break; + + case 0xD2: + Print (L"ViaC7M\n"); + break; + + case 0xD3: + Print (L"ViaC7D\n"); + break; + + case 0xD4: + Print (L"ViaC7\n"); + break; + + case 0xD5: + Print (L"Eden\n"); + break; + + case 0xD6: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_MULTI_CORE), gShellDebug1HiiHandle); + break; + + case 0xD7: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_3_SERIES_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xD8: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_3_SERIES_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0xDA: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5_SERIES_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xDB: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5_SERIES_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0xDD: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7_SERIES_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xDE: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7_SERIES_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0xDF: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7_SERIES_MULTI_CORE), gShellDebug1HiiHandle); + break; + + case 0xE6: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_EMBEDDED_OPTERON_QUAD_CORE), gShellDebug1HiiHandle); + break; + + case 0xE7: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_PHENOM_TRIPLE_CORE), gShellDebug1HiiHandle); + break; + + case 0xE8: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_TURION_ULTRA_DUAL_CORE_MOBILE), gShellDebug1HiiHandle); + break; + + case 0xE9: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_TURION_DUAL_CORE_MOBILE), gShellDebug1HiiHandle); + break; + + case 0xEA: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_ATHLON_DUAL_CORE), gShellDebug1HiiHandle); + break; + + case 0xEB: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_SEMPRON_SI), gShellDebug1HiiHandle); + break; + + case 0xFA: + Print (L"i860\n"); + break; + + case 0xFB: + Print (L"i960\n"); + break; + + default: + // + // In order to reduce code quality notice of + // case & break not pair, so + // move multiple case into the else part and + // use if/else to check value. + // + if (Family >= 0x13 && Family <= 0x17) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RSVD_FOR_SPEC_M1), gShellDebug1HiiHandle); + } else if (Family >= 0x1A && Family <= 0x1F) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RSVD_FOR_SPEC_K5), gShellDebug1HiiHandle); + } else if (Family >= 0xB1 && Family <= 0xBF) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RSVD_FOR_SPEC_PENTIUM), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNDEFINED_PROC_FAMILY), gShellDebug1HiiHandle); + } + } + // + // end switch + // +} + +VOID +DisplayProcessorFamily2 ( + UINT16 Family2, + UINT8 Option + ) +{ + // + // Print prompt message + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROCESSOR_FAMILY), gShellDebug1HiiHandle); + + // + // Print option + // + PRINT_INFO_OPTION (Family2, Option); + + // + // Use switch to check + // + switch (Family2) { + case 0x104: + Print (L"SH-3\n"); + break; + + case 0x105: + Print (L"SH-4\n"); + break; + + case 0x118: + Print (L"ARM\n"); + break; + + case 0x119: + Print (L"StrongARM\n"); + break; + + case 0x12C: + Print (L"6x86\n"); + break; + + case 0x12D: + Print (L"MediaGX\n"); + break; + + case 0x12E: + Print (L"MII\n"); + break; + + case 0x140: + Print (L"WinChip\n"); + break; + + case 0x15E: + Print (L"DSP\n"); + break; + + case 0x1F4: + Print (L"Video Processor\n"); + break; + + default: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNDEFINED_PROC_FAMILY), gShellDebug1HiiHandle); + } + +} + +VOID +DisplayProcessorVoltage ( + UINT8 Voltage, + UINT8 Option + ) +/*++ +Routine Description: + Bit 7 Set to 0, indicating 'legacy' mode for processor voltage + Bits 6:4 Reserved, must be zero + Bits 3:0 Voltage Capability. + A Set bit indicates that the voltage is supported. + Bit 0 - 5V + Bit 1 - 3.3V + Bit 2 - 2.9V + Bit 3 - Reserved, must be zero. + + Note: + Setting of multiple bits indicates the socket is configurable + If bit 7 is set to 1, the remaining seven bits of the field are set to + contain the processor's current voltage times 10. + For example, the field value for a processor voltage of 1.8 volts would be + 92h = 80h + (1.8 * 10) = 80h + 18 = 80h +12h. + +Arguments: + Voltage - The Voltage + Option - The option + +Returns: + +**/ +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROC_INFO), gShellDebug1HiiHandle); + // + // Print option + // + PRINT_INFO_OPTION (Voltage, Option); + + if (BIT (Voltage, 7) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROC_CURRENT_VOLTAGE), gShellDebug1HiiHandle, (Voltage - 0x80)); + } else { + if (BIT (Voltage, 0) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_5V_SUPOPRTED), gShellDebug1HiiHandle); + } + + if (BIT (Voltage, 1) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_33V_SUPPORTED), gShellDebug1HiiHandle); + } + + if (BIT (Voltage, 2) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_29V_SUPPORTED), gShellDebug1HiiHandle); + } + // + // check the reserved zero bits: + // + if (BIT (Voltage, 3) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT3_NOT_ZERO), gShellDebug1HiiHandle); + } + + if (BIT (Voltage, 4) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT4_NOT_ZERO), gShellDebug1HiiHandle); + } + + if (BIT (Voltage, 5) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT5_NOT_ZERO), gShellDebug1HiiHandle); + } + + if (BIT (Voltage, 6) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT6_NOT_ZERO), gShellDebug1HiiHandle); + } + } +} + +VOID +DisplayProcessorStatus ( + UINT8 Status, + UINT8 Option + ) +/*++ +Routine Description: + +Bit 7 Reserved, must be 0 +Bit 6 CPU Socket Populated + 1 - CPU Socket Populated + 0 - CPU Socket UnpopulatedBits + 5:3 Reserved, must be zero + Bits 2:0 CPU Status + 0h - Unknown + 1h - CPU Enabled + 2h - CPU Disabled by User via BIOS Setup + 3h - CPU Disabled By BIOS (POST Error) + 4h - CPU is Idle, waiting to be enabled. + 5-6h - Reserved + 7h - Other + +Arguments: + Status - The status + Option - The option + +Returns: + +**/ +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROC_STATUS), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Status, Option); + + if (BIT (Status, 7) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ERROR_BIT7), gShellDebug1HiiHandle); + } else if (BIT (Status, 5) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ERROR_BIT5), gShellDebug1HiiHandle); + } else if (BIT (Status, 4) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ERROR_BIT4), gShellDebug1HiiHandle); + } else if (BIT (Status, 3) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ERROR_BIT3), gShellDebug1HiiHandle); + } + // + // Check BIT 6 + // + if (BIT (Status, 6) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_SOCKET_POPULATED), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_SOCKET_UNPOPULATED), gShellDebug1HiiHandle); + } + // + // Check BITs 2:0 + // + switch (Status & 0x07) { + case 0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle); + break; + + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_ENABLED), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_DISABLED_BY_USER), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_DIABLED_BY_BIOS), gShellDebug1HiiHandle); + break; + + case 4: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_IDLE), gShellDebug1HiiHandle); + break; + + case 7: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTHERS), gShellDebug1HiiHandle); + break; + + default: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED), gShellDebug1HiiHandle); + } +} + +VOID +DisplayMaxMemoryModuleSize ( + UINT8 Size, + UINT8 SlotNum, + UINT8 Option + ) +{ + UINTN MaxSize; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SIZE_LARGEST_MEM), gShellDebug1HiiHandle); + // + // MaxSize is determined by follow formula + // + MaxSize = (UINTN) 1 << Size; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_VAR_MB), gShellDebug1HiiHandle, MaxSize); + + if (Option >= SHOW_DETAIL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MAX_AMOUNT_MEM), gShellDebug1HiiHandle); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_VAR_MB), gShellDebug1HiiHandle, MaxSize, SlotNum, MaxSize * SlotNum); + } +} + +VOID +DisplayMemoryModuleConfigHandles ( + UINT16 *Handles, + UINT8 SlotNum, + UINT8 Option + ) +{ + UINT8 Index; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HANDLES_CONTROLLED), gShellDebug1HiiHandle, SlotNum); + + if (Option >= SHOW_DETAIL) { + // + // No handle, Handles is INVALID. + // + if (SlotNum == 0) { + return ; + } + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HANDLES_LIST_CONTROLLED), gShellDebug1HiiHandle); + for (Index = 0; Index < SlotNum; Index++) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HANDLE), gShellDebug1HiiHandle, Index + 1, Handles[Index]); + } + } +} +// +// Memory Module Information (Type 6) +// +VOID +DisplayMmBankConnections ( + UINT8 BankConnections, + UINT8 Option + ) +{ + UINT8 High; + UINT8 Low; + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BANK_CONNECTIONS), gShellDebug1HiiHandle); + // + // Print option + // + PRINT_INFO_OPTION (BankConnections, Option); + + // + // Divide it to high and low + // + High = (UINT8) (BankConnections & 0xF0); + Low = (UINT8) (BankConnections & 0x0F); + if (High != 0xF) { + if (Low != 0xF) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BANK_RAS), gShellDebug1HiiHandle, High, Low, High, Low); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BANK_RAS_2), gShellDebug1HiiHandle, High, High); + } + } else { + if (Low != 0xF) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BANK_RAS_2), gShellDebug1HiiHandle, Low, Low); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NO_BANKS_CONNECTED), gShellDebug1HiiHandle); + } + } +} + +VOID +DisplayMmMemorySize ( + UINT8 Size, + UINT8 Option + ) +/*++ +Routine Description: + Bits 0:6 Size (n), + where 2**n is the size in MB with three special-case values: + 7Dh Not determinable (Installed Size only) + 7Eh Module is installed, but no memory has been enabled + 7Fh Not installed + Bit 7 Defines whether the memory module has a single- (0) + or double-bank (1) connection. + +Arguments: + Size - The size + Option - The option + +Returns: + +**/ +{ + UINT8 Value; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEMORY_SIZE), gShellDebug1HiiHandle); + // + // Print option + // + PRINT_INFO_OPTION (Size, Option); + + // + // Get the low bits(0-6 bit) + // + Value = (UINT8) (Size & 0x7F); + if (Value == 0x7D) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEM_SIZE_NOT_DETERMINABLE), gShellDebug1HiiHandle); + } else if (Value == 0x7E) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MODULE_INSTALLED), gShellDebug1HiiHandle); + } else if (Value == 0x7F) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_INSTALLED), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEM_SIZE), gShellDebug1HiiHandle, 1 << Value); + } + + if (BIT (Size, 7) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEM_MODULE_DOUBLE_BANK), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEM_MODULE_SINGLE_BANK), gShellDebug1HiiHandle); + } +} + +VOID +DisplaySystemSlotId ( + UINT16 SlotId, + UINT8 SlotType, + UINT8 Option + ) +/*++ +Routine Description: + + The Slot ID field of the System Slot structure provides a mechanism to + correlate the physical attributes of the slot to its logical access method + (which varies based on the Slot Type field). + +Arguments: + + SlotId - The slot ID + SlotType - The slot type + Option - The Option + +Returns: + +**/ +{ + // + // Display slot type first + // + DisplaySystemSlotType (SlotType, Option); + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SLOT_ID), gShellDebug1HiiHandle); + // + // print option + // + PRINT_INFO_OPTION (SlotType, Option); + + switch (SlotType) { + // + // Slot Type: MCA + // + case 0x04: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_LOGICAL_MICRO_CHAN), gShellDebug1HiiHandle); + if (SlotId > 0 && SlotId < 15) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_VAR_D), gShellDebug1HiiHandle, SlotId); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ERROR_NOT_1_15), gShellDebug1HiiHandle); + } + break; + + // + // EISA + // + case 0x05: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_LOGICAL_EISA_NUM), gShellDebug1HiiHandle); + if (SlotId > 0 && SlotId < 15) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_VAR_D), gShellDebug1HiiHandle, SlotId); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ERROR_NOT_1_15), gShellDebug1HiiHandle); + } + break; + + // + // Slot Type: PCI + // + case 0x06: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VALUE_PRESENT), gShellDebug1HiiHandle, SlotId); + break; + + // + // PCMCIA + // + case 0x07: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_IDENTIFIES_ADAPTER_NUM), gShellDebug1HiiHandle, SlotId); + break; + + // + // Slot Type: PCI-E + // + case 0xA5: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VALUE_PRESENT), gShellDebug1HiiHandle, SlotId); + break; + + default: + if (SlotType >= 0x0E && SlotType <= 0x12) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VALUE_PRESENT), gShellDebug1HiiHandle, SlotId); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNDEFINED_SLOT_ID), gShellDebug1HiiHandle); + } + } +} + +VOID +DisplaySystemBootStatus ( + UINT8 Parameter, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_BOOT_STATUS), gShellDebug1HiiHandle); + // + // Print option + // + PRINT_INFO_OPTION (Parameter, Option); + + // + // Check value and print + // + if (Parameter == 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NO_ERRORS_DETECTED), gShellDebug1HiiHandle); + } else if (Parameter == 1) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NO_BOOTABLE_MEDIA), gShellDebug1HiiHandle); + } else if (Parameter == 2) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NORMAL_OP_SYSTEM), gShellDebug1HiiHandle); + } else if (Parameter == 3) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FIRMWARE_DETECTED), gShellDebug1HiiHandle); + } else if (Parameter == 4) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OP_SYSTEM), gShellDebug1HiiHandle); + } else if (Parameter == 5) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_USER_REQUESTED_BOOT), gShellDebug1HiiHandle); + } else if (Parameter == 6) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_SECURITY_VIOLATION), gShellDebug1HiiHandle); + } else if (Parameter == 7) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PREV_REQ_IMAGE), gShellDebug1HiiHandle); + } else if (Parameter == 8) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_WATCHDOG_TIMER), gShellDebug1HiiHandle); + } else if (Parameter >= 9 && Parameter <= 127) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RSVD_FUTURE_ASSIGNMENT), gShellDebug1HiiHandle); + } else if (Parameter >= 128 && Parameter <= 191) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VENDOR_OEM_SPECIFIC), gShellDebug1HiiHandle); + } else if (Parameter >= 192 && Parameter <= 255) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PRODUCT_SPEC_IMPLMENTATION), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ERROR_VALUE), gShellDebug1HiiHandle); + } +} +// +// Portable Battery (Type 22) +// +VOID +DisplaySBDSManufactureDate ( + UINT16 Date, + UINT8 Option + ) +/*++ +Routine Description: + The date the cell pack was manufactured, in packed format: + Bits 15:9 Year, biased by 1980, in the range 0 to 127. + Bits 8:5 Month, in the range 1 to 12. + Bits 4:0 Date, in the range 1 to 31. + For example, 01 February 2000 would be identified as + 0010 1000 0100 0001b (0x2841). + +Arguments: + Date - The date + Option - The option + +Returns: + +**/ +{ + UINTN Day; + UINTN Month; + UINTN Year; + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SBDS_MANUFACTURE_DATE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Date, Option); + // + // Print date + // + Day = Date & 0x001F; + Month = (Date & 0x00E0) >> 5; + Year = ((Date & 0xFF00) >> 8) + 1980; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MONTH_DAY_YEAR), gShellDebug1HiiHandle, Day, Month, Year); + +} +// +// System Reset (Type 23) +// +VOID +DisplaySystemResetCapabilities ( + UINT8 Reset, + UINT8 Option + ) +/*++ +Routine Description: +Identifies the system-reset capabilities for the system. + Bits 7:6 Reserved for future assignment via this specification, set to 00b. + Bit 5 System contains a watchdog timer, either True (1) or False (0). + Bits 4:3 Boot Option on Limit. + Identifies the system action to be taken when the Reset Limit is reached, one of: + 00b Reserved, do not use. + 01b Operating system + 10b System utilities + 11b Do not rebootBits + 2:1 Boot Option. Indicates the action to be taken following a watchdog reset, one of: + 00b Reserved, do not use. + 01b Operating system + 10b System utilities + 11b Do not reboot + Bit 0 Status. + 1b The system reset is enabled by the user + 0b The system reset is not enabled by the user + +Arguments: + Reset - Reset + Option - The option + +Returns: + +**/ +{ + UINTN Temp; + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_RESET_CAPABILITIES), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Reset, Option); + + // + // Check reserved bits 7:6 + // + if ((Reset & 0xC0) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_RESERVED_ZERO), gShellDebug1HiiHandle); + } + // + // Watch dog + // + if (BIT (Reset, 5) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_WATCHDOG_TIMER_2), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_NOT_CONTAIN_TIMER), gShellDebug1HiiHandle); + } + // + // Boot Option on Limit + // + Temp = (Reset & 0x18) >> 3; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BOOT_OPTION_LIMIT), gShellDebug1HiiHandle); + switch (Temp) { + case 0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED), gShellDebug1HiiHandle); + break; + + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OP_SYSTEM_2), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_UTIL), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DO_NOT_REBOOT_BITS), gShellDebug1HiiHandle); + break; + } + // + // Boot Option + // + Temp = (Reset & 0x06) >> 1; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BOOT_OPTION), gShellDebug1HiiHandle); + switch (Temp) { + case 0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED), gShellDebug1HiiHandle); + break; + + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OP_SYSTEM_2), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_UTIL), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DO_NOT_REBOOT), gShellDebug1HiiHandle); + break; + } + // + // Reset enable flag + // + if ((Reset & 0x01) != 0) { + Print (L"The system reset is enabled by the user\n"); + } else { + Print (L"The system reset is disabled by the user\n"); + } +} +// +// Hardware Security (Type 24) +// +VOID +DisplayHardwareSecuritySettings ( + UINT8 Settings, + UINT8 Option + ) +/*++ +Routine Description: +Identifies the password and reset status for the system: + +Bits 7:6 Power-on Password Status, one of: + 00b Disabled + 01b Enabled + 10b Not Implemented + 11b Unknown +Bits 5:4 Keyboard Password Status, one of: + 00b Disabled + 01b Enabled + 10b Not Implemented + 11b Unknown +Bits 3:2 Administrator Password Status, one of: + 00b Disabled + 01b Enabled + 10b Not Implemented + 11b Unknown +Bits 1:0 Front Panel Reset Status, one of: + 00b Disabled + 01b Enabled + 10b Not Implemented + 11b Unknown + +Arguments: + Settings - The settings + Option - the option + +Returns: + +**/ +{ + UINTN Temp; + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HARDWARE_SECURITY_SET), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Settings, Option); + + // + // Power-on Password Status + // + Temp = (Settings & 0xC0) >> 6; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_ON_PASSWORD), gShellDebug1HiiHandle); + switch (Temp) { + case 0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DISABLED), gShellDebug1HiiHandle); + break; + + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED_NEWLINE), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_IMPLEMENTED), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle); + break; + } + // + // Keyboard Password Status + // + Temp = (Settings & 0x30) >> 4; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_KEYBOARD_PASSWORD), gShellDebug1HiiHandle); + switch (Temp) { + case 0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DISABLED), gShellDebug1HiiHandle); + break; + + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED_NEWLINE), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_IMPLEMENTED), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle); + break; + } + // + // Administrator Password Status + // + Temp = (Settings & 0x0C) >> 2; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ADMIN_PASSWORD_STATUS), gShellDebug1HiiHandle); + switch (Temp) { + case 0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DISABLED), gShellDebug1HiiHandle); + break; + + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED_NEWLINE), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_IMPLEMENTED), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle); + break; + } + // + // Front Panel Reset Status + // + Temp = Settings & 0x3; + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FRONT_PANEL_RESET), gShellDebug1HiiHandle); + switch (Temp) { + case 0: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DISABLED), gShellDebug1HiiHandle); + break; + + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED_NEWLINE), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_IMPLEMENTED), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle); + break; + } +} +// +// Out-of-Band Remote Access (Type 30) +// +VOID +DisplayOBRAConnections ( + UINT8 Connections, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CONNECTIONS), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Connections, Option); + + // + // Check reserved bits 7:2 + // + if ((Connections & 0xFC) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_RESERVED_ZERO_2), gShellDebug1HiiHandle); + } + // + // Outbound Connection + // + if (BIT (Connections, 1) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OUTBOUND_CONN_ENABLED), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTUBOUND_CONN_DISABLED), gShellDebug1HiiHandle); + } + // + // Inbound Connection + // + if (BIT (Connections, 0) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INBOIUND_CONN_ENABLED), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INBOUND_CONN_DISABLED), gShellDebug1HiiHandle); + } +} +// +// System Power Supply (Type 39) +// +VOID +DisplaySPSCharacteristics ( + UINT16 Characteristics, + UINT8 Option + ) +{ + UINTN Temp; + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_CHAR), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Characteristics, Option); + + // + // Check reserved bits 15:14 + // + if ((Characteristics & 0xC000) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_15_14_RSVD), gShellDebug1HiiHandle); + } + // + // Bits 13:10 - DMTF Power Supply Type + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_TYPE), gShellDebug1HiiHandle); + Temp = (Characteristics & 0x1C00) << 10; + switch (Temp) { + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTHER_SPACE), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_LINEAR), gShellDebug1HiiHandle); + break; + + case 4: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SWITCHING), gShellDebug1HiiHandle); + break; + + case 5: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BATTERY), gShellDebug1HiiHandle); + break; + + case 6: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UPS), gShellDebug1HiiHandle); + break; + + case 7: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CONVERTER), gShellDebug1HiiHandle); + break; + + case 8: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_REGULATOR), gShellDebug1HiiHandle); + break; + + default: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED_2), gShellDebug1HiiHandle); + } + // + // Bits 9:7 - Status + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_STATUS_DASH), gShellDebug1HiiHandle); + Temp = (Characteristics & 0x380) << 7; + switch (Temp) { + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTHER_SPACE), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OK), gShellDebug1HiiHandle); + break; + + case 4: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NON_CRITICAL), gShellDebug1HiiHandle); + break; + + case 5: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CRITICAL_POWER_SUPPLY), gShellDebug1HiiHandle); + break; + + default: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNDEFINED), gShellDebug1HiiHandle); + } + // + // Bits 6:3 - DMTF Input Voltage Range Switching + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INPUT_VOLTAGE_RANGE), gShellDebug1HiiHandle); + Temp = (Characteristics & 0x78) << 3; + switch (Temp) { + case 1: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTHER_SPACE), gShellDebug1HiiHandle); + break; + + case 2: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle); + break; + + case 3: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MANUAL), gShellDebug1HiiHandle); + break; + + case 4: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AUTO_SWITCH), gShellDebug1HiiHandle); + break; + + case 5: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_WIDE_RANGE), gShellDebug1HiiHandle); + break; + + case 6: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_APPLICABLE), gShellDebug1HiiHandle); + break; + + default: + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED_3), gShellDebug1HiiHandle); + break; + } + // + // Power supply is unplugged from the wall + // + if (BIT (Characteristics, 2) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_UNPLUGGED), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_PLUGGED), gShellDebug1HiiHandle); + } + // + // Power supply is present + // + if (BIT (Characteristics, 1) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_PRESENT), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_NOT_PRESENT), gShellDebug1HiiHandle); + } + // + // hot replaceable + // + if (BIT (Characteristics, 0) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_REPLACE), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_NOT_REPLACE), gShellDebug1HiiHandle); + } +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.h new file mode 100644 index 0000000000..a6c8ef6ba8 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.h @@ -0,0 +1,192 @@ +/** @file + Module to clarify the element info of the smbios structure. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMBIOS_PRINT_INFO_H +#define _SMBIOS_PRINT_INFO_H + +#include "LibSmbios.h" + +extern UINT8 SmbiosMajorVersion; +extern UINT8 SmbiosMinorVersion; + +#define SHOW_NONE 0x00 +#define SHOW_OUTLINE 0x01 +#define SHOW_NORMAL 0x02 +#define SHOW_DETAIL 0x03 +// +// SHOW_ALL: WaitEnter() not wait input. +// +#define SHOW_ALL 0x04 +#define SHOW_STATISTICS 0x05 + +#define AS_UINT16(pData) (*((UINT16 *) pData)) +#define AS_UINT32(pData) (*((UINT32 *) pData)) +#define AS_UINT64(pData) (*((UINT64 *) pData)) + +VOID +SmbiosPrintEPSInfo ( + IN SMBIOS_STRUCTURE_TABLE *pSmbiosTable, + IN UINT8 Option + ); + +EFI_STATUS +SmbiosPrintStructure ( + IN SMBIOS_STRUCTURE_POINTER *pStruct, + IN UINT8 Option + ); + +// +// BIOS Information (Type 0) +// +VOID +DisplayBiosCharacteristics ( + UINT64 chara, + UINT8 Option + ); +VOID +DisplayBiosCharacteristicsExt1 ( + UINT8 byte1, + UINT8 Option + ); +VOID +DisplayBiosCharacteristicsExt2 ( + UINT8 byte2, + UINT8 Option + ); + +// +// Processor Information (Type 4) +// +VOID +DisplayProcessorFamily ( + UINT8 Family, + UINT8 Option + ); + +VOID +DisplayProcessorFamily2 ( + UINT16 Family2, + UINT8 Option + ); + +VOID +DisplayProcessorVoltage ( + UINT8 Voltage, + UINT8 Option + ); +VOID +DisplayProcessorStatus ( + UINT8 Status, + UINT8 Option + ); + +// +// Memory Controller Information (Type 5) +// +VOID +DisplayMaxMemoryModuleSize ( + UINT8 Size, + UINT8 SlotNum, + UINT8 Option + ); +VOID +DisplayMemoryModuleConfigHandles ( + UINT16 *pHandles, + UINT8 SlotNum, + UINT8 Option + ); + +// +// Memory Module Information (Type 6) +// +VOID +DisplayMmBankConnections ( + UINT8 BankConnections, + UINT8 Option + ); +VOID +DisplayMmMemorySize ( + UINT8 Size, + UINT8 Option + ); + +// +// System Slots (Type 9) +// +VOID +DisplaySystemSlotId ( + UINT16 SlotId, + UINT8 SlotType, + UINT8 Option + ); + +// +// Physical Memory Array (Type 16) +// Memory Device (Type 17) +// Memory Array Mapped Address (Type 19) +// Memory Device Mapped Address (Type 20) +// Portable Battery (Type 22) +// +VOID +DisplaySBDSManufactureDate ( + UINT16 Date, + UINT8 Option + ); + +// +// System Reset (Type 23) +// +VOID +DisplaySystemResetCapabilities ( + UINT8 Reset, + UINT8 Option + ); + +// +// Hardware Security (Type 24) +// +VOID +DisplayHardwareSecuritySettings ( + UINT8 Settings, + UINT8 Option + ); + +// +// Out-of-Band Remote Access (Type 30) +// +VOID +DisplayOBRAConnections ( + UINT8 Connections, + UINT8 Option + ); + +// +// System Boot Information (Type 32) +// +VOID +DisplaySystemBootStatus ( + UINT8 Parameter, + UINT8 Option + ); + +// +// System Power Supply (Type 39) +// +VOID +DisplaySPSCharacteristics ( + UINT16 Characteristics, + UINT8 Option + ); + +#endif diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c new file mode 100644 index 0000000000..c04dba5b76 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c @@ -0,0 +1,3798 @@ +/** @file + Build a table, each item is (Key, Info) pair. + And give a interface of query a string out of a table. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "../UefiShellDebug1CommandsLib.h" +#include "QueryTable.h" +#include "PrintInfo.h" + +TABLE_ITEM SystemWakeupTypeTable[] = { + { + 0x0, + L" Reserved" + }, + { + 0x1, + L" Other" + }, + { + 0x2, + L" Unknown" + }, + { + 0x3, + L" APM Timer" + }, + { + 0x4, + L" Modem Ring" + }, + { + 0x5, + L" LAN Remote" + }, + { + 0x6, + L" Power Switch" + }, + { + 0x7, + L" AC Power Restored" + } +}; + +TABLE_ITEM SystemEnclosureTypeTable[] = { + { + 0x01, + L" None" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" Desktop" + }, + { + 0x04, + L" Low Profile Desktop" + }, + { + 0x05, + L" Pizza Box" + }, + { + 0x06, + L" Mini Tower" + }, + { + 0x07, + L" Tower" + }, + { + 0x08, + L" Portable" + }, + { + 0x09, + L" LapTop" + }, + { + 0x0A, + L" Notebook" + }, + { + 0x0B, + L" Hand Held" + }, + { + 0x0C, + L" Docking Station" + }, + { + 0x0D, + L" All in One" + }, + { + 0x0E, + L" Sub Notebook" + }, + { + 0x0F, + L" Space-saving" + }, + { + 0x10, + L" Main Server Chassis" + }, + { + 0x11, + L" Expansion Chassis" + }, + { + 0x12, + L" SubChassis" + }, + { + 0x13, + L" Sub Notebook" + }, + { + 0x14, + L" Bus Expansion Chassis" + }, + { + 0x15, + L" Peripheral Chassis" + }, + { + 0x16, + L" RAID Chassis" + }, + { + 0x17, + L" Rack Mount Chassis" + }, + { + 0x18, + L" Sealed-case PC" + }, + { + 0x19, + L" Multi-system Chassis" + }, + { + 0x1A, + L" CompactPCI" + }, + { + 0x1B, + L" AdvancedTCA" + }, + { + 0x1C, + L" Blade" + }, + { + 0x1D, + L" Blade Enclosure" + }, +}; + +TABLE_ITEM SystemEnclosureStatusTable[] = { + { + 0x1, + L" Other" + }, + { + 0x2, + L" Unknown" + }, + { + 0x3, + L" Safe" + }, + { + 0x4, + L" Warning" + }, + { + 0x5, + L" Critical" + }, + { + 0x6, + L" Non-recoverable" + } +}; + +TABLE_ITEM SESecurityStatusTable[] = { + { + 0x1, + L" Other" + }, + { + 0x2, + L" Unknown" + }, + { + 0x3, + L" None" + }, + { + 0x4, + L" External interface locked out" + }, + { + 0x5, + L" External interface enabled" + } +}; + +TABLE_ITEM ProcessorTypeTable[] = { + { + 0x1, + L" Other" + }, + { + 0x2, + L" Unknown" + }, + { + 0x3, + L" Central Processor" + }, + { + 0x4, + L" Math Processor" + }, + { + 0x5, + L" DSP Processor" + }, + { + 0x6, + L" Video Processor " + }, +}; + +TABLE_ITEM ProcessorUpgradeTable[] = { + { + 0x01, + L"Other" + }, + { + 0x02, + L"Unknown" + }, + { + 0x03, + L"Daughter Board" + }, + { + 0x04, + L"ZIF Socket" + }, + { + 0x05, + L"Replaceable Piggy Back" + }, + { + 0x06, + L"None" + }, + { + 0x07, + L"LIF Socket" + }, + { + 0x08, + L"Slot 1" + }, + { + 0x09, + L"Slot 2" + }, + { + 0x0A, + L"370-pin socket" + }, + { + 0x0B, + L"Slot A" + }, + { + 0x0C, + L"Slot M" + }, + { + 0x0D, + L"Socket 423" + }, + { + 0x0E, + L"Socket A" + }, + { + 0x0F, + L"Socket 478" + }, + { + 0x10, + L"Socket 754" + }, + { + 0x11, + L"Socket 940" + }, + { + 0x12, + L"Socket 939" + }, + { + 0x13, + L"Socket mPGA604" + }, + { + 0x14, + L"Socket LGA771" + }, + { + 0x15, + L"Socket LGA775" + }, + { + 0x16, + L"Socket S1" + }, + { + 0x17, + L"Socket AM2" + }, + { + 0x18, + L"Socket F" + }, + { + 0x19, + L"Socket LGA1366" + }\ +}; + +TABLE_ITEM McErrorDetectMethodTable[] = { + { + 0x01, + L"Other" + }, + { + 0x02, + L"Unknown" + }, + { + 0x03, + L"None" + }, + { + 0x04, + L"8-bit Parity" + }, + { + 0x05, + L"32-bit ECC" + }, + { + 0x06, + L"64-bit ECC" + }, + { + 0x07, + L"128-bit ECC" + }, + { + 0x08, + L"CRC" + }, +}; + +TABLE_ITEM McErrorCorrectCapabilityTable[] = { + { + 0, + L"Other" + }, + { + 1, + L"Unknown" + }, + { + 2, + L"None" + }, + { + 3, + L"Single Bit Error Correcting" + }, + { + 4, + L"Double Bit Error Correcting" + }, + { + 5, + L"Error Scrubbing" + }, +}; + +TABLE_ITEM McInterleaveSupportTable[] = { + { + 0x01, + L"Other" + }, + { + 0x02, + L"Unknown" + }, + { + 0x03, + L"One Way Interleave" + }, + { + 0x04, + L"Two Way Interleave" + }, + { + 0x05, + L"Four Way Interleave" + }, + { + 0x06, + L"Eight Way Interleave" + }, + { + 0x07, + L"Sixteen Way Interleave" + } +}; + +TABLE_ITEM McMemorySpeedsTable[] = { + { + 0, + L" Other" + }, + { + 1, + L" Unknown" + }, + { + 2, + L" 70ns" + }, + { + 3, + L" 60ns" + }, + { + 4, + L" 50ns" + }, +}; + +TABLE_ITEM MemoryModuleVoltageTable[] = { + { + 0, + L" 5V" + }, + { + 1, + L" 3.3V" + }, + { + 2, + L" 2.9V" + }, +}; + +TABLE_ITEM MmMemoryTypeTable[] = { + { + 0, + L" Other" + }, + { + 1, + L" Unknown" + }, + { + 2, + L" Standard" + }, + { + 3, + L" Fast Page Mode" + }, + { + 4, + L" EDO" + }, + { + 5, + L" Parity" + }, + { + 6, + L" ECC " + }, + { + 7, + L" SIMM" + }, + { + 8, + L" DIMM" + }, + { + 9, + L" Burst EDO" + }, + { + 10, + L" SDRAM" + } +}; + +TABLE_ITEM MmErrorStatusTable[] = { + { + 0, + L" Uncorrectable errors received" + }, + { + 1, + L" Correctable errors received" + }, + { + 2, + L" Error Status obtained from the event log" + } +}; + +TABLE_ITEM CacheSRAMTypeTable[] = { + { + 0, + L" Other" + }, + { + 1, + L" Unknown" + }, + { + 2, + L" Non-Burst" + }, + { + 3, + L" Burst" + }, + { + 4, + L" Pipeline Burst" + }, + { + 5, + L" Synchronous" + }, + { + 6, + L" Asynchronous" + }, +}; + +TABLE_ITEM CacheErrCorrectingTypeTable[] = { + { + 0x01, + L"Other" + }, + { + 0x02, + L"Unknown" + }, + { + 0x03, + L"None" + }, + { + 0x04, + L"Parity" + }, + { + 0x05, + L"Single-bit ECC" + }, + { + 0x06, + L"Multi-bit ECC" + }, + { + 0x07, + L"Sixteen Way Interleave" + } +}; + +TABLE_ITEM CacheSystemCacheTypeTable[] = { + { + 0x01, + L"Other" + }, + { + 0x02, + L"Unknown" + }, + { + 0x03, + L"Instruction" + }, + { + 0x04, + L"Data" + }, + { + 0x05, + L"Unified" + } +}; + +TABLE_ITEM CacheAssociativityTable[] = { + { + 0x01, + L"Other" + }, + { + 0x02, + L"Unknown" + }, + { + 0x03, + L"Direct Mapped" + }, + { + 0x04, + L"2-way Set-Associative" + }, + { + 0x05, + L"4-way Set-Associative" + }, + { + 0x06, + L"Fully Associative" + }, + { + 0x07, + L"8-way Set-Associative" + }, + { + 0x08, + L"16-way Set-Associative" + }, + { + 0x09, + L"12-way Set-Associative" + }, + { + 0x0A, + L"24-way Set-Associative" + }, + { + 0x0B, + L"32-way Set-Associative" + }, + { + 0x0C, + L"48-way Set-Associative" + }, + { + 0x0D, + L"64-way Set-Associative" + } +}; + +TABLE_ITEM PortConnectorTypeTable[] = { + { + 0x00, + L"None" + }, + { + 0x01, + L"Centronics" + }, + { + 0x02, + L"Mini Centronics" + }, + { + 0x03, + L"Proprietary" + }, + { + 0x04, + L"DB-25 pin male" + }, + { + 0x05, + L"DB-25 pin female" + }, + { + 0x06, + L"DB-15 pin male" + }, + { + 0x07, + L"DB-15 pin female" + }, + { + 0x08, + L"DB-9 pin male" + }, + { + 0x09, + L"DB-9 pin female" + }, + { + 0x0A, + L"RJ-11" + }, + { + 0x0B, + L"RJ-45" + }, + { + 0x0C, + L"50 Pin MiniSCSI" + }, + { + 0x0D, + L"Mini-DIN" + }, + { + 0x0E, + L"Micro-DIN" + }, + { + 0x0F, + L"PS/2" + }, + { + 0x10, + L"Infrared" + }, + { + 0x11, + L"HP-HIL" + }, + { + 0x12, + L"Access Bus (USB)" + }, + { + 0x13, + L"SSA SCSI" + }, + { + 0x14, + L"Circular DIN-8 male" + }, + { + 0x15, + L"Circular DIN-8 female" + }, + { + 0x16, + L"On Board IDE" + }, + { + 0x17, + L"On Board Floppy" + }, + { + 0x18, + L"9 Pin Dual Inline (pin 10 cut)" + }, + { + 0x19, + L"25 Pin Dual Inline (pin 26 cut)" + }, + { + 0x1A, + L"50 Pin Dual Inline" + }, + { + 0x1B, + L"68 Pin Dual Inline" + }, + { + 0x1C, + L"On Board Sound Input from CD-ROM" + }, + { + 0x1D, + L"Mini-Centronics Type-14" + }, + { + 0x1E, + L"Mini-Centronics Type-26" + }, + { + 0x1F, + L"Mini-jack (headphones)" + }, + { + 0x20, + L"BNC" + }, + { + 0x21, + L"1394" + }, + { + 0x22, + L"SAS/SATA Plug Receptacle" + }, + { + 0xA0, + L"PC-98" + }, + { + 0xA1, + L"PC-98Hireso" + }, + { + 0xA2, + L"PC-H98" + }, + { + 0xA3, + L"PC-98Note" + }, + { + 0xA4, + L"PC-98Full" + }, + { + 0xFF, + L"Other" + }, +}; + +TABLE_ITEM PortTypeTable[] = { + { + 0x00, + L"None" + }, + { + 0x01, + L"Parallel Port XT/AT Compatible" + }, + { + 0x02, + L"Parallel Port PS/2" + }, + { + 0x03, + L"Parallel Port ECP" + }, + { + 0x04, + L"Parallel Port EPP" + }, + { + 0x05, + L"Parallel Port ECP/EPP" + }, + { + 0x06, + L"Serial Port XT/AT Compatible" + }, + { + 0x07, + L"Serial Port 16450 Compatible" + }, + { + 0x08, + L"Serial Port 16550 Compatible" + }, + { + 0x09, + L"Serial Port 16550A Compatible" + }, + { + 0x0A, + L"SCSI Port" + }, + { + 0x0B, + L"MIDI Port" + }, + { + 0x0C, + L"Joy Stick Port" + }, + { + 0x0D, + L"Keyboard Port" + }, + { + 0x0E, + L"Mouse Port" + }, + { + 0x0F, + L"SSA SCSI" + }, + { + 0x10, + L"USB" + }, + { + 0x11, + L"FireWire (IEEE P1394)" + }, + { + 0x12, + L"PCMCIA Type II" + }, + { + 0x13, + L"PCMCIA Type II" + }, + { + 0x14, + L"PCMCIA Type III" + }, + { + 0x15, + L"Cardbus" + }, + { + 0x16, + L"Access Bus Port" + }, + { + 0x17, + L"SCSI II" + }, + { + 0x18, + L"SCSI Wide" + }, + { + 0x19, + L"PC-98" + }, + { + 0x1A, + L"PC-98-Hireso" + }, + { + 0x1B, + L"PC-H98" + }, + { + 0x1C, + L"Video Port" + }, + { + 0x1D, + L"Audio Port" + }, + { + 0x1E, + L"Modem Port" + }, + { + 0x1F, + L"Network Port" + }, + { + 0x20, + L"SATA Port" + }, + { + 0x21, + L"SAS Port" + }, + { + 0xA0, + L"8251 Compatible" + }, + { + 0xA1, + L"8251 FIFO Compatible" + }, + { + 0xFF, + L"Other " + }, +}; + +TABLE_ITEM SystemSlotTypeTable[] = { + { + 0x01, + L"Other" + }, + { + 0x02, + L"Unknown" + }, + { + 0x03, + L"ISA" + }, + { + 0x04, + L"MCA" + }, + { + 0x05, + L"EISA" + }, + { + 0x06, + L"PCI" + }, + { + 0x07, + L"PC Card (PCMCIA)" + }, + { + 0x08, + L"VL-VESA" + }, + { + 0x09, + L"Proprietary" + }, + { + 0x0A, + L"Processor Card Slot" + }, + { + 0x0B, + L"Proprietary Memory Card Slot" + }, + { + 0x0C, + L"I/O Riser Card Slot" + }, + { + 0x0D, + L"NuBus" + }, + { + 0x0E, + L"PCI - 66MHz Capable" + }, + { + 0x0F, + L"AGP" + }, + { + 0x10, + L"AGP 2X" + }, + { + 0x11, + L"AGP 4X" + }, + { + 0x12, + L"PCI-X" + }, + { + 0xA0, + L"PC-98/C20 " + }, + { + 0xA1, + L"PC-98/C24 " + }, + { + 0xA2, + L"PC-98/E " + }, + { + 0xA3, + L"PC-98/Local Bus " + }, + { + 0xA4, + L"PC-98/Card " + }, + { + 0xA5, + L"PCI Express " + }, + { + 0xA6, + L"PCI Express X1" + }, + { + 0xA7, + L"PCI Express X2" + }, + { + 0xA8, + L"PCI Express X4" + }, + { + 0xA9, + L"PCI Express X8" + }, + { + 0xAA, + L"PCI Express X16" + }, + { + 0xAB, + L"PCI Express Gen 26" + }, + { + 0xAC, + L"PCI Express Gen 2 X1" + }, + { + 0xAD, + L"PCI Express Gen 2 X2" + }, + { + 0xAE, + L"PCI Express Gen 2 X4" + }, + { + 0xAF, + L"PCI Express Gen 2 X8" + }, + { + 0xB0, + L"PCI Express Gen 2 X16" + } +}; + +TABLE_ITEM SystemSlotDataBusWidthTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" 8 bit" + }, + { + 0x04, + L" 16 bit" + }, + { + 0x05, + L" 32 bit" + }, + { + 0x06, + L" 64 bit" + }, + { + 0x07, + L" 128 bit" + }, +}; + +TABLE_ITEM SystemSlotCurrentUsageTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" Available" + }, + { + 0x04, + L" In use" + }, +}; + +TABLE_ITEM SystemSlotLengthTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" Short length" + }, + { + 0x04, + L" Long Length" + }, +}; + +TABLE_ITEM SlotCharacteristics1Table[] = { + { + 0, + L" Characteristics Unknown" + }, + { + 1, + L" Provides 5.0 Volts" + }, + { + 2, + L" Provides 3.3 Volts" + }, + { + 3, + L" Slot's opening is shared with another slot, e.g. PCI/EISA shared slot." + }, + + { + 4, + L" PC Card slot supports PC Card-16" + }, + { + 5, + L" PC Card slot supports CardBus" + }, + { + 6, + L" PC Card slot supports Zoom Video " + }, + { + 7, + L" PC Card slot supports Modem Ring Resume " + } +}; + +TABLE_ITEM SlotCharacteristics2Table[] = { + { + 0, + L" PCI slot supports Power Management Enable (PME#) signal" + }, + { + 1, + L" Slot supports hot-plug devices" + }, + { + 2, + L" PCI slot supports SMBus signal" + } +}; + +TABLE_ITEM OnboardDeviceTypesTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" Video" + }, + { + 0x04, + L" SCSI Controller" + }, + { + 0x05, + L" Ethernet" + }, + { + 0x06, + L" Token Ring" + }, + { + 0x07, + L" Sound" + }, + { + 0x08, + L" Pata Controller" + }, + { + 0x09, + L" Sata Controller" + }, + { + 0x0A, + L" Sas Controller" + }, +}; + +TABLE_ITEM SELTypesTable[] = { + { + 0x00, + L" Reserved." + }, + { + 0x01, + L" Single-bit ECC memory error" + }, + { + 0x02, + L" Multi-bit ECC memory error" + }, + { + 0x03, + L" Parity memory error" + }, + { + 0x04, + L" Bus time-out" + }, + { + 0x05, + L" I/O Channel Check" + }, + { + 0x06, + L" Software NMI" + }, + { + 0x07, + L" POST Memory Resize" + }, + { + 0x08, + L" POST Error" + }, + { + 0x09, + L" PCI Parity Error" + }, + { + 0x0A, + L" PCI System Error" + }, + { + 0x0B, + L" CPU Failure" + }, + { + 0x0C, + L" EISA FailSafe Timer time-out" + }, + { + 0x0D, + L" Correctable memory log disabled" + }, + { + 0x0E, + L" Logging disabled for a specific Event Type" + }, + { + 0x0F, + L" Reserved" + }, + { + 0x10, + L" System Limit Exceeded" + }, + { + 0x11, + L" Asynchronous hardware timer expired and issued a system reset" + }, + { + 0x12, + L" System configuration information" + }, + { + 0x13, + L" Hard-disk information" + }, + { + 0x14, + L" System reconfigured" + }, + { + 0x15, + L" Uncorrectable CPU-complex error" + }, + { + 0x16, + L" Log Area Reset/Cleared" + }, + { + 0x17, + L" System boot" + }, + { + 0x7F18, + L" Unused by SMBIOS specification" + }, + { + 0xFE80, + L" System and OEM specified" + }, + { + 0xFF, + L" End-of-log" + }, +}; + +TABLE_ITEM SELVarDataFormatTypeTable[] = { + { + 0x00, + L" None " + }, + { + 0x01, + L" Handle " + }, + { + 0x02, + L" Multiple-Event " + }, + { + 0x03, + L" Multiple-Event Handle " + }, + { + 0x04, + L" POST Results Bitmap " + }, + // + // Defined below + // + { + 0x05, + L" System Management Type" + }, + // + // Defined below + // + { + 0x06, + L" Multiple-Event System Management Type " + }, + { + 0x7F07, + L" Unused " + }, + { + 0xFF80, + L" OEM assigned " + }, +}; + +TABLE_ITEM PostResultsBitmapDw1Table[] = { + { + 0, + L" Channel 2 Timer error " + }, + { + 1, + L" Master PIC (8259 #1) error " + }, + { + 2, + L" Slave PIC (8259 #2) error " + }, + { + 3, + L" CMOS Battery Failure " + }, + { + 4, + L" CMOS System Options Not Set " + }, + { + 5, + L" CMOS Checksum Error " + }, + { + 6, + L" CMOS Configuration Error " + }, + { + 7, + L" Mouse and Keyboard Swapped " + }, + { + 8, + L" Keyboard Locked " + }, + { + 9, + L" Keyboard Not Functional " + }, + { + 10, + L" Keyboard Controller Not Functional " + }, + { + 11, + L" CMOS Memory Size Different " + }, + { + 12, + L" Memory Decreased in Size " + }, + { + 13, + L" Cache Memory Error " + }, + { + 14, + L" Floppy Drive 0 Error " + }, + { + 15, + L" Floppy Drive 1 Error " + }, + { + 16, + L" Floppy Controller Failure " + }, + { + 17, + L" Number of ATA Drives Reduced Error " + }, + { + 18, + L" CMOS Time Not Set " + }, + { + 19, + L" DDC Monitor Configuration Change " + }, + { + 20, + L" Reserved, set to 0 " + }, + { + 21, + L" Reserved, set to 0 " + }, + { + 22, + L" Reserved, set to 0 " + }, + { + 23, + L" Reserved, set to 0 " + }, + { + 24, + L" Second DWORD has valid data " + }, + { + 25, + L" Reserved, set to 0 " + }, + { + 26, + L" Reserved, set to 0 " + }, + { + 27, + L" Reserved, set to 0 " + }, + { + 28, + L" Normally 0; available for OEM assignment " + }, + { + 29, + L" Normally 0; available for OEM assignment " + }, + { + 30, + L" Normally 0; available for OEM assignment " + }, + { + 31, + L" Normally 0; available for OEM assignment " + }, +}; + +TABLE_ITEM PostResultsBitmapDw2Table[] = { + { + 0, + L" Normally 0; available for OEM assignment " + }, + { + 1, + L" Normally 0; available for OEM assignment " + }, + { + 2, + L" Normally 0; available for OEM assignment " + }, + { + 3, + L" Normally 0; available for OEM assignment " + }, + { + 4, + L" Normally 0; available for OEM assignment " + }, + { + 5, + L" Normally 0; available for OEM assignment " + }, + { + 6, + L" Normally 0; available for OEM assignment " + }, + { + 7, + L" PCI Memory Conflict " + }, + { + 8, + L" PCI I/O Conflict " + }, + { + 9, + L" PCI IRQ Conflict " + }, + { + 10, + L" PNP Memory Conflict " + }, + { + 11, + L" PNP 32 bit Memory Conflict " + }, + { + 12, + L" PNP I/O Conflict " + }, + { + 13, + L" PNP IRQ Conflict " + }, + { + 14, + L" PNP DMA Conflict " + }, + { + 15, + L" Bad PNP Serial ID Checksum " + }, + { + 16, + L" Bad PNP Resource Data Checksum " + }, + { + 17, + L" Static Resource Conflict " + }, + { + 18, + L" NVRAM Checksum Error, NVRAM Cleared " + }, + { + 19, + L" System Board Device Resource Conflict " + }, + { + 20, + L" Primary Output Device Not Found " + }, + { + 21, + L" Primary Input Device Not Found " + }, + { + 22, + L" Primary Boot Device Not Found " + }, + { + 23, + L" NVRAM Cleared By Jumper " + }, + { + 24, + L" NVRAM Data Invalid, NVRAM Cleared " + }, + { + 25, + L" FDC Resource Conflict " + }, + { + 26, + L" Primary ATA Controller Resource Conflict " + }, + { + 27, + L" Secondary ATA Controller Resource Conflict " + }, + { + 28, + L" Parallel Port Resource Conflict " + }, + { + 29, + L" Serial Port 1 Resource Conflict " + }, + { + 30, + L" Serial Port 2 Resource Conflict " + }, + { + 31, + L" Audio Resource Conflict " + }, +}; + +TABLE_ITEM SELSysManagementTypesTable[] = { + { + 0x01, + L" +2.5V Out of range, #2 " + }, + { + 0x02, + L" +3.3V Out of range " + }, + { + 0x03, + L" +5V Out of range " + }, + { + 0x04, + L" -5V Out of range " + }, + { + 0x05, + L" +12V Out of range " + }, + { + 0x06, + L" -12V Out of range " + }, + { + 0x0F07, + L" Reserved for future out-of-range voltage levels " + }, + { + 0x10, + L" System board temperature out of range " + }, + { + 0x11, + L" Processor #1 temperature out of range " + }, + { + 0x12, + L" Processor #2 temperature out of range " + }, + { + 0x13, + L" Processor #3 temperature out of range " + }, + { + 0x14, + L" Processor #4 temperature out of range " + }, + { + 0x1F15, + L" Reserved for future out-of-range temperatures" + }, + { + 0x2720, + L" Fan n (n = 0 to 7) Out of range " + }, + { + 0x2F28, + L" Reserved for future assignment via this specification " + }, + { + 0x30, + L" Chassis secure switch activated " + }, +}; + +TABLE_ITEM PMALocationTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" System board or motherboard" + }, + { + 0x04, + L" ISA add-on card" + }, + { + 0x05, + L" EISA add-on card" + }, + { + 0x06, + L" PCI add-on card" + }, + { + 0x07, + L" MCA add-on card" + }, + { + 0x08, + L" PCMCIA add-on card" + }, + { + 0x09, + L" Proprietary add-on card" + }, + { + 0x0A, + L" NuBus" + }, + { + 0xA0, + L" PC-98/C20 add-on card" + }, + { + 0xA1, + L" PC-98/C24 add-on card" + }, + { + 0xA2, + L" PC-98/E add-on card" + }, + { + 0xA3, + L" PC-98/Local bus add-on card" + } +}; + +TABLE_ITEM PMAUseTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" System memory" + }, + { + 0x04, + L" Video memory" + }, + { + 0x05, + L" Flash memory" + }, + { + 0x06, + L" Non-volatile RAM" + }, + { + 0x07, + L" Cache memory" + } +}; + +TABLE_ITEM PMAErrorCorrectionTypesTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" None" + }, + { + 0x04, + L" Parity" + }, + { + 0x05, + L" Single-bit ECC" + }, + { + 0x06, + L" Multi-bit ECC" + }, + { + 0x07, + L" CRC" + } +}; + +TABLE_ITEM MemoryDeviceFormFactorTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" SIMM" + }, + { + 0x04, + L" SIP" + }, + { + 0x05, + L" Chip" + }, + { + 0x06, + L" DIP" + }, + { + 0x07, + L" ZIP" + }, + { + 0x08, + L" Proprietary Card" + }, + { + 0x09, + L" DIMM" + }, + { + 0x0A, + L" TSOP" + }, + { + 0x0B, + L" Row of chips" + }, + { + 0x0C, + L" RIMM" + }, + { + 0x0D, + L" SODIMM" + }, + { + 0x0E, + L" SRIMM" + }, + { + 0x0F, + L" FB-DIMM" + } +}; + +TABLE_ITEM MemoryDeviceTypeTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" DRAM" + }, + { + 0x04, + L" EDRAM" + }, + { + 0x05, + L" VRAM" + }, + { + 0x06, + L" SRAM" + }, + { + 0x07, + L" RAM" + }, + { + 0x08, + L" ROM" + }, + { + 0x09, + L" FLASH" + }, + { + 0x0A, + L" EEPROM" + }, + { + 0x0B, + L" FEPROM" + }, + { + 0x0C, + L" EPROM" + }, + { + 0x0D, + L" CDRAM" + }, + { + 0x0E, + L" 3DRAM" + }, + { + 0x0F, + L" SDRAM" + }, + { + 0x10, + L" SGRAM" + }, + { + 0x11, + L" RDRAM" + }, + { + 0x12, + L" DDR" + }, + { + 0x13, + L" DDR2" + }, + { + 0x14, + L" DDR2 FB-DIMM" + }, + { + 0x18, + L" DDR3" + }, + { + 0x19, + L" FBD2" + } +}; + +TABLE_ITEM MemoryDeviceTypeDetailTable[] = { + { + 1, + L" Other" + }, + { + 2, + L" Unknown" + }, + { + 3, + L" Fast-paged" + }, + { + 4, + L" Static column" + }, + { + 5, + L" Pseudo-STATIC" + }, + { + 6, + L" RAMBUS " + }, + { + 7, + L" Synchronous" + }, + { + 8, + L" CMOS" + }, + { + 9, + L" EDO" + }, + { + 10, + L" Window DRAM" + }, + { + 11, + L" Cache DRAM" + }, + { + 12, + L" Non-volatile" + }, +}; + +TABLE_ITEM MemoryErrorTypeTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" OK" + }, + { + 0x04, + L" Bad read" + }, + { + 0x05, + L" Parity error" + }, + { + 0x06, + L" Single-bit error" + }, + { + 0x07, + L" Double-bit error" + }, + { + 0x08, + L" Multi-bit error" + }, + { + 0x09, + L" Nibble error" + }, + { + 0x0A, + L" Checksum error" + }, + { + 0x0B, + L" CRC error" + }, + { + 0x0C, + L" Corrected single-bit error" + }, + { + 0x0D, + L" Corrected error" + }, + { + 0x0E, + L" Uncorrectable error" + }, +}; + +TABLE_ITEM MemoryErrorGranularityTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" Device level" + }, + { + 0x04, + L" Memory partition level" + }, +}; + +TABLE_ITEM MemoryErrorOperationTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" Read" + }, + { + 0x04, + L" Write" + }, + { + 0x05, + L" Partial Write" + }, +}; + +TABLE_ITEM PointingDeviceTypeTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" Mouse" + }, + { + 0x04, + L" Track Ball" + }, + { + 0x05, + L" Track Point" + }, + { + 0x06, + L" Glide Point" + }, + { + 0x07, + L" Touch Pad" + }, +}; + +TABLE_ITEM PointingDeviceInterfaceTable[] = { + { + 0x01, + L" Other" + }, + { + 0x02, + L" Unknown" + }, + { + 0x03, + L" Serial" + }, + { + 0x04, + L" PS/2" + }, + { + 0x05, + L" Infrared" + }, + { + 0x06, + L" HP-HIL" + }, + { + 0x07, + L" Bus mouse" + }, + { + 0x08, + L" ADB(Apple Desktop Bus" + }, + { + 0xA0, + L" Bus mouse DB-9" + }, + { + 0xA1, + L" Bus mouse mirco-DIN" + }, + { + 0xA2, + L" USB" + }, +}; + +TABLE_ITEM PBDeviceChemistryTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" Lead Acid " + }, + { + 0x04, + L" Nickel Cadmium " + }, + { + 0x05, + L" Nickel metal hydride " + }, + { + 0x06, + L" Lithium-ion " + }, + { + 0x07, + L" Zinc air " + }, + { + 0x08, + L" Lithium Polymer " + }, +}; + +TABLE_ITEM VPLocationTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" OK " + }, + { + 0x04, + L" Non-critical " + }, + { + 0x05, + L" Critical " + }, + { + 0x06, + L" Non-recoverable " + }, +}; + +TABLE_ITEM VPStatusTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" Processor " + }, + { + 0x04, + L" Disk " + }, + { + 0x05, + L" Peripheral Bay " + }, + { + 0x06, + L" System Management Module " + }, + { + 0x07, + L" Motherboard " + }, + { + 0x08, + L" Memory Module " + }, + { + 0x09, + L" Processor Module " + }, + { + 0x0A, + L" Power Unit " + }, + { + 0x0B, + L" Add-in Card " + }, +}; + +TABLE_ITEM CoolingDeviceStatusTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" OK " + }, + { + 0x04, + L" Non-critical " + }, + { + 0x05, + L" Critical " + }, + { + 0x06, + L" Non-recoverable " + }, +}; + +TABLE_ITEM CoolingDeviceTypeTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" Fan " + }, + { + 0x04, + L" Centrifugal Blower " + }, + { + 0x05, + L" Chip Fan " + }, + { + 0x06, + L" Cabinet Fan " + }, + { + 0x07, + L" Power Supply Fan " + }, + { + 0x08, + L" Heat Pipe " + }, + { + 0x09, + L" Integrated Refrigeration " + }, + { + 0x0A, + L" Active Cooling " + }, + { + 0x0B, + L" Passive Cooling " + }, +}; + +TABLE_ITEM TemperatureProbeStatusTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" OK " + }, + { + 0x04, + L" Non-critical " + }, + { + 0x05, + L" Critical " + }, + { + 0x06, + L" Non-recoverable " + }, +}; + +TABLE_ITEM TemperatureProbeLocTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" Processor " + }, + { + 0x04, + L" Disk " + }, + { + 0x05, + L" Peripheral Bay " + }, + { + 0x06, + L" System Management Module " + }, + { + 0x07, + L" Motherboard " + }, + { + 0x08, + L" Memory Module " + }, + { + 0x09, + L" Processor Module " + }, + { + 0x0A, + L" Power Unit " + }, + { + 0x0B, + L" Add-in Card " + }, +}; + +TABLE_ITEM ECPStatusTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" OK " + }, + { + 0x04, + L" Non-critical " + }, + { + 0x05, + L" Critical " + }, + { + 0x06, + L" Non-recoverable " + }, +}; + +TABLE_ITEM ECPLocTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" Processor " + }, + { + 0x04, + L" Disk " + }, + { + 0x05, + L" Peripheral Bay " + }, + { + 0x06, + L" System Management Module " + }, + { + 0x07, + L" Motherboard " + }, + { + 0x08, + L" Memory Module " + }, + { + 0x09, + L" Processor Module " + }, + { + 0x0A, + L" Power Unit " + }, + { + 0x0B, + L" Add-in Card " + }, +}; + +TABLE_ITEM MDTypeTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" National Semiconductor LM75 " + }, + { + 0x04, + L" National Semiconductor LM78 " + }, + { + 0x05, + L" National Semiconductor LM79 " + }, + { + 0x06, + L" National Semiconductor LM80 " + }, + { + 0x07, + L" National Semiconductor LM81 " + }, + { + 0x08, + L" Analog Devices ADM9240 " + }, + { + 0x09, + L" Dallas Semiconductor DS1780 " + }, + { + 0x0A, + L" Maxim 1617 " + }, + { + 0x0B, + L" Genesys GL518SM " + }, + { + 0x0C, + L" Winbond W83781D " + }, + { + 0x0D, + L" Holtek HT82H791 " + }, +}; + +TABLE_ITEM MDAddressTypeTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" I/O Port " + }, + { + 0x04, + L" Memory " + }, + { + 0x05, + L" SM Bus " + }, +}; + +TABLE_ITEM MemoryChannelTypeTable[] = { + { + 0x01, + L" Other " + }, + { + 0x02, + L" Unknown " + }, + { + 0x03, + L" RamBus " + }, + { + 0x04, + L" SyncLink " + }, +}; + +TABLE_ITEM IPMIDIBMCInterfaceTypeTable[] = { + { + 0x00, + L" Unknown " + }, + { + 0x01, + L" KCS: Keyboard Controller Style " + }, + { + 0x02, + L" SMIC: Server Management Interface Chip " + }, + { + 0x03, + L" BT: Block Transfer " + }, + { + 0xFF04, + L" Reserved for future assignment by this specification " + }, +}; + +TABLE_ITEM StructureTypeInfoTable[] = { + { + 0, + L" BIOS Information" + }, + { + 1, + L" System Information" + }, + { + 2, + L" Base Board Information" + }, + { + 3, + L" System Enclosure" + }, + { + 4, + L" Processor Information" + }, + { + 5, + L" Memory Controller Information " + }, + { + 6, + L" Memory Module Information " + }, + { + 7, + L" Cache Information " + }, + { + 8, + L" Port Connector Information " + }, + { + 9, + L" System Slots " + }, + { + 10, + L" On Board Devices Information " + }, + { + 11, + L" OEM Strings" + }, + { + 12, + L" System Configuration Options " + }, + { + 13, + L" BIOS Language Information " + }, + { + 14, + L" Group Associations " + }, + { + 15, + L" System Event Log " + }, + { + 16, + L" Physical Memory Array " + }, + { + 17, + L" Memory Device " + }, + { + 18, + L" 32-bit Memory Error Information " + }, + { + 19, + L" Memory Array Mapped Address " + }, + { + 20, + L" Memory Device Mapped Address " + }, + { + 21, + L" Built-in Pointing Device " + }, + { + 22, + L" Portable Battery " + }, + { + 23, + L" System Reset " + }, + { + 24, + L" Hardware Security " + }, + { + 25, + L" System Power Controls " + }, + { + 26, + L" Voltage Probe " + }, + { + 27, + L" Cooling Device " + }, + { + 28, + L" Temperature Probe " + }, + { + 29, + L" Electrical Current Probe " + }, + { + 30, + L" Out-of-Band Remote Access " + }, + { + 31, + L" Boot Integrity Services (BIS) Entry Point" + }, + { + 32, + L" System Boot Information " + }, + { + 33, + L" 64-bit Memory Error Information " + }, + { + 34, + L" Management Device " + }, + { + 35, + L" Management Device Component " + }, + { + 36, + L" Management Device Threshold Data " + }, + { + 37, + L" Memory Channel " + }, + { + 38, + L" IPMI Device Information " + }, + { + 39, + L" System Power Supply" + }, + { + 0x7E, + L" Inactive" + }, + { + 0x7F, + L" End-of-Table " + }, +}; + + +UINT8 +QueryTable ( + IN TABLE_ITEM *Table, + IN UINTN Number, + IN UINT8 Key, + IN OUT CHAR16 *Info + ) +/*++ +Routine Description: + Function Description + Given a table and a Key, return the responding info. + + Arguments: + Table - The begin address of table + Number - The number of table items + Key - The query Key + Info - Input as empty buffer; output as data buffer. + + Returns: + if Key found - return found Key and Info + if Key unfound - return QUERY_TABLE_UNFOUND, Info=NULL + + Notes: + Table[Index].Key is change from UINT8 to UINT16, + in order to deal with "0xaa - 0xbb". + + For example: + DisplaySELVariableDataFormatTypes(UINT8 Type, UINT8 Option) + has a item: + "0x07-0x7F, Unused" + Now define Key = 0x7F07, that is to say: High = 0x7F, Low = 0x07. + Then all the Key Value between Low and High gets the same string + L"Unused". + +**/ +{ + UINTN Index; + // + // High byte and Low byte of word + // + UINT8 High; + UINT8 Low; + + for (Index = 0; Index < Number; Index++) { + High = (UINT8) (Table[Index].Key >> 8); + Low = (UINT8) (Table[Index].Key & 0x00FF); + // + // Check if Key is in the range + // + if (High > Low && Key >= Low && Key <= High) { + StrCpy (Info, Table[Index].Info); + StrCat (Info, L"\n"); + return Key; + } + // + // Check if Key == Value in the table + // + if (Table[Index].Key == Key) { + StrCpy (Info, Table[Index].Info); + StrCat (Info, L"\n"); + return Key; + } + } + + StrCpy (Info, L"Undefined Value\n"); + return QUERY_TABLE_UNFOUND; +} + +VOID +PrintBitsInfo ( + IN TABLE_ITEM *Table, + IN UINTN Number, + IN UINT32 Bits + ) +/*++ + + Routine Description: + Given a table of bit info and a Key, + return the responding info to the Key. + + Arguments: + Table - Point to a table which maintains a map of 'bit' to 'message' + Number - Number of table items. + Bits - The Key of query the bit map information. + + Returns: + None + +**/ +{ + // + // Get certain bit of 'Value': + // +#define BIT(Value, bit) ((Value) & ((UINT32) 1) << (bit)) + // + // Clear certain bit of 'Value': + // +#define CLR_BIT(Value, bit) ((Value) -= (BIT (Value, bit))) + + UINTN Index; + UINT32 Value; + BOOLEAN NoInfo; + + NoInfo = TRUE; + Value = Bits; + // + // query the table and print information + // + for (Index = 0; Index < Number; Index++) { + if (BIT (Value, Table[Index].Key) != 0) { + Print (Table[Index].Info); + Print (L" | "); + + NoInfo = FALSE; + // + // clear the bit, for reserved bits test + // + CLR_BIT (Value, Table[Index].Key); + } + } + + if (NoInfo) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_NO_INFO), gShellDebug1HiiHandle); + } + + if (Value != 0) { + ShellPrintHiiEx(-1,-1,NULL, + STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_RSVD_BITS_SET), + gShellDebug1HiiHandle, + Value + ); + } + + Print (L"\n"); +} +// +// ////////////////////////////////////////////////////////////////// +// +// Following uses QueryTable functions to simplify the coding. +// QueryTable(), PrintBitsInfo() +// +// +#define PRINT_TABLE_ITEM(Table, Key) \ + do { \ + UINTN Num; \ + CHAR16 Info[66]; \ + Num = sizeof (Table) / sizeof (TABLE_ITEM); \ + ZeroMem (Info, sizeof (Info)); \ + QueryTable (Table, Num, Key, Info); \ + Print (Info); \ + } while (0); + +#define PRINT_BITS_INFO(Table, bits) \ + do { \ + UINTN Num; \ + Num = sizeof (Table) / sizeof (TABLE_ITEM); \ + PrintBitsInfo (Table, Num, (UINT32) bits); \ + } while (0); + +// +//////////////////////////////////////////////////////////////////// +// +// System Information (Type 1) +// +VOID +DisplaySystemWakeupType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_WAKEUP_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (SystemWakeupTypeTable, Type); +} +// +// System Enclosure (Type 3) +// +VOID +DisplaySystemEnclosureType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_CHASSIS_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + // + // query table and print info + // + PRINT_TABLE_ITEM (SystemEnclosureTypeTable, Type); + + if (BIT (Type, 7) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_CHASSIS_LOCK_PRESENT), gShellDebug1HiiHandle); + } +} + +VOID +DisplaySystemEnclosureStatus ( + UINT8 Status, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_CHASSIS_STATUS), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Status, Option); + PRINT_TABLE_ITEM (SystemEnclosureStatusTable, Status); +} + +VOID +DisplaySESecurityStatus ( + UINT8 Status, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_CHASSIS_SECURITY), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Status, Option); + PRINT_TABLE_ITEM (SESecurityStatusTable, Status); +} +// +// Processor Information (Type 4) +// +VOID +DisplayProcessorType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PROC_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (ProcessorTypeTable, Type); +} + +VOID +DisplayProcessorUpgrade ( + UINT8 Upgrade, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PROC_UPDATE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Upgrade, Option); + PRINT_TABLE_ITEM (ProcessorUpgradeTable, Upgrade); +} +// +// Memory Controller Information (Type 5) +// +VOID +DisplayMcErrorDetectMethod ( + UINT8 Method, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_DETECTMETHOD), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Method, Option); + PRINT_TABLE_ITEM (McErrorDetectMethodTable, Method); +} + +VOID +DisplayMcErrorCorrectCapability ( + UINT8 Capability, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_CORRECT_CAPABILITY), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Capability, Option); + PRINT_BITS_INFO (McErrorCorrectCapabilityTable, Capability); +} + +VOID +DisplayMcInterleaveSupport ( + UINT8 Support, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_INTERLEAVE_SUPPORT), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Support, Option); + PRINT_TABLE_ITEM (McInterleaveSupportTable, Support); +} + +VOID +DisplayMcMemorySpeeds ( + UINT16 Speed, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_MEMORY_SPEED), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Speed, Option); + PRINT_BITS_INFO (McMemorySpeedsTable, Speed); +} + +VOID +DisplayMemoryModuleVoltage ( + UINT8 Voltage, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_REQUIRED_VOLTAGES), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Voltage, Option); + PRINT_BITS_INFO (MemoryModuleVoltageTable, Voltage); +} +// +// Memory Module Information (Type 6) +// +VOID +DisplayMmMemoryType ( + UINT16 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_MODULE_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_BITS_INFO (MmMemoryTypeTable, Type); +} + +VOID +DisplayMmErrorStatus ( + UINT8 Status, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_MODULE_ERROR_STATUS), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Status, Option); + PRINT_BITS_INFO (MmErrorStatusTable, Status); +} +// +// Cache Information (Type 7) +// +VOID +DisplayCacheSRAMType ( + UINT16 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_CACHE_SRAM_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION ((UINT8) Type, Option); + PRINT_BITS_INFO (CacheSRAMTypeTable, (UINT8) Type); +} + +VOID +DisplayCacheErrCorrectingType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_CACHE_ERROR_CORRECTING), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (CacheErrCorrectingTypeTable, Type); +} + +VOID +DisplayCacheSystemCacheType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_CACHE_SYSTEM_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (CacheSystemCacheTypeTable, Type); +} + +VOID +DisplayCacheAssociativity ( + UINT8 Associativity, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_CACHE_ASSOCIATIVITY), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Associativity, Option); + PRINT_TABLE_ITEM (CacheAssociativityTable, Associativity); +} +// +// Port Connector Information (Type 8) +// +VOID +DisplayPortConnectorType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PORT_CONNECTOR_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (PortConnectorTypeTable, Type); +} + +VOID +DisplayPortType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PORT_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (PortTypeTable, Type); +} +// +// System Slots (Type 9) +// +VOID +DisplaySystemSlotType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_SLOT_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (SystemSlotTypeTable, Type); +} + +VOID +DisplaySystemSlotDataBusWidth ( + UINT8 Width, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_SLOT_DATA), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Width, Option); + PRINT_TABLE_ITEM (SystemSlotDataBusWidthTable, Width); +} + +VOID +DisplaySystemSlotCurrentUsage ( + UINT8 Usage, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_SLOT_CURRENT_USAGE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Usage, Option); + PRINT_TABLE_ITEM (SystemSlotCurrentUsageTable, Usage); +} + +VOID +DisplaySystemSlotLength ( + UINT8 Length, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_SLOT_LENGTH), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Length, Option); + PRINT_TABLE_ITEM (SystemSlotLengthTable, Length); +} + +VOID +DisplaySlotCharacteristics1 ( + UINT8 Chara1, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SLOT_CHARACTERISTICS), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Chara1, Option); + PRINT_BITS_INFO (SlotCharacteristics1Table, Chara1); +} + +VOID +DisplaySlotCharacteristics2 ( + UINT8 Chara2, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SLOT_CHARACTERISTICS_2), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Chara2, Option); + PRINT_BITS_INFO (SlotCharacteristics2Table, Chara2); +} +// +// On Board Devices Information (Type 10) +// +VOID +DisplayOnboardDeviceTypes ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_ONBOARD_DEVICE_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (OnboardDeviceTypesTable, Type); +} +// +// System Event Log (Type 15) +// +VOID +DisplaySELTypes ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_EVENT_LOG_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (SELTypesTable, Type); +} + +VOID +DisplaySELVarDataFormatType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_EVENT_LOG_VAR_DATA_FORMAT), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (SELVarDataFormatTypeTable, Type); +} + +VOID +DisplayPostResultsBitmapDw1 ( + UINT32 Key, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_POST_RESULTS_BITMAP), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + PRINT_BITS_INFO (PostResultsBitmapDw1Table, Key); +} + +VOID +DisplayPostResultsBitmapDw2 ( + UINT32 Key, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_POST_RESULTS_SECOND_DWORD), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + PRINT_BITS_INFO (PostResultsBitmapDw2Table, Key); +} + +VOID +DisplaySELSysManagementTypes ( + UINT32 SMType, + UINT8 Option + ) +{ + UINT8 Temp; + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_MANAGEMENT_TYPES), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (SMType, Option); + + // + // Deal with wide range Value + // + if (SMType >= 0x80000000) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_OEM_ASSIGNED), gShellDebug1HiiHandle); + } else if (SMType >= 0x00020000) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_RSVD_FOR_FUTURE_ASSIGN), gShellDebug1HiiHandle); + } else if (SMType >= 0x00010000) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_MANAGEMENT_PROBE), gShellDebug1HiiHandle); + } else if (SMType >= 0x31) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_RSVD_FOR_FUTURE_ASSIGN), gShellDebug1HiiHandle); + } else { + // + // Deal with One byte data + // + Temp = (UINT8) (SMType & 0x3F); + PRINT_TABLE_ITEM (SELSysManagementTypesTable, Temp); + } +} +// +// Physical Memory Array (Type 16) +// +VOID +DisplayPMALocation ( + UINT8 Location, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PHYS_MEM_ARRAY_LOCATION), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Location, Option); + PRINT_TABLE_ITEM (PMALocationTable, Location); +} + +VOID +DisplayPMAUse ( + UINT8 Use, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PHYS_MEM_ARRAY_LOCATION), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Use, Option); + PRINT_TABLE_ITEM (PMAUseTable, Use); +} + +VOID +DisplayPMAErrorCorrectionTypes ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PHYS_MEM_ARRAY_ERROR), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (PMAErrorCorrectionTypesTable, Type); +} +// +// Memory Device (Type 17) +// +VOID +DisplayMemoryDeviceFormFactor ( + UINT8 FormFactor, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_DEVICE_FORM_FACTOR), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (FormFactor, Option); + PRINT_TABLE_ITEM (MemoryDeviceFormFactorTable, FormFactor); +} + +VOID +DisplayMemoryDeviceType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_DEVICE_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (MemoryDeviceTypeTable, Type); +} + +VOID +DisplayMemoryDeviceTypeDetail ( + UINT16 para, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_DEVICE_TYPE_DETAIL), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (para, Option); + PRINT_BITS_INFO (MemoryDeviceTypeDetailTable, para); +} +// +// 32-bit Memory Error Information (Type 18) +// +VOID +DisplayMemoryErrorType ( + UINT8 ErrorType, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_ERROR_INFO), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (ErrorType, Option); + PRINT_TABLE_ITEM (MemoryErrorTypeTable, ErrorType); +} + +VOID +DisplayMemoryErrorGranularity ( + UINT8 Granularity, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_ERROR_GRANULARITY), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Granularity, Option); + PRINT_TABLE_ITEM (MemoryErrorGranularityTable, Granularity); +} + +VOID +DisplayMemoryErrorOperation ( + UINT8 Operation, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_ERROR_OP), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Operation, Option); + PRINT_TABLE_ITEM (MemoryErrorOperationTable, Operation); +} +// +// Built-in Pointing Device (Type 21) +// +VOID +DisplayPointingDeviceType ( + UINT8 Type, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_POINTING_DEVICE_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (PointingDeviceTypeTable, Type); +} + +VOID +DisplayPointingDeviceInterface ( + UINT8 Interface, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_POINTING_DEVICE_INTERFACE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Interface, Option); + PRINT_TABLE_ITEM (PointingDeviceInterfaceTable, Interface); +} +// +// Portable Battery (Type 22) +// +VOID +DisplayPBDeviceChemistry ( + UINT8 Key, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PORTABLE_BATT_DEV_CHEM), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + PRINT_TABLE_ITEM (PBDeviceChemistryTable, Key); +} +// +// Voltage Probe (Type 26) +// +VOID +DisplayVPLocation ( + UINT8 Key, + UINT8 Option + ) +{ + UINT8 Loc; + + Loc = (UINT8) ((Key & 0xE0) >> 5); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_VOLTAGE_PROBE_LOC), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Loc, Option); + PRINT_TABLE_ITEM (VPLocationTable, Loc); +} + +VOID +DisplayVPStatus ( + UINT8 Key, + UINT8 Option + ) +{ + UINT8 Status; + + Status = (UINT8) (Key & 0x1F); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_VOLTAGE_PROBE_STATUS), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Status, Option); + PRINT_TABLE_ITEM (VPStatusTable, Status); +} +// +// Voltage Probe (Type 27) +// +VOID +DisplayCoolingDeviceStatus ( + UINT8 Key, + UINT8 Option + ) +{ + UINT8 Status; + + Status = (UINT8) ((Key & 0xE0) >> 5); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_COOLING_DEV_STATUS), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Status, Option); + PRINT_TABLE_ITEM (CoolingDeviceStatusTable, Status); +} + +VOID +DisplayCoolingDeviceType ( + UINT8 Key, + UINT8 Option + ) +{ + UINT8 Type; + + Type = (UINT8) (Key & 0x1F); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_COOLING_DEV_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Type, Option); + PRINT_TABLE_ITEM (CoolingDeviceTypeTable, Type); +} +// +// Temperature Probe (Type 28) +// +VOID +DisplayTemperatureProbeStatus ( + UINT8 Key, + UINT8 Option + ) +{ + UINT8 Status; + + Status = (UINT8) ((Key & 0xE0) >> 5); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_TEMP_PROBE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Status, Option); + PRINT_TABLE_ITEM (TemperatureProbeStatusTable, Status); +} + +VOID +DisplayTemperatureProbeLoc ( + UINT8 Key, + UINT8 Option + ) +{ + UINT8 Loc; + + Loc = (UINT8) (Key & 0x1F); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_VOLTAGE_PROBE_LOC), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Loc, Option); + PRINT_TABLE_ITEM (TemperatureProbeLocTable, Loc); +} +// +// Electrical Current Probe (Type 29) +// +VOID +DisplayECPStatus ( + UINT8 Key, + UINT8 Option + ) +{ + UINT8 Status; + + Status = (UINT8) ((Key & 0xE0) >> 5); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_ELEC_PROBE_STATUS), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Status, Option); + PRINT_TABLE_ITEM (ECPStatusTable, Status); +} + +VOID +DisplayECPLoc ( + UINT8 Key, + UINT8 Option + ) +{ + UINT8 Loc; + + Loc = (UINT8) (Key & 0x1F); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_ELEC_PROBE_LOC), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Loc, Option); + PRINT_TABLE_ITEM (ECPLocTable, Loc); +} +// +// Management Device (Type 34) +// +VOID +DisplayMDType ( + UINT8 Key, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MANAGEMENT_DEV_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + PRINT_TABLE_ITEM (MDTypeTable, Key); +} + +VOID +DisplayMDAddressType ( + UINT8 Key, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MANAGEMENT_DEV_ADDR_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + PRINT_TABLE_ITEM (MDAddressTypeTable, Key); +} +// +// Memory Channel (Type 37) +// +VOID +DisplayMemoryChannelType ( + UINT8 Key, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_CHANNEL_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + PRINT_TABLE_ITEM (MemoryChannelTypeTable, Key); +} +// +// IPMI Device Information (Type 38) +// +VOID +DisplayIPMIDIBMCInterfaceType ( + UINT8 Key, + UINT8 Option + ) +{ + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_BMC_INTERFACE_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + PRINT_TABLE_ITEM (IPMIDIBMCInterfaceTypeTable, Key); +} + +VOID +DisplayStructureTypeInfo ( + UINT8 Key, + UINT8 Option + ) +{ + // + // display + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_STRUCT_TYPE), gShellDebug1HiiHandle); + PRINT_INFO_OPTION (Key, Option); + PRINT_TABLE_ITEM (StructureTypeInfoTable, Key); +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h new file mode 100644 index 0000000000..adacc41cf3 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h @@ -0,0 +1,430 @@ +/** @file + Build a table, each item is (key, info) pair. + and give a interface of query a string out of a table. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMBIOS_QUERY_TABLE_H +#define _SMBIOS_QUERY_TABLE_H + +#define QUERY_TABLE_UNFOUND 0xFF + +typedef struct TABLE_ITEM { + UINT16 Key; + CHAR16 *Info; +} TABLE_ITEM; + +// +// Print info by option +// +#define PRINT_INFO_OPTION(Value, Option) \ + do { \ + if (Option == SHOW_NONE) { \ + return ; \ + } \ + if (Option < SHOW_DETAIL) { \ + Print (L"0x%x\n", Value); \ + return ; \ + } \ + } while (0); + +UINT8 +QueryTable ( + IN TABLE_ITEM *Table, + IN UINTN Number, + IN UINT8 Key, + IN OUT CHAR16 *Info + ); + +VOID +PrintBitsInfo ( + IN TABLE_ITEM *Table, + IN UINTN Number, + IN UINT32 Bits + ); + +// +// Display the element detail information +// +VOID +DisplayStructureTypeInfo ( + UINT8 Key, + UINT8 Option + ); + +// +// System Information (Type 1) +// +VOID +DisplaySystemWakeupType ( + UINT8 Type, + UINT8 Option + ); + +// +// System Enclosure (Type 3) +// +VOID +DisplaySystemEnclosureType ( + UINT8 Type, + UINT8 Option + ); +VOID +DisplaySystemEnclosureStatus ( + UINT8 Status, + UINT8 Option + ); +VOID +DisplaySESecurityStatus ( + UINT8 Status, + UINT8 Option + ); + +// +// Processor Information (Type 4) +// +VOID +DisplayProcessorType ( + UINT8 Type, + UINT8 Option + ); +VOID +DisplayProcessorUpgrade ( + UINT8 Upgrade, + UINT8 Option + ); + +// +// Memory Controller Information (Type 5) +// +VOID +DisplayMcErrorDetectMethod ( + UINT8 Method, + UINT8 Option + ); +VOID +DisplayMcErrorCorrectCapability ( + UINT8 Capability, + UINT8 Option + ); +VOID +DisplayMcInterleaveSupport ( + UINT8 Support, + UINT8 Option + ); +VOID +DisplayMcMemorySpeeds ( + UINT16 Speed, + UINT8 Option + ); +VOID +DisplayMemoryModuleVoltage ( + UINT8 Voltage, + UINT8 Option + ); + +// +// Memory Module Information (Type 6) +// +VOID +DisplayMmMemoryType ( + UINT16 Type, + UINT8 Option + ); +VOID +DisplayMmErrorStatus ( + UINT8 Status, + UINT8 Option + ); + +// +// Cache Information (Type 7) +// +VOID +DisplayCacheSRAMType ( + UINT16 Type, + UINT8 Option + ); +VOID +DisplayCacheErrCorrectingType ( + UINT8 Type, + UINT8 Option + ); +VOID +DisplayCacheSystemCacheType ( + UINT8 Type, + UINT8 Option + ); +VOID +DisplayCacheAssociativity ( + UINT8 Associativity, + UINT8 Option + ); + +// +// Port Connector Information (Type 8) +// +VOID +DisplayPortConnectorType ( + UINT8 Type, + UINT8 Option + ); +VOID +DisplayPortType ( + UINT8 Type, + UINT8 Option + ); + +// +// System Slots (Type 9) +// +VOID +DisplaySystemSlotType ( + UINT8 Type, + UINT8 Option + ); +VOID +DisplaySystemSlotDataBusWidth ( + UINT8 Width, + UINT8 Option + ); +VOID +DisplaySystemSlotCurrentUsage ( + UINT8 Usage, + UINT8 Option + ); +VOID +DisplaySystemSlotLength ( + UINT8 Length, + UINT8 Option + ); +VOID +DisplaySlotCharacteristics1 ( + UINT8 Chara1, + UINT8 Option + ); +VOID +DisplaySlotCharacteristics2 ( + UINT8 Chara2, + UINT8 Option + ); + +// +// On Board Devices Information (Type 10) +// +VOID +DisplayOnboardDeviceTypes ( + UINT8 Type, + UINT8 Option + ); + +// +// System Event Log (Type 15) +// +VOID +DisplaySELTypes ( + UINT8 Type, + UINT8 Option + ); +VOID +DisplaySELVarDataFormatType ( + UINT8 Type, + UINT8 Option + ); +VOID +DisplayPostResultsBitmapDw1 ( + UINT32 Key, + UINT8 Option + ); +VOID +DisplayPostResultsBitmapDw2 ( + UINT32 Key, + UINT8 Option + ); +VOID +DisplaySELSysManagementTypes ( + UINT32 SMType, + UINT8 Option + ); + +// +// Physical Memory Array (Type 16) +// +VOID +DisplayPMALocation ( + UINT8 Location, + UINT8 Option + ); +VOID +DisplayPMAUse ( + UINT8 Use, + UINT8 Option + ); +VOID +DisplayPMAErrorCorrectionTypes ( + UINT8 Type, + UINT8 Option + ); + +// +// Memory Device (Type 17) +// +VOID +DisplayMemoryDeviceFormFactor ( + UINT8 FormFactor, + UINT8 Option + ); +VOID +DisplayMemoryDeviceType ( + UINT8 Type, + UINT8 Option + ); +VOID +DisplayMemoryDeviceTypeDetail ( + UINT16 Parameter, + UINT8 Option + ); + +// +// 32-bit Memory Error Information (Type 18) +// +VOID +DisplayMemoryErrorType ( + UINT8 ErrorType, + UINT8 Option + ); +VOID +DisplayMemoryErrorGranularity ( + UINT8 Granularity, + UINT8 Option + ); +VOID +DisplayMemoryErrorOperation ( + UINT8 Operation, + UINT8 Option + ); + +// +// Memory Array Mapped Address (Type 19) +// Memory Device Mapped Address (Type 20) +// +// Built-in Pointing Device (Type 21) +// +VOID +DisplayPointingDeviceType ( + UINT8 Type, + UINT8 Option + ); +VOID +DisplayPointingDeviceInterface ( + UINT8 Interface, + UINT8 Option + ); + +// +// Portable Battery (Type 22) +// +VOID +DisplayPBDeviceChemistry ( + UINT8 Key, + UINT8 Option + ); + +// +// Voltage Probe (Type 26) +// +VOID +DisplayVPLocation ( + UINT8 Key, + UINT8 Option + ); +VOID +DisplayVPStatus ( + UINT8 Key, + UINT8 Option + ); + +// +// Voltage Probe (Type 27) +// +VOID +DisplayCoolingDeviceStatus ( + UINT8 Key, + UINT8 Option + ); +VOID +DisplayCoolingDeviceType ( + UINT8 Key, + UINT8 Option + ); + +// +// Temperature Probe (Type 28) +// +VOID +DisplayTemperatureProbeStatus ( + UINT8 Key, + UINT8 Option + ); +VOID +DisplayTemperatureProbeLoc ( + UINT8 Key, + UINT8 Option + ); + +// +// Electrical Current Probe (Type 29) +// +VOID +DisplayECPStatus ( + UINT8 Key, + UINT8 Option + ); +VOID +DisplayECPLoc ( + UINT8 Key, + UINT8 Option + ); + +// +// Management Device (Type 34) +// +VOID +DisplayMDType ( + UINT8 Key, + UINT8 Option + ); +VOID +DisplayMDAddressType ( + UINT8 Key, + UINT8 Option + ); + +// +// Memory Channel (Type 37) +// +VOID +DisplayMemoryChannelType ( + UINT8 Key, + UINT8 Option + ); + +// +// IPMI Device Information (Type 38) +// +VOID +DisplayIPMIDIBMCInterfaceType ( + UINT8 Key, + UINT8 Option + ); + +#endif diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/Smbios.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/Smbios.c new file mode 100644 index 0000000000..8d21967dcc --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/Smbios.c @@ -0,0 +1,126 @@ +/** @file + Lib fucntions for SMBIOS. Used to get system serial number and GUID + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "../UefiShellDebug1CommandsLib.h" +#include +#include "LibSmbios.h" + +EFI_STATUS +LibGetSmbiosSystemGuidAndSerialNumber ( + IN EFI_GUID *SystemGuid, + OUT CHAR8 **SystemSerialNumber + ) +{ + EFI_STATUS Status; + SMBIOS_STRUCTURE_TABLE *SmbiosTable; + SMBIOS_STRUCTURE_POINTER Smbios; + SMBIOS_STRUCTURE_POINTER SmbiosEnd; + UINT16 Index; + + Status = GetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **) &SmbiosTable); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + Smbios.Hdr = (SMBIOS_HEADER *) ((UINTN) (SmbiosTable->TableAddress)); + + SmbiosEnd.Raw = (UINT8 *) ((UINTN) (SmbiosTable->TableAddress + SmbiosTable->TableLength)); + for (Index = 0; Index < SmbiosTable->TableLength; Index++) { + if (Smbios.Hdr->Type == 1) { + if (Smbios.Hdr->Length < 0x19) { + // + // Older version did not support Guid and Serial number + // + continue; + } + // + // SMBIOS tables are byte packed so we need to do a byte copy to + // prevend alignment faults on Itanium-based platform. + // + CopyMem (SystemGuid, &Smbios.Type1->Uuid, sizeof (EFI_GUID)); + *SystemSerialNumber = LibGetSmbiosString (&Smbios, Smbios.Type1->SerialNumber); + return EFI_SUCCESS; + } + // + // Make Smbios point to the next record + // + LibGetSmbiosString (&Smbios, (UINT16) (-1)); + + if (Smbios.Raw >= SmbiosEnd.Raw) { + // + // SMBIOS 2.1 incorrectly stated the length of SmbiosTable as 0x1e. + // given this we must double check against the lenght of + // the structure. My home PC has this bug.ruthard + // + return EFI_SUCCESS; + } + } + + return EFI_SUCCESS; +} + +CHAR8 * +LibGetSmbiosString ( + IN SMBIOS_STRUCTURE_POINTER *Smbios, + IN UINT16 StringNumber + ) +/*++ +Routine Description: + Return SMBIOS string given the string number. + + Arguments: + Smbios - Pointer to SMBIOS structure + StringNumber - String number to return. -1 is used to skip all strings and + point to the next SMBIOS structure. + + Returns: + Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1 +**/ +{ + UINT16 Index; + CHAR8 *String; + + ASSERT (Smbios != NULL); + + // + // Skip over formatted section + // + String = (CHAR8 *) (Smbios->Raw + Smbios->Hdr->Length); + + // + // Look through unformated section + // + for (Index = 1; Index <= StringNumber; Index++) { + if (StringNumber == Index) { + return String; + } + // + // Skip string + // + for (; *String != 0; String++); + String++; + + if (*String == 0) { + // + // If double NULL then we are done. + // Retrun pointer to next structure in Smbios. + // if you pass in a -1 you will always get here + // + Smbios->Raw = (UINT8 *)++String; + return NULL; + } + } + + return NULL; +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c new file mode 100644 index 0000000000..b9ff013d60 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c @@ -0,0 +1,547 @@ +/** @file + Tools of clarify the content of the smbios table. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "../UefiShellDebug1CommandsLib.h" +#include "LibSmbiosView.h" +#include "smbiosview.h" +#include "PrintInfo.h" +#include "QueryTable.h" + +UINT8 gShowType = SHOW_DETAIL; +STATIC STRUCTURE_STATISTICS *mStatisticsTable = NULL; + +UINT8 SmbiosMajorVersion; +UINT8 SmbiosMinorVersion; + +STATIC CONST SHELL_PARAM_ITEM ParamList[] = { + {L"-t", TypeValue}, + {L"-h", TypeValue}, + {L"-s", TypeFlag}, + {L"-a", TypeFlag}, + {NULL, TypeMax} + }; + +SHELL_STATUS +EFIAPI +ShellCommandRunSmbiosView ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + UINT8 StructType; + UINT16 StructHandle; + EFI_STATUS Status; + BOOLEAN RandomView; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + CONST CHAR16 *Temp; + + mStatisticsTable = NULL; + Package = NULL; + ShellStatus = SHELL_SUCCESS; + + Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); + if (EFI_ERROR(Status)) { + if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + FreePool(ProblemParam); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ASSERT(FALSE); + } + } else { + if (ShellCommandLineGetCount(Package) > 1) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + + // + // Init Lib + // + Status = LibSmbiosInit (); + if (EFI_ERROR (Status)) { + ShellStatus = SHELL_NOT_FOUND; + goto Done; + } + // + // build statistics table + // + Status = InitSmbiosTableStatistics (); + if (EFI_ERROR (Status)) { + ShellStatus = SHELL_NOT_FOUND; + goto Done; + } + + StructType = STRUCTURE_TYPE_RANDOM; + RandomView = TRUE; + // + // Initialize the StructHandle to be the first handle + // + StructHandle = STRUCTURE_HANDLE_INVALID; + LibGetSmbiosStructure (&StructHandle, NULL, NULL); + + Temp = ShellCommandLineGetValue(Package, L"-t"); + if (Temp != NULL) { + StructType = (UINT8) ShellStrToUintn (Temp); + } + + Temp = ShellCommandLineGetValue(Package, L"-h"); + if (Temp != NULL) { + RandomView = FALSE; + StructHandle = (UINT16) ShellStrToUintn(Temp); + } + + if (ShellCommandLineGetFlag(Package, L"-s")) { + Status = DisplayStatisticsTable (SHOW_DETAIL); + if (EFI_ERROR(Status)) { + ShellStatus = SHELL_NOT_FOUND; + } + goto Done; + } + + if (ShellCommandLineGetFlag(Package, L"-a")) { + gShowType = SHOW_ALL; + } + // + // Show SMBIOS structure information + // + Status = SMBiosView (StructType, StructHandle, gShowType, RandomView); + if (EFI_ERROR(Status)) { + ShellStatus = SHELL_NOT_FOUND; + } + } + } +Done: + // + // Release resources + // + if (mStatisticsTable != NULL) { + // + // Release statistics table + // + FreePool (mStatisticsTable); + mStatisticsTable = NULL; + } + + if (Package != NULL) { + ShellCommandLineFreeVarList (Package); + } + + LibSmbiosCleanup (); + + return ShellStatus; +} + +/** + Query all structures Data from SMBIOS table and Display + the information to users as required display option. + + @param[in] QueryType Structure type to view. + @param[in] QueryHandle Structure handle to view. + @param[in] Option Display option: none,outline,normal,detail. + @param[in] RandomView Support for -h parameter. + + @retval EFI_SUCCESS print is successful. + @retval EFI_BAD_BUFFER_SIZE structure is out of the range of SMBIOS table. +**/ +EFI_STATUS +EFIAPI +SMBiosView ( + IN UINT8 QueryType, + IN UINT16 QueryHandle, + IN UINT8 Option, + IN BOOLEAN RandomView + ) +{ + UINT16 Handle; + UINT8 Buffer[1024]; + // + // bigger than SMBIOS_STRUCTURE_TABLE.MaxStructureSize + // + UINT16 Length; + UINTN Index; + UINT16 Offset; + // + // address offset from structure table head. + // + UINT32 TableHead; + // + // structure table head. + // + + SMBIOS_STRUCTURE_POINTER pStruct; + SMBIOS_STRUCTURE_TABLE *SMBiosTable; + + SMBiosTable = NULL; + LibSmbiosGetEPS (&SMBiosTable); + if (SMBiosTable == NULL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle); + return EFI_BAD_BUFFER_SIZE; + } + + if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) == 0) { + // + // Have get SMBIOS table + // + SmbiosPrintEPSInfo (SMBiosTable, Option); + + SmbiosMajorVersion = SMBiosTable->MajorVersion; + SmbiosMinorVersion = SMBiosTable->MinorVersion; + + ShellPrintEx(-1,-1,L"=========================================================\n"); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERY_STRUCT_COND), gShellDebug1HiiHandle); + + if (QueryType == STRUCTURE_TYPE_RANDOM) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE_RANDOM), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE), gShellDebug1HiiHandle, QueryType); + } + + if (RandomView) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE_RANDOM), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE), gShellDebug1HiiHandle, QueryHandle); + } + + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SHOWTYPE), gShellDebug1HiiHandle); + ShellPrintEx(-1,-1,GetShowTypeString (gShowType)); + ShellPrintEx(-1,-1,L"\n\n"); + +/* + // + // Get internal commands, such as change options. + // + Status = WaitEnter (); + if (EFI_ERROR (Status)) { + if (Status == EFI_ABORTED) { + return EFI_SUCCESS; + } + + return Status; + } +*/ + + // + // Searching and display structure info + // + Handle = QueryHandle; + TableHead = SMBiosTable->TableAddress; + Offset = 0; + for (Index = 0; Index < SMBiosTable->NumberOfSmbiosStructures; Index++) { + // + // if reach the end of table, break.. + // + if (Handle == STRUCTURE_HANDLE_INVALID) { + break; + } + // + // handle then point to the next! + // + if (LibGetSmbiosStructure (&Handle, Buffer, &Length) != DMI_SUCCESS) { + break; + } + Offset = (UINT16) (Offset + Length); + pStruct.Raw = Buffer; + + // + // if QueryType==Random, print this structure. + // if QueryType!=Random, but Hdr->Type==QueryType, also print it. + // only if QueryType != Random and Hdr->Type != QueryType, skiped it. + // + if (QueryType != STRUCTURE_TYPE_RANDOM && pStruct.Hdr->Type != QueryType) { + continue; + } + + ShellPrintEx(-1,-1,L"\n=========================================================\n"); + ShellPrintHiiEx(-1,-1,NULL, + STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE_HANDLE_DUMP_STRUCT), + gShellDebug1HiiHandle, + pStruct.Hdr->Type, + pStruct.Hdr->Handle + ); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX_LENGTH), gShellDebug1HiiHandle, Index, Length); + // + // Addr of structure in structure in table + // + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ADDR), gShellDebug1HiiHandle, TableHead + Offset); + DumpHex (0, 0, Length, Buffer); + +/* + // + // Get internal commands, such as change options. + // + Status = WaitEnter (); + if (EFI_ERROR (Status)) { + if (Status == EFI_ABORTED) { + return EFI_SUCCESS; + } + + return Status; + } +*/ + + if (gShowType != SHOW_NONE) { + // + // check structure legality + // + SmbiosCheckStructure (&pStruct); + + // + // Print structure information + // + SmbiosPrintStructure (&pStruct, gShowType); + ShellPrintEx(-1,-1,L"\n"); + +/* + // + // Get internal commands, such as change options. + // + Status = WaitEnter (); + if (EFI_ERROR (Status)) { + if (Status == EFI_ABORTED) { + return EFI_SUCCESS; + } + + return Status; + } +*/ + } + if (!RandomView) { + break; + } + } + + ShellPrintEx(-1,-1,L"\n=========================================================\n"); + return EFI_SUCCESS; + } + + return EFI_BAD_BUFFER_SIZE; +} + +/** + Function to initialize the global mStatisticsTable object. + + @retval EFI_SUCCESS print is successful. +**/ +EFI_STATUS +EFIAPI +InitSmbiosTableStatistics ( + VOID + ) +{ + UINT16 Handle; + UINT8 Buffer[1024]; + UINT16 Length; + UINT16 Offset; + UINT16 Index; + + SMBIOS_STRUCTURE_POINTER pStruct; + SMBIOS_STRUCTURE_TABLE *SMBiosTable; + STRUCTURE_STATISTICS *pStatistics; + + SMBiosTable = NULL; + LibSmbiosGetEPS (&SMBiosTable); + if (SMBiosTable == NULL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle); + return EFI_NOT_FOUND; + } + + if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) != 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE), gShellDebug1HiiHandle); + return EFI_INVALID_PARAMETER; + } + // + // Allocate memory to mStatisticsTable + // + if (mStatisticsTable != NULL) { + FreePool (mStatisticsTable); + mStatisticsTable = NULL; + } + + mStatisticsTable = (STRUCTURE_STATISTICS *) AllocatePool (SMBiosTable->NumberOfSmbiosStructures * sizeof (STRUCTURE_STATISTICS)); + + if (mStatisticsTable == NULL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM), gShellDebug1HiiHandle); + return EFI_OUT_OF_RESOURCES; + } + + Offset = 0; + pStatistics = mStatisticsTable; + + // + // search from the first one + // + Handle = STRUCTURE_HANDLE_INVALID; + LibGetSmbiosStructure (&Handle, NULL, NULL); + for (Index = 1; Index <= SMBiosTable->NumberOfSmbiosStructures; Index++) { + // + // If reach the end of table, break.. + // + if (Handle == STRUCTURE_HANDLE_INVALID) { + break; + } + // + // After LibGetSmbiosStructure(), handle then point to the next! + // + if (LibGetSmbiosStructure (&Handle, Buffer, &Length) != DMI_SUCCESS) { + break; + } + + pStruct.Raw = Buffer; + Offset = (UINT16) (Offset + Length); + + // + // general statistics + // + pStatistics->Index = Index; + pStatistics->Type = pStruct.Hdr->Type; + pStatistics->Handle = pStruct.Hdr->Handle; + pStatistics->Length = Length; + pStatistics->Addr = Offset; + + pStatistics = &mStatisticsTable[Index]; + } + + return EFI_SUCCESS; +} + +/** + Function to display the global mStatisticsTable object. + + @param[in] Option ECHO, NORMAL, or DETAIL control the amount of detail displayed. + + @retval EFI_SUCCESS print is successful. +**/ +EFI_STATUS +EFIAPI +DisplayStatisticsTable ( + IN UINT8 Option + ) +{ + UINTN Index; + UINTN Num; + STRUCTURE_STATISTICS *pStatistics; + SMBIOS_STRUCTURE_TABLE *SMBiosTable; + + SMBiosTable = NULL; + if (Option < SHOW_OUTLINE) { + return EFI_SUCCESS; + } + // + // display EPS information firstly + // + LibSmbiosGetEPS (&SMBiosTable); + if (SMBiosTable == NULL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle); + return EFI_UNSUPPORTED; + } + + ShellPrintEx(-1,-1,L"\n============================================================\n"); + SmbiosPrintEPSInfo (SMBiosTable, Option); + + if (Option < SHOW_NORMAL) { + return EFI_SUCCESS; + } + + if (mStatisticsTable == NULL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_STATS), gShellDebug1HiiHandle); + return EFI_NOT_FOUND; + } + + ShellPrintEx(-1,-1,L"============================================================\n"); + pStatistics = &mStatisticsTable[0]; + Num = SMBiosTable->NumberOfSmbiosStructures; + // + // display statistics table content + // + for (Index = 1; Index <= Num; Index++) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX), gShellDebug1HiiHandle, pStatistics->Index); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE), gShellDebug1HiiHandle, pStatistics->Type); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE), gShellDebug1HiiHandle, pStatistics->Handle); + if (Option >= SHOW_DETAIL) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET), gShellDebug1HiiHandle, pStatistics->Addr); + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH), gShellDebug1HiiHandle, pStatistics->Length); + } + + ShellPrintEx(-1,-1,L"\n"); + pStatistics = &mStatisticsTable[Index]; +/* + // + // Display 20 lines and wait for a page break + // + if (Index % 20 == 0) { + ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTER_CONTINUE), gShellDebug1HiiHandle); + Status = WaitEnter (); + if (EFI_ERROR (Status)) { + if (Status == EFI_ABORTED) { + return EFI_SUCCESS; + } + + return Status; + } + } +*/ + } + + return EFI_SUCCESS; +} + +/** + function to return a string of the detail level. + + @param[in] ShowType The detail level whose name is desired in clear text. + + @return A pointer to a string representing the ShowType (or 'undefined type' if not known). +**/ +CHAR16 * +EFIAPI +GetShowTypeString ( + UINT8 ShowType + ) +{ + // + // show type + // + switch (ShowType) { + + case SHOW_NONE: + return L"SHOW_NONE"; + + case SHOW_OUTLINE: + return L"SHOW_OUTLINE"; + + case SHOW_NORMAL: + return L"SHOW_NORMAL"; + + case SHOW_DETAIL: + return L"SHOW_DETAIL"; + + case SHOW_ALL: + return L"SHOW_ALL"; + + default: + return L"Undefined type"; + } +} + +/* +EFI_STATUS +InitializeSmbiosViewApplicationGetLineHelp ( + OUT CHAR16 **Str + ) +{ + return LibCmdGetStringByToken (STRING_ARRAY_NAME, &EfiSmbiosViewGuid, STRING_TOKEN (STR_SMBIOSVIEW_LINE_HELP), Str); +} +*/ diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni new file mode 100644 index 0000000000000000000000000000000000000000..94f95bd176cc4480698f999cde7f1239e78d9150 GIT binary patch literal 93278 zcmd6w`Ewjcmf!o=-M^x(33|0_ffNsoW*F9NfH+7D34jBDq%=Dl2;QQ_Lk2)m-0h6K&(~%jr<0Azhsm##&y$nM zo5}0R&yzE~?(50($-nCJjmfuq`%Yi2&Az*?@4wO4JCpZ%<;%%iea#b2^b9^e)lc8( ztM~f(RlTq46}%=s{WN^{a&oG_KAHTck1xV2|L5e+@{3K0LU z*EAu@sbX~etXDmo{r!g-{y=p0g{H{PnRswJ$QM#&bmi42fy!5f`H47lP5(co`>B5N zOmM%DoaMi{s;B&{_grR=Cif;=g6E+mW`A;5AJ-?l`hG{0oQjrwKGIKjBvX&{)mEVI zqsg8=Z|UdI!k!Rmzau%`(kl+bllS!%(#yxM^qJ@K)UWjUPWYbhzWIXt6aAKF?uY+3 zojlQN4gy?z`uUEY$rJX&|31)nK+ezjk4Jhfui<~%tG4x8{`XJ%d|$r-ZnSP|_FoK# zt;vsHo)e$GBT77!Eb%`#rCB-UcEy1gf&WOtp7{4pT)N$O)g%4vl{j=5BnDa8)K8G7 z*OTi(-`@q@Lb6YT+&|dA$0yUJta>@P?$X2|oDnm443ek>pcR@T>4wu9b$V$>*_NzbmNV{h^?O zXHO=_`uJGyNX7&G=B|FeC%pIdn{`niIX%?dvHo^TuR-cIC;v2ii|~CEoUaATG{6&~ zTMt$Q%K>fSKlTH;xE-Je$2!m=(OUtZ9bs`#upS3&j|M=Cr-9PH>mB>NBW~;mNU!U= zKZ)wkL}zRma$~QA`&gQ@pf%0cy%1f_^d4XJ554vu`s( zt`L9c{h{#xQJmk>+g^44U!VN((n4OrVV(<&(c=BDG|I5;&3rV+W`xtV*E?c!O9zPInSg>_{z8iRrms;1) z%`%nPrFNY4n=nID?+SzWddH8v6@CvxOo5gYN8-tdvmWas)*0VnR(~^m#}kNp-UlCK z@#(2FzP{F{)WBjNh#K1=CU_J)J{BC?jZN4Klv#`}?h(Q2EYJcfJQX#Nh1bFqyH1Qg zRg7&kj8Wogke}!JIsOsJac?^YP29gBAJ~A+8C~{+ew6zyf6i3T0k;=HC-4U7*_tp% zDT2x@W@A|L4fQE=DxyAC5U=vL53bd;EINSxr1 zTCRi+p`S!GFGi(ogc{9x@Wp}*p>BlPvz;*{yG`dkNh48C4tc+hw`u)ea)S1b3BTna z9+MGKI{bf^+>l$9+U^5sUYgO9D-x9vVLB%NrPq+jTQ%WZMRZs6J|04I(WD?|*2SQ-4`RDT_z9s|ZBMKZ)S$I?;q zlx}$YseGgu2HQPVb~%-WF$+nx!f8GR^nJd%RQA_{UCir4UH*9t9NZ`7zIBMC_!G*# zs^MnRKL$=+vV?>YJ2+-#;Su9QTvL!xiDmyriN2NAEo$6Rn zZK-a6{UZmlsKBA@rzMp`t1psCP%}9Z#8ds0h|}tV(3Lu`>FgMCF%KK}St(W*$H~1G zHP7*JI}AA?Suz=8tpB)WEwx35AseKwOQn1()YmNw=++0fyx85`tBt`yi_}g2sC^!U zjKJlvL|5zyQ~hNgZ`}UkgFUX8swQX=#`#~3f#+_BTdC<%iM0xtSM-h*eNdy_Dvqso zl_R`WEcHe{(z4o=uSfbhxgIrVtAKq_WfKeM_%9zrEDhCmi?jN5@q7$7WN*mbiH4~L zJ`YyL^V_j8wMzXRVPug#@#JQ(pycu8{^((Vn##-vy@5;0Mb}Q3Ykp79Z9|emZJ2&Q zTFF^9*4Bfd{YJ8C6>7l*E{k| z_$BKXn?8??q2;%2KU0E_Yohn4Q&=Nk;#Xr>*);nzuStcK>LC$lxhAGDFnCcBq)tf9 zG{tKS9J-=;hrEOj4wGBR6c=Ex*|W(rLORFusL=cjvn=CjE2DNPsLAcL_iC2@K>XeizFwu@*LNnX{kA@R+Em&_ zU;CphezQ9NK|iA&k1d1}pY$D-`8Y>HRt1$lh0j<_=4^=Q$wTmnyq+gON1IIHS>w=% zISQxBJw+kZ?}=$$hf65arUmd*!MAw!2Vt^|Xf@BQqL0Hvl=AsqBN|^5SD0cl&X60M zZ==>ZwrwTGrvG4_#oT&X?`e3q>5(v@CxJvUbJEsD*WP({>zO=#I+N7w%OJVtd&ZF1 zE-Iwibt#|Ev)-pkmQ5UIvP|?guM^ePnH#4Anc|wuyL;jr#j@`F>8~oBNM5`yL_f>_ zvZlS>43+z6dEjKf^|21{OHGYGeD&qVSyQ|70G}XFJEir42p0nafQ-CQLz`2Ro61%aqj*uIT%5FtX^7`AYI(q>WCH z$4e!eX;U3-e8`IP*a?|~e^i=3h71`ziL%m;KOXD9T>x7uJ=8hSAfLC}6n@N8noj%2 zeok!)PUevp$xpiAK$q#sIs~OQ#(7V+NB{MQ&}+DeeeQ-X>TlFfy2(TP_okILr5SaS z**^LV{=C{;wpq&q)!>=W+Mh{*Sx}$Tf#UsqzoH6KZdtZMWOx!{qKA@UDm^CiO)1Bs z?p2oGJJLw+_;l3{N^r{Yu_syuzF9}85yf}O7ko#;u$XzK7WJW@H+w-R>E~cOYzDt= zYit_l%7yZ&E*zLUz#H4-uV++Ez3#_iSDxy3!Jk5oB{cmewux``u}HPsE8&p`CDN2? zb-Sh=Vdtxh=Y(CHNO7>P@?F{ddx>rB=R%5w^^{*rtA7p|Uyj2?ySrT&kcCsdwH(hR zY8V&RWra9XLiFjfWHsnqg23g9B+mWF@OZupe$GG8mCh^ByMs7j&!C!|SJvC`k0nR* zyvEQ;g?S#rPWUkY5eaM_pOMuKsnV3G;C2 z*JrHi|C(t7)tvLNs?USn5OJ6`Ujzp<*fe_iILy-qdNA$Cqn{)5w1P@QGwvA2Pox!Z zJ3~fY*rrTuQj*gxW_SDXNvA8k_PZ`QV_qiLadd{dIrHvyb>%#aqW`FYOI^4vE3@d2 z6Hw;)hCsX%qHc@)Qs396{22Z&h5sTxFU6wI?~Sh$9!q z4H{A3&gQXqS2v?1f=wfDPPWpaxhD*~pMgx(hutSo9*OFfMKH(g_NUBW-;q^e_T*!z zOq}W~>qFJ5Qjj}83GoCF0x9!PWYthUhqvF#kS%`_buB^#X6B#hEx>`gkQ4u7Ux+3+ z$<&6oL^7C@1YTxiIg3@F!t{DJL|H0TOkYPx({m{Ov^^A@&m{+(y*|8tKihhh42j~ZJczWljjhX=`=pU zU27*bmvJpgNU4qK&@_M(d8Y^YS|I=2~gJ<2Z5b($^1luAwG*T{De7V{9k% zQ#{F4ur_$h+BNC--$vZG!fp=c=Y`QX7!{)g!JT#|Dm|Fc>U-`VNN3U#hiCzbN zB%fmo%c-``)TNA{!A3{PLfM@VX;MNJ`0J;yO@bZTapcw@wYh&Ptizzil0^8Jnd1Z% z5vk<^*3JE&gXQ7YjkJkBW=iZmY{X&HHU2GHshp z-h?Tj?#Zt;&2lp*vM26fC*M#0MH*%sE6gLY<{WF61Z6(d#(fMr6RAANntA!quaM+C9A-Q@4r7ik-pP_Q+7baSiLonXIE}72O`j zjZn6~1}@je$WQ87-JHzZ<&@9;@cZ9e&76$eBo_;e-6!sNuFqJDy4u#9!}b%$5&nMY z52PPWPlK-1g%s(yuXpm;_O_A|Dly77~FWdbZ3*>04O^bi6Dhp?DpvijJ-srLXxLQhu?@>4z#aHXInv~W4 zni^Yz(_7_AoP_e3T55hzLxpNN_^_+VPJVUcQ08mxDa(>7x7|cH55)`iE)nB+^~U{d zKmGkl4*4Txt+siS6L=o0eXWTJM)yCSFW9FGz|?9U-0=d=Oa zf;eko=j=?DsM5X-KPO(R>!ZmkYFO3BqV!tGQFxm3Wo$o2m6@%iO$#-I16CE=6wEoa zjzjxoL0t}b$0VLz!t%Cp@))U1s=S)vCz!Cn;J6&?ME##CF`27X?jn}mzNBC0=>e|2AY#yGaj`uek&Qsh~YJDk4yMYxVpg^Qfn{(=KO zIr@9oo_?N0>TfGMW4AHeZa4ICp1)rXmykI$h{}OgeW2oP>WL zY&0`zSYqmI;PXrPitNE{_}W{8e_C&NtNq^bz~Q*&4c?bmaKC z&%yW8z^bBbKDsFy*wp@CrH8i5+HziYbKs|_AyZv7+e0SCf0|DItUah~>gFj|b#mjK zvQBERH}&0j@@rqIR(m~A(@$ZuaoKu+XL{~QsO8?&E=`_sAUt-L7(w>Y^GLKM7T~1F zdWZqWrRtF=Ld?JhZMNPyP08kSnzC(kH8jg54k=`piq*H7tX$L=bV=iPL8eTOuFWvM zFJ3gI5_w8%`NZ&4HJkpweyrvDm(tmN-@nV;c)8u}$KRxZr#A8T>Xi2~mWTiM()n-2 zb-3cV+ULbICEAT^6MJ?SzgLH^^ETyox@S54+WCKRO0Z}APkOstypQwMX#IxlfNxsP zZNN}@_)Zp(4j+4K$eO75S?|{OVYT&rIWY(k;ZKtEeR%_~qL}?_+P$GT|9OTp-t?Aq zitYO^<#C_MBUqIM8m!97nU$xyV-rf}+k9{zBJ;OqxEojPz6_$RRbd&*xC4Uz1REdO<@+*xJw&c=RIZg+ z9Lqc@*%HyLX>O_hdK}E(uZ6#_T}fctj<|~L>c_GT-w%Y4e41_*olu@}J3J#s2<jL=kjN9QECHUpL1;)jZJRTuD)Q?L)COmOXxj#=_K0eIKQ)NPv|E`ZnRjjbNCii0zpEI33huWG~)RvDIRjxnF zyVT*4KW+JVa3ubLlP;~^^gu%E`heYBwFs_SjLL|c@^rh`N+K!oDFBLk!*sR5ZUsv zzTeY(JcZFOkK5|Rr#I$IL+6A$h^Pk;&8Bzr$T zEPLl2Kt9K}xJ)8!9Qt9NTK<+sBEDF>)hrm8%J9Xu-m2zZXl4d8Z>e4Wu{!5|i*Oq+luP$8Z zE_uoWdCxy7vm#S&a@(Qphtz7^^nC4UU+dY{?`d;>EIh~&>)~NfTOJ;G3)>TATcVvC zT^iTVkB1?z$C|P;>T7Y9K4+U3xfa&tOgBbR&dR0hJZ$_{&eXPyi^q97Bk?etxITA+s@VH(5`a$F1u{f z)z20FeoV`IUlSS^fsel*6Tb9Jzt!g#jVj}5ew$=UW6HWbZ^O)##<0_n>GlDG*PgKq zNN;|L)=O+(H>5W!Tj_3^-VFAd3GgBNW#>WsKb8V>+S};Y|87`sRfd$FE;j>n-X+zq zSaHE#^+UTZFUXz1%q^w*#VzS|B{$|I)QreCnS^6s>c0MW^Q|B9n3Z@0%)LM4*U_7^ zRh7Qw*k1iS+_=wqUlnGu>aBohUEDZp%$YHwnN?v*{eX$aCa!fbJrssSlH5JNDqN}9 z+GKE3QvLfya9vld&8%*e*s&#*`VRFircbF5cntkF=^hH+M6O*(Db z$IVmx54PL0o1z_KwCvw$b`$H^53P^?YJz~BCJx`_Hj1jWG51Qo{(-rT~9ENCj8$vO%~ORE~#IX zCI*@J#@@)cEQcoFsnXv?lhwgD7+RVv`tDrjO7+O#K^fhMccod@b5 zFYaCHSr6b?hW+Hmj?00uL9z^-zn^K`<&%4dY!$ZPR;PWu3_imkTRu%zjr%fm;k!98 zytR|-P|J?MgyQ)+?P##ZD zd04GtS9OTDp(2-7DHqGh9J*!6iepN}!mI3M6`D4FUZM4BGc}r6TW@FO<9Ux1D?3v| zH;CPJ>peAl!d08D+%j4VXx<09#63?_dTqQk{GEMYe<>kQE zZB4VIR}bH4c~*}x)9y@Z*TIgHSUhdH7B!!V8#nrHPS4G&>yGC^Vom!p#0AU1lgXL9 zYCkTI%c}Oj>$IxfE=k{Wc@^q5HQdV%jSk(DUOYCu8ECNzYA_La*<|CpOGJ&;%f{-c z@%<%~jqg_`8*OT=UN$ZhH7>*w5P2szMYE@nkM(Awwv=~rd-Myv*_J|| znwU2k)#Zy;Gcl1*$sC1Q0roXBv*}q;S-k8xcTWc$g{Xm@%`Y#(oXC-KJf6pU`*|s#Hvmbh*Ebb2W02Q>Yz*)~8BWNAxmKBA+R0 zQ(~BQbWam?;l3Ka6J74kPFgWT#r~UN7&6!MZk7|L6I1r2k~*NTerCd5k+S6)o`rKyKV_? z%jwwsZQuPCPn&mHlYT0&^@D6M-ul+nCtzcH+@Hes82*Yo@jeGRudAPae%^NeY|BHs z-14~}r!KzG^YR-n($g^9YRDc@PIPg5#B0%__Qs}&PkwvzvHmaT)Yz29iJwx*?ZVIQ z!lt)un~s0WFq%$&5SCwudup$RS;2p;K8^WZn7XvxVSZzFx_hsLb5q%<$AWY@dzf#^ z3o|L&z3;4)8=Mum8lJQ)xNm3!T@AR|2hNk01-I?BqEo^-FXG+5OX@lC7xlYeyM3G0 zO~K9CF1F46m*k$!8QnMf`fu6cWjk!^+AG70oq#p);*8d1!i!!`4ZPU$aGCJ>V;BifJtABY#GMML*er_fQQ1XAji*aIwr z-3(*TrjE~r>0-$+L0K%7Qb0b3DcwSFIL&$DSwzmJSfNZjzmY%5w=f5&S#7UV>= zF(E7ZwS|pG9<{S}$BXmte&gk^ZRgI9Ey3+K;MKkl(xKc8b+!m6mYe;o_!_KUY255E z+f8W^YN9kY20xlrR>-N@(+c(JgdOTDYWH}gUn^G-yNZ ze>LuID&T-=u?LP`iy7l|Ai)?Ofa;!vyoo8%m z|6P0|_TXMlDtjOFwN;Lck2$~E8?W6;!*8<)&-DzRK-A5x#Bi@3$Ly|7vs-M4VCDll zkUcyI)+~C=e(o71sFuY|*v7qkq6W21;ODNJHdfR<%|o4!dtDi5;{PCcVdP*QCHkq5 zp|cpxzXZy*Uk}B%-uefTKN=1_=`M#E7`viy2HO$)>H0L*i&cJd1ALZ`TnNp zqxv~>CrBY%=s6?xUT=20u}$cZhu5)#5n`r_B81Sl97^=WwCBIizG4F&&-+8`H??D$ zCIu# zevc=jUiM4Pu4Fkz0*ABsp_W7&d=au(yJVWuHq0?A6Em$cS*L&71vhsXTMe2nnr)Zk zo`D$k63ftiA`W8v6rKei;+PXTz1L4aE5fPGt9?cKMHK3L{h zkqtakB!LH^)=PaOr5bxZu@>Y8WCr8r2VS+Fk9moXMGm*|t<5iD@F=@ctIFW)mQZ}2 zS?4h#Q-heeG)mg0zI!AaXL9GZ&ammX4>3wjB`41qT#jrqmDu%J(5tmCw$LLOw}j?7 z$Kh9wJvMPqnbmTz$BK}3V^x-m{h=_lE*|xSp|W}?h|O+NNvLK0f#|O2zajt19kW<^ zZWPAnZiMZ`dtV^!m&7!i<=z19#m0hT4f&c($8U$S7>(bZe!=X0$gi+<NuQJEcsUa@!MJ;UpgZ=Q9vGTcp>VZ!lH@-z0e)od&R z!e>%j$YtOBP+h5`g2VQ9w1NI7xZ2$|&bKm|b3A?v8vZfh^sA)M=KHKNf~Ac%AzH8; zS0<^r%Yzs%uZgjRpDFbnJ;&&DA}T?%sUXLTv8C5*s9rU-7>T+HHDlnUyW%qcdH z^<01HT^A~{)MJ01z22g=XqU_qjlqqs`Lu37Q6h0vq?)s7k?P1}U0FI*PD6xjF->|0 zXS{^Z&+SwF>l&MCu;W$=ecBy9HveU!ZYIi z5KVa3#p;{%n$`zdV9$u{_SUFFZzCfq5O<+)b4v_Jhg(e$iiSbs5d(bby`3JPMVs z$I=Hn4@^$j`OH!t=YE0H12(&h$9C-KpqLC$8>)kmMMuny8vm#WVZY+!aVZ8&iM0S=bIy;SGm*I>EuB}gXuAQW)B>``R?RO^RBAD8M{I+>pLi1)(MDdY~-9Z_d5 zP=;KfTr&>@Y4@p?{ySl#c0vn}Jh5s-sKmz5%x|NpCl!yy|2C?G<-hEZ3F7y1spvi{GoC!eyv1fRETcDVEwkoZ;*`~lus}r5 z#1pmi!#lDtWLEf1szaRDMS_V8s6bF*A=fIkGl!~@^F%6&UE1vv&74W9t?$P(=a^5Zkk!$L1Z$f`oEO23DVJXH_Gz4T$s&6x^4N4J zj>I2uFrJ*rv0gULu_i{Y>zNPJg!pYV&@D(mrm-Ss+lTyqGBO^UM52#=R#EHP`FSdT zB^i2Oem_@pzv!}7< z@FTRTbUVZ)^qwcvwfcVZDLe$q`IN0IzfA6NpJA*Sw(BV7%MJQ|nP8qTuL*JzAg`bB zlQX?pE@WQ2E?((P!nT=cRP&m@l`K0f`l}Vv7ItI;i z98rQwB)xfRqb`N>lQ7tnEzuS)!&eSzKXtc4u4S_!wc}Fv_@1#+A+VfvSg(bS1ySct ztCBz_S(mQ&1>sM@Dw}4~GhI}2?@P}gaXlX%4!m}R zANA~u^J_ve9- z`ruacrw?TwiayF1v2C=D%-S)%cPsdyL)l2T5hd|qw2D0Ec6iR^vW)a`={k5cS(<|! zDe9pMG*x$@mQRW&S*;gBRXK&MUxK*Z-nx%;gm|yjH}`*BI2Ao>3j+UKe7)B>* z3h(8gIHO?wD|*jN6xQ?%O&G~r_hpsQWc(P`f?mGcz7h^^G$5u=#U_?d!45K$kVZ#- z4#;QwtoQC6a{p~SZAKl988PZ?%x1q5ji`s?q3Y76JqaB-SSDMK1XXkTxh{-&P4@rL zOU*Y?k{i?EjfGceh5=7k%o0;f|!cA@wNmQtR-+hkwzi8R6v~Xb)odyEB${g zjGg$h6NkfS>eW{|{>*XNe415^>%#1HyjX3znMr5~WxalP681>b8<t)2# zC3DD>Xdh3RoU`gDRp@2$%j z8bOcDPv}GcMR%>^KkY;#)1|{F{JSBFbM3JnnNA8o&wkl(I_(6##d~m4(oPmJQ{@&a zdQ+c{BhO%pV5+($(J61|y&ewPUZLNs(I7v8!VCr7TXHI<%F^0pKPB=xpeNFBvLG@k zrqivSxyX!4H}`VLtr~9U5zvW?!A@7{xj2b__(?A7(^{pR$q9=p9IwSr-FIWw#D%lt z>{BK4UBrtvVSXUI*r!_0%XH&$K8MmuO=;AhOISIV(u&Sv^R@uCaTN3v(HL(WO|SrcC0 zDwUq7=4VXNv-!s8TjG;;1zFsFWtD5@P2$ePbOS8&|F%_%^C$c*JswV^)U(!(8+CZL zvD@SZ70Bjvz18vhz0FV@p#rBj&=P!Zd;b2j@O5uqE5>lVse)OLhK)VzVHPA-FQJJ| z-qgXHDw*{tI5YM%U|uXotTkF{RO|Lp%m_xlG6XN=;b%DVt|BaktVkp|`Ym`DHS?S5=biTgDc=f*~;bP%1`ME4`%<~J4AllggA z5f#%3Cf6yoH}g33AmH#?x?GzhzKhZ-G36zjdJ*XJ0)J2*|qNZOX`Dl zC94b%pHDB5sZvaCRKWL;T~XLlFtmYpEMyW=2jRg730JZxi$d1 zo$cYQt8bmTNDX!?WPYa4RQ=dBGltdeg4}PtaLdchvG_Y?CrWeOF8Ch@{;-G8`bWOK zfOFZ~!H2UA2tV$a+5~g0n2D%^oWW0aFtK-}pZMK!;PFRtYZeYu8$&x;iPmvuAi_`@ulVgl2hu1i>+^B76PL`F(Wj69 zsXn&34%%do`BQR7sy5M*m~AhyhiMFN^FHQF$>>cV$B|CoNtEtpN^3AB)kAv*bM)5d zcrA#jS=5%Z*ncz2fQ6X1U#d*POs<$^W=_{8JS={%y;G_-ElQ-&>e+WBm1WduZXR1x zEs05~rX(_J@IlrTFK5(xuFuqpJ%6Us9X+9SzBuc{?jt4~*~@nE8LW9((mmy%*jKOR z;O&XMs4`k_%<@(2QW<3)D&9gvZ4Qewi+Lq#UHE_z+m)%6K7c6TiQ>0HcXHIEJKetDv5yjvO8Iq&kQ&HN@(&6L-+cuMu3?`!h08>iu! zavvt{GnNOt@AqZXjLo|Cd%sdFyzgWiQ^&w5YEXOfq#uu)+C0T=2h6rNEkvq4bX%-; zZ;_|(m_hc&0l0Lg2cTV#lTw zvw@3PgcSZJKKZU4>|RY=h@`FaXSHq9ro}T~7kwy3z=x z1Ru1^dYQJ9lAe3bT#gEIoKo}Cbj~Si%XC`ohK7Ed;Z@|Ao#rR(ER)N96!SUs`RvRs z=kV%bn0GF1f@ohg6Y3)tJGox<8L+!oNo8@@|~K35u{=Mn`savbW}=XqERk9PWT7{hxqg~9gMR2N(aN@V9K=qghO zWC*??mklT}i)z!qmJG42g)UbLeU}84V6r72ZqqRM@#n&ZOsLrhSS4OVE!1Kdjc2#I zt4Wsm#Hx}>U%&nBt|O(IPre#;rk2c|j|F>@HWhv5_|(D%O=54-3u%|l3yy;!Ho<&7 zClY-t(r}xWN78t9>LR`wsXlM+2yU!FI|9r3QDP75S?SF|9&wF9bG+Vx@)dIZCah&q zJ{~UL9DXr44@FBqRY8o-Hn?MXY@{LH;!XAGt~xbCe8v^knilcE-4Mk(nOXiwMSL^0 zd55iE3;(7}4o`;VXw#E((bNK|!rKXNz6KX^KO*tP>!5wOx$gNHQMOVJxhE}R=32-3 zmg$5$)DMDIviJ6#z8fD0=SP`bp9lFBabi4p(_65+=srZA?#*aylYULAF9(N6_lrU9 zr*3LP&29>I8Mv%RcuVZ{p}Y$_3v&532_NqJyY#ZLX zX-KVZEZt=Gdt2{(-cyu97d6#^61vile5H4MB`3J|`!B@mJlOOnSMZDy+KPNOTvawn!Q4p4hSKrp8e)>8z znCK_|{y!vjYm=Lk|IA)zQ(V4*#HRJ*Q?E__efDaf^QY?fR(8!Ht)*+JZD6B0LX+7y=#A*-h#HkUY|*f-lsj{!?H7AHDN)PLfz2`XW?((%+qC zuY5X_=-Qa$M>(ayZUJs0i8z-?;+FJ}8;95(KnAg*roFcZ7 z#VC{K`%uPjKQ_7lK~EfyDmgXsXrRn1olg-o^@cW?wrP@61j)!L;dDs#+@d+2Hy%Y? zPHY3T@A+bSgGml%21Tvn*MG5=*#O1?47{66;s zT2>mLR+~bx9>?};G>O{GuHGz*iZ-xci(&_q*{!$2ipb@i-VDnzETWx%q%wD&&+3OA zuEu!E;|2eWCA3qK*n%$4R+}$2xo9@`$pb!yT<-yv*k_!|GX$Aa!6K15BTA?a1WD= z8?NGbYgpfEPdi?fw_3THR~UyvmR1qJRW4o|u6A@+%JH-H!N8;2~mf<*$tLd{-&XE;T^R%;C^?Ux7Sux#$zp$D6 zA-XpYAG^29t5NS{`RRjP>~4{iMsY6ZJgvjmaVE^GEd4S#51;e2jw)QcQroS4|2+Bs DfA}$F literal 0 HcmV?d00001 diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/smbiosview.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/smbiosview.h new file mode 100644 index 0000000000..3d532b4ab1 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/smbiosview.h @@ -0,0 +1,91 @@ +/** @file + Tools of clarify the content of the smbios table. + + Copyright (c) 2005 - 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMBIOS_VIEW_H +#define _SMBIOS_VIEW_H + +#define STRUCTURE_TYPE_RANDOM (UINT8) 0xFE +#define STRUCTURE_TYPE_INVALID (UINT8) 0xFF + +#define STRUCTURE_HANDLE_INVALID (UINT16) 0xFFFF + +typedef struct { + UINT16 Index; + UINT8 Type; + UINT16 Handle; + UINT16 Addr; // offset from table head + UINT16 Length; // total structure length +} STRUCTURE_STATISTICS; + +/** + Query all structures Data from SMBIOS table and Display + the information to users as required display option. + + @param[in] QueryType Structure type to view. + @param[in] QueryHandle Structure handle to view. + @param[in] Option Display option: none,outline,normal,detail. + @param[in] RandomView Support for -h parameter. + + @retval EFI_SUCCESS print is successful. + @retval EFI_BAD_BUFFER_SIZE structure is out of the range of SMBIOS table. +**/ +EFI_STATUS +EFIAPI +SMBiosView ( + IN UINT8 QueryType, + IN UINT16 QueryHandle, + IN UINT8 Option, + IN BOOLEAN RandomView + ); + +/** + Function to initialize the global mStatisticsTable object. + + @retval EFI_SUCCESS print is successful. +**/ +EFI_STATUS +EFIAPI +InitSmbiosTableStatistics ( + VOID + ); + +/** + Function to display the global mStatisticsTable object. + + @param[in] Option ECHO, NORMAL, or DETAIL control the amount of detail displayed. + + @retval EFI_SUCCESS print is successful. +**/ +EFI_STATUS +EFIAPI +DisplayStatisticsTable ( + IN UINT8 Option + ); + +/** + function to return a string of the detail level. + + @param[in] ShowType The detail level whose name is desired in clear text. + + @return A pointer to a string representing the ShowType (or 'undefined type' if not known). +**/ +CHAR16* +EFIAPI +GetShowTypeString ( + UINT8 ShowType + ); + +extern UINT8 gShowType; + +#endif diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c new file mode 100644 index 0000000000..094e429fed --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c @@ -0,0 +1,309 @@ +/** @file + Main file for NULL named library for debug1 profile shell command functions. + + Copyright (c) 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "UefiShellDebug1CommandsLib.h" + +STATIC CONST CHAR16 mFileName[] = L"Debug1Commands"; +EFI_HANDLE gShellDebug1HiiHandle = NULL; +CONST EFI_GUID gShellDebug1HiiGuid = \ + { \ + 0x25f200aa, 0xd3cb, 0x470a, { 0xbf, 0x51, 0xe7, 0xd1, 0x62, 0xd2, 0x2e, 0x6f } \ + }; + +CONST CHAR16* +EFIAPI +ShellCommandGetManFileNameDebug1 ( + VOID + ) +{ + return (mFileName); +} + +/** + Constructor for the Shell Debug1 Commands library. + + @param ImageHandle the image handle of the process + @param SystemTable the EFI System Table pointer + + @retval EFI_SUCCESS the shell command handlers were installed sucessfully + @retval EFI_UNSUPPORTED the shell level required was not found. +**/ +EFI_STATUS +EFIAPI +UefiShellDebug1CommandsLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + // + // check our bit of the profiles mask + // + if ((PcdGet8(PcdShellProfileMask) & BIT1) == 0) { + return (EFI_UNSUPPORTED); + } + + // + // install the HII stuff. + // + gShellDebug1HiiHandle = HiiAddPackages (&gShellDebug1HiiGuid, gImageHandle, UefiShellDebug1CommandsLibStrings, NULL); + if (gShellDebug1HiiHandle == NULL) { + return (EFI_DEVICE_ERROR); + } + + // + // install our shell command handlers that are always installed + // + ShellCommandRegisterCommandName(L"SetSize", ShellCommandRunSetSize , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETSIZE) ); + ShellCommandRegisterCommandName(L"comp", ShellCommandRunComp , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_COMP) ); + ShellCommandRegisterCommandName(L"mode", ShellCommandRunMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MODE) ); + ShellCommandRegisterCommandName(L"memmap", ShellCommandRunMemMap , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MEMMAP) ); + ShellCommandRegisterCommandName(L"eficompress", ShellCommandRunEfiCompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFICOMPRESS) ); + ShellCommandRegisterCommandName(L"efidecompress", ShellCommandRunEfiDecompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFIDCOMPRESS) ); + ShellCommandRegisterCommandName(L"dmem", ShellCommandRunDmem , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMEM) ); + ShellCommandRegisterCommandName(L"LoadPciRom", ShellCommandRunLoadPciRom , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_LOAD_PCI_ROM) ); + ShellCommandRegisterCommandName(L"mm", ShellCommandRunMm , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MM) ); + ShellCommandRegisterCommandName(L"SetVar", ShellCommandRunSetVar , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETVAR) ); + ShellCommandRegisterCommandName(L"SerMode", ShellCommandRunSerMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SERMODE) ); + ShellCommandRegisterCommandName(L"Pci", ShellCommandRunPci , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_PCI) ); + ShellCommandRegisterCommandName(L"smbiosview", ShellCommandRunSmbiosView , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SMBIOSVIEW) ); + ShellCommandRegisterCommandName(L"dmpstore", ShellCommandRunDmpStore , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMPSTORE) ); + ShellCommandRegisterCommandName(L"dblk", ShellCommandRunDblk , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DBLK) ); + + // + // check install profile bit of the profiles mask is set + // + if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) { + ShellCommandRegisterCommandName(L"bcfg", ShellCommandRunBcfg , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_BCFG) ); + } + +/* + ShellCommandRegisterCommandName(L"hexedit", ShellCommandRunHexEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_HEXEDIT ); + ShellCommandRegisterCommandName(L"edit", ShellCommandRunEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EDIT) ); +*/ + + ShellCommandRegisterAlias(L"dmem", L"mem"); + + return (EFI_SUCCESS); +} + +/** + Destructor for the library. free any resources. +**/ +EFI_STATUS +EFIAPI +UefiShellDebug1CommandsLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + if (gShellDebug1HiiHandle != NULL) { + HiiRemovePackages(gShellDebug1HiiHandle); + } + return (EFI_SUCCESS); +} + +STATIC CONST CHAR8 Hex[] = { + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + 'A', + 'B', + 'C', + 'D', + 'E', + 'F' +}; + +VOID +EFIAPI +DumpHex ( + IN UINTN Indent, + IN UINTN Offset, + IN UINTN DataSize, + IN VOID *UserData + ) +{ + UINT8 *Data; + + CHAR8 Val[50]; + + CHAR8 Str[20]; + + UINT8 c; + UINTN Size; + UINTN Index; + + ASSERT (UserData != NULL); + + Data = UserData; + while (DataSize != 0) { + Size = 16; + if (Size > DataSize) { + Size = DataSize; + } + + for (Index = 0; Index < Size; Index += 1) { + c = Data[Index]; + Val[Index * 3 + 0] = Hex[c >> 4]; + Val[Index * 3 + 1] = Hex[c & 0xF]; + Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' '); + Str[Index] = (CHAR8) ((c < ' ' || c > 'z') ? '.' : c); + } + + Val[Index * 3] = 0; + Str[Index] = 0; + ShellPrintEx(-1, -1, L"%*a%02X: %-.48a *%a*\r\n", Indent, "", Offset, Val, Str); + + Data += Size; + Offset += Size; + DataSize -= Size; + } +} + +/** + Convert a Unicode character to upper case only if + it maps to a valid small-case ASCII character. + + This internal function only deal with Unicode character + which maps to a valid small-case ASCII character, i.e. + L'a' to L'z'. For other Unicode character, the input character + is returned directly. + + @param Char The character to convert. + + @retval LowerCharacter If the Char is with range L'a' to L'z'. + @retval Unchanged Otherwise. + + + //Stolen from MdePkg Baselib +**/ +CHAR16 +EFIAPI +CharToUpper ( + IN CHAR16 Char + ) +{ + if (Char >= L'a' && Char <= L'z') { + return (CHAR16) (Char - (L'a' - L'A')); + } + + return Char; +} + +/** + Function returns a system configuration table that is stored in the + EFI System Table based on the provided GUID. + + @param[in] TableGuid A pointer to the table's GUID type. + @param[out] Table On exit, a pointer to a system configuration table. + + @retval EFI_SUCCESS A configuration table matching TableGuid was found. + @retval EFI_NOT_FOUND A configuration table matching TableGuid was not found. +**/ +EFI_STATUS +EFIAPI +GetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + IN OUT VOID **Table + ) +{ + UINTN Index; + ASSERT (Table != NULL); + + for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { + if (CompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid)) == 0) { + *Table = gST->ConfigurationTable[Index].VendorTable; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + +/** + Convert a Unicode character to numerical value. + + This internal function only deal with Unicode character + which maps to a valid hexadecimal ASII character, i.e. + L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other + Unicode character, the value returned does not make sense. + + @param Char The character to convert. + + @return The numerical value converted. + +**/ +UINTN +EFIAPI +HexCharToUintn ( + IN CHAR16 Char + ) +{ + if (Char >= L'0' && Char <= L'9') { + return Char - L'0'; + } + + return (UINTN) (10 + CharToUpper (Char) - L'A'); +} + +EFI_STATUS +EFIAPI +ConvertStringToGuid ( + IN CONST CHAR16 *StringGuid, + IN OUT EFI_GUID *Guid + ) +{ + if (StrLen(StringGuid) != 35) { + return (EFI_INVALID_PARAMETER); + } else { + Guid->Data1 = (UINT32)StrHexToUintn(StringGuid); + StringGuid += 9; + Guid->Data2 = (UINT16)StrHexToUintn(StringGuid); + StringGuid += 5; + Guid->Data3 = (UINT16)StrHexToUintn(StringGuid); + StringGuid += 5; + Guid->Data4[0] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); + Guid->Data4[0] = (UINT8)(Guid->Data4[0]+ (UINT8)HexCharToUintn(StringGuid[1])); + StringGuid += 2; + Guid->Data4[1] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); + Guid->Data4[1] = (UINT8)(Guid->Data4[1] + (UINT8)HexCharToUintn(StringGuid[1])); + StringGuid += 2; + Guid->Data4[2] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); + Guid->Data4[2] = (UINT8)(Guid->Data4[2] + (UINT8)HexCharToUintn(StringGuid[1])); + StringGuid += 2; + Guid->Data4[3] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); + Guid->Data4[3] = (UINT8)(Guid->Data4[3] + (UINT8)HexCharToUintn(StringGuid[1])); + StringGuid += 2; + Guid->Data4[4] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); + Guid->Data4[4] = (UINT8)(Guid->Data4[4] + (UINT8)HexCharToUintn(StringGuid[1])); + StringGuid += 2; + Guid->Data4[5] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); + Guid->Data4[5] = (UINT8)(Guid->Data4[5] + (UINT8)HexCharToUintn(StringGuid[1])); + StringGuid += 2; + Guid->Data4[6] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); + Guid->Data4[6] = (UINT8)(Guid->Data4[6] + (UINT8)HexCharToUintn(StringGuid[1])); + StringGuid += 2; + Guid->Data4[7] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); + Guid->Data4[7] = (UINT8)(Guid->Data4[7] = (UINT8)HexCharToUintn(StringGuid[1])); + return (EFI_SUCCESS); + } +} + diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h new file mode 100644 index 0000000000..f34889f76d --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h @@ -0,0 +1,332 @@ +/** @file + Main file for NULL named library for Profile1 shell command functions. + + Copyright (c) 2010, 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +extern EFI_HANDLE gShellDebug1HiiHandle; +extern CONST EFI_GUID gShellDebug1HiiGuid; + +/** + Function printing hex output to the console. + + @param[in] Indent Number of spaces to indent. + @param[in] Offset Offset to start with. + @param[in] DataSize Length of data. + @param[in] UserData Pointer to some data. +**/ +VOID +DumpHex ( + IN UINTN Indent, + IN UINTN Offset, + IN UINTN DataSize, + IN VOID *UserData + ); + +/** + Function returns a system configuration table that is stored in the + EFI System Table based on the provided GUID. + + @param[in] TableGuid A pointer to the table's GUID type. + @param[out] Table On exit, a pointer to a system configuration table. + + @retval EFI_SUCCESS A configuration table matching TableGuid was found. + @retval EFI_NOT_FOUND A configuration table matching TableGuid was not found. +**/ +EFI_STATUS +EFIAPI +GetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + IN OUT VOID **Table + ); + +/** + Convert a string representation of a GUID to the GUID value. + + @param[in] StringGuid The pointer to the string containing a GUID printed. + @param[in,out] Guid The pointer to the buffer to get the GUID value. +**/ +EFI_STATUS +EFIAPI +ConvertStringToGuid ( + IN CONST CHAR16 *StringGuid, + IN OUT EFI_GUID *Guid + ); + +/** + Convert a Unicode character to numerical value. + + This internal function only deal with Unicode character + which maps to a valid hexadecimal ASII character, i.e. + L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other + Unicode character, the value returned does not make sense. + + @param Char The character to convert. + + @return The numerical value converted. + +**/ +UINTN +EFIAPI +HexCharToUintn ( + IN CHAR16 Char + ); + +/** + Function for 'setsize' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunSetSize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'comp' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunComp ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'mode' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunMode ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'memmap' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunMemMap ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'compress' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunEfiCompress ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'decompress' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunEfiDecompress ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'dmem' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunDmem ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'loadpcirom' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunLoadPciRom ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'mm' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunMm ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'setvar' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunSetVar ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'sermode' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunSerMode ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'bcfg' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunBcfg ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'pci' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunPci ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'smbiosview' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunSmbiosView ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'dmpstore' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunDmpStore ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'dblk' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunDblk ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf new file mode 100644 index 0000000000..4cc5392e11 --- /dev/null +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf @@ -0,0 +1,84 @@ +## @file +# Provides shell Debug1 profile functions +# +# Copyright (c) 2010, 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 +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +## +[Defines] + INF_VERSION = 0x00010006 + BASE_NAME = UefiShellDebug1CommandsLib + FILE_GUID = 90330D51-A99B-4cc8-A2EB-AE22542A3F45 + MODULE_TYPE = UEFI_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER + CONSTRUCTOR = UefiShellDebug1CommandsLibConstructor + DESTRUCTOR = UefiShellDebug1CommandsLibDestructor + +[Sources] + SetSize.c + Comp.c + Mode.c + MemMap.c + Compress.h + Compress.c + EfiCompress.c + EfiDecompress.c + Dmem.c + LoadPciRom.c + Mm.c + SetVar.c + SerMode.c + Bcfg.c + Pci.c + Pci.h + DmpStore.c + Dblk.c + ./SmbiosView/EventLogInfo.c + ./SmbiosView/PrintInfo.c + ./SmbiosView/QueryTable.c + ./SmbiosView/SmbiosView.c + ./SmbiosView/Smbios.c + ./SmbiosView/SmbiosViewStrings.uni + ./SmbiosView/LibSmbiosView.c + UefiShellDebug1CommandsLib.c + UefiShellDebug1CommandsLib.h + UefiShellDebug1CommandsLib.uni + +[Packages] + MdePkg/MdePkg.dec + ShellPkg/ShellPkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + MemoryAllocationLib + BaseLib + BaseMemoryLib + DebugLib + ShellCommandLib + ShellLib + UefiLib + UefiRuntimeServicesTableLib + UefiBootServicesTableLib + SortLib + PrintLib + +[Pcd] + gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask # ALWAYS_CONSUMED + gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize # ALWAYS_CONSUMED + +[Protocols] + gEfiPciRootBridgeIoProtocolGuid + gEfiBlockIoProtocolGuid + +[Guids] + gEfiGlobalVariableGuid + gEfiSmbiosTableGuid + diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni new file mode 100644 index 0000000000000000000000000000000000000000..25c2389c8ae67e6588ef6961b40a0fc9ef9bccc0 GIT binary patch literal 59886 zcmeI5`)?ITmdEeUEA9Va8L<;a;SoqO*=VvW8{5GeFkah`WSEf!#t>_;VQnDEX#V!y zJ)ipexE|eotNPySkjzF`&<}T4omZVYud4pv|G7E2Ia#uQzqjANPX5KtZeARhCU+;V zCvPS{O-?6Alb4h4CvWZ9k0u9`Yj(Unxi$I3{(Wrco0Aj!+u`Juo%7DAy~Y1e?e3AC zo!I>w_HV_W;F;LoS-3i!oY~u_llS)j^YG*!C##d4$$uoU>{Jj>cL568j*zIY;{dg{0%X8@bU_<%dOdlOytg{povhjQ z{S1}}>kokz2lhYE<=7q>G_(jcL@)X}vum(^W^g)B;0RO&`WJRzyaDDP?U@p$oGzl} zPxjQa^Y>q$QvitGCUiw=-Wn&q46=nhiMBj{8Yq3kus=2a+%yPM+Mn5-X9oH6$@Std zH>{QK?VnS`kKl7}vTjgqoAf-Kd~N@)Odi*cGsIk3RS8DW0KMJ+)!a^5%DT{FD6!$Qgs{=e-Dv^~tvv?ZnnMjTYM` zRrI-LRhw+B2 zp9M*NW<4@Wj(S>K37keok>|I)J?`3lWLRUFkx2iv=MsHpFuw@Wv}CkipKKVWO9_N% ztsADZkc0@UYZO`&-qIe7cR}y;DUVA*Z%Sk8Z(mKW1njuFVy)4_OQQg=E`=Y`f8C&i zE6aADza#f&M#tskT_3T+R#Llf5{*>spUd~E(RDq@x7yDCkNv+hI9^&`OQFBm`&D~; z-DrwFJq>#Isj{ zIH84P5sV!TCG^tg4)=U~s6mhQB3tOv|9P z83~%9WNFOseA%`mv)+bD7I&RD zew>v@8|ToWlVq1NQ$(1#e`39rd|0x%1giu4`%4=q%$;pBM#KtzyJt9IlVW#vf3sq> zX0YMQAYbsuJpx7xHh}9WFg`UNf{8RO-W{|1wPt*F4f;O^E;&BCfm?SMh|jJ;`1b&L zccuV`S!V7o9~KYyiqRn2l$QbfHzqmw7L1bqu`#O*ZDgb1hag2**|J8Fs}wh6Ml(kH zNWjNgG3g(IJRJ{WgLf=m7*=>G%yi@7e{AFTzS;5UR&aP^S6$5{EM|q@E%EmT z=c{u|+-+|6*h|ebO{d~hqI2S??Ux#$o)zXeT8U4{|3T|4Mz2o8ju{;Pc0a@bkgY!3 zsg)!0U}a+fKQcm81SBG4_VEWEwoi7{b`>Ax*V7_e{;LBpRzAQ-6c9$=BBTgYh zxy_J1eOc$rfooSS2J(eP`J}UN8BKo7xH-P}-`kituxQAKz{q9(_BlTP{B&*6HRXuC zU2yof5nGe;U;c?(ui{&FhU^-=yLM5#(Y z|0DAlsl1Wjul$no9%RY>YJbVSuewIcVcoWP+-}HAM`&AMC7!(03o#LsA!u`0r_uI- z(UVvXaVy2I`lu?H>+tsHyz_XcqC9#0ifBKv7IGfs^T)$Sdb?plOLmPNCKBnj-#3@(!&XRSvbrw)*f;B%NxZ{8#4&&l4}Cwv8CmX9m+!$P!a?5btn)P>j;) zl26_aNg=99?FaOB=~wNN!&-;3UGk|FfwEM7#2g=TMI9Gdw8#0CdvqM8OHCbzJ?i#G*wt%?*w{DSAI5PaZVy&u12Duyhtymvv9o=CkhBu^hhp5meb9E{pQP(Yk z2dvC>pG-ct+{3qaFTKkDmS5%CcP!MqA@7lolseQq7mHEe-BLlQ_Y85{bX;U5lbyNR(t!LgFTH0 zfKI4u?-bGp2K^h;$yW^;{%7tPIxc3W83*fb$dzNSP@N>mp3i;EF_~t!sq%Q=^p`Ty zs^{KKY_~W=)hX|pXfnQM_VX1LX-0jlRpt=lSJj}bL%3#;VWYF+ViqW;(Q?hk2v%_P zGvrxQ-(OY>*C9=%m^%9B_H&4H3yG_5ZDho8m-ByU)J1r)+*N_fngp*$*f$%ucPkdD&cuRc^%Z)AH6E<9K+dVwZ>iXKc)dm$?Itb9 zdX`7#rS4gK`qkkb@<)9YMi++^!>a)otv^8bP`Uih^iO*%qaPc;8~yB7DeqfL;k5~U zHKbi^QjPBM8RwgGsx`vlc;vhyVnc;?8b@fE{TIQjKJ2LdmG3@;-?Z_AhNZq=m9#5n zhiqDuWXrVe+Jzj>E05(Ip^C7y>b#scB$Hlct5q>CEdnuSErT#4-uboRNcA%ub4;?8GXho5>~Kb@o1eJu`B1qJTPm{Lyx8Nw&H=l zVv#ig)T!d7v)1c+IR0q1u6}L0PT26j`b?oO&s%ieJ!?sAv36?u$|&_+@3)nb_W};B z{Yqn$IF{FKIIFGJo@MEkJ(bsOJ*%zOo&{$vqh-Hsdh(vlf~-GUw|TXV&-sYy_NqH| ztaDc|dT_ge$wbn_T3jK_!9)W1%~={PIgV<3sE7N)^8Du|Kdl{RZCw-pes*iZ$Q$o3=deYp zdbW2gY<*VvRkH>hPKS8ItOQ@1=C-zSp<_IvVd#~u`#GWatX;c5Hw^un&0-swgtW*- zAMJ?^d3Khp4tewq^VNtJ?b+Y7*90CMYsgvG&>!JS*WC5xA8YczW7e0~5hw$nThY#` zS@BfvUAZmoF2V{`{L;5!l#I8h;Z6y){I=Bk7u=TtwXf9fu8(KUJe(@=OzR6u{WKIW zE3sq`4OWHSvm<+3um*Hq-rNfw!E>7@@d>V4+a7bmM)MU_?)i`<%kfJq43^GUHL0~( zvDC<0ES3*U+LW7gJ*L>7@-){k#}>HG=bqNgi)v6|^T8nv-3^sY4kL{dTqK=`^aWp>3M&< zeXV8}x48R2iWldXiCeDyRE_966b!{lhxA(?PFQy(K9`LX79JcT1K~4mYV}dQB}`>8 zx~(`~E*0VSYPm)3{&Kem2c%5ZW$gFDPBzNUDX#4{xt_t=oe!TruC>V`{vMHbhv+M# zH&zf{+jyAVesQ0&tG8zzAGyYsM7TYJzd5`7Z-uJ0)xnr_8y)+6oGs(~ao7nD@1?t= zQMxxEQTFll_H2&yQMx0XOGFF3*}LnyRoQ)FP-6M!kq>X_GLOqf9nC*yrn|i-k0pFa zc;1^%ly@2<1s@8Yhar!tIuG(kqEA^lJf!gzf6jdivb3@q6=8A8w@6K&#NRVoq4hM= zYDZ4SDjJ=-Cj8#G+Y!5mvfCr{_39P;N9{G`^lq;yb_|JG=Q*bR;4`Oj!dWr=+VnVc z5_vntDA?PO(Vga(7J-FFBea*Jb0$B|ipAZ)C!cTQT-D_mGn7`7V0~y`39r9L|K^#( zAA=9$6uCNL4sqTIYe{8}YrI+v)^7Drm&fNpI`REA+FENO93Qyn)pQYq{Hz5Ztp`!7 z)V7zD_xhRDb7}NQMsC$>Zr9rI4SSNELgGC|J)YQD!G=%ot95VFkGITD_-ip+)U*$C z)Ls_7$!Wn=ogR8eRN&mPc5J!l_&x9%M3r{>!C~@| zE<3zG?JE82SCg-7A7<{-QpnT1l0(h0&Uxo%`c{7a*v1BPkmefjQ3fK7I13Zq z-wyK)nSjk6U55_yKBwo>geN=fGOMySXT{`_ed&<+?=J3cTJ$nPT*nw){l?l@3-Kbx z?zLd;#y0#ccK6aA3D-m#l6- z+^OS|j{#xEUgc!Gv|ln&lOfC;7joK*!G*mwku>&9%W)cy3sG$(3QKbcgV=}TvM9c& zf^IKZp0O95jm1SP*WQMiyp9RFOj>+)T%?=-bRl1<=JK7$TXDG`A|HPrQT%OdzPO}@tBGFHA8gUhasaaCk?XUDNJwrgWtJ1Tz|8B1}Q zSH@CYK7@=#T;`Xth|7nOF=i5%v3dEjV-n^v_96JPV^+&!v-5uXYva;W054xhh^RVA-i zzEq26m(oZxSnN5T)nSM;7E#iV&H5#xNF4O!Jc|*1^08KS7e=iPi12Y%hf%)pLGV2N zTSjB#>GruL$v!4{Ez$S)-EPN11l5$))%TBxzY+)29^mk^90yUt^1ixPE!+nqYCrHJ zx6HD|pC^_@J^5^Y<$c2lPm&lMd*$yLF6^u!pLhtHv0TX47!rqI*ZeLGxKo#ldj=ns z5@U=E( zfO4IWL&LEJB3k1+Fw_?6yDDQLLSye3B%T|Z23Z{7RL> zUUkTrO~}jmSM$cx2`yLd_vQWP$2v53ZQMOIc$A-S9sT-V8uNy)Ovw99uj(+Y1_&5q zE5@;OeOMXMQ{+pUcP!mx*J=gjbS>K=@exDWxKs;6jU4`{fq8y6*!9ZL>3t&Gd|?dx zLc5mftAzh)Py5ejP`~aTiGk>AAY*AlE)Q$D+h+GposYcpk+p{}c4#s1R%s%NN-Ul) z<*^opFUH`Hutro>okY9P>5RQP98QIGvpDdi_#&iduhlM=I&osRoSuhxBy#2N`f(9B z_-JvOE(U|4QPXE>mA=$i>`L9tI=S5esi|Y^SES>z|rwke+2m&dB}0Qu>Qkfa$ax6UIEQdx3~cPt)Qm&#N5t_jg| z%6n?zLCj|Q4hYe6N=I?oavT$mNBTtTxah-W+hhQbzx>sC(ud2o>DZGC%}V`W`g56b z9LDm3HQCG*>>JP*Ye@U5!~Y<_N^9h(rc*y{c`>|TmqoJD@?Z1z%c~Y#p4!YuYxu7% zxXjB7pW&iCs9gj~*txF5KQyyx7s8ie=2nI`wFg_}zRwQaA6P$Khc#mOYqtZbz#Fo| zB9<-u^O1}t$oGwhtT2~MZ@ra+!*Jry;v3>O zwNu>h^=fDQ&Dm`%$I6c%84jv~%xj)m>BPK=-|qXaIabaWRkNw)pK3eyX3L+EH9q9krHE!tRz(J4f|Tux^!f|e*` zidBgdUv#d2)mc#`j|-=fm^`YQ_B2KtxYh4+I36#0?&8+6|5e0Iu^iUn?il~j6CMk2 zjS=x{=bK_Wtdlu4{-Gy4@)}#~p0zv^HBa~b^v>)t0PVN3Ke-b$LE2{byiO7A)8`{U zZGkl)>9wCbM_q6F{qC`R(nn3}m?gH*<#M+l?$j~eoZPhbeyNxa`za-->zF#7`)qvG z-yB}hA+_?IUvA;|Q<}SdEnlwpFdP-=N=Q3}#zY64I(;#LoKiopug+JSJ(I)EY&k6X zRh=^BiWt6k`MFhFubREVDh)KV>d>$qmMj`g-8`8@GH!8QdDMe>jMc~AA}la@2K^O+ zIo>V$p{#xIh(yVEA6>0ltk3cog1pY3K8vG-objtHykK{U9Sb>;=5I^`*Q(2)bsch^ z`Y65H6-3+_gII)Wvcsbyd!RDwF;VozqCRt-A8l+ zSnmwPo77hw+6a@*sFlKgo)4m-k>09}Q>YxGR{9X@V7JSB@2a%LcwVQ^*xtL`DXrwO zy)#F~ce-b-bm@a^NYdNr0%WbdmwCTk(>>@`!EFQ|Sl23jL3yPRDH5vN0 zfKxF)wn2;K{)Jgkd>H`?O7)8IJ2vd;Kur2=@B`QFoONTT9Sb+DB!&1l0eAtyFo@o(_1^ZkletX_tZt8Z3xxiQZOhQ>tkH_t0G z7lYMp!wOmx$v+A^ug!;5>)7sMlj_}^a&?K}`Hzf4cY3kO_3mZzh?+iXG@|4&i%^Hx zt;%o5>eF7y+s*2khGz}YGL^j9d9)~Ox)OK!*f38qt5dr#t*{7ei1)CLomu@L{LlDl zozc6z89T4*yI71Jva|WPDX;1h$KG+rAveyR6>ecOk4t`HJYX!GyGE0hpueb_xf{;( z?G5;{W#dK_ufSY~lc%shZW;BJn_@Ry>g1G>f3`U%x&P>JDI zamgE}XNpy;_F^Y(NE|Z^nVJ)uEs1`z@+j^-t?wn0 z&p8MdLci>#*o@_oXRyKXGKk}9DgT=#Y z7u9F<;gw?5$|H0FHrig$$?%AXFIl;+Z_vc7EQhyc%pTC#1zZj6v+QZjtKtQ z?H)9oc0k8ckj(XY1N7L=8SI`R8`HmE&UYPH4K$QVO*zxb372g!!OPJ~rAV#xtQ{M9 z)}jrgWyA#d-!^29j7ro!tPPavta~wDORmK8m{_F>80~JkDQi@ z$BeD|>-HG$#449~Z`#@HReyVC(=dlAdpbRrTc^lyE!;Hd%fGo^@jOi{ck@he*=l}W z$0dKh@2Z5;<)Ibc)KltfKfPCnH}#I(J55_?J1=o+#bw(xIlGZ!udU&=8l*s3mQu19I~}o+e67JZdNh73;pIdpa6L)(Y2YzG;e8tHfbbZkluuB_Kke zJwUu-#w#@xn`*~~I8?sQ(RTqkuo#V2AH*HLO34!*eP3UhzC$!KS)a@;1}CCXeR8MW zO=@_hIJNR-7;Z&DsSF}Vf<(9S=97@K8itwr3%<&v{gzA4xc*5cZS44&j+LS?-cLJL z#Bio#Rgdq?gO!h%A^qkUjp5ZTTbpprG^j?*82y&^HV;;t!Q=cd8&`|gb>8w#(>~f$ zVwz@4@zHsTRqJ?4b5`3nvyw?r4xx)*yW|lIO>XX=UBvdxPA2Y5%sY+D=z`;&-N# z_}Yh88OEKp_@cX1_euiPD&&x$Lx6Ux&$zsNO`H7T(tX9q@(wd1)M z_{nlne?FF1UHJLd2YZ5{yRRB1Ief^|w0}eN_b&w^VfRhy@JoiiOH`LIjo4+&)9jf9 z;guZN&TLTlmi=3{D{$aTO!_7k8B{9Uv;(!is+DKAmJ2*-n^g`=M%5J?C+nTRV-b^k zF&XvmJwLK5c8k{a-B1s5YG3VvLM5eLc4{0+ z`H+uX*&=*p^=YW8R;9*q=>5pBW5umYT;575Us_9vJawfej)%Nwx3t^(j;*xz8zrpP zujAL+GV)rssq2!O(_2oza(!qsjPk=&T%c3P`Ezz)ym@Ex)ZrJtSxvseqU~w&i_TlTO{*_GLdr`ctXJg%haN&FFUZLFkTpM(stBFr1b>;%Nfx~&tRpmG&?VP+Di(0IskIxfhYVK=cKAF#^{ak+rzb*vq_cFdtm zw17$~i)O?xkg{lpq}q$W`i|wITZBEu9Ns`*SyDeYE?qmV^ys3L?gd*{^NUupGqO}6 z{;r7+NZl;P-y6o77^v0)-^O+mhV#SExG8N^m@hnr>U}f%LWTj&&K58jZiQqvngg5I3J2Oi)<3#Y{m&-HP z*yZcN((#|#*`c-R)+dl+X`yAjf2V1>_5#Z0ykji`e%Xn=shFIs9obZPpuiFBFwv=R z*22O94kVX#1SclBe-AJ*D@9DP&K*YD5q%jS{n3x~U3tyY0rclq#nMGj*GA#f1%17Nns2RmgEN;SIWEC)|No!NxPFK+w8-;CN{dI^i0JQH z#Ey(~+!wF385b3|WfY?8B+b&zX_PjVRqTSeE)jjHxDMI}?d?%MAA76zJoC$y^B|5ygPhzeil8 z2WeRpkv8;qqP_8G`|m zh?IayI@fgZ@c!qOrj+91GdMu|6w59qnu)MFnSI`w{L7|<@-B@I^}__C?ifh_I%X93 zY)F)nQN#c4X>?~J*Dvg4P6lQ>!cf-t&Wc)|S zjxusR$CbC};sr|3t?Qm2^UVpjW zp^$4Pvmbu}y*dFlsP|IV(^aUTZvV$0)R(4$Z*`jyz8ngL{&VSi}{ z3_KnE1=+-JCzGW3Q+HlSp&{>%H@jg+zGS&(Ep>kmO}BOQUz`~tgm`Pj3-Dq1)@ENM zE`^){86s$kGM4WJ^rpZktn;qhsGHgu3h+w~@yy`6qM0}WZDo%-SOxbTp* zex3F-dwcbG?g@zIU>IW~NSQD`>ygtGXXuSIu%=t}&T%h}$OET+E(t^2jyM9tnL&cB z01hqEpej=2nRO9Fboj#cLz7$LI{I#2>K~NfD~-K7{}n-Sy2`?4&XvuC9fi%xY z=3F)l#`UEgZnm>t)Z^m&V$Tq~;1r|F>x=K&QTbisws^c0H*`u$DkY1T)z_NM zEqv8dYbNyt*TwfmRU%aUIrw$o@Zk%v%n9rwl$F69{MYVm#T8cwX?!&+yiV(Z`28jTkN-FTPNH-y-|54?k<|Yg(;q H-{1ZZ3~I4h literal 0 HcmV?d00001 -- 2.39.2