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