diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2022-10-29 20:35:51 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2022-10-29 20:35:51 +0000 |
commit | 82edcba6cbb65d788cbce10c5bb45e3c86974fe7 (patch) | |
tree | e7fd79fb6c7c02b8098f10d443880403f236ea7a /sys/arch/arm64 | |
parent | 76d99f04869705c86a7aa7ffb313872f02329dcb (diff) |
The x13s only defines the (legacy) 32-bit SMBIOS entry point. Add code to
handle that such that we can see the firmware version in dmesg.
ok deraadt@, phessler@
Diffstat (limited to 'sys/arch/arm64')
-rw-r--r-- | sys/arch/arm64/dev/efi_machdep.c | 7 | ||||
-rw-r--r-- | sys/arch/arm64/dev/smbios.c | 101 |
2 files changed, 81 insertions, 27 deletions
diff --git a/sys/arch/arm64/dev/efi_machdep.c b/sys/arch/arm64/dev/efi_machdep.c index 1144af51cf9..1dd2c4eb71b 100644 --- a/sys/arch/arm64/dev/efi_machdep.c +++ b/sys/arch/arm64/dev/efi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efi_machdep.c,v 1.3 2022/10/20 18:43:35 kettenis Exp $ */ +/* $OpenBSD: efi_machdep.c,v 1.4 2022/10/29 20:35:50 kettenis Exp $ */ /* * Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org> @@ -138,12 +138,15 @@ efi_attach(struct device *parent, struct device *self, void *aux) for (i = 0; i < st->NumberOfTableEntries; i++) { EFI_CONFIGURATION_TABLE *ct = &st->ConfigurationTable[i]; static EFI_GUID acpi_guid = EFI_ACPI_20_TABLE_GUID; - static EFI_GUID smbios_guid = SMBIOS3_TABLE_GUID; + static EFI_GUID smbios_guid = SMBIOS_TABLE_GUID; + static EFI_GUID smbios3_guid = SMBIOS3_TABLE_GUID; if (efi_guidcmp(&acpi_guid, &ct->VendorGuid) == 0) efi_acpi_table = (uint64_t)ct->VendorTable; if (efi_guidcmp(&smbios_guid, &ct->VendorGuid) == 0) efi_smbios_table = (uint64_t)ct->VendorTable; + if (efi_guidcmp(&smbios3_guid, &ct->VendorGuid) == 0) + efi_smbios_table = (uint64_t)ct->VendorTable; } efi_leave(sc); diff --git a/sys/arch/arm64/dev/smbios.c b/sys/arch/arm64/dev/smbios.c index e5d78d74445..9bde1b5881a 100644 --- a/sys/arch/arm64/dev/smbios.c +++ b/sys/arch/arm64/dev/smbios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smbios.c,v 1.7 2021/10/24 17:52:28 mpi Exp $ */ +/* $OpenBSD: smbios.c,v 1.8 2022/10/29 20:35:50 kettenis Exp $ */ /* * Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca> * Copyright (c) 2019 Mark Kettenis <kettenis@openbsd.org> @@ -76,42 +76,96 @@ smbios_attach(struct device *parent, struct device *self, void *aux) struct smbios_struct_bios *sb; struct smbtable bios; char scratch[64]; + char sig[5]; char *sminfop; bus_addr_t addr; bus_size_t size; bus_space_handle_t ioh; - struct smb3hdr *hdr; - uint8_t *p, checksum = 0; - int i; sc->sc_iot = faa->fa_iot; - if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, sizeof(*hdr), + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, sizeof(sig), BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, &ioh)) { printf(": can't map SMBIOS entry point structure\n"); return; } + bus_space_read_region_1(sc->sc_iot, ioh, 0, sig, sizeof(sig)); + bus_space_unmap(sc->sc_iot, ioh, sizeof(sig)); + + if (strncmp(sig, "_SM_", 4) == 0) { + struct smbhdr *hdr; + uint8_t *p, checksum = 0; + int i; + + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, sizeof(*hdr), + BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, &ioh)) { + printf(": can't map SMBIOS entry point structure\n"); + return; + } - hdr = bus_space_vaddr(sc->sc_iot, ioh); - if (strncmp(hdr->sig, "_SM3_", sizeof(hdr->sig)) != 0) - goto fail; - if (hdr->len != sizeof(*hdr) || hdr->epr != 0x01) - goto fail; - for (i = 0, p = (uint8_t *)hdr; i < hdr->len; i++) - checksum += p[i]; - if (checksum != 0) - goto fail; + hdr = bus_space_vaddr(sc->sc_iot, ioh); + if (hdr->len != sizeof(*hdr)) { + bus_space_unmap(sc->sc_iot, ioh, sizeof(*hdr)); + printf("\n"); + return; + } + for (i = 0, p = (uint8_t *)hdr; i < hdr->len; i++) + checksum += p[i]; + if (checksum != 0) { + bus_space_unmap(sc->sc_iot, ioh, sizeof(*hdr)); + printf("\n"); + return; + } - printf(": SMBIOS %d.%d.%d", hdr->majrev, hdr->minrev, hdr->docrev); + printf(": SMBIOS %d.%d", hdr->majrev, hdr->minrev); + + smbios_entry.len = hdr->size; + smbios_entry.mjr = hdr->majrev; + smbios_entry.min = hdr->minrev; + smbios_entry.count = hdr->count; + + addr = hdr->addr; + size = hdr->size; + bus_space_unmap(sc->sc_iot, ioh, sizeof(*hdr)); + } else if (strncmp(sig, "_SM3_", 5) == 0) { + struct smb3hdr *hdr; + uint8_t *p, checksum = 0; + int i; + + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, sizeof(*hdr), + BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, &ioh)) { + printf(": can't map SMBIOS entry point structure\n"); + return; + } - smbios_entry.len = hdr->size; - smbios_entry.mjr = hdr->majrev; - smbios_entry.min = hdr->minrev; - smbios_entry.count = -1; + hdr = bus_space_vaddr(sc->sc_iot, ioh); + if (hdr->len != sizeof(*hdr) || hdr->epr != 0x01) { + bus_space_unmap(sc->sc_iot, ioh, sizeof(*hdr)); + printf("\n"); + return; + } + for (i = 0, p = (uint8_t *)hdr; i < hdr->len; i++) + checksum += p[i]; + if (checksum != 0) { + bus_space_unmap(sc->sc_iot, ioh, sizeof(*hdr)); + printf("\n"); + return; + } - addr = hdr->addr; - size = hdr->size; + printf(": SMBIOS %d.%d.%d", hdr->majrev, hdr->minrev, + hdr->docrev); - bus_space_unmap(sc->sc_iot, ioh, sizeof(*hdr)); + smbios_entry.len = hdr->size; + smbios_entry.mjr = hdr->majrev; + smbios_entry.min = hdr->minrev; + smbios_entry.count = -1; + + addr = hdr->addr; + size = hdr->size; + bus_space_unmap(sc->sc_iot, ioh, sizeof(*hdr)); + } else { + printf(": unsupported SMBIOS entry point\n"); + return; + } if (bus_space_map(sc->sc_iot, addr, size, BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, &ioh)) { @@ -150,9 +204,6 @@ smbios_attach(struct device *parent, struct device *self, void *aux) printf("\n"); return; - -fail: - bus_space_unmap(sc->sc_iot, ioh, sizeof(*hdr)); } /* |