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