xref: /titanic_53/usr/src/uts/sun/sys/bootconf.h (revision fa9e4066f08beec538e775443c5be79dd423fcab)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_BOOTCONF_H
287c478bd9Sstevel@tonic-gate #define	_SYS_BOOTCONF_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI" /* SunOS-4.0 1.7 */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * Boot time configuration information objects
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
377c478bd9Sstevel@tonic-gate #include <sys/memlist.h>
387c478bd9Sstevel@tonic-gate #include <sys/bootstat.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifdef __cplusplus
417c478bd9Sstevel@tonic-gate extern "C" {
427c478bd9Sstevel@tonic-gate #endif
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * masks to hand to bsys_alloc memory allocator
467c478bd9Sstevel@tonic-gate  * XXX	These names shouldn't really be srmmu derived.
477c478bd9Sstevel@tonic-gate  */
487c478bd9Sstevel@tonic-gate #define	BO_NO_ALIGN	0x00001000
497c478bd9Sstevel@tonic-gate #define	BO_ALIGN_L3	0x00001000
507c478bd9Sstevel@tonic-gate #define	BO_ALIGN_L2	0x00040000
517c478bd9Sstevel@tonic-gate #define	BO_ALIGN_L1	0x01000000
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate  *  We pass a ptr to the space that boot has been using
557c478bd9Sstevel@tonic-gate  *  for its memory lists.
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate struct bsys_mem {
587c478bd9Sstevel@tonic-gate 	struct memlist *physinstalled;	/* amt of physmem installed */
597c478bd9Sstevel@tonic-gate 	struct memlist *physavail;	/* amt of physmem avail for use */
607c478bd9Sstevel@tonic-gate 	struct memlist *virtavail;	/* amt of virtmem avail for use */
617c478bd9Sstevel@tonic-gate 	uint_t		extent; 	/* number of bytes in the space */
627c478bd9Sstevel@tonic-gate };
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate #define	BO_VERSION	9		/* bootops interface revision # */
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate #define	BOOTOPS_ARE_1275(bop) \
677c478bd9Sstevel@tonic-gate 	((BOP_GETVERSION(bop)) >= 9 && (bop->bsys_1275_call != 0))
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate typedef struct bootops {
707c478bd9Sstevel@tonic-gate 	/*
717c478bd9Sstevel@tonic-gate 	 * the ubiquitous version number
727c478bd9Sstevel@tonic-gate 	 */
737c478bd9Sstevel@tonic-gate 	uint_t	bsys_version;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate 	/*
767c478bd9Sstevel@tonic-gate 	 * pointer to our parents bootops
777c478bd9Sstevel@tonic-gate 	 */
787c478bd9Sstevel@tonic-gate 	struct bootops  *bsys_super;
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate 	/*
817c478bd9Sstevel@tonic-gate 	 * the area containing boot's memlists (non-LP64 boot)
827c478bd9Sstevel@tonic-gate 	 */
837c478bd9Sstevel@tonic-gate 	struct  bsys_mem *boot_mem;
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate #ifndef _LP64
867c478bd9Sstevel@tonic-gate 	uint32_t	bsys_pad2[2]; /* pointers above get larger */
877c478bd9Sstevel@tonic-gate #endif
887c478bd9Sstevel@tonic-gate 	/*
897c478bd9Sstevel@tonic-gate 	 * The entry point to jump to for boot services.
907c478bd9Sstevel@tonic-gate 	 * Pass this routine the array of boot_cell_t's describing the
917c478bd9Sstevel@tonic-gate 	 * service requested.
927c478bd9Sstevel@tonic-gate 	 */
937c478bd9Sstevel@tonic-gate 	uint64_t bsys_1275_call;
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 	uint32_t	bsys_pad1[7];
967c478bd9Sstevel@tonic-gate 	/*
977c478bd9Sstevel@tonic-gate 	 * print formatted output - PRINTFLIKE1
987c478bd9Sstevel@tonic-gate 	 * here (and maintained) so old kernels can fail with
997c478bd9Sstevel@tonic-gate 	 * an error message rather than something weird.
1007c478bd9Sstevel@tonic-gate 	 * not really 'printf' though.
1017c478bd9Sstevel@tonic-gate 	 */
1027c478bd9Sstevel@tonic-gate 	uint32_t	bsys_printf;
1037c478bd9Sstevel@tonic-gate } bootops_t;
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate extern uint_t bop_getversion(struct bootops *bootops);
1067c478bd9Sstevel@tonic-gate extern int bop_open(struct bootops *bop, char *s, int flags);
1077c478bd9Sstevel@tonic-gate extern int bop_read(struct bootops *bop, int fd, caddr_t buf, size_t size);
1087c478bd9Sstevel@tonic-gate extern int bop_seek(struct bootops *bop, int fd, off_t hi, off_t lo);
1097c478bd9Sstevel@tonic-gate extern int bop_close(struct bootops *bop, int fd);
1107c478bd9Sstevel@tonic-gate extern caddr_t bop_alloc(struct bootops *bop, caddr_t virthint, size_t size,
1117c478bd9Sstevel@tonic-gate     int align);
1127c478bd9Sstevel@tonic-gate extern caddr_t bop_alloc_virt(struct bootops *bop, caddr_t virt, size_t size);
1137c478bd9Sstevel@tonic-gate extern void bop_free(struct bootops *bop, caddr_t virt, size_t size);
1147c478bd9Sstevel@tonic-gate extern caddr_t bop_map(struct bootops *bop, caddr_t virt, int space,
1157c478bd9Sstevel@tonic-gate     caddr_t phys, size_t size);
1167c478bd9Sstevel@tonic-gate extern void bop_unmap(struct bootops *bop, caddr_t virt, size_t size);
1177c478bd9Sstevel@tonic-gate extern void bop_quiesce_io(struct bootops *bop);
1187c478bd9Sstevel@tonic-gate extern int bop_getproplen(struct bootops *bop, char *name);
1197c478bd9Sstevel@tonic-gate extern int bop_getprop(struct bootops *bop, char *name, void *value);
1207c478bd9Sstevel@tonic-gate extern char *bop_nextprop(struct bootops *bop, char *prevprop);
1217c478bd9Sstevel@tonic-gate extern int bop_mountroot(struct bootops *bop, char *path);
1227c478bd9Sstevel@tonic-gate extern int bop_unmountroot(struct bootops *bop);
1237c478bd9Sstevel@tonic-gate extern void bop_puts(struct bootops *, char *);
1247c478bd9Sstevel@tonic-gate extern void bop_putsarg(struct bootops *, const char *, ...);
1257c478bd9Sstevel@tonic-gate extern int bop_fstat(struct bootops *, int fd, struct bootstat *);
1267c478bd9Sstevel@tonic-gate extern void bop_enter_mon(struct bootops *bop);
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate #define	BOP_GETVERSION(bop)		bop_getversion(bop)
1297c478bd9Sstevel@tonic-gate #define	BOP_OPEN(bop, s, flags)		bop_open(bop, s, flags)
1307c478bd9Sstevel@tonic-gate #define	BOP_READ(bop, fd, buf, size)	bop_read(bop, fd, buf, size)
1317c478bd9Sstevel@tonic-gate #define	BOP_SEEK(bop, fd, hi, lo)	bop_seek(bop, fd, hi, lo)
1327c478bd9Sstevel@tonic-gate #define	BOP_CLOSE(bop, fd)		bop_close(bop, fd)
1337c478bd9Sstevel@tonic-gate #define	BOP_ALLOC(bop, virthint, size, align)	\
1347c478bd9Sstevel@tonic-gate 				bop_alloc(bop, virthint, size, align)
1357c478bd9Sstevel@tonic-gate #define	BOP_ALLOC_VIRT(bop, virt, size)	bop_alloc_virt(bop, virt, size)
1367c478bd9Sstevel@tonic-gate #define	BOP_FREE(bop, virt, size)	bop_free(bop, virt, size)
1377c478bd9Sstevel@tonic-gate #define	BOP_MAP(bop, virt, space, phys, size)	\
1387c478bd9Sstevel@tonic-gate 				bop_map(bop, virt, space, phys, size)
1397c478bd9Sstevel@tonic-gate #define	BOP_UNMAP(bop, virt, size)	bop_unmap(bop, virt, size)
1407c478bd9Sstevel@tonic-gate #define	BOP_QUIESCE_IO(bop)		bop_quiesce_io(bop)
1417c478bd9Sstevel@tonic-gate #define	BOP_GETPROPLEN(bop, name)	bop_getproplen(bop, name)
1427c478bd9Sstevel@tonic-gate #define	BOP_GETPROP(bop, name, buf)	bop_getprop(bop, name, buf)
1437c478bd9Sstevel@tonic-gate #define	BOP_NEXTPROP(bop, prev)		bop_nextprop(bop, prev)
1447c478bd9Sstevel@tonic-gate #define	BOP_MOUNTROOT(bop, path)	bop_mountroot(bop, path)
1457c478bd9Sstevel@tonic-gate #define	BOP_UNMOUNTROOT(bop)		bop_unmountroot(bop)
1467c478bd9Sstevel@tonic-gate #define	BOP_PUTS(bop, msg)		bop_puts(bop, msg)
1477c478bd9Sstevel@tonic-gate #define	BOP_PUTSARG(bop, msg, arg)	bop_putsarg(bop, msg, arg)
1487c478bd9Sstevel@tonic-gate #define	BOP_FSTAT(bop, fd, st)		bop_fstat(bop, fd, st)
1497c478bd9Sstevel@tonic-gate #define	BOP_ENTER_MON(bop)		bop_enter_mon(bop)
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * macros and declarations needed by clients of boot to
1537c478bd9Sstevel@tonic-gate  * call the 1275-like boot interface routines.
1547c478bd9Sstevel@tonic-gate  */
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate typedef unsigned long long boot_cell_t;
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate /*
1597c478bd9Sstevel@tonic-gate  * Macros that work in both compilation models, to permit either a
1607c478bd9Sstevel@tonic-gate  * sun4u/ILP32 or a sun4u/LP64 program to interface with the new
1617c478bd9Sstevel@tonic-gate  * 1275-like boot service replacement for bootops.
1627c478bd9Sstevel@tonic-gate  *
1637c478bd9Sstevel@tonic-gate  * These macros stuff/unstuff arguments into/from boot_cell_t's, which are
1647c478bd9Sstevel@tonic-gate  * fixed size in all models. Note that some of the types (e.g. off_t)
1657c478bd9Sstevel@tonic-gate  * change size in the models.
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate #define	boot_ptr2cell(p)	((boot_cell_t)((uintptr_t)((void *)(p))))
1687c478bd9Sstevel@tonic-gate #define	boot_int2cell(i)	((boot_cell_t)((int)(i)))
1697c478bd9Sstevel@tonic-gate #define	boot_uint2cell(u)	((boot_cell_t)((unsigned int)(u)))
1707c478bd9Sstevel@tonic-gate #define	boot_uint642cell(u)	((boot_cell_t)((uint64_t)(u)))
1717c478bd9Sstevel@tonic-gate #define	boot_offt2cell(u)	((boot_cell_t)((off_t)(u)))
1727c478bd9Sstevel@tonic-gate #define	boot_size2cell(u)	((boot_cell_t)((size_t)(u)))
1737c478bd9Sstevel@tonic-gate #define	boot_phandle2cell(ph)	((boot_cell_t)((unsigned)((phandle_t)(ph))))
174*fa9e4066Sahrens #define	boot_dnode2cell(d)	((boot_cell_t)((unsigned)((pnode_t)(d))))
1757c478bd9Sstevel@tonic-gate #define	boot_ihandle2cell(ih)	((boot_cell_t)((unsigned)((ihandle_t)(ih))))
1767c478bd9Sstevel@tonic-gate 
17753391bafSeota #define	boot_cell2ptr(p)	((void *)(uintptr_t)((boot_cell_t)(p)))
1787c478bd9Sstevel@tonic-gate #define	boot_cell2int(i)	((int)((boot_cell_t)(i)))
1797c478bd9Sstevel@tonic-gate #define	boot_cell2uint(u)	((unsigned int)((boot_cell_t)(u)))
1807c478bd9Sstevel@tonic-gate #define	boot_cell2uint64(u)	((uint64_t)((boot_cell_t)(u)))
1817c478bd9Sstevel@tonic-gate #define	boot_cell2offt(u)	((off_t)((boot_cell_t)(u)))
1827c478bd9Sstevel@tonic-gate #define	boot_cell2size(u)	((size_t)((boot_cell_t)(u)))
1837c478bd9Sstevel@tonic-gate #define	boot_cell2phandle(ph)	((phandle_t)((boot_cell_t)(ph)))
184*fa9e4066Sahrens #define	boot_cell2dnode(d)	((pnode_t)((boot_cell_t)(d)))
1857c478bd9Sstevel@tonic-gate #define	boot_cell2ihandle(ih)	((ihandle_t)((boot_cell_t)(ih)))
1867c478bd9Sstevel@tonic-gate #define	boot_cells2ull(h, l)	((unsigned long long)(boot_cell_t)(l))
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate #define	BOOT_SVC_FAIL	(int)(-1)
1897c478bd9Sstevel@tonic-gate #define	BOOT_SVC_OK	(int)(1)
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate #if defined(_KERNEL) && !defined(_BOOT)
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate  * Boot configuration information
1957c478bd9Sstevel@tonic-gate  */
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate #define	BO_MAXFSNAME	16
1987c478bd9Sstevel@tonic-gate #define	BO_MAXOBJNAME	256
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate struct bootobj {
2017c478bd9Sstevel@tonic-gate 	char	bo_fstype[BO_MAXFSNAME];	/* vfs type name (e.g. nfs) */
2027c478bd9Sstevel@tonic-gate 	char	bo_name[BO_MAXOBJNAME];		/* name of object */
2037c478bd9Sstevel@tonic-gate 	int	bo_flags;			/* flags, see below */
2047c478bd9Sstevel@tonic-gate 	int	bo_size;			/* number of blocks */
2057c478bd9Sstevel@tonic-gate 	struct vnode *bo_vp;			/* vnode of object */
2067c478bd9Sstevel@tonic-gate 	char	bo_devname[BO_MAXOBJNAME];
2077c478bd9Sstevel@tonic-gate 	char	bo_ifname[BO_MAXOBJNAME];
2087c478bd9Sstevel@tonic-gate 	int	bo_ppa;
2097c478bd9Sstevel@tonic-gate };
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate /*
2127c478bd9Sstevel@tonic-gate  * flags
2137c478bd9Sstevel@tonic-gate  */
2147c478bd9Sstevel@tonic-gate #define	BO_VALID	0x01	/* all information in object is valid */
2157c478bd9Sstevel@tonic-gate #define	BO_BUSY		0x02	/* object is busy */
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate extern struct bootobj rootfs;
2187c478bd9Sstevel@tonic-gate extern struct bootobj swapfile;
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate extern char obp_bootpath[BO_MAXOBJNAME];
2217c478bd9Sstevel@tonic-gate extern char svm_bootpath[BO_MAXOBJNAME];
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate extern dev_t getrootdev(void);
2247c478bd9Sstevel@tonic-gate extern void getfsname(char *, char *, size_t);
2257c478bd9Sstevel@tonic-gate extern int loadrootmodules(void);
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate extern int strplumb(void);
2287c478bd9Sstevel@tonic-gate extern int strplumb_load(void);
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate extern void consconfig(void);
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate extern int dhcpinit(void);
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate /* XXX	Doesn't belong here */
2357c478bd9Sstevel@tonic-gate extern int zsgetspeed(dev_t);
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate extern void param_check(void);
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate extern struct bootops *bootops;
2407c478bd9Sstevel@tonic-gate extern int netboot;
2417c478bd9Sstevel@tonic-gate extern int swaploaded;
2427c478bd9Sstevel@tonic-gate extern int modrootloaded;
2437c478bd9Sstevel@tonic-gate extern char kern_bootargs[];
2447c478bd9Sstevel@tonic-gate extern char *default_path;
2457c478bd9Sstevel@tonic-gate extern char *dhcack;
2467c478bd9Sstevel@tonic-gate extern char *netdev_path;
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate #endif /* _KERNEL && !_BOOT */
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2517c478bd9Sstevel@tonic-gate }
2527c478bd9Sstevel@tonic-gate #endif
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate #endif	/* _SYS_BOOTCONF_H */
255