1/* $NetBSD: smbiosvar.h,v 1.3 2008/04/16 16:06:51 cegger 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#ifndef _I386_SMBIOSVAR_
29#define _I386_SMBIOSVAR_
30
31#define SMBIOS_START 0xf0000
32#define SMBIOS_END 0xfffff
33
34#define SMBIOS_UUID_NPRESENT 0x1
35#define SMBIOS_UUID_NSET 0x2
36
37/*
38 * Section 3.5 of "UUIDs and GUIDs" found at
39 * http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt
40 * specifies the string repersentation of a UUID.
41 */
42#define SMBIOS_UUID_REP "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
43#define SMBIOS_UUID_REPLEN 37 /* 16 zero padded values, 4 hyphens, 1 null */
44
45struct smbios_entry {
46 uint8_t mjr;
47 uint8_t min;
48 uint8_t *addr;
49 uint16_t len;
50 uint16_t count;
51};
52
53struct smbhdr {
54 uint32_t sig; /* "_SM_" */
55 uint8_t checksum; /* Entry point checksum */
56 uint8_t len; /* Entry point structure length */
57 uint8_t majrev; /* Specification major revision */
58 uint8_t minrev; /* Specification minor revision */
59 uint16_t mss; /* Maximum Structure Size */
60 uint8_t epr; /* Entry Point Revision */
61 uint8_t fa[5]; /* value determined by EPR */
62 uint8_t sasig[5]; /* Secondary Anchor "_DMI_" */
63 uint8_t sachecksum; /* Secondary Checksum */
64 uint16_t size; /* Length of structure table in bytes */
65 uint32_t addr; /* Structure table address */
66 uint16_t count; /* Number of SMBIOS structures */
67 uint8_t rev; /* BCD revision */
68} __packed;
69
70struct smbtblhdr {
71 uint8_t type;
72 uint8_t size;
73 uint16_t handle;
74} __packed;
75
76struct smbtable {
77 struct smbtblhdr *hdr;
78 void *tblhdr;
79 uint32_t cookie;
80};
81
82#define SMBIOS_TYPE_BIOS 0
83#define SMBIOS_TYPE_SYSTEM 1
84#define SMBIOS_TYPE_BASEBOARD 2
85#define SMBIOS_TYPE_ENCLOSURE 3
86#define SMBIOS_TYPE_PROCESSOR 4
87#define SMBIOS_TYPE_MEMCTRL 5
88#define SMBIOS_TYPE_MEMMOD 6
89#define SMBIOS_TYPE_CACHE 7
90#define SMBIOS_TYPE_PORT 8
91#define SMBIOS_TYPE_SLOTS 9
92#define SMBIOS_TYPE_OBD 10
93#define SMBIOS_TYPE_OEM 11
94#define SMBIOS_TYPE_SYSCONFOPT 12
95#define SMBIOS_TYPE_BIOSLANG 13
96#define SMBIOS_TYPE_GROUPASSOC 14
97#define SMBIOS_TYPE_SYSEVENTLOG 15
98#define SMBIOS_TYPE_PHYMEM 16
99#define SMBIOS_TYPE_MEMDEV 17
100#define SMBIOS_TYPE_ECCINFO32 18
101#define SMBIOS_TYPE_MEMMAPARRAYADDR 19
102#define SMBIOS_TYPE_MEMMAPDEVADDR 20
103#define SMBIOS_TYPE_INBUILTPOINT 21
104#define SMBIOS_TYPE_PORTBATT 22
105#define SMBIOS_TYPE_SYSRESET 23
106#define SMBIOS_TYPE_HWSECUIRTY 24
107#define SMBIOS_TYPE_PWRCTRL 25
108#define SMBIOS_TYPE_VOLTPROBE 26
109#define SMBIOS_TYPE_COOLING 27
110#define SMBIOS_TYPE_TEMPPROBE 28
111#define SMBIOS_TYPE_CURRENTPROBE 29
112#define SMBIOS_TYPE_OOB_REMOTEACCESS 30
113#define SMBIOS_TYPE_BIS 31
114#define SMBIOS_TYPE_SBI 32
115#define SMBIOS_TYPE_ECCINFO64 33
116#define SMBIOS_TYPE_MGMTDEV 34
117#define SMBIOS_TYPE_MGTDEVCOMP 35
118#define SMBIOS_TYPE_MGTDEVTHRESH 36
119#define SMBIOS_TYPE_MEMCHANNEL 37
120#define SMBIOS_TYPE_IPMIDEV 38
121#define SMBIOS_TYPE_SPS 39
122#define SMBIOS_TYPE_INACTIVE 126
123#define SMBIOS_TYPE_EOT 127
124
125/*
126 * SMBIOS Structure Type 0 "BIOS Information"
127 * DMTF Specification DSP0134 Section: 3.3.1 p.g. 34
128 */
129struct smbios_struct_bios {
130 uint8_t vendor; /* string */
131 uint8_t version; /* string */
132 uint16_t startaddr;
133 uint8_t release; /* string */
134 uint8_t romsize;
135 uint64_t characteristics;
136 uint32_t charext;
137 uint8_t major_rel;
138 uint8_t minor_rel;
139 uint8_t ecf_mjr_rel; /* embedded controler firmware */
140 uint8_t ecf_min_rel; /* embedded controler firmware */
141} __packed;
142
143/*
144 * SMBIOS Structure Type 1 "System Information"
145 * DMTF Specification DSP0134 Section 3.3.2 p.g. 35
146 */
147
148struct smbios_sys {
149/* SMBIOS spec 2.0+ */
150 uint8_t vendor; /* string */
151 uint8_t product; /* string */
152 uint8_t version; /* string */
153 uint8_t serial; /* string */
154/* SMBIOS spec 2.1+ */
155 uint8_t uuid[16];
156 uint8_t wakeup;
157/* SMBIOS spec 2.4+ */
158 uint8_t sku; /* string */
159 uint8_t family; /* string */
160} __packed;
161
162/*
163 * SMBIOS Structure Type 2 "Base Board (Module) Information"
164 * DMTF Specification DSP0134 Section 3.3.3 p.g. 37
165 */
166struct smbios_board {
167 uint8_t vendor; /* string */
168 uint8_t product; /* string */
169 uint8_t version; /* string */
170 uint8_t serial; /* string */
171 uint8_t asset; /* stirng */
172 uint8_t feature; /* feature flags */
173 uint8_t location; /* location in chassis */
174 uint16_t handle; /* chassis handle */
175 uint8_t type; /* board type */
176 uint8_t noc; /* number of contained objects */
177} __packed;
178
179/*
180 * SMBIOS Structure Type 9 "Expansion slot"
181 */
182struct smbios_slot {
183 uint8_t designation;
184 uint8_t type;
185 uint8_t width;
186 uint8_t usage;
187 uint8_t length;
188 uint8_t slotid[2];
189 uint8_t characteristics[2];
190} __packed;
191
192#define SMBIOS_SLOT_ISA 0x03
193#define SMBIOS_SLOT_EISA 0x05
194
195/*
196 * SMBIOS Structure Type 38 "IPMI Information"
197 * DMTF Specification DSP0134 Section 3.3.39 p.g. 91
198 */
199struct smbios_ipmi {
200 uint8_t smipmi_if_type; /* IPMI Interface Type */
201 uint8_t smipmi_if_rev; /* BCD IPMI Revision */
202 uint8_t smipmi_i2c_address; /* I2C address of BMC */
203 uint8_t smipmi_nvram_address; /* I2C address of NVRAM
204 * storage */
205 uint64_t smipmi_base_address; /* Base address of BMC (BAR
206 * format */
207 uint8_t smipmi_base_flags; /* Flags field:
208 * bit 7:6 : register spacing
209 * 00 = byte
210 * 01 = dword
211 * 02 = word
212 * bit 4 : Lower bit BAR
213 * bit 3 : IRQ valid
214 * bit 2 : N/A
215 * bit 1 : Interrupt polarity
216 * bit 0 : Interrupt trigger */
217 uint8_t smipmi_irq; /* IRQ if applicable */
218} __packed;
219
220int smbios_find_table(uint8_t, struct smbtable *);
221char *smbios_get_string(struct smbtable *, uint8_t, char *, size_t);
222
223#endif
224