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