185227700SMike Smith /*- 2*c49761ddSPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*c49761ddSPedro F. Giffuni * 485227700SMike Smith * Copyright (c) 1997 Michael Smith 5496027bfSMike Smith * Copyright (c) 1998 Jonathan Lemon 685227700SMike Smith * All rights reserved. 785227700SMike Smith * 885227700SMike Smith * Redistribution and use in source and binary forms, with or without 985227700SMike Smith * modification, are permitted provided that the following conditions 1085227700SMike Smith * are met: 1185227700SMike Smith * 1. Redistributions of source code must retain the above copyright 1285227700SMike Smith * notice, this list of conditions and the following disclaimer. 1385227700SMike Smith * 2. Redistributions in binary form must reproduce the above copyright 1485227700SMike Smith * notice, this list of conditions and the following disclaimer in the 1585227700SMike Smith * documentation and/or other materials provided with the distribution. 1685227700SMike Smith * 1785227700SMike Smith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1885227700SMike Smith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1985227700SMike Smith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2085227700SMike Smith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2185227700SMike Smith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2285227700SMike Smith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2385227700SMike Smith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2485227700SMike Smith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2585227700SMike Smith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2685227700SMike Smith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2785227700SMike Smith * SUCH DAMAGE. 2885227700SMike Smith * 29c3aac50fSPeter Wemm * $FreeBSD$ 3085227700SMike Smith */ 3185227700SMike Smith 3279005bbdSPoul-Henning Kamp #ifndef _MACHINE_PC_BIOS_H_ 3379005bbdSPoul-Henning Kamp #define _MACHINE_PC_BIOS_H_ 3479005bbdSPoul-Henning Kamp 3529f0d433SWarner Losh /* 3696f52845SMike Smith * Int 15:E820 'SMAP' structure 3796f52845SMike Smith */ 3896f52845SMike Smith #define SMAP_SIG 0x534D4150 /* 'SMAP' */ 398518d50aSJohn Baldwin 408518d50aSJohn Baldwin #define SMAP_TYPE_MEMORY 1 418518d50aSJohn Baldwin #define SMAP_TYPE_RESERVED 2 428518d50aSJohn Baldwin #define SMAP_TYPE_ACPI_RECLAIM 3 438518d50aSJohn Baldwin #define SMAP_TYPE_ACPI_NVS 4 448518d50aSJohn Baldwin #define SMAP_TYPE_ACPI_ERROR 5 45fb112f72SAlexander Motin #define SMAP_TYPE_DISABLED 6 46fb112f72SAlexander Motin #define SMAP_TYPE_PMEM 7 47fb112f72SAlexander Motin #define SMAP_TYPE_PRAM 12 488518d50aSJohn Baldwin 49cebe9dc9SJung-uk Kim #define SMAP_XATTR_ENABLED 0x00000001 50cebe9dc9SJung-uk Kim #define SMAP_XATTR_NON_VOLATILE 0x00000002 51cebe9dc9SJung-uk Kim #define SMAP_XATTR_MASK (SMAP_XATTR_ENABLED | SMAP_XATTR_NON_VOLATILE) 52cebe9dc9SJung-uk Kim 5396f52845SMike Smith struct bios_smap { 5496f52845SMike Smith u_int64_t base; 5596f52845SMike Smith u_int64_t length; 5696f52845SMike Smith u_int32_t type; 574f492bfaSAlfred Perlstein } __packed; 5879005bbdSPoul-Henning Kamp 5989871cdeSJohn Baldwin /* Structure extended to include extended attribute field in ACPI 3.0. */ 6089871cdeSJohn Baldwin struct bios_smap_xattr { 6189871cdeSJohn Baldwin u_int64_t base; 6289871cdeSJohn Baldwin u_int64_t length; 6389871cdeSJohn Baldwin u_int32_t type; 6489871cdeSJohn Baldwin u_int32_t xattr; 6589871cdeSJohn Baldwin } __packed; 6689871cdeSJohn Baldwin 67960b5a70SJohn Baldwin /* 68960b5a70SJohn Baldwin * System Management BIOS 69960b5a70SJohn Baldwin */ 70960b5a70SJohn Baldwin #define SMBIOS_START 0xf0000 71960b5a70SJohn Baldwin #define SMBIOS_STEP 0x10 72960b5a70SJohn Baldwin #define SMBIOS_OFF 0 73960b5a70SJohn Baldwin #define SMBIOS_LEN 4 74960b5a70SJohn Baldwin #define SMBIOS_SIG "_SM_" 75960b5a70SJohn Baldwin 76960b5a70SJohn Baldwin struct smbios_eps { 77960b5a70SJohn Baldwin uint8_t anchor_string[4]; /* '_SM_' */ 78960b5a70SJohn Baldwin uint8_t checksum; 79960b5a70SJohn Baldwin uint8_t length; 80960b5a70SJohn Baldwin uint8_t major_version; 81960b5a70SJohn Baldwin uint8_t minor_version; 82960b5a70SJohn Baldwin uint16_t maximum_structure_size; 83960b5a70SJohn Baldwin uint8_t entry_point_revision; 84960b5a70SJohn Baldwin uint8_t formatted_area[5]; 85960b5a70SJohn Baldwin uint8_t intermediate_anchor_string[5]; /* '_DMI_' */ 86960b5a70SJohn Baldwin uint8_t intermediate_checksum; 87960b5a70SJohn Baldwin uint16_t structure_table_length; 88960b5a70SJohn Baldwin uint32_t structure_table_address; 89960b5a70SJohn Baldwin uint16_t number_structures; 90960b5a70SJohn Baldwin uint8_t BCD_revision; 91960b5a70SJohn Baldwin }; 92960b5a70SJohn Baldwin 93960b5a70SJohn Baldwin struct smbios_structure_header { 94960b5a70SJohn Baldwin uint8_t type; 95960b5a70SJohn Baldwin uint8_t length; 96960b5a70SJohn Baldwin uint16_t handle; 97960b5a70SJohn Baldwin }; 98960b5a70SJohn Baldwin 99960b5a70SJohn Baldwin #ifdef _KERNEL 100960b5a70SJohn Baldwin #define BIOS_PADDRTOVADDR(x) ((x) + KERNBASE) 101960b5a70SJohn Baldwin #define BIOS_VADDRTOPADDR(x) ((x) - KERNBASE) 102960b5a70SJohn Baldwin 103636d90fcSPoul-Henning Kamp struct bios_oem_signature { 104636d90fcSPoul-Henning Kamp char * anchor; /* search anchor string in BIOS memory */ 105636d90fcSPoul-Henning Kamp size_t offset; /* offset from anchor (may be negative) */ 106636d90fcSPoul-Henning Kamp size_t totlen; /* total length of BIOS string to copy */ 107636d90fcSPoul-Henning Kamp } __packed; 108960b5a70SJohn Baldwin 109636d90fcSPoul-Henning Kamp struct bios_oem_range { 110636d90fcSPoul-Henning Kamp u_int from; /* shouldn't be below 0xe0000 */ 111636d90fcSPoul-Henning Kamp u_int to; /* shouldn't be above 0xfffff */ 112636d90fcSPoul-Henning Kamp } __packed; 113960b5a70SJohn Baldwin 114636d90fcSPoul-Henning Kamp struct bios_oem { 115636d90fcSPoul-Henning Kamp struct bios_oem_range range; 116636d90fcSPoul-Henning Kamp struct bios_oem_signature signature[]; 117636d90fcSPoul-Henning Kamp } __packed; 118636d90fcSPoul-Henning Kamp 119960b5a70SJohn Baldwin int bios_oem_strings(struct bios_oem *oem, u_char *buffer, size_t maxlen); 120960b5a70SJohn Baldwin uint32_t bios_sigsearch(uint32_t start, u_char *sig, int siglen, int paralen, 121960b5a70SJohn Baldwin int sigofs); 1221e69553eSRoger Pau Monné void bios_add_smap_entries(struct bios_smap *smapbase, u_int32_t smapsize, 1231e69553eSRoger Pau Monné vm_paddr_t *physmap, int *physmap_idx); 124960b5a70SJohn Baldwin #endif 12579005bbdSPoul-Henning Kamp 12679005bbdSPoul-Henning Kamp #endif /* _MACHINE_PC_BIOS_H_ */ 127