Skip to content

Commit c3162c7

Browse files
mintsukiFlyGoat
authored andcommitted
Prefer SMBIOS2 table over SMBIOS3, if present and below 4G
This is because SeaBIOS relies on SMBIOS 2.1, not SMBIOS 3.0.
1 parent 3dd9e7e commit c3162c7

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
@@ -47,41 +47,42 @@ static void *find_table(uint32_t signature, uint8_t *csm_bin_base, size_t size)
4747

4848
int set_smbios_table()
4949
{
50-
UINTN i;
5150
EFI_GUID smbiosGuid = SMBIOS_TABLE_GUID;
5251
EFI_GUID smbios3Guid = SMBIOS3_TABLE_GUID;
53-
bool found = FALSE;
5452
uintptr_t table_addr = 0;
5553

56-
for (i = 0; i < gST->NumberOfTableEntries; i++) {
57-
EFI_CONFIGURATION_TABLE *table;
58-
table = gST->ConfigurationTable + i;
54+
for (size_t i = 0; i < gST->NumberOfTableEntries; i++) {
55+
EFI_CONFIGURATION_TABLE *table = gST->ConfigurationTable + i;
5956

6057
if (!efi_guidcmp(table->VendorGuid, smbiosGuid)) {
6158
printf("Found SMBIOS Table at %x\n", (uintptr_t)table->VendorTable);
62-
table_addr = (uintptr_t)table->VendorTable;
63-
found = TRUE;
59+
if (table_addr < 0x100000000) {
60+
table_addr = (uintptr_t)table->VendorTable;
61+
}
6462
break;
6563
}
64+
}
6665

67-
if (!efi_guidcmp(table->VendorGuid, smbios3Guid)) {
68-
printf("Found SMBIOS 3.0 Table at %x\n", (uintptr_t)table->VendorTable);
69-
table_addr = (uintptr_t)table->VendorTable;
70-
found = TRUE;
71-
break;
66+
if (table_addr == 0) {
67+
for (size_t i = 0; i < gST->NumberOfTableEntries; i++) {
68+
EFI_CONFIGURATION_TABLE *table = gST->ConfigurationTable + i;
69+
70+
if (!efi_guidcmp(table->VendorGuid, smbios3Guid)) {
71+
printf("Found SMBIOS 3.0 Table at %x\n", (uintptr_t)table->VendorTable);
72+
if (table_addr < 0x100000000) {
73+
table_addr = (uintptr_t)table->VendorTable;
74+
}
75+
break;
76+
}
7277
}
7378
}
7479

75-
if (found) {
76-
if (table_addr > 0xffffffff) {
77-
printf("SMBIOS table address too high\n");
78-
return -1;
79-
}
80+
if (table_addr != 0) {
8081
priv.low_stub->boot_table.SmbiosTable = table_addr;
8182
return 0;
8283
}
8384

84-
printf("No SMBIOS table found\n");
85+
printf("No usable SMBIOS table found\n");
8586

8687
return -1;
8788
}

0 commit comments

Comments
 (0)