xref: /freebsd/sys/amd64/include/pc/bios.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
185227700SMike Smith /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3c49761ddSPedro 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  */
2985227700SMike Smith 
3079005bbdSPoul-Henning Kamp #ifndef _MACHINE_PC_BIOS_H_
3179005bbdSPoul-Henning Kamp #define _MACHINE_PC_BIOS_H_
3279005bbdSPoul-Henning Kamp 
3329f0d433SWarner Losh /*
3496f52845SMike Smith  * Int 15:E820 'SMAP' structure
3596f52845SMike Smith  */
3696f52845SMike Smith #define SMAP_SIG	0x534D4150			/* 'SMAP' */
378518d50aSJohn Baldwin 
388518d50aSJohn Baldwin #define	SMAP_TYPE_MEMORY	1
398518d50aSJohn Baldwin #define	SMAP_TYPE_RESERVED	2
408518d50aSJohn Baldwin #define	SMAP_TYPE_ACPI_RECLAIM	3
418518d50aSJohn Baldwin #define	SMAP_TYPE_ACPI_NVS	4
428518d50aSJohn Baldwin #define	SMAP_TYPE_ACPI_ERROR	5
43fb112f72SAlexander Motin #define	SMAP_TYPE_DISABLED	6
44fb112f72SAlexander Motin #define	SMAP_TYPE_PMEM		7
45fb112f72SAlexander Motin #define	SMAP_TYPE_PRAM		12
468518d50aSJohn Baldwin 
47cebe9dc9SJung-uk Kim #define	SMAP_XATTR_ENABLED	0x00000001
48cebe9dc9SJung-uk Kim #define	SMAP_XATTR_NON_VOLATILE	0x00000002
49cebe9dc9SJung-uk Kim #define	SMAP_XATTR_MASK		(SMAP_XATTR_ENABLED | SMAP_XATTR_NON_VOLATILE)
50cebe9dc9SJung-uk Kim 
5196f52845SMike Smith struct bios_smap {
5296f52845SMike Smith     u_int64_t	base;
5396f52845SMike Smith     u_int64_t	length;
5496f52845SMike Smith     u_int32_t	type;
554f492bfaSAlfred Perlstein } __packed;
5679005bbdSPoul-Henning Kamp 
5789871cdeSJohn Baldwin /* Structure extended to include extended attribute field in ACPI 3.0. */
5889871cdeSJohn Baldwin struct bios_smap_xattr {
5989871cdeSJohn Baldwin     u_int64_t	base;
6089871cdeSJohn Baldwin     u_int64_t	length;
6189871cdeSJohn Baldwin     u_int32_t	type;
6289871cdeSJohn Baldwin     u_int32_t	xattr;
6389871cdeSJohn Baldwin } __packed;
6489871cdeSJohn Baldwin 
65960b5a70SJohn Baldwin #ifdef _KERNEL
66960b5a70SJohn Baldwin #define BIOS_PADDRTOVADDR(x)	((x) + KERNBASE)
67960b5a70SJohn Baldwin #define BIOS_VADDRTOPADDR(x)	((x) - KERNBASE)
68960b5a70SJohn Baldwin 
69636d90fcSPoul-Henning Kamp struct bios_oem_signature {
70636d90fcSPoul-Henning Kamp 	char * anchor;		/* search anchor string in BIOS memory */
71636d90fcSPoul-Henning Kamp 	size_t offset;		/* offset from anchor (may be negative) */
72636d90fcSPoul-Henning Kamp 	size_t totlen;		/* total length of BIOS string to copy */
73636d90fcSPoul-Henning Kamp } __packed;
74960b5a70SJohn Baldwin 
75636d90fcSPoul-Henning Kamp struct bios_oem_range {
76636d90fcSPoul-Henning Kamp 	u_int from;		/* shouldn't be below 0xe0000 */
77636d90fcSPoul-Henning Kamp 	u_int to;		/* shouldn't be above 0xfffff */
78636d90fcSPoul-Henning Kamp } __packed;
79960b5a70SJohn Baldwin 
80636d90fcSPoul-Henning Kamp struct bios_oem {
81636d90fcSPoul-Henning Kamp 	struct bios_oem_range range;
82636d90fcSPoul-Henning Kamp 	struct bios_oem_signature signature[];
83636d90fcSPoul-Henning Kamp } __packed;
84636d90fcSPoul-Henning Kamp 
85960b5a70SJohn Baldwin int	bios_oem_strings(struct bios_oem *oem, u_char *buffer, size_t maxlen);
86960b5a70SJohn Baldwin uint32_t bios_sigsearch(uint32_t start, u_char *sig, int siglen, int paralen,
87960b5a70SJohn Baldwin 	    int sigofs);
881e69553eSRoger Pau Monné void bios_add_smap_entries(struct bios_smap *smapbase, u_int32_t smapsize,
891e69553eSRoger Pau Monné 	    vm_paddr_t *physmap, int *physmap_idx);
90960b5a70SJohn Baldwin #endif
9179005bbdSPoul-Henning Kamp 
9279005bbdSPoul-Henning Kamp #endif /* _MACHINE_PC_BIOS_H_ */
93