1 1.2 jmcneill /* $NetBSD: smbiosvar.h,v 1.2 2021/07/24 11:39:19 jmcneill Exp $ */ 2 1.1 jmcneill /* 3 1.1 jmcneill * Copyright (c) 2006 Gordon Willem Klok <gklok (at) cogeco.ca> 4 1.1 jmcneill * Copyright (c) 2005 Jordan Hargrave 5 1.1 jmcneill * All rights reserved. 6 1.1 jmcneill * 7 1.1 jmcneill * Redistribution and use in source and binary forms, with or without 8 1.1 jmcneill * modification, are permitted provided that the following conditions 9 1.1 jmcneill * are met: 10 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright 11 1.1 jmcneill * notice, this list of conditions and the following disclaimer. 12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the 14 1.1 jmcneill * documentation and/or other materials provided with the distribution. 15 1.1 jmcneill * 16 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 17 1.1 jmcneill * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 1.1 jmcneill * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 1.1 jmcneill * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 20 1.1 jmcneill * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 1.1 jmcneill * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 1.1 jmcneill * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 1.1 jmcneill * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 1.1 jmcneill * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 1.1 jmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 1.1 jmcneill * SUCH DAMAGE. 27 1.1 jmcneill */ 28 1.1 jmcneill 29 1.1 jmcneill #ifndef _DEV_SMBIOSVAR_H 30 1.1 jmcneill #define _DEV_SMBIOSVAR_H 31 1.1 jmcneill 32 1.1 jmcneill #define SMBIOS_UUID_NPRESENT 0x1 33 1.1 jmcneill #define SMBIOS_UUID_NSET 0x2 34 1.1 jmcneill 35 1.1 jmcneill /* 36 1.1 jmcneill * Section 3.5 of "UUIDs and GUIDs" found at 37 1.1 jmcneill * http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt 38 1.1 jmcneill * specifies the string repersentation of a UUID. 39 1.1 jmcneill */ 40 1.1 jmcneill #define SMBIOS_UUID_REP "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x" 41 1.1 jmcneill #define SMBIOS_UUID_REPLEN 37 /* 16 zero padded values, 4 hyphens, 1 null */ 42 1.1 jmcneill 43 1.1 jmcneill struct smbios_entry { 44 1.2 jmcneill paddr_t hdrphys; 45 1.2 jmcneill paddr_t tabphys; 46 1.1 jmcneill uint8_t rev; 47 1.1 jmcneill uint8_t mjr; 48 1.1 jmcneill uint8_t min; 49 1.1 jmcneill uint8_t doc; 50 1.1 jmcneill uint8_t *addr; 51 1.1 jmcneill uint32_t len; 52 1.1 jmcneill uint16_t count; 53 1.1 jmcneill }; 54 1.1 jmcneill 55 1.1 jmcneill struct smbhdr { 56 1.1 jmcneill uint32_t sig; /* "_SM_" */ 57 1.1 jmcneill uint8_t checksum; /* Entry point checksum */ 58 1.1 jmcneill uint8_t len; /* Entry point structure length */ 59 1.1 jmcneill uint8_t majrev; /* Specification major revision */ 60 1.1 jmcneill uint8_t minrev; /* Specification minor revision */ 61 1.1 jmcneill uint16_t mss; /* Maximum Structure Size */ 62 1.1 jmcneill uint8_t epr; /* Entry Point Revision */ 63 1.1 jmcneill uint8_t fa[5]; /* value determined by EPR */ 64 1.1 jmcneill uint8_t sasig[5]; /* Secondary Anchor "_DMI_" */ 65 1.1 jmcneill uint8_t sachecksum; /* Secondary Checksum */ 66 1.1 jmcneill uint16_t size; /* Length of structure table in bytes */ 67 1.1 jmcneill uint32_t addr; /* Structure table address */ 68 1.1 jmcneill uint16_t count; /* Number of SMBIOS structures */ 69 1.1 jmcneill uint8_t rev; /* BCD revision */ 70 1.1 jmcneill } __packed; 71 1.1 jmcneill 72 1.1 jmcneill struct smb3hdr { 73 1.1 jmcneill uint8_t sig[5]; /* "_SM3_" */ 74 1.1 jmcneill uint8_t checksum; /* Entry point structure checksum */ 75 1.1 jmcneill uint8_t len; /* Entry point structure length */ 76 1.1 jmcneill uint8_t majrev; /* Specification major revision */ 77 1.1 jmcneill uint8_t minrev; /* Specification minor revision */ 78 1.1 jmcneill uint8_t docrev; /* docrec of Specification */ 79 1.1 jmcneill uint8_t eprev; /* Entry point structure revision */ 80 1.1 jmcneill #define SMBIOS3_EPREV_RESERVED 0 81 1.1 jmcneill #define SMBIOS3_EPREV_3_0 1 /* SMBIOS 3.0 */ 82 1.1 jmcneill uint8_t reverved; 83 1.1 jmcneill uint32_t size; /* Length of structure table in bytes */ 84 1.1 jmcneill uint64_t addr; /* Structure table address */ 85 1.1 jmcneill } __packed; 86 1.1 jmcneill 87 1.1 jmcneill struct smbtblhdr { 88 1.1 jmcneill uint8_t type; 89 1.1 jmcneill uint8_t size; 90 1.1 jmcneill uint16_t handle; 91 1.1 jmcneill } __packed; 92 1.1 jmcneill 93 1.1 jmcneill struct smbtable { 94 1.1 jmcneill struct smbtblhdr *hdr; 95 1.1 jmcneill void *tblhdr; 96 1.1 jmcneill uint32_t cookie; 97 1.1 jmcneill }; 98 1.1 jmcneill 99 1.1 jmcneill #define SMBIOS_TYPE_BIOS 0 100 1.1 jmcneill #define SMBIOS_TYPE_SYSTEM 1 101 1.1 jmcneill #define SMBIOS_TYPE_BASEBOARD 2 102 1.1 jmcneill #define SMBIOS_TYPE_ENCLOSURE 3 103 1.1 jmcneill #define SMBIOS_TYPE_PROCESSOR 4 104 1.1 jmcneill #define SMBIOS_TYPE_MEMCTRL 5 105 1.1 jmcneill #define SMBIOS_TYPE_MEMMOD 6 106 1.1 jmcneill #define SMBIOS_TYPE_CACHE 7 107 1.1 jmcneill #define SMBIOS_TYPE_PORT 8 108 1.1 jmcneill #define SMBIOS_TYPE_SLOTS 9 109 1.1 jmcneill #define SMBIOS_TYPE_OBD 10 110 1.1 jmcneill #define SMBIOS_TYPE_OEM 11 111 1.1 jmcneill #define SMBIOS_TYPE_SYSCONFOPT 12 112 1.1 jmcneill #define SMBIOS_TYPE_BIOSLANG 13 113 1.1 jmcneill #define SMBIOS_TYPE_GROUPASSOC 14 114 1.1 jmcneill #define SMBIOS_TYPE_SYSEVENTLOG 15 115 1.1 jmcneill #define SMBIOS_TYPE_PHYMEM 16 116 1.1 jmcneill #define SMBIOS_TYPE_MEMDEV 17 117 1.1 jmcneill #define SMBIOS_TYPE_ECCINFO32 18 118 1.1 jmcneill #define SMBIOS_TYPE_MEMMAPARRAYADDR 19 119 1.1 jmcneill #define SMBIOS_TYPE_MEMMAPDEVADDR 20 120 1.1 jmcneill #define SMBIOS_TYPE_INBUILTPOINT 21 121 1.1 jmcneill #define SMBIOS_TYPE_PORTBATT 22 122 1.1 jmcneill #define SMBIOS_TYPE_SYSRESET 23 123 1.1 jmcneill #define SMBIOS_TYPE_HWSECUIRTY 24 124 1.1 jmcneill #define SMBIOS_TYPE_PWRCTRL 25 125 1.1 jmcneill #define SMBIOS_TYPE_VOLTPROBE 26 126 1.1 jmcneill #define SMBIOS_TYPE_COOLING 27 127 1.1 jmcneill #define SMBIOS_TYPE_TEMPPROBE 28 128 1.1 jmcneill #define SMBIOS_TYPE_CURRENTPROBE 29 129 1.1 jmcneill #define SMBIOS_TYPE_OOB_REMOTEACCESS 30 130 1.1 jmcneill #define SMBIOS_TYPE_BIS 31 131 1.1 jmcneill #define SMBIOS_TYPE_SBI 32 132 1.1 jmcneill #define SMBIOS_TYPE_ECCINFO64 33 133 1.1 jmcneill #define SMBIOS_TYPE_MGMTDEV 34 134 1.1 jmcneill #define SMBIOS_TYPE_MGTDEVCOMP 35 135 1.1 jmcneill #define SMBIOS_TYPE_MGTDEVTHRESH 36 136 1.1 jmcneill #define SMBIOS_TYPE_MEMCHANNEL 37 137 1.1 jmcneill #define SMBIOS_TYPE_IPMIDEV 38 138 1.1 jmcneill #define SMBIOS_TYPE_SPS 39 139 1.1 jmcneill #define SMBIOS_TYPE_INACTIVE 126 140 1.1 jmcneill #define SMBIOS_TYPE_EOT 127 141 1.1 jmcneill 142 1.1 jmcneill /* 143 1.1 jmcneill * SMBIOS Structure Type 0 "BIOS Information" 144 1.1 jmcneill * DMTF Specification DSP0134 Section: 3.3.1 p.g. 34 145 1.1 jmcneill */ 146 1.1 jmcneill struct smbios_struct_bios { 147 1.1 jmcneill uint8_t vendor; /* string */ 148 1.1 jmcneill uint8_t version; /* string */ 149 1.1 jmcneill uint16_t startaddr; 150 1.1 jmcneill uint8_t release; /* string */ 151 1.1 jmcneill uint8_t romsize; 152 1.1 jmcneill uint64_t characteristics; 153 1.1 jmcneill uint32_t charext; 154 1.1 jmcneill uint8_t major_rel; 155 1.1 jmcneill uint8_t minor_rel; 156 1.1 jmcneill uint8_t ecf_mjr_rel; /* embedded controller firmware */ 157 1.1 jmcneill uint8_t ecf_min_rel; /* embedded controller firmware */ 158 1.1 jmcneill } __packed; 159 1.1 jmcneill 160 1.1 jmcneill /* 161 1.1 jmcneill * SMBIOS Structure Type 1 "System Information" 162 1.1 jmcneill * DMTF Specification DSP0134 Section 3.3.2 p.g. 35 163 1.1 jmcneill */ 164 1.1 jmcneill 165 1.1 jmcneill struct smbios_sys { 166 1.1 jmcneill /* SMBIOS spec 2.0+ */ 167 1.1 jmcneill uint8_t vendor; /* string */ 168 1.1 jmcneill uint8_t product; /* string */ 169 1.1 jmcneill uint8_t version; /* string */ 170 1.1 jmcneill uint8_t serial; /* string */ 171 1.1 jmcneill /* SMBIOS spec 2.1+ */ 172 1.1 jmcneill uint8_t uuid[16]; 173 1.1 jmcneill uint8_t wakeup; 174 1.1 jmcneill /* SMBIOS spec 2.4+ */ 175 1.1 jmcneill uint8_t sku; /* string */ 176 1.1 jmcneill uint8_t family; /* string */ 177 1.1 jmcneill } __packed; 178 1.1 jmcneill 179 1.1 jmcneill /* 180 1.1 jmcneill * SMBIOS Structure Type 2 "Base Board (Module) Information" 181 1.1 jmcneill * DMTF Specification DSP0134 Section 3.3.3 p.g. 37 182 1.1 jmcneill */ 183 1.1 jmcneill struct smbios_board { 184 1.1 jmcneill uint8_t vendor; /* string */ 185 1.1 jmcneill uint8_t product; /* string */ 186 1.1 jmcneill uint8_t version; /* string */ 187 1.1 jmcneill uint8_t serial; /* string */ 188 1.1 jmcneill uint8_t asset; /* string */ 189 1.1 jmcneill uint8_t feature; /* feature flags */ 190 1.1 jmcneill uint8_t location; /* location in chassis */ 191 1.1 jmcneill uint16_t handle; /* chassis handle */ 192 1.1 jmcneill uint8_t type; /* board type */ 193 1.1 jmcneill uint8_t noc; /* number of contained objects */ 194 1.1 jmcneill } __packed; 195 1.1 jmcneill 196 1.1 jmcneill /* 197 1.1 jmcneill * SMBIOS Structure Type 3 "System Enclosure or Chassis" 198 1.1 jmcneill * DMTF Specification DSP0134 Section 3.1.1 p.g. 37 199 1.1 jmcneill */ 200 1.1 jmcneill struct smbios_chassis { 201 1.1 jmcneill uint8_t vendor; /* string */ 202 1.1 jmcneill uint8_t shape; 203 1.1 jmcneill uint8_t version; /* string */ 204 1.1 jmcneill uint8_t serial; /* string */ 205 1.1 jmcneill uint8_t asset; /* string */ 206 1.1 jmcneill uint8_t bustate; 207 1.1 jmcneill uint8_t psstate; 208 1.1 jmcneill uint8_t thstate; 209 1.1 jmcneill uint8_t security; 210 1.1 jmcneill uint32_t oemdata; 211 1.1 jmcneill uint8_t height; 212 1.1 jmcneill uint8_t powercords; 213 1.1 jmcneill uint8_t noc; /* number of contained objects */ 214 1.1 jmcneill } __packed; 215 1.1 jmcneill 216 1.1 jmcneill /* 217 1.1 jmcneill * SMBIOS Structure Type 4 "Processor Information" 218 1.1 jmcneill * DMTF Specification DSP0134 Section 3.1.1 p.g. 42 219 1.1 jmcneill */ 220 1.1 jmcneill struct smbios_processor { 221 1.1 jmcneill uint8_t socket; /* string */ 222 1.1 jmcneill uint8_t type; 223 1.1 jmcneill uint8_t family; 224 1.1 jmcneill uint8_t vendor; /* string */ 225 1.1 jmcneill uint64_t cpuid; 226 1.1 jmcneill uint8_t version; /* string */ 227 1.1 jmcneill uint8_t voltage; 228 1.1 jmcneill uint16_t clkspeed; 229 1.1 jmcneill uint16_t maxspeed; 230 1.1 jmcneill uint16_t curspeed; 231 1.1 jmcneill uint8_t status; 232 1.1 jmcneill uint8_t upgrade; 233 1.1 jmcneill uint8_t l1cache; 234 1.1 jmcneill uint8_t l2cache; 235 1.1 jmcneill uint8_t l3cache; 236 1.1 jmcneill uint8_t serial; /* string */ 237 1.1 jmcneill uint8_t asset; /* string */ 238 1.1 jmcneill uint8_t part; /* string */ 239 1.1 jmcneill uint8_t cores; /* cores per socket */ 240 1.1 jmcneill uint8_t enabled; /* enabled cores per socket */ 241 1.1 jmcneill uint8_t threads; /* threads per socket */ 242 1.1 jmcneill uint16_t characteristics; 243 1.1 jmcneill uint16_t family2; /* for values >= 255 */ 244 1.1 jmcneill uint16_t cores2; /* for values >= 255 */ 245 1.1 jmcneill uint16_t enabled2; /* for values >= 255 */ 246 1.1 jmcneill uint16_t threads2; /* for values >= 255 */ 247 1.1 jmcneill } __packed; 248 1.1 jmcneill 249 1.1 jmcneill /* 250 1.1 jmcneill * SMBIOS Structure Type 9 "Expansion slot" 251 1.1 jmcneill */ 252 1.1 jmcneill struct smbios_slot { 253 1.1 jmcneill uint8_t designation; 254 1.1 jmcneill uint8_t type; 255 1.1 jmcneill uint8_t width; 256 1.1 jmcneill uint8_t usage; 257 1.1 jmcneill uint8_t length; 258 1.1 jmcneill uint8_t slotid[2]; 259 1.1 jmcneill uint8_t characteristics[2]; 260 1.1 jmcneill } __packed; 261 1.1 jmcneill 262 1.1 jmcneill #define SMBIOS_SLOT_ISA 0x03 263 1.1 jmcneill #define SMBIOS_SLOT_EISA 0x05 264 1.1 jmcneill 265 1.1 jmcneill /* 266 1.1 jmcneill * SMBIOS Structure Type 38 "IPMI Information" 267 1.1 jmcneill * DMTF Specification DSP0134 Section 3.3.39 p.g. 91 268 1.1 jmcneill */ 269 1.1 jmcneill struct smbios_ipmi { 270 1.1 jmcneill uint8_t smipmi_if_type; /* IPMI Interface Type */ 271 1.1 jmcneill uint8_t smipmi_if_rev; /* BCD IPMI Revision */ 272 1.1 jmcneill uint8_t smipmi_i2c_address; /* I2C address of BMC */ 273 1.1 jmcneill uint8_t smipmi_nvram_address; /* I2C address of NVRAM 274 1.1 jmcneill * storage */ 275 1.1 jmcneill uint64_t smipmi_base_address; /* Base address of BMC (BAR 276 1.1 jmcneill * format */ 277 1.1 jmcneill uint8_t smipmi_base_flags; /* Flags field: 278 1.1 jmcneill * bit 7:6 : register spacing 279 1.1 jmcneill * 00 = byte 280 1.1 jmcneill * 01 = dword 281 1.1 jmcneill * 02 = word 282 1.1 jmcneill * bit 4 : Lower bit BAR 283 1.1 jmcneill * bit 3 : IRQ valid 284 1.1 jmcneill * bit 2 : N/A 285 1.1 jmcneill * bit 1 : Interrupt polarity 286 1.1 jmcneill * bit 0 : Interrupt trigger */ 287 1.1 jmcneill uint8_t smipmi_irq; /* IRQ if applicable */ 288 1.1 jmcneill } __packed; 289 1.1 jmcneill 290 1.1 jmcneill extern struct smbios_entry smbios_entry; 291 1.1 jmcneill 292 1.1 jmcneill int smbios2_check_header(const uint8_t *); 293 1.1 jmcneill int smbios3_check_header(const uint8_t *); 294 1.1 jmcneill int smbios_find_table(uint8_t, struct smbtable *); 295 1.1 jmcneill char *smbios_get_string(struct smbtable *, uint8_t, char *, size_t); 296 1.1 jmcneill 297 1.1 jmcneill #endif 298