1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_SYS_BOOTCONF_H
28*0Sstevel@tonic-gate #define	_SYS_BOOTCONF_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * Boot time configuration information objects
34*0Sstevel@tonic-gate  */
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #include <sys/types.h>
37*0Sstevel@tonic-gate #include <sys/bootregs.h>		/* for struct bop_regs */
38*0Sstevel@tonic-gate #include <sys/bootstat.h>
39*0Sstevel@tonic-gate #include <sys/dirent.h>		/* for struct dirent */
40*0Sstevel@tonic-gate #include <sys/memlist.h>
41*0Sstevel@tonic-gate #include <sys/obpdefs.h>
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate #ifdef __cplusplus
44*0Sstevel@tonic-gate extern "C" {
45*0Sstevel@tonic-gate #endif
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate /*
48*0Sstevel@tonic-gate  * masks to hand to bsys_alloc memory allocator
49*0Sstevel@tonic-gate  * XXX	These names shouldn't really be srmmu derived.
50*0Sstevel@tonic-gate  */
51*0Sstevel@tonic-gate #define	BO_NO_ALIGN	0x00001000
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate /* flags for BOP_EALLOC */
54*0Sstevel@tonic-gate #define	BOPF_X86_ALLOC_CLIENT	0x001
55*0Sstevel@tonic-gate #define	BOPF_X86_ALLOC_REAL	0x002
56*0Sstevel@tonic-gate #define	BOPF_X86_ALLOC_IDMAP	0x003
57*0Sstevel@tonic-gate #define	BOPF_X86_ALLOC_PHYS	0x004
58*0Sstevel@tonic-gate 
59*0Sstevel@tonic-gate /* return values for the newer bootops */
60*0Sstevel@tonic-gate #define	BOOT_SUCCESS	0
61*0Sstevel@tonic-gate #define	BOOT_FAILURE	(-1)
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate /* top of boot scratch memory: 15 MB; multiboot loads at 16 MB */
64*0Sstevel@tonic-gate #define	MAGIC_PHYS	0xF00000
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate /*
67*0Sstevel@tonic-gate  *  We pass a ptr to the space that boot has been using
68*0Sstevel@tonic-gate  *  for its memory lists.
69*0Sstevel@tonic-gate  */
70*0Sstevel@tonic-gate struct bsys_mem {
71*0Sstevel@tonic-gate 	struct memlist	*physinstalled;	/* amt of physmem installed */
72*0Sstevel@tonic-gate 	struct memlist	*physavail;	/* amt of physmem avail for use */
73*0Sstevel@tonic-gate 	struct memlist	*virtavail;	/* amt of virtmem avail for use */
74*0Sstevel@tonic-gate 	struct memlist	*pcimem;	/* amt of pcimem avail for use */
75*0Sstevel@tonic-gate 	uint_t		extent; 	/* number of bytes in the space */
76*0Sstevel@tonic-gate };
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate /*
79*0Sstevel@tonic-gate  * Warning: Changing BO_VERSION blows compatibility between booters
80*0Sstevel@tonic-gate  *          and older kernels.  If you want to change the struct bootops,
81*0Sstevel@tonic-gate  *          please consider adding new stuff to the end and using the
82*0Sstevel@tonic-gate  *          "bootops-extensions" mechanism described below.
83*0Sstevel@tonic-gate  */
84*0Sstevel@tonic-gate #define	BO_VERSION	10		/* bootops interface revision # */
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate typedef struct bootops {
87*0Sstevel@tonic-gate 	/*
88*0Sstevel@tonic-gate 	 * the ubiquitous version number
89*0Sstevel@tonic-gate 	 */
90*0Sstevel@tonic-gate 	uint_t	bsys_version;
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate 	/*
93*0Sstevel@tonic-gate 	 * the area containing boot's memlists
94*0Sstevel@tonic-gate 	 */
95*0Sstevel@tonic-gate 	struct 	bsys_mem *boot_mem;
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate 	/*
98*0Sstevel@tonic-gate 	 * have boot allocate size bytes at virthint
99*0Sstevel@tonic-gate 	 */
100*0Sstevel@tonic-gate 	caddr_t	(*bsys_alloc)(struct bootops *, caddr_t virthint, size_t size,
101*0Sstevel@tonic-gate 		int align);
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate 	/*
104*0Sstevel@tonic-gate 	 * free size bytes allocated at virt - put the
105*0Sstevel@tonic-gate 	 * address range back onto the avail lists.
106*0Sstevel@tonic-gate 	 */
107*0Sstevel@tonic-gate 	void	(*bsys_free)(struct bootops *, caddr_t virt, size_t size);
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate 	/*
110*0Sstevel@tonic-gate 	 * to find the size of the buffer to allocate
111*0Sstevel@tonic-gate 	 */
112*0Sstevel@tonic-gate 	int	(*bsys_getproplen)(struct bootops *, char *name);
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate 	/*
115*0Sstevel@tonic-gate 	 * get the value associated with this name
116*0Sstevel@tonic-gate 	 */
117*0Sstevel@tonic-gate 	int	(*bsys_getprop)(struct bootops *, char *name, void *value);
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate 	/*
120*0Sstevel@tonic-gate 	 * get the name of the next property in succession
121*0Sstevel@tonic-gate 	 * from the standalone
122*0Sstevel@tonic-gate 	 */
123*0Sstevel@tonic-gate 	char	*(*bsys_nextprop)(struct bootops *, char *prevprop);
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate 	/*
126*0Sstevel@tonic-gate 	 * print formatted output
127*0Sstevel@tonic-gate 	 */
128*0Sstevel@tonic-gate 	void	(*bsys_printf)(struct bootops *, char *, ...);
129*0Sstevel@tonic-gate 
130*0Sstevel@tonic-gate 	/*
131*0Sstevel@tonic-gate 	 * Do a real mode interrupt
132*0Sstevel@tonic-gate 	 */
133*0Sstevel@tonic-gate 	void	(*bsys_doint)(struct bootops *, int, struct bop_regs *);
134*0Sstevel@tonic-gate 
135*0Sstevel@tonic-gate 	/*
136*0Sstevel@tonic-gate 	 * Enhanced version of bsys_alloc().
137*0Sstevel@tonic-gate 	 */
138*0Sstevel@tonic-gate 	caddr_t	(*bsys_ealloc)(struct bootops *, caddr_t virthint, size_t size,
139*0Sstevel@tonic-gate 		int align, int flags);
140*0Sstevel@tonic-gate 
141*0Sstevel@tonic-gate 	/* end of bootops which exist if (bootops-extensions >= 1) */
142*0Sstevel@tonic-gate } bootops_t;
143*0Sstevel@tonic-gate 
144*0Sstevel@tonic-gate #define	BOP_GETVERSION(bop)		((bop)->bsys_version)
145*0Sstevel@tonic-gate #define	BOP_ALLOC(bop, virthint, size, align)	\
146*0Sstevel@tonic-gate 				((bop)->bsys_alloc)(bop, virthint, size, align)
147*0Sstevel@tonic-gate #define	BOP_FREE(bop, virt, size)	((bop)->bsys_free)(bop, virt, size)
148*0Sstevel@tonic-gate #define	BOP_GETPROPLEN(bop, name)	((bop)->bsys_getproplen)(bop, name)
149*0Sstevel@tonic-gate #define	BOP_GETPROP(bop, name, buf)	((bop)->bsys_getprop)(bop, name, buf)
150*0Sstevel@tonic-gate #define	BOP_NEXTPROP(bop, prev)		((bop)->bsys_nextprop)(bop, prev)
151*0Sstevel@tonic-gate #define	BOP_DOINT(bop, intnum, rp)	((bop)->bsys_doint)(bop, intnum, rp)
152*0Sstevel@tonic-gate #define	BOP_EALLOC(bop, virthint, size, align, flags)\
153*0Sstevel@tonic-gate 		((bop)->bsys_ealloc)(bop, virthint, size, align, flags)
154*0Sstevel@tonic-gate 
155*0Sstevel@tonic-gate #define	BOP_PUTSARG(bop, msg, arg)	((bop)->bsys_printf)(bop, msg, arg)
156*0Sstevel@tonic-gate 
157*0Sstevel@tonic-gate #if defined(_KERNEL) && !defined(_BOOT)
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate /*
160*0Sstevel@tonic-gate  * Boot configuration information
161*0Sstevel@tonic-gate  */
162*0Sstevel@tonic-gate 
163*0Sstevel@tonic-gate #define	BO_MAXFSNAME	16
164*0Sstevel@tonic-gate #define	BO_MAXOBJNAME	256
165*0Sstevel@tonic-gate 
166*0Sstevel@tonic-gate struct bootobj {
167*0Sstevel@tonic-gate 	char	bo_fstype[BO_MAXFSNAME];	/* vfs type name (e.g. nfs) */
168*0Sstevel@tonic-gate 	char	bo_name[BO_MAXOBJNAME];		/* name of object */
169*0Sstevel@tonic-gate 	int	bo_flags;			/* flags, see below */
170*0Sstevel@tonic-gate 	int	bo_size;			/* number of blocks */
171*0Sstevel@tonic-gate 	struct vnode *bo_vp;			/* vnode of object */
172*0Sstevel@tonic-gate 	char	bo_devname[BO_MAXOBJNAME];
173*0Sstevel@tonic-gate 	char	bo_ifname[BO_MAXOBJNAME];
174*0Sstevel@tonic-gate 	int	bo_ppa;
175*0Sstevel@tonic-gate };
176*0Sstevel@tonic-gate 
177*0Sstevel@tonic-gate /*
178*0Sstevel@tonic-gate  * flags
179*0Sstevel@tonic-gate  */
180*0Sstevel@tonic-gate #define	BO_VALID	0x01	/* all information in object is valid */
181*0Sstevel@tonic-gate #define	BO_BUSY		0x02	/* object is busy */
182*0Sstevel@tonic-gate 
183*0Sstevel@tonic-gate extern struct bootobj rootfs;
184*0Sstevel@tonic-gate extern struct bootobj swapfile;
185*0Sstevel@tonic-gate 
186*0Sstevel@tonic-gate extern char obp_bootpath[BO_MAXOBJNAME];
187*0Sstevel@tonic-gate extern char svm_bootpath[BO_MAXOBJNAME];
188*0Sstevel@tonic-gate 
189*0Sstevel@tonic-gate extern dev_t getrootdev(void);
190*0Sstevel@tonic-gate extern void getfsname(char *, char *, size_t);
191*0Sstevel@tonic-gate extern int loadrootmodules(void);
192*0Sstevel@tonic-gate 
193*0Sstevel@tonic-gate extern int strplumb(void);
194*0Sstevel@tonic-gate extern int strplumb_load(void);
195*0Sstevel@tonic-gate extern char *strplumb_get_netdev_path(void);
196*0Sstevel@tonic-gate 
197*0Sstevel@tonic-gate extern void consconfig(void);
198*0Sstevel@tonic-gate extern void release_bootstrap(void);
199*0Sstevel@tonic-gate 
200*0Sstevel@tonic-gate extern void param_check(void);
201*0Sstevel@tonic-gate extern int octet_to_hexascii(const void *, uint_t, char *, uint_t *);
202*0Sstevel@tonic-gate 
203*0Sstevel@tonic-gate extern int dhcpinit(void);
204*0Sstevel@tonic-gate 
205*0Sstevel@tonic-gate /*
206*0Sstevel@tonic-gate  * XXX	The memlist stuff belongs in a header of its own
207*0Sstevel@tonic-gate  */
208*0Sstevel@tonic-gate extern int check_boot_version(int);
209*0Sstevel@tonic-gate extern void size_physavail(struct memlist *, pgcnt_t *, int *, pfn_t);
210*0Sstevel@tonic-gate extern int copy_physavail(struct memlist *, struct memlist **,
211*0Sstevel@tonic-gate     uint_t, uint_t);
212*0Sstevel@tonic-gate extern void installed_top_size(struct memlist *, pfn_t *, pgcnt_t *, int *);
213*0Sstevel@tonic-gate extern int check_memexp(struct memlist *, uint_t);
214*0Sstevel@tonic-gate extern void copy_memlist_filter(struct memlist *, struct memlist **,
215*0Sstevel@tonic-gate     void (*filter)(uint64_t *, uint64_t *));
216*0Sstevel@tonic-gate 
217*0Sstevel@tonic-gate extern struct bootops *bootops;
218*0Sstevel@tonic-gate extern int netboot;
219*0Sstevel@tonic-gate extern int swaploaded;
220*0Sstevel@tonic-gate extern int modrootloaded;
221*0Sstevel@tonic-gate extern char kern_bootargs[];
222*0Sstevel@tonic-gate extern char *default_path;
223*0Sstevel@tonic-gate extern char *dhcack;
224*0Sstevel@tonic-gate extern int dhcacklen;
225*0Sstevel@tonic-gate extern char *netdev_path;
226*0Sstevel@tonic-gate 
227*0Sstevel@tonic-gate #endif /* _KERNEL && !_BOOT */
228*0Sstevel@tonic-gate 
229*0Sstevel@tonic-gate #ifdef __cplusplus
230*0Sstevel@tonic-gate }
231*0Sstevel@tonic-gate #endif
232*0Sstevel@tonic-gate 
233*0Sstevel@tonic-gate #endif	/* _SYS_BOOTCONF_H */
234