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