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