xref: /illumos-gate/usr/src/uts/sun/sys/bootconf.h (revision 508de9f3)
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 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  * Copyright 2016 Nexenta Systems, Inc.
26  */
27 
28 #ifndef	_SYS_BOOTCONF_H
29 #define	_SYS_BOOTCONF_H
30 
31 
32 /*
33  * Boot time configuration information objects
34  */
35 
36 #include <sys/types.h>
37 #include <sys/varargs.h>
38 #include <sys/sysmacros.h>
39 #include <sys/memlist.h>
40 #include <sys/bootstat.h>
41 #include <net/if.h>			/* for IFNAMSIZ */
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * masks to hand to bsys_alloc memory allocator
49  * XXX	These names shouldn't really be srmmu derived.
50  */
51 #define	BO_NO_ALIGN	0x00001000
52 #define	BO_ALIGN_L3	0x00001000
53 #define	BO_ALIGN_L2	0x00040000
54 #define	BO_ALIGN_L1	0x01000000
55 
56 /*
57  *  We pass a ptr to the space that boot has been using
58  *  for its memory lists.
59  */
60 struct bsys_mem {
61 	struct memlist *physinstalled;	/* amt of physmem installed */
62 	struct memlist *physavail;	/* amt of physmem avail for use */
63 	struct memlist *virtavail;	/* amt of virtmem avail for use */
64 	uint_t		extent;		/* number of bytes in the space */
65 };
66 
67 #define	BO_VERSION	9		/* bootops interface revision # */
68 
69 #define	BOOTOPS_ARE_1275(bop) \
70 	((BOP_GETVERSION(bop)) >= 9 && (bop->bsys_1275_call != 0))
71 
72 typedef struct bootops {
73 	/*
74 	 * the ubiquitous version number
75 	 */
76 	uint_t	bsys_version;
77 
78 	/*
79 	 * The entry point to jump to for boot services.
80 	 * Pass this routine the array of boot_cell_t's describing the
81 	 * service requested.
82 	 */
83 	uint64_t bsys_1275_call;
84 
85 	/*
86 	 * print formatted output - PRINTFLIKE1
87 	 * here (and maintained) so old kernels can fail with
88 	 * an error message rather than something weird.
89 	 * not really 'printf' though.
90 	 */
91 	uint32_t	bsys_printf;
92 } bootops_t;
93 
94 extern void bop_init(void);
95 extern int bop_open(const char *s, int flags);
96 extern int bop_read(int fd, caddr_t buf, size_t size);
97 extern int bop_seek(int fd, off_t off);
98 extern int bop_close(int fd);
99 extern caddr_t bop_alloc(caddr_t virthint, size_t size, int align);
100 extern caddr_t bop_alloc_virt(caddr_t virt, size_t size);
101 extern caddr_t bop_temp_alloc(size_t size, int align);
102 extern caddr_t bop_alloc_chunk(caddr_t virthint, size_t size, int align);
103 extern void bop_free(caddr_t virt, size_t size);
104 extern int bop_getproplen(const char *name);
105 extern int bop_getprop(const char *name, void *value);
106 extern int bop_mountroot(void);
107 extern int bop_unmountroot(void);
108 extern int bop_fstat(int fd, struct bootstat *st);
109 extern void bop_enter_mon(void);
110 extern void bop_fini(void);
111 
112 extern void bop_printf(void *ops, const char *fmt, ...);
113 extern void vbop_printf(void *ops, const char *fmt, va_list);
114 extern void bop_putsarg(const char *fmt, char *arg);
115 extern void bop_panic(const char *s);
116 
117 #define	BOP_OPEN(s, flags)		bop_open(s, flags)
118 #define	BOP_READ(fd, buf, size)		bop_read(fd, buf, size)
119 #define	BOP_SEEK(fd, off)		bop_seek(fd, off)
120 #define	BOP_CLOSE(fd)			bop_close(fd)
121 #define	BOP_ALLOC(bop, virthint, size, align)	\
122 				bop_alloc(virthint, size, align)
123 #define	BOP_ALLOC_VIRT(virt, size)	bop_alloc_virt(virt, size)
124 #define	BOP_FREE(bop, virt, size)	bop_free(virt, size)
125 #define	BOP_GETPROPLEN(bop, name)	bop_getproplen(name)
126 #define	BOP_GETPROP(bop, name, buf)	bop_getprop(name, buf)
127 #define	BOP_MOUNTROOT()			bop_mountroot()
128 #define	BOP_UNMOUNTROOT()		bop_unmountroot()
129 #define	BOP_FSTAT(bop, fd, st)		bop_fstat(fd, st)
130 
131 /* special routine for kmdb only */
132 #define	BOP_PUTSARG(bop, fmt, arg)	bop_putsarg(fmt, arg)
133 
134 /*
135  * macros and declarations needed by clients of boot to
136  * call the 1275-like boot interface routines.
137  */
138 
139 typedef unsigned long long boot_cell_t;
140 
141 /*
142  * Macros that work in both compilation models, to permit either a
143  * sun4u/ILP32 or a sun4u/LP64 program to interface with the new
144  * 1275-like boot service replacement for bootops.
145  *
146  * These macros stuff/unstuff arguments into/from boot_cell_t's, which are
147  * fixed size in all models. Note that some of the types (e.g. off_t)
148  * change size in the models.
149  */
150 #define	boot_ptr2cell(p)	((boot_cell_t)((uintptr_t)((void *)(p))))
151 #define	boot_int2cell(i)	((boot_cell_t)((int)(i)))
152 #define	boot_uint2cell(u)	((boot_cell_t)((unsigned int)(u)))
153 #define	boot_uint642cell(u)	((boot_cell_t)((uint64_t)(u)))
154 #define	boot_offt2cell(u)	((boot_cell_t)((off_t)(u)))
155 #define	boot_size2cell(u)	((boot_cell_t)((size_t)(u)))
156 #define	boot_phandle2cell(ph)	((boot_cell_t)((unsigned)((phandle_t)(ph))))
157 #define	boot_dnode2cell(d)	((boot_cell_t)((unsigned)((pnode_t)(d))))
158 #define	boot_ihandle2cell(ih)	((boot_cell_t)((unsigned)((ihandle_t)(ih))))
159 
160 #define	boot_cell2ptr(p)	((void *)(uintptr_t)((boot_cell_t)(p)))
161 #define	boot_cell2int(i)	((int)((boot_cell_t)(i)))
162 #define	boot_cell2uint(u)	((unsigned int)((boot_cell_t)(u)))
163 #define	boot_cell2uint64(u)	((uint64_t)((boot_cell_t)(u)))
164 #define	boot_cell2offt(u)	((off_t)((boot_cell_t)(u)))
165 #define	boot_cell2size(u)	((size_t)((boot_cell_t)(u)))
166 #define	boot_cell2phandle(ph)	((phandle_t)((boot_cell_t)(ph)))
167 #define	boot_cell2dnode(d)	((pnode_t)((boot_cell_t)(d)))
168 #define	boot_cell2ihandle(ih)	((ihandle_t)((boot_cell_t)(ih)))
169 #define	boot_cells2ull(h, l)	((unsigned long long)(boot_cell_t)(l))
170 
171 #define	BOOT_SVC_FAIL	(int)(-1)
172 #define	BOOT_SVC_OK	(int)(1)
173 
174 #if defined(_KERNEL) && !defined(_BOOT)
175 
176 /*
177  * Boot configuration information
178  */
179 
180 #define	BO_MAXFSNAME	16
181 #define	BO_MAXOBJNAME	256
182 
183 struct bootobj {
184 	char	bo_fstype[BO_MAXFSNAME];	/* vfs type name (e.g. nfs) */
185 	char	bo_name[BO_MAXOBJNAME];		/* name of object */
186 	int	bo_flags;			/* flags, see below */
187 	int	bo_size;			/* number of blocks */
188 	struct vnode *bo_vp;			/* vnode of object */
189 	char	bo_devname[BO_MAXOBJNAME];
190 	char	bo_ifname[BO_MAXOBJNAME];
191 	int	bo_ppa;
192 };
193 
194 /*
195  * flags
196  */
197 #define	BO_VALID	0x01	/* all information in object is valid */
198 #define	BO_BUSY		0x02	/* object is busy */
199 
200 extern struct bootobj rootfs;
201 extern struct bootobj swapfile;
202 
203 extern char obp_bootpath[BO_MAXOBJNAME];
204 
205 extern dev_t getrootdev(void);
206 extern void getfsname(char *, char *, size_t);
207 extern int loadrootmodules(void);
208 
209 extern int strplumb(void);
210 extern int strplumb_load(void);
211 
212 extern void consconfig(void);
213 extern void release_bootstrap(void);
214 
215 extern int dhcpinit(void);
216 
217 /* XXX	Doesn't belong here */
218 extern int zsgetspeed(dev_t);
219 
220 extern void param_check(void);
221 
222 extern struct bootops *bootops;
223 extern int netboot;
224 extern int swaploaded;
225 extern int modrootloaded;
226 extern char kern_bootargs[];
227 extern char kern_bootfile[];
228 extern char *kobj_module_path;
229 extern char *default_path;
230 extern char *dhcack;
231 extern int dhcacklen;
232 extern char dhcifname[IFNAMSIZ];
233 extern char *netdev_path;
234 
235 extern char *strplumb_get_netdev_path(void);
236 
237 #endif /* _KERNEL && !_BOOT */
238 
239 #ifdef __cplusplus
240 }
241 #endif
242 
243 #endif	/* _SYS_BOOTCONF_H */
244