/** @file
a head for test smbios
Copyright (c) 2019 GreatWall All rigths reserved.<BR>
**/
#ifndef TEST_SMBIOS_
#define TEST_SMBIOS_
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <IndustryStandard/SmBios.h>
#include <Library/BaseMemoryLib.h>
#include <IndustryStandard/SmBios.h>
#include <Library/DebugLib.h>
#define INVALID_HANDLE (UINT16) (-1)
#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
/**
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
LibGetSmbiosStructure (
IN OUT UINT16 *Handle,
OUT UINT8 **Buffer,
OUT UINT16 *Length
);
/**
Return SMBIOS string for the given string number.
@param[in] Smbios Pointer to SMBIOS structure.
@param[in] StringNumber String number to return. -1 is used to skip all strings and
point to the next SMBIOS structure.
@return Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
**/
CHAR8*
LibGetSmbiosString (
IN SMBIOS_STRUCTURE_POINTER *Smbios,
IN UINT16 StringNumber
);
#endif
/** @file
test smbios
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
STATIC SMBIOS_STRUCTURE_POINTER m_SmbiosStruct;
STATIC SMBIOS_STRUCTURE_POINTER *mSmbiosStruct = &m_SmbiosStruct;
STATIC SMBIOS_TABLE_ENTRY_POINT *mSmbiosTable = NULL;
/**
The user Entry Point for Application. The user code starts with this function
as the real entry point for the application.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval other Some error occurs when executing this entry point.
**/
EFI_STATUS
EFIAPI
SmBiosTest1Entry (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
SMBIOS_STRUCTURE_POINTER SmBiosStruct;
UINT16 Index;
UINT16 Handle;
UINT8 *Buffer;
UINT16 Length;
// Get SMBIOS table from System Configure table
//
Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID**)&mSmbiosTable);
if((Status != EFI_SUCCESS || mSmbiosTable == NULL) ||
(CompareMem (mSmbiosTable->AnchorString, "_SM_", 4) != 0 )) {
Print (L"smbios table is not found!");
return Status;
}
Print (L"[SMBIOS Entry]\n");
Print (L" Anchor String:%c%c%c%c\n Checksum:0x%x\n Length:0x%x\n ",
mSmbiosTable->AnchorString[0],
mSmbiosTable->AnchorString[1],
mSmbiosTable->AnchorString[2],
mSmbiosTable->AnchorString[3],
mSmbiosTable->IntermediateChecksum,
mSmbiosTable->EntryPointLength
// mSmbiosTable->MajorVersion,
//mSmbiosTable->MinorVersion
);
Print (L" Max Structure Size:0x%x\n Intermediate Anchor:%c%c%c%c%c\n Intermediate Checksum:0x%x\n",
mSmbiosTable->MaxStructureSize,
mSmbiosTable->IntermediateAnchorString[0],
mSmbiosTable->IntermediateAnchorString[1],
mSmbiosTable->IntermediateAnchorString[2],
mSmbiosTable->IntermediateAnchorString[3],
mSmbiosTable->IntermediateAnchorString[4],
mSmbiosTable->IntermediateChecksum
);
Print (L" Structure Table Length:0x%x\n Structure Table Address:0x%x\n Number Of Structures:0x%x\n\n\n",
mSmbiosTable->TableLength,
mSmbiosTable->TableAddress,
mSmbiosTable->NumberOfSmbiosStructures
);
Print (L"[BIOS Language Infomation] (Type 13)\n");
//Print(L"Type:0x%x\n",SmBiosStruct->Hdr->Type);
Print(L" Type:0x%x\n",SmBiosStruct.Type13->Hdr.Type);
Print(L" Length:0x%x\n",SmBiosStruct.Type13->Hdr.Length);
Print(L" Handle:0x%x\n",SmBiosStruct.Type13->Hdr.Handle);
//原来的位置
//Print(L"Type:0x%x\n",SmBiosStruct->Type13.Hdr.Type);
//Print(L"Type:0x%x\n",SmBiosStruct->Type13->Hdr->Type);
//Print(L"Length:0x%x\n",SmBiosStruct->Type13->Hdr->Length);
//Print(L"Handle:0x%x\n",SmBiosStruct->Type13->Hdr->Handle);
Print(L" Installable Languages:0x%x\n",SmBiosStruct.Type13->InstallableLanguages);
//Print(L"Bus Number:0x%x\n",SmBiosStruct.Type13->Hdr);
Print(L" Flags:0x%x\n",SmBiosStruct.Type13->Flags);
Print(L" Reserved:0x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x\n",
SmBiosStruct.Type13->Reserved[0],
SmBiosStruct.Type13->Reserved[1],
SmBiosStruct.Type13->Reserved[2],
SmBiosStruct.Type13->Reserved[3],
SmBiosStruct.Type13->Reserved[4],
SmBiosStruct.Type13->Reserved[5],
SmBiosStruct.Type13->Reserved[6],
SmBiosStruct.Type13->Reserved[7],
SmBiosStruct.Type13->Reserved[8],
SmBiosStruct.Type13->Reserved[9],
SmBiosStruct.Type13->Reserved[10],
SmBiosStruct.Type13->Reserved[11],
SmBiosStruct.Type13->Reserved[12],
SmBiosStruct.Type13->Reserved[13],
SmBiosStruct.Type13->Reserved[14]);
Print(L" Current Languages:0x%x\n",SmBiosStruct.Type13->CurrentLanguages);
//Print(L"Bus Number:0x%x\n",SmBiosStruct.Type13->CurrentLanguages);
mSmbiosStruct->Raw = (UINT8 *) (UINTN) (mSmbiosTable->TableAddress);
Handle = INVALID_HANDLE;
LibGetSmbiosStructure (&Handle, NULL, NULL);
for (Index = 0; Index < mSmbiosTable->NumberOfSmbiosStructures; Index++) {
// If reach the end of table, break..
if (Handle == INVALID_HANDLE) {
break;
}
// After LibGetSmbiosStructure(), handle then point to the next!
if (LibGetSmbiosStructure (&Handle, &Buffer, &Length) != DMI_SUCCESS) {
break;
}
SmBiosStruct.Raw = Buffer;
//Print (L"SmBios Table: %d smbios handle: 0x%x\n",SmBiosStruct.Hdr->Type,SmBiosStruct.Hdr->Handle);
}
return Status;
}
/**
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 hand