prom.h revision 1.3 1 /* $NetBSD: prom.h,v 1.3 2000/09/16 08:27:58 wdk Exp $ */
2
3 /*
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Wayne Knowles
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Entry points into PROM firmware functions for MIPS machines
41 */
42
43 #ifndef _MIPSCO_PROM_H
44 #define _MIPSCO_PROM_H
45
46 #ifndef _LOCORE
47 #include <sys/types.h>
48 #include <sys/cdefs.h>
49
50 struct mips_prom {
51
52 /*
53 * transferred to on hardware reset, configures MIPS boards,
54 * runs diags, check for appropriate auto boot action in
55 * "bootmode" environment variable and performs that action.
56 */
57 void (*prom_reset) __P((void)) __attribute__((__noreturn__));
58
59 /*
60 * called to utilize prom to boot new image. After the booted
61 * program returns control can either be returned to the
62 * original caller of the exec routine or to the prom monitor.
63 * (to return to the original caller, the new program must
64 * not destroy any text, data, or stack of the parent. the
65 * new programs stack continues on the parents stack.
66 */
67 int (*prom_exec) __P((void));
68
69 /* re-enter the prom command parser, do not reset prom state */
70 void (*prom_restart) __P((void)) __attribute__((__noreturn__));
71
72 /* reinitialize prom state and re-enter the prom command parser */
73 void (*prom_reinit) __P((void)) __attribute__((__noreturn__));
74
75 /* reboot machine using current bootmode setting. No diags */
76 void (*prom_reboot) __P((void)) __attribute__((__noreturn__));
77
78 /* perform an autoboot sequence, no configuration or diags run */
79 void (*prom_autoboot) __P((void)) __attribute__((__noreturn__));
80
81 /*
82 * these routines access prom "saio" routines, and may be used
83 * by standalone programs that would like to use prom io
84 */
85 int (*prom_open) __P((char *, int, ...));
86 int (*prom_read) __P((int, void *, int));
87 int (*prom_write) __P((int, void *, int));
88 int (*prom_ioctl) __P((int, long, ...));
89 int (*prom_close) __P((int));
90 int (*prom_getchar) __P((void));
91 int (*prom_putchar) __P((int c));
92 void (*prom_showchar) __P((int c));
93 char * (*prom_gets) __P((char *s));
94 void (*prom_puts) __P((const char *));
95 int (*prom_printf) __P((const char *, ...));
96
97 /* prom protocol entry points */
98 void (*prom_initproto) __P((void)); /* ??? */
99 void (*prom_protoenable) __P((void)); /* ??? */
100 void (*prom_protodisable) __P((void)); /* ??? */
101 void (*prom_getpkt) __P((void)); /* ??? */
102 void (*prom_putpkt) __P((void)); /* ??? */
103
104 /*
105 * read-modify-write routine use special cpu board circuitry to
106 * accomplish vme bus r-m-w cycles.
107 */
108 void (*prom_orw_rmw) __P((void));
109 void (*prom_orh_rmw) __P((void));
110 void (*prom_orb_rmw) __P((void));
111 void (*prom_andw_rmw) __P((void));
112 void (*prom_andh_rmw) __P((void));
113 void (*prom_andb_rmw) __P((void));
114
115 /*
116 * cache control entry points
117 * flushcache is called without arguments and invalidates entire
118 * contents of both i and d caches
119 * clearcache is called with a base address and length (where
120 * address is either K0, K1, or physical) and clears both
121 * i and d cache for entries that alias to specified address
122 * range.
123 */
124 void (*prom_flushcache) __P((void));
125 void (*prom_clearcache) __P((void));
126
127 /*
128 * Libc compatible functions
129 */
130 void (*prom_setjmp) __P((void));
131 void (*prom_longjmp) __P((void));
132 void (*prom_bevutlb) __P((void));
133 char * (*prom_getenv) __P((char *name));
134 int (*prom_setenv) __P((char *name, char *val));
135 int (*prom_atob) __P((char *s));
136 int (*prom_strcmp) __P((char *s1, char *s2));
137 int (*prom_strlen) __P((char *s));
138 char * (*prom_strcpy) __P((char *s1, char *s2));
139 char * (*prom_strcat) __P((char *s1, char *s2));
140
141 /*
142 * command parser entry points
143 */
144 void (*prom_parser) __P((void)); /* ??? */
145 void (*prom_range) __P((void)); /* ??? */
146 void (*prom_argvize) __P((void)); /* ??? */
147 void (*prom_help) __P((void));
148
149 /*
150 * prom commands
151 */
152 void (*prom_dumpcmd) __P((void));
153 void (*prom_setenvcmd) __P((void));
154 void (*prom_unsetenvcmd) __P((void));
155 void (*prom_bevexcept) __P((void));
156 void (*prom_enablecmd) __P((void));
157 void (*prom_disablecmd) __P((void));
158
159 /*
160 * clear existing fault handlers
161 * used by clients that link to prom on situations where client has
162 * interrupted out of prom code and wish to reenter without being
163 * tripped up by any pending prom timers set earlier.
164 */
165 void (*prom_clearnofault) __P((void));
166
167 void (*prom_notimpl) __P((void));
168
169 /*
170 * PROM_NVGET, PROM_NVSET will get/set information in the NVRAM.
171 * Both of these routines take indexes as opposed to addresses
172 * to guarantee portability between various platforms
173 */
174 int (*prom_nvget) __P((int));
175 void (*prom_nvset) __P((void));
176 };
177
178 extern struct mips_prom *callv;
179
180 extern void prom_init __P((void));
181
182 #endif /* _LOCORE */
183
184 /*
185 * Macro to help call a prom function
186 */
187 #define MIPS_PROM(func) (callv->prom_##func)
188
189 /*
190 * Return the address for a given prom function number
191 */
192 #define MIPS_PROM_ENTRY(x) (0xbfc00000+((x)*8))
193
194 /*
195 * MIPS PROM firmware functions:
196 *
197 * MIPS_PROM_RESET Run diags, check bootmode, reinit.
198 * MIPS_PROM_EXEC Load new program image.
199 * MIPS_PROM_RESTART Re-enter monitor command loop.
200 * MIPS_PROM_REINIT Re-init monitor, then cmd loop.
201 * MIPS_PROM_REBOOT Check bootmode, no config.
202 * MIPS_PROM_AUTOBOOT Autoboot the system.
203 *
204 * The following routines access PROM saio routines and may be used by
205 * standalone programs that would like to use PROM I/O:
206 *
207 * MIPS_PROM_OPEN Open a file.
208 * MIPS_PROM_READ Read from a file.
209 * MIPS_PROM_WRITE Write to a file.
210 * MIPS_PROM_IOCTL Ioctl on a file.
211 * MIPS_PROM_CLOSE Close a file.
212 * MIPS_PROM_GETCHAR Read character from console.
213 * MIPS_PROM_PUTCHAR Put character on console.
214 * MIPS_PROM_SHOWCHAR Show a char visibly.
215 * MIPS_PROM_GETS gets with editing.
216 * MIPS_PROM_PUTS Put string to console.
217 * MIPS_PROM_PRINTF Kernel style printf to console.
218 *
219 * PROM protocol entry points:
220 *
221 * MIPS_PROM_INITPROTO Initialize protocol.
222 * MIPS_PROM_PROTOENABLE Enable protocol mode.
223 * MIPS_PROM_PROTODISABLE Disable protocol mode.
224 * MIPS_PROM_GETPKT Get protocol packet.
225 * MIPS_PROM_PUTPKT Put protocol packet.
226 *
227 * Atomic Read-Modify-Write functions
228 *
229 * MIPS_PROM_RMW_OR32 r-m-w OR word.
230 * MIPS_PROM_RMW_OR16 r-m-w OR halfword.
231 * MIPS_PROM_RMW_OR8 r-m-w OR or byte.
232 * MIPS_PROM_RMW_AND32 r-m-w AND word.
233 * MIPS_PROM_RMW_AND16 r-m-w AND halfword.
234 * MIPS_PROM_RMW_AND8 r-m-w AND byte.
235 *
236 * MIPS_PROM_FLUSHCACHE Flush entire cache ().
237 * MIPS_PROM_CLEARCACHE Clear I & D cache in range (addr, len).
238 * MIPS_PROM_SETJMP Save registers in a buffer.
239 * MIPS_PROM_LONGJMP Get register back from buffer.
240 * MIPS_PROM_BEVUTLB utlbmiss boot exception vector
241 * MIPS_PROM_GETENV Gets a string from system environment.
242 * MIPS_PROM_SETENV Sets a string in system environment.
243 * MIPS_PROM_ATOB Converts ascii string to number.
244 * MIPS_PROM_STRCMP Compares strings (strcmp).
245 * MIPS_PROM_STRLEN Length of string (strlen).
246 * MIPS_PROM_STRCPY Copies string (strcpy).
247 * MIPS_PROM_STRCAT Appends string (strcat).
248 * MIPS_PROM_PARSER Command parser.
249 * MIPS_PROM_RANGE Address range parser
250 * MIPS_PROM_ARGVIZE Parses string to argc,argv.
251 * MIPS_PROM_HELP Help on prom commands.
252 * MIPS_PROM_DUMP Dump memory command.
253 * MIPS_PROM_SETENVCMD Setenv command.
254 * MIPS_PROM_UNSETENVCMD Unsetenv command.
255 * MIPS_PROM_PRINTENV Print environment command.
256 * MIPS_PROM_BEVEXCEPT General boot exception vector
257 * MIPS_PROM_ENABLE Performs prom enable command.
258 * MIPS_PROM_DISABLE Performs prom disable command.
259 * MIPS_PROM_CLEARNOFAULT Clear existing fault handlers.
260 * MIPS_PROM_NOTIMPL Guaranteed to be not implemented
261 * MIPS_PROM_NVGET Read bytes from NVRAM
262 * MIPS_PROM_NVSET Write bytes to NVRAM
263 */
264
265 #define MIPS_PROM_RESET MIPS_PROM_ENTRY(0)
266 #define MIPS_PROM_EXEC MIPS_PROM_ENTRY(1)
267 #define MIPS_PROM_RESTART MIPS_PROM_ENTRY(2)
268 #define MIPS_PROM_REINIT MIPS_PROM_ENTRY(3)
269 #define MIPS_PROM_REBOOT MIPS_PROM_ENTRY(4)
270 #define MIPS_PROM_AUTOBOOT MIPS_PROM_ENTRY(5)
271 #define MIPS_PROM_OPEN MIPS_PROM_ENTRY(6)
272 #define MIPS_PROM_READ MIPS_PROM_ENTRY(7)
273 #define MIPS_PROM_WRITE MIPS_PROM_ENTRY(8)
274 #define MIPS_PROM_IOCTL MIPS_PROM_ENTRY(9)
275 #define MIPS_PROM_CLOSE MIPS_PROM_ENTRY(10)
276 #define MIPS_PROM_GETCHAR MIPS_PROM_ENTRY(11)
277 #define MIPS_PROM_PUTCHAR MIPS_PROM_ENTRY(12)
278 #define MIPS_PROM_SHOWCHAR MIPS_PROM_ENTRY(13)
279 #define MIPS_PROM_GETS MIPS_PROM_ENTRY(14)
280 #define MIPS_PROM_PUTS MIPS_PROM_ENTRY(15)
281 #define MIPS_PROM_PRINTF MIPS_PROM_ENTRY(16)
282 #define MIPS_PROM_INITPROTO MIPS_PROM_ENTRY(17)
283 #define MIPS_PROM_PROTOENABLE MIPS_PROM_ENTRY(18)
284 #define MIPS_PROM_PROTODISABLE MIPS_PROM_ENTRY(19)
285 #define MIPS_PROM_GETPKT MIPS_PROM_ENTRY(20)
286 #define MIPS_PROM_PUTPKT MIPS_PROM_ENTRY(21)
287 #define MIPS_PROM_ORW_RMW MIPS_PROM_ENTRY(22)
288 #define MIPS_PROM_ORH_RMW MIPS_PROM_ENTRY(23)
289 #define MIPS_PROM_ORB_RMW MIPS_PROM_ENTRY(24)
290 #define MIPS_PROM_ANDW_RMW MIPS_PROM_ENTRY(25)
291 #define MIPS_PROM_ANDH_RMW MIPS_PROM_ENTRY(26)
292 #define MIPS_PROM_ANDB_RMW MIPS_PROM_ENTRY(27)
293 #define MIPS_PROM_FLUSHCACHE MIPS_PROM_ENTRY(28)
294 #define MIPS_PROM_CLEARCACHE MIPS_PROM_ENTRY(29)
295 #define MIPS_PROM_SETJMP MIPS_PROM_ENTRY(30)
296 #define MIPS_PROM_LONGJMP MIPS_PROM_ENTRY(31)
297 #define MIPS_PROM_BEVUTLB MIPS_PROM_ENTRY(32)
298 #define MIPS_PROM_GETENV MIPS_PROM_ENTRY(33)
299 #define MIPS_PROM_SETENV MIPS_PROM_ENTRY(34)
300 #define MIPS_PROM_ATOB MIPS_PROM_ENTRY(35)
301 #define MIPS_PROM_STRCMP MIPS_PROM_ENTRY(36)
302 #define MIPS_PROM_STRLEN MIPS_PROM_ENTRY(37)
303 #define MIPS_PROM_STRCPY MIPS_PROM_ENTRY(38)
304 #define MIPS_PROM_STRCAT MIPS_PROM_ENTRY(39)
305 #define MIPS_PROM_PARSER MIPS_PROM_ENTRY(40)
306 #define MIPS_PROM_RANGE MIPS_PROM_ENTRY(41)
307 #define MIPS_PROM_ARGVIZE MIPS_PROM_ENTRY(42)
308 #define MIPS_PROM_HELP MIPS_PROM_ENTRY(43)
309 #define MIPS_PROM_DUMP MIPS_PROM_ENTRY(44)
310 #define MIPS_PROM_SETENVCMD MIPS_PROM_ENTRY(45)
311 #define MIPS_PROM_UNSETENVCMD MIPS_PROM_ENTRY(46)
312 #define MIPS_PROM_PRINTENV MIPS_PROM_ENTRY(47)
313 #define MIPS_PROM_BEVEXCEPT MIPS_PROM_ENTRY(48)
314 #define MIPS_PROM_ENABLE MIPS_PROM_ENTRY(49)
315 #define MIPS_PROM_DISABLE MIPS_PROM_ENTRY(50)
316 #define MIPS_PROM_CLEARNOFAULT MIPS_PROM_ENTRY(51)
317 #define MIPS_PROM_NOTIMPLEMENT MIPS_PROM_ENTRY(52)
318 #define MIPS_PROM_NVGET MIPS_PROM_ENTRY(53)
319 #define MIPS_PROM_NVSET MIPS_PROM_ENTRY(54)
320
321 #endif /* ! _MIPSCO_PROM_H */
322