1d0673fe1SAllan Jude /*- 24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3d0673fe1SAllan Jude * 4d0673fe1SAllan Jude * Copyright (c) 1997 Michael Smith 5d0673fe1SAllan Jude * Copyright (c) 1998 Jonathan Lemon 6d0673fe1SAllan Jude * All rights reserved. 7d0673fe1SAllan Jude * 8d0673fe1SAllan Jude * Redistribution and use in source and binary forms, with or without 9d0673fe1SAllan Jude * modification, are permitted provided that the following conditions 10d0673fe1SAllan Jude * are met: 11d0673fe1SAllan Jude * 1. Redistributions of source code must retain the above copyright 12d0673fe1SAllan Jude * notice, this list of conditions and the following disclaimer. 13d0673fe1SAllan Jude * 2. Redistributions in binary form must reproduce the above copyright 14d0673fe1SAllan Jude * notice, this list of conditions and the following disclaimer in the 15d0673fe1SAllan Jude * documentation and/or other materials provided with the distribution. 16d0673fe1SAllan Jude * 17d0673fe1SAllan Jude * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18d0673fe1SAllan Jude * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19d0673fe1SAllan Jude * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20d0673fe1SAllan Jude * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21d0673fe1SAllan Jude * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22d0673fe1SAllan Jude * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23d0673fe1SAllan Jude * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24d0673fe1SAllan Jude * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25d0673fe1SAllan Jude * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26d0673fe1SAllan Jude * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27d0673fe1SAllan Jude * SUCH DAMAGE. 28d0673fe1SAllan Jude */ 29d0673fe1SAllan Jude 30d0673fe1SAllan Jude #ifndef _SMBIOS_H_ 31d0673fe1SAllan Jude #define _SMBIOS_H_ 32d0673fe1SAllan Jude 33d0673fe1SAllan Jude /* 34d0673fe1SAllan Jude * System Management BIOS 35d0673fe1SAllan Jude */ 36d0673fe1SAllan Jude #define SMBIOS_START 0xf0000 37d0673fe1SAllan Jude #define SMBIOS_STEP 0x10 38d0673fe1SAllan Jude #define SMBIOS_OFF 0 39d0673fe1SAllan Jude #define SMBIOS_LEN 4 40d0673fe1SAllan Jude #define SMBIOS_SIG "_SM_" 41*ba0e4d79SAndrew Gallatin #define SMBIOS3_LEN 5 42*ba0e4d79SAndrew Gallatin #define SMBIOS3_SIG "_SM3_" 43d0673fe1SAllan Jude 44d0673fe1SAllan Jude struct smbios_eps { 45d0673fe1SAllan Jude uint8_t anchor_string[4]; /* '_SM_' */ 46d0673fe1SAllan Jude uint8_t checksum; 47d0673fe1SAllan Jude uint8_t length; 48d0673fe1SAllan Jude uint8_t major_version; 49d0673fe1SAllan Jude uint8_t minor_version; 50d0673fe1SAllan Jude uint16_t maximum_structure_size; 51d0673fe1SAllan Jude uint8_t entry_point_revision; 52d0673fe1SAllan Jude uint8_t formatted_area[5]; 53d0673fe1SAllan Jude uint8_t intermediate_anchor_string[5]; /* '_DMI_' */ 54d0673fe1SAllan Jude uint8_t intermediate_checksum; 55d0673fe1SAllan Jude uint16_t structure_table_length; 56d0673fe1SAllan Jude uint32_t structure_table_address; 57d0673fe1SAllan Jude uint16_t number_structures; 58d0673fe1SAllan Jude uint8_t BCD_revision; 59f689cb23SGreg V } __packed; 60d0673fe1SAllan Jude 61*ba0e4d79SAndrew Gallatin struct smbios3_eps { 62*ba0e4d79SAndrew Gallatin uint8_t anchor_string[5]; /* '_SM3_' */ 63*ba0e4d79SAndrew Gallatin uint8_t checksum; 64*ba0e4d79SAndrew Gallatin uint8_t length; 65*ba0e4d79SAndrew Gallatin uint8_t major_version; 66*ba0e4d79SAndrew Gallatin uint8_t minor_version; 67*ba0e4d79SAndrew Gallatin uint8_t docrev; 68*ba0e4d79SAndrew Gallatin uint8_t entry_point_revision; 69*ba0e4d79SAndrew Gallatin uint8_t reserved; 70*ba0e4d79SAndrew Gallatin uint32_t structure_table_max_size; 71*ba0e4d79SAndrew Gallatin uint64_t structure_table_address; 72*ba0e4d79SAndrew Gallatin }; 73*ba0e4d79SAndrew Gallatin 74d0673fe1SAllan Jude struct smbios_structure_header { 75d0673fe1SAllan Jude uint8_t type; 76d0673fe1SAllan Jude uint8_t length; 77d0673fe1SAllan Jude uint16_t handle; 78f689cb23SGreg V } __packed; 79f689cb23SGreg V 80f689cb23SGreg V typedef void (*smbios_callback_t)(struct smbios_structure_header *, void *); 81f689cb23SGreg V 82f689cb23SGreg V static inline void 83f689cb23SGreg V smbios_walk_table(uint8_t *p, int entries, smbios_callback_t cb, void *arg) 84f689cb23SGreg V { 85f689cb23SGreg V struct smbios_structure_header *s; 86f689cb23SGreg V 87f689cb23SGreg V while (entries--) { 88f689cb23SGreg V s = (struct smbios_structure_header *)p; 89f689cb23SGreg V cb(s, arg); 90f689cb23SGreg V 91f689cb23SGreg V /* 92f689cb23SGreg V * Look for a double-nul after the end of the 93f689cb23SGreg V * formatted area of this structure. 94f689cb23SGreg V */ 95f689cb23SGreg V p += s->length; 96f689cb23SGreg V while (!(p[0] == 0 && p[1] == 0)) 97f689cb23SGreg V p++; 98f689cb23SGreg V 99f689cb23SGreg V /* 100f689cb23SGreg V * Skip over the double-nul to the start of the next 101f689cb23SGreg V * structure. 102f689cb23SGreg V */ 103f689cb23SGreg V p += 2; 104f689cb23SGreg V } 105f689cb23SGreg V } 106d0673fe1SAllan Jude 1072fee8756SJohn-Mark Gurney #ifdef _KERNEL 1082fee8756SJohn-Mark Gurney void identify_hypervisor_smbios(void); 1092fee8756SJohn-Mark Gurney #endif 1102fee8756SJohn-Mark Gurney 111d0673fe1SAllan Jude #endif /* _SMBIOS_H_ */ 112