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 #ifndef _SYS_PROMIF_H 28*0Sstevel@tonic-gate #define _SYS_PROMIF_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/types.h> 33*0Sstevel@tonic-gate #include <sys/obpdefs.h> 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMDB) 36*0Sstevel@tonic-gate #include <sys/va_list.h> 37*0Sstevel@tonic-gate #endif 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate #ifdef __cplusplus 40*0Sstevel@tonic-gate extern "C" { 41*0Sstevel@tonic-gate #endif 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate /* 44*0Sstevel@tonic-gate * These are for V0 ops only. We sometimes have to specify 45*0Sstevel@tonic-gate * to promif which type of operation we need to perform 46*0Sstevel@tonic-gate * and since we can't get such a property from a V0 prom, we 47*0Sstevel@tonic-gate * sometimes just assume it. V2 and later proms do the right thing. 48*0Sstevel@tonic-gate */ 49*0Sstevel@tonic-gate #define BLOCK 0 50*0Sstevel@tonic-gate #define NETWORK 1 51*0Sstevel@tonic-gate #define BYTE 2 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMDB) 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate extern caddr_t prom_map(caddr_t virthint, uint_t space, 56*0Sstevel@tonic-gate uint_t phys, uint_t size); 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate /* 59*0Sstevel@tonic-gate * resource allocation group: OBP and IEEE 1275-1994. 60*0Sstevel@tonic-gate * prom_alloc is platform dependent on SPARC. 61*0Sstevel@tonic-gate */ 62*0Sstevel@tonic-gate extern caddr_t prom_alloc(caddr_t virthint, uint_t size, int align); 63*0Sstevel@tonic-gate extern void prom_free(caddr_t virt, uint_t size); 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate /* 66*0Sstevel@tonic-gate * Device tree and property group: OBP and IEEE 1275-1994. 67*0Sstevel@tonic-gate */ 68*0Sstevel@tonic-gate extern dnode_t prom_childnode(dnode_t nodeid); 69*0Sstevel@tonic-gate extern dnode_t prom_nextnode(dnode_t nodeid); 70*0Sstevel@tonic-gate extern dnode_t prom_optionsnode(void); 71*0Sstevel@tonic-gate extern dnode_t prom_alias_node(void); 72*0Sstevel@tonic-gate extern dnode_t prom_rootnode(void); 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate extern int prom_getproplen(dnode_t nodeid, caddr_t name); 75*0Sstevel@tonic-gate extern int prom_getprop(dnode_t nodeid, caddr_t name, 76*0Sstevel@tonic-gate caddr_t value); 77*0Sstevel@tonic-gate extern caddr_t prom_nextprop(dnode_t nodeid, caddr_t previous, 78*0Sstevel@tonic-gate caddr_t next); 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate extern char *prom_decode_composite_string(void *buf, 81*0Sstevel@tonic-gate size_t buflen, char *prev); 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate /* 84*0Sstevel@tonic-gate * Device tree and property group: IEEE 1275-1994 Only. 85*0Sstevel@tonic-gate */ 86*0Sstevel@tonic-gate extern dnode_t prom_finddevice(char *path); 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate extern int prom_bounded_getprop(dnode_t nodeid, 89*0Sstevel@tonic-gate caddr_t name, caddr_t buffer, int buflen); 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate /* 92*0Sstevel@tonic-gate * Device pathnames and pathname conversion: OBP and IEEE 1275-1994. 93*0Sstevel@tonic-gate */ 94*0Sstevel@tonic-gate extern int prom_devname_from_pathname(char *path, char *buffer); 95*0Sstevel@tonic-gate extern char *prom_path_gettoken(char *from, char *to); 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate /* 98*0Sstevel@tonic-gate * Device pathnames and pathname conversion: IEEE 1275-1994 only. 99*0Sstevel@tonic-gate */ 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate /* 102*0Sstevel@tonic-gate * Special device nodes: OBP and IEEE 1275-1994. 103*0Sstevel@tonic-gate */ 104*0Sstevel@tonic-gate extern int prom_stdin_is_keyboard(void); 105*0Sstevel@tonic-gate extern int prom_stdout_is_framebuffer(void); 106*0Sstevel@tonic-gate extern void prom_framebuffer_getpos(int *row, int *col); 107*0Sstevel@tonic-gate extern void prom_framebuffer_getcolors(int *fg, int *bg); 108*0Sstevel@tonic-gate extern char *prom_stdinpath(void); 109*0Sstevel@tonic-gate extern char *prom_stdoutpath(void); 110*0Sstevel@tonic-gate extern void prom_strip_options(char *from, char *to); 111*0Sstevel@tonic-gate extern void prom_pathname(char *); 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate /* 114*0Sstevel@tonic-gate * Special device nodes: IEEE 1275-1994 only. 115*0Sstevel@tonic-gate */ 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate /* 118*0Sstevel@tonic-gate * Administrative group: OBP and IEEE 1275-1994. 119*0Sstevel@tonic-gate */ 120*0Sstevel@tonic-gate extern void prom_enter_mon(void); 121*0Sstevel@tonic-gate extern void prom_exit_to_mon(void) 122*0Sstevel@tonic-gate __NORETURN; 123*0Sstevel@tonic-gate extern void prom_reboot(char *bootstr) 124*0Sstevel@tonic-gate __NORETURN; 125*0Sstevel@tonic-gate extern void prom_panic(char *string) 126*0Sstevel@tonic-gate __NORETURN; 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate extern int prom_is_openprom(void); 129*0Sstevel@tonic-gate extern int prom_is_p1275(void); 130*0Sstevel@tonic-gate extern int prom_version_name(char *buf, int buflen); 131*0Sstevel@tonic-gate extern int prom_version_boot_syscalls(void); 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate extern uint_t prom_gettime(void); 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate extern char *prom_bootpath(void); 136*0Sstevel@tonic-gate extern char *prom_bootargs(void); 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate /* 139*0Sstevel@tonic-gate * Administrative group: OBP only. 140*0Sstevel@tonic-gate */ 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate /* 143*0Sstevel@tonic-gate * Administrative group: IEEE 1275-1994 only. 144*0Sstevel@tonic-gate */ 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate /* 147*0Sstevel@tonic-gate * Administrative group: IEEE 1275 only. 148*0Sstevel@tonic-gate */ 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate /* 151*0Sstevel@tonic-gate * Promif support group: Generic. 152*0Sstevel@tonic-gate */ 153*0Sstevel@tonic-gate extern void prom_init(char *progname, void *prom_cookie); 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate typedef uint_t prom_generation_cookie_t; 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate #define prom_tree_access(CALLBACK, ARG, GENP) (CALLBACK)((ARG), 0) 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate /* 160*0Sstevel@tonic-gate * I/O Group: OBP and IEEE 1275. 161*0Sstevel@tonic-gate */ 162*0Sstevel@tonic-gate extern uchar_t prom_getchar(void); 163*0Sstevel@tonic-gate extern void prom_putchar(char c); 164*0Sstevel@tonic-gate extern int prom_mayget(void); 165*0Sstevel@tonic-gate extern int prom_mayput(char c); 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate extern int prom_open(char *name); 168*0Sstevel@tonic-gate extern int prom_close(int fd); 169*0Sstevel@tonic-gate extern int prom_read(int fd, caddr_t buf, uint_t len, 170*0Sstevel@tonic-gate uint_t startblk, char type); 171*0Sstevel@tonic-gate extern int prom_write(int fd, caddr_t buf, uint_t len, 172*0Sstevel@tonic-gate uint_t startblk, char devtype); 173*0Sstevel@tonic-gate extern int prom_seek(int fd, unsigned long long offset); 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate extern void prom_writestr(const char *buf, size_t bufsize); 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gate /*PRINTFLIKE1*/ 178*0Sstevel@tonic-gate extern void prom_printf(const char *fmt, ...) 179*0Sstevel@tonic-gate __PRINTFLIKE(1); 180*0Sstevel@tonic-gate #pragma rarely_called(prom_printf) 181*0Sstevel@tonic-gate extern void prom_vprintf(const char *fmt, __va_list adx) 182*0Sstevel@tonic-gate __VPRINTFLIKE(1); 183*0Sstevel@tonic-gate #pragma rarely_called(prom_vprintf) 184*0Sstevel@tonic-gate 185*0Sstevel@tonic-gate /*PRINTFLIKE2*/ 186*0Sstevel@tonic-gate extern char *prom_sprintf(char *s, const char *fmt, ...) 187*0Sstevel@tonic-gate __PRINTFLIKE(2); 188*0Sstevel@tonic-gate extern char *prom_vsprintf(char *s, const char *fmt, __va_list adx) 189*0Sstevel@tonic-gate __VPRINTFLIKE(2); 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate /* 192*0Sstevel@tonic-gate * promif tree searching routines ... OBP and IEEE 1275-1994. 193*0Sstevel@tonic-gate */ 194*0Sstevel@tonic-gate 195*0Sstevel@tonic-gate extern dnode_t prom_findnode_byname(dnode_t id, char *name); 196*0Sstevel@tonic-gate extern char *prom_get_extend_name(void); 197*0Sstevel@tonic-gate 198*0Sstevel@tonic-gate extern int prom_devreset(int); 199*0Sstevel@tonic-gate extern int OpenCount; 200*0Sstevel@tonic-gate extern struct ihandle *open_devices[]; 201*0Sstevel@tonic-gate 202*0Sstevel@tonic-gate #define PROM_STOP { \ 203*0Sstevel@tonic-gate prom_printf("File %s line %d\n", __FILE__, __LINE__); \ 204*0Sstevel@tonic-gate prom_enter_mon(); \ 205*0Sstevel@tonic-gate } 206*0Sstevel@tonic-gate 207*0Sstevel@tonic-gate #endif /* _KERNEL || _KMDB */ 208*0Sstevel@tonic-gate 209*0Sstevel@tonic-gate #ifdef _KERNEL 210*0Sstevel@tonic-gate 211*0Sstevel@tonic-gate /* 212*0Sstevel@tonic-gate * Used by wrappers which bring up console frame buffer before prom_printf() 213*0Sstevel@tonic-gate * and other prom calls that may output to the console. Struct is filled in 214*0Sstevel@tonic-gate * in prom_env.c and in sunpm.c 215*0Sstevel@tonic-gate */ 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate typedef struct promif_owrap { 218*0Sstevel@tonic-gate void (*preout)(void); 219*0Sstevel@tonic-gate void (*postout)(void); 220*0Sstevel@tonic-gate } promif_owrap_t; 221*0Sstevel@tonic-gate 222*0Sstevel@tonic-gate /* 223*0Sstevel@tonic-gate * WAN boot key storage interface 224*0Sstevel@tonic-gate */ 225*0Sstevel@tonic-gate int prom_set_security_key(char *keyname, caddr_t buf, int buflen, int *reslen, 226*0Sstevel@tonic-gate int *status); 227*0Sstevel@tonic-gate int prom_get_security_key(char *keyname, caddr_t buf, int buflen, int *keylen, 228*0Sstevel@tonic-gate int *status); 229*0Sstevel@tonic-gate 230*0Sstevel@tonic-gate #endif /* _KERNEL */ 231*0Sstevel@tonic-gate #ifdef __cplusplus 232*0Sstevel@tonic-gate } 233*0Sstevel@tonic-gate #endif 234*0Sstevel@tonic-gate 235*0Sstevel@tonic-gate #endif /* _SYS_PROMIF_H */ 236