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