smbios: Add a module for retrieving SMBIOS information

The following are two use cases from Rajat Jain <rajatjain@juniper.net>:

  1) We have a board that boots Linux and this board itself can be plugged
     into one of different chassis types. We need to pass different
     parameters to the kernel based on the "CHASSIS_TYPE" information
     that is passed by the bios in the DMI/SMBIOS tables.

  2) We may have a USB stick that can go into multiple boards, and the
     exact kernel to be loaded depends on the machine information
     (PRODUCT_NAME etc) passed via the DMI.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
David Michael 2019-07-05 08:47:09 -04:00 committed by Daniel Kiper
parent 261df54f17
commit 688023cd0a
7 changed files with 650 additions and 11 deletions

View file

@ -22,11 +22,11 @@
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/acpi.h>
#include <grub/smbios.h>
grub_err_t
grub_machine_efiemu_init_tables (void)
{
grub_uint8_t *ptr;
void *table;
grub_err_t err;
grub_efi_guid_t smbios = GRUB_EFI_SMBIOS_TABLE_GUID;
@ -57,17 +57,10 @@ grub_machine_efiemu_init_tables (void)
if (err)
return err;
}
for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000;
ptr += 16)
if (grub_memcmp (ptr, "_SM_", 4) == 0
&& grub_byte_checksum (ptr, *(ptr + 5)) == 0)
break;
if (ptr < (grub_uint8_t *) 0x100000)
table = grub_smbios_get_eps ();
if (table)
{
grub_dprintf ("efiemu", "Registering SMBIOS\n");
err = grub_efiemu_register_configuration_table (smbios, 0, 0, ptr);
err = grub_efiemu_register_configuration_table (smbios, 0, 0, table);
if (err)
return err;
}