smbios: Rename code specific for SMBIOS 2.1 entry points

Rename copy_smbios(), smbios_next(), SMBIOS_SIGNATURE,
smbios_entry_point, and SMBiosAddr, to indicate they refer to
SMBIOS 2.1 entry points.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
Eduardo Habkost 2020-12-10 10:10:42 -05:00 committed by Kevin O'Connor
parent 7b02616560
commit 97f6c5b024
6 changed files with 33 additions and 33 deletions

View File

@ -14,7 +14,7 @@
#include "std/acpi.h" // struct rsdp_descriptor
#include "std/mptable.h" // MPTABLE_SIGNATURE
#include "std/pirtable.h" // struct pir_header
#include "std/smbios.h" // struct smbios_entry_point
#include "std/smbios.h" // struct smbios_21_entry_point
#include "string.h" // memcpy
#include "util.h" // copy_table
#include "x86.h" // outb
@ -265,7 +265,7 @@ find_acpi_features(void)
// Iterator for each sub-table in the smbios blob.
void *
smbios_next(struct smbios_entry_point *smbios, void *prev)
smbios_21_next(struct smbios_21_entry_point *smbios, void *prev)
{
if (!smbios)
return NULL;
@ -288,15 +288,15 @@ smbios_next(struct smbios_entry_point *smbios, void *prev)
return prev;
}
struct smbios_entry_point *SMBiosAddr;
struct smbios_21_entry_point *SMBios21Addr;
void
copy_smbios(void *pos)
copy_smbios_21(void *pos)
{
if (SMBiosAddr)
if (SMBios21Addr)
return;
struct smbios_entry_point *p = pos;
if (p->signature != SMBIOS_SIGNATURE)
struct smbios_21_entry_point *p = pos;
if (p->signature != SMBIOS_21_SIGNATURE)
return;
if (checksum(pos, 0x10) != 0)
return;
@ -304,15 +304,15 @@ copy_smbios(void *pos)
return;
if (checksum(pos+0x10, p->length-0x10) != 0)
return;
SMBiosAddr = copy_fseg_table("SMBIOS", pos, p->length);
SMBios21Addr = copy_fseg_table("SMBIOS", pos, p->length);
}
void
display_uuid(void)
{
struct smbios_type_1 *tbl = smbios_next(SMBiosAddr, NULL);
struct smbios_type_1 *tbl = smbios_21_next(SMBios21Addr, NULL);
int minlen = offsetof(struct smbios_type_1, uuid) + sizeof(tbl->uuid);
for (; tbl; tbl = smbios_next(SMBiosAddr, tbl))
for (; tbl; tbl = smbios_21_next(SMBios21Addr, tbl))
if (tbl->header.type == 1 && tbl->header.length >= minlen) {
u8 *uuid = tbl->uuid;
u8 empty_uuid[sizeof(tbl->uuid)] = { 0 };
@ -325,9 +325,9 @@ display_uuid(void)
* the encoding, but we follow dmidecode and assume big-endian
* encoding.
*/
if (SMBiosAddr->smbios_major_version > 2 ||
(SMBiosAddr->smbios_major_version == 2 &&
SMBiosAddr->smbios_minor_version >= 6)) {
if (SMBios21Addr->smbios_major_version > 2 ||
(SMBios21Addr->smbios_major_version == 2 &&
SMBios21Addr->smbios_minor_version >= 6)) {
printf("Machine UUID"
" %02x%02x%02x%02x"
"-%02x%02x"
@ -421,7 +421,7 @@ smbios_romfile_setup(void)
{
struct romfile_s *f_anchor = romfile_find("etc/smbios/smbios-anchor");
struct romfile_s *f_tables = romfile_find("etc/smbios/smbios-tables");
struct smbios_entry_point ep;
struct smbios_21_entry_point ep;
struct smbios_type_0 *t0;
u16 qtables_len, need_t0 = 1;
u8 *qtables, *tables;
@ -440,10 +440,10 @@ smbios_romfile_setup(void)
return 0;
}
f_tables->copy(f_tables, qtables, f_tables->size);
ep.structure_table_address = (u32)qtables; /* for smbios_next(), below */
ep.structure_table_address = (u32)qtables; /* for smbios_21_next(), below */
/* did we get a type 0 structure ? */
for (t0 = smbios_next(&ep, NULL); t0; t0 = smbios_next(&ep, t0))
for (t0 = smbios_21_next(&ep, NULL); t0; t0 = smbios_21_next(&ep, t0))
if (t0->header.type == 0) {
need_t0 = 0;
break;
@ -488,7 +488,7 @@ smbios_romfile_setup(void)
ep.checksum -= checksum(&ep, 0x10);
ep.intermediate_checksum -= checksum((void *)&ep + 0x10, ep.length - 0x10);
copy_smbios(&ep);
copy_smbios_21(&ep);
return 1;
}
@ -506,5 +506,5 @@ copy_table(void *pos)
copy_pir(pos);
copy_mptable(pos);
copy_acpi_rsdp(pos);
copy_smbios(pos);
copy_smbios_21(pos);
}

View File

@ -19,7 +19,7 @@
#include "std/acpi.h" // RSDP_SIGNATURE
#include "std/bda.h" // struct bios_data_area_s
#include "std/optionrom.h" // struct rom_header
#include "util.h" // copy_smbios
#include "util.h" // copy_smbios_21
#define UINT8 u8
#define UINT16 u16
@ -172,8 +172,8 @@ handle_csm_0002(struct bregs *regs)
// SMBIOS table needs to be copied into the f-seg
// XX: OVMF doesn't seem to set SmbiosTableLength so don't check it
if (csm_boot_table->SmbiosTable && !SMBiosAddr)
copy_smbios((void *)csm_boot_table->SmbiosTable);
if (csm_boot_table->SmbiosTable && !SMBios21Addr)
copy_smbios_21((void *)csm_boot_table->SmbiosTable);
// MPTABLE is just there; we don't care where.

View File

@ -11,13 +11,13 @@
#include "output.h" // dprintf
#include "paravirt.h" // RamSize
#include "romfile.h" // romfile_findprefix
#include "std/smbios.h" // struct smbios_entry_point
#include "std/smbios.h" // struct smbios_21_entry_point
#include "string.h" // memset
#include "util.h" // MaxCountCPUs
#include "x86.h" // cpuid
static void
smbios_entry_point_setup(u16 max_structure_size,
smbios_21_entry_point_setup(u16 max_structure_size,
u16 structure_table_length,
void *structure_table_address,
u16 number_of_structures)
@ -35,9 +35,9 @@ smbios_entry_point_setup(u16 max_structure_size,
}
memcpy(finaltable, structure_table_address, structure_table_length);
struct smbios_entry_point ep;
struct smbios_21_entry_point ep;
memset(&ep, 0, sizeof(ep));
ep.signature = SMBIOS_SIGNATURE;
ep.signature = SMBIOS_21_SIGNATURE;
ep.length = 0x1f;
ep.smbios_major_version = 2;
ep.smbios_minor_version = 4;
@ -53,7 +53,7 @@ smbios_entry_point_setup(u16 max_structure_size,
ep.intermediate_checksum -= checksum((void*)&ep + 0x10, ep.length - 0x10);
copy_smbios(&ep);
copy_smbios_21(&ep);
}
static int
@ -584,6 +584,6 @@ smbios_legacy_setup(void)
#undef add_struct
smbios_entry_point_setup(max_struct_size, p - start, start, nr_structs);
smbios_21_entry_point_setup(max_struct_size, p - start, start, nr_structs);
free(start);
}

View File

@ -3,12 +3,12 @@
#include "types.h" // u32
#define SMBIOS_SIGNATURE 0x5f4d535f // "_SM_"
#define SMBIOS_21_SIGNATURE 0x5f4d535f // "_SM_"
/* SMBIOS entry point -- must be written to a 16-bit aligned address
between 0xf0000 and 0xfffff.
*/
struct smbios_entry_point {
struct smbios_21_entry_point {
u32 signature;
u8 checksum;
u8 length;

View File

@ -18,7 +18,7 @@
#include "output.h" // dprintf
#include "sha.h" // sha1, sha256, ...
#include "std/acpi.h" // RSDP_SIGNATURE, rsdt_descriptor
#include "std/smbios.h" // struct smbios_entry_point
#include "std/smbios.h" // struct smbios_21_entry_point
#include "std/tcg.h" // TCG_PC_LOGOVERFLOW
#include "string.h" // checksum
#include "tcgbios.h"// tpm_*, prototypes
@ -1058,7 +1058,7 @@ tpm_smbios_measure(void)
.eventid = 1,
.eventdatasize = SHA1_BUFSIZE,
};
struct smbios_entry_point *sep = SMBiosAddr;
struct smbios_21_entry_point *sep = SMBios21Addr;
dprintf(DEBUG_tcg, "TCGBIOS: SMBIOS at %p\n", sep);

View File

@ -87,8 +87,8 @@ void *find_acpi_table(u32 signature);
u32 find_resume_vector(void);
void acpi_reboot(void);
void find_acpi_features(void);
extern struct smbios_entry_point *SMBiosAddr;
void copy_smbios(void *pos);
extern struct smbios_21_entry_point *SMBios21Addr;
void copy_smbios_21(void *pos);
void display_uuid(void);
void copy_table(void *pos);
void smbios_setup(void);