MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables

The default EfiSmbiosProtocol operates on an empty SMBIOS table.
The SMBIOS tables are provided by the bootloader on UefiPayloadPkg.
Scan for existing tables in SmbiosDxe and load them if they seem valid.
This fixes the settings menu not showing any hardware information, instead
only "0 MB RAM" was displayed.
Tests showed that the OS can still see the SMBIOS tables.

SmbiosDxe will get the SMBIOS from a guid Hob.
Also will keep the SmbiosHandle if it is available.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Tested-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
This commit is contained in:
Zhiguang Liu
2021-04-30 13:36:54 +08:00
committed by mergify[bot]
parent 9d53e01efe
commit 70e8c9c3bc
3 changed files with 360 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
/** @file
This code supports the implementation of the Smbios protocol
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h>
#include <Library/HobLib.h>
#include <UniversalPayload/SmbiosTable.h>
#define SMBIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('S', 'B', 'i', 's')
typedef struct {
@@ -121,4 +123,65 @@ SmbiosTableConstruction (
BOOLEAN Smbios64BitTable
);
/**
Validates a SMBIOS 3.0 table entry point.
@param TableEntry The SmBios table entry to validate.
@param TableAddress On exit, point to the smbios table addres.
@param TableMaximumSize On exit, point to the maximum size of the table.
@retval TRUE SMBIOS table entry point is valid.
@retval FALSE SMBIOS table entry point is malformed.
**/
STATIC
BOOLEAN
IsValidSmbios30Table (
IN VOID *TableEntry,
OUT VOID **TableAddress,
OUT UINTN *TableMaximumSize
);
/**
Validates a SMBIOS 2.0 table entry point.
@param TableEntry The SmBios table entry to validate.
@param TableAddress On exit, point to the smbios table addres.
@param TableMaximumSize On exit, point to the maximum size of the table.
@retval TRUE SMBIOS table entry point is valid.
@retval FALSE SMBIOS table entry point is malformed.
**/
STATIC
BOOLEAN
IsValidSmbios20Table (
IN VOID *TableEntry,
OUT VOID **TableAddress,
OUT UINTN *TableMaximumSize
);
/**
Validates a SMBIOS table entry point.
@param TableEntry The SmBios table entry to validate.
@param TableAddress On exit, point to the smbios table addres.
@param TableMaximumSize On exit, point to the maximum size of the table.
@retval TRUE SMBIOS table entry point is valid.
@retval FALSE SMBIOS table entry point is malformed.
**/
typedef
BOOLEAN
(* IS_SMBIOS_TABLE_VALID) (
IN VOID *TableEntry,
OUT VOID **TableAddress,
OUT UINTN *TableMaximumSize
);
typedef struct {
EFI_GUID *Guid;
IS_SMBIOS_TABLE_VALID IsValid;
} IS_SMBIOS_TABLE_VALID_ENTRY;
#endif