1178172Simp/*-
2178172Simp * Copyright (C) 1994 by Rodney W. Grimes, Milwaukie, Oregon  97222
3178172Simp * All rights reserved.
4178172Simp *
5178172Simp * Redistribution and use in source and binary forms, with or without
6178172Simp * modification, are permitted provided that the following conditions
7178172Simp * are met:
8178172Simp * 1. Redistributions of source code must retain the above copyright
9178172Simp *    notice, this list of conditions and the following disclaimer as
10178172Simp *    the first lines of this file unmodified.
11178172Simp * 2. Redistributions in binary form must reproduce the above copyright
12178172Simp *    notice, this list of conditions and the following disclaimer in the
13178172Simp *    documentation and/or other materials provided with the distribution.
14178172Simp * 3. All advertising materials mentioning features or use of this software
15178172Simp *    must display the following acknowledgement:
16178172Simp *	This product includes software developed by Rodney W. Grimes.
17178172Simp * 4. The name of the author may not be used to endorse or promote products
18178172Simp *    derived from this software without specific prior written permission.
19178172Simp *
20178172Simp * THIS SOFTWARE IS PROVIDED BY RODNEY W. GRIMES ``AS IS'' AND
21178172Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22178172Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23178172Simp * ARE DISCLAIMED.  IN NO EVENT SHALL RODNEY W. GRIMES BE LIABLE
24178172Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25178172Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26178172Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27178172Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28178172Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29178172Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30178172Simp * SUCH DAMAGE.
31178172Simp *
32178172Simp * $FreeBSD$
33178172Simp */
34178172Simp
35178172Simp#ifndef	_MACHINE_BOOTINFO_H_
36178172Simp#define	_MACHINE_BOOTINFO_H_
37178172Simp
38178172Simp/* Only change the version number if you break compatibility. */
39178172Simp#define	BOOTINFO_VERSION	1
40178172Simp
41178172Simp#define	N_BIOS_GEOM		8
42178172Simp
43178172Simp#define	MIPS_BOOTINFO_MAGIC	0xCDEACDEA
44178172Simp
45178172Simp/* Extended OLV bootinfo struct.  The data area includes a list of named
46178172Simp   OIDs and associated data values.  The format is:
47178172Simp
48178172Simp   NUL-terminated dotted-string name
49178172Simp   2 byte length, in big-endian order
50178172Simp   LENGTH bytes of data
51178172Simp   [...]
52178172Simp
53178172Simp   The two magic fields are used to guard against other bootloaders that
54178172Simp   may place other sorts of data here.  */
55178172Simp
56178172Simpstruct bootinfo_ext {
57178172Simp#define	BOOTINFO_EXT_MAGIC1	0x55aa00ff
58178172Simp	unsigned int		magic1;
59178172Simp	unsigned char		*data;
60178172Simp	unsigned int		size;
61178172Simp#define	BOOTINFO_EXT_MAGIC2	0x32719187
62178172Simp	unsigned int		magic2;
63178172Simp};
64178172Simp
65178172Simp#define	BOOTINFO_EXT_MAX_SIZE	16384
66178172Simp
67178172Simp/*
68178172Simp * A zero bootinfo field often means that there is no info available.
69178172Simp * Flags are used to indicate the validity of fields where zero is a
70178172Simp * normal value.
71178172Simp */
72178172Simpstruct bootinfo {
73178172Simp	u_int32_t	bi_version;
74178172Simp	u_int32_t	bi_kernelname;		/* represents a char * */
75178172Simp	u_int32_t	bi_nfs_diskless;	/* struct nfs_diskless * */
76178172Simp				/* End of fields that are always present. */
77178172Simp#define	bi_endcommon	bi_n_bios_used
78178172Simp	u_int32_t	bi_n_bios_used;
79178172Simp	u_int32_t	bi_bios_geom[N_BIOS_GEOM];
80178172Simp	u_int32_t	bi_size;
81178172Simp	u_int8_t	bi_memsizes_valid;
82178172Simp	u_int8_t	bi_bios_dev;		/* bootdev BIOS unit number */
83178172Simp	u_int8_t	bi_pad[2];
84178172Simp	u_int32_t	bi_basemem;
85178172Simp	u_int32_t	bi_extmem;
86178172Simp	u_int32_t	bi_symtab;		/* struct symtab * */
87178172Simp	u_int32_t	bi_esymtab;		/* struct symtab * */
88178172Simp				/* Items below only from advanced bootloader */
89178172Simp	u_int32_t	bi_kernend;		/* end of kernel space */
90178172Simp	u_int32_t	bi_envp;		/* environment */
91178172Simp	u_int32_t	bi_modulep;		/* preloaded modules */
92178172Simp};
93178172Simp
94178172Simp#ifdef _KERNEL
95178172Simpextern struct bootinfo	bootinfo;
96178172Simp#endif
97178172Simp
98178172Simp/*
99178172Simp * Constants for converting boot-style device number to type,
100178172Simp * adaptor (uba, mba, etc), unit number and partition number.
101178172Simp * Type (== major device number) is in the low byte
102178172Simp * for backward compatibility.  Except for that of the "magic
103178172Simp * number", each mask applies to the shifted value.
104178172Simp * Format:
105178172Simp *	 (4) (4) (4) (4)  (8)     (8)
106178172Simp *	--------------------------------
107178172Simp *	|MA | AD| CT| UN| PART  | TYPE |
108178172Simp *	--------------------------------
109178172Simp */
110178172Simp#define	B_ADAPTORSHIFT		24
111178172Simp#define	B_ADAPTORMASK		0x0f
112178172Simp#define	B_ADAPTOR(val)		(((val) >> B_ADAPTORSHIFT) & B_ADAPTORMASK)
113178172Simp#define	B_CONTROLLERSHIFT	20
114178172Simp#define	B_CONTROLLERMASK	0xf
115178172Simp#define	B_CONTROLLER(val)	(((val)>>B_CONTROLLERSHIFT) & B_CONTROLLERMASK)
116178172Simp#define	B_SLICESHIFT		20
117178172Simp#define	B_SLICEMASK		0xff
118178172Simp#define	B_SLICE(val)		(((val)>>B_SLICESHIFT) & B_SLICEMASK)
119178172Simp#define	B_UNITSHIFT		16
120178172Simp#define	B_UNITMASK		0xf
121178172Simp#define	B_UNIT(val)		(((val) >> B_UNITSHIFT) & B_UNITMASK)
122178172Simp#define	B_PARTITIONSHIFT	8
123178172Simp#define	B_PARTITIONMASK		0xff
124178172Simp#define	B_PARTITION(val)	(((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK)
125178172Simp#define	B_TYPESHIFT		0
126178172Simp#define	B_TYPEMASK		0xff
127178172Simp#define	B_TYPE(val)		(((val) >> B_TYPESHIFT) & B_TYPEMASK)
128178172Simp
129178172Simp#define	B_MAGICMASK	0xf0000000
130178172Simp#define	B_DEVMAGIC	0xa0000000
131178172Simp
132178172Simp#define	MAKEBOOTDEV(type, adaptor, controller, unit, partition)		\
133178172Simp	(((type) << B_TYPESHIFT) | ((adaptor) << B_ADAPTORSHIFT) |	\
134178172Simp	((controller) << B_CONTROLLERSHIFT) | ((unit) << B_UNITSHIFT) |	\
135178172Simp	((partition) << B_PARTITIONSHIFT) | B_DEVMAGIC)
136178172Simp
137178172Simp#define	BASE_SLICE		2
138178172Simp#define	COMPATIBILITY_SLICE	0
139178172Simp#define	MAX_SLICES		32
140178172Simp#define	WHOLE_DISK_SLICE	1
141178172Simp
142178172Simp#endif	/* !_MACHINE_BOOTINFO_H_ */
143