xref: /titanic_41/usr/src/uts/sun/sys/bootconf.h (revision 749f21d359d8fbd020c974a1a5227316221bfc9c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_BOOTCONF_H
28 #define	_SYS_BOOTCONF_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI" /* SunOS-4.0 1.7 */
31 
32 /*
33  * Boot time configuration information objects
34  */
35 
36 #include <sys/types.h>
37 #include <sys/memlist.h>
38 #include <sys/bootstat.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * masks to hand to bsys_alloc memory allocator
46  * XXX	These names shouldn't really be srmmu derived.
47  */
48 #define	BO_NO_ALIGN	0x00001000
49 #define	BO_ALIGN_L3	0x00001000
50 #define	BO_ALIGN_L2	0x00040000
51 #define	BO_ALIGN_L1	0x01000000
52 
53 /*
54  *  We pass a ptr to the space that boot has been using
55  *  for its memory lists.
56  */
57 struct bsys_mem {
58 	struct memlist *physinstalled;	/* amt of physmem installed */
59 	struct memlist *physavail;	/* amt of physmem avail for use */
60 	struct memlist *virtavail;	/* amt of virtmem avail for use */
61 	uint_t		extent; 	/* number of bytes in the space */
62 };
63 
64 #define	BO_VERSION	9		/* bootops interface revision # */
65 
66 #define	BOOTOPS_ARE_1275(bop) \
67 	((BOP_GETVERSION(bop)) >= 9 && (bop->bsys_1275_call != 0))
68 
69 typedef struct bootops {
70 	/*
71 	 * the ubiquitous version number
72 	 */
73 	uint_t	bsys_version;
74 
75 	/*
76 	 * pointer to our parents bootops
77 	 */
78 	struct bootops  *bsys_super;
79 
80 	/*
81 	 * the area containing boot's memlists (non-LP64 boot)
82 	 */
83 	struct  bsys_mem *boot_mem;
84 
85 #ifndef _LP64
86 	uint32_t	bsys_pad2[2]; /* pointers above get larger */
87 #endif
88 	/*
89 	 * The entry point to jump to for boot services.
90 	 * Pass this routine the array of boot_cell_t's describing the
91 	 * service requested.
92 	 */
93 	uint64_t bsys_1275_call;
94 
95 	uint32_t	bsys_pad1[7];
96 	/*
97 	 * print formatted output - PRINTFLIKE1
98 	 * here (and maintained) so old kernels can fail with
99 	 * an error message rather than something weird.
100 	 * not really 'printf' though.
101 	 */
102 	uint32_t	bsys_printf;
103 } bootops_t;
104 
105 extern uint_t bop_getversion(struct bootops *bootops);
106 extern int bop_open(struct bootops *bop, char *s, int flags);
107 extern int bop_read(struct bootops *bop, int fd, caddr_t buf, size_t size);
108 extern int bop_seek(struct bootops *bop, int fd, off_t hi, off_t lo);
109 extern int bop_close(struct bootops *bop, int fd);
110 extern caddr_t bop_alloc(struct bootops *bop, caddr_t virthint, size_t size,
111     int align);
112 extern caddr_t bop_alloc_virt(struct bootops *bop, caddr_t virt, size_t size);
113 extern void bop_free(struct bootops *bop, caddr_t virt, size_t size);
114 extern caddr_t bop_map(struct bootops *bop, caddr_t virt, int space,
115     caddr_t phys, size_t size);
116 extern void bop_unmap(struct bootops *bop, caddr_t virt, size_t size);
117 extern void bop_quiesce_io(struct bootops *bop);
118 extern int bop_getproplen(struct bootops *bop, char *name);
119 extern int bop_getprop(struct bootops *bop, char *name, void *value);
120 extern char *bop_nextprop(struct bootops *bop, char *prevprop);
121 extern int bop_mountroot(struct bootops *bop, char *path);
122 extern int bop_unmountroot(struct bootops *bop);
123 extern void bop_puts(struct bootops *, char *);
124 extern void bop_putsarg(struct bootops *, const char *, ...);
125 extern int bop_fstat(struct bootops *, int fd, struct bootstat *);
126 extern void bop_enter_mon(struct bootops *bop);
127 
128 #define	BOP_GETVERSION(bop)		bop_getversion(bop)
129 #define	BOP_OPEN(bop, s, flags)		bop_open(bop, s, flags)
130 #define	BOP_READ(bop, fd, buf, size)	bop_read(bop, fd, buf, size)
131 #define	BOP_SEEK(bop, fd, hi, lo)	bop_seek(bop, fd, hi, lo)
132 #define	BOP_CLOSE(bop, fd)		bop_close(bop, fd)
133 #define	BOP_ALLOC(bop, virthint, size, align)	\
134 				bop_alloc(bop, virthint, size, align)
135 #define	BOP_ALLOC_VIRT(bop, virt, size)	bop_alloc_virt(bop, virt, size)
136 #define	BOP_FREE(bop, virt, size)	bop_free(bop, virt, size)
137 #define	BOP_MAP(bop, virt, space, phys, size)	\
138 				bop_map(bop, virt, space, phys, size)
139 #define	BOP_UNMAP(bop, virt, size)	bop_unmap(bop, virt, size)
140 #define	BOP_QUIESCE_IO(bop)		bop_quiesce_io(bop)
141 #define	BOP_GETPROPLEN(bop, name)	bop_getproplen(bop, name)
142 #define	BOP_GETPROP(bop, name, buf)	bop_getprop(bop, name, buf)
143 #define	BOP_NEXTPROP(bop, prev)		bop_nextprop(bop, prev)
144 #define	BOP_MOUNTROOT(bop, path)	bop_mountroot(bop, path)
145 #define	BOP_UNMOUNTROOT(bop)		bop_unmountroot(bop)
146 #define	BOP_PUTS(bop, msg)		bop_puts(bop, msg)
147 #define	BOP_PUTSARG(bop, msg, arg)	bop_putsarg(bop, msg, arg)
148 #define	BOP_FSTAT(bop, fd, st)		bop_fstat(bop, fd, st)
149 #define	BOP_ENTER_MON(bop)		bop_enter_mon(bop)
150 
151 /*
152  * macros and declarations needed by clients of boot to
153  * call the 1275-like boot interface routines.
154  */
155 
156 typedef unsigned long long boot_cell_t;
157 
158 /*
159  * Macros that work in both compilation models, to permit either a
160  * sun4u/ILP32 or a sun4u/LP64 program to interface with the new
161  * 1275-like boot service replacement for bootops.
162  *
163  * These macros stuff/unstuff arguments into/from boot_cell_t's, which are
164  * fixed size in all models. Note that some of the types (e.g. off_t)
165  * change size in the models.
166  */
167 #define	boot_ptr2cell(p)	((boot_cell_t)((uintptr_t)((void *)(p))))
168 #define	boot_int2cell(i)	((boot_cell_t)((int)(i)))
169 #define	boot_uint2cell(u)	((boot_cell_t)((unsigned int)(u)))
170 #define	boot_uint642cell(u)	((boot_cell_t)((uint64_t)(u)))
171 #define	boot_offt2cell(u)	((boot_cell_t)((off_t)(u)))
172 #define	boot_size2cell(u)	((boot_cell_t)((size_t)(u)))
173 #define	boot_phandle2cell(ph)	((boot_cell_t)((unsigned)((phandle_t)(ph))))
174 #define	boot_dnode2cell(d)	((boot_cell_t)((unsigned)((pnode_t)(d))))
175 #define	boot_ihandle2cell(ih)	((boot_cell_t)((unsigned)((ihandle_t)(ih))))
176 
177 #define	boot_cell2ptr(p)	((void *)(uintptr_t)((boot_cell_t)(p)))
178 #define	boot_cell2int(i)	((int)((boot_cell_t)(i)))
179 #define	boot_cell2uint(u)	((unsigned int)((boot_cell_t)(u)))
180 #define	boot_cell2uint64(u)	((uint64_t)((boot_cell_t)(u)))
181 #define	boot_cell2offt(u)	((off_t)((boot_cell_t)(u)))
182 #define	boot_cell2size(u)	((size_t)((boot_cell_t)(u)))
183 #define	boot_cell2phandle(ph)	((phandle_t)((boot_cell_t)(ph)))
184 #define	boot_cell2dnode(d)	((pnode_t)((boot_cell_t)(d)))
185 #define	boot_cell2ihandle(ih)	((ihandle_t)((boot_cell_t)(ih)))
186 #define	boot_cells2ull(h, l)	((unsigned long long)(boot_cell_t)(l))
187 
188 #define	BOOT_SVC_FAIL	(int)(-1)
189 #define	BOOT_SVC_OK	(int)(1)
190 
191 #if defined(_KERNEL) && !defined(_BOOT)
192 
193 /*
194  * Boot configuration information
195  */
196 
197 #define	BO_MAXFSNAME	16
198 #define	BO_MAXOBJNAME	256
199 
200 struct bootobj {
201 	char	bo_fstype[BO_MAXFSNAME];	/* vfs type name (e.g. nfs) */
202 	char	bo_name[BO_MAXOBJNAME];		/* name of object */
203 	int	bo_flags;			/* flags, see below */
204 	int	bo_size;			/* number of blocks */
205 	struct vnode *bo_vp;			/* vnode of object */
206 	char	bo_devname[BO_MAXOBJNAME];
207 	char	bo_ifname[BO_MAXOBJNAME];
208 	int	bo_ppa;
209 };
210 
211 /*
212  * flags
213  */
214 #define	BO_VALID	0x01	/* all information in object is valid */
215 #define	BO_BUSY		0x02	/* object is busy */
216 
217 extern struct bootobj rootfs;
218 extern struct bootobj swapfile;
219 
220 extern char obp_bootpath[BO_MAXOBJNAME];
221 extern char svm_bootpath[BO_MAXOBJNAME];
222 
223 extern dev_t getrootdev(void);
224 extern void getfsname(char *, char *, size_t);
225 extern int loadrootmodules(void);
226 
227 extern int strplumb(void);
228 extern int strplumb_load(void);
229 
230 extern void consconfig(void);
231 
232 extern int dhcpinit(void);
233 
234 /* XXX	Doesn't belong here */
235 extern int zsgetspeed(dev_t);
236 
237 extern void param_check(void);
238 
239 extern struct bootops *bootops;
240 extern int netboot;
241 extern int swaploaded;
242 extern int modrootloaded;
243 extern char kern_bootargs[];
244 extern char *default_path;
245 extern char *dhcack;
246 extern char *netdev_path;
247 
248 #endif /* _KERNEL && !_BOOT */
249 
250 #ifdef __cplusplus
251 }
252 #endif
253 
254 #endif	/* _SYS_BOOTCONF_H */
255