/** @file
Tools of clarify the content of the smbios table.
Copyright (c) 2005 - 2011, 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
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"
{L"-t", TypeValue},
{L"-h", TypeValue},
{L"-s", TypeFlag},
{L"-a", TypeFlag},
};
/**
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).
**/
)
{
} else {
}
} else {
} else if (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetValue(Package, L"-t") == NULL) {
} else if (ShellCommandLineGetFlag(Package, L"-h") && ShellCommandLineGetValue(Package, L"-h") == NULL) {
} else if (
) {
} else {
//
// Init Lib
Status = LibSmbiosInit ();
goto Done;
}
//
// build statistics table
//
goto Done;
}
RandomView = TRUE;
//
// Initialize the StructHandle to be the first handle
//
}
RandomView = FALSE;
}
}
goto Done;
}
}
//
// Show SMBIOS structure information
//
}
}
}
Done:
//
// Release resources
//
if (mStatisticsTable != NULL) {
//
// Release statistics table
//
}
}
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.
**/
)
{
//
// bigger than SMBIOS_STRUCTURE_TABLE.MaxStructureSize
//
//
// address offset from structure table head.
//
//
// structure table head.
//
SMBiosTable = NULL;
if (SMBiosTable == NULL) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
return EFI_BAD_BUFFER_SIZE;
}
//
// Have get SMBIOS table
//
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);
/*
//
// 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
//
Offset = 0;
//
// if reach the end of table, break..
//
if (Handle == STRUCTURE_HANDLE_INVALID) {
break;
}
//
// handle then point to the next!
//
break;
}
//
// 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.
//
continue;
}
);
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);
/*
//
// Get internal commands, such as change options.
//
Status = WaitEnter ();
if (EFI_ERROR (Status)) {
if (Status == EFI_ABORTED) {
return EFI_SUCCESS;
}
return Status;
}
*/
//
// check structure legality
//
//
// Print structure information
//
/*
//
// 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;
}
}
return EFI_SUCCESS;
}
return EFI_BAD_BUFFER_SIZE;
}
/**
Function to initialize the global mStatisticsTable object.
@retval EFI_SUCCESS print is successful.
**/
)
{
SMBiosTable = NULL;
if (SMBiosTable == NULL) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
return EFI_NOT_FOUND;
}
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE), gShellDebug1HiiHandle);
return EFI_INVALID_PARAMETER;
}
//
// Allocate memory to mStatisticsTable
//
if (mStatisticsTable != NULL) {
}
mStatisticsTable = (STRUCTURE_STATISTICS *) AllocateZeroPool (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;
//
// search from the first one
//
//
// If reach the end of table, break..
//
if (Handle == STRUCTURE_HANDLE_INVALID) {
break;
}
//
// After LibGetSmbiosStructure(), handle then point to the next!
//
break;
}
//
// general statistics
//
}
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.
**/
)
{
SMBiosTable = NULL;
if (Option < SHOW_OUTLINE) {
return EFI_SUCCESS;
}
//
// display EPS information firstly
//
if (SMBiosTable == NULL) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
return EFI_UNSUPPORTED;
}
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;
}
//
// display statistics table content
//
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX), gShellDebug1HiiHandle, StatisticsPointer->Index);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE), gShellDebug1HiiHandle, StatisticsPointer->Type);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE), gShellDebug1HiiHandle, StatisticsPointer->Handle);
if (Option >= SHOW_DETAIL) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET), gShellDebug1HiiHandle, StatisticsPointer->Addr);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH), gShellDebug1HiiHandle, StatisticsPointer->Length);
}
/*
//
// 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 *
)
{
//
// 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);
}
*/