Add smbios command
Incorporate the smbios command from https://raw.githubusercontent.com/dm0-/gnuxc/master/patches/grub-2.02~beta2-smbios-module.patch so we can extract the machine UUID and serial number.
This commit is contained in:
parent
d4bc2bf02f
commit
92e46cccf1
10 changed files with 673 additions and 18 deletions
|
@ -30,6 +30,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||
static grub_efi_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
|
||||
static grub_efi_guid_t acpi2_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
|
||||
static grub_efi_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
|
||||
static grub_efi_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
|
||||
|
||||
#define EBDA_SEG_ADDR 0x40e
|
||||
#define LOW_MEM_ADDR 0x413
|
||||
|
@ -93,7 +94,7 @@ static void
|
|||
fake_bios_data (int use_rom)
|
||||
{
|
||||
unsigned i;
|
||||
void *acpi, *smbios;
|
||||
void *acpi, *smbios, *smbios3;
|
||||
grub_uint16_t *ebda_seg_ptr, *low_mem_ptr;
|
||||
|
||||
ebda_seg_ptr = (grub_uint16_t *) EBDA_SEG_ADDR;
|
||||
|
@ -103,6 +104,7 @@ fake_bios_data (int use_rom)
|
|||
|
||||
acpi = 0;
|
||||
smbios = 0;
|
||||
smbios3 = 0;
|
||||
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||
{
|
||||
grub_efi_packed_guid_t *guid =
|
||||
|
@ -127,6 +129,11 @@ fake_bios_data (int use_rom)
|
|||
smbios = grub_efi_system_table->configuration_table[i].vendor_table;
|
||||
grub_dprintf ("efi", "SMBIOS: %p\n", smbios);
|
||||
}
|
||||
else if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_efi_guid_t)))
|
||||
{
|
||||
smbios3 = grub_efi_system_table->configuration_table[i].vendor_table;
|
||||
grub_dprintf ("efi", "SMBIOS3: %p\n", smbios3);
|
||||
}
|
||||
}
|
||||
|
||||
*ebda_seg_ptr = FAKE_EBDA_SEG;
|
||||
|
@ -137,8 +144,13 @@ fake_bios_data (int use_rom)
|
|||
if (acpi)
|
||||
grub_memcpy ((char *) ((FAKE_EBDA_SEG << 4) + 16), acpi, 1024 - 16);
|
||||
|
||||
if ((use_rom) && (smbios))
|
||||
grub_memcpy ((char *) SBIOS_ADDR, (char *) smbios + 16, 16);
|
||||
if (use_rom)
|
||||
{
|
||||
if (smbios)
|
||||
grub_memcpy ((char *) SBIOS_ADDR, (char *) smbios, 31);
|
||||
if (smbios3)
|
||||
grub_memcpy ((char *) SBIOS_ADDR + 32, (char *) smbios3, 24);
|
||||
}
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
|
|
@ -48,6 +48,7 @@ static const struct guid_mapping guid_mappings[] =
|
|||
{ GRUB_EFI_MPS_TABLE_GUID, "MPS"},
|
||||
{ GRUB_EFI_SAL_TABLE_GUID, "SAL"},
|
||||
{ GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
|
||||
{ GRUB_EFI_SMBIOS3_TABLE_GUID, "SMBIOS3"},
|
||||
{ GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"},
|
||||
{ GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"},
|
||||
{ GRUB_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"},
|
||||
|
|
59
grub-core/commands/efi/smbios.c
Normal file
59
grub-core/commands/efi/smbios.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* smbios.c - get smbios tables. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2015 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/smbios.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/api.h>
|
||||
|
||||
struct grub_smbios_eps *
|
||||
grub_machine_smbios_get_eps (void)
|
||||
{
|
||||
unsigned i;
|
||||
static grub_efi_packed_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
|
||||
|
||||
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||
{
|
||||
grub_efi_packed_guid_t *guid =
|
||||
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||
|
||||
if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_packed_guid_t)))
|
||||
return (struct grub_smbios_eps *)
|
||||
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct grub_smbios_eps3 *
|
||||
grub_machine_smbios_get_eps3 (void)
|
||||
{
|
||||
unsigned i;
|
||||
static grub_efi_packed_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
|
||||
|
||||
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||
{
|
||||
grub_efi_packed_guid_t *guid =
|
||||
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||
|
||||
if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_efi_packed_guid_t)))
|
||||
return (struct grub_smbios_eps3 *)
|
||||
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue