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