xref: /onnv-gate/usr/src/uts/sun/sys/bootconf.h (revision 7656:2621e50fdf4a)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51544Seschrock  * Common Development and Distribution License (the "License").
61544Seschrock  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
225974Sjm22469  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_BOOTCONF_H
270Sstevel@tonic-gate #define	_SYS_BOOTCONF_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate 
300Sstevel@tonic-gate /*
310Sstevel@tonic-gate  * Boot time configuration information objects
320Sstevel@tonic-gate  */
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #include <sys/types.h>
355648Ssetje #include <sys/varargs.h>
365648Ssetje #include <sys/sysmacros.h>
370Sstevel@tonic-gate #include <sys/memlist.h>
380Sstevel@tonic-gate #include <sys/bootstat.h>
395648Ssetje #include <net/if.h>			/* for IFNAMSIZ */
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #ifdef __cplusplus
420Sstevel@tonic-gate extern "C" {
430Sstevel@tonic-gate #endif
440Sstevel@tonic-gate 
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate  * masks to hand to bsys_alloc memory allocator
470Sstevel@tonic-gate  * XXX	These names shouldn't really be srmmu derived.
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate #define	BO_NO_ALIGN	0x00001000
500Sstevel@tonic-gate #define	BO_ALIGN_L3	0x00001000
510Sstevel@tonic-gate #define	BO_ALIGN_L2	0x00040000
520Sstevel@tonic-gate #define	BO_ALIGN_L1	0x01000000
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /*
550Sstevel@tonic-gate  *  We pass a ptr to the space that boot has been using
560Sstevel@tonic-gate  *  for its memory lists.
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate struct bsys_mem {
590Sstevel@tonic-gate 	struct memlist *physinstalled;	/* amt of physmem installed */
600Sstevel@tonic-gate 	struct memlist *physavail;	/* amt of physmem avail for use */
610Sstevel@tonic-gate 	struct memlist *virtavail;	/* amt of virtmem avail for use */
620Sstevel@tonic-gate 	uint_t		extent; 	/* number of bytes in the space */
630Sstevel@tonic-gate };
640Sstevel@tonic-gate 
650Sstevel@tonic-gate #define	BO_VERSION	9		/* bootops interface revision # */
660Sstevel@tonic-gate 
670Sstevel@tonic-gate #define	BOOTOPS_ARE_1275(bop) \
680Sstevel@tonic-gate 	((BOP_GETVERSION(bop)) >= 9 && (bop->bsys_1275_call != 0))
690Sstevel@tonic-gate 
700Sstevel@tonic-gate typedef struct bootops {
710Sstevel@tonic-gate 	/*
720Sstevel@tonic-gate 	 * the ubiquitous version number
730Sstevel@tonic-gate 	 */
740Sstevel@tonic-gate 	uint_t	bsys_version;
750Sstevel@tonic-gate 
760Sstevel@tonic-gate 	/*
770Sstevel@tonic-gate 	 * The entry point to jump to for boot services.
780Sstevel@tonic-gate 	 * Pass this routine the array of boot_cell_t's describing the
790Sstevel@tonic-gate 	 * service requested.
800Sstevel@tonic-gate 	 */
810Sstevel@tonic-gate 	uint64_t bsys_1275_call;
820Sstevel@tonic-gate 
830Sstevel@tonic-gate 	/*
840Sstevel@tonic-gate 	 * print formatted output - PRINTFLIKE1
850Sstevel@tonic-gate 	 * here (and maintained) so old kernels can fail with
860Sstevel@tonic-gate 	 * an error message rather than something weird.
870Sstevel@tonic-gate 	 * not really 'printf' though.
880Sstevel@tonic-gate 	 */
890Sstevel@tonic-gate 	uint32_t	bsys_printf;
900Sstevel@tonic-gate } bootops_t;
910Sstevel@tonic-gate 
925648Ssetje extern void bop_init(void);
935648Ssetje extern int bop_open(const char *s, int flags);
945648Ssetje extern int bop_read(int fd, caddr_t buf, size_t size);
955648Ssetje extern int bop_seek(int fd, off_t off);
965648Ssetje extern int bop_close(int fd);
975648Ssetje extern caddr_t bop_alloc(caddr_t virthint, size_t size, int align);
985648Ssetje extern caddr_t bop_alloc_virt(caddr_t virt, size_t size);
995648Ssetje extern caddr_t bop_temp_alloc(size_t size, int align);
1007218Ssvemuri extern caddr_t bop_alloc_chunk(caddr_t virthint, size_t size, int align);
1015648Ssetje extern void bop_free(caddr_t virt, size_t size);
1025648Ssetje extern int bop_getproplen(const char *name);
1035648Ssetje extern int bop_getprop(const char *name, void *value);
1045648Ssetje extern int bop_mountroot(void);
1055648Ssetje extern int bop_unmountroot(void);
1065648Ssetje extern int bop_fstat(int fd, struct bootstat *st);
1075648Ssetje extern void bop_enter_mon(void);
1085648Ssetje extern void bop_fini(void);
1090Sstevel@tonic-gate 
1105648Ssetje extern void bop_printf(void *ops, const char *fmt, ...);
1115648Ssetje extern void bop_putsarg(const char *fmt, char *arg);
1125648Ssetje extern void bop_panic(const char *s);
1135648Ssetje 
1145648Ssetje #define	BOP_OPEN(s, flags)		bop_open(s, flags)
1155648Ssetje #define	BOP_READ(fd, buf, size)		bop_read(fd, buf, size)
1165648Ssetje #define	BOP_SEEK(fd, off)		bop_seek(fd, off)
1175648Ssetje #define	BOP_CLOSE(fd)			bop_close(fd)
1180Sstevel@tonic-gate #define	BOP_ALLOC(bop, virthint, size, align)	\
1195648Ssetje 				bop_alloc(virthint, size, align)
1205648Ssetje #define	BOP_ALLOC_VIRT(virt, size)	bop_alloc_virt(virt, size)
1215648Ssetje #define	BOP_FREE(bop, virt, size)	bop_free(virt, size)
1225648Ssetje #define	BOP_GETPROPLEN(bop, name)	bop_getproplen(name)
1235648Ssetje #define	BOP_GETPROP(bop, name, buf)	bop_getprop(name, buf)
1245648Ssetje #define	BOP_MOUNTROOT()			bop_mountroot()
1255648Ssetje #define	BOP_UNMOUNTROOT()		bop_unmountroot()
1265648Ssetje #define	BOP_FSTAT(bop, fd, st)		bop_fstat(fd, st)
1275648Ssetje 
1285648Ssetje /* special routine for kmdb only */
1295648Ssetje #define	BOP_PUTSARG(bop, fmt, arg)	bop_putsarg(fmt, arg)
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate /*
1320Sstevel@tonic-gate  * macros and declarations needed by clients of boot to
1330Sstevel@tonic-gate  * call the 1275-like boot interface routines.
1340Sstevel@tonic-gate  */
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate typedef unsigned long long boot_cell_t;
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate /*
1390Sstevel@tonic-gate  * Macros that work in both compilation models, to permit either a
1400Sstevel@tonic-gate  * sun4u/ILP32 or a sun4u/LP64 program to interface with the new
1410Sstevel@tonic-gate  * 1275-like boot service replacement for bootops.
1420Sstevel@tonic-gate  *
1430Sstevel@tonic-gate  * These macros stuff/unstuff arguments into/from boot_cell_t's, which are
1440Sstevel@tonic-gate  * fixed size in all models. Note that some of the types (e.g. off_t)
1450Sstevel@tonic-gate  * change size in the models.
1460Sstevel@tonic-gate  */
1470Sstevel@tonic-gate #define	boot_ptr2cell(p)	((boot_cell_t)((uintptr_t)((void *)(p))))
1480Sstevel@tonic-gate #define	boot_int2cell(i)	((boot_cell_t)((int)(i)))
1490Sstevel@tonic-gate #define	boot_uint2cell(u)	((boot_cell_t)((unsigned int)(u)))
1500Sstevel@tonic-gate #define	boot_uint642cell(u)	((boot_cell_t)((uint64_t)(u)))
1510Sstevel@tonic-gate #define	boot_offt2cell(u)	((boot_cell_t)((off_t)(u)))
1520Sstevel@tonic-gate #define	boot_size2cell(u)	((boot_cell_t)((size_t)(u)))
1530Sstevel@tonic-gate #define	boot_phandle2cell(ph)	((boot_cell_t)((unsigned)((phandle_t)(ph))))
154789Sahrens #define	boot_dnode2cell(d)	((boot_cell_t)((unsigned)((pnode_t)(d))))
1550Sstevel@tonic-gate #define	boot_ihandle2cell(ih)	((boot_cell_t)((unsigned)((ihandle_t)(ih))))
1560Sstevel@tonic-gate 
157785Seota #define	boot_cell2ptr(p)	((void *)(uintptr_t)((boot_cell_t)(p)))
1580Sstevel@tonic-gate #define	boot_cell2int(i)	((int)((boot_cell_t)(i)))
1590Sstevel@tonic-gate #define	boot_cell2uint(u)	((unsigned int)((boot_cell_t)(u)))
1600Sstevel@tonic-gate #define	boot_cell2uint64(u)	((uint64_t)((boot_cell_t)(u)))
1610Sstevel@tonic-gate #define	boot_cell2offt(u)	((off_t)((boot_cell_t)(u)))
1620Sstevel@tonic-gate #define	boot_cell2size(u)	((size_t)((boot_cell_t)(u)))
1630Sstevel@tonic-gate #define	boot_cell2phandle(ph)	((phandle_t)((boot_cell_t)(ph)))
164789Sahrens #define	boot_cell2dnode(d)	((pnode_t)((boot_cell_t)(d)))
1650Sstevel@tonic-gate #define	boot_cell2ihandle(ih)	((ihandle_t)((boot_cell_t)(ih)))
1660Sstevel@tonic-gate #define	boot_cells2ull(h, l)	((unsigned long long)(boot_cell_t)(l))
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate #define	BOOT_SVC_FAIL	(int)(-1)
1690Sstevel@tonic-gate #define	BOOT_SVC_OK	(int)(1)
1700Sstevel@tonic-gate 
1710Sstevel@tonic-gate #if defined(_KERNEL) && !defined(_BOOT)
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate /*
1740Sstevel@tonic-gate  * Boot configuration information
1750Sstevel@tonic-gate  */
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate #define	BO_MAXFSNAME	16
1780Sstevel@tonic-gate #define	BO_MAXOBJNAME	256
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate struct bootobj {
1810Sstevel@tonic-gate 	char	bo_fstype[BO_MAXFSNAME];	/* vfs type name (e.g. nfs) */
1820Sstevel@tonic-gate 	char	bo_name[BO_MAXOBJNAME];		/* name of object */
1830Sstevel@tonic-gate 	int	bo_flags;			/* flags, see below */
1840Sstevel@tonic-gate 	int	bo_size;			/* number of blocks */
1850Sstevel@tonic-gate 	struct vnode *bo_vp;			/* vnode of object */
1860Sstevel@tonic-gate 	char	bo_devname[BO_MAXOBJNAME];
1870Sstevel@tonic-gate 	char	bo_ifname[BO_MAXOBJNAME];
1880Sstevel@tonic-gate 	int	bo_ppa;
1890Sstevel@tonic-gate };
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate /*
1920Sstevel@tonic-gate  * flags
1930Sstevel@tonic-gate  */
1940Sstevel@tonic-gate #define	BO_VALID	0x01	/* all information in object is valid */
1950Sstevel@tonic-gate #define	BO_BUSY		0x02	/* object is busy */
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate extern struct bootobj rootfs;
1980Sstevel@tonic-gate extern struct bootobj swapfile;
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate extern char obp_bootpath[BO_MAXOBJNAME];
2010Sstevel@tonic-gate extern char svm_bootpath[BO_MAXOBJNAME];
2020Sstevel@tonic-gate 
2030Sstevel@tonic-gate extern dev_t getrootdev(void);
2040Sstevel@tonic-gate extern void getfsname(char *, char *, size_t);
2050Sstevel@tonic-gate extern int loadrootmodules(void);
2060Sstevel@tonic-gate 
2070Sstevel@tonic-gate extern int strplumb(void);
2080Sstevel@tonic-gate extern int strplumb_load(void);
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate extern void consconfig(void);
2115974Sjm22469 extern void release_bootstrap(void);
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate extern int dhcpinit(void);
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate /* XXX	Doesn't belong here */
2160Sstevel@tonic-gate extern int zsgetspeed(dev_t);
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate extern void param_check(void);
2190Sstevel@tonic-gate 
2200Sstevel@tonic-gate extern struct bootops *bootops;
2210Sstevel@tonic-gate extern int netboot;
2220Sstevel@tonic-gate extern int swaploaded;
2230Sstevel@tonic-gate extern int modrootloaded;
2240Sstevel@tonic-gate extern char kern_bootargs[];
225*7656SSherry.Moore@Sun.COM extern char kern_bootfile[];
2263446Smrj extern char *kobj_module_path;
2270Sstevel@tonic-gate extern char *default_path;
2280Sstevel@tonic-gate extern char *dhcack;
2295648Ssetje extern int dhcacklen;
2305648Ssetje extern char dhcifname[IFNAMSIZ];
2310Sstevel@tonic-gate extern char *netdev_path;
2320Sstevel@tonic-gate 
2334172Ssetje extern char *strplumb_get_netdev_path(void);
2344172Ssetje 
2350Sstevel@tonic-gate #endif /* _KERNEL && !_BOOT */
2360Sstevel@tonic-gate 
2370Sstevel@tonic-gate #ifdef __cplusplus
2380Sstevel@tonic-gate }
2390Sstevel@tonic-gate #endif
2400Sstevel@tonic-gate 
2410Sstevel@tonic-gate #endif	/* _SYS_BOOTCONF_H */
242