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