ShellPkg: update smbiosview for SMBIOS 3.0.
smbiosview can dump 64-bit entry point and table as long as SMBIOS 3.0 table exists in system configuration table. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Elvin Li <elvin.li@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17060 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
API for SMBIOS table.
|
||||
|
||||
Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2005 - 2015, 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
|
||||
@ -19,9 +19,13 @@
|
||||
#include "SmbiosView.h"
|
||||
|
||||
STATIC UINT8 mInit = 0;
|
||||
STATIC SMBIOS_TABLE_ENTRY_POINT *mSmbiosTable = NULL;
|
||||
STATIC UINT8 m64Init = 0;
|
||||
STATIC SMBIOS_TABLE_ENTRY_POINT *mSmbiosTable = NULL;
|
||||
STATIC SMBIOS_TABLE_3_0_ENTRY_POINT *mSmbios64BitTable = NULL;
|
||||
STATIC SMBIOS_STRUCTURE_POINTER m_SmbiosStruct;
|
||||
STATIC SMBIOS_STRUCTURE_POINTER *mSmbiosStruct = &m_SmbiosStruct;
|
||||
STATIC SMBIOS_STRUCTURE_POINTER m_Smbios64BitStruct;
|
||||
STATIC SMBIOS_STRUCTURE_POINTER *mSmbios64BitStruct = &m_Smbios64BitStruct;
|
||||
|
||||
/**
|
||||
Init the SMBIOS VIEW API's environment.
|
||||
@ -47,7 +51,6 @@ LibSmbiosInit (
|
||||
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;
|
||||
}
|
||||
|
||||
@ -64,6 +67,46 @@ LibSmbiosInit (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Init the SMBIOS VIEW API's environment.
|
||||
|
||||
@retval EFI_SUCCESS Successful to init the SMBIOS VIEW Lib.
|
||||
**/
|
||||
EFI_STATUS
|
||||
LibSmbios64BitInit (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Init only once
|
||||
//
|
||||
if (m64Init == 1) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
//
|
||||
// Get SMBIOS table from System Configure table
|
||||
//
|
||||
Status = GetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOID**)&mSmbios64BitTable);
|
||||
|
||||
if (mSmbios64BitTable == NULL) {
|
||||
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
|
||||
//
|
||||
mSmbios64BitStruct->Raw = (UINT8 *) (UINTN) (mSmbios64BitTable->TableAddress);
|
||||
|
||||
m64Init = 1;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Cleanup the Smbios information.
|
||||
**/
|
||||
@ -82,6 +125,24 @@ LibSmbiosCleanup (
|
||||
mInit = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Cleanup the Smbios information.
|
||||
**/
|
||||
VOID
|
||||
LibSmbios64BitCleanup (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
//
|
||||
// Release resources
|
||||
//
|
||||
if (mSmbios64BitTable != NULL) {
|
||||
mSmbios64BitTable = NULL;
|
||||
}
|
||||
|
||||
m64Init = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Get the entry point structure for the table.
|
||||
|
||||
@ -98,6 +159,22 @@ LibSmbiosGetEPS (
|
||||
*EntryPointStructure = mSmbiosTable;
|
||||
}
|
||||
|
||||
/**
|
||||
Get the entry point structure for the table.
|
||||
|
||||
@param[out] EntryPointStructure The pointer to populate.
|
||||
**/
|
||||
VOID
|
||||
LibSmbios64BitGetEPS (
|
||||
OUT SMBIOS_TABLE_3_0_ENTRY_POINT **EntryPointStructure
|
||||
)
|
||||
{
|
||||
//
|
||||
// return SMBIOS Table address
|
||||
//
|
||||
*EntryPointStructure = mSmbios64BitTable;
|
||||
}
|
||||
|
||||
/**
|
||||
Return SMBIOS string for the given string number.
|
||||
|
||||
@ -222,3 +299,75 @@ LibGetSmbiosStructure (
|
||||
return DMI_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
/**
|
||||
Get SMBIOS structure for the given Handle,
|
||||
Handle is changed to the next handle or 0xFFFF when the end is
|
||||
reached or the handle is not found.
|
||||
|
||||
@param[in, out] Handle 0xFFFF: get the first structure
|
||||
Others: get a structure according to this value.
|
||||
@param[out] Buffer The pointer to the pointer to the structure.
|
||||
@param[out] Length Length of the structure.
|
||||
|
||||
@retval DMI_SUCCESS Handle is updated with next structure handle or
|
||||
0xFFFF(end-of-list).
|
||||
|
||||
@retval DMI_INVALID_HANDLE Handle is updated with first structure handle or
|
||||
0xFFFF(end-of-list).
|
||||
**/
|
||||
EFI_STATUS
|
||||
LibGetSmbios64BitStructure (
|
||||
IN OUT UINT16 *Handle,
|
||||
OUT UINT8 **Buffer,
|
||||
OUT UINT16 *Length
|
||||
)
|
||||
{
|
||||
SMBIOS_STRUCTURE_POINTER Smbios;
|
||||
SMBIOS_STRUCTURE_POINTER SmbiosEnd;
|
||||
UINT8 *Raw;
|
||||
|
||||
if (*Handle == INVALID_HANDLE) {
|
||||
*Handle = mSmbios64BitStruct->Hdr->Handle;
|
||||
return DMI_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if ((Buffer == NULL) || (Length == NULL)) {
|
||||
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_NO_BUFF_LEN_SPEC), gShellDebug1HiiHandle);
|
||||
return DMI_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
*Length = 0;
|
||||
Smbios.Hdr = mSmbios64BitStruct->Hdr;
|
||||
|
||||
SmbiosEnd.Raw = Smbios.Raw + mSmbios64BitTableLength;
|
||||
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);
|
||||
*Buffer = Raw;
|
||||
//
|
||||
// update with the next structure handle.
|
||||
//
|
||||
if (Smbios.Raw < SmbiosEnd.Raw) {
|
||||
*Handle = Smbios.Hdr->Handle;
|
||||
} else {
|
||||
*Handle = INVALID_HANDLE;
|
||||
}
|
||||
return DMI_SUCCESS;
|
||||
}
|
||||
//
|
||||
// Walk to next structure
|
||||
//
|
||||
LibGetSmbiosString (&Smbios, (UINT16) (-1));
|
||||
}
|
||||
|
||||
*Handle = INVALID_HANDLE;
|
||||
return DMI_INVALID_HANDLE;
|
||||
}
|
Reference in New Issue
Block a user