10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5295Srandyf * Common Development and Distribution License (the "License"). 6*5295Srandyf * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*5295Srandyf * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_PROMIF_H 270Sstevel@tonic-gate #define _SYS_PROMIF_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/types.h> 320Sstevel@tonic-gate #include <sys/obpdefs.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMDB) 350Sstevel@tonic-gate #include <sys/va_list.h> 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifdef __cplusplus 390Sstevel@tonic-gate extern "C" { 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * These are for V0 ops only. We sometimes have to specify 440Sstevel@tonic-gate * to promif which type of operation we need to perform 450Sstevel@tonic-gate * and since we can't get such a property from a V0 prom, we 460Sstevel@tonic-gate * sometimes just assume it. V2 and later proms do the right thing. 470Sstevel@tonic-gate */ 480Sstevel@tonic-gate #define BLOCK 0 490Sstevel@tonic-gate #define NETWORK 1 500Sstevel@tonic-gate #define BYTE 2 510Sstevel@tonic-gate 520Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMDB) 530Sstevel@tonic-gate 540Sstevel@tonic-gate extern caddr_t prom_map(caddr_t virthint, uint_t space, 550Sstevel@tonic-gate uint_t phys, uint_t size); 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* 580Sstevel@tonic-gate * resource allocation group: OBP and IEEE 1275-1994. 590Sstevel@tonic-gate * prom_alloc is platform dependent on SPARC. 600Sstevel@tonic-gate */ 610Sstevel@tonic-gate extern caddr_t prom_alloc(caddr_t virthint, uint_t size, int align); 620Sstevel@tonic-gate extern void prom_free(caddr_t virt, uint_t size); 630Sstevel@tonic-gate 640Sstevel@tonic-gate /* 650Sstevel@tonic-gate * Device tree and property group: OBP and IEEE 1275-1994. 660Sstevel@tonic-gate */ 67789Sahrens extern pnode_t prom_childnode(pnode_t nodeid); 68789Sahrens extern pnode_t prom_nextnode(pnode_t nodeid); 69789Sahrens extern pnode_t prom_optionsnode(void); 70789Sahrens extern pnode_t prom_alias_node(void); 71789Sahrens extern pnode_t prom_rootnode(void); 720Sstevel@tonic-gate 73789Sahrens extern int prom_getproplen(pnode_t nodeid, caddr_t name); 74789Sahrens extern int prom_getprop(pnode_t nodeid, caddr_t name, 750Sstevel@tonic-gate caddr_t value); 76789Sahrens extern caddr_t prom_nextprop(pnode_t nodeid, caddr_t previous, 770Sstevel@tonic-gate caddr_t next); 780Sstevel@tonic-gate 790Sstevel@tonic-gate extern char *prom_decode_composite_string(void *buf, 800Sstevel@tonic-gate size_t buflen, char *prev); 810Sstevel@tonic-gate 820Sstevel@tonic-gate /* 830Sstevel@tonic-gate * Device tree and property group: IEEE 1275-1994 Only. 840Sstevel@tonic-gate */ 85789Sahrens extern pnode_t prom_finddevice(char *path); 860Sstevel@tonic-gate 87789Sahrens extern int prom_bounded_getprop(pnode_t nodeid, 880Sstevel@tonic-gate caddr_t name, caddr_t buffer, int buflen); 890Sstevel@tonic-gate 900Sstevel@tonic-gate /* 910Sstevel@tonic-gate * Device pathnames and pathname conversion: OBP and IEEE 1275-1994. 920Sstevel@tonic-gate */ 930Sstevel@tonic-gate extern int prom_devname_from_pathname(char *path, char *buffer); 940Sstevel@tonic-gate extern char *prom_path_gettoken(char *from, char *to); 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* 970Sstevel@tonic-gate * Device pathnames and pathname conversion: IEEE 1275-1994 only. 980Sstevel@tonic-gate */ 990Sstevel@tonic-gate 1000Sstevel@tonic-gate /* 1010Sstevel@tonic-gate * Special device nodes: OBP and IEEE 1275-1994. 1020Sstevel@tonic-gate */ 1030Sstevel@tonic-gate extern int prom_stdin_is_keyboard(void); 1040Sstevel@tonic-gate extern int prom_stdout_is_framebuffer(void); 1050Sstevel@tonic-gate extern void prom_framebuffer_getpos(int *row, int *col); 1060Sstevel@tonic-gate extern void prom_framebuffer_getcolors(int *fg, int *bg); 1070Sstevel@tonic-gate extern char *prom_stdinpath(void); 1080Sstevel@tonic-gate extern char *prom_stdoutpath(void); 1090Sstevel@tonic-gate extern void prom_strip_options(char *from, char *to); 1100Sstevel@tonic-gate extern void prom_pathname(char *); 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate /* 1130Sstevel@tonic-gate * Special device nodes: IEEE 1275-1994 only. 1140Sstevel@tonic-gate */ 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate /* 1170Sstevel@tonic-gate * Administrative group: OBP and IEEE 1275-1994. 1180Sstevel@tonic-gate */ 1190Sstevel@tonic-gate extern void prom_enter_mon(void); 1200Sstevel@tonic-gate extern void prom_exit_to_mon(void) 1210Sstevel@tonic-gate __NORETURN; 1220Sstevel@tonic-gate extern void prom_reboot(char *bootstr) 1230Sstevel@tonic-gate __NORETURN; 1240Sstevel@tonic-gate extern void prom_panic(char *string) 1250Sstevel@tonic-gate __NORETURN; 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate extern int prom_is_openprom(void); 1280Sstevel@tonic-gate extern int prom_is_p1275(void); 1290Sstevel@tonic-gate extern int prom_version_name(char *buf, int buflen); 1300Sstevel@tonic-gate extern int prom_version_boot_syscalls(void); 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate extern uint_t prom_gettime(void); 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate extern char *prom_bootpath(void); 1350Sstevel@tonic-gate extern char *prom_bootargs(void); 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate /* 1380Sstevel@tonic-gate * Administrative group: OBP only. 1390Sstevel@tonic-gate */ 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate /* 1420Sstevel@tonic-gate * Administrative group: IEEE 1275-1994 only. 1430Sstevel@tonic-gate */ 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate /* 1460Sstevel@tonic-gate * Administrative group: IEEE 1275 only. 1470Sstevel@tonic-gate */ 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate /* 1500Sstevel@tonic-gate * Promif support group: Generic. 1510Sstevel@tonic-gate */ 1520Sstevel@tonic-gate extern void prom_init(char *progname, void *prom_cookie); 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate typedef uint_t prom_generation_cookie_t; 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate #define prom_tree_access(CALLBACK, ARG, GENP) (CALLBACK)((ARG), 0) 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate /* 1590Sstevel@tonic-gate * I/O Group: OBP and IEEE 1275. 1600Sstevel@tonic-gate */ 1610Sstevel@tonic-gate extern uchar_t prom_getchar(void); 1620Sstevel@tonic-gate extern void prom_putchar(char c); 1630Sstevel@tonic-gate extern int prom_mayget(void); 1640Sstevel@tonic-gate extern int prom_mayput(char c); 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate extern int prom_open(char *name); 1670Sstevel@tonic-gate extern int prom_close(int fd); 1680Sstevel@tonic-gate extern int prom_read(int fd, caddr_t buf, uint_t len, 1690Sstevel@tonic-gate uint_t startblk, char type); 1700Sstevel@tonic-gate extern int prom_write(int fd, caddr_t buf, uint_t len, 1710Sstevel@tonic-gate uint_t startblk, char devtype); 1720Sstevel@tonic-gate extern int prom_seek(int fd, unsigned long long offset); 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate extern void prom_writestr(const char *buf, size_t bufsize); 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate /*PRINTFLIKE1*/ 1770Sstevel@tonic-gate extern void prom_printf(const char *fmt, ...) 1780Sstevel@tonic-gate __PRINTFLIKE(1); 1790Sstevel@tonic-gate #pragma rarely_called(prom_printf) 1800Sstevel@tonic-gate extern void prom_vprintf(const char *fmt, __va_list adx) 1810Sstevel@tonic-gate __VPRINTFLIKE(1); 1820Sstevel@tonic-gate #pragma rarely_called(prom_vprintf) 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate /*PRINTFLIKE2*/ 1850Sstevel@tonic-gate extern char *prom_sprintf(char *s, const char *fmt, ...) 1860Sstevel@tonic-gate __PRINTFLIKE(2); 1870Sstevel@tonic-gate extern char *prom_vsprintf(char *s, const char *fmt, __va_list adx) 1880Sstevel@tonic-gate __VPRINTFLIKE(2); 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate /* 1910Sstevel@tonic-gate * promif tree searching routines ... OBP and IEEE 1275-1994. 1920Sstevel@tonic-gate */ 1930Sstevel@tonic-gate 194789Sahrens extern pnode_t prom_findnode_byname(pnode_t id, char *name); 1950Sstevel@tonic-gate extern char *prom_get_extend_name(void); 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate extern int prom_devreset(int); 1980Sstevel@tonic-gate extern int OpenCount; 1990Sstevel@tonic-gate extern struct ihandle *open_devices[]; 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate #define PROM_STOP { \ 2020Sstevel@tonic-gate prom_printf("File %s line %d\n", __FILE__, __LINE__); \ 2030Sstevel@tonic-gate prom_enter_mon(); \ 2040Sstevel@tonic-gate } 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate #endif /* _KERNEL || _KMDB */ 2070Sstevel@tonic-gate 2080Sstevel@tonic-gate #ifdef _KERNEL 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate /* 2110Sstevel@tonic-gate * Used by wrappers which bring up console frame buffer before prom_printf() 2120Sstevel@tonic-gate * and other prom calls that may output to the console. Struct is filled in 2130Sstevel@tonic-gate * in prom_env.c and in sunpm.c 2140Sstevel@tonic-gate */ 2150Sstevel@tonic-gate 2160Sstevel@tonic-gate typedef struct promif_owrap { 2170Sstevel@tonic-gate void (*preout)(void); 2180Sstevel@tonic-gate void (*postout)(void); 2190Sstevel@tonic-gate } promif_owrap_t; 2200Sstevel@tonic-gate 221*5295Srandyf extern void prom_suspend_prepost(void); 222*5295Srandyf extern void prom_resume_prepost(void); 223*5295Srandyf 2240Sstevel@tonic-gate /* 2250Sstevel@tonic-gate * WAN boot key storage interface 2260Sstevel@tonic-gate */ 2270Sstevel@tonic-gate int prom_set_security_key(char *keyname, caddr_t buf, int buflen, int *reslen, 2280Sstevel@tonic-gate int *status); 2290Sstevel@tonic-gate int prom_get_security_key(char *keyname, caddr_t buf, int buflen, int *keylen, 2300Sstevel@tonic-gate int *status); 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate #endif /* _KERNEL */ 2330Sstevel@tonic-gate #ifdef __cplusplus 2340Sstevel@tonic-gate } 2350Sstevel@tonic-gate #endif 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate #endif /* _SYS_PROMIF_H */ 238