bsd_openprom.h revision 1.19.2.2 1 1.19.2.1 skrll /* $NetBSD: bsd_openprom.h,v 1.19.2.2 2004/09/18 14:40:38 skrll Exp $ */
2 1.2 deraadt
3 1.1 deraadt /*
4 1.1 deraadt * Copyright (c) 1992, 1993
5 1.1 deraadt * The Regents of the University of California. All rights reserved.
6 1.1 deraadt *
7 1.1 deraadt * This code is derived from software contributed to Berkeley by
8 1.1 deraadt * Jan-Simon Pendry.
9 1.1 deraadt *
10 1.1 deraadt * Redistribution and use in source and binary forms, with or without
11 1.1 deraadt * modification, are permitted provided that the following conditions
12 1.1 deraadt * are met:
13 1.1 deraadt * 1. Redistributions of source code must retain the above copyright
14 1.1 deraadt * notice, this list of conditions and the following disclaimer.
15 1.1 deraadt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 deraadt * notice, this list of conditions and the following disclaimer in the
17 1.1 deraadt * documentation and/or other materials provided with the distribution.
18 1.19.2.1 skrll * 3. Neither the name of the University nor the names of its contributors
19 1.1 deraadt * may be used to endorse or promote products derived from this software
20 1.1 deraadt * without specific prior written permission.
21 1.1 deraadt *
22 1.1 deraadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 1.1 deraadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.1 deraadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.1 deraadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 1.1 deraadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 deraadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.1 deraadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 deraadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 deraadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 deraadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 deraadt * SUCH DAMAGE.
33 1.1 deraadt *
34 1.1 deraadt * @(#)bsd_openprom.h 8.1 (Berkeley) 6/11/93
35 1.1 deraadt */
36 1.1 deraadt
37 1.1 deraadt /*
38 1.10 abrown * Sun4m support by Aaron Brown, Harvard University.
39 1.8 pk * Changes Copyright (c) 1995 The President and Fellows of Harvard College.
40 1.8 pk * All rights reserved.
41 1.8 pk */
42 1.8 pk
43 1.13 pk #ifndef _BSD_OPENPROM_H_
44 1.13 pk #define _BSD_OPENPROM_H_
45 1.13 pk
46 1.8 pk /*
47 1.1 deraadt * This file defines the interface between the kernel and the Openboot PROM.
48 1.1 deraadt * N.B.: this has been tested only on interface versions 0 and 2 (we have
49 1.1 deraadt * never seen interface version 1).
50 1.1 deraadt */
51 1.1 deraadt
52 1.1 deraadt /*
53 1.1 deraadt * The v0 interface tells us what virtual memory to scan to avoid PMEG
54 1.1 deraadt * conflicts, but the v2 interface fails to do so, and we must `magically'
55 1.1 deraadt * know where the OPENPROM lives in virtual space.
56 1.1 deraadt */
57 1.1 deraadt #define OPENPROM_STARTVADDR 0xffd00000
58 1.1 deraadt #define OPENPROM_ENDVADDR 0xfff00000
59 1.1 deraadt
60 1.1 deraadt #define OPENPROM_MAGIC 0x10010407
61 1.1 deraadt
62 1.1 deraadt /*
63 1.1 deraadt * Version 0 PROM vector device operations (collected here to emphasise that
64 1.1 deraadt * they are deprecated). Open and close are obvious. Read and write are
65 1.1 deraadt * segregated according to the device type (block, network, or character);
66 1.1 deraadt * this is unnecessary and was eliminated from the v2 device operations, but
67 1.1 deraadt * we are stuck with it.
68 1.1 deraadt *
69 1.1 deraadt * Seek is probably only useful on tape devices, since the only character
70 1.1 deraadt * devices are the serial ports.
71 1.1 deraadt *
72 1.1 deraadt * Note that a v0 device name is always exactly two characters ("sd", "le",
73 1.1 deraadt * and so forth).
74 1.1 deraadt */
75 1.1 deraadt struct v0devops {
76 1.6 christos int (*v0_open) __P((char *dev));
77 1.6 christos int (*v0_close) __P((int d));
78 1.6 christos int (*v0_rbdev) __P((int d, int nblks, int blkno, void *addr));
79 1.8 pk int (*v0_wbdev) __P((int d, int nblks, int blkno, void *addr));
80 1.6 christos int (*v0_wnet) __P((int d, int nbytes, void *addr));
81 1.6 christos int (*v0_rnet) __P((int d, int nbytes, void *addr));
82 1.6 christos int (*v0_rcdev) __P((int d, int nbytes, int, void *addr));
83 1.6 christos int (*v0_wcdev) __P((int d, int nbytes, int, void *addr));
84 1.6 christos int (*v0_seek) __P((int d, long offset, int whence));
85 1.1 deraadt };
86 1.1 deraadt
87 1.1 deraadt /*
88 1.1 deraadt * Version 2 device operations. Open takes a device `path' such as
89 1.1 deraadt * /sbus/le@0,c00000,0 or /sbus/esp@.../sd@0,0, which means it can open
90 1.1 deraadt * anything anywhere, without any magic translation.
91 1.1 deraadt *
92 1.1 deraadt * The memory allocator and map functions are included here even though
93 1.1 deraadt * they relate only indirectly to devices (e.g., mmap is good for mapping
94 1.1 deraadt * device memory, and drivers need to allocate space in which to record
95 1.1 deraadt * the device state).
96 1.1 deraadt */
97 1.1 deraadt struct v2devops {
98 1.3 pk /*
99 1.3 pk * Convert an `instance handle' (acquired through v2_open()) to
100 1.3 pk * a `package handle', a.k.a. a `node'.
101 1.3 pk */
102 1.6 christos int (*v2_fd_phandle) __P((int d));
103 1.1 deraadt
104 1.1 deraadt /* Memory allocation and release. */
105 1.6 christos void *(*v2_malloc) __P((caddr_t va, u_int sz));
106 1.6 christos void (*v2_free) __P((caddr_t va, u_int sz));
107 1.1 deraadt
108 1.1 deraadt /* Device memory mapper. */
109 1.6 christos caddr_t (*v2_mmap) __P((caddr_t va, int asi, u_int pa, u_int sz));
110 1.6 christos void (*v2_munmap) __P((caddr_t va, u_int sz));
111 1.1 deraadt
112 1.1 deraadt /* Device open, close, etc. */
113 1.6 christos int (*v2_open) __P((char *devpath));
114 1.6 christos void (*v2_close) __P((int d));
115 1.6 christos int (*v2_read) __P((int d, void *buf, int nbytes));
116 1.6 christos int (*v2_write) __P((int d, void *buf, int nbytes));
117 1.6 christos void (*v2_seek) __P((int d, int hi, int lo));
118 1.1 deraadt
119 1.6 christos void (*v2_chain) __P((void)); /* ??? */
120 1.6 christos void (*v2_release) __P((void)); /* ??? */
121 1.1 deraadt };
122 1.1 deraadt
123 1.1 deraadt /*
124 1.1 deraadt * The v0 interface describes memory regions with these linked lists.
125 1.1 deraadt * (The !$&@#+ v2 interface reformats these as properties, so that we
126 1.1 deraadt * have to extract them into local temporary memory and reinterpret them.)
127 1.1 deraadt */
128 1.1 deraadt struct v0mlist {
129 1.1 deraadt struct v0mlist *next;
130 1.1 deraadt caddr_t addr;
131 1.1 deraadt u_int nbytes;
132 1.1 deraadt };
133 1.1 deraadt
134 1.1 deraadt /*
135 1.1 deraadt * V0 gives us three memory lists: Total physical memory, VM reserved to
136 1.1 deraadt * the PROM, and available physical memory (which, presumably, is just the
137 1.1 deraadt * total minus any pages mapped in the PROM's VM region). We can find the
138 1.1 deraadt * reserved PMEGs by scanning the taken VM. Unfortunately, the V2 prom
139 1.1 deraadt * forgot to provide taken VM, and we are stuck with scanning ``magic''
140 1.1 deraadt * addresses.
141 1.1 deraadt */
142 1.1 deraadt struct v0mem {
143 1.1 deraadt struct v0mlist **v0_phystot; /* physical memory */
144 1.1 deraadt struct v0mlist **v0_vmprom; /* VM used by PROM */
145 1.1 deraadt struct v0mlist **v0_physavail; /* available physical memory */
146 1.1 deraadt };
147 1.1 deraadt
148 1.1 deraadt /*
149 1.1 deraadt * The version 0 PROM breaks up the string given to the boot command and
150 1.1 deraadt * leaves the decoded version behind.
151 1.1 deraadt */
152 1.1 deraadt struct v0bootargs {
153 1.1 deraadt char *ba_argv[8]; /* argv format for boot string */
154 1.1 deraadt char ba_args[100]; /* string space */
155 1.1 deraadt char ba_bootdev[2]; /* e.g., "sd" for `b sd(...' */
156 1.1 deraadt int ba_ctlr; /* controller # */
157 1.1 deraadt int ba_unit; /* unit # */
158 1.1 deraadt int ba_part; /* partition # */
159 1.1 deraadt char *ba_kernel; /* kernel to boot, e.g., "vmunix" */
160 1.1 deraadt void *ba_spare0; /* not decoded here XXX */
161 1.1 deraadt };
162 1.1 deraadt
163 1.1 deraadt /*
164 1.1 deraadt * The version 2 PROM interface uses the more general, if less convenient,
165 1.1 deraadt * approach of passing the boot strings unchanged. We also get open file
166 1.1 deraadt * numbers for stdin and stdout (keyboard and screen, or whatever), for use
167 1.1 deraadt * with the v2 device ops.
168 1.1 deraadt */
169 1.1 deraadt struct v2bootargs {
170 1.1 deraadt char **v2_bootpath; /* V2: Path to boot device */
171 1.1 deraadt char **v2_bootargs; /* V2: Boot args */
172 1.1 deraadt int *v2_fd0; /* V2: Stdin descriptor */
173 1.1 deraadt int *v2_fd1; /* V2: Stdout descriptor */
174 1.1 deraadt };
175 1.1 deraadt
176 1.1 deraadt /*
177 1.18 thorpej * The format used by the PROM to describe a physical address. These
178 1.18 thorpej * are typically found in a "reg" property.
179 1.13 pk */
180 1.13 pk struct openprom_addr {
181 1.13 pk int oa_space; /* address space (may be relative) */
182 1.13 pk u_int oa_base; /* address within space */
183 1.13 pk u_int oa_size; /* extent (number of bytes) */
184 1.18 thorpej };
185 1.18 thorpej
186 1.18 thorpej /*
187 1.18 thorpej * The format used by the PROM to describe an address space window. These
188 1.18 thorpej * are typically found in a "range" property.
189 1.18 thorpej */
190 1.18 thorpej struct openprom_range {
191 1.18 thorpej int or_child_space; /* address space of child */
192 1.18 thorpej u_int or_child_base; /* offset in child's view of bus */
193 1.18 thorpej int or_parent_space; /* address space of parent */
194 1.18 thorpej u_int or_parent_base; /* offset in parent's view of bus */
195 1.18 thorpej u_int or_size; /* extent (number of bytes) */
196 1.18 thorpej };
197 1.18 thorpej
198 1.18 thorpej /*
199 1.18 thorpej * The format used by the PROM to describe an interrupt. These are
200 1.18 thorpej * typically found in an "intr" property.
201 1.18 thorpej */
202 1.18 thorpej struct openprom_intr {
203 1.18 thorpej int oi_pri; /* interrupt priority */
204 1.18 thorpej int oi_vec; /* interrupt vector */
205 1.13 pk };
206 1.13 pk
207 1.13 pk /*
208 1.1 deraadt * The following structure defines the primary PROM vector interface.
209 1.1 deraadt * The Boot PROM hands the kernel a pointer to this structure in %o0.
210 1.1 deraadt * There are numerous substructures defined below.
211 1.1 deraadt */
212 1.1 deraadt struct promvec {
213 1.1 deraadt /* Version numbers. */
214 1.1 deraadt u_int pv_magic; /* Magic number */
215 1.15 pk #define OBP_MAGIC 0x10010407
216 1.1 deraadt u_int pv_romvec_vers; /* interface version (0, 2) */
217 1.1 deraadt u_int pv_plugin_vers; /* ??? */
218 1.1 deraadt u_int pv_printrev; /* PROM rev # (* 10, e.g 1.9 = 19) */
219 1.1 deraadt
220 1.1 deraadt /* Version 0 memory descriptors (see below). */
221 1.1 deraadt struct v0mem pv_v0mem; /* V0: Memory description lists. */
222 1.1 deraadt
223 1.1 deraadt /* Node operations (see below). */
224 1.1 deraadt struct nodeops *pv_nodeops; /* node functions */
225 1.1 deraadt
226 1.1 deraadt char **pv_bootstr; /* Boot command, eg sd(0,0,0)vmunix */
227 1.1 deraadt
228 1.1 deraadt struct v0devops pv_v0devops; /* V0: device ops */
229 1.1 deraadt
230 1.1 deraadt /*
231 1.1 deraadt * PROMDEV_* cookies. I fear these may vanish in lieu of fd0/fd1
232 1.1 deraadt * (see below) in future PROMs, but for now they work fine.
233 1.1 deraadt */
234 1.1 deraadt char *pv_stdin; /* stdin cookie */
235 1.1 deraadt char *pv_stdout; /* stdout cookie */
236 1.1 deraadt #define PROMDEV_KBD 0 /* input from keyboard */
237 1.1 deraadt #define PROMDEV_SCREEN 0 /* output to screen */
238 1.1 deraadt #define PROMDEV_TTYA 1 /* in/out to ttya */
239 1.1 deraadt #define PROMDEV_TTYB 2 /* in/out to ttyb */
240 1.1 deraadt
241 1.1 deraadt /* Blocking getchar/putchar. NOT REENTRANT! (grr) */
242 1.6 christos int (*pv_getchar) __P((void));
243 1.6 christos void (*pv_putchar) __P((int ch));
244 1.1 deraadt
245 1.1 deraadt /* Non-blocking variants that return -1 on error. */
246 1.6 christos int (*pv_nbgetchar) __P((void));
247 1.6 christos int (*pv_nbputchar) __P((int ch));
248 1.1 deraadt
249 1.1 deraadt /* Put counted string (can be very slow). */
250 1.6 christos void (*pv_putstr) __P((char *str, int len));
251 1.1 deraadt
252 1.1 deraadt /* Miscellany. */
253 1.15 pk void (*pv_reboot) __P((char *bootstr)) __attribute__((noreturn));
254 1.6 christos void (*pv_printf) __P((const char *fmt, ...));
255 1.6 christos void (*pv_abort) __P((void)); /* L1-A abort */
256 1.1 deraadt int *pv_ticks; /* Ticks since last reset */
257 1.6 christos __dead void (*pv_halt) __P((void)) __attribute__((noreturn));/* Halt! */
258 1.6 christos void (**pv_synchook) __P((void)); /* "sync" command hook */
259 1.1 deraadt
260 1.1 deraadt /*
261 1.1 deraadt * This eval's a FORTH string. Unfortunately, its interface
262 1.1 deraadt * changed between V0 and V2, which gave us much pain.
263 1.1 deraadt */
264 1.1 deraadt union {
265 1.6 christos void (*v0_eval) __P((int len, char *str));
266 1.6 christos void (*v2_eval) __P((char *str));
267 1.1 deraadt } pv_fortheval;
268 1.1 deraadt
269 1.1 deraadt struct v0bootargs **pv_v0bootargs; /* V0: Boot args */
270 1.1 deraadt
271 1.1 deraadt /* Extract Ethernet address from network device. */
272 1.6 christos u_int (*pv_enaddr) __P((int d, char *enaddr));
273 1.1 deraadt
274 1.1 deraadt struct v2bootargs pv_v2bootargs; /* V2: Boot args + std in/out */
275 1.1 deraadt struct v2devops pv_v2devops; /* V2: device operations */
276 1.1 deraadt
277 1.1 deraadt int pv_spare[15];
278 1.1 deraadt
279 1.1 deraadt /*
280 1.1 deraadt * The following is machine-dependent.
281 1.1 deraadt *
282 1.1 deraadt * The sun4c needs a PROM function to set a PMEG for another
283 1.1 deraadt * context, so that the kernel can map itself in all contexts.
284 1.1 deraadt * It is not possible simply to set the context register, because
285 1.1 deraadt * contexts 1 through N may have invalid translations for the
286 1.1 deraadt * current program counter. The hardware has a mode in which
287 1.1 deraadt * all memory references go to the PROM, so the PROM can do it
288 1.1 deraadt * easily.
289 1.1 deraadt */
290 1.6 christos void (*pv_setctxt) __P((int ctxt, caddr_t va, int pmeg));
291 1.12 pk
292 1.8 pk /*
293 1.4 pk * The following are V3 ROM functions to handle MP machines in the
294 1.4 pk * Sun4m series. They have undefined results when run on a uniprocessor!
295 1.4 pk */
296 1.15 pk int (*pv_v3cpustart) __P((int module,
297 1.13 pk struct openprom_addr *ctxtbl,
298 1.6 christos int context, caddr_t pc));
299 1.15 pk int (*pv_v3cpustop) __P((int module));
300 1.15 pk int (*pv_v3cpuidle) __P((int module));
301 1.15 pk int (*pv_v3cpuresume) __P((int module));
302 1.1 deraadt };
303 1.1 deraadt
304 1.1 deraadt /*
305 1.1 deraadt * In addition to the global stuff defined in the PROM vectors above,
306 1.1 deraadt * the PROM has quite a collection of `nodes'. A node is described by
307 1.1 deraadt * an integer---these seem to be internal pointers, actually---and the
308 1.1 deraadt * nodes are arranged into an N-ary tree. Each node implements a fixed
309 1.1 deraadt * set of functions, as described below. The first two deal with the tree
310 1.1 deraadt * structure, allowing traversals in either breadth- or depth-first fashion.
311 1.1 deraadt * The rest deal with `properties'.
312 1.1 deraadt *
313 1.1 deraadt * A node property is simply a name/value pair. The names are C strings
314 1.1 deraadt * (NUL-terminated); the values are arbitrary byte strings (counted strings).
315 1.1 deraadt * Many values are really just C strings. Sometimes these are NUL-terminated,
316 1.16 soren * sometimes not, depending on the interface version; v0 seems to terminate
317 1.16 soren * and v2 not. Many others are simply integers stored as four bytes in
318 1.16 soren * machine order: you just get them and go. The third popular format is
319 1.16 soren * an `physical address', which is made up of one or more sets of three
320 1.16 soren * integers as defined above.
321 1.1 deraadt *
322 1.1 deraadt * N.B.: for the `next' functions, next(0) = first, and next(last) = 0.
323 1.1 deraadt * Whoever designed this part had good taste. On the other hand, these
324 1.1 deraadt * operation vectors are global, rather than per-node, yet the pointers
325 1.1 deraadt * are not in the openprom vectors but rather found by indirection from
326 1.1 deraadt * there. So the taste balances out.
327 1.1 deraadt */
328 1.1 deraadt
329 1.1 deraadt struct nodeops {
330 1.1 deraadt /*
331 1.1 deraadt * Tree traversal.
332 1.1 deraadt */
333 1.6 christos int (*no_nextnode) __P((int node)); /* next(node) */
334 1.6 christos int (*no_child) __P((int node)); /* first child */
335 1.1 deraadt
336 1.1 deraadt /*
337 1.1 deraadt * Property functions. Proper use of getprop requires calling
338 1.1 deraadt * proplen first to make sure it fits. Kind of a pain, but no
339 1.1 deraadt * doubt more convenient for the PROM coder.
340 1.1 deraadt */
341 1.15 pk int (*no_proplen) __P((int node, char *name));
342 1.15 pk int (*no_getprop) __P((int node, char *name, void *val));
343 1.17 pk int (*no_setprop) __P((int node, char *name, const void *val,
344 1.6 christos int len));
345 1.15 pk char *(*no_nextprop) __P((int node, char *name));
346 1.1 deraadt };
347 1.7 christos
348 1.19 pk /*
349 1.19 pk * OBP Module mailbox messages for multi processor machines.
350 1.19 pk *
351 1.19 pk * 00..7F : power-on self test
352 1.19 pk * 80..8F : active in boot prom (at the "ok" prompt)
353 1.19 pk * 90..EF : idle in boot prom
354 1.19 pk * F0 : active in application
355 1.19 pk * F1..FA : reserved for future use
356 1.19 pk *
357 1.19 pk * FB : pv_v3cpustop(node) was called for this CPU,
358 1.19 pk * respond by calling pv_v3cpustop(0).
359 1.19 pk *
360 1.19 pk * FC : pv_v3cpuidle(node) was called for this CPU,
361 1.19 pk * respond by calling pv_v3cpuidle(0).
362 1.19 pk *
363 1.19 pk * FD : One processor hit a BREAKPOINT, call pv_v3cpuidle(0).
364 1.19 pk * [According to SunOS4 header; but what breakpoint?]
365 1.19 pk *
366 1.19 pk * FE : One processor got a WATCHDOG RESET, call pv_v3cpustop(0).
367 1.19 pk * [According to SunOS4 header; never seen this, although
368 1.19 pk * I've had plenty of watchdogs already]
369 1.19 pk *
370 1.19 pk * FF : This processor is not available.
371 1.19 pk */
372 1.19 pk
373 1.19 pk #define OPENPROM_MBX_STOP 0xfb
374 1.19 pk #define OPENPROM_MBX_ABORT 0xfc
375 1.19 pk #define OPENPROM_MBX_BPT 0xfd
376 1.19 pk #define OPENPROM_MBX_WD 0xfe
377 1.13 pk
378 1.13 pk #endif /* _BSD_OPENPROM_H_ */
379