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