xref: /freebsd/sys/i386/include/bootinfo.h (revision 4134f677eb39ace176de2967c6ed449d6dfff732)
176b993fbSRodney W. Grimes /*-
283ef78beSPedro F. Giffuni  * SPDX-License-Identifier: BSD-4-Clause
383ef78beSPedro F. Giffuni  *
476b993fbSRodney W. Grimes  * Copyright (C) 1994 by Rodney W. Grimes, Milwaukie, Oregon  97222
576b993fbSRodney W. Grimes  * All rights reserved.
676b993fbSRodney W. Grimes  *
776b993fbSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
876b993fbSRodney W. Grimes  * modification, are permitted provided that the following conditions
976b993fbSRodney W. Grimes  * are met:
1076b993fbSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
1176b993fbSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer as
1276b993fbSRodney W. Grimes  *    the first lines of this file unmodified.
1376b993fbSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
1476b993fbSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
1576b993fbSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
1676b993fbSRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
1776b993fbSRodney W. Grimes  *    must display the following acknowledgement:
1876b993fbSRodney W. Grimes  *	This product includes software developed by Rodney W. Grimes.
1976b993fbSRodney W. Grimes  * 4. The name of the author may not be used to endorse or promote products
2076b993fbSRodney W. Grimes  *    derived from this software without specific prior written permission.
2176b993fbSRodney W. Grimes  *
2276b993fbSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY RODNEY W. GRIMES ``AS IS'' AND
2376b993fbSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2476b993fbSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2576b993fbSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL RODNEY W. GRIMES BE LIABLE
2676b993fbSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2776b993fbSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2876b993fbSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2976b993fbSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3076b993fbSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3176b993fbSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3276b993fbSRodney W. Grimes  * SUCH DAMAGE.
3376b993fbSRodney W. Grimes  *
34c3aac50fSPeter Wemm  * $FreeBSD$
3576b993fbSRodney W. Grimes  */
3676b993fbSRodney W. Grimes 
3776b993fbSRodney W. Grimes #ifndef	_MACHINE_BOOTINFO_H_
3876b993fbSRodney W. Grimes #define	_MACHINE_BOOTINFO_H_
3976b993fbSRodney W. Grimes 
40b5d89ca8SBruce Evans /* Only change the version number if you break compatibility. */
41b5d89ca8SBruce Evans #define	BOOTINFO_VERSION	1
42b5d89ca8SBruce Evans 
4359b1d074SWarner Losh #define	_WAS_N_BIOS_GEOM	8
44b5d89ca8SBruce Evans 
45b5d89ca8SBruce Evans /*
46b5d89ca8SBruce Evans  * A zero bootinfo field often means that there is no info available.
47*4134f677SWarner Losh  * Assumes booting with a boot loader from FreeBSD 2.1 or newer and
48*4134f677SWarner Losh  * that bi_size is always valid when bi_version == 1.
49b5d89ca8SBruce Evans  */
50b5d89ca8SBruce Evans struct bootinfo {
51*4134f677SWarner Losh 	u_int32_t	bi_version;		/* Must be 1 */
529d508ad2SBruce Evans 	u_int32_t	bi_kernelname;		/* represents a char * */
539d508ad2SBruce Evans 	u_int32_t	bi_nfs_diskless;	/* struct nfs_diskless * */
5459b1d074SWarner Losh 	u_int32_t	_was_bi_n_bios_used;
5559b1d074SWarner Losh 	u_int32_t	_was_bi_bios_geom[_WAS_N_BIOS_GEOM];
569d508ad2SBruce Evans 	u_int32_t	bi_size;
579d508ad2SBruce Evans 	u_int8_t	bi_memsizes_valid;
5859b1d074SWarner Losh 	u_int8_t	bi_bios_dev;	/* bootdev BIOS unit number (bootX -> loader only) */
59882ffc4bSMike Smith 	u_int8_t	bi_pad[2];
609d508ad2SBruce Evans 	u_int32_t	bi_basemem;
619d508ad2SBruce Evans 	u_int32_t	bi_extmem;
629d508ad2SBruce Evans 	u_int32_t	bi_symtab;		/* struct symtab * */
639d508ad2SBruce Evans 	u_int32_t	bi_esymtab;		/* struct symtab * */
647877a80aSMike Smith 				/* Items below only from advanced bootloader */
657877a80aSMike Smith 	u_int32_t	bi_kernend;		/* end of kernel space */
667877a80aSMike Smith 	u_int32_t	bi_envp;		/* environment */
677877a80aSMike Smith 	u_int32_t	bi_modulep;		/* preloaded modules */
6876b993fbSRodney W. Grimes };
6976b993fbSRodney W. Grimes 
70664a31e4SPeter Wemm #ifdef _KERNEL
71b5d89ca8SBruce Evans extern struct bootinfo	bootinfo;
72e0abbebfSPoul-Henning Kamp #endif
73b5d89ca8SBruce Evans 
74197e5e73SPoul-Henning Kamp /*
75197e5e73SPoul-Henning Kamp  * Constants for converting boot-style device number to type,
76197e5e73SPoul-Henning Kamp  * adaptor (uba, mba, etc), unit number and partition number.
77197e5e73SPoul-Henning Kamp  * Type (== major device number) is in the low byte
78197e5e73SPoul-Henning Kamp  * for backward compatibility.  Except for that of the "magic
79197e5e73SPoul-Henning Kamp  * number", each mask applies to the shifted value.
80197e5e73SPoul-Henning Kamp  * Format:
815c5b5d46SJohn Baldwin  *	 (4)   (8)   (4)  (8)     (8)
82197e5e73SPoul-Henning Kamp  *	--------------------------------
835c5b5d46SJohn Baldwin  *	|MA | SLICE | UN| PART  | TYPE |
84197e5e73SPoul-Henning Kamp  *	--------------------------------
85197e5e73SPoul-Henning Kamp  */
86197e5e73SPoul-Henning Kamp #define B_SLICESHIFT		20
87197e5e73SPoul-Henning Kamp #define B_SLICEMASK		0xff
88197e5e73SPoul-Henning Kamp #define B_SLICE(val)		(((val)>>B_SLICESHIFT) & B_SLICEMASK)
89197e5e73SPoul-Henning Kamp #define B_UNITSHIFT		16
90197e5e73SPoul-Henning Kamp #define B_UNITMASK		0xf
91197e5e73SPoul-Henning Kamp #define	B_UNIT(val)		(((val) >> B_UNITSHIFT) & B_UNITMASK)
92197e5e73SPoul-Henning Kamp #define B_PARTITIONSHIFT	8
93197e5e73SPoul-Henning Kamp #define B_PARTITIONMASK		0xff
94197e5e73SPoul-Henning Kamp #define	B_PARTITION(val)	(((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK)
95197e5e73SPoul-Henning Kamp #define	B_TYPESHIFT		0
96197e5e73SPoul-Henning Kamp #define	B_TYPEMASK		0xff
97197e5e73SPoul-Henning Kamp #define	B_TYPE(val)		(((val) >> B_TYPESHIFT) & B_TYPEMASK)
98197e5e73SPoul-Henning Kamp 
99197e5e73SPoul-Henning Kamp #define	B_MAGICMASK	0xf0000000
100197e5e73SPoul-Henning Kamp #define	B_DEVMAGIC	0xa0000000
101197e5e73SPoul-Henning Kamp 
1025c5b5d46SJohn Baldwin #define	MAKEBOOTDEV(type, slice, unit, partition) \
1035c5b5d46SJohn Baldwin 	(((type) << B_TYPESHIFT) | ((slice) << B_SLICESHIFT) | \
1045c5b5d46SJohn Baldwin 	((unit) << B_UNITSHIFT) | ((partition) << B_PARTITIONSHIFT) | \
1055c5b5d46SJohn Baldwin 	B_DEVMAGIC)
106197e5e73SPoul-Henning Kamp 
107197e5e73SPoul-Henning Kamp #define	BASE_SLICE		2
108197e5e73SPoul-Henning Kamp #define	COMPATIBILITY_SLICE	0
109197e5e73SPoul-Henning Kamp #define	MAX_SLICES		32
110197e5e73SPoul-Henning Kamp #define	WHOLE_DISK_SLICE	1
111197e5e73SPoul-Henning Kamp 
112b5d89ca8SBruce Evans #endif	/* !_MACHINE_BOOTINFO_H_ */
113