1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_BOOTCONF_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_BOOTCONF_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SunOS-4.0 1.7 */ 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * Boot time configuration information objects 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/memlist.h> 38*7c478bd9Sstevel@tonic-gate #include <sys/bootstat.h> 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 41*7c478bd9Sstevel@tonic-gate extern "C" { 42*7c478bd9Sstevel@tonic-gate #endif 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate /* 45*7c478bd9Sstevel@tonic-gate * masks to hand to bsys_alloc memory allocator 46*7c478bd9Sstevel@tonic-gate * XXX These names shouldn't really be srmmu derived. 47*7c478bd9Sstevel@tonic-gate */ 48*7c478bd9Sstevel@tonic-gate #define BO_NO_ALIGN 0x00001000 49*7c478bd9Sstevel@tonic-gate #define BO_ALIGN_L3 0x00001000 50*7c478bd9Sstevel@tonic-gate #define BO_ALIGN_L2 0x00040000 51*7c478bd9Sstevel@tonic-gate #define BO_ALIGN_L1 0x01000000 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate /* 54*7c478bd9Sstevel@tonic-gate * We pass a ptr to the space that boot has been using 55*7c478bd9Sstevel@tonic-gate * for its memory lists. 56*7c478bd9Sstevel@tonic-gate */ 57*7c478bd9Sstevel@tonic-gate struct bsys_mem { 58*7c478bd9Sstevel@tonic-gate struct memlist *physinstalled; /* amt of physmem installed */ 59*7c478bd9Sstevel@tonic-gate struct memlist *physavail; /* amt of physmem avail for use */ 60*7c478bd9Sstevel@tonic-gate struct memlist *virtavail; /* amt of virtmem avail for use */ 61*7c478bd9Sstevel@tonic-gate uint_t extent; /* number of bytes in the space */ 62*7c478bd9Sstevel@tonic-gate }; 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate #define BO_VERSION 9 /* bootops interface revision # */ 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate #define BOOTOPS_ARE_1275(bop) \ 67*7c478bd9Sstevel@tonic-gate ((BOP_GETVERSION(bop)) >= 9 && (bop->bsys_1275_call != 0)) 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate typedef struct bootops { 70*7c478bd9Sstevel@tonic-gate /* 71*7c478bd9Sstevel@tonic-gate * the ubiquitous version number 72*7c478bd9Sstevel@tonic-gate */ 73*7c478bd9Sstevel@tonic-gate uint_t bsys_version; 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate /* 76*7c478bd9Sstevel@tonic-gate * pointer to our parents bootops 77*7c478bd9Sstevel@tonic-gate */ 78*7c478bd9Sstevel@tonic-gate struct bootops *bsys_super; 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate /* 81*7c478bd9Sstevel@tonic-gate * the area containing boot's memlists (non-LP64 boot) 82*7c478bd9Sstevel@tonic-gate */ 83*7c478bd9Sstevel@tonic-gate struct bsys_mem *boot_mem; 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate #ifndef _LP64 86*7c478bd9Sstevel@tonic-gate uint32_t bsys_pad2[2]; /* pointers above get larger */ 87*7c478bd9Sstevel@tonic-gate #endif 88*7c478bd9Sstevel@tonic-gate /* 89*7c478bd9Sstevel@tonic-gate * The entry point to jump to for boot services. 90*7c478bd9Sstevel@tonic-gate * Pass this routine the array of boot_cell_t's describing the 91*7c478bd9Sstevel@tonic-gate * service requested. 92*7c478bd9Sstevel@tonic-gate */ 93*7c478bd9Sstevel@tonic-gate uint64_t bsys_1275_call; 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate uint32_t bsys_pad1[7]; 96*7c478bd9Sstevel@tonic-gate /* 97*7c478bd9Sstevel@tonic-gate * print formatted output - PRINTFLIKE1 98*7c478bd9Sstevel@tonic-gate * here (and maintained) so old kernels can fail with 99*7c478bd9Sstevel@tonic-gate * an error message rather than something weird. 100*7c478bd9Sstevel@tonic-gate * not really 'printf' though. 101*7c478bd9Sstevel@tonic-gate */ 102*7c478bd9Sstevel@tonic-gate uint32_t bsys_printf; 103*7c478bd9Sstevel@tonic-gate } bootops_t; 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate extern uint_t bop_getversion(struct bootops *bootops); 106*7c478bd9Sstevel@tonic-gate extern int bop_open(struct bootops *bop, char *s, int flags); 107*7c478bd9Sstevel@tonic-gate extern int bop_read(struct bootops *bop, int fd, caddr_t buf, size_t size); 108*7c478bd9Sstevel@tonic-gate extern int bop_seek(struct bootops *bop, int fd, off_t hi, off_t lo); 109*7c478bd9Sstevel@tonic-gate extern int bop_close(struct bootops *bop, int fd); 110*7c478bd9Sstevel@tonic-gate extern caddr_t bop_alloc(struct bootops *bop, caddr_t virthint, size_t size, 111*7c478bd9Sstevel@tonic-gate int align); 112*7c478bd9Sstevel@tonic-gate extern caddr_t bop_alloc_virt(struct bootops *bop, caddr_t virt, size_t size); 113*7c478bd9Sstevel@tonic-gate extern void bop_free(struct bootops *bop, caddr_t virt, size_t size); 114*7c478bd9Sstevel@tonic-gate extern caddr_t bop_map(struct bootops *bop, caddr_t virt, int space, 115*7c478bd9Sstevel@tonic-gate caddr_t phys, size_t size); 116*7c478bd9Sstevel@tonic-gate extern void bop_unmap(struct bootops *bop, caddr_t virt, size_t size); 117*7c478bd9Sstevel@tonic-gate extern void bop_quiesce_io(struct bootops *bop); 118*7c478bd9Sstevel@tonic-gate extern int bop_getproplen(struct bootops *bop, char *name); 119*7c478bd9Sstevel@tonic-gate extern int bop_getprop(struct bootops *bop, char *name, void *value); 120*7c478bd9Sstevel@tonic-gate extern char *bop_nextprop(struct bootops *bop, char *prevprop); 121*7c478bd9Sstevel@tonic-gate extern int bop_mountroot(struct bootops *bop, char *path); 122*7c478bd9Sstevel@tonic-gate extern int bop_unmountroot(struct bootops *bop); 123*7c478bd9Sstevel@tonic-gate extern void bop_puts(struct bootops *, char *); 124*7c478bd9Sstevel@tonic-gate extern void bop_putsarg(struct bootops *, const char *, ...); 125*7c478bd9Sstevel@tonic-gate extern int bop_fstat(struct bootops *, int fd, struct bootstat *); 126*7c478bd9Sstevel@tonic-gate extern void bop_enter_mon(struct bootops *bop); 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate #define BOP_GETVERSION(bop) bop_getversion(bop) 129*7c478bd9Sstevel@tonic-gate #define BOP_OPEN(bop, s, flags) bop_open(bop, s, flags) 130*7c478bd9Sstevel@tonic-gate #define BOP_READ(bop, fd, buf, size) bop_read(bop, fd, buf, size) 131*7c478bd9Sstevel@tonic-gate #define BOP_SEEK(bop, fd, hi, lo) bop_seek(bop, fd, hi, lo) 132*7c478bd9Sstevel@tonic-gate #define BOP_CLOSE(bop, fd) bop_close(bop, fd) 133*7c478bd9Sstevel@tonic-gate #define BOP_ALLOC(bop, virthint, size, align) \ 134*7c478bd9Sstevel@tonic-gate bop_alloc(bop, virthint, size, align) 135*7c478bd9Sstevel@tonic-gate #define BOP_ALLOC_VIRT(bop, virt, size) bop_alloc_virt(bop, virt, size) 136*7c478bd9Sstevel@tonic-gate #define BOP_FREE(bop, virt, size) bop_free(bop, virt, size) 137*7c478bd9Sstevel@tonic-gate #define BOP_MAP(bop, virt, space, phys, size) \ 138*7c478bd9Sstevel@tonic-gate bop_map(bop, virt, space, phys, size) 139*7c478bd9Sstevel@tonic-gate #define BOP_UNMAP(bop, virt, size) bop_unmap(bop, virt, size) 140*7c478bd9Sstevel@tonic-gate #define BOP_QUIESCE_IO(bop) bop_quiesce_io(bop) 141*7c478bd9Sstevel@tonic-gate #define BOP_GETPROPLEN(bop, name) bop_getproplen(bop, name) 142*7c478bd9Sstevel@tonic-gate #define BOP_GETPROP(bop, name, buf) bop_getprop(bop, name, buf) 143*7c478bd9Sstevel@tonic-gate #define BOP_NEXTPROP(bop, prev) bop_nextprop(bop, prev) 144*7c478bd9Sstevel@tonic-gate #define BOP_MOUNTROOT(bop, path) bop_mountroot(bop, path) 145*7c478bd9Sstevel@tonic-gate #define BOP_UNMOUNTROOT(bop) bop_unmountroot(bop) 146*7c478bd9Sstevel@tonic-gate #define BOP_PUTS(bop, msg) bop_puts(bop, msg) 147*7c478bd9Sstevel@tonic-gate #define BOP_PUTSARG(bop, msg, arg) bop_putsarg(bop, msg, arg) 148*7c478bd9Sstevel@tonic-gate #define BOP_FSTAT(bop, fd, st) bop_fstat(bop, fd, st) 149*7c478bd9Sstevel@tonic-gate #define BOP_ENTER_MON(bop) bop_enter_mon(bop) 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate /* 152*7c478bd9Sstevel@tonic-gate * macros and declarations needed by clients of boot to 153*7c478bd9Sstevel@tonic-gate * call the 1275-like boot interface routines. 154*7c478bd9Sstevel@tonic-gate */ 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate typedef unsigned long long boot_cell_t; 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate /* 159*7c478bd9Sstevel@tonic-gate * Macros that work in both compilation models, to permit either a 160*7c478bd9Sstevel@tonic-gate * sun4u/ILP32 or a sun4u/LP64 program to interface with the new 161*7c478bd9Sstevel@tonic-gate * 1275-like boot service replacement for bootops. 162*7c478bd9Sstevel@tonic-gate * 163*7c478bd9Sstevel@tonic-gate * These macros stuff/unstuff arguments into/from boot_cell_t's, which are 164*7c478bd9Sstevel@tonic-gate * fixed size in all models. Note that some of the types (e.g. off_t) 165*7c478bd9Sstevel@tonic-gate * change size in the models. 166*7c478bd9Sstevel@tonic-gate */ 167*7c478bd9Sstevel@tonic-gate #define boot_ptr2cell(p) ((boot_cell_t)((uintptr_t)((void *)(p)))) 168*7c478bd9Sstevel@tonic-gate #define boot_int2cell(i) ((boot_cell_t)((int)(i))) 169*7c478bd9Sstevel@tonic-gate #define boot_uint2cell(u) ((boot_cell_t)((unsigned int)(u))) 170*7c478bd9Sstevel@tonic-gate #define boot_uint642cell(u) ((boot_cell_t)((uint64_t)(u))) 171*7c478bd9Sstevel@tonic-gate #define boot_offt2cell(u) ((boot_cell_t)((off_t)(u))) 172*7c478bd9Sstevel@tonic-gate #define boot_size2cell(u) ((boot_cell_t)((size_t)(u))) 173*7c478bd9Sstevel@tonic-gate #define boot_phandle2cell(ph) ((boot_cell_t)((unsigned)((phandle_t)(ph)))) 174*7c478bd9Sstevel@tonic-gate #define boot_dnode2cell(d) ((boot_cell_t)((unsigned)((dnode_t)(d)))) 175*7c478bd9Sstevel@tonic-gate #define boot_ihandle2cell(ih) ((boot_cell_t)((unsigned)((ihandle_t)(ih)))) 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate #define boot_cell2ptr(p) ((void *)((boot_cell_t)(p))) 178*7c478bd9Sstevel@tonic-gate #define boot_cell2int(i) ((int)((boot_cell_t)(i))) 179*7c478bd9Sstevel@tonic-gate #define boot_cell2uint(u) ((unsigned int)((boot_cell_t)(u))) 180*7c478bd9Sstevel@tonic-gate #define boot_cell2uint64(u) ((uint64_t)((boot_cell_t)(u))) 181*7c478bd9Sstevel@tonic-gate #define boot_cell2offt(u) ((off_t)((boot_cell_t)(u))) 182*7c478bd9Sstevel@tonic-gate #define boot_cell2size(u) ((size_t)((boot_cell_t)(u))) 183*7c478bd9Sstevel@tonic-gate #define boot_cell2phandle(ph) ((phandle_t)((boot_cell_t)(ph))) 184*7c478bd9Sstevel@tonic-gate #define boot_cell2dnode(d) ((dnode_t)((boot_cell_t)(d))) 185*7c478bd9Sstevel@tonic-gate #define boot_cell2ihandle(ih) ((ihandle_t)((boot_cell_t)(ih))) 186*7c478bd9Sstevel@tonic-gate #define boot_cells2ull(h, l) ((unsigned long long)(boot_cell_t)(l)) 187*7c478bd9Sstevel@tonic-gate 188*7c478bd9Sstevel@tonic-gate #define BOOT_SVC_FAIL (int)(-1) 189*7c478bd9Sstevel@tonic-gate #define BOOT_SVC_OK (int)(1) 190*7c478bd9Sstevel@tonic-gate 191*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL) && !defined(_BOOT) 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate /* 194*7c478bd9Sstevel@tonic-gate * Boot configuration information 195*7c478bd9Sstevel@tonic-gate */ 196*7c478bd9Sstevel@tonic-gate 197*7c478bd9Sstevel@tonic-gate #define BO_MAXFSNAME 16 198*7c478bd9Sstevel@tonic-gate #define BO_MAXOBJNAME 256 199*7c478bd9Sstevel@tonic-gate 200*7c478bd9Sstevel@tonic-gate struct bootobj { 201*7c478bd9Sstevel@tonic-gate char bo_fstype[BO_MAXFSNAME]; /* vfs type name (e.g. nfs) */ 202*7c478bd9Sstevel@tonic-gate char bo_name[BO_MAXOBJNAME]; /* name of object */ 203*7c478bd9Sstevel@tonic-gate int bo_flags; /* flags, see below */ 204*7c478bd9Sstevel@tonic-gate int bo_size; /* number of blocks */ 205*7c478bd9Sstevel@tonic-gate struct vnode *bo_vp; /* vnode of object */ 206*7c478bd9Sstevel@tonic-gate char bo_devname[BO_MAXOBJNAME]; 207*7c478bd9Sstevel@tonic-gate char bo_ifname[BO_MAXOBJNAME]; 208*7c478bd9Sstevel@tonic-gate int bo_ppa; 209*7c478bd9Sstevel@tonic-gate }; 210*7c478bd9Sstevel@tonic-gate 211*7c478bd9Sstevel@tonic-gate /* 212*7c478bd9Sstevel@tonic-gate * flags 213*7c478bd9Sstevel@tonic-gate */ 214*7c478bd9Sstevel@tonic-gate #define BO_VALID 0x01 /* all information in object is valid */ 215*7c478bd9Sstevel@tonic-gate #define BO_BUSY 0x02 /* object is busy */ 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate extern struct bootobj rootfs; 218*7c478bd9Sstevel@tonic-gate extern struct bootobj swapfile; 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate extern char obp_bootpath[BO_MAXOBJNAME]; 221*7c478bd9Sstevel@tonic-gate extern char svm_bootpath[BO_MAXOBJNAME]; 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate extern dev_t getrootdev(void); 224*7c478bd9Sstevel@tonic-gate extern void getfsname(char *, char *, size_t); 225*7c478bd9Sstevel@tonic-gate extern int loadrootmodules(void); 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate extern int strplumb(void); 228*7c478bd9Sstevel@tonic-gate extern int strplumb_load(void); 229*7c478bd9Sstevel@tonic-gate 230*7c478bd9Sstevel@tonic-gate extern void consconfig(void); 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate extern int dhcpinit(void); 233*7c478bd9Sstevel@tonic-gate 234*7c478bd9Sstevel@tonic-gate /* XXX Doesn't belong here */ 235*7c478bd9Sstevel@tonic-gate extern int zsgetspeed(dev_t); 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate extern void param_check(void); 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate extern struct bootops *bootops; 240*7c478bd9Sstevel@tonic-gate extern int netboot; 241*7c478bd9Sstevel@tonic-gate extern int swaploaded; 242*7c478bd9Sstevel@tonic-gate extern int modrootloaded; 243*7c478bd9Sstevel@tonic-gate extern char kern_bootargs[]; 244*7c478bd9Sstevel@tonic-gate extern char *default_path; 245*7c478bd9Sstevel@tonic-gate extern char *dhcack; 246*7c478bd9Sstevel@tonic-gate extern char *netdev_path; 247*7c478bd9Sstevel@tonic-gate 248*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL && !_BOOT */ 249*7c478bd9Sstevel@tonic-gate 250*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 251*7c478bd9Sstevel@tonic-gate } 252*7c478bd9Sstevel@tonic-gate #endif 253*7c478bd9Sstevel@tonic-gate 254*7c478bd9Sstevel@tonic-gate #endif /* _SYS_BOOTCONF_H */ 255