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]
#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应用与编程--EFI_SMBIOS_PROTOCOL
- UEFI应用与编程--EFI_SMBUS_HC_PROTOCOL
- UEFI应用与编程--读写Pci配置空间
- UEFI应用与编程--EFI_DISK_INFO_PROTOCOL
- UEFI应用与编程--AcpiTable
- UEFI应用与编程--显示文件信息
- UEFI应用与编程--ReadSpd
- UEFI应用与编程--HelloWorld(03)
- UEFI应用与编程--解析命令行参数
- UEFI应用与编程--GetNextVariableName
- UEFI应用与编程--ReadCmos
- UEFI应用与编程--EFI_USB2_HC_PROTOCOL
- UEFI应用与编程--WriteCmos
- UEFI应用与编程--EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
- UEFI应用与编程--ShowBootDevice
- UEFI应用与编程--IndexIo
- UEFI应用与编程--HelloWorld(01)
- UEFI应用与编程--Handle&EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
- UEFI应用与编程--HelloWorld(02)
- UEFI应用与编程--BootOrder