xref: /illumos-gate/usr/src/uts/intel/sys/promif.h (revision 2d6eb4a5)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*2df1fe9cSrandyf  * Common Development and Distribution License (the "License").
6*2df1fe9cSrandyf  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*2df1fe9cSrandyf  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_PROMIF_H
277c478bd9Sstevel@tonic-gate #define	_SYS_PROMIF_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h>
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMDB)
337c478bd9Sstevel@tonic-gate #include <sys/va_list.h>
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /*
417c478bd9Sstevel@tonic-gate  *  These are for V0 ops only.  We sometimes have to specify
427c478bd9Sstevel@tonic-gate  *  to promif which type of operation we need to perform
437c478bd9Sstevel@tonic-gate  *  and since we can't get such a property from a V0 prom, we
447c478bd9Sstevel@tonic-gate  *  sometimes just assume it.  V2 and later proms do the right thing.
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate #define	BLOCK	0
477c478bd9Sstevel@tonic-gate #define	NETWORK	1
487c478bd9Sstevel@tonic-gate #define	BYTE	2
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMDB)
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate extern	caddr_t		prom_map(caddr_t virthint, uint_t space,
537c478bd9Sstevel@tonic-gate 			    uint_t phys, uint_t size);
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /*
567c478bd9Sstevel@tonic-gate  * resource allocation group: OBP and IEEE 1275-1994.
577c478bd9Sstevel@tonic-gate  * prom_alloc is platform dependent on SPARC.
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate extern	caddr_t		prom_alloc(caddr_t virthint, uint_t size, int align);
607c478bd9Sstevel@tonic-gate extern	void		prom_free(caddr_t virt, uint_t size);
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * Device tree and property group: OBP and IEEE 1275-1994.
647c478bd9Sstevel@tonic-gate  */
65fa9e4066Sahrens extern	pnode_t		prom_childnode(pnode_t nodeid);
66fa9e4066Sahrens extern	pnode_t		prom_nextnode(pnode_t nodeid);
67fa9e4066Sahrens extern	pnode_t		prom_optionsnode(void);
68fa9e4066Sahrens extern	pnode_t		prom_alias_node(void);
69fa9e4066Sahrens extern	pnode_t		prom_rootnode(void);
707c478bd9Sstevel@tonic-gate 
71fa9e4066Sahrens extern	int		prom_getproplen(pnode_t nodeid, caddr_t name);
72fa9e4066Sahrens extern	int		prom_getprop(pnode_t nodeid, caddr_t name,
737c478bd9Sstevel@tonic-gate 			    caddr_t value);
74fa9e4066Sahrens extern	caddr_t		prom_nextprop(pnode_t nodeid, caddr_t previous,
757c478bd9Sstevel@tonic-gate 			    caddr_t next);
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate extern	char		*prom_decode_composite_string(void *buf,
787c478bd9Sstevel@tonic-gate 			    size_t buflen, char *prev);
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /*
817c478bd9Sstevel@tonic-gate  * Device tree and property group: IEEE 1275-1994 Only.
827c478bd9Sstevel@tonic-gate  */
83fa9e4066Sahrens extern	pnode_t		prom_finddevice(char *path);
847c478bd9Sstevel@tonic-gate 
85fa9e4066Sahrens extern	int		prom_bounded_getprop(pnode_t nodeid,
867c478bd9Sstevel@tonic-gate 			    caddr_t name, caddr_t buffer, int buflen);
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /*
897c478bd9Sstevel@tonic-gate  * Device pathnames and pathname conversion: OBP and IEEE 1275-1994.
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate extern	int		prom_devname_from_pathname(char *path, char *buffer);
927c478bd9Sstevel@tonic-gate extern	char		*prom_path_gettoken(char *from, char *to);
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * Device pathnames and pathname conversion: IEEE 1275-1994 only.
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate /*
997c478bd9Sstevel@tonic-gate  * Special device nodes: OBP and IEEE 1275-1994.
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate extern	int		prom_stdin_is_keyboard(void);
1027c478bd9Sstevel@tonic-gate extern	int		prom_stdout_is_framebuffer(void);
1037c478bd9Sstevel@tonic-gate extern	void		prom_framebuffer_getpos(int *row, int *col);
1047c478bd9Sstevel@tonic-gate extern	void		prom_framebuffer_getcolors(int *fg, int *bg);
1057c478bd9Sstevel@tonic-gate extern  char    	*prom_stdinpath(void);
1067c478bd9Sstevel@tonic-gate extern  char    	*prom_stdoutpath(void);
1077c478bd9Sstevel@tonic-gate extern  void    	prom_strip_options(char *from, char *to);
1087c478bd9Sstevel@tonic-gate extern  void    	prom_pathname(char *);
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * Special device nodes: IEEE 1275-1994 only.
1127c478bd9Sstevel@tonic-gate  */
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate /*
1157c478bd9Sstevel@tonic-gate  * Administrative group: OBP and IEEE 1275-1994.
1167c478bd9Sstevel@tonic-gate  */
1177c478bd9Sstevel@tonic-gate extern	void		prom_enter_mon(void);
1187c478bd9Sstevel@tonic-gate extern	void		prom_exit_to_mon(void)
1197c478bd9Sstevel@tonic-gate 	__NORETURN;
1207c478bd9Sstevel@tonic-gate extern	void		prom_reboot(char *bootstr)
1217c478bd9Sstevel@tonic-gate 	__NORETURN;
1227c478bd9Sstevel@tonic-gate extern	void		prom_panic(char *string)
1237c478bd9Sstevel@tonic-gate 	__NORETURN;
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate extern	int		prom_is_openprom(void);
1267c478bd9Sstevel@tonic-gate extern	int		prom_is_p1275(void);
1277c478bd9Sstevel@tonic-gate extern	int		prom_version_name(char *buf, int buflen);
1287c478bd9Sstevel@tonic-gate extern	int		prom_version_boot_syscalls(void);
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate extern	uint_t		prom_gettime(void);
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate extern	char		*prom_bootpath(void);
1337c478bd9Sstevel@tonic-gate extern	char		*prom_bootargs(void);
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate  * Administrative group: OBP only.
1377c478bd9Sstevel@tonic-gate  */
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate /*
1407c478bd9Sstevel@tonic-gate  * Administrative group: IEEE 1275-1994 only.
1417c478bd9Sstevel@tonic-gate  */
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate /*
1447c478bd9Sstevel@tonic-gate  * Administrative group: IEEE 1275 only.
1457c478bd9Sstevel@tonic-gate  */
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate /*
1487c478bd9Sstevel@tonic-gate  * Promif support group: Generic.
1497c478bd9Sstevel@tonic-gate  */
1507c478bd9Sstevel@tonic-gate extern	void		prom_init(char *progname, void *prom_cookie);
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate typedef uint_t		prom_generation_cookie_t;
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate #define	prom_tree_access(CALLBACK, ARG, GENP) (CALLBACK)((ARG), 0)
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate /*
1577c478bd9Sstevel@tonic-gate  * I/O Group: OBP and IEEE 1275.
1587c478bd9Sstevel@tonic-gate  */
1597c478bd9Sstevel@tonic-gate extern	uchar_t		prom_getchar(void);
1607c478bd9Sstevel@tonic-gate extern	void		prom_putchar(char c);
1617c478bd9Sstevel@tonic-gate extern	int		prom_mayget(void);
1627c478bd9Sstevel@tonic-gate extern	int		prom_mayput(char c);
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate extern  int		prom_open(char *name);
1657c478bd9Sstevel@tonic-gate extern  int		prom_close(int fd);
1667c478bd9Sstevel@tonic-gate extern  int		prom_read(int fd, caddr_t buf, uint_t len,
1677c478bd9Sstevel@tonic-gate 			    uint_t startblk, char type);
1687c478bd9Sstevel@tonic-gate extern	int		prom_write(int fd, caddr_t buf, uint_t len,
1697c478bd9Sstevel@tonic-gate 			    uint_t startblk, char devtype);
1707c478bd9Sstevel@tonic-gate extern	int		prom_seek(int fd, unsigned long long offset);
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate extern	void		prom_writestr(const char *buf, size_t bufsize);
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate /*PRINTFLIKE1*/
1757c478bd9Sstevel@tonic-gate extern	void		prom_printf(const char *fmt, ...)
1767c478bd9Sstevel@tonic-gate 	__PRINTFLIKE(1);
1777c478bd9Sstevel@tonic-gate #pragma	rarely_called(prom_printf)
1787c478bd9Sstevel@tonic-gate extern	void		prom_vprintf(const char *fmt, __va_list adx)
1797c478bd9Sstevel@tonic-gate 	__VPRINTFLIKE(1);
1807c478bd9Sstevel@tonic-gate #pragma	rarely_called(prom_vprintf)
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate /*PRINTFLIKE2*/
1837c478bd9Sstevel@tonic-gate extern	char		*prom_sprintf(char *s, const char *fmt, ...)
1847c478bd9Sstevel@tonic-gate 	__PRINTFLIKE(2);
1857c478bd9Sstevel@tonic-gate extern	char		*prom_vsprintf(char *s, const char *fmt, __va_list adx)
1867c478bd9Sstevel@tonic-gate 	__VPRINTFLIKE(2);
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate /*
1897c478bd9Sstevel@tonic-gate  * promif tree searching routines ... OBP and IEEE 1275-1994.
1907c478bd9Sstevel@tonic-gate  */
1917c478bd9Sstevel@tonic-gate 
192fa9e4066Sahrens extern	pnode_t		prom_findnode_byname(pnode_t id, char *name);
1937c478bd9Sstevel@tonic-gate extern	char		*prom_get_extend_name(void);
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate extern	int		prom_devreset(int);
1967c478bd9Sstevel@tonic-gate extern	int		OpenCount;
1977c478bd9Sstevel@tonic-gate extern struct ihandle	*open_devices[];
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate #define	PROM_STOP	{	\
2007c478bd9Sstevel@tonic-gate 	prom_printf("File %s line %d\n", __FILE__, __LINE__); \
2017c478bd9Sstevel@tonic-gate 	prom_enter_mon();	\
2027c478bd9Sstevel@tonic-gate }
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate #endif /* _KERNEL || _KMDB */
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate #ifdef _KERNEL
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate /*
2097c478bd9Sstevel@tonic-gate  * Used by wrappers which bring up console frame buffer before prom_printf()
2107c478bd9Sstevel@tonic-gate  * and other prom calls that may output to the console.  Struct is filled in
2117c478bd9Sstevel@tonic-gate  * in prom_env.c and in sunpm.c
2127c478bd9Sstevel@tonic-gate  */
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate typedef struct promif_owrap {
2157c478bd9Sstevel@tonic-gate 	void (*preout)(void);
2167c478bd9Sstevel@tonic-gate 	void (*postout)(void);
2177c478bd9Sstevel@tonic-gate } promif_owrap_t;
2187c478bd9Sstevel@tonic-gate 
219*2df1fe9cSrandyf extern	void		prom_suspend_prepost(void);
220*2df1fe9cSrandyf extern	void		prom_resume_prepost(void);
221*2df1fe9cSrandyf 
2227c478bd9Sstevel@tonic-gate /*
2237c478bd9Sstevel@tonic-gate  * WAN boot key storage interface
2247c478bd9Sstevel@tonic-gate  */
2257c478bd9Sstevel@tonic-gate int prom_set_security_key(char *keyname, caddr_t buf, int buflen, int *reslen,
2267c478bd9Sstevel@tonic-gate     int *status);
2277c478bd9Sstevel@tonic-gate int prom_get_security_key(char *keyname, caddr_t buf, int buflen, int *keylen,
2287c478bd9Sstevel@tonic-gate     int *status);
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
2317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2327c478bd9Sstevel@tonic-gate }
2337c478bd9Sstevel@tonic-gate #endif
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate #endif /* _SYS_PROMIF_H */
236