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