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