1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate /* 30*0Sstevel@tonic-gate * Definitions of interfaces that provide services from the secondary 31*0Sstevel@tonic-gate * boot program to its clients (primarily Solaris, krtld, kmdb and their 32*0Sstevel@tonic-gate * successors.) This interface replaces the bootops (BOP) implementation 33*0Sstevel@tonic-gate * as the interface to be called by boot clients. 34*0Sstevel@tonic-gate * 35*0Sstevel@tonic-gate */ 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #include <sys/types.h> 38*0Sstevel@tonic-gate #include <sys/reboot.h> 39*0Sstevel@tonic-gate #include <sys/param.h> 40*0Sstevel@tonic-gate #include <sys/varargs.h> 41*0Sstevel@tonic-gate #include <sys/obpdefs.h> 42*0Sstevel@tonic-gate #include <sys/promif.h> 43*0Sstevel@tonic-gate #include <sys/bootconf.h> 44*0Sstevel@tonic-gate #include <sys/bootstat.h> 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate /* 47*0Sstevel@tonic-gate * Implementation of the "version" boot service. 48*0Sstevel@tonic-gate * Return the compiled version number of this implementation. 49*0Sstevel@tonic-gate * 50*0Sstevel@tonic-gate * Note: An individual service can be tested for and versioned with 51*0Sstevel@tonic-gate * bop_serviceavail(); 52*0Sstevel@tonic-gate * 53*0Sstevel@tonic-gate * Calling spec: 54*0Sstevel@tonic-gate * args[0] Service name string 55*0Sstevel@tonic-gate * args[1] #argument cells 56*0Sstevel@tonic-gate * args[2] #result cells 57*0Sstevel@tonic-gate * args[3] Res0: returned version number 58*0Sstevel@tonic-gate */ 59*0Sstevel@tonic-gate uint_t 60*0Sstevel@tonic-gate bop_getversion(struct bootops *bop) 61*0Sstevel@tonic-gate { 62*0Sstevel@tonic-gate return (bop->bsys_version); 63*0Sstevel@tonic-gate } 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate /* 67*0Sstevel@tonic-gate * Implementation of the "open" boot service. 68*0Sstevel@tonic-gate * 69*0Sstevel@tonic-gate * Calling spec: 70*0Sstevel@tonic-gate * args[0] Service name string 71*0Sstevel@tonic-gate * args[1] #argument cells 72*0Sstevel@tonic-gate * args[2] #result cells 73*0Sstevel@tonic-gate * args[3] filename string 74*0Sstevel@tonic-gate * args[4] flags 75*0Sstevel@tonic-gate * args[5] Res0: returned result 76*0Sstevel@tonic-gate * 77*0Sstevel@tonic-gate */ 78*0Sstevel@tonic-gate int 79*0Sstevel@tonic-gate bop_open(struct bootops *bop, char *name, int flags) 80*0Sstevel@tonic-gate { 81*0Sstevel@tonic-gate boot_cell_t args[6]; 82*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 85*0Sstevel@tonic-gate args[0] = boot_ptr2cell("open"); 86*0Sstevel@tonic-gate args[1] = 2; 87*0Sstevel@tonic-gate args[2] = 1; 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate args[3] = boot_ptr2cell(name); 90*0Sstevel@tonic-gate args[4] = boot_int2cell(flags); 91*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 92*0Sstevel@tonic-gate return (boot_cell2int(args[5])); 93*0Sstevel@tonic-gate } 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate /* 96*0Sstevel@tonic-gate * Implementation of the "read" boot service. 97*0Sstevel@tonic-gate * 98*0Sstevel@tonic-gate * Calling spec: 99*0Sstevel@tonic-gate * args[0] Service name string 100*0Sstevel@tonic-gate * args[1] #argument cells 101*0Sstevel@tonic-gate * args[2] #result cells 102*0Sstevel@tonic-gate * args[3] boot-opened file descriptor 103*0Sstevel@tonic-gate * args[4] client's buffer 104*0Sstevel@tonic-gate * args[5] size of read request 105*0Sstevel@tonic-gate * args[6] Res0: returned result 106*0Sstevel@tonic-gate * 107*0Sstevel@tonic-gate */ 108*0Sstevel@tonic-gate int 109*0Sstevel@tonic-gate bop_read(struct bootops *bop, int fd, caddr_t buf, size_t size) 110*0Sstevel@tonic-gate { 111*0Sstevel@tonic-gate boot_cell_t args[7]; 112*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 115*0Sstevel@tonic-gate args[0] = boot_ptr2cell("read"); 116*0Sstevel@tonic-gate args[1] = 3; 117*0Sstevel@tonic-gate args[2] = 1; 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate args[3] = boot_int2cell(fd); 120*0Sstevel@tonic-gate args[4] = boot_ptr2cell(buf); 121*0Sstevel@tonic-gate args[5] = boot_uint2cell(size); 122*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 123*0Sstevel@tonic-gate return (boot_cell2int(args[6])); 124*0Sstevel@tonic-gate } 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate /* 127*0Sstevel@tonic-gate * Implementation of the "seek" boot service. 128*0Sstevel@tonic-gate * 129*0Sstevel@tonic-gate * Calling spec: 130*0Sstevel@tonic-gate * args[0] Service name string 131*0Sstevel@tonic-gate * args[1] #argument cells 132*0Sstevel@tonic-gate * args[2] #result cells 133*0Sstevel@tonic-gate * args[3] boot-opened file descriptor 134*0Sstevel@tonic-gate * args[4] offset hi XXX just use one cell for offset? 135*0Sstevel@tonic-gate * args[5] offset lo 136*0Sstevel@tonic-gate * args[6] Res0: returned result 137*0Sstevel@tonic-gate */ 138*0Sstevel@tonic-gate int 139*0Sstevel@tonic-gate bop_seek(struct bootops *bop, int fd, off_t hi, off_t lo) 140*0Sstevel@tonic-gate { 141*0Sstevel@tonic-gate boot_cell_t args[7]; 142*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 145*0Sstevel@tonic-gate args[0] = boot_ptr2cell("seek"); 146*0Sstevel@tonic-gate args[1] = 3; 147*0Sstevel@tonic-gate args[2] = 1; 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate args[3] = boot_int2cell(fd); 150*0Sstevel@tonic-gate args[4] = boot_offt2cell(hi); 151*0Sstevel@tonic-gate args[5] = boot_offt2cell(lo); 152*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 153*0Sstevel@tonic-gate return (boot_cell2int(args[6])); 154*0Sstevel@tonic-gate } 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate /* 157*0Sstevel@tonic-gate * Implementation of the "close" boot service. 158*0Sstevel@tonic-gate * 159*0Sstevel@tonic-gate * Calling spec: 160*0Sstevel@tonic-gate * args[0] Service name string 161*0Sstevel@tonic-gate * args[1] #argument cells 162*0Sstevel@tonic-gate * args[2] #result cells 163*0Sstevel@tonic-gate * args[3] boot-opened file descriptor 164*0Sstevel@tonic-gate * args[4] Res0: returned result 165*0Sstevel@tonic-gate */ 166*0Sstevel@tonic-gate int 167*0Sstevel@tonic-gate bop_close(struct bootops *bop, int fd) 168*0Sstevel@tonic-gate { 169*0Sstevel@tonic-gate boot_cell_t args[5]; 170*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 171*0Sstevel@tonic-gate 172*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 173*0Sstevel@tonic-gate args[0] = boot_ptr2cell("close"); 174*0Sstevel@tonic-gate args[1] = 1; 175*0Sstevel@tonic-gate args[2] = 1; 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gate args[3] = boot_int2cell(fd); 178*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 179*0Sstevel@tonic-gate return (boot_cell2int(args[4])); 180*0Sstevel@tonic-gate } 181*0Sstevel@tonic-gate 182*0Sstevel@tonic-gate /* 183*0Sstevel@tonic-gate * Implementation of the "alloc" boot service. 184*0Sstevel@tonic-gate * 185*0Sstevel@tonic-gate * Calling spec: 186*0Sstevel@tonic-gate * args[0] Service name string 187*0Sstevel@tonic-gate * args[1] #argument cells 188*0Sstevel@tonic-gate * args[2] #result cells 189*0Sstevel@tonic-gate * args[3] virtual hint 190*0Sstevel@tonic-gate * args[4] size to allocate 191*0Sstevel@tonic-gate * args[5] alignment 192*0Sstevel@tonic-gate * args[6] Res0: returned result 193*0Sstevel@tonic-gate */ 194*0Sstevel@tonic-gate caddr_t 195*0Sstevel@tonic-gate bop_alloc(struct bootops *bop, caddr_t virthint, size_t size, int align) 196*0Sstevel@tonic-gate { 197*0Sstevel@tonic-gate boot_cell_t args[7]; 198*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 199*0Sstevel@tonic-gate 200*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 201*0Sstevel@tonic-gate args[0] = boot_ptr2cell("alloc"); 202*0Sstevel@tonic-gate args[1] = 3; 203*0Sstevel@tonic-gate args[2] = 1; 204*0Sstevel@tonic-gate 205*0Sstevel@tonic-gate args[3] = boot_ptr2cell(virthint); 206*0Sstevel@tonic-gate args[4] = boot_size2cell(size); 207*0Sstevel@tonic-gate args[5] = boot_int2cell(align); 208*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 209*0Sstevel@tonic-gate return ((caddr_t)boot_ptr2cell(args[6])); 210*0Sstevel@tonic-gate } 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate /* 213*0Sstevel@tonic-gate * Implementation of the "alloc_virt" boot service 214*0Sstevel@tonic-gate * 215*0Sstevel@tonic-gate * Calling spec: 216*0Sstevel@tonic-gate * args[0] Service name string 217*0Sstevel@tonic-gate * args[1] #argument cells 218*0Sstevel@tonic-gate * args[2] #result cells 219*0Sstevel@tonic-gate * args[3] virtual address 220*0Sstevel@tonic-gate * args[4] size to allocate 221*0Sstevel@tonic-gate * args[5] Resi: returned result 222*0Sstevel@tonic-gate */ 223*0Sstevel@tonic-gate caddr_t 224*0Sstevel@tonic-gate bop_alloc_virt(struct bootops *bop, caddr_t virt, size_t size) 225*0Sstevel@tonic-gate { 226*0Sstevel@tonic-gate boot_cell_t args[6]; 227*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 228*0Sstevel@tonic-gate 229*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 230*0Sstevel@tonic-gate args[0] = boot_ptr2cell("alloc_virt"); 231*0Sstevel@tonic-gate args[1] = 2; 232*0Sstevel@tonic-gate args[2] = 1; 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate args[3] = boot_ptr2cell(virt); 235*0Sstevel@tonic-gate args[4] = boot_size2cell(size); 236*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 237*0Sstevel@tonic-gate return ((caddr_t)boot_ptr2cell(args[5])); 238*0Sstevel@tonic-gate } 239*0Sstevel@tonic-gate 240*0Sstevel@tonic-gate /* 241*0Sstevel@tonic-gate * Implementation of the "free" boot service. 242*0Sstevel@tonic-gate * 243*0Sstevel@tonic-gate * Calling spec: 244*0Sstevel@tonic-gate * args[0] Service name string 245*0Sstevel@tonic-gate * args[1] #argument cells 246*0Sstevel@tonic-gate * args[2] #result cells 247*0Sstevel@tonic-gate * args[3] virtual hint 248*0Sstevel@tonic-gate * args[4] size to free 249*0Sstevel@tonic-gate * args[5] Res0: returned result 250*0Sstevel@tonic-gate */ 251*0Sstevel@tonic-gate /*ARGSUSED*/ 252*0Sstevel@tonic-gate void 253*0Sstevel@tonic-gate bop_free(struct bootops *bop, caddr_t virt, size_t size) 254*0Sstevel@tonic-gate { 255*0Sstevel@tonic-gate boot_cell_t args[6]; 256*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 257*0Sstevel@tonic-gate 258*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 259*0Sstevel@tonic-gate args[0] = boot_ptr2cell("free"); 260*0Sstevel@tonic-gate args[1] = 2; 261*0Sstevel@tonic-gate args[2] = 1; 262*0Sstevel@tonic-gate 263*0Sstevel@tonic-gate args[3] = boot_ptr2cell(virt); 264*0Sstevel@tonic-gate args[4] = boot_size2cell(size); 265*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 266*0Sstevel@tonic-gate } 267*0Sstevel@tonic-gate 268*0Sstevel@tonic-gate /* 269*0Sstevel@tonic-gate * Implementation of the "map" boot service. 270*0Sstevel@tonic-gate * 271*0Sstevel@tonic-gate * Calling spec: 272*0Sstevel@tonic-gate * args[0] Service name string 273*0Sstevel@tonic-gate * args[1] #argument cells 274*0Sstevel@tonic-gate * args[2] #result cells 275*0Sstevel@tonic-gate * args[3] virtual address 276*0Sstevel@tonic-gate * args[4] space of phys addr 277*0Sstevel@tonic-gate * args[5] phys addr 278*0Sstevel@tonic-gate * args[6] size 279*0Sstevel@tonic-gate * args[7] Res0: returned result 280*0Sstevel@tonic-gate */ 281*0Sstevel@tonic-gate /*ARGSUSED*/ 282*0Sstevel@tonic-gate caddr_t 283*0Sstevel@tonic-gate bop_map(struct bootops *bop, caddr_t virt, int space, 284*0Sstevel@tonic-gate caddr_t phys, size_t size) 285*0Sstevel@tonic-gate { 286*0Sstevel@tonic-gate boot_cell_t args[8]; 287*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 288*0Sstevel@tonic-gate 289*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 290*0Sstevel@tonic-gate args[0] = boot_ptr2cell("map"); 291*0Sstevel@tonic-gate args[1] = 3; 292*0Sstevel@tonic-gate args[2] = 1; 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gate args[3] = boot_ptr2cell(virt); 295*0Sstevel@tonic-gate args[4] = boot_int2cell(space); 296*0Sstevel@tonic-gate args[5] = boot_ptr2cell(phys); 297*0Sstevel@tonic-gate args[6] = boot_size2cell(size); 298*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 299*0Sstevel@tonic-gate return ((caddr_t)boot_cell2ptr(args[7])); 300*0Sstevel@tonic-gate } 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate /* 303*0Sstevel@tonic-gate * Implementation of the "unmap" boot service. 304*0Sstevel@tonic-gate * 305*0Sstevel@tonic-gate * Calling spec: 306*0Sstevel@tonic-gate * args[0] Service name string 307*0Sstevel@tonic-gate * args[1] #argument cells 308*0Sstevel@tonic-gate * args[2] #result cells 309*0Sstevel@tonic-gate * args[3] virtual address 310*0Sstevel@tonic-gate * args[4] size of chunk 311*0Sstevel@tonic-gate * args[5] Res0: returned result 312*0Sstevel@tonic-gate */ 313*0Sstevel@tonic-gate /*ARGSUSED*/ 314*0Sstevel@tonic-gate void 315*0Sstevel@tonic-gate bop_unmap(struct bootops *bop, caddr_t virt, size_t size) 316*0Sstevel@tonic-gate { 317*0Sstevel@tonic-gate boot_cell_t args[6]; 318*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 321*0Sstevel@tonic-gate args[0] = boot_ptr2cell("unmap"); 322*0Sstevel@tonic-gate args[1] = 2; 323*0Sstevel@tonic-gate args[2] = 1; 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gate args[3] = boot_ptr2cell(virt); 326*0Sstevel@tonic-gate args[4] = boot_size2cell(size); 327*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 328*0Sstevel@tonic-gate } 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gate /* 331*0Sstevel@tonic-gate * Implementation of the "quiesce" boot service. 332*0Sstevel@tonic-gate * 333*0Sstevel@tonic-gate * Calling spec: 334*0Sstevel@tonic-gate * args[0] Service name string 335*0Sstevel@tonic-gate * args[1] #argument cells 336*0Sstevel@tonic-gate * args[2] #result cells 337*0Sstevel@tonic-gate * args[3] Res0: returned result 338*0Sstevel@tonic-gate */ 339*0Sstevel@tonic-gate /*ARGSUSED*/ 340*0Sstevel@tonic-gate void 341*0Sstevel@tonic-gate bop_quiesce_io(struct bootops *bop) 342*0Sstevel@tonic-gate { 343*0Sstevel@tonic-gate boot_cell_t args[4]; 344*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 345*0Sstevel@tonic-gate 346*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 347*0Sstevel@tonic-gate args[0] = boot_ptr2cell("quiesce"); 348*0Sstevel@tonic-gate args[1] = 0; 349*0Sstevel@tonic-gate args[2] = 1; 350*0Sstevel@tonic-gate 351*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 352*0Sstevel@tonic-gate } 353*0Sstevel@tonic-gate 354*0Sstevel@tonic-gate /* 355*0Sstevel@tonic-gate * Implementation of the "getproplen" boot service. 356*0Sstevel@tonic-gate * 357*0Sstevel@tonic-gate * Calling spec: 358*0Sstevel@tonic-gate * args[0] Service name string 359*0Sstevel@tonic-gate * args[1] #argument cells 360*0Sstevel@tonic-gate * args[2] #result cells 361*0Sstevel@tonic-gate * args[3] property name string 362*0Sstevel@tonic-gate * args[4] Res0: returned result 363*0Sstevel@tonic-gate */ 364*0Sstevel@tonic-gate /*ARGSUSED*/ 365*0Sstevel@tonic-gate int 366*0Sstevel@tonic-gate bop_getproplen(struct bootops *bop, char *name) 367*0Sstevel@tonic-gate { 368*0Sstevel@tonic-gate boot_cell_t args[7]; 369*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 370*0Sstevel@tonic-gate 371*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 372*0Sstevel@tonic-gate args[0] = boot_ptr2cell("getproplen"); 373*0Sstevel@tonic-gate args[1] = 1; 374*0Sstevel@tonic-gate args[2] = 1; 375*0Sstevel@tonic-gate 376*0Sstevel@tonic-gate args[3] = boot_ptr2cell(name); 377*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 378*0Sstevel@tonic-gate return (boot_cell2int(args[4])); 379*0Sstevel@tonic-gate } 380*0Sstevel@tonic-gate 381*0Sstevel@tonic-gate /* 382*0Sstevel@tonic-gate * Implementation of the "getprop" boot service. 383*0Sstevel@tonic-gate * 384*0Sstevel@tonic-gate * Calling spec: 385*0Sstevel@tonic-gate * args[0] Service name string 386*0Sstevel@tonic-gate * args[1] #argument cells 387*0Sstevel@tonic-gate * args[2] #result cells 388*0Sstevel@tonic-gate * args[3] property name string 389*0Sstevel@tonic-gate * args[4] buffer pointer to hold value of the property 390*0Sstevel@tonic-gate * args[5] Res0: returned result 391*0Sstevel@tonic-gate */ 392*0Sstevel@tonic-gate /*ARGSUSED*/ 393*0Sstevel@tonic-gate int 394*0Sstevel@tonic-gate bop_getprop(struct bootops *bop, char *name, void *value) 395*0Sstevel@tonic-gate { 396*0Sstevel@tonic-gate boot_cell_t args[6]; 397*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 398*0Sstevel@tonic-gate 399*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 400*0Sstevel@tonic-gate args[0] = boot_ptr2cell("getprop"); 401*0Sstevel@tonic-gate args[1] = 2; 402*0Sstevel@tonic-gate args[2] = 1; 403*0Sstevel@tonic-gate 404*0Sstevel@tonic-gate args[3] = boot_ptr2cell(name); 405*0Sstevel@tonic-gate args[4] = boot_ptr2cell(value); 406*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 407*0Sstevel@tonic-gate return (boot_cell2int(args[5])); 408*0Sstevel@tonic-gate } 409*0Sstevel@tonic-gate 410*0Sstevel@tonic-gate /* 411*0Sstevel@tonic-gate * Implementation of the "nextprop" boot service. 412*0Sstevel@tonic-gate * 413*0Sstevel@tonic-gate * Calling spec: 414*0Sstevel@tonic-gate * args[0] Service name string 415*0Sstevel@tonic-gate * args[1] #argument cells 416*0Sstevel@tonic-gate * args[2] #result cells 417*0Sstevel@tonic-gate * args[3] previous property name string 418*0Sstevel@tonic-gate * args[4] Res0: returned result 419*0Sstevel@tonic-gate */ 420*0Sstevel@tonic-gate /*ARGSUSED*/ 421*0Sstevel@tonic-gate char * 422*0Sstevel@tonic-gate bop_nextprop(struct bootops *bop, char *prevprop) 423*0Sstevel@tonic-gate { 424*0Sstevel@tonic-gate boot_cell_t args[5]; 425*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 426*0Sstevel@tonic-gate 427*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 428*0Sstevel@tonic-gate args[0] = boot_ptr2cell("nextprop"); 429*0Sstevel@tonic-gate args[1] = 1; 430*0Sstevel@tonic-gate args[2] = 1; 431*0Sstevel@tonic-gate 432*0Sstevel@tonic-gate args[3] = boot_ptr2cell(prevprop); 433*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 434*0Sstevel@tonic-gate return ((char *)boot_cell2ptr(args[4])); 435*0Sstevel@tonic-gate } 436*0Sstevel@tonic-gate 437*0Sstevel@tonic-gate /* 438*0Sstevel@tonic-gate * Implementation of the "puts" boot service. 439*0Sstevel@tonic-gate * 440*0Sstevel@tonic-gate * Calling spec: 441*0Sstevel@tonic-gate * args[0] Service name string 442*0Sstevel@tonic-gate * args[1] #argument cells 443*0Sstevel@tonic-gate * args[2] #result cells 444*0Sstevel@tonic-gate * args[3] string to print 445*0Sstevel@tonic-gate */ 446*0Sstevel@tonic-gate /*ARGSUSED*/ 447*0Sstevel@tonic-gate void 448*0Sstevel@tonic-gate bop_puts(struct bootops *bop, char *string) 449*0Sstevel@tonic-gate { 450*0Sstevel@tonic-gate boot_cell_t args[6]; 451*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 452*0Sstevel@tonic-gate void (*bsys_printf)(struct bootops *, char *, ...); 453*0Sstevel@tonic-gate 454*0Sstevel@tonic-gate /* so new kernel, old boot can print a message before dying */ 455*0Sstevel@tonic-gate if (!BOOTOPS_ARE_1275(bop)) { 456*0Sstevel@tonic-gate bsys_printf = (void (*)(struct bootops *, char *, ...)) 457*0Sstevel@tonic-gate (bop->bsys_printf); 458*0Sstevel@tonic-gate (*bsys_printf)(bop, string); 459*0Sstevel@tonic-gate return; 460*0Sstevel@tonic-gate } 461*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 462*0Sstevel@tonic-gate args[0] = boot_ptr2cell("puts"); 463*0Sstevel@tonic-gate args[1] = 1; 464*0Sstevel@tonic-gate args[2] = 0; 465*0Sstevel@tonic-gate 466*0Sstevel@tonic-gate args[3] = boot_ptr2cell(string); 467*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 468*0Sstevel@tonic-gate 469*0Sstevel@tonic-gate } 470*0Sstevel@tonic-gate 471*0Sstevel@tonic-gate /* 472*0Sstevel@tonic-gate * Implementation of the "putsarg" boot service. 473*0Sstevel@tonic-gate * 474*0Sstevel@tonic-gate * Calling spec: 475*0Sstevel@tonic-gate * args[0] Service name string 476*0Sstevel@tonic-gate * args[1] #argument cells 477*0Sstevel@tonic-gate * args[2] #result cells 478*0Sstevel@tonic-gate * args[3] string to print (with '%*' format) 479*0Sstevel@tonic-gate * args[4] 64-bit thing to print 480*0Sstevel@tonic-gate */ 481*0Sstevel@tonic-gate /*ARGSUSED*/ 482*0Sstevel@tonic-gate void 483*0Sstevel@tonic-gate bop_putsarg(struct bootops *bop, const char *string, ...) 484*0Sstevel@tonic-gate { 485*0Sstevel@tonic-gate boot_cell_t args[6]; 486*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 487*0Sstevel@tonic-gate void (*bsys_printf)(struct bootops *, char *, ...); 488*0Sstevel@tonic-gate va_list ap; 489*0Sstevel@tonic-gate const char *fmt = string; 490*0Sstevel@tonic-gate int ells = 0; 491*0Sstevel@tonic-gate uint64_t arg; 492*0Sstevel@tonic-gate 493*0Sstevel@tonic-gate /* 494*0Sstevel@tonic-gate * We need to do the minimum printf-like stuff here to figure 495*0Sstevel@tonic-gate * out the size of argument, if present. 496*0Sstevel@tonic-gate */ 497*0Sstevel@tonic-gate while (*fmt) { 498*0Sstevel@tonic-gate if (*fmt++ != '%') 499*0Sstevel@tonic-gate continue; 500*0Sstevel@tonic-gate if (*fmt == '%') { 501*0Sstevel@tonic-gate fmt++; 502*0Sstevel@tonic-gate continue; 503*0Sstevel@tonic-gate } 504*0Sstevel@tonic-gate 505*0Sstevel@tonic-gate while (*fmt >= '0' && *fmt <= '9') 506*0Sstevel@tonic-gate fmt++; 507*0Sstevel@tonic-gate for (ells = 0; *fmt == 'l'; fmt++) 508*0Sstevel@tonic-gate ells++; 509*0Sstevel@tonic-gate va_start(ap, string); 510*0Sstevel@tonic-gate switch (*fmt) { 511*0Sstevel@tonic-gate case 's': 512*0Sstevel@tonic-gate arg = (uint64_t)va_arg(ap, char *); 513*0Sstevel@tonic-gate break; 514*0Sstevel@tonic-gate case 'p': 515*0Sstevel@tonic-gate arg = (uint64_t)va_arg(ap, void *); 516*0Sstevel@tonic-gate break; 517*0Sstevel@tonic-gate case 'd': 518*0Sstevel@tonic-gate case 'D': 519*0Sstevel@tonic-gate case 'x': 520*0Sstevel@tonic-gate case 'X': 521*0Sstevel@tonic-gate case 'u': 522*0Sstevel@tonic-gate case 'U': 523*0Sstevel@tonic-gate case 'o': 524*0Sstevel@tonic-gate case 'O': 525*0Sstevel@tonic-gate if (ells == 0) 526*0Sstevel@tonic-gate arg = (uint64_t)va_arg(ap, uint_t); 527*0Sstevel@tonic-gate else if (ells == 1) 528*0Sstevel@tonic-gate arg = (uint64_t)va_arg(ap, ulong_t); 529*0Sstevel@tonic-gate else 530*0Sstevel@tonic-gate arg = (uint64_t)va_arg(ap, uint64_t); 531*0Sstevel@tonic-gate break; 532*0Sstevel@tonic-gate default: 533*0Sstevel@tonic-gate arg = (uint64_t)va_arg(ap, uint_t); 534*0Sstevel@tonic-gate break; 535*0Sstevel@tonic-gate } 536*0Sstevel@tonic-gate va_end(ap); 537*0Sstevel@tonic-gate break; 538*0Sstevel@tonic-gate } 539*0Sstevel@tonic-gate 540*0Sstevel@tonic-gate /* so new kernel, old boot can print a message before dying */ 541*0Sstevel@tonic-gate if (!BOOTOPS_ARE_1275(bop)) { 542*0Sstevel@tonic-gate bsys_printf = (void (*)(struct bootops *, char *, ...)) 543*0Sstevel@tonic-gate (bop->bsys_printf); 544*0Sstevel@tonic-gate (*bsys_printf)(bop, (char *)string, arg); 545*0Sstevel@tonic-gate return; 546*0Sstevel@tonic-gate } 547*0Sstevel@tonic-gate 548*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 549*0Sstevel@tonic-gate args[0] = boot_ptr2cell("putsarg"); 550*0Sstevel@tonic-gate args[1] = 2; 551*0Sstevel@tonic-gate args[2] = 0; 552*0Sstevel@tonic-gate args[3] = boot_ptr2cell(string); 553*0Sstevel@tonic-gate args[4] = boot_uint642cell(arg); 554*0Sstevel@tonic-gate 555*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 556*0Sstevel@tonic-gate } 557*0Sstevel@tonic-gate 558*0Sstevel@tonic-gate /* 559*0Sstevel@tonic-gate * Implementation of the "mount" boot service. 560*0Sstevel@tonic-gate * 561*0Sstevel@tonic-gate * Calling spec: 562*0Sstevel@tonic-gate * args[0] Service name string 563*0Sstevel@tonic-gate * args[1] #argument cells 564*0Sstevel@tonic-gate * args[2] #result cells 565*0Sstevel@tonic-gate * args[3] pathname string 566*0Sstevel@tonic-gate * args[4] Res0: returned result 567*0Sstevel@tonic-gate */ 568*0Sstevel@tonic-gate /*ARGSUSED*/ 569*0Sstevel@tonic-gate int 570*0Sstevel@tonic-gate bop_mountroot(struct bootops *bop, char *path) 571*0Sstevel@tonic-gate { 572*0Sstevel@tonic-gate boot_cell_t args[5]; 573*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 574*0Sstevel@tonic-gate 575*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 576*0Sstevel@tonic-gate args[0] = boot_ptr2cell("mountroot"); 577*0Sstevel@tonic-gate args[1] = 2; 578*0Sstevel@tonic-gate args[2] = 1; 579*0Sstevel@tonic-gate 580*0Sstevel@tonic-gate args[3] = boot_ptr2cell(path); 581*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 582*0Sstevel@tonic-gate return (boot_cell2int(args[4])); 583*0Sstevel@tonic-gate } 584*0Sstevel@tonic-gate 585*0Sstevel@tonic-gate /* 586*0Sstevel@tonic-gate * Implementation of the "unmountroot" boot service. 587*0Sstevel@tonic-gate * 588*0Sstevel@tonic-gate * Calling spec: 589*0Sstevel@tonic-gate * args[0] Service name string 590*0Sstevel@tonic-gate * args[1] #argument cells 591*0Sstevel@tonic-gate * args[2] #result cells 592*0Sstevel@tonic-gate * args[3] Res0: returned result 593*0Sstevel@tonic-gate */ 594*0Sstevel@tonic-gate /*ARGSUSED*/ 595*0Sstevel@tonic-gate int 596*0Sstevel@tonic-gate bop_unmountroot(struct bootops *bop) 597*0Sstevel@tonic-gate { 598*0Sstevel@tonic-gate boot_cell_t args[4]; 599*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 600*0Sstevel@tonic-gate 601*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 602*0Sstevel@tonic-gate args[0] = boot_ptr2cell("unmountroot"); 603*0Sstevel@tonic-gate args[1] = 0; 604*0Sstevel@tonic-gate args[2] = 1; 605*0Sstevel@tonic-gate 606*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 607*0Sstevel@tonic-gate return (boot_cell2int(args[3])); 608*0Sstevel@tonic-gate } 609*0Sstevel@tonic-gate 610*0Sstevel@tonic-gate /* 611*0Sstevel@tonic-gate * Implementation of the "serviceavail" boot service. 612*0Sstevel@tonic-gate * 613*0Sstevel@tonic-gate * Calling spec: 614*0Sstevel@tonic-gate * args[0] Service name string 615*0Sstevel@tonic-gate * args[1] #argument cells 616*0Sstevel@tonic-gate * args[2] #result cells 617*0Sstevel@tonic-gate * args[3] name string of service to be tested for 618*0Sstevel@tonic-gate * args[4] Res0: returned version number or 0 619*0Sstevel@tonic-gate */ 620*0Sstevel@tonic-gate /*ARGSUSED*/ 621*0Sstevel@tonic-gate int 622*0Sstevel@tonic-gate bop_serviceavail(struct bootops *bop, char *name) 623*0Sstevel@tonic-gate { 624*0Sstevel@tonic-gate boot_cell_t args[5]; 625*0Sstevel@tonic-gate int (*bsys_1275_call)(void *) = 626*0Sstevel@tonic-gate (int (*)(void *))bop->bsys_1275_call; 627*0Sstevel@tonic-gate 628*0Sstevel@tonic-gate args[0] = boot_ptr2cell("serviceavail"); 629*0Sstevel@tonic-gate args[1] = 1; 630*0Sstevel@tonic-gate args[2] = 1; 631*0Sstevel@tonic-gate 632*0Sstevel@tonic-gate args[3] = boot_ptr2cell(name); 633*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 634*0Sstevel@tonic-gate return (boot_cell2int(args[4])); 635*0Sstevel@tonic-gate } 636*0Sstevel@tonic-gate 637*0Sstevel@tonic-gate /* 638*0Sstevel@tonic-gate * Implementation of the "fstat" boot service. 639*0Sstevel@tonic-gate * 640*0Sstevel@tonic-gate * Calling spec: 641*0Sstevel@tonic-gate * args[0] Service name string 642*0Sstevel@tonic-gate * args[1] #argument cells 643*0Sstevel@tonic-gate * args[2] #result cells 644*0Sstevel@tonic-gate * args[3] fd 645*0Sstevel@tonic-gate * args[4] client's stat structure 646*0Sstevel@tonic-gate */ 647*0Sstevel@tonic-gate int 648*0Sstevel@tonic-gate bop_fstat(struct bootops *bop, int fd, struct bootstat *st) 649*0Sstevel@tonic-gate { 650*0Sstevel@tonic-gate boot_cell_t args[6]; 651*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 652*0Sstevel@tonic-gate 653*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 654*0Sstevel@tonic-gate args[0] = boot_ptr2cell("fstat"); 655*0Sstevel@tonic-gate args[1] = 2; 656*0Sstevel@tonic-gate args[2] = 1; 657*0Sstevel@tonic-gate args[3] = boot_int2cell(fd); 658*0Sstevel@tonic-gate args[4] = boot_ptr2cell(st); 659*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 660*0Sstevel@tonic-gate return (boot_cell2int(args[5])); 661*0Sstevel@tonic-gate } 662*0Sstevel@tonic-gate 663*0Sstevel@tonic-gate /* 664*0Sstevel@tonic-gate * Implementation of the "enter_mon" boot service. 665*0Sstevel@tonic-gate * 666*0Sstevel@tonic-gate * Calling spec: 667*0Sstevel@tonic-gate * args[0] Service name string 668*0Sstevel@tonic-gate * args[1] #argument cells (0) 669*0Sstevel@tonic-gate * args[2] #result cells (0) 670*0Sstevel@tonic-gate */ 671*0Sstevel@tonic-gate void 672*0Sstevel@tonic-gate bop_enter_mon(struct bootops *bop) 673*0Sstevel@tonic-gate { 674*0Sstevel@tonic-gate boot_cell_t args[4]; 675*0Sstevel@tonic-gate int (*bsys_1275_call)(void *); 676*0Sstevel@tonic-gate 677*0Sstevel@tonic-gate bsys_1275_call = (int (*)(void *))bop->bsys_1275_call; 678*0Sstevel@tonic-gate args[0] = boot_ptr2cell("enter_mon"); 679*0Sstevel@tonic-gate args[1] = 0; 680*0Sstevel@tonic-gate args[2] = 0; 681*0Sstevel@tonic-gate (void) (bsys_1275_call)(args); 682*0Sstevel@tonic-gate } 683