xref: /illumos-gate/usr/src/uts/intel/sys/bootconf.h (revision 78801af7286cd73dbc996d470f789e75993cf15d)
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 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  * Copyright 2016 Nexenta Systems, Inc.
26  * Copyright 2020 Joyent, Inc.
27  */
28 
29 #ifndef	_SYS_BOOTCONF_H
30 #define	_SYS_BOOTCONF_H
31 
32 
33 /*
34  * Boot time configuration information objects
35  */
36 
37 #include <sys/types.h>
38 #include <sys/bootregs.h>		/* for struct bop_regs */
39 #include <sys/bootstat.h>
40 #include <sys/dirent.h>			/* for struct dirent */
41 #include <sys/memlist.h>
42 #include <sys/obpdefs.h>
43 #include <sys/varargs.h>
44 #include <net/if.h>			/* for IFNAMSIZ */
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #define	BP_MAX_STRLEN	32
51 
52 /*
53  * Boot property names
54  */
55 #define	BP_CPU_APICID_ARRAY	"cpu_apicid_array"
56 #define	BP_LGRP_SLIT_ENABLE	"lgrp_slit_enable"
57 #define	BP_LGRP_SRAT_ENABLE	"lgrp_srat_enable"
58 #define	BP_LGRP_MSCT_ENABLE	"lgrp_msct_enable"
59 #define	BP_LGRP_TOPO_LEVELS	"lgrp_topo_levels"
60 
61 /*
62  * masks to hand to bsys_alloc memory allocator
63  * XXX	These names shouldn't really be srmmu derived.
64  */
65 #define	BO_NO_ALIGN	0x00001000
66 
67 /* flags for BOP_EALLOC */
68 #define	BOPF_X86_ALLOC_CLIENT	0x001
69 #define	BOPF_X86_ALLOC_REAL	0x002
70 #define	BOPF_X86_ALLOC_IDMAP	0x003
71 #define	BOPF_X86_ALLOC_PHYS	0x004
72 
73 /* return values for the newer bootops */
74 #define	BOOT_SUCCESS	0
75 #define	BOOT_FAILURE	(-1)
76 
77 /* top of boot scratch memory: 15 MB; multiboot loads at 16 MB */
78 #define	MAGIC_PHYS	0xF00000
79 
80 /*
81  *  We pass a ptr to the space that boot has been using
82  *  for its memory lists.
83  */
84 struct bsys_mem {
85 	struct memlist	*physinstalled;	/* amt of physmem installed */
86 	struct memlist	*rsvdmem;	/* amt of bios reserved mem */
87 	struct memlist	*physavail;	/* amt of physmem avail for use */
88 	struct memlist	*virtavail;	/* amt of virtmem avail for use */
89 	struct memlist	*pcimem;	/* amt of pcimem avail for use */
90 	uint_t		extent;		/* number of bytes in the space */
91 };
92 
93 /*
94  * Warning: Changing BO_VERSION blows compatibility between booters
95  *          and older kernels.  If you want to change the struct bootops,
96  *          please consider adding new stuff to the end and using the
97  *          "bootops-extensions" mechanism described below.
98  */
99 #define	BO_VERSION	10		/* bootops interface revision # */
100 
101 typedef struct bootops {
102 	/*
103 	 * the ubiquitous version number
104 	 */
105 	uint_t	bsys_version;
106 
107 	/*
108 	 * the area containing boot's memlists
109 	 */
110 	struct	bsys_mem *boot_mem;
111 
112 	/*
113 	 * have boot allocate size bytes at virthint
114 	 */
115 	caddr_t	(*bsys_alloc)(struct bootops *, caddr_t virthint, size_t size,
116 		int align);
117 
118 	/*
119 	 * free size bytes allocated at virt - put the
120 	 * address range back onto the avail lists.
121 	 */
122 	void	(*bsys_free)(struct bootops *, caddr_t virt, size_t size);
123 
124 	/*
125 	 * to find the size of the buffer to allocate
126 	 */
127 	int	(*bsys_getproplen)(struct bootops *, const char *);
128 
129 	/*
130 	 * get the value associated with this name
131 	 */
132 	int	(*bsys_getprop)(struct bootops *, const char *, void *);
133 
134 	/*
135 	 * get the name of the next property in succession
136 	 * from the standalone
137 	 */
138 	char	*(*bsys_nextprop)(struct bootops *, char *prevprop);
139 
140 	/*
141 	 * print formatted output
142 	 */
143 	void	(*bsys_printf)(void *, const char *, ...);
144 
145 	/*
146 	 * Do a real mode interrupt
147 	 */
148 	void	(*bsys_doint)(struct bootops *, int, struct bop_regs *);
149 
150 	/*
151 	 * Enhanced version of bsys_alloc().
152 	 */
153 	caddr_t	(*bsys_ealloc)(struct bootops *, caddr_t virthint, size_t size,
154 		int align, int flags);
155 
156 	/* end of bootops which exist if (bootops-extensions >= 1) */
157 } bootops_t;
158 
159 #define	BOP_GETVERSION(bop)		((bop)->bsys_version)
160 #define	BOP_ALLOC(bop, virthint, size, align)	\
161 				((bop)->bsys_alloc)(bop, virthint, size, align)
162 #define	BOP_FREE(bop, virt, size)	((bop)->bsys_free)(bop, virt, size)
163 #define	BOP_GETPROPLEN(bop, name)	((bop)->bsys_getproplen)(bop, name)
164 #define	BOP_GETPROP(bop, name, buf)	((bop)->bsys_getprop)(bop, name, buf)
165 #define	BOP_NEXTPROP(bop, prev)		((bop)->bsys_nextprop)(bop, prev)
166 #define	BOP_DOINT(bop, intnum, rp)	((bop)->bsys_doint)(bop, intnum, rp)
167 #define	BOP_EALLOC(bop, virthint, size, align, flags)\
168 		((bop)->bsys_ealloc)(bop, virthint, size, align, flags)
169 
170 #define	BOP_PUTSARG(bop, msg, arg)	((bop)->bsys_printf)(bop, msg, arg)
171 
172 #if defined(_KERNEL) && !defined(_BOOT)
173 
174 /*
175  * Boot configuration information
176  */
177 
178 #define	BO_MAXFSNAME	16
179 #define	BO_MAXOBJNAME	256
180 
181 struct bootobj {
182 	char	bo_fstype[BO_MAXFSNAME];	/* vfs type name (e.g. nfs) */
183 	char	bo_name[BO_MAXOBJNAME];		/* name of object */
184 	int	bo_flags;			/* flags, see below */
185 	int	bo_size;			/* number of blocks */
186 	struct vnode *bo_vp;			/* vnode of object */
187 	char	bo_devname[BO_MAXOBJNAME];
188 	char	bo_ifname[BO_MAXOBJNAME];
189 	int	bo_ppa;
190 };
191 
192 /*
193  * flags
194  */
195 #define	BO_VALID	0x01	/* all information in object is valid */
196 #define	BO_BUSY		0x02	/* object is busy */
197 
198 extern struct bootobj rootfs;
199 extern struct bootobj swapfile;
200 
201 extern char obp_bootpath[BO_MAXOBJNAME];
202 
203 extern void *gfx_devinfo_list;
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 extern char *strplumb_get_netdev_path(void);
212 
213 extern void consconfig(void);
214 extern void release_bootstrap(void);
215 
216 extern void param_check(void);
217 extern int octet_to_hexascii(const void *, uint_t, char *, uint_t *);
218 
219 extern int dhcpinit(void);
220 
221 extern struct bootops *bootops;
222 extern int netboot;
223 extern int swaploaded;
224 extern int modrootloaded;
225 extern char kern_bootargs[];
226 extern char kern_bootfile[];
227 extern char *kobj_module_path;
228 extern char *default_path;
229 extern char *dhcack;
230 extern int dhcacklen;
231 extern char dhcifname[IFNAMSIZ];
232 extern char *netdev_path;
233 
234 extern void bop_no_more_mem(void);
235 
236 /*PRINTFLIKE2*/
237 extern void bop_printf(void *, const char *, ...)
238     __KPRINTFLIKE(2);
239 extern void vbop_printf(void *, const char *, va_list);
240 
241 /*PRINTFLIKE1*/
242 extern void bop_panic(const char *, ...)
243     __KPRINTFLIKE(1) __NORETURN;
244 #pragma rarely_called(bop_panic)
245 
246 extern void read_bootenvrc(void);
247 
248 extern int bootprop_getval(const char *, u_longlong_t *);
249 extern int bootprop_getstr(const char *, char *, size_t);
250 
251 /*
252  * Back door to fakebop.c to get physical memory allocated.
253  * 64 bit data types are fixed for 32 bit PAE use.
254  */
255 extern paddr_t do_bop_phys_alloc(uint64_t, uint64_t);
256 
257 extern int do_bsys_getproplen(bootops_t *, const char *);
258 extern int do_bsys_getprop(bootops_t *, const char *, void *);
259 extern int do_bsys_getproptype(bootops_t *, const char *);
260 
261 #endif /* _KERNEL && !_BOOT */
262 
263 #ifdef __cplusplus
264 }
265 #endif
266 
267 #endif	/* _SYS_BOOTCONF_H */
268