Skip to content

Commit dd308a7

Browse files
committed
Prefer SMBIOS table to SMBIOS 3.0, if present and below 4G
SeaBIOS relies on SMBIOS 2.1, not SMBIOS 3.0.
1 parent 0590877 commit dd308a7

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/csmwrap.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,41 +68,42 @@ int test_bios_region_rw()
6868

6969
int set_smbios_table()
7070
{
71-
UINTN i;
7271
EFI_GUID smbiosGuid = SMBIOS_TABLE_GUID;
7372
EFI_GUID smbios3Guid = SMBIOS3_TABLE_GUID;
74-
bool found = FALSE;
7573
uintptr_t table_addr = 0;
7674

77-
for (i = 0; i < gST->NumberOfTableEntries; i++) {
78-
EFI_CONFIGURATION_TABLE *table;
79-
table = gST->ConfigurationTable + i;
75+
for (size_t i = 0; i < gST->NumberOfTableEntries; i++) {
76+
EFI_CONFIGURATION_TABLE *table = gST->ConfigurationTable + i;
8077

8178
if (!efi_guidcmp(table->VendorGuid, smbiosGuid)) {
8279
printf("Found SMBIOS Table at %x\n", (uintptr_t)table->VendorTable);
83-
table_addr = (uintptr_t)table->VendorTable;
84-
found = TRUE;
80+
if (table_addr < 0x100000000) {
81+
table_addr = (uintptr_t)table->VendorTable;
82+
}
8583
break;
8684
}
85+
}
8786

88-
if (!efi_guidcmp(table->VendorGuid, smbios3Guid)) {
89-
printf("Found SMBIOS 3.0 Table at %x\n", (uintptr_t)table->VendorTable);
90-
table_addr = (uintptr_t)table->VendorTable;
91-
found = TRUE;
92-
break;
87+
if (table_addr == 0) {
88+
for (size_t i = 0; i < gST->NumberOfTableEntries; i++) {
89+
EFI_CONFIGURATION_TABLE *table = gST->ConfigurationTable + i;
90+
91+
if (!efi_guidcmp(table->VendorGuid, smbios3Guid)) {
92+
printf("Found SMBIOS 3.0 Table at %x\n", (uintptr_t)table->VendorTable);
93+
if (table_addr < 0x100000000) {
94+
table_addr = (uintptr_t)table->VendorTable;
95+
}
96+
break;
97+
}
9398
}
9499
}
95100

96-
if (found) {
97-
if (table_addr > 0xffffffff) {
98-
printf("SMBIOS table address too high\n");
99-
return -1;
100-
}
101+
if (table_addr != 0) {
101102
priv.low_stub->boot_table.SmbiosTable = table_addr;
102103
return 0;
103104
}
104105

105-
printf("No SMBIOS table found\n");
106+
printf("No usable SMBIOS table found\n");
106107

107108
return -1;
108109
}

0 commit comments

Comments
 (0)