diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/bios.c | 66 | ||||
-rw-r--r-- | sys/arch/amd64/include/biosvar.h | 58 | ||||
-rw-r--r-- | sys/arch/amd64/include/smbiosvar.h | 220 | ||||
-rw-r--r-- | sys/arch/arm64/dev/smbios.c | 43 | ||||
-rw-r--r-- | sys/arch/arm64/include/smbiosvar.h | 222 | ||||
-rw-r--r-- | sys/arch/i386/i386/bios.c | 95 | ||||
-rw-r--r-- | sys/arch/i386/include/biosvar.h | 78 | ||||
-rw-r--r-- | sys/arch/i386/include/smbiosvar.h | 220 |
8 files changed, 516 insertions, 486 deletions
diff --git a/sys/arch/amd64/amd64/bios.c b/sys/arch/amd64/amd64/bios.c index 92a089e9c81..e0d0a951c29 100644 --- a/sys/arch/amd64/amd64/bios.c +++ b/sys/arch/amd64/amd64/bios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bios.c,v 1.39 2019/07/24 04:04:44 jsg Exp $ */ +/* $OpenBSD: bios.c,v 1.40 2019/08/04 14:28:58 kettenis Exp $ */ /* * Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca> * @@ -39,7 +39,7 @@ struct bios_softc { struct device sc_dev; }; -struct smbhdr *smbios_find(u_int8_t *); +struct smbhdr *smbios_find(uint8_t *); void smbios_info(char *); int bios_match(struct device *, void *, void *); void bios_attach(struct device *, struct device *, void *); @@ -89,19 +89,19 @@ bios_attach(struct device *parent, struct device *self, void *aux) char scratch[64]; vaddr_t va; paddr_t pa, end; - u_int8_t *p; + uint8_t *p; int smbiosrev = 0; struct smbhdr *hdr = NULL; char *sminfop; if (bios_efiinfo != NULL && bios_efiinfo->config_smbios != 0) hdr = smbios_find(PMAP_DIRECT_MAP( - (u_int8_t *)bios_efiinfo->config_smbios)); + (uint8_t *)bios_efiinfo->config_smbios)); if (hdr == NULL) { /* see if we have SMBIOS extentions */ for (p = ISA_HOLE_VADDR(SMBIOS_START); - p < (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END); p+= 16) { + p < (uint8_t *)ISA_HOLE_VADDR(SMBIOS_END); p+= 16) { hdr = smbios_find(p); if (hdr != NULL) break; @@ -115,7 +115,7 @@ bios_attach(struct device *parent, struct device *self, void *aux) if (va == 0) goto out; - smbios_entry.addr = (u_int8_t *)(va + (hdr->addr & PGOFSET)); + smbios_entry.addr = (uint8_t *)(va + (hdr->addr & PGOFSET)); smbios_entry.len = hdr->size; smbios_entry.mjr = hdr->majrev; smbios_entry.min = hdr->minrev; @@ -165,7 +165,7 @@ out: const char *signature = "Soekris Engineering"; for (p = ISA_HOLE_VADDR(SMBIOS_START); - p <= (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END - + p <= (uint8_t *)ISA_HOLE_VADDR(SMBIOS_END - (strlen(signature) - 1)); p++) if (!memcmp(p, signature, strlen(signature))) { hw_vendor = malloc(strlen(signature) + 1, @@ -178,7 +178,7 @@ out: } for (; hw_vendor && - p <= (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END - 6); p++) + p <= (uint8_t *)ISA_HOLE_VADDR(SMBIOS_END - 6); p++) /* * Search only for "net6501" in the comBIOS as that's * the only Soekris platform that can run amd64 @@ -224,10 +224,10 @@ out: } struct smbhdr * -smbios_find(u_int8_t *p) +smbios_find(uint8_t *p) { - struct smbhdr * hdr = (struct smbhdr *)p; - u_int8_t chksum; + struct smbhdr *hdr = (struct smbhdr *)p; + uint8_t chksum; int i; if (hdr->sig != SMBIOS_SIGNATURE) @@ -259,9 +259,9 @@ smbios_find(u_int8_t *p) * smbios_find_table with the same arguments. */ int -smbios_find_table(u_int8_t type, struct smbtable *st) +smbios_find_table(uint8_t type, struct smbtable *st) { - u_int8_t *va, *end; + uint8_t *va, *end; struct smbtblhdr *hdr; int ret = 0, tcount = 1; @@ -276,20 +276,20 @@ smbios_find_table(u_int8_t type, struct smbtable *st) * preceding that referenced by the handle is encoded in bits 15:31. */ if ((st->cookie & 0xfff) == type && st->cookie >> 16) { - if ((u_int8_t *)st->hdr >= va && (u_int8_t *)st->hdr < end) { + if ((uint8_t *)st->hdr >= va && (uint8_t *)st->hdr < end) { hdr = st->hdr; if (hdr->type == type) { - va = (u_int8_t *)hdr + hdr->size; + va = (uint8_t *)hdr + hdr->size; for (; va + 1 < end; va++) if (*va == 0 && *(va + 1) == 0) break; - va+= 2; + va += 2; tcount = st->cookie >> 16; } } } - for (; va + sizeof(struct smbtblhdr) < end && tcount <= - smbios_entry.count; tcount++) { + for (; va + sizeof(struct smbtblhdr) < end && + tcount <= smbios_entry.count; tcount++) { hdr = (struct smbtblhdr *)va; if (hdr->type == type) { ret = 1; @@ -300,23 +300,23 @@ smbios_find_table(u_int8_t type, struct smbtable *st) } if (hdr->type == SMBIOS_TYPE_EOT) break; - va+= hdr->size; + va += hdr->size; for (; va + 1 < end; va++) if (*va == 0 && *(va + 1) == 0) break; - va+=2; + va += 2; } return ret; } char * -smbios_get_string(struct smbtable *st, u_int8_t indx, char *dest, size_t len) +smbios_get_string(struct smbtable *st, uint8_t indx, char *dest, size_t len) { - u_int8_t *va, *end; + uint8_t *va, *end; char *ret = NULL; int i; - va = (u_int8_t *)st->hdr + st->hdr->size; + va = (uint8_t *)st->hdr + st->hdr->size; end = smbios_entry.addr + smbios_entry.len; for (i = 1; va < end && i < indx && *va; i++) while (*va++) @@ -325,7 +325,7 @@ smbios_get_string(struct smbtable *st, u_int8_t indx, char *dest, size_t len) if (va + len < end) { ret = dest; memcpy(ret, va, len); - ret[len-1] = '\0'; + ret[len - 1] = '\0'; } } @@ -340,7 +340,7 @@ fixstring(char *s) for (i = 0; i < nitems(smbios_uninfo); i++) if ((strncasecmp(s, smbios_uninfo[i], - strlen(smbios_uninfo[i])))==0) + strlen(smbios_uninfo[i]))) == 0) return NULL; /* * Remove leading and trailing whitespace @@ -363,7 +363,7 @@ fixstring(char *s) } void -smbios_info(char * str) +smbios_info(char *str) { char *sminfop, sminfo[64]; struct smbtable stbl, btbl; @@ -387,11 +387,12 @@ smbios_info(char * str) if (havebb) board = (struct smbios_board *)btbl.tblhdr; /* - * Some smbios implementations have no system vendor or product strings, - * some have very uninformative data which is harder to work around - * and we must rely upon various heuristics to detect this. In both - * cases we attempt to fall back on the base board information in the - * perhaps naive belief that motherboard vendors will supply this + * Some smbios implementations have no system vendor or + * product strings, some have very uninformative data which is + * harder to work around and we must rely upon various + * heuristics to detect this. In both cases we attempt to fall + * back on the base board information in the perhaps naive + * belief that motherboard vendors will supply this * information. */ sminfop = NULL; @@ -495,7 +496,6 @@ bios_print(void *aux, const char *pnp) struct bios_attach_args *ba = aux; if (pnp) - printf("%s at %s", - ba->ba_name, pnp); + printf("%s at %s", ba->ba_name, pnp); return (UNCONF); } diff --git a/sys/arch/amd64/include/biosvar.h b/sys/arch/amd64/include/biosvar.h index 14de16baf31..a78af133764 100644 --- a/sys/arch/amd64/include/biosvar.h +++ b/sys/arch/amd64/include/biosvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: biosvar.h,v 1.25 2018/02/06 01:09:17 patrick Exp $ */ +/* $OpenBSD: biosvar.h,v 1.26 2019/08/04 14:28:58 kettenis Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -41,7 +41,7 @@ #define BIOSF_BIOS32 0x0001 #define BIOSF_PCIBIOS 0x0002 #define BIOSF_PROMSCAN 0x0004 -#define BIOSF_SMBIOS 0x0006 +#define BIOSF_SMBIOS 0x0006 /* BIOS media ID */ #define BIOSM_F320K 0xff /* floppy ds/sd 8 spt */ @@ -69,11 +69,11 @@ */ typedef struct bios_romheader { - u_int16_t signature; /* 0xaa55 */ - u_int8_t len; /* length in pages (512 bytes) */ - u_int32_t entry; /* initialization entry point */ - u_int8_t reserved[19]; - u_int16_t pnpheader; /* offset to PnP expansion header */ + uint16_t signature; /* 0xaa55 */ + uint8_t len; /* length in pages (512 bytes) */ + uint32_t entry; /* initialization entry point */ + uint8_t reserved[19]; + uint16_t pnpheader; /* offset to PnP expansion header */ } __packed *bios_romheader_t; #define BIOS32_MAKESIG(a, b, c, d) \ @@ -97,9 +97,9 @@ struct bios_romheader { #define BOOTARG_MEMMAP 0 typedef struct _bios_memmap { - u_int64_t addr; /* Beginning of block */ - u_int64_t size; /* Size of block */ - u_int32_t type; /* Type of block */ + uint64_t addr; /* Beginning of block */ + uint64_t size; /* Size of block */ + uint32_t type; /* Type of block */ } __packed bios_memmap_t; /* Info about disk from the bios, plus the mapping from @@ -123,10 +123,10 @@ typedef struct _bios_diskinfo { dev_t bsd_dev; /* BSD device */ /* Checksum section */ - u_int32_t checksum; /* Checksum for drive */ + uint32_t checksum; /* Checksum for drive */ /* Misc. flags */ - u_int32_t flags; + uint32_t flags; #define BDI_INVALID 0x00000001 /* I/O error during checksumming */ #define BDI_GOODLABEL 0x00000002 /* Had SCSI or ST506/ESDI disklabel */ #define BDI_BADLABEL 0x00000004 /* Had another disklabel */ @@ -149,15 +149,15 @@ typedef struct _bios_apminfo { u_int apm_code16_len; } __packed bios_apminfo_t; -#define BOOTARG_CKSUMLEN 3 /* u_int32_t */ +#define BOOTARG_CKSUMLEN 3 /* uint32_t */ #define BOOTARG_PCIINFO 4 typedef struct _bios_pciinfo { /* PCI BIOS v2.0+ - Installation check values */ - u_int32_t pci_chars; /* Characteristics (%eax) */ - u_int32_t pci_rev; /* BCD Revision (%ebx) */ - u_int32_t pci_entry32; /* PM entry point for PCI BIOS */ - u_int32_t pci_lastbus; /* Number of last PCI bus */ + uint32_t pci_chars; /* Characteristics (%eax) */ + uint32_t pci_rev; /* BCD Revision (%ebx) */ + uint32_t pci_entry32; /* PM entry point for PCI BIOS */ + uint32_t pci_lastbus; /* Number of last PCI bus */ } __packed bios_pciinfo_t; #define BOOTARG_CONSDEV 5 @@ -187,8 +187,8 @@ typedef struct _bios_bootduid { #define BOOTSR_UUID_MAX 16 #define BOOTSR_CRYPTO_MAXKEYBYTES 32 typedef struct _bios_bootsr { - u_int8_t uuid[BOOTSR_UUID_MAX]; - u_int8_t maskkey[BOOTSR_CRYPTO_MAXKEYBYTES]; + uint8_t uuid[BOOTSR_UUID_MAX]; + uint8_t maskkey[BOOTSR_CRYPTO_MAXKEYBYTES]; } __packed bios_bootsr_t; #define BOOTARG_EFIINFO 11 @@ -220,15 +220,15 @@ typedef struct _bios_ucode { #define DOINT(n) "int $0x20+(" #n ")" extern volatile struct BIOS_regs { - u_int32_t biosr_ax; - u_int32_t biosr_cx; - u_int32_t biosr_dx; - u_int32_t biosr_bx; - u_int32_t biosr_bp; - u_int32_t biosr_si; - u_int32_t biosr_di; - u_int32_t biosr_ds; - u_int32_t biosr_es; + uint32_t biosr_ax; + uint32_t biosr_cx; + uint32_t biosr_dx; + uint32_t biosr_bx; + uint32_t biosr_bp; + uint32_t biosr_si; + uint32_t biosr_di; + uint32_t biosr_ds; + uint32_t biosr_es; } __packed BIOS_regs; #ifdef _KERNEL @@ -236,7 +236,7 @@ extern volatile struct BIOS_regs { struct bios_attach_args { char *ba_name; - u_int ba_biosfunc; + u_int ba_func; bus_space_tag_t ba_iot; bus_space_tag_t ba_memt; union { diff --git a/sys/arch/amd64/include/smbiosvar.h b/sys/arch/amd64/include/smbiosvar.h index 69662e5afe6..54655c1cdfe 100644 --- a/sys/arch/amd64/include/smbiosvar.h +++ b/sys/arch/amd64/include/smbiosvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smbiosvar.h,v 1.9 2011/08/18 16:01:24 marco Exp $ */ +/* $OpenBSD: smbiosvar.h,v 1.10 2019/08/04 14:28:58 kettenis Exp $ */ /* * Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca> * Copyright (c) 2005 Jordan Hargrave @@ -25,8 +25,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#ifndef _I386_SMBIOSVAR_ -#define _I386_SMBIOSVAR_ + +#ifndef _MACHINE_SMBIOSVAR_ +#define _MACHINE_SMBIOSVAR_ #define SMBIOS_START 0xf0000 #define SMBIOS_END 0xfffff @@ -43,40 +44,53 @@ #define SMBIOS_UUID_REPLEN 37 /* 16 zero padded values, 4 hyphens, 1 null */ struct smbios_entry { - u_int8_t mjr; - u_int8_t min; - u_int8_t *addr; - u_int16_t len; - u_int16_t count; + uint8_t mjr; + uint8_t min; + uint8_t *addr; + uint16_t len; + uint16_t count; }; struct smbhdr { - u_int32_t sig; /* "_SM_" */ - u_int8_t checksum; /* Entry point checksum */ - u_int8_t len; /* Entry point structure length */ - u_int8_t majrev; /* Specification major revision */ - u_int8_t minrev; /* Specification minor revision */ - u_int16_t mss; /* Maximum Structure Size */ - u_int8_t epr; /* Entry Point Revision */ - u_int8_t fa[5]; /* value determined by EPR */ - u_int8_t sasig[5]; /* Secondary Anchor "_DMI_" */ - u_int8_t sachecksum; /* Secondary Checksum */ - u_int16_t size; /* Length of structure table in bytes */ - u_int32_t addr; /* Structure table address */ - u_int16_t count; /* Number of SMBIOS structures */ - u_int8_t rev; /* BCD revision */ + uint32_t sig; /* "_SM_" */ + uint8_t checksum; /* Entry point checksum */ + uint8_t len; /* Entry point structure length */ + uint8_t majrev; /* Specification major revision */ + uint8_t minrev; /* Specification minor revision */ + uint16_t mss; /* Maximum Structure Size */ + uint8_t epr; /* Entry Point Revision */ + uint8_t fa[5]; /* value determined by EPR */ + uint8_t sasig[5]; /* Secondary Anchor "_DMI_" */ + uint8_t sachecksum; /* Secondary Checksum */ + uint16_t size; /* Length of structure table in bytes */ + uint32_t addr; /* Structure table address */ + uint16_t count; /* Number of SMBIOS structures */ + uint8_t rev; /* BCD revision */ +} __packed; + +struct smb3hdr { + uint8_t sig[5]; /* "_SM3_" */ + uint8_t checksum; /* Entry point structure checksum */ + uint8_t len; /* Entry point length */ + uint8_t majrev; /* SMBIOS major version */ + uint8_t minrev; /* SMBIOS minor version */ + uint8_t docrev; /* SMBIOS docrev */ + uint8_t epr; /* Entry point revision */ + uint8_t reserved; /* Reserved */ + uint32_t size; /* Structure table maximum size */ + uint64_t addr; /* Structure table address */ } __packed; struct smbtblhdr { - u_int8_t type; - u_int8_t size; - u_int16_t handle; + uint8_t type; + uint8_t size; + uint16_t handle; } __packed; struct smbtable { struct smbtblhdr *hdr; void *tblhdr; - u_int32_t cookie; + uint32_t cookie; }; #define SMBIOS_TYPE_BIOS 0 @@ -127,17 +141,17 @@ struct smbtable { * DMTF Specification DSP0134 Section: 3.3.1 p.g. 34 */ struct smbios_struct_bios { - u_int8_t vendor; /* string */ - u_int8_t version; /* string */ - u_int16_t startaddr; - u_int8_t release; /* string */ - u_int8_t romsize; - u_int64_t characteristics; - u_int32_t charext; - u_int8_t major_rel; - u_int8_t minor_rel; - u_int8_t ecf_mjr_rel; /* embedded controler firmware */ - u_int8_t ecf_min_rel; /* embedded controler firmware */ + uint8_t vendor; /* string */ + uint8_t version; /* string */ + uint16_t startaddr; + uint8_t release; /* string */ + uint8_t romsize; + uint64_t characteristics; + uint32_t charext; + uint8_t major_rel; + uint8_t minor_rel; + uint8_t ecf_mjr_rel; /* embedded controler firmware */ + uint8_t ecf_min_rel; /* embedded controler firmware */ } __packed; /* @@ -147,16 +161,16 @@ struct smbios_struct_bios { struct smbios_sys { /* SMBIOS spec 2.0+ */ - u_int8_t vendor; /* string */ - u_int8_t product; /* string */ - u_int8_t version; /* string */ - u_int8_t serial; /* string */ + uint8_t vendor; /* string */ + uint8_t product; /* string */ + uint8_t version; /* string */ + uint8_t serial; /* string */ /* SMBIOS spec 2.1+ */ - u_int8_t uuid[16]; - u_int8_t wakeup; + uint8_t uuid[16]; + uint8_t wakeup; /* SMBIOS spec 2.4+ */ - u_int8_t sku; /* string */ - u_int8_t family; /* string */ + uint8_t sku; /* string */ + uint8_t family; /* string */ } __packed; /* @@ -164,16 +178,16 @@ struct smbios_sys { * DMTF Specification DSP0134 Section 3.3.3 p.g. 37 */ struct smbios_board { - u_int8_t vendor; /* string */ - u_int8_t product; /* string */ - u_int8_t version; /* string */ - u_int8_t serial; /* string */ - u_int8_t asset; /* stirng */ - u_int8_t feature; /* feature flags */ - u_int8_t location; /* location in chassis */ - u_int16_t handle; /* chassis handle */ - u_int8_t type; /* board type */ - u_int8_t noc; /* number of contained objects */ + uint8_t vendor; /* string */ + uint8_t product; /* string */ + uint8_t version; /* string */ + uint8_t serial; /* string */ + uint8_t asset; /* stirng */ + uint8_t feature; /* feature flags */ + uint8_t location; /* location in chassis */ + uint16_t handle; /* chassis handle */ + uint8_t type; /* board type */ + uint8_t noc; /* number of contained objects */ } __packed; /* @@ -182,25 +196,25 @@ struct smbios_board { */ struct smbios_enclosure { /* SMBIOS spec 2.0+ */ - u_int8_t vendor; /* string */ - u_int8_t type; - u_int8_t version; /* string */ - u_int8_t serial; /* string */ - u_int8_t asset_tag; /* string */ + uint8_t vendor; /* string */ + uint8_t type; + uint8_t version; /* string */ + uint8_t serial; /* string */ + uint8_t asset_tag; /* string */ /* SMBIOS spec 2.1+ */ - u_int8_t boot_state; - u_int8_t psu_state; - u_int8_t thermal_state; - u_int8_t security_status; + uint8_t boot_state; + uint8_t psu_state; + uint8_t thermal_state; + uint8_t security_status; /* SMBIOS spec 2.3+ */ - u_int16_t oem_defined; - u_int8_t height; - u_int8_t no_power_cords; - u_int8_t no_contained_element; - u_int8_t reclen_contained_element; - u_int8_t contained_elements; + uint16_t oem_defined; + uint8_t height; + uint8_t no_power_cords; + uint8_t no_contained_element; + uint8_t reclen_contained_element; + uint8_t contained_elements; /* SMBIOS spec 2.7+ */ - u_int8_t sku; /* string */ + uint8_t sku; /* string */ } __packed; /* @@ -208,32 +222,32 @@ struct smbios_enclosure { * DMTF Specification DSP0134 v2.5 Section 3.3.5 p.g. 24 */ struct smbios_cpu { - u_int8_t cpu_socket_designation; /* string */ - u_int8_t cpu_type; - u_int8_t cpu_family; - u_int8_t cpu_mfg; /* string */ - u_int32_t cpu_id_eax; - u_int32_t cpu_id_edx; - u_int8_t cpu_version; /* string */ - u_int8_t cpu_voltage; - u_int16_t cpu_clock; - u_int16_t cpu_max_speed; - u_int16_t cpu_current_speed; - u_int8_t cpu_status; + uint8_t cpu_socket_designation; /* string */ + uint8_t cpu_type; + uint8_t cpu_family; + uint8_t cpu_mfg; /* string */ + uint32_t cpu_id_eax; + uint32_t cpu_id_edx; + uint8_t cpu_version; /* string */ + uint8_t cpu_voltage; + uint16_t cpu_clock; + uint16_t cpu_max_speed; + uint16_t cpu_current_speed; + uint8_t cpu_status; #define SMBIOS_CPUST_POPULATED (1<<6) #define SMBIOS_CPUST_STATUSMASK (0x07) - u_int8_t cpu_upgrade; - u_int16_t cpu_l1_handle; - u_int16_t cpu_l2_handle; - u_int16_t cpu_l3_handle; - u_int8_t cpu_serial; /* string */ - u_int8_t cpu_asset_tag; /* string */ - u_int8_t cpu_part_nr; /* string */ + uint8_t cpu_upgrade; + uint16_t cpu_l1_handle; + uint16_t cpu_l2_handle; + uint16_t cpu_l3_handle; + uint8_t cpu_serial; /* string */ + uint8_t cpu_asset_tag; /* string */ + uint8_t cpu_part_nr; /* string */ /* following fields were added in smbios 2.5 */ - u_int8_t cpu_core_count; - u_int8_t cpu_core_enabled; - u_int8_t cpu_thread_count; - u_int16_t cpu_characteristics; + uint8_t cpu_core_count; + uint8_t cpu_core_enabled; + uint8_t cpu_thread_count; + uint16_t cpu_characteristics; } __packed; /* @@ -241,14 +255,14 @@ struct smbios_cpu { * DMTF Specification DSP0134 Section 3.3.39 p.g. 91 */ struct smbios_ipmi { - u_int8_t smipmi_if_type; /* IPMI Interface Type */ - u_int8_t smipmi_if_rev; /* BCD IPMI Revision */ - u_int8_t smipmi_i2c_address; /* I2C address of BMC */ - u_int8_t smipmi_nvram_address; /* I2C address of NVRAM + uint8_t smipmi_if_type; /* IPMI Interface Type */ + uint8_t smipmi_if_rev; /* BCD IPMI Revision */ + uint8_t smipmi_i2c_address; /* I2C address of BMC */ + uint8_t smipmi_nvram_address; /* I2C address of NVRAM * storage */ - u_int64_t smipmi_base_address; /* Base address of BMC (BAR + uint64_t smipmi_base_address; /* Base address of BMC (BAR * format */ - u_int8_t smipmi_base_flags; /* Flags field: + uint8_t smipmi_base_flags; /* Flags field: * bit 7:6 : register spacing * 00 = byte * 01 = dword @@ -258,10 +272,10 @@ struct smbios_ipmi { * bit 2 : N/A * bit 1 : Interrupt polarity * bit 0 : Interrupt trigger */ - u_int8_t smipmi_irq; /* IRQ if applicable */ + uint8_t smipmi_irq; /* IRQ if applicable */ } __packed; -int smbios_find_table(u_int8_t, struct smbtable *); -char *smbios_get_string(struct smbtable *, u_int8_t, char *, size_t); +int smbios_find_table(uint8_t, struct smbtable *); +char *smbios_get_string(struct smbtable *, uint8_t, char *, size_t); #endif diff --git a/sys/arch/arm64/dev/smbios.c b/sys/arch/arm64/dev/smbios.c index 911e056bb86..d9e9d906a63 100644 --- a/sys/arch/arm64/dev/smbios.c +++ b/sys/arch/arm64/dev/smbios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smbios.c,v 1.2 2019/08/04 10:00:37 kettenis Exp $ */ +/* $OpenBSD: smbios.c,v 1.3 2019/08/04 14:28:58 kettenis Exp $ */ /* * Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca> * Copyright (c) 2019 Mark Kettenis <kettenis@openbsd.org> @@ -167,9 +167,9 @@ fail: * smbios_find_table with the same arguments. */ int -smbios_find_table(u_int8_t type, struct smbtable *st) +smbios_find_table(uint8_t type, struct smbtable *st) { - u_int8_t *va, *end; + uint8_t *va, *end; struct smbtblhdr *hdr; int ret = 0, tcount = 1; @@ -184,20 +184,20 @@ smbios_find_table(u_int8_t type, struct smbtable *st) * preceding that referenced by the handle is encoded in bits 15:31. */ if ((st->cookie & 0xfff) == type && st->cookie >> 16) { - if ((u_int8_t *)st->hdr >= va && (u_int8_t *)st->hdr < end) { + if ((uint8_t *)st->hdr >= va && (uint8_t *)st->hdr < end) { hdr = st->hdr; if (hdr->type == type) { - va = (u_int8_t *)hdr + hdr->size; + va = (uint8_t *)hdr + hdr->size; for (; va + 1 < end; va++) if (*va == 0 && *(va + 1) == 0) break; - va+= 2; + va += 2; tcount = st->cookie >> 16; } } } - for (; va + sizeof(struct smbtblhdr) < end && tcount <= - smbios_entry.count; tcount++) { + for (; va + sizeof(struct smbtblhdr) < end && + tcount <= smbios_entry.count; tcount++) { hdr = (struct smbtblhdr *)va; if (hdr->type == type) { ret = 1; @@ -208,23 +208,23 @@ smbios_find_table(u_int8_t type, struct smbtable *st) } if (hdr->type == SMBIOS_TYPE_EOT) break; - va+= hdr->size; + va += hdr->size; for (; va + 1 < end; va++) if (*va == 0 && *(va + 1) == 0) break; - va+=2; + va += 2; } return ret; } char * -smbios_get_string(struct smbtable *st, u_int8_t indx, char *dest, size_t len) +smbios_get_string(struct smbtable *st, uint8_t indx, char *dest, size_t len) { - u_int8_t *va, *end; + uint8_t *va, *end; char *ret = NULL; int i; - va = (u_int8_t *)st->hdr + st->hdr->size; + va = (uint8_t *)st->hdr + st->hdr->size; end = smbios_entry.addr + smbios_entry.len; for (i = 1; va < end && i < indx && *va; i++) while (*va++) @@ -233,7 +233,7 @@ smbios_get_string(struct smbtable *st, u_int8_t indx, char *dest, size_t len) if (va + len < end) { ret = dest; memcpy(ret, va, len); - ret[len-1] = '\0'; + ret[len - 1] = '\0'; } } @@ -248,7 +248,7 @@ fixstring(char *s) for (i = 0; i < nitems(smbios_uninfo); i++) if ((strncasecmp(s, smbios_uninfo[i], - strlen(smbios_uninfo[i])))==0) + strlen(smbios_uninfo[i]))) == 0) return NULL; /* * Remove leading and trailing whitespace @@ -271,7 +271,7 @@ fixstring(char *s) } void -smbios_info(char * str) +smbios_info(char *str) { char *sminfop, sminfo[64]; struct smbtable stbl, btbl; @@ -295,11 +295,12 @@ smbios_info(char * str) if (havebb) board = (struct smbios_board *)btbl.tblhdr; /* - * Some smbios implementations have no system vendor or product strings, - * some have very uninformative data which is harder to work around - * and we must rely upon various heuristics to detect this. In both - * cases we attempt to fall back on the base board information in the - * perhaps naive belief that motherboard vendors will supply this + * Some smbios implementations have no system vendor or + * product strings, some have very uninformative data which is + * harder to work around and we must rely upon various + * heuristics to detect this. In both cases we attempt to fall + * back on the base board information in the perhaps naive + * belief that motherboard vendors will supply this * information. */ sminfop = NULL; diff --git a/sys/arch/arm64/include/smbiosvar.h b/sys/arch/arm64/include/smbiosvar.h index 8e4b59e3fea..bb55285509c 100644 --- a/sys/arch/arm64/include/smbiosvar.h +++ b/sys/arch/arm64/include/smbiosvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smbiosvar.h,v 1.1 2019/08/04 09:27:09 kettenis Exp $ */ +/* $OpenBSD: smbiosvar.h,v 1.2 2019/08/04 14:28:58 kettenis Exp $ */ /* * Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca> * Copyright (c) 2005 Jordan Hargrave @@ -41,53 +41,53 @@ #define SMBIOS_UUID_REPLEN 37 /* 16 zero padded values, 4 hyphens, 1 null */ struct smbios_entry { - u_int8_t mjr; - u_int8_t min; - u_int8_t *addr; - u_int16_t len; - u_int16_t count; + uint8_t mjr; + uint8_t min; + uint8_t *addr; + uint16_t len; + uint16_t count; }; struct smbhdr { - u_int32_t sig; /* "_SM_" */ - u_int8_t checksum; /* Entry point checksum */ - u_int8_t len; /* Entry point structure length */ - u_int8_t majrev; /* Specification major revision */ - u_int8_t minrev; /* Specification minor revision */ - u_int16_t mss; /* Maximum Structure Size */ - u_int8_t epr; /* Entry Point Revision */ - u_int8_t fa[5]; /* value determined by EPR */ - u_int8_t sasig[5]; /* Secondary Anchor "_DMI_" */ - u_int8_t sachecksum; /* Secondary Checksum */ - u_int16_t size; /* Length of structure table in bytes */ - u_int32_t addr; /* Structure table address */ - u_int16_t count; /* Number of SMBIOS structures */ - u_int8_t rev; /* BCD revision */ + uint32_t sig; /* "_SM_" */ + uint8_t checksum; /* Entry point checksum */ + uint8_t len; /* Entry point structure length */ + uint8_t majrev; /* Specification major revision */ + uint8_t minrev; /* Specification minor revision */ + uint16_t mss; /* Maximum Structure Size */ + uint8_t epr; /* Entry Point Revision */ + uint8_t fa[5]; /* value determined by EPR */ + uint8_t sasig[5]; /* Secondary Anchor "_DMI_" */ + uint8_t sachecksum; /* Secondary Checksum */ + uint16_t size; /* Length of structure table in bytes */ + uint32_t addr; /* Structure table address */ + uint16_t count; /* Number of SMBIOS structures */ + uint8_t rev; /* BCD revision */ } __packed; struct smb3hdr { - u_int8_t sig[5]; /* "_SM3_" */ - u_int8_t checksum; /* Entry point structure checksum */ - u_int8_t len; /* Entry point length */ - u_int8_t majrev; /* SMBIOS major version */ - u_int8_t minrev; /* SMBIOS minor version */ - u_int8_t docrev; /* SMBIOS docrev */ - u_int8_t epr; /* Entry point revision */ - u_int8_t reserved; /* Reserved */ - u_int32_t size; /* Structure table maximum size */ - u_int64_t addr; /* Structure table address */ + uint8_t sig[5]; /* "_SM3_" */ + uint8_t checksum; /* Entry point structure checksum */ + uint8_t len; /* Entry point length */ + uint8_t majrev; /* SMBIOS major version */ + uint8_t minrev; /* SMBIOS minor version */ + uint8_t docrev; /* SMBIOS docrev */ + uint8_t epr; /* Entry point revision */ + uint8_t reserved; /* Reserved */ + uint32_t size; /* Structure table maximum size */ + uint64_t addr; /* Structure table address */ } __packed; struct smbtblhdr { - u_int8_t type; - u_int8_t size; - u_int16_t handle; + uint8_t type; + uint8_t size; + uint16_t handle; } __packed; struct smbtable { struct smbtblhdr *hdr; void *tblhdr; - u_int32_t cookie; + uint32_t cookie; }; #define SMBIOS_TYPE_BIOS 0 @@ -138,17 +138,17 @@ struct smbtable { * DMTF Specification DSP0134 Section: 3.3.1 p.g. 34 */ struct smbios_struct_bios { - u_int8_t vendor; /* string */ - u_int8_t version; /* string */ - u_int16_t startaddr; - u_int8_t release; /* string */ - u_int8_t romsize; - u_int64_t characteristics; - u_int32_t charext; - u_int8_t major_rel; - u_int8_t minor_rel; - u_int8_t ecf_mjr_rel; /* embedded controler firmware */ - u_int8_t ecf_min_rel; /* embedded controler firmware */ + uint8_t vendor; /* string */ + uint8_t version; /* string */ + uint16_t startaddr; + uint8_t release; /* string */ + uint8_t romsize; + uint64_t characteristics; + uint32_t charext; + uint8_t major_rel; + uint8_t minor_rel; + uint8_t ecf_mjr_rel; /* embedded controler firmware */ + uint8_t ecf_min_rel; /* embedded controler firmware */ } __packed; /* @@ -158,16 +158,16 @@ struct smbios_struct_bios { struct smbios_sys { /* SMBIOS spec 2.0+ */ - u_int8_t vendor; /* string */ - u_int8_t product; /* string */ - u_int8_t version; /* string */ - u_int8_t serial; /* string */ + uint8_t vendor; /* string */ + uint8_t product; /* string */ + uint8_t version; /* string */ + uint8_t serial; /* string */ /* SMBIOS spec 2.1+ */ - u_int8_t uuid[16]; - u_int8_t wakeup; + uint8_t uuid[16]; + uint8_t wakeup; /* SMBIOS spec 2.4+ */ - u_int8_t sku; /* string */ - u_int8_t family; /* string */ + uint8_t sku; /* string */ + uint8_t family; /* string */ } __packed; /* @@ -175,16 +175,16 @@ struct smbios_sys { * DMTF Specification DSP0134 Section 3.3.3 p.g. 37 */ struct smbios_board { - u_int8_t vendor; /* string */ - u_int8_t product; /* string */ - u_int8_t version; /* string */ - u_int8_t serial; /* string */ - u_int8_t asset; /* stirng */ - u_int8_t feature; /* feature flags */ - u_int8_t location; /* location in chassis */ - u_int16_t handle; /* chassis handle */ - u_int8_t type; /* board type */ - u_int8_t noc; /* number of contained objects */ + uint8_t vendor; /* string */ + uint8_t product; /* string */ + uint8_t version; /* string */ + uint8_t serial; /* string */ + uint8_t asset; /* stirng */ + uint8_t feature; /* feature flags */ + uint8_t location; /* location in chassis */ + uint16_t handle; /* chassis handle */ + uint8_t type; /* board type */ + uint8_t noc; /* number of contained objects */ } __packed; /* @@ -193,25 +193,25 @@ struct smbios_board { */ struct smbios_enclosure { /* SMBIOS spec 2.0+ */ - u_int8_t vendor; /* string */ - u_int8_t type; - u_int8_t version; /* string */ - u_int8_t serial; /* string */ - u_int8_t asset_tag; /* string */ + uint8_t vendor; /* string */ + uint8_t type; + uint8_t version; /* string */ + uint8_t serial; /* string */ + uint8_t asset_tag; /* string */ /* SMBIOS spec 2.1+ */ - u_int8_t boot_state; - u_int8_t psu_state; - u_int8_t thermal_state; - u_int8_t security_status; + uint8_t boot_state; + uint8_t psu_state; + uint8_t thermal_state; + uint8_t security_status; /* SMBIOS spec 2.3+ */ - u_int16_t oem_defined; - u_int8_t height; - u_int8_t no_power_cords; - u_int8_t no_contained_element; - u_int8_t reclen_contained_element; - u_int8_t contained_elements; + uint16_t oem_defined; + uint8_t height; + uint8_t no_power_cords; + uint8_t no_contained_element; + uint8_t reclen_contained_element; + uint8_t contained_elements; /* SMBIOS spec 2.7+ */ - u_int8_t sku; /* string */ + uint8_t sku; /* string */ } __packed; /* @@ -219,32 +219,32 @@ struct smbios_enclosure { * DMTF Specification DSP0134 v2.5 Section 3.3.5 p.g. 24 */ struct smbios_cpu { - u_int8_t cpu_socket_designation; /* string */ - u_int8_t cpu_type; - u_int8_t cpu_family; - u_int8_t cpu_mfg; /* string */ - u_int32_t cpu_id_eax; - u_int32_t cpu_id_edx; - u_int8_t cpu_version; /* string */ - u_int8_t cpu_voltage; - u_int16_t cpu_clock; - u_int16_t cpu_max_speed; - u_int16_t cpu_current_speed; - u_int8_t cpu_status; + uint8_t cpu_socket_designation; /* string */ + uint8_t cpu_type; + uint8_t cpu_family; + uint8_t cpu_mfg; /* string */ + uint32_t cpu_id_eax; + uint32_t cpu_id_edx; + uint8_t cpu_version; /* string */ + uint8_t cpu_voltage; + uint16_t cpu_clock; + uint16_t cpu_max_speed; + uint16_t cpu_current_speed; + uint8_t cpu_status; #define SMBIOS_CPUST_POPULATED (1<<6) #define SMBIOS_CPUST_STATUSMASK (0x07) - u_int8_t cpu_upgrade; - u_int16_t cpu_l1_handle; - u_int16_t cpu_l2_handle; - u_int16_t cpu_l3_handle; - u_int8_t cpu_serial; /* string */ - u_int8_t cpu_asset_tag; /* string */ - u_int8_t cpu_part_nr; /* string */ + uint8_t cpu_upgrade; + uint16_t cpu_l1_handle; + uint16_t cpu_l2_handle; + uint16_t cpu_l3_handle; + uint8_t cpu_serial; /* string */ + uint8_t cpu_asset_tag; /* string */ + uint8_t cpu_part_nr; /* string */ /* following fields were added in smbios 2.5 */ - u_int8_t cpu_core_count; - u_int8_t cpu_core_enabled; - u_int8_t cpu_thread_count; - u_int16_t cpu_characteristics; + uint8_t cpu_core_count; + uint8_t cpu_core_enabled; + uint8_t cpu_thread_count; + uint16_t cpu_characteristics; } __packed; /* @@ -252,14 +252,14 @@ struct smbios_cpu { * DMTF Specification DSP0134 Section 3.3.39 p.g. 91 */ struct smbios_ipmi { - u_int8_t smipmi_if_type; /* IPMI Interface Type */ - u_int8_t smipmi_if_rev; /* BCD IPMI Revision */ - u_int8_t smipmi_i2c_address; /* I2C address of BMC */ - u_int8_t smipmi_nvram_address; /* I2C address of NVRAM + uint8_t smipmi_if_type; /* IPMI Interface Type */ + uint8_t smipmi_if_rev; /* BCD IPMI Revision */ + uint8_t smipmi_i2c_address; /* I2C address of BMC */ + uint8_t smipmi_nvram_address; /* I2C address of NVRAM * storage */ - u_int64_t smipmi_base_address; /* Base address of BMC (BAR + uint64_t smipmi_base_address; /* Base address of BMC (BAR * format */ - u_int8_t smipmi_base_flags; /* Flags field: + uint8_t smipmi_base_flags; /* Flags field: * bit 7:6 : register spacing * 00 = byte * 01 = dword @@ -269,10 +269,10 @@ struct smbios_ipmi { * bit 2 : N/A * bit 1 : Interrupt polarity * bit 0 : Interrupt trigger */ - u_int8_t smipmi_irq; /* IRQ if applicable */ + uint8_t smipmi_irq; /* IRQ if applicable */ } __packed; -int smbios_find_table(u_int8_t, struct smbtable *); -char *smbios_get_string(struct smbtable *, u_int8_t, char *, size_t); +int smbios_find_table(uint8_t, struct smbtable *); +char *smbios_get_string(struct smbtable *, uint8_t, char *, size_t); #endif diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c index bf396390131..13980f7c21c 100644 --- a/sys/arch/i386/i386/bios.c +++ b/sys/arch/i386/i386/bios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bios.c,v 1.122 2019/07/24 04:04:44 jsg Exp $ */ +/* $OpenBSD: bios.c,v 1.123 2019/08/04 14:28:58 kettenis Exp $ */ /* * Copyright (c) 1997-2001 Michael Shalayeff @@ -112,7 +112,7 @@ bios_pciinfo_t *bios_pciinfo; bios_diskinfo_t *bios_diskinfo; bios_memmap_t *bios_memmap; struct bios_softc *bios_softc; -u_int32_t bios_cksumlen; +uint32_t bios_cksumlen; struct bios32_entry bios32_entry; struct smbios_entry smbios_entry; #ifdef MULTIPROCESSOR @@ -171,7 +171,7 @@ biosattach(struct device *parent, struct device *self, void *aux) #endif struct smbios_struct_bios *sb; struct smbtable bios; - volatile u_int8_t *va; + volatile uint8_t *va; char scratch[64], *str; int flags, smbiosrev = 0, ncpu = 0, isa_hole_exec = 0; #if NACPI > 0 || NAPM > 0 @@ -216,9 +216,9 @@ biosattach(struct device *parent, struct device *self, void *aux) if (!(flags & BIOSF_BIOS32)) { for (va = ISA_HOLE_VADDR(BIOS32_START); - va < (u_int8_t *)ISA_HOLE_VADDR(BIOS32_END); va += 16) { + va < (uint8_t *)ISA_HOLE_VADDR(BIOS32_END); va += 16) { bios32_header_t h = (bios32_header_t)va; - u_int8_t cksum; + uint8_t cksum; int i; if (h->signature != BIOS32_SIGNATURE) @@ -234,7 +234,7 @@ biosattach(struct device *parent, struct device *self, void *aux) continue; bios32_entry.segment = GSEL(GCODE_SEL, SEL_KPL); - bios32_entry.offset = (u_int32_t)ISA_HOLE_VADDR(h->entry); + bios32_entry.offset = (uint32_t)ISA_HOLE_VADDR(h->entry); printf(", BIOS32 rev. %d @ 0x%x", h->rev, h->entry); break; } @@ -243,10 +243,10 @@ biosattach(struct device *parent, struct device *self, void *aux) /* see if we have SMBIOS extensions */ if (!(flags & BIOSF_SMBIOS)) { for (va = ISA_HOLE_VADDR(SMBIOS_START); - va < (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END); va+= 16) { + va < (uint8_t *)ISA_HOLE_VADDR(SMBIOS_END); va+= 16) { struct smbhdr *sh = (struct smbhdr *)va; char *sminfop; - u_int8_t chksum; + uint8_t chksum; vaddr_t eva; paddr_t pa, end; int i; @@ -274,7 +274,7 @@ biosattach(struct device *parent, struct device *self, void *aux) if (eva == 0) break; - smbios_entry.addr = (u_int8_t *)(eva + + smbios_entry.addr = (uint8_t *)(eva + (sh->addr & PGOFSET)); smbios_entry.len = sh->size; smbios_entry.mjr = sh->majrev; @@ -348,9 +348,9 @@ biosattach(struct device *parent, struct device *self, void *aux) const char *signature = "Soekris Engineering"; for (va = ISA_HOLE_VADDR(SMBIOS_START); - va <= (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END - + va <= (uint8_t *)ISA_HOLE_VADDR(SMBIOS_END - (strlen(signature) - 1)); va++) - if (!memcmp((u_int8_t *)va, signature, + if (!memcmp((uint8_t *)va, signature, strlen(signature))) { hw_vendor = malloc(strlen(signature) + 1, M_DEVBUF, M_NOWAIT); @@ -362,18 +362,18 @@ biosattach(struct device *parent, struct device *self, void *aux) } for (; hw_vendor && - va <= (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END - 6); va++) + va <= (uint8_t *)ISA_HOLE_VADDR(SMBIOS_END - 6); va++) /* * Search for "net(4(5xx|801)|[56]501)" which matches * the strings found in the comBIOS images */ - if (!memcmp((u_int8_t *)va, "net45xx", 7) || - !memcmp((u_int8_t *)va, "net4801", 7) || - !memcmp((u_int8_t *)va, "net5501", 7) || - !memcmp((u_int8_t *)va, "net6501", 7)) { + if (!memcmp((uint8_t *)va, "net45xx", 7) || + !memcmp((uint8_t *)va, "net4801", 7) || + !memcmp((uint8_t *)va, "net5501", 7) || + !memcmp((uint8_t *)va, "net6501", 7)) { hw_prod = malloc(8, M_DEVBUF, M_NOWAIT); if (hw_prod) { - memcpy(hw_prod, (u_int8_t *)va, 7); + memcpy(hw_prod, (uint8_t *)va, 7); hw_prod[7] = '\0'; } break; @@ -451,15 +451,15 @@ biosattach(struct device *parent, struct device *self, void *aux) * scan and map all the proms we can find */ if (!(flags & BIOSF_PROMSCAN)) { - volatile u_int8_t *eva; + volatile uint8_t *eva; for (str = NULL, va = ISA_HOLE_VADDR(0xc0000), eva = ISA_HOLE_VADDR(0xf0000); va < eva; va += 512) { extern struct extent *iomem_ex; bios_romheader_t romh = (bios_romheader_t)va; - u_int32_t off, len; - u_int8_t cksum; + uint32_t off, len; + uint8_t cksum; int i; if (romh->signature != 0xaa55) @@ -478,7 +478,7 @@ biosattach(struct device *parent, struct device *self, void *aux) for (cksum = 0, i = len; i--; cksum += va[i]) ; - off = 0xc0000 + (va - (u_int8_t *) + off = 0xc0000 + (va - (uint8_t *) ISA_HOLE_VADDR(0xc0000)); if (!str) @@ -543,7 +543,7 @@ bios_getopt(void) break; #endif case BOOTARG_CKSUMLEN: - bios_cksumlen = *(u_int32_t *)q->ba_arg; + bios_cksumlen = *(uint32_t *)q->ba_arg; #ifdef BIOS_DEBUG printf(" cksumlen %d", bios_cksumlen); #endif @@ -648,11 +648,11 @@ bios_print(void *aux, const char *pnp) } int -bios32_service(u_int32_t service, bios32_entry_t e, bios32_entry_info_t ei) +bios32_service(uint32_t service, bios32_entry_t e, bios32_entry_info_t ei) { u_long pa, endpa; vaddr_t va, sva; - u_int32_t base, count, off, ent; + uint32_t base, count, off, ent; if (bios32_entry.offset == 0) return 0; @@ -837,9 +837,9 @@ bios_getdiskinfo(dev_t dev) * smbios_find_table with the same arguments. */ int -smbios_find_table(u_int8_t type, struct smbtable *st) +smbios_find_table(uint8_t type, struct smbtable *st) { - u_int8_t *va, *end; + uint8_t *va, *end; struct smbtblhdr *hdr; int ret = 0, tcount = 1; @@ -854,20 +854,20 @@ smbios_find_table(u_int8_t type, struct smbtable *st) * preceding that referenced by the handle is encoded in bits 15:31. */ if ((st->cookie & 0xfff) == type && st->cookie >> 16) { - if ((u_int8_t *)st->hdr >= va && (u_int8_t *)st->hdr < end) { + if ((uint8_t *)st->hdr >= va && (uint8_t *)st->hdr < end) { hdr = st->hdr; if (hdr->type == type) { - va = (u_int8_t *)hdr + hdr->size; + va = (uint8_t *)hdr + hdr->size; for (; va + 1 < end; va++) if (*va == 0 && *(va + 1) == 0) break; - va+= 2; + va += 2; tcount = st->cookie >> 16; } } } - for (; va + sizeof(struct smbtblhdr) < end && tcount <= - smbios_entry.count; tcount++) { + for (; va + sizeof(struct smbtblhdr) < end && + tcount <= smbios_entry.count; tcount++) { hdr = (struct smbtblhdr *)va; if (hdr->type == type) { ret = 1; @@ -878,24 +878,23 @@ smbios_find_table(u_int8_t type, struct smbtable *st) } if (hdr->type == SMBIOS_TYPE_EOT) break; - va+= hdr->size; + va += hdr->size; for (; va + 1 < end; va++) if (*va == 0 && *(va + 1) == 0) break; - va+=2; + va += 2; } - return ret; } char * -smbios_get_string(struct smbtable *st, u_int8_t indx, char *dest, size_t len) +smbios_get_string(struct smbtable *st, uint8_t indx, char *dest, size_t len) { - u_int8_t *va, *end; + uint8_t *va, *end; char *ret = NULL; int i; - va = (u_int8_t *)st->hdr + st->hdr->size; + va = (uint8_t *)st->hdr + st->hdr->size; end = smbios_entry.addr + smbios_entry.len; for (i = 1; va < end && i < indx && *va; i++) while (*va++) @@ -903,7 +902,7 @@ smbios_get_string(struct smbtable *st, u_int8_t indx, char *dest, size_t len) if (i == indx) { if (va + len < end) { ret = dest; - bcopy(va, ret, len); + memcpy(ret, va, len); ret[len - 1] = '\0'; } } @@ -917,8 +916,9 @@ fixstring(char *s) char *p, *e; int i; - for (i= 0; i < sizeof(smbios_uninfo)/sizeof(smbios_uninfo[0]); i++) - if ((strncasecmp(s, smbios_uninfo[i], strlen(smbios_uninfo[i])))==0) + for (i = 0; i < nitems(smbios_uninfo); i++) + if ((strncasecmp(s, smbios_uninfo[i], + strlen(smbios_uninfo[i]))) == 0) return NULL; /* * Remove leading and trailing whitespace @@ -933,7 +933,7 @@ fixstring(char *s) for (e = s + strlen(s) - 1; e > s && *e == ' '; e--) ; if (p > s || e < s + strlen(s) - 1) { - bcopy(p, s, e-p + 1); + memmove(s, p, e - p + 1); s[e - p + 1] = '\0'; } @@ -941,7 +941,7 @@ fixstring(char *s) } void -smbios_info(char * str) +smbios_info(char *str) { char *sminfop, sminfo[64]; struct smbtable stbl, btbl; @@ -965,11 +965,12 @@ smbios_info(char * str) if (havebb) board = (struct smbios_board *)btbl.tblhdr; /* - * Some smbios implementations have no system vendor or product strings, - * some have very uninformative data which is harder to work around - * and we must rely upon various heuristics to detect this. In both - * cases we attempt to fall back on the base board information in the - * perhaps naive belief that motherboard vendors will supply this + * Some smbios implementations have no system vendor or + * product strings, some have very uninformative data which is + * harder to work around and we must rely upon various + * heuristics to detect this. In both cases we attempt to fall + * back on the base board information in the perhaps naive + * belief that motherboard vendors will supply this * information. */ sminfop = NULL; diff --git a/sys/arch/i386/include/biosvar.h b/sys/arch/i386/include/biosvar.h index 94a7df3140f..a3657f1eb5c 100644 --- a/sys/arch/i386/include/biosvar.h +++ b/sys/arch/i386/include/biosvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: biosvar.h,v 1.67 2018/08/23 14:47:52 jsg Exp $ */ +/* $OpenBSD: biosvar.h,v 1.68 2019/08/04 14:28:58 kettenis Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -67,11 +67,11 @@ */ typedef struct bios_romheader { - u_int16_t signature; /* 0xaa55 */ - u_int8_t len; /* length in pages (512 bytes) */ - u_int32_t entry; /* initialization entry point */ - u_int8_t reserved[19]; - u_int16_t pnpheader; /* offset to PnP expansion header */ + uint16_t signature; /* 0xaa55 */ + uint8_t len; /* length in pages (512 bytes) */ + uint32_t entry; /* initialization entry point */ + uint8_t reserved[19]; + uint16_t pnpheader; /* offset to PnP expansion header */ } __packed *bios_romheader_t; /* @@ -79,25 +79,25 @@ struct bios_romheader { */ typedef struct bios32_header { - u_int32_t signature; /* 00: signature "_32_" */ - u_int32_t entry; /* 04: entry point */ - u_int8_t rev; /* 08: revision */ - u_int8_t length; /* 09: header length */ - u_int8_t cksum; /* 0a: modulo 256 checksum */ - u_int8_t reserved[5]; + uint32_t signature; /* 00: signature "_32_" */ + uint32_t entry; /* 04: entry point */ + uint8_t rev; /* 08: revision */ + uint8_t length; /* 09: header length */ + uint8_t cksum; /* 0a: modulo 256 checksum */ + uint8_t reserved[5]; } __packed *bios32_header_t; typedef struct bios32_entry_info { - u_int32_t bei_base; - u_int32_t bei_size; - u_int32_t bei_entry; + uint32_t bei_base; + uint32_t bei_size; + uint32_t bei_entry; } __packed *bios32_entry_info_t; typedef struct bios32_entry { - u_int32_t offset; - u_int16_t segment; + uint32_t offset; + uint16_t segment; } __packed *bios32_entry_t; #define BIOS32_START 0xe0000 @@ -127,9 +127,9 @@ struct bios32_entry { #define BOOTARG_MEMMAP 0 typedef struct _bios_memmap { - u_int64_t addr; /* Beginning of block */ - u_int64_t size; /* Size of block */ - u_int32_t type; /* Type of block */ + uint64_t addr; /* Beginning of block */ + uint64_t size; /* Size of block */ + uint32_t type; /* Type of block */ } __packed bios_memmap_t; /* Info about disk from the bios, plus the mapping from @@ -153,10 +153,10 @@ typedef struct _bios_diskinfo { dev_t bsd_dev; /* BSD device */ /* Checksum section */ - u_int32_t checksum; /* Checksum for drive */ + uint32_t checksum; /* Checksum for drive */ /* Misc. flags */ - u_int32_t flags; + uint32_t flags; #define BDI_INVALID 0x00000001 /* I/O error during checksumming */ #define BDI_GOODLABEL 0x00000002 /* Had SCSI or ST506/ESDI disklabel */ #define BDI_BADLABEL 0x00000004 /* Had another disklabel */ @@ -179,15 +179,15 @@ typedef struct _bios_apminfo { u_int apm_code16_len; } __packed bios_apminfo_t; -#define BOOTARG_CKSUMLEN 3 /* u_int32_t */ +#define BOOTARG_CKSUMLEN 3 /* uint32_t */ #define BOOTARG_PCIINFO 4 typedef struct _bios_pciinfo { /* PCI BIOS v2.0+ - Installation check values */ - u_int32_t pci_chars; /* Characteristics (%eax) */ - u_int32_t pci_rev; /* BCD Revision (%ebx) */ - u_int32_t pci_entry32; /* PM entry point for PCI BIOS */ - u_int32_t pci_lastbus; /* Number of last PCI bus */ + uint32_t pci_chars; /* Characteristics (%eax) */ + uint32_t pci_rev; /* BCD Revision (%ebx) */ + uint32_t pci_entry32; /* PM entry point for PCI BIOS */ + uint32_t pci_lastbus; /* Number of last PCI bus */ } __packed bios_pciinfo_t; #define BOOTARG_CONSDEV 5 @@ -219,8 +219,8 @@ typedef struct _bios_bootduid { #define BOOTSR_UUID_MAX 16 #define BOOTSR_CRYPTO_MAXKEYBYTES 32 typedef struct _bios_bootsr { - u_int8_t uuid[BOOTSR_UUID_MAX]; - u_int8_t maskkey[BOOTSR_CRYPTO_MAXKEYBYTES]; + uint8_t uuid[BOOTSR_UUID_MAX]; + uint8_t maskkey[BOOTSR_CRYPTO_MAXKEYBYTES]; } __packed bios_bootsr_t; #define BOOTARG_EFIINFO 11 @@ -252,15 +252,15 @@ typedef struct _bios_ucode { #define DOINT(n) "int $0x20+(" #n ")" extern volatile struct BIOS_regs { - u_int32_t biosr_ax; - u_int32_t biosr_cx; - u_int32_t biosr_dx; - u_int32_t biosr_bx; - u_int32_t biosr_bp; - u_int32_t biosr_si; - u_int32_t biosr_di; - u_int32_t biosr_ds; - u_int32_t biosr_es; + uint32_t biosr_ax; + uint32_t biosr_cx; + uint32_t biosr_dx; + uint32_t biosr_bx; + uint32_t biosr_bp; + uint32_t biosr_si; + uint32_t biosr_di; + uint32_t biosr_ds; + uint32_t biosr_es; } __packed BIOS_regs; #ifdef _KERNEL @@ -289,7 +289,7 @@ int bios_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *); void bios_getopt(void); /* bios32.c */ -int bios32_service(u_int32_t, bios32_entry_t, bios32_entry_info_t); +int bios32_service(uint32_t, bios32_entry_t, bios32_entry_info_t); void bios32_cleanup(void); extern u_int bootapiver; diff --git a/sys/arch/i386/include/smbiosvar.h b/sys/arch/i386/include/smbiosvar.h index 69662e5afe6..54655c1cdfe 100644 --- a/sys/arch/i386/include/smbiosvar.h +++ b/sys/arch/i386/include/smbiosvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smbiosvar.h,v 1.9 2011/08/18 16:01:24 marco Exp $ */ +/* $OpenBSD: smbiosvar.h,v 1.10 2019/08/04 14:28:58 kettenis Exp $ */ /* * Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca> * Copyright (c) 2005 Jordan Hargrave @@ -25,8 +25,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#ifndef _I386_SMBIOSVAR_ -#define _I386_SMBIOSVAR_ + +#ifndef _MACHINE_SMBIOSVAR_ +#define _MACHINE_SMBIOSVAR_ #define SMBIOS_START 0xf0000 #define SMBIOS_END 0xfffff @@ -43,40 +44,53 @@ #define SMBIOS_UUID_REPLEN 37 /* 16 zero padded values, 4 hyphens, 1 null */ struct smbios_entry { - u_int8_t mjr; - u_int8_t min; - u_int8_t *addr; - u_int16_t len; - u_int16_t count; + uint8_t mjr; + uint8_t min; + uint8_t *addr; + uint16_t len; + uint16_t count; }; struct smbhdr { - u_int32_t sig; /* "_SM_" */ - u_int8_t checksum; /* Entry point checksum */ - u_int8_t len; /* Entry point structure length */ - u_int8_t majrev; /* Specification major revision */ - u_int8_t minrev; /* Specification minor revision */ - u_int16_t mss; /* Maximum Structure Size */ - u_int8_t epr; /* Entry Point Revision */ - u_int8_t fa[5]; /* value determined by EPR */ - u_int8_t sasig[5]; /* Secondary Anchor "_DMI_" */ - u_int8_t sachecksum; /* Secondary Checksum */ - u_int16_t size; /* Length of structure table in bytes */ - u_int32_t addr; /* Structure table address */ - u_int16_t count; /* Number of SMBIOS structures */ - u_int8_t rev; /* BCD revision */ + uint32_t sig; /* "_SM_" */ + uint8_t checksum; /* Entry point checksum */ + uint8_t len; /* Entry point structure length */ + uint8_t majrev; /* Specification major revision */ + uint8_t minrev; /* Specification minor revision */ + uint16_t mss; /* Maximum Structure Size */ + uint8_t epr; /* Entry Point Revision */ + uint8_t fa[5]; /* value determined by EPR */ + uint8_t sasig[5]; /* Secondary Anchor "_DMI_" */ + uint8_t sachecksum; /* Secondary Checksum */ + uint16_t size; /* Length of structure table in bytes */ + uint32_t addr; /* Structure table address */ + uint16_t count; /* Number of SMBIOS structures */ + uint8_t rev; /* BCD revision */ +} __packed; + +struct smb3hdr { + uint8_t sig[5]; /* "_SM3_" */ + uint8_t checksum; /* Entry point structure checksum */ + uint8_t len; /* Entry point length */ + uint8_t majrev; /* SMBIOS major version */ + uint8_t minrev; /* SMBIOS minor version */ + uint8_t docrev; /* SMBIOS docrev */ + uint8_t epr; /* Entry point revision */ + uint8_t reserved; /* Reserved */ + uint32_t size; /* Structure table maximum size */ + uint64_t addr; /* Structure table address */ } __packed; struct smbtblhdr { - u_int8_t type; - u_int8_t size; - u_int16_t handle; + uint8_t type; + uint8_t size; + uint16_t handle; } __packed; struct smbtable { struct smbtblhdr *hdr; void *tblhdr; - u_int32_t cookie; + uint32_t cookie; }; #define SMBIOS_TYPE_BIOS 0 @@ -127,17 +141,17 @@ struct smbtable { * DMTF Specification DSP0134 Section: 3.3.1 p.g. 34 */ struct smbios_struct_bios { - u_int8_t vendor; /* string */ - u_int8_t version; /* string */ - u_int16_t startaddr; - u_int8_t release; /* string */ - u_int8_t romsize; - u_int64_t characteristics; - u_int32_t charext; - u_int8_t major_rel; - u_int8_t minor_rel; - u_int8_t ecf_mjr_rel; /* embedded controler firmware */ - u_int8_t ecf_min_rel; /* embedded controler firmware */ + uint8_t vendor; /* string */ + uint8_t version; /* string */ + uint16_t startaddr; + uint8_t release; /* string */ + uint8_t romsize; + uint64_t characteristics; + uint32_t charext; + uint8_t major_rel; + uint8_t minor_rel; + uint8_t ecf_mjr_rel; /* embedded controler firmware */ + uint8_t ecf_min_rel; /* embedded controler firmware */ } __packed; /* @@ -147,16 +161,16 @@ struct smbios_struct_bios { struct smbios_sys { /* SMBIOS spec 2.0+ */ - u_int8_t vendor; /* string */ - u_int8_t product; /* string */ - u_int8_t version; /* string */ - u_int8_t serial; /* string */ + uint8_t vendor; /* string */ + uint8_t product; /* string */ + uint8_t version; /* string */ + uint8_t serial; /* string */ /* SMBIOS spec 2.1+ */ - u_int8_t uuid[16]; - u_int8_t wakeup; + uint8_t uuid[16]; + uint8_t wakeup; /* SMBIOS spec 2.4+ */ - u_int8_t sku; /* string */ - u_int8_t family; /* string */ + uint8_t sku; /* string */ + uint8_t family; /* string */ } __packed; /* @@ -164,16 +178,16 @@ struct smbios_sys { * DMTF Specification DSP0134 Section 3.3.3 p.g. 37 */ struct smbios_board { - u_int8_t vendor; /* string */ - u_int8_t product; /* string */ - u_int8_t version; /* string */ - u_int8_t serial; /* string */ - u_int8_t asset; /* stirng */ - u_int8_t feature; /* feature flags */ - u_int8_t location; /* location in chassis */ - u_int16_t handle; /* chassis handle */ - u_int8_t type; /* board type */ - u_int8_t noc; /* number of contained objects */ + uint8_t vendor; /* string */ + uint8_t product; /* string */ + uint8_t version; /* string */ + uint8_t serial; /* string */ + uint8_t asset; /* stirng */ + uint8_t feature; /* feature flags */ + uint8_t location; /* location in chassis */ + uint16_t handle; /* chassis handle */ + uint8_t type; /* board type */ + uint8_t noc; /* number of contained objects */ } __packed; /* @@ -182,25 +196,25 @@ struct smbios_board { */ struct smbios_enclosure { /* SMBIOS spec 2.0+ */ - u_int8_t vendor; /* string */ - u_int8_t type; - u_int8_t version; /* string */ - u_int8_t serial; /* string */ - u_int8_t asset_tag; /* string */ + uint8_t vendor; /* string */ + uint8_t type; + uint8_t version; /* string */ + uint8_t serial; /* string */ + uint8_t asset_tag; /* string */ /* SMBIOS spec 2.1+ */ - u_int8_t boot_state; - u_int8_t psu_state; - u_int8_t thermal_state; - u_int8_t security_status; + uint8_t boot_state; + uint8_t psu_state; + uint8_t thermal_state; + uint8_t security_status; /* SMBIOS spec 2.3+ */ - u_int16_t oem_defined; - u_int8_t height; - u_int8_t no_power_cords; - u_int8_t no_contained_element; - u_int8_t reclen_contained_element; - u_int8_t contained_elements; + uint16_t oem_defined; + uint8_t height; + uint8_t no_power_cords; + uint8_t no_contained_element; + uint8_t reclen_contained_element; + uint8_t contained_elements; /* SMBIOS spec 2.7+ */ - u_int8_t sku; /* string */ + uint8_t sku; /* string */ } __packed; /* @@ -208,32 +222,32 @@ struct smbios_enclosure { * DMTF Specification DSP0134 v2.5 Section 3.3.5 p.g. 24 */ struct smbios_cpu { - u_int8_t cpu_socket_designation; /* string */ - u_int8_t cpu_type; - u_int8_t cpu_family; - u_int8_t cpu_mfg; /* string */ - u_int32_t cpu_id_eax; - u_int32_t cpu_id_edx; - u_int8_t cpu_version; /* string */ - u_int8_t cpu_voltage; - u_int16_t cpu_clock; - u_int16_t cpu_max_speed; - u_int16_t cpu_current_speed; - u_int8_t cpu_status; + uint8_t cpu_socket_designation; /* string */ + uint8_t cpu_type; + uint8_t cpu_family; + uint8_t cpu_mfg; /* string */ + uint32_t cpu_id_eax; + uint32_t cpu_id_edx; + uint8_t cpu_version; /* string */ + uint8_t cpu_voltage; + uint16_t cpu_clock; + uint16_t cpu_max_speed; + uint16_t cpu_current_speed; + uint8_t cpu_status; #define SMBIOS_CPUST_POPULATED (1<<6) #define SMBIOS_CPUST_STATUSMASK (0x07) - u_int8_t cpu_upgrade; - u_int16_t cpu_l1_handle; - u_int16_t cpu_l2_handle; - u_int16_t cpu_l3_handle; - u_int8_t cpu_serial; /* string */ - u_int8_t cpu_asset_tag; /* string */ - u_int8_t cpu_part_nr; /* string */ + uint8_t cpu_upgrade; + uint16_t cpu_l1_handle; + uint16_t cpu_l2_handle; + uint16_t cpu_l3_handle; + uint8_t cpu_serial; /* string */ + uint8_t cpu_asset_tag; /* string */ + uint8_t cpu_part_nr; /* string */ /* following fields were added in smbios 2.5 */ - u_int8_t cpu_core_count; - u_int8_t cpu_core_enabled; - u_int8_t cpu_thread_count; - u_int16_t cpu_characteristics; + uint8_t cpu_core_count; + uint8_t cpu_core_enabled; + uint8_t cpu_thread_count; + uint16_t cpu_characteristics; } __packed; /* @@ -241,14 +255,14 @@ struct smbios_cpu { * DMTF Specification DSP0134 Section 3.3.39 p.g. 91 */ struct smbios_ipmi { - u_int8_t smipmi_if_type; /* IPMI Interface Type */ - u_int8_t smipmi_if_rev; /* BCD IPMI Revision */ - u_int8_t smipmi_i2c_address; /* I2C address of BMC */ - u_int8_t smipmi_nvram_address; /* I2C address of NVRAM + uint8_t smipmi_if_type; /* IPMI Interface Type */ + uint8_t smipmi_if_rev; /* BCD IPMI Revision */ + uint8_t smipmi_i2c_address; /* I2C address of BMC */ + uint8_t smipmi_nvram_address; /* I2C address of NVRAM * storage */ - u_int64_t smipmi_base_address; /* Base address of BMC (BAR + uint64_t smipmi_base_address; /* Base address of BMC (BAR * format */ - u_int8_t smipmi_base_flags; /* Flags field: + uint8_t smipmi_base_flags; /* Flags field: * bit 7:6 : register spacing * 00 = byte * 01 = dword @@ -258,10 +272,10 @@ struct smbios_ipmi { * bit 2 : N/A * bit 1 : Interrupt polarity * bit 0 : Interrupt trigger */ - u_int8_t smipmi_irq; /* IRQ if applicable */ + uint8_t smipmi_irq; /* IRQ if applicable */ } __packed; -int smbios_find_table(u_int8_t, struct smbtable *); -char *smbios_get_string(struct smbtable *, u_int8_t, char *, size_t); +int smbios_find_table(uint8_t, struct smbtable *); +char *smbios_get_string(struct smbtable *, uint8_t, char *, size_t); #endif |