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