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