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