Home | History | Annotate | Line # | Download | only in efiboot
      1  1.1  jmcneill /*	$NetBSD: smbios.h,v 1.1 2019/11/30 13:02:18 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 #define SMBIOS_UUID_NPRESENT		0x1
     30  1.1  jmcneill #define SMBIOS_UUID_NSET		0x2
     31  1.1  jmcneill 
     32  1.1  jmcneill /*
     33  1.1  jmcneill  * Section 3.5 of "UUIDs and GUIDs" found at
     34  1.1  jmcneill  * http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt
     35  1.1  jmcneill  * specifies the string repersentation of a UUID.
     36  1.1  jmcneill  */
     37  1.1  jmcneill #define SMBIOS_UUID_REP "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
     38  1.1  jmcneill #define SMBIOS_UUID_REPLEN 37 /* 16 zero padded values, 4 hyphens, 1 null */
     39  1.1  jmcneill 
     40  1.1  jmcneill struct smbios_entry {
     41  1.1  jmcneill 	uint8_t 	rev;
     42  1.1  jmcneill 	uint8_t 	mjr;
     43  1.1  jmcneill 	uint8_t 	min;
     44  1.1  jmcneill 	uint8_t 	doc;
     45  1.1  jmcneill 	uint8_t 	*addr;
     46  1.1  jmcneill 	uint32_t	len;
     47  1.1  jmcneill 	uint16_t	count;
     48  1.1  jmcneill };
     49  1.1  jmcneill 
     50  1.1  jmcneill struct smbhdr {
     51  1.1  jmcneill 	uint32_t	sig;		/* "_SM_" */
     52  1.1  jmcneill 	uint8_t 	checksum;	/* Entry point checksum */
     53  1.1  jmcneill 	uint8_t 	len;		/* Entry point structure length */
     54  1.1  jmcneill 	uint8_t 	majrev;		/* Specification major revision */
     55  1.1  jmcneill 	uint8_t 	minrev;		/* Specification minor revision */
     56  1.1  jmcneill 	uint16_t	mss;		/* Maximum Structure Size */
     57  1.1  jmcneill 	uint8_t 	epr;		/* Entry Point Revision */
     58  1.1  jmcneill 	uint8_t 	fa[5];		/* value determined by EPR */
     59  1.1  jmcneill 	uint8_t 	sasig[5];	/* Secondary Anchor "_DMI_" */
     60  1.1  jmcneill 	uint8_t 	sachecksum;	/* Secondary Checksum */
     61  1.1  jmcneill 	uint16_t	size;		/* Length of structure table in bytes */
     62  1.1  jmcneill 	uint32_t	addr;		/* Structure table address */
     63  1.1  jmcneill 	uint16_t	count;		/* Number of SMBIOS structures */
     64  1.1  jmcneill 	uint8_t 	rev;		/* BCD revision */
     65  1.1  jmcneill } __packed;
     66  1.1  jmcneill 
     67  1.1  jmcneill struct smb3hdr {
     68  1.1  jmcneill 	uint8_t 	sig[5];		/* "_SM3_" */
     69  1.1  jmcneill 	uint8_t 	checksum;	/* Entry point structure checksum */
     70  1.1  jmcneill 	uint8_t 	len;		/* Entry point structure length */
     71  1.1  jmcneill 	uint8_t 	majrev;		/* Specification major revision */
     72  1.1  jmcneill 	uint8_t 	minrev;		/* Specification minor revision */
     73  1.1  jmcneill 	uint8_t 	docrev;		/* docrec of Specification */
     74  1.1  jmcneill 	uint8_t 	eprev;		/* Entry point structure revision */
     75  1.1  jmcneill #define	SMBIOS3_EPREV_RESERVED	0
     76  1.1  jmcneill #define	SMBIOS3_EPREV_3_0	1	/* SMBIOS 3.0 */
     77  1.1  jmcneill 	uint8_t 	reverved;
     78  1.1  jmcneill 	uint32_t	size;		/* Length of structure table in bytes */
     79  1.1  jmcneill 	uint64_t	addr;		/* Structure table address */
     80  1.1  jmcneill } __packed;
     81  1.1  jmcneill 
     82  1.1  jmcneill struct smbtblhdr {
     83  1.1  jmcneill 	uint8_t	type;
     84  1.1  jmcneill 	uint8_t	size;
     85  1.1  jmcneill 	uint16_t	handle;
     86  1.1  jmcneill } __packed;
     87  1.1  jmcneill 
     88  1.1  jmcneill struct smbtable {
     89  1.1  jmcneill 	struct smbtblhdr *hdr;
     90  1.1  jmcneill 	void		 *tblhdr;
     91  1.1  jmcneill 	uint32_t	 cookie;
     92  1.1  jmcneill };
     93  1.1  jmcneill 
     94  1.1  jmcneill #define	SMBIOS_TYPE_BIOS		0
     95  1.1  jmcneill #define	SMBIOS_TYPE_SYSTEM		1
     96  1.1  jmcneill #define	SMBIOS_TYPE_BASEBOARD		2
     97  1.1  jmcneill #define	SMBIOS_TYPE_ENCLOSURE		3
     98  1.1  jmcneill #define	SMBIOS_TYPE_PROCESSOR		4
     99  1.1  jmcneill #define	SMBIOS_TYPE_MEMCTRL		5
    100  1.1  jmcneill #define	SMBIOS_TYPE_MEMMOD		6
    101  1.1  jmcneill #define	SMBIOS_TYPE_CACHE		7
    102  1.1  jmcneill #define	SMBIOS_TYPE_PORT		8
    103  1.1  jmcneill #define	SMBIOS_TYPE_SLOTS		9
    104  1.1  jmcneill #define	SMBIOS_TYPE_OBD			10
    105  1.1  jmcneill #define	SMBIOS_TYPE_OEM			11
    106  1.1  jmcneill #define	SMBIOS_TYPE_SYSCONFOPT		12
    107  1.1  jmcneill #define	SMBIOS_TYPE_BIOSLANG		13
    108  1.1  jmcneill #define	SMBIOS_TYPE_GROUPASSOC		14
    109  1.1  jmcneill #define	SMBIOS_TYPE_SYSEVENTLOG		15
    110  1.1  jmcneill #define	SMBIOS_TYPE_PHYMEM		16
    111  1.1  jmcneill #define	SMBIOS_TYPE_MEMDEV		17
    112  1.1  jmcneill #define	SMBIOS_TYPE_ECCINFO32		18
    113  1.1  jmcneill #define	SMBIOS_TYPE_MEMMAPARRAYADDR	19
    114  1.1  jmcneill #define	SMBIOS_TYPE_MEMMAPDEVADDR	20
    115  1.1  jmcneill #define	SMBIOS_TYPE_INBUILTPOINT	21
    116  1.1  jmcneill #define	SMBIOS_TYPE_PORTBATT		22
    117  1.1  jmcneill #define	SMBIOS_TYPE_SYSRESET		23
    118  1.1  jmcneill #define	SMBIOS_TYPE_HWSECUIRTY		24
    119  1.1  jmcneill #define	SMBIOS_TYPE_PWRCTRL		25
    120  1.1  jmcneill #define	SMBIOS_TYPE_VOLTPROBE		26
    121  1.1  jmcneill #define	SMBIOS_TYPE_COOLING		27
    122  1.1  jmcneill #define	SMBIOS_TYPE_TEMPPROBE		28
    123  1.1  jmcneill #define	SMBIOS_TYPE_CURRENTPROBE	29
    124  1.1  jmcneill #define	SMBIOS_TYPE_OOB_REMOTEACCESS	30
    125  1.1  jmcneill #define	SMBIOS_TYPE_BIS			31
    126  1.1  jmcneill #define	SMBIOS_TYPE_SBI			32
    127  1.1  jmcneill #define	SMBIOS_TYPE_ECCINFO64		33
    128  1.1  jmcneill #define	SMBIOS_TYPE_MGMTDEV		34
    129  1.1  jmcneill #define	SMBIOS_TYPE_MGTDEVCOMP		35
    130  1.1  jmcneill #define	SMBIOS_TYPE_MGTDEVTHRESH	36
    131  1.1  jmcneill #define	SMBIOS_TYPE_MEMCHANNEL		37
    132  1.1  jmcneill #define	SMBIOS_TYPE_IPMIDEV		38
    133  1.1  jmcneill #define	SMBIOS_TYPE_SPS			39
    134  1.1  jmcneill #define	SMBIOS_TYPE_INACTIVE		126
    135  1.1  jmcneill #define	SMBIOS_TYPE_EOT			127
    136  1.1  jmcneill 
    137  1.1  jmcneill /*
    138  1.1  jmcneill  * SMBIOS Structure Type 0 "BIOS Information"
    139  1.1  jmcneill  * DMTF Specification DSP0134 Section: 3.3.1 p.g. 34
    140  1.1  jmcneill  */
    141  1.1  jmcneill struct smbios_struct_bios {
    142  1.1  jmcneill 	uint8_t	vendor;		/* string */
    143  1.1  jmcneill 	uint8_t	version;	/* string */
    144  1.1  jmcneill 	uint16_t	startaddr;
    145  1.1  jmcneill 	uint8_t	release;	/* string */
    146  1.1  jmcneill 	uint8_t	romsize;
    147  1.1  jmcneill 	uint64_t	characteristics;
    148  1.1  jmcneill 	uint32_t	charext;
    149  1.1  jmcneill 	uint8_t	major_rel;
    150  1.1  jmcneill 	uint8_t	minor_rel;
    151  1.1  jmcneill 	uint8_t	ecf_mjr_rel;	/* embedded controller firmware */
    152  1.1  jmcneill 	uint8_t 	ecf_min_rel;	/* embedded controller firmware */
    153  1.1  jmcneill } __packed;
    154  1.1  jmcneill 
    155  1.1  jmcneill /*
    156  1.1  jmcneill  * SMBIOS Structure Type 1 "System Information"
    157  1.1  jmcneill  * DMTF Specification DSP0134 Section 3.3.2 p.g. 35
    158  1.1  jmcneill  */
    159  1.1  jmcneill 
    160  1.1  jmcneill struct smbios_sys {
    161  1.1  jmcneill /* SMBIOS spec 2.0+ */
    162  1.1  jmcneill 	uint8_t	vendor;		/* string */
    163  1.1  jmcneill 	uint8_t	product;	/* string */
    164  1.1  jmcneill 	uint8_t	version;	/* string */
    165  1.1  jmcneill 	uint8_t	serial;		/* string */
    166  1.1  jmcneill /* SMBIOS spec 2.1+ */
    167  1.1  jmcneill 	uint8_t	uuid[16];
    168  1.1  jmcneill 	uint8_t	wakeup;
    169  1.1  jmcneill /* SMBIOS spec 2.4+ */
    170  1.1  jmcneill 	uint8_t	sku;		/* string */
    171  1.1  jmcneill 	uint8_t	family;		/* string */
    172  1.1  jmcneill } __packed;
    173  1.1  jmcneill 
    174  1.1  jmcneill /*
    175  1.1  jmcneill  * SMBIOS Structure Type 2 "Base Board (Module) Information"
    176  1.1  jmcneill  * DMTF Specification DSP0134 Section 3.3.3 p.g. 37
    177  1.1  jmcneill  */
    178  1.1  jmcneill struct smbios_board {
    179  1.1  jmcneill 	uint8_t	vendor;		/* string */
    180  1.1  jmcneill 	uint8_t	product;	/* string */
    181  1.1  jmcneill 	uint8_t	version;	/* string */
    182  1.1  jmcneill 	uint8_t	serial;		/* string */
    183  1.1  jmcneill 	uint8_t	asset;		/* string */
    184  1.1  jmcneill 	uint8_t	feature;	/* feature flags */
    185  1.1  jmcneill 	uint8_t	location;	/* location in chassis */
    186  1.1  jmcneill 	uint16_t	handle;		/* chassis handle */
    187  1.1  jmcneill 	uint8_t	type;		/* board type */
    188  1.1  jmcneill 	uint8_t	noc;		/* number of contained objects */
    189  1.1  jmcneill } __packed;
    190  1.1  jmcneill 
    191  1.1  jmcneill /*
    192  1.1  jmcneill  * SMBIOS Structure Type 3 "System Enclosure or Chassis"
    193  1.1  jmcneill  * DMTF Specification DSP0134 Section 3.1.1 p.g. 37
    194  1.1  jmcneill  */
    195  1.1  jmcneill struct smbios_chassis {
    196  1.1  jmcneill 	uint8_t	vendor;		/* string */
    197  1.1  jmcneill 	uint8_t	shape;
    198  1.1  jmcneill 	uint8_t	version;	/* string */
    199  1.1  jmcneill 	uint8_t	serial;		/* string */
    200  1.1  jmcneill 	uint8_t	asset;		/* string */
    201  1.1  jmcneill 	uint8_t	bustate;
    202  1.1  jmcneill 	uint8_t	psstate;
    203  1.1  jmcneill 	uint8_t	thstate;
    204  1.1  jmcneill 	uint8_t	security;
    205  1.1  jmcneill 	uint32_t	oemdata;
    206  1.1  jmcneill 	uint8_t	height;
    207  1.1  jmcneill 	uint8_t	powercords;
    208  1.1  jmcneill 	uint8_t	noc;		/* number of contained objects */
    209  1.1  jmcneill } __packed;
    210  1.1  jmcneill 
    211  1.1  jmcneill /*
    212  1.1  jmcneill  * SMBIOS Structure Type 4 "Processor Information"
    213  1.1  jmcneill  * DMTF Specification DSP0134 Section 3.1.1 p.g. 42
    214  1.1  jmcneill  */
    215  1.1  jmcneill struct smbios_processor {
    216  1.1  jmcneill 	uint8_t socket;		/* string */
    217  1.1  jmcneill 	uint8_t	type;
    218  1.1  jmcneill 	uint8_t	family;
    219  1.1  jmcneill 	uint8_t	vendor;		/* string */
    220  1.1  jmcneill 	uint64_t	cpuid;
    221  1.1  jmcneill 	uint8_t	version;	/* string */
    222  1.1  jmcneill 	uint8_t	voltage;
    223  1.1  jmcneill 	uint16_t	clkspeed;
    224  1.1  jmcneill 	uint16_t	maxspeed;
    225  1.1  jmcneill 	uint16_t	curspeed;
    226  1.1  jmcneill 	uint8_t	status;
    227  1.1  jmcneill 	uint8_t	upgrade;
    228  1.1  jmcneill 	uint8_t	l1cache;
    229  1.1  jmcneill 	uint8_t	l2cache;
    230  1.1  jmcneill 	uint8_t	l3cache;
    231  1.1  jmcneill 	uint8_t	serial;		/* string */
    232  1.1  jmcneill 	uint8_t	asset;		/* string */
    233  1.1  jmcneill 	uint8_t	part;		/* string */
    234  1.1  jmcneill 	uint8_t	cores;		/* cores per socket */
    235  1.1  jmcneill 	uint8_t	enabled;	/* enabled cores per socket */
    236  1.1  jmcneill 	uint8_t	threads;	/* threads per socket */
    237  1.1  jmcneill 	uint16_t	characteristics;
    238  1.1  jmcneill 	uint16_t	family2;	/* for values >= 255 */
    239  1.1  jmcneill 	uint16_t	cores2;		/* for values >= 255 */
    240  1.1  jmcneill 	uint16_t	enabled2;	/* for values >= 255 */
    241  1.1  jmcneill 	uint16_t	threads2;	/* for values >= 255 */
    242  1.1  jmcneill } __packed;
    243  1.1  jmcneill 
    244  1.1  jmcneill /*
    245  1.1  jmcneill  * SMBIOS Structure Type 9 "Expansion slot"
    246  1.1  jmcneill  */
    247  1.1  jmcneill struct smbios_slot {
    248  1.1  jmcneill 	uint8_t		designation;
    249  1.1  jmcneill 	uint8_t		type;
    250  1.1  jmcneill 	uint8_t		width;
    251  1.1  jmcneill 	uint8_t		usage;
    252  1.1  jmcneill 	uint8_t		length;
    253  1.1  jmcneill 	uint8_t		slotid[2];
    254  1.1  jmcneill 	uint8_t		characteristics[2];
    255  1.1  jmcneill } __packed;
    256  1.1  jmcneill 
    257  1.1  jmcneill #define	SMBIOS_SLOT_ISA		0x03
    258  1.1  jmcneill #define	SMBIOS_SLOT_EISA	0x05
    259  1.1  jmcneill 
    260  1.1  jmcneill /*
    261  1.1  jmcneill  * SMBIOS Structure Type 38 "IPMI Information"
    262  1.1  jmcneill  * DMTF Specification DSP0134 Section 3.3.39 p.g. 91
    263  1.1  jmcneill  */
    264  1.1  jmcneill struct smbios_ipmi {
    265  1.1  jmcneill         uint8_t        smipmi_if_type;         /* IPMI Interface Type */
    266  1.1  jmcneill         uint8_t        smipmi_if_rev;          /* BCD IPMI Revision */
    267  1.1  jmcneill         uint8_t        smipmi_i2c_address;     /* I2C address of BMC */
    268  1.1  jmcneill         uint8_t        smipmi_nvram_address;   /* I2C address of NVRAM
    269  1.1  jmcneill 						 * storage */
    270  1.1  jmcneill         uint64_t       smipmi_base_address;    /* Base address of BMC (BAR
    271  1.1  jmcneill 						 * format */
    272  1.1  jmcneill         uint8_t        smipmi_base_flags;      /* Flags field:
    273  1.1  jmcneill 						 * bit 7:6 : register spacing
    274  1.1  jmcneill 						 *   00 = byte
    275  1.1  jmcneill 						 *   01 = dword
    276  1.1  jmcneill 						 *   02 = word
    277  1.1  jmcneill 						 * bit 4 : Lower bit BAR
    278  1.1  jmcneill 						 * bit 3 : IRQ valid
    279  1.1  jmcneill 						 * bit 2 : N/A
    280  1.1  jmcneill 						 * bit 1 : Interrupt polarity
    281  1.1  jmcneill 						 * bit 0 : Interrupt trigger */
    282  1.1  jmcneill         uint8_t        smipmi_irq;             /* IRQ if applicable */
    283  1.1  jmcneill } __packed;
    284  1.1  jmcneill 
    285  1.1  jmcneill void smbios_init(uint8_t *);
    286  1.1  jmcneill int smbios_find_table(uint8_t, struct smbtable *);
    287  1.1  jmcneill char *smbios_get_string(struct smbtable *, uint8_t, char *, size_t);
    288