xref: /titanic_50/usr/src/uts/sun/sys/bootconf.h (revision e373b6e444a487df89a5dc6a4a4030b5b2aa87f9)
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
5ea8dc4b6Seschrock  * Common Development and Distribution License (the "License").
6ea8dc4b6Seschrock  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21*e373b6e4SYuri Pankov 
227c478bd9Sstevel@tonic-gate /*
231b83305cSjm22469  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*e373b6e4SYuri Pankov  * Copyright 2016 Nexenta Systems, Inc.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_SYS_BOOTCONF_H
297c478bd9Sstevel@tonic-gate #define	_SYS_BOOTCONF_H
307c478bd9Sstevel@tonic-gate 
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>
37986fd29aSsetje #include <sys/varargs.h>
38986fd29aSsetje #include <sys/sysmacros.h>
397c478bd9Sstevel@tonic-gate #include <sys/memlist.h>
407c478bd9Sstevel@tonic-gate #include <sys/bootstat.h>
41986fd29aSsetje #include <net/if.h>			/* for IFNAMSIZ */
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #ifdef __cplusplus
447c478bd9Sstevel@tonic-gate extern "C" {
457c478bd9Sstevel@tonic-gate #endif
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate /*
487c478bd9Sstevel@tonic-gate  * masks to hand to bsys_alloc memory allocator
497c478bd9Sstevel@tonic-gate  * XXX	These names shouldn't really be srmmu derived.
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate #define	BO_NO_ALIGN	0x00001000
527c478bd9Sstevel@tonic-gate #define	BO_ALIGN_L3	0x00001000
537c478bd9Sstevel@tonic-gate #define	BO_ALIGN_L2	0x00040000
547c478bd9Sstevel@tonic-gate #define	BO_ALIGN_L1	0x01000000
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  *  We pass a ptr to the space that boot has been using
587c478bd9Sstevel@tonic-gate  *  for its memory lists.
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate struct bsys_mem {
617c478bd9Sstevel@tonic-gate 	struct memlist *physinstalled;	/* amt of physmem installed */
627c478bd9Sstevel@tonic-gate 	struct memlist *physavail;	/* amt of physmem avail for use */
637c478bd9Sstevel@tonic-gate 	struct memlist *virtavail;	/* amt of virtmem avail for use */
647c478bd9Sstevel@tonic-gate 	uint_t		extent; 	/* number of bytes in the space */
657c478bd9Sstevel@tonic-gate };
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #define	BO_VERSION	9		/* bootops interface revision # */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #define	BOOTOPS_ARE_1275(bop) \
707c478bd9Sstevel@tonic-gate 	((BOP_GETVERSION(bop)) >= 9 && (bop->bsys_1275_call != 0))
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate typedef struct bootops {
737c478bd9Sstevel@tonic-gate 	/*
747c478bd9Sstevel@tonic-gate 	 * the ubiquitous version number
757c478bd9Sstevel@tonic-gate 	 */
767c478bd9Sstevel@tonic-gate 	uint_t	bsys_version;
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate 	/*
797c478bd9Sstevel@tonic-gate 	 * The entry point to jump to for boot services.
807c478bd9Sstevel@tonic-gate 	 * Pass this routine the array of boot_cell_t's describing the
817c478bd9Sstevel@tonic-gate 	 * service requested.
827c478bd9Sstevel@tonic-gate 	 */
837c478bd9Sstevel@tonic-gate 	uint64_t bsys_1275_call;
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate 	/*
867c478bd9Sstevel@tonic-gate 	 * print formatted output - PRINTFLIKE1
877c478bd9Sstevel@tonic-gate 	 * here (and maintained) so old kernels can fail with
887c478bd9Sstevel@tonic-gate 	 * an error message rather than something weird.
897c478bd9Sstevel@tonic-gate 	 * not really 'printf' though.
907c478bd9Sstevel@tonic-gate 	 */
917c478bd9Sstevel@tonic-gate 	uint32_t	bsys_printf;
927c478bd9Sstevel@tonic-gate } bootops_t;
937c478bd9Sstevel@tonic-gate 
94986fd29aSsetje extern void bop_init(void);
95986fd29aSsetje extern int bop_open(const char *s, int flags);
96986fd29aSsetje extern int bop_read(int fd, caddr_t buf, size_t size);
97986fd29aSsetje extern int bop_seek(int fd, off_t off);
98986fd29aSsetje extern int bop_close(int fd);
99986fd29aSsetje extern caddr_t bop_alloc(caddr_t virthint, size_t size, int align);
100986fd29aSsetje extern caddr_t bop_alloc_virt(caddr_t virt, size_t size);
101986fd29aSsetje extern caddr_t bop_temp_alloc(size_t size, int align);
102ca622e3aSsvemuri extern caddr_t bop_alloc_chunk(caddr_t virthint, size_t size, int align);
103986fd29aSsetje extern void bop_free(caddr_t virt, size_t size);
104986fd29aSsetje extern int bop_getproplen(const char *name);
105986fd29aSsetje extern int bop_getprop(const char *name, void *value);
106986fd29aSsetje extern int bop_mountroot(void);
107986fd29aSsetje extern int bop_unmountroot(void);
108986fd29aSsetje extern int bop_fstat(int fd, struct bootstat *st);
109986fd29aSsetje extern void bop_enter_mon(void);
110986fd29aSsetje extern void bop_fini(void);
1117c478bd9Sstevel@tonic-gate 
112986fd29aSsetje extern void bop_printf(void *ops, const char *fmt, ...);
113986fd29aSsetje extern void bop_putsarg(const char *fmt, char *arg);
114986fd29aSsetje extern void bop_panic(const char *s);
115986fd29aSsetje 
116986fd29aSsetje #define	BOP_OPEN(s, flags)		bop_open(s, flags)
117986fd29aSsetje #define	BOP_READ(fd, buf, size)		bop_read(fd, buf, size)
118986fd29aSsetje #define	BOP_SEEK(fd, off)		bop_seek(fd, off)
119986fd29aSsetje #define	BOP_CLOSE(fd)			bop_close(fd)
1207c478bd9Sstevel@tonic-gate #define	BOP_ALLOC(bop, virthint, size, align)	\
121986fd29aSsetje 				bop_alloc(virthint, size, align)
122986fd29aSsetje #define	BOP_ALLOC_VIRT(virt, size)	bop_alloc_virt(virt, size)
123986fd29aSsetje #define	BOP_FREE(bop, virt, size)	bop_free(virt, size)
124986fd29aSsetje #define	BOP_GETPROPLEN(bop, name)	bop_getproplen(name)
125986fd29aSsetje #define	BOP_GETPROP(bop, name, buf)	bop_getprop(name, buf)
126986fd29aSsetje #define	BOP_MOUNTROOT()			bop_mountroot()
127986fd29aSsetje #define	BOP_UNMOUNTROOT()		bop_unmountroot()
128986fd29aSsetje #define	BOP_FSTAT(bop, fd, st)		bop_fstat(fd, st)
129986fd29aSsetje 
130986fd29aSsetje /* special routine for kmdb only */
131986fd29aSsetje #define	BOP_PUTSARG(bop, fmt, arg)	bop_putsarg(fmt, arg)
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate /*
1347c478bd9Sstevel@tonic-gate  * macros and declarations needed by clients of boot to
1357c478bd9Sstevel@tonic-gate  * call the 1275-like boot interface routines.
1367c478bd9Sstevel@tonic-gate  */
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate typedef unsigned long long boot_cell_t;
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate /*
1417c478bd9Sstevel@tonic-gate  * Macros that work in both compilation models, to permit either a
1427c478bd9Sstevel@tonic-gate  * sun4u/ILP32 or a sun4u/LP64 program to interface with the new
1437c478bd9Sstevel@tonic-gate  * 1275-like boot service replacement for bootops.
1447c478bd9Sstevel@tonic-gate  *
1457c478bd9Sstevel@tonic-gate  * These macros stuff/unstuff arguments into/from boot_cell_t's, which are
1467c478bd9Sstevel@tonic-gate  * fixed size in all models. Note that some of the types (e.g. off_t)
1477c478bd9Sstevel@tonic-gate  * change size in the models.
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate #define	boot_ptr2cell(p)	((boot_cell_t)((uintptr_t)((void *)(p))))
1507c478bd9Sstevel@tonic-gate #define	boot_int2cell(i)	((boot_cell_t)((int)(i)))
1517c478bd9Sstevel@tonic-gate #define	boot_uint2cell(u)	((boot_cell_t)((unsigned int)(u)))
1527c478bd9Sstevel@tonic-gate #define	boot_uint642cell(u)	((boot_cell_t)((uint64_t)(u)))
1537c478bd9Sstevel@tonic-gate #define	boot_offt2cell(u)	((boot_cell_t)((off_t)(u)))
1547c478bd9Sstevel@tonic-gate #define	boot_size2cell(u)	((boot_cell_t)((size_t)(u)))
1557c478bd9Sstevel@tonic-gate #define	boot_phandle2cell(ph)	((boot_cell_t)((unsigned)((phandle_t)(ph))))
156fa9e4066Sahrens #define	boot_dnode2cell(d)	((boot_cell_t)((unsigned)((pnode_t)(d))))
1577c478bd9Sstevel@tonic-gate #define	boot_ihandle2cell(ih)	((boot_cell_t)((unsigned)((ihandle_t)(ih))))
1587c478bd9Sstevel@tonic-gate 
15953391bafSeota #define	boot_cell2ptr(p)	((void *)(uintptr_t)((boot_cell_t)(p)))
1607c478bd9Sstevel@tonic-gate #define	boot_cell2int(i)	((int)((boot_cell_t)(i)))
1617c478bd9Sstevel@tonic-gate #define	boot_cell2uint(u)	((unsigned int)((boot_cell_t)(u)))
1627c478bd9Sstevel@tonic-gate #define	boot_cell2uint64(u)	((uint64_t)((boot_cell_t)(u)))
1637c478bd9Sstevel@tonic-gate #define	boot_cell2offt(u)	((off_t)((boot_cell_t)(u)))
1647c478bd9Sstevel@tonic-gate #define	boot_cell2size(u)	((size_t)((boot_cell_t)(u)))
1657c478bd9Sstevel@tonic-gate #define	boot_cell2phandle(ph)	((phandle_t)((boot_cell_t)(ph)))
166fa9e4066Sahrens #define	boot_cell2dnode(d)	((pnode_t)((boot_cell_t)(d)))
1677c478bd9Sstevel@tonic-gate #define	boot_cell2ihandle(ih)	((ihandle_t)((boot_cell_t)(ih)))
1687c478bd9Sstevel@tonic-gate #define	boot_cells2ull(h, l)	((unsigned long long)(boot_cell_t)(l))
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate #define	BOOT_SVC_FAIL	(int)(-1)
1717c478bd9Sstevel@tonic-gate #define	BOOT_SVC_OK	(int)(1)
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate #if defined(_KERNEL) && !defined(_BOOT)
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate /*
1767c478bd9Sstevel@tonic-gate  * Boot configuration information
1777c478bd9Sstevel@tonic-gate  */
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate #define	BO_MAXFSNAME	16
1807c478bd9Sstevel@tonic-gate #define	BO_MAXOBJNAME	256
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate struct bootobj {
1837c478bd9Sstevel@tonic-gate 	char	bo_fstype[BO_MAXFSNAME];	/* vfs type name (e.g. nfs) */
1847c478bd9Sstevel@tonic-gate 	char	bo_name[BO_MAXOBJNAME];		/* name of object */
1857c478bd9Sstevel@tonic-gate 	int	bo_flags;			/* flags, see below */
1867c478bd9Sstevel@tonic-gate 	int	bo_size;			/* number of blocks */
1877c478bd9Sstevel@tonic-gate 	struct vnode *bo_vp;			/* vnode of object */
1887c478bd9Sstevel@tonic-gate 	char	bo_devname[BO_MAXOBJNAME];
1897c478bd9Sstevel@tonic-gate 	char	bo_ifname[BO_MAXOBJNAME];
1907c478bd9Sstevel@tonic-gate 	int	bo_ppa;
1917c478bd9Sstevel@tonic-gate };
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate  * flags
1957c478bd9Sstevel@tonic-gate  */
1967c478bd9Sstevel@tonic-gate #define	BO_VALID	0x01	/* all information in object is valid */
1977c478bd9Sstevel@tonic-gate #define	BO_BUSY		0x02	/* object is busy */
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate extern struct bootobj rootfs;
2007c478bd9Sstevel@tonic-gate extern struct bootobj swapfile;
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate extern char obp_bootpath[BO_MAXOBJNAME];
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate extern dev_t getrootdev(void);
2057c478bd9Sstevel@tonic-gate extern void getfsname(char *, char *, size_t);
2067c478bd9Sstevel@tonic-gate extern int loadrootmodules(void);
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate extern int strplumb(void);
2097c478bd9Sstevel@tonic-gate extern int strplumb_load(void);
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate extern void consconfig(void);
2121b83305cSjm22469 extern void release_bootstrap(void);
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate extern int dhcpinit(void);
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate /* XXX	Doesn't belong here */
2177c478bd9Sstevel@tonic-gate extern int zsgetspeed(dev_t);
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate extern void param_check(void);
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate extern struct bootops *bootops;
2227c478bd9Sstevel@tonic-gate extern int netboot;
2237c478bd9Sstevel@tonic-gate extern int swaploaded;
2247c478bd9Sstevel@tonic-gate extern int modrootloaded;
2257c478bd9Sstevel@tonic-gate extern char kern_bootargs[];
22619397407SSherry Moore extern char kern_bootfile[];
227ae115bc7Smrj extern char *kobj_module_path;
2287c478bd9Sstevel@tonic-gate extern char *default_path;
2297c478bd9Sstevel@tonic-gate extern char *dhcack;
230986fd29aSsetje extern int dhcacklen;
231986fd29aSsetje extern char dhcifname[IFNAMSIZ];
2327c478bd9Sstevel@tonic-gate extern char *netdev_path;
2337c478bd9Sstevel@tonic-gate 
234a9ddc71cSsetje extern char *strplumb_get_netdev_path(void);
235a9ddc71cSsetje 
2367c478bd9Sstevel@tonic-gate #endif /* _KERNEL && !_BOOT */
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2397c478bd9Sstevel@tonic-gate }
2407c478bd9Sstevel@tonic-gate #endif
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate #endif	/* _SYS_BOOTCONF_H */
243