您的位置:首页 > 产品设计 > UI/UE

UEFI应用与编程--SmBios

2018-03-15 12:33 1151 查看
SmBiosList.c#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/ShellCEntryLib.h>
#include <IndustryStandard/SmBios.h>
#include "UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h"
#include "UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.h "

INTN
EFIAPI
ShellAppMain (
IN UINTN Argc,
IN CHAR16 **Argv
)
{
EFI_STATUS Status;
SMBIOS_TABLE_ENTRY_POINT *mSmbiosTable = NULL;
SMBIOS_STRUCTURE_POINTER m_SmbiosStruct;
SMBIOS_STRUCTURE_POINTER *mSmbiosStruct = &m_SmbiosStruct;

UINT16 Handle1 = 1;
UINT8 *Buffer1;
UINT16 Length1;

UINT16 *Handle;
UINT8 **Buffer;
UINT16 *Length;

SMBIOS_STRUCTURE_POINTER Smbios;
SMBIOS_STRUCTURE_POINTER SmbiosEnd;
UINT8 *Raw;

mSmbiosTable = NULL;

//
// Get SMBIOS table from System Configure table
//
Status = GetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID**)&mSmbiosTable);

if (mSmbiosTable == NULL) {
Print(L"%r.\n",Status);
}
//
// Init SMBIOS structure table address
//
mSmbiosStruct->Raw = (UINT8 *) (UINTN) (mSmbiosTable->TableAddress);

//
//Find the structure
//
Handle = &Handle1;
Length = &Length1;
Buffer = &Buffer1;

if (*Handle == INVALID_HANDLE) {
*Handle = mSmbiosStruct->Hdr->Handle;
Print(L"input handle error.\n");
return DMI_INVALID_HANDLE;
}

if ((Buffer == NULL) || (Length == NULL)) {
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);
*Buffer = Raw;
//
// update with the next structure handle.
//
if (Smbios.Raw < SmbiosEnd.Raw) {
*Handle = Smbios.Hdr->Handle;
} else {
*Handle = INVALID_HANDLE;
}
Print(L"Handle:%04x Address:%08x Length:%04x\n", *Handle - 1, *Buffer, *Length);
//return DMI_SUCCESS;
}
//
// Walk to next structure
//
LibGetSmbiosString (&Smbios, (UINT16) (-1));
}

*Handle = INVALID_HANDLE;
DumpHex(2, 0, *Length, *Buffer);
return EFI_SUCCESS;
}
SmBiosList.inf[Defines]
INF_VERSION = 0x00010005
BASE_NAME = SmBiosList
FILE_GUID = dc72d2c7-a48a-42fd-80b6-9d229d9943c8
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = ShellCEntryLib

[Sources]
SmBiosList.c

[Packages]
MdePkg/MdePkg.dec
ShellPkg/ShellPkg.dec
MdeModulePkg/MdeModulePkg.dec

[LibraryClasses]
UefiLib
ShellCEntryLib
UefiShellDebug1CommandsLib
[Protocols]

[Ppis]

[Guids]
gEfiSmbiosTableGuid
[BuildOptions]

[Pcd]

[PcdEx]

[FixedPcd]

[FeaturePcd]

[PatchPcd]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  uefi edk2 udk bios smbios