xref: /freebsd/stand/libsa/smbios.c (revision 3e15b01d6914c927e37d1699645783acf286655c)
1a64f0b83SWarner Losh /*-
2a64f0b83SWarner Losh  * Copyright (c) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org>
3a64f0b83SWarner Losh  * All rights reserved.
4a64f0b83SWarner Losh  *
5a64f0b83SWarner Losh  * Redistribution and use in source and binary forms, with or without
6a64f0b83SWarner Losh  * modification, are permitted provided that the following conditions
7a64f0b83SWarner Losh  * are met:
8a64f0b83SWarner Losh  * 1. Redistributions of source code must retain the above copyright
9a64f0b83SWarner Losh  *	notice, this list of conditions and the following disclaimer.
10a64f0b83SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
11a64f0b83SWarner Losh  *	notice, this list of conditions and the following disclaimer in the
12a64f0b83SWarner Losh  *	documentation and/or other materials provided with the distribution.
13a64f0b83SWarner Losh  *
14a64f0b83SWarner Losh  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15a64f0b83SWarner Losh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16a64f0b83SWarner Losh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17a64f0b83SWarner Losh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18a64f0b83SWarner Losh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19a64f0b83SWarner Losh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20a64f0b83SWarner Losh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21a64f0b83SWarner Losh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22a64f0b83SWarner Losh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23a64f0b83SWarner Losh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24a64f0b83SWarner Losh  * SUCH DAMAGE.
25a64f0b83SWarner Losh  */
26a64f0b83SWarner Losh 
27a64f0b83SWarner Losh #include <stand.h>
28a64f0b83SWarner Losh #include <sys/endian.h>
29a64f0b83SWarner Losh 
30a64f0b83SWarner Losh #define PTOV(x)		ptov(x)
31a64f0b83SWarner Losh 
32ee97f198SJohn-Mark Gurney /* Only enable 64-bit entry point if it makes sense */
33ee97f198SJohn-Mark Gurney #if __SIZEOF_POINTER__ > 4
34ee97f198SJohn-Mark Gurney #define	HAS_SMBV3	1
35ee97f198SJohn-Mark Gurney #endif
36ee97f198SJohn-Mark Gurney 
37a64f0b83SWarner Losh /*
38a64f0b83SWarner Losh  * Detect SMBIOS and export information about the SMBIOS into the
39a64f0b83SWarner Losh  * environment.
40a64f0b83SWarner Losh  *
41a64f0b83SWarner Losh  * System Management BIOS Reference Specification, v2.6 Final
42a64f0b83SWarner Losh  * http://www.dmtf.org/standards/published_documents/DSP0134_2.6.0.pdf
43b5c3ade7SStephen J. Kiernan  *
44b5c3ade7SStephen J. Kiernan  * System Management BIOS (SMBIOS) Reference Specification, 3.6.0
45b5c3ade7SStephen J. Kiernan  * https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.6.0.pdf
46a64f0b83SWarner Losh  */
47a64f0b83SWarner Losh 
48a64f0b83SWarner Losh /*
49b5c3ade7SStephen J. Kiernan  * The first quoted paragraph below can also be found in section 2.1.1 SMBIOS
50b5c3ade7SStephen J. Kiernan  * Structure Table Entry Point of System Management BIOS Reference
51b5c3ade7SStephen J. Kiernan  * Specification, v2.6 Final
52a64f0b83SWarner Losh  *
53b5c3ade7SStephen J. Kiernan  * (From System Management BIOS (SMBIOS) Reference Specification, 3.6.0)
54b5c3ade7SStephen J. Kiernan  * 5.2.1 SMBIOS 2.1 (32-bit) Entry Point
55b5c3ade7SStephen J. Kiernan  *
56b5c3ade7SStephen J. Kiernan  * "On non-UEFI systems, the 32-bit SMBIOS Entry Point structure, can be
57b5c3ade7SStephen J. Kiernan  * located by application software by searching for the anchor-string on
58b5c3ade7SStephen J. Kiernan  * paragraph (16-byte) boundaries within the physical memory address
59b5c3ade7SStephen J. Kiernan  * range 000F0000h to 000FFFFFh. This entry point encapsulates an intermediate
60b5c3ade7SStephen J. Kiernan  * anchor string that is used by some existing DMI browsers.
61b5c3ade7SStephen J. Kiernan  *
62b5c3ade7SStephen J. Kiernan  * On UEFI-based systems, the SMBIOS Entry Point structure can be located by
63b5c3ade7SStephen J. Kiernan  * looking in the EFI Configuration Table for the SMBIOS GUID
64b5c3ade7SStephen J. Kiernan  * (SMBIOS_TABLE_GUID, {EB9D2D31-2D88-11D3-9A16-0090273FC14D}) and using the
65b5c3ade7SStephen J. Kiernan  * associated pointer. See section 4.6 of the UEFI Specification for details.
66b5c3ade7SStephen J. Kiernan  * See section 2.3 of the UEFI Specification for how to report the containing
67b5c3ade7SStephen J. Kiernan  * memory type.
68b5c3ade7SStephen J. Kiernan  *
69b5c3ade7SStephen J. Kiernan  * NOTE While the SMBIOS Major and Minor Versions (offsets 06h and 07h)
70b5c3ade7SStephen J. Kiernan  * currently duplicate the information that is present in the SMBIOS BCD
71b5c3ade7SStephen J. Kiernan  * Revision (offset 1Eh), they provide a path for future growth in this
72b5c3ade7SStephen J. Kiernan  * specification. The BCD Revision, for example, provides only a single digit
73b5c3ade7SStephen J. Kiernan  * for each of the major and minor version numbers."
74b5c3ade7SStephen J. Kiernan  *
75b5c3ade7SStephen J. Kiernan  * 5.2.2 SMBIOS 860 3.0 (64-bit) Entry Point
76b5c3ade7SStephen J. Kiernan  *
77b5c3ade7SStephen J. Kiernan  * "On non-UEFI systems, the 64-bit SMBIOS Entry Point structure can be located
78b5c3ade7SStephen J. Kiernan  * by application software by searching for the anchor-string on paragraph
79b5c3ade7SStephen J. Kiernan  * (16-byte) boundaries within the physical memory address range 000F0000h to
80b5c3ade7SStephen J. Kiernan  * 000FFFFFh.
81b5c3ade7SStephen J. Kiernan  *
82b5c3ade7SStephen J. Kiernan  * On UEFI-based systems, the SMBIOS Entry Point structure can be located by
83b5c3ade7SStephen J. Kiernan  * looking in the EFI Configuration Table for the SMBIOS 3.x GUID
84b5c3ade7SStephen J. Kiernan  * (SMBIOS3_TABLE_GUID, {F2FD1544-9794-4A2C-992E-E5BBCF20E394}) and using the
85b5c3ade7SStephen J. Kiernan  * associated pointer. See section 4.6 of the UEFI Specification for details.
86b5c3ade7SStephen J. Kiernan  * See section 2.3 of the UEFI Specification for how to report the containing
87b5c3ade7SStephen J. Kiernan  * memory type."
88a64f0b83SWarner Losh  */
89a64f0b83SWarner Losh #define	SMBIOS_START		0xf0000
90a64f0b83SWarner Losh #define	SMBIOS_LENGTH		0x10000
91a64f0b83SWarner Losh #define	SMBIOS_STEP		0x10
92a64f0b83SWarner Losh #define	SMBIOS_SIG		"_SM_"
93ee97f198SJohn-Mark Gurney #define	SMBIOS3_SIG		"_SM3_"
94a64f0b83SWarner Losh #define	SMBIOS_DMI_SIG		"_DMI_"
95a64f0b83SWarner Losh 
96c5e433b9SWarner Losh /*
97c5e433b9SWarner Losh  * 5.1 General
98c5e433b9SWarner Losh  *...
99c5e433b9SWarner Losh  * NOTE The Entry Point Structure and all SMBIOS structures assume a
100c5e433b9SWarner Losh  * little-endian ordering convention...
101c5e433b9SWarner Losh  * ...
102c5e433b9SWarner Losh  *
103c5e433b9SWarner Losh  * We use memcpy to avoid unaligned access to memory. To normal memory, this is
104c5e433b9SWarner Losh  * fine, but the memory we are using might be mmap'd /dev/mem which under Linux
105c5e433b9SWarner Losh  * on aarch64 doesn't allow unaligned access. leXdec and friends can't be used
106c5e433b9SWarner Losh  * because those can optimize to an unaligned load (which often is fine, but not
107c5e433b9SWarner Losh  * for mmap'd /dev/mem which has special memory attributes).
108c5e433b9SWarner Losh  */
SMBIOS_GET8(const caddr_t base,int off)109c5e433b9SWarner Losh static inline uint8_t SMBIOS_GET8(const caddr_t base, int off) { return (base[off]); }
110c5e433b9SWarner Losh 
111c5e433b9SWarner Losh static inline uint16_t
SMBIOS_GET16(const caddr_t base,int off)112c5e433b9SWarner Losh SMBIOS_GET16(const caddr_t base, int off)
113c5e433b9SWarner Losh {
114c5e433b9SWarner Losh 	uint16_t v;
115c5e433b9SWarner Losh 
116c5e433b9SWarner Losh 	memcpy(&v, base + off, sizeof(v));
117c5e433b9SWarner Losh 	return (le16toh(v));
118c5e433b9SWarner Losh }
119c5e433b9SWarner Losh 
120c5e433b9SWarner Losh static inline uint32_t
SMBIOS_GET32(const caddr_t base,int off)121c5e433b9SWarner Losh SMBIOS_GET32(const caddr_t base, int off)
122c5e433b9SWarner Losh {
123c5e433b9SWarner Losh 	uint32_t v;
124c5e433b9SWarner Losh 
125c5e433b9SWarner Losh 	memcpy(&v, base + off, sizeof(v));
126c5e433b9SWarner Losh 	return (le32toh(v));
127c5e433b9SWarner Losh }
128c5e433b9SWarner Losh 
129c5e433b9SWarner Losh static inline uint64_t
SMBIOS_GET64(const caddr_t base,int off)130c5e433b9SWarner Losh SMBIOS_GET64(const caddr_t base, int off)
131c5e433b9SWarner Losh {
132c5e433b9SWarner Losh 	uint64_t v;
133c5e433b9SWarner Losh 
134c5e433b9SWarner Losh 	memcpy(&v, base + off, sizeof(v));
135c5e433b9SWarner Losh 	return (le64toh(v));
136c5e433b9SWarner Losh }
137a64f0b83SWarner Losh 
138a64f0b83SWarner Losh #define	SMBIOS_GETLEN(base)	SMBIOS_GET8(base, 0x01)
139a64f0b83SWarner Losh #define	SMBIOS_GETSTR(base)	((base) + SMBIOS_GETLEN(base))
140a64f0b83SWarner Losh 
141a64f0b83SWarner Losh struct smbios_attr {
142a64f0b83SWarner Losh 	int		probed;
143a64f0b83SWarner Losh 	caddr_t 	addr;
144a64f0b83SWarner Losh 	size_t		length;
145a64f0b83SWarner Losh 	size_t		count;
146a64f0b83SWarner Losh 	int		major;
147a64f0b83SWarner Losh 	int		minor;
148a64f0b83SWarner Losh 	int		ver;
149a64f0b83SWarner Losh 	const char*	bios_vendor;
150a64f0b83SWarner Losh 	const char*	maker;
151a64f0b83SWarner Losh 	const char*	product;
152a64f0b83SWarner Losh 	uint32_t	enabled_memory;
153a64f0b83SWarner Losh 	uint32_t	old_enabled_memory;
154a64f0b83SWarner Losh 	uint8_t		enabled_sockets;
155a64f0b83SWarner Losh 	uint8_t		populated_sockets;
156a64f0b83SWarner Losh };
157a64f0b83SWarner Losh 
158a64f0b83SWarner Losh static struct smbios_attr smbios;
159ee97f198SJohn-Mark Gurney #ifdef HAS_SMBV3
160ee97f198SJohn-Mark Gurney static int isv3;
161ee97f198SJohn-Mark Gurney #endif
162a64f0b83SWarner Losh 
163a64f0b83SWarner Losh static uint8_t
smbios_checksum(const caddr_t addr,const uint8_t len)164a64f0b83SWarner Losh smbios_checksum(const caddr_t addr, const uint8_t len)
165a64f0b83SWarner Losh {
166a64f0b83SWarner Losh 	uint8_t		sum;
167a64f0b83SWarner Losh 	int		i;
168a64f0b83SWarner Losh 
169a64f0b83SWarner Losh 	for (sum = 0, i = 0; i < len; i++)
170a64f0b83SWarner Losh 		sum += SMBIOS_GET8(addr, i);
171a64f0b83SWarner Losh 	return (sum);
172a64f0b83SWarner Losh }
173a64f0b83SWarner Losh 
174a64f0b83SWarner Losh static caddr_t
smbios_sigsearch(const caddr_t addr,const uint32_t len)175a64f0b83SWarner Losh smbios_sigsearch(const caddr_t addr, const uint32_t len)
176a64f0b83SWarner Losh {
177a64f0b83SWarner Losh 	caddr_t		cp;
178a64f0b83SWarner Losh 
179a64f0b83SWarner Losh 	/* Search on 16-byte boundaries. */
180ee97f198SJohn-Mark Gurney 	for (cp = addr; cp < addr + len; cp += SMBIOS_STEP) {
181ee97f198SJohn-Mark Gurney 		/* v2.1, 32-bit Entry point */
182ee97f198SJohn-Mark Gurney 		if (strncmp(cp, SMBIOS_SIG, sizeof(SMBIOS_SIG) - 1) == 0 &&
183a64f0b83SWarner Losh 		    smbios_checksum(cp, SMBIOS_GET8(cp, 0x05)) == 0 &&
184a64f0b83SWarner Losh 		    strncmp(cp + 0x10, SMBIOS_DMI_SIG, 5) == 0 &&
185a64f0b83SWarner Losh 		    smbios_checksum(cp + 0x10, 0x0f) == 0)
186a64f0b83SWarner Losh 			return (cp);
187ee97f198SJohn-Mark Gurney 
188ee97f198SJohn-Mark Gurney #ifdef HAS_SMBV3
189ee97f198SJohn-Mark Gurney 		/* v3.0, 64-bit Entry point */
190ee97f198SJohn-Mark Gurney 		if (strncmp(cp, SMBIOS3_SIG, sizeof(SMBIOS3_SIG) - 1) == 0 &&
191ee97f198SJohn-Mark Gurney 		    smbios_checksum(cp, SMBIOS_GET8(cp, 0x06)) == 0) {
192ee97f198SJohn-Mark Gurney 			isv3 = 1;
193ee97f198SJohn-Mark Gurney 			return (cp);
194ee97f198SJohn-Mark Gurney 		}
195ee97f198SJohn-Mark Gurney #endif
196ee97f198SJohn-Mark Gurney 	}
197a64f0b83SWarner Losh 	return (NULL);
198a64f0b83SWarner Losh }
199a64f0b83SWarner Losh 
200a64f0b83SWarner Losh static const char*
smbios_getstring(caddr_t addr,const int offset)201a64f0b83SWarner Losh smbios_getstring(caddr_t addr, const int offset)
202a64f0b83SWarner Losh {
203a64f0b83SWarner Losh 	caddr_t		cp;
204a64f0b83SWarner Losh 	int		i, idx;
205a64f0b83SWarner Losh 
206a64f0b83SWarner Losh 	idx = SMBIOS_GET8(addr, offset);
207a64f0b83SWarner Losh 	if (idx != 0) {
208a64f0b83SWarner Losh 		cp = SMBIOS_GETSTR(addr);
209a64f0b83SWarner Losh 		for (i = 1; i < idx; i++)
210a64f0b83SWarner Losh 			cp += strlen(cp) + 1;
211a64f0b83SWarner Losh 		return cp;
212a64f0b83SWarner Losh 	}
213a64f0b83SWarner Losh 	return (NULL);
214a64f0b83SWarner Losh }
215a64f0b83SWarner Losh 
216a64f0b83SWarner Losh static void
smbios_setenv(const char * name,caddr_t addr,const int offset)217a64f0b83SWarner Losh smbios_setenv(const char *name, caddr_t addr, const int offset)
218a64f0b83SWarner Losh {
219a64f0b83SWarner Losh 	const char*	val;
220a64f0b83SWarner Losh 
221a64f0b83SWarner Losh 	val = smbios_getstring(addr, offset);
222a64f0b83SWarner Losh 	if (val != NULL)
223a64f0b83SWarner Losh 		setenv(name, val, 1);
224a64f0b83SWarner Losh }
225a64f0b83SWarner Losh 
226a64f0b83SWarner Losh #ifdef SMBIOS_SERIAL_NUMBERS
227a64f0b83SWarner Losh 
228a64f0b83SWarner Losh #define	UUID_SIZE		16
229a64f0b83SWarner Losh #define	UUID_TYPE		uint32_t
230a64f0b83SWarner Losh #define	UUID_STEP		sizeof(UUID_TYPE)
231a64f0b83SWarner Losh #define	UUID_ALL_BITS		(UUID_SIZE / UUID_STEP)
232c5e433b9SWarner Losh #define	UUID_GET(base, off)	SMBIOS_GET32(base, off)
233a64f0b83SWarner Losh 
234a64f0b83SWarner Losh static void
smbios_setuuid(const char * name,const caddr_t addr,const int ver __unused)23516e9ec44SWarner Losh smbios_setuuid(const char *name, const caddr_t addr, const int ver __unused)
236a64f0b83SWarner Losh {
237a64f0b83SWarner Losh 	char		uuid[37];
238a64f0b83SWarner Losh 	int		byteorder, i, ones, zeros;
239a64f0b83SWarner Losh 	UUID_TYPE	n;
240a64f0b83SWarner Losh 	uint32_t	f1;
241a64f0b83SWarner Losh 	uint16_t	f2, f3;
242a64f0b83SWarner Losh 
243a64f0b83SWarner Losh 	for (i = 0, ones = 0, zeros = 0; i < UUID_SIZE; i += UUID_STEP) {
244a64f0b83SWarner Losh 		n = UUID_GET(addr, i) + 1;
245a64f0b83SWarner Losh 		if (zeros == 0 && n == 0)
246a64f0b83SWarner Losh 			ones++;
247a64f0b83SWarner Losh 		else if (ones == 0 && n == 1)
248a64f0b83SWarner Losh 			zeros++;
249a64f0b83SWarner Losh 		else
250a64f0b83SWarner Losh 			break;
251a64f0b83SWarner Losh 	}
252a64f0b83SWarner Losh 
253a64f0b83SWarner Losh 	if (ones != UUID_ALL_BITS && zeros != UUID_ALL_BITS) {
254a64f0b83SWarner Losh 		/*
255a64f0b83SWarner Losh 		 * 3.3.2.1 System UUID
256a64f0b83SWarner Losh 		 *
257a64f0b83SWarner Losh 		 * "Although RFC 4122 recommends network byte order for all
258a64f0b83SWarner Losh 		 * fields, the PC industry (including the ACPI, UEFI, and
259a64f0b83SWarner Losh 		 * Microsoft specifications) has consistently used
260a64f0b83SWarner Losh 		 * little-endian byte encoding for the first three fields:
261a64f0b83SWarner Losh 		 * time_low, time_mid, time_hi_and_version. The same encoding,
262a64f0b83SWarner Losh 		 * also known as wire format, should also be used for the
263a64f0b83SWarner Losh 		 * SMBIOS representation of the UUID."
264a64f0b83SWarner Losh 		 *
265a64f0b83SWarner Losh 		 * Note: We use network byte order for backward compatibility
266a64f0b83SWarner Losh 		 * unless SMBIOS version is 2.6+ or little-endian is forced.
267a64f0b83SWarner Losh 		 */
268a64f0b83SWarner Losh #if defined(SMBIOS_LITTLE_ENDIAN_UUID)
269a64f0b83SWarner Losh 		byteorder = LITTLE_ENDIAN;
270a64f0b83SWarner Losh #elif defined(SMBIOS_NETWORK_ENDIAN_UUID)
271a64f0b83SWarner Losh 		byteorder = BIG_ENDIAN;
272a64f0b83SWarner Losh #else
273a64f0b83SWarner Losh 		byteorder = ver < 0x0206 ? BIG_ENDIAN : LITTLE_ENDIAN;
274a64f0b83SWarner Losh #endif
275a64f0b83SWarner Losh 		if (byteorder != LITTLE_ENDIAN) {
276a64f0b83SWarner Losh 			f1 = ntohl(SMBIOS_GET32(addr, 0));
277a64f0b83SWarner Losh 			f2 = ntohs(SMBIOS_GET16(addr, 4));
278a64f0b83SWarner Losh 			f3 = ntohs(SMBIOS_GET16(addr, 6));
279a64f0b83SWarner Losh 		} else {
280a64f0b83SWarner Losh 			f1 = le32toh(SMBIOS_GET32(addr, 0));
281a64f0b83SWarner Losh 			f2 = le16toh(SMBIOS_GET16(addr, 4));
282a64f0b83SWarner Losh 			f3 = le16toh(SMBIOS_GET16(addr, 6));
283a64f0b83SWarner Losh 		}
284a64f0b83SWarner Losh 		sprintf(uuid,
285a64f0b83SWarner Losh 		    "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
286a64f0b83SWarner Losh 		    f1, f2, f3, SMBIOS_GET8(addr, 8), SMBIOS_GET8(addr, 9),
287a64f0b83SWarner Losh 		    SMBIOS_GET8(addr, 10), SMBIOS_GET8(addr, 11),
288a64f0b83SWarner Losh 		    SMBIOS_GET8(addr, 12), SMBIOS_GET8(addr, 13),
289a64f0b83SWarner Losh 		    SMBIOS_GET8(addr, 14), SMBIOS_GET8(addr, 15));
290a64f0b83SWarner Losh 		setenv(name, uuid, 1);
291a64f0b83SWarner Losh 	}
292a64f0b83SWarner Losh }
293a64f0b83SWarner Losh 
294a64f0b83SWarner Losh #undef UUID_SIZE
295a64f0b83SWarner Losh #undef UUID_TYPE
296a64f0b83SWarner Losh #undef UUID_STEP
297a64f0b83SWarner Losh #undef UUID_ALL_BITS
298a64f0b83SWarner Losh #undef UUID_GET
299a64f0b83SWarner Losh 
300a64f0b83SWarner Losh #endif
301a64f0b83SWarner Losh 
3029060f2c3SEmmanuel Vadot static const char *
smbios_parse_chassis_type(caddr_t addr)3039060f2c3SEmmanuel Vadot smbios_parse_chassis_type(caddr_t addr)
3049060f2c3SEmmanuel Vadot {
3059060f2c3SEmmanuel Vadot 	int		type;
3069060f2c3SEmmanuel Vadot 
3079060f2c3SEmmanuel Vadot 	type = SMBIOS_GET8(addr, 0x5);
3089060f2c3SEmmanuel Vadot 	switch (type) {
3099060f2c3SEmmanuel Vadot 	case 0x1:
3109060f2c3SEmmanuel Vadot 		return ("Other");
3119060f2c3SEmmanuel Vadot 	case 0x2:
3129060f2c3SEmmanuel Vadot 		return ("Unknown");
3139060f2c3SEmmanuel Vadot 	case 0x3:
3149060f2c3SEmmanuel Vadot 		return ("Desktop");
3159060f2c3SEmmanuel Vadot 	case 0x4:
3169060f2c3SEmmanuel Vadot 		return ("Low Profile Desktop");
3179060f2c3SEmmanuel Vadot 	case 0x5:
3189060f2c3SEmmanuel Vadot 		return ("Pizza Box");
3199060f2c3SEmmanuel Vadot 	case 0x6:
3209060f2c3SEmmanuel Vadot 		return ("Mini Tower");
3219060f2c3SEmmanuel Vadot 	case 0x7:
3229060f2c3SEmmanuel Vadot 		return ("Tower");
3239060f2c3SEmmanuel Vadot 	case 0x8:
3249060f2c3SEmmanuel Vadot 		return ("Portable");
3259060f2c3SEmmanuel Vadot 	case 0x9:
3269060f2c3SEmmanuel Vadot 		return ("Laptop");
3279060f2c3SEmmanuel Vadot 	case 0xA:
3289060f2c3SEmmanuel Vadot 		return ("Notebook");
3299060f2c3SEmmanuel Vadot 	case 0xB:
3309060f2c3SEmmanuel Vadot 		return ("Hand Held");
3319060f2c3SEmmanuel Vadot 	case 0xC:
3329060f2c3SEmmanuel Vadot 		return ("Docking Station");
3339060f2c3SEmmanuel Vadot 	case 0xD:
3349060f2c3SEmmanuel Vadot 		return ("All in One");
3359060f2c3SEmmanuel Vadot 	case 0xE:
3369060f2c3SEmmanuel Vadot 		return ("Sub Notebook");
3379060f2c3SEmmanuel Vadot 	case 0xF:
3389060f2c3SEmmanuel Vadot 		return ("Lunch Box");
3399060f2c3SEmmanuel Vadot 	case 0x10:
3409060f2c3SEmmanuel Vadot 		return ("Space-saving");
3419060f2c3SEmmanuel Vadot 	case 0x11:
3429060f2c3SEmmanuel Vadot 		return ("Main Server Chassis");
3439060f2c3SEmmanuel Vadot 	case 0x12:
3449060f2c3SEmmanuel Vadot 		return ("Expansion Chassis");
3459060f2c3SEmmanuel Vadot 	case 0x13:
3469060f2c3SEmmanuel Vadot 		return ("SubChassis");
3479060f2c3SEmmanuel Vadot 	case 0x14:
3489060f2c3SEmmanuel Vadot 		return ("Bus Expansion Chassis");
3499060f2c3SEmmanuel Vadot 	case 0x15:
3509060f2c3SEmmanuel Vadot 		return ("Peripheral Chassis");
3519060f2c3SEmmanuel Vadot 	case 0x16:
3529060f2c3SEmmanuel Vadot 		return ("RAID Chassis");
3539060f2c3SEmmanuel Vadot 	case 0x17:
3549060f2c3SEmmanuel Vadot 		return ("Rack Mount Chassis");
3559060f2c3SEmmanuel Vadot 	case 0x18:
3569060f2c3SEmmanuel Vadot 		return ("Sealed-case PC");
3579060f2c3SEmmanuel Vadot 	case 0x19:
3589060f2c3SEmmanuel Vadot 		return ("Multi-system chassis");
3599060f2c3SEmmanuel Vadot 	case 0x1A:
3609060f2c3SEmmanuel Vadot 		return ("Compact PCI");
3619060f2c3SEmmanuel Vadot 	case 0x1B:
3629060f2c3SEmmanuel Vadot 		return ("Advanced TCA");
3639060f2c3SEmmanuel Vadot 	case 0x1C:
3649060f2c3SEmmanuel Vadot 		return ("Blade");
3659060f2c3SEmmanuel Vadot 	case 0x1D:
3669060f2c3SEmmanuel Vadot 		return ("Blade Enclosure");
3679060f2c3SEmmanuel Vadot 	case 0x1E:
3689060f2c3SEmmanuel Vadot 		return ("Tablet");
3699060f2c3SEmmanuel Vadot 	case 0x1F:
3709060f2c3SEmmanuel Vadot 		return ("Convertible");
3719060f2c3SEmmanuel Vadot 	case 0x20:
3729060f2c3SEmmanuel Vadot 		return ("Detachable");
3739060f2c3SEmmanuel Vadot 	case 0x21:
3749060f2c3SEmmanuel Vadot 		return ("IoT Gateway");
3759060f2c3SEmmanuel Vadot 	case 0x22:
3769060f2c3SEmmanuel Vadot 		return ("Embedded PC");
3779060f2c3SEmmanuel Vadot 	case 0x23:
3789060f2c3SEmmanuel Vadot 		return ("Mini PC");
3799060f2c3SEmmanuel Vadot 	case 0x24:
3809060f2c3SEmmanuel Vadot 		return ("Stick PC");
3819060f2c3SEmmanuel Vadot 	}
3829060f2c3SEmmanuel Vadot 
3839060f2c3SEmmanuel Vadot 	return ("Undefined");
3849060f2c3SEmmanuel Vadot }
3859060f2c3SEmmanuel Vadot 
386a64f0b83SWarner Losh static caddr_t
smbios_parse_table(const caddr_t addr)387a64f0b83SWarner Losh smbios_parse_table(const caddr_t addr)
388a64f0b83SWarner Losh {
389a64f0b83SWarner Losh 	caddr_t		cp;
390a64f0b83SWarner Losh 	int		proc, size, osize, type;
39166c73af7SKornel Dulęba 	uint8_t		bios_minor, bios_major;
39266c73af7SKornel Dulęba 	char		buf[16];
393a64f0b83SWarner Losh 
394a64f0b83SWarner Losh 	type = SMBIOS_GET8(addr, 0);	/* 3.1.2 Structure Header Format */
395a64f0b83SWarner Losh 	switch(type) {
396a64f0b83SWarner Losh 	case 0:		/* 3.3.1 BIOS Information (Type 0) */
397a64f0b83SWarner Losh 		smbios_setenv("smbios.bios.vendor", addr, 0x04);
398a64f0b83SWarner Losh 		smbios_setenv("smbios.bios.version", addr, 0x05);
399a64f0b83SWarner Losh 		smbios_setenv("smbios.bios.reldate", addr, 0x08);
40066c73af7SKornel Dulęba 		bios_major = SMBIOS_GET8(addr, 0x14);
40166c73af7SKornel Dulęba 		bios_minor = SMBIOS_GET8(addr, 0x15);
40266c73af7SKornel Dulęba 		if (bios_minor != 0xFF && bios_major != 0xFF) {
40366c73af7SKornel Dulęba 			snprintf(buf, sizeof(buf), "%u.%u",
40466c73af7SKornel Dulęba 			    bios_major, bios_minor);
40566c73af7SKornel Dulęba 			setenv("smbios.bios.revision", buf, 1);
40666c73af7SKornel Dulęba 		}
407a64f0b83SWarner Losh 		break;
408a64f0b83SWarner Losh 
409a64f0b83SWarner Losh 	case 1:		/* 3.3.2 System Information (Type 1) */
410a64f0b83SWarner Losh 		smbios_setenv("smbios.system.maker", addr, 0x04);
411a64f0b83SWarner Losh 		smbios_setenv("smbios.system.product", addr, 0x05);
412a64f0b83SWarner Losh 		smbios_setenv("smbios.system.version", addr, 0x06);
413a64f0b83SWarner Losh #ifdef SMBIOS_SERIAL_NUMBERS
414a64f0b83SWarner Losh 		smbios_setenv("smbios.system.serial", addr, 0x07);
415a64f0b83SWarner Losh 		smbios_setuuid("smbios.system.uuid", addr + 0x08, smbios.ver);
416a64f0b83SWarner Losh #endif
417a64f0b83SWarner Losh 		if (smbios.major > 2 ||
418a64f0b83SWarner Losh 		    (smbios.major == 2 && smbios.minor >= 4)) {
419a64f0b83SWarner Losh 			smbios_setenv("smbios.system.sku", addr, 0x19);
420a64f0b83SWarner Losh 			smbios_setenv("smbios.system.family", addr, 0x1a);
421a64f0b83SWarner Losh 		}
422a64f0b83SWarner Losh 		break;
423a64f0b83SWarner Losh 
424a64f0b83SWarner Losh 	case 2:		/* 3.3.3 Base Board (or Module) Information (Type 2) */
425a64f0b83SWarner Losh 		smbios_setenv("smbios.planar.maker", addr, 0x04);
426a64f0b83SWarner Losh 		smbios_setenv("smbios.planar.product", addr, 0x05);
427a64f0b83SWarner Losh 		smbios_setenv("smbios.planar.version", addr, 0x06);
428a64f0b83SWarner Losh #ifdef SMBIOS_SERIAL_NUMBERS
429a64f0b83SWarner Losh 		smbios_setenv("smbios.planar.serial", addr, 0x07);
430a64f0b83SWarner Losh 		smbios_setenv("smbios.planar.tag", addr, 0x08);
431a64f0b83SWarner Losh #endif
432a64f0b83SWarner Losh 		smbios_setenv("smbios.planar.location", addr, 0x0a);
433a64f0b83SWarner Losh 		break;
434a64f0b83SWarner Losh 
435a64f0b83SWarner Losh 	case 3:		/* 3.3.4 System Enclosure or Chassis (Type 3) */
436a64f0b83SWarner Losh 		smbios_setenv("smbios.chassis.maker", addr, 0x04);
4379060f2c3SEmmanuel Vadot 		setenv("smbios.chassis.type", smbios_parse_chassis_type(addr), 1);
438a64f0b83SWarner Losh 		smbios_setenv("smbios.chassis.version", addr, 0x06);
439a64f0b83SWarner Losh #ifdef SMBIOS_SERIAL_NUMBERS
440a64f0b83SWarner Losh 		smbios_setenv("smbios.chassis.serial", addr, 0x07);
441a64f0b83SWarner Losh 		smbios_setenv("smbios.chassis.tag", addr, 0x08);
442a64f0b83SWarner Losh #endif
443a64f0b83SWarner Losh 		break;
444a64f0b83SWarner Losh 
445a64f0b83SWarner Losh 	case 4:		/* 3.3.5 Processor Information (Type 4) */
446a64f0b83SWarner Losh 		/*
447a64f0b83SWarner Losh 		 * Offset 18h: Processor Status
448a64f0b83SWarner Losh 		 *
449a64f0b83SWarner Losh 		 * Bit 7	Reserved, must be 0
450a64f0b83SWarner Losh 		 * Bit 6	CPU Socket Populated
451a64f0b83SWarner Losh 		 *		1 - CPU Socket Populated
452a64f0b83SWarner Losh 		 *		0 - CPU Socket Unpopulated
453a64f0b83SWarner Losh 		 * Bit 5:3	Reserved, must be zero
454a64f0b83SWarner Losh 		 * Bit 2:0	CPU Status
455a64f0b83SWarner Losh 		 *		0h - Unknown
456a64f0b83SWarner Losh 		 *		1h - CPU Enabled
457a64f0b83SWarner Losh 		 *		2h - CPU Disabled by User via BIOS Setup
458a64f0b83SWarner Losh 		 *		3h - CPU Disabled by BIOS (POST Error)
459a64f0b83SWarner Losh 		 *		4h - CPU is Idle, waiting to be enabled
460a64f0b83SWarner Losh 		 *		5-6h - Reserved
461a64f0b83SWarner Losh 		 *		7h - Other
462a64f0b83SWarner Losh 		 */
463a64f0b83SWarner Losh 		proc = SMBIOS_GET8(addr, 0x18);
464a64f0b83SWarner Losh 		if ((proc & 0x07) == 1)
465a64f0b83SWarner Losh 			smbios.enabled_sockets++;
466a64f0b83SWarner Losh 		if ((proc & 0x40) != 0)
467a64f0b83SWarner Losh 			smbios.populated_sockets++;
468a64f0b83SWarner Losh 		break;
469a64f0b83SWarner Losh 
470a64f0b83SWarner Losh 	case 6:		/* 3.3.7 Memory Module Information (Type 6, Obsolete) */
471a64f0b83SWarner Losh 		/*
472a64f0b83SWarner Losh 		 * Offset 0Ah: Enabled Size
473a64f0b83SWarner Losh 		 *
474a64f0b83SWarner Losh 		 * Bit 7	Bank connection
475a64f0b83SWarner Losh 		 *		1 - Double-bank connection
476a64f0b83SWarner Losh 		 *		0 - Single-bank connection
477a64f0b83SWarner Losh 		 * Bit 6:0	Size (n), where 2**n is the size in MB
478a64f0b83SWarner Losh 		 *		7Dh - Not determinable (Installed Size only)
479a64f0b83SWarner Losh 		 *		7Eh - Module is installed, but no memory
480a64f0b83SWarner Losh 		 *		      has been enabled
481a64f0b83SWarner Losh 		 *		7Fh - Not installed
482a64f0b83SWarner Losh 		 */
483a64f0b83SWarner Losh 		osize = SMBIOS_GET8(addr, 0x0a) & 0x7f;
484a64f0b83SWarner Losh 		if (osize > 0 && osize < 22)
485a64f0b83SWarner Losh 			smbios.old_enabled_memory += 1 << (osize + 10);
486a64f0b83SWarner Losh 		break;
487a64f0b83SWarner Losh 
488a64f0b83SWarner Losh 	case 17:	/* 3.3.18 Memory Device (Type 17) */
489a64f0b83SWarner Losh 		/*
490a64f0b83SWarner Losh 		 * Offset 0Ch: Size
491a64f0b83SWarner Losh 		 *
492a64f0b83SWarner Losh 		 * Bit 15	Granularity
493a64f0b83SWarner Losh 		 *		1 - Value is in kilobytes units
494a64f0b83SWarner Losh 		 *		0 - Value is in megabytes units
495a64f0b83SWarner Losh 		 * Bit 14:0	Size
496a64f0b83SWarner Losh 		 */
497a64f0b83SWarner Losh 		size = SMBIOS_GET16(addr, 0x0c);
498a64f0b83SWarner Losh 		if (size != 0 && size != 0xffff)
499a64f0b83SWarner Losh 			smbios.enabled_memory += (size & 0x8000) != 0 ?
500a64f0b83SWarner Losh 			    (size & 0x7fff) : (size << 10);
501a64f0b83SWarner Losh 		break;
502a64f0b83SWarner Losh 
503a64f0b83SWarner Losh 	default:	/* skip other types */
504a64f0b83SWarner Losh 		break;
505a64f0b83SWarner Losh 	}
506a64f0b83SWarner Losh 
507a64f0b83SWarner Losh 	/* Find structure terminator. */
508a64f0b83SWarner Losh 	cp = SMBIOS_GETSTR(addr);
509a64f0b83SWarner Losh 	while (SMBIOS_GET16(cp, 0) != 0)
510a64f0b83SWarner Losh 		cp++;
511a64f0b83SWarner Losh 
512a64f0b83SWarner Losh 	return (cp + 2);
513a64f0b83SWarner Losh }
514a64f0b83SWarner Losh 
515a64f0b83SWarner Losh static caddr_t
smbios_find_struct(int type)516a64f0b83SWarner Losh smbios_find_struct(int type)
517a64f0b83SWarner Losh {
518a64f0b83SWarner Losh 	caddr_t		dmi;
519a64f0b83SWarner Losh 	size_t		i;
520*a5b4ec52SWarner Losh 	caddr_t		ep;
521a64f0b83SWarner Losh 
522a64f0b83SWarner Losh 	if (smbios.addr == NULL)
523a64f0b83SWarner Losh 		return (NULL);
524a64f0b83SWarner Losh 
525*a5b4ec52SWarner Losh 	ep = smbios.addr + smbios.length;
526a64f0b83SWarner Losh 	for (dmi = smbios.addr, i = 0;
527*a5b4ec52SWarner Losh 	     dmi < ep && i < smbios.count; i++) {
528*a5b4ec52SWarner Losh 		if (SMBIOS_GET8(dmi, 0) == type) {
529a64f0b83SWarner Losh 			return dmi;
530*a5b4ec52SWarner Losh 		}
531a64f0b83SWarner Losh 		/* Find structure terminator. */
532a64f0b83SWarner Losh 		dmi = SMBIOS_GETSTR(dmi);
533*a5b4ec52SWarner Losh 		while (SMBIOS_GET16(dmi, 0) != 0 && dmi < ep) {
534a64f0b83SWarner Losh 			dmi++;
535*a5b4ec52SWarner Losh 		}
536*a5b4ec52SWarner Losh 		dmi += 2;	/* For checksum */
537a64f0b83SWarner Losh 	}
538a64f0b83SWarner Losh 
539a64f0b83SWarner Losh 	return (NULL);
540a64f0b83SWarner Losh }
541a64f0b83SWarner Losh 
542a64f0b83SWarner Losh static void
smbios_probe(const caddr_t addr)543a64f0b83SWarner Losh smbios_probe(const caddr_t addr)
544a64f0b83SWarner Losh {
545a64f0b83SWarner Losh 	caddr_t		saddr, info;
546a64f0b83SWarner Losh 	uintptr_t	paddr;
547ee97f198SJohn-Mark Gurney 	int		maj_off;
548ee97f198SJohn-Mark Gurney 	int		min_off;
549a64f0b83SWarner Losh 
550a64f0b83SWarner Losh 	if (smbios.probed)
551a64f0b83SWarner Losh 		return;
552a64f0b83SWarner Losh 	smbios.probed = 1;
553a64f0b83SWarner Losh 
554a64f0b83SWarner Losh 	/* Search signatures and validate checksums. */
555a64f0b83SWarner Losh 	saddr = smbios_sigsearch(addr ? addr : PTOV(SMBIOS_START),
556a64f0b83SWarner Losh 	    SMBIOS_LENGTH);
557a64f0b83SWarner Losh 	if (saddr == NULL)
558a64f0b83SWarner Losh 		return;
559a64f0b83SWarner Losh 
560ee97f198SJohn-Mark Gurney #ifdef HAS_SMBV3
561ee97f198SJohn-Mark Gurney 	if (isv3) {
56213597be9SJohn-Mark Gurney 		smbios.length = SMBIOS_GET32(saddr, 0x0c);	/* Structure Table Length */
563ee97f198SJohn-Mark Gurney 		paddr = SMBIOS_GET64(saddr, 0x10);		/* Structure Table Address */
564ee97f198SJohn-Mark Gurney 		smbios.count = -1;				/* not present in V3 */
565ee97f198SJohn-Mark Gurney 		smbios.ver = 0;					/* not present in V3 */
566ee97f198SJohn-Mark Gurney 		maj_off = 0x07;
567ee97f198SJohn-Mark Gurney 		min_off = 0x08;
568ee97f198SJohn-Mark Gurney 	} else
569ee97f198SJohn-Mark Gurney #endif
570ee97f198SJohn-Mark Gurney 	{
571a64f0b83SWarner Losh 		smbios.length = SMBIOS_GET16(saddr, 0x16);	/* Structure Table Length */
572a64f0b83SWarner Losh 		paddr = SMBIOS_GET32(saddr, 0x18);		/* Structure Table Address */
573a64f0b83SWarner Losh 		smbios.count = SMBIOS_GET16(saddr, 0x1c);	/* No of SMBIOS Structures */
574a64f0b83SWarner Losh 		smbios.ver = SMBIOS_GET8(saddr, 0x1e);		/* SMBIOS BCD Revision */
575ee97f198SJohn-Mark Gurney 		maj_off = 0x06;
576ee97f198SJohn-Mark Gurney 		min_off = 0x07;
577ee97f198SJohn-Mark Gurney 	}
578ee97f198SJohn-Mark Gurney 
579a64f0b83SWarner Losh 
580a64f0b83SWarner Losh 	if (smbios.ver != 0) {
581a64f0b83SWarner Losh 		smbios.major = smbios.ver >> 4;
582a64f0b83SWarner Losh 		smbios.minor = smbios.ver & 0x0f;
583a64f0b83SWarner Losh 		if (smbios.major > 9 || smbios.minor > 9)
584a64f0b83SWarner Losh 			smbios.ver = 0;
585a64f0b83SWarner Losh 	}
586a64f0b83SWarner Losh 	if (smbios.ver == 0) {
587ee97f198SJohn-Mark Gurney 		smbios.major = SMBIOS_GET8(saddr, maj_off);/* SMBIOS Major Version */
588ee97f198SJohn-Mark Gurney 		smbios.minor = SMBIOS_GET8(saddr, min_off);/* SMBIOS Minor Version */
589a64f0b83SWarner Losh 	}
590a64f0b83SWarner Losh 	smbios.ver = (smbios.major << 8) | smbios.minor;
591a64f0b83SWarner Losh 	smbios.addr = PTOV(paddr);
592a64f0b83SWarner Losh 
593a64f0b83SWarner Losh 	/* Get system information from SMBIOS */
594a64f0b83SWarner Losh 	info = smbios_find_struct(0x00);
595a64f0b83SWarner Losh 	if (info != NULL) {
596a64f0b83SWarner Losh 		smbios.bios_vendor = smbios_getstring(info, 0x04);
597a64f0b83SWarner Losh 	}
598a64f0b83SWarner Losh 	info = smbios_find_struct(0x01);
599a64f0b83SWarner Losh 	if (info != NULL) {
600a64f0b83SWarner Losh 		smbios.maker = smbios_getstring(info, 0x04);
601a64f0b83SWarner Losh 		smbios.product = smbios_getstring(info, 0x05);
602a64f0b83SWarner Losh 	}
603a64f0b83SWarner Losh }
604a64f0b83SWarner Losh 
605a64f0b83SWarner Losh void
smbios_detect(const caddr_t addr)606a64f0b83SWarner Losh smbios_detect(const caddr_t addr)
607a64f0b83SWarner Losh {
608a64f0b83SWarner Losh 	char		buf[16];
609a64f0b83SWarner Losh 	caddr_t		dmi;
610a64f0b83SWarner Losh 	size_t		i;
611a64f0b83SWarner Losh 
612a64f0b83SWarner Losh 	smbios_probe(addr);
613a64f0b83SWarner Losh 	if (smbios.addr == NULL)
614a64f0b83SWarner Losh 		return;
615a64f0b83SWarner Losh 
616a64f0b83SWarner Losh 	for (dmi = smbios.addr, i = 0;
617a64f0b83SWarner Losh 	     dmi < smbios.addr + smbios.length && i < smbios.count; i++)
618a64f0b83SWarner Losh 		dmi = smbios_parse_table(dmi);
619a64f0b83SWarner Losh 
620a64f0b83SWarner Losh 	sprintf(buf, "%d.%d", smbios.major, smbios.minor);
621a64f0b83SWarner Losh 	setenv("smbios.version", buf, 1);
622a64f0b83SWarner Losh 	if (smbios.enabled_memory > 0 || smbios.old_enabled_memory > 0) {
623a64f0b83SWarner Losh 		sprintf(buf, "%u", smbios.enabled_memory > 0 ?
624a64f0b83SWarner Losh 		    smbios.enabled_memory : smbios.old_enabled_memory);
625a64f0b83SWarner Losh 		setenv("smbios.memory.enabled", buf, 1);
626a64f0b83SWarner Losh 	}
627a64f0b83SWarner Losh 	if (smbios.enabled_sockets > 0) {
628a64f0b83SWarner Losh 		sprintf(buf, "%u", smbios.enabled_sockets);
629a64f0b83SWarner Losh 		setenv("smbios.socket.enabled", buf, 1);
630a64f0b83SWarner Losh 	}
631a64f0b83SWarner Losh 	if (smbios.populated_sockets > 0) {
632a64f0b83SWarner Losh 		sprintf(buf, "%u", smbios.populated_sockets);
633a64f0b83SWarner Losh 		setenv("smbios.socket.populated", buf, 1);
634a64f0b83SWarner Losh 	}
635a64f0b83SWarner Losh }
636a64f0b83SWarner Losh 
637a64f0b83SWarner Losh static int
smbios_match_str(const char * s1,const char * s2)638a64f0b83SWarner Losh smbios_match_str(const char* s1, const char* s2)
639a64f0b83SWarner Losh {
640a64f0b83SWarner Losh 	return (s1 == NULL || (s2 != NULL && !strcmp(s1, s2)));
641a64f0b83SWarner Losh }
642a64f0b83SWarner Losh 
643a64f0b83SWarner Losh int
smbios_match(const char * bios_vendor,const char * maker,const char * product)644a64f0b83SWarner Losh smbios_match(const char* bios_vendor, const char* maker,
645a64f0b83SWarner Losh     const char* product)
646a64f0b83SWarner Losh {
647a64f0b83SWarner Losh 	/* XXXRP currently, only called from non-EFI. */
648a64f0b83SWarner Losh 	smbios_probe(NULL);
649a64f0b83SWarner Losh 	return (smbios_match_str(bios_vendor, smbios.bios_vendor) &&
650a64f0b83SWarner Losh 	    smbios_match_str(maker, smbios.maker) &&
651a64f0b83SWarner Losh 	    smbios_match_str(product, smbios.product));
652a64f0b83SWarner Losh }
653