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