mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
75aadf59c3
commit
5d73d92f56
|
@ -0,0 +1,798 @@
|
|||
/** @file
|
||||
Main file for bcfg shell install1 function.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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 <Guid/GlobalVariable.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/HandleParsingLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
|
||||
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);LoopVar2<BufferSize;LoopVar2++){
|
||||
ShellPrintEx(
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
L"%02x",
|
||||
Buffer[LoopVar2]);
|
||||
}
|
||||
ShellPrintEx(
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
L"\r\n");
|
||||
}
|
||||
|
||||
if (Buffer != NULL) {
|
||||
FreePool(Buffer);
|
||||
}
|
||||
if (DevPath != NULL) {
|
||||
FreePool(DevPath);
|
||||
}
|
||||
if (DevPathString != NULL) {
|
||||
FreePool(DevPathString);
|
||||
}
|
||||
}
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InitBcfgStruct(
|
||||
IN BGFG_OPERATION *Struct
|
||||
)
|
||||
{
|
||||
ASSERT(Struct != NULL);
|
||||
Struct->Target = 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);
|
||||
}
|
|
@ -0,0 +1,255 @@
|
|||
/** @file
|
||||
Main file for Comp shell Debug1 function.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,40 @@
|
|||
/** @file
|
||||
Header file for compression routine.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
/** @file
|
||||
Main file for Dblk shell Debug1 function.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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 <Protocol/BlockIo.h>
|
||||
|
||||
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);
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
/** @file
|
||||
Main file for Dmem shell Debug1 function.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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 <Protocol/PciRootBridgeIo.h>
|
||||
|
||||
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);
|
||||
}
|
|
@ -0,0 +1,228 @@
|
|||
/** @file
|
||||
Main file for DmpStore shell Debug1 function.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
/** @file
|
||||
Main file for EfiCompress shell Debug1 function.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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);
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
/** @file
|
||||
Main file for EfiDecompress shell Debug1 function.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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 <Protocol/Decompress.h>
|
||||
|
||||
|
||||
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);
|
||||
}
|
|
@ -0,0 +1,428 @@
|
|||
/** @file
|
||||
Main file for LoadPciRom shell Debug1 function.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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 <IndustryStandard/Pci22.h>
|
||||
#include <IndustryStandard/Pci23.h>
|
||||
#include <IndustryStandard/PeImage.h>
|
||||
#include <Protocol/Decompress.h>
|
||||
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
/** @file
|
||||
Main file for Mode shell Debug1 function.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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);
|
||||
}
|
||||
|
|
@ -0,0 +1,602 @@
|
|||
/** @file
|
||||
Main file for Mm shell Debug1 function.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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 <Library/ShellLib.h>
|
||||
#include <Protocol/PciRootBridgeIo.h>
|
||||
#include <Protocol/DeviceIo.h>
|
||||
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/** @file
|
||||
Main file for Mode shell Debug1 function.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,460 @@
|
|||
/** @file
|
||||
Header file for Pci shell Debug1 function.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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_
|
|
@ -0,0 +1,344 @@
|
|||
/** @file
|
||||
Main file for SerMode shell Debug1 function.
|
||||
|
||||
Copyright (c) 20052010, Intel Corporation. All rights reserved.<BR>
|
||||
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 <Library/ShellLib.h>
|
||||
#include <Protocol/SerialIo.h>
|
||||
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/** @file
|
||||
Main file for SetSize shell Debug1 function.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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);
|
||||
}
|
|
@ -0,0 +1,228 @@
|
|||
/** @file
|
||||
Main file for SetVar shell Debug1 function.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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);
|
||||
}
|
|
@ -0,0 +1,394 @@
|
|||
/**
|
||||
Module for clarifying the content of the smbios structure element info.
|
||||
|
||||
Copyright (c) 2005-2010, Intel Corporation. All rights reserved. <BR>
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/**
|
||||
Module to clarify system event log of smbios structure.
|
||||
|
||||
Copyright (c) 2005-2010, Intel Corporation. All rights reserved. <BR>
|
||||
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
|
|
@ -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.<BR>
|
||||
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
|
|
@ -0,0 +1,349 @@
|
|||
/** @file
|
||||
API for SMBIOS table.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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 <Guid/Smbios.h>
|
||||
#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;
|
||||
}
|
||||
}
|
|
@ -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.<BR>
|
||||
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
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,192 @@
|
|||
/** @file
|
||||
Module to clarify the element info of the smbios structure.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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
|
File diff suppressed because it is too large
Load Diff
|
@ -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.<BR>
|
||||
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
|
|
@ -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.<BR>
|
||||
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 <Guid/Smbios.h>
|
||||
#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;
|
||||
}
|
|
@ -0,0 +1,547 @@
|
|||
/** @file
|
||||
Tools of clarify the content of the smbios table.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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);
|
||||
}
|
||||
*/
|
Binary file not shown.
|
@ -0,0 +1,91 @@
|
|||
/** @file
|
||||
Tools of clarify the content of the smbios table.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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
|
|
@ -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.<BR>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,332 @@
|
|||
/** @file
|
||||
Main file for NULL named library for Profile1 shell command functions.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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 <Uefi.h>
|
||||
#include <ShellBase.h>
|
||||
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Guid/ConsoleInDevice.h>
|
||||
#include <Guid/ConsoleOutDevice.h>
|
||||
|
||||
#include <Protocol/EfiShell.h>
|
||||
#include <Protocol/EfiShellParameters.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/UnicodeCollation.h>
|
||||
#include <Protocol/DevicePathToText.h>
|
||||
#include <Protocol/DriverDiagnostics2.h>
|
||||
#include <Protocol/DriverDiagnostics.h>
|
||||
#include <Protocol/PlatformDriverOverride.h>
|
||||
#include <Protocol/BusSpecificDriverOverride.h>
|
||||
#include <Protocol/PlatformToDriverConfiguration.h>
|
||||
#include <Protocol/DriverSupportedEfiVersion.h>
|
||||
#include <Protocol/DriverFamilyOverride.h>
|
||||
#include <Protocol/DriverHealth.h>
|
||||
#include <Protocol/DevicePathFromText.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/ShellCommandLib.h>
|
||||
#include <Library/ShellLib.h>
|
||||
#include <Library/SortLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
#include <Library/FileHandleLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/HandleParsingLib.h>
|
||||
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
## @file
|
||||
# Provides shell Debug1 profile functions
|
||||
#
|
||||
# Copyright (c) 2010, Intel Corporation.All rights reserved. <BR>
|
||||
#
|
||||
# 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
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue