autoconf.h revision 1.18 1 1.18 pk /* $NetBSD: autoconf.h,v 1.18 1997/04/08 20:06:26 pk Exp $ */
2 1.6 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 software was developed by the Computer Systems Engineering group
8 1.1 deraadt * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 1.1 deraadt * contributed to Berkeley.
10 1.1 deraadt *
11 1.1 deraadt * All advertising materials mentioning features or use of this software
12 1.1 deraadt * must display the following acknowledgement:
13 1.1 deraadt * This product includes software developed by the University of
14 1.1 deraadt * California, Lawrence Berkeley Laboratory.
15 1.1 deraadt *
16 1.1 deraadt * Redistribution and use in source and binary forms, with or without
17 1.1 deraadt * modification, are permitted provided that the following conditions
18 1.1 deraadt * are met:
19 1.1 deraadt * 1. Redistributions of source code must retain the above copyright
20 1.1 deraadt * notice, this list of conditions and the following disclaimer.
21 1.1 deraadt * 2. Redistributions in binary form must reproduce the above copyright
22 1.1 deraadt * notice, this list of conditions and the following disclaimer in the
23 1.1 deraadt * documentation and/or other materials provided with the distribution.
24 1.1 deraadt * 3. All advertising materials mentioning features or use of this software
25 1.1 deraadt * must display the following acknowledgement:
26 1.1 deraadt * This product includes software developed by the University of
27 1.1 deraadt * California, Berkeley and its contributors.
28 1.1 deraadt * 4. Neither the name of the University nor the names of its contributors
29 1.1 deraadt * may be used to endorse or promote products derived from this software
30 1.1 deraadt * without specific prior written permission.
31 1.1 deraadt *
32 1.1 deraadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 1.1 deraadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 1.1 deraadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 1.1 deraadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 1.1 deraadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.1 deraadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.1 deraadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.1 deraadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 1.1 deraadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 1.1 deraadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 1.1 deraadt * SUCH DAMAGE.
43 1.1 deraadt *
44 1.3 deraadt * @(#)autoconf.h 8.2 (Berkeley) 9/30/93
45 1.1 deraadt */
46 1.1 deraadt
47 1.1 deraadt /*
48 1.1 deraadt * Autoconfiguration information.
49 1.1 deraadt */
50 1.1 deraadt
51 1.1 deraadt /*
52 1.1 deraadt * Most devices are configured according to information kept in
53 1.1 deraadt * the FORTH PROMs. In particular, we extract the `name', `reg',
54 1.1 deraadt * and `address' properties of each device attached to the mainbus;
55 1.1 deraadt * other drives may also use this information. The mainbus itself
56 1.1 deraadt * (which `is' the CPU, in some sense) gets just the node, with a
57 1.1 deraadt * fake name ("mainbus").
58 1.1 deraadt */
59 1.15 pk
60 1.15 pk #define RA_MAXVADDR 8 /* max (virtual) addresses per device */
61 1.15 pk #define RA_MAXREG 16 /* max # of register banks per device */
62 1.1 deraadt #define RA_MAXINTR 8 /* max interrupts per device */
63 1.15 pk
64 1.1 deraadt struct romaux {
65 1.1 deraadt const char *ra_name; /* name from FORTH PROM */
66 1.1 deraadt int ra_node; /* FORTH PROM node ID */
67 1.9 pk void *ra_vaddrs[RA_MAXVADDR];/* ROM mapped virtual addresses */
68 1.9 pk int ra_nvaddrs; /* # of ra_vaddrs[]s, may be 0 */
69 1.9 pk #define ra_vaddr ra_vaddrs[0] /* compatibility */
70 1.15 pk
71 1.8 pk struct rom_reg {
72 1.8 pk int rr_iospace; /* register space (obio, etc) */
73 1.8 pk void *rr_paddr; /* register physical address */
74 1.8 pk int rr_len; /* register length */
75 1.8 pk } ra_reg[RA_MAXREG];
76 1.8 pk int ra_nreg; /* # of ra_reg[]s */
77 1.8 pk #define ra_iospace ra_reg[0].rr_iospace
78 1.8 pk #define ra_paddr ra_reg[0].rr_paddr
79 1.8 pk #define ra_len ra_reg[0].rr_len
80 1.15 pk
81 1.1 deraadt struct rom_intr { /* interrupt information: */
82 1.1 deraadt int int_pri; /* priority (IPL) */
83 1.1 deraadt int int_vec; /* vector (always 0?) */
84 1.1 deraadt } ra_intr[RA_MAXINTR];
85 1.1 deraadt int ra_nintr; /* number of interrupt info elements */
86 1.15 pk
87 1.18 pk struct bootpath *ra_bp; /* used for locating boot device */
88 1.18 pk };
89 1.15 pk
90 1.18 pk struct rom_range { /* Only used on v3 PROMs */
91 1.18 pk u_int32_t cspace; /* Client space */
92 1.18 pk u_int32_t coffset; /* Client offset */
93 1.18 pk u_int32_t pspace; /* Parent space */
94 1.18 pk u_int32_t poffset; /* Parent offset */
95 1.18 pk u_int32_t size; /* Size in bytes of this range */
96 1.1 deraadt };
97 1.4 deraadt
98 1.4 deraadt
99 1.4 deraadt struct confargs {
100 1.4 deraadt int ca_bustype;
101 1.4 deraadt struct romaux ca_ra;
102 1.4 deraadt int ca_slot;
103 1.4 deraadt int ca_offset;
104 1.4 deraadt };
105 1.4 deraadt #define BUS_MAIN 0
106 1.5 deraadt #define BUS_OBIO 1
107 1.5 deraadt #define BUS_VME16 2
108 1.5 deraadt #define BUS_VME32 3
109 1.5 deraadt #define BUS_SBUS 4
110 1.5 deraadt
111 1.5 deraadt extern int bt2pmt[];
112 1.1 deraadt
113 1.1 deraadt /*
114 1.11 pk * mapiodev maps an I/O device to a virtual address, returning the address.
115 1.11 pk * mapdev does the real work: you can supply a special virtual address and
116 1.11 pk * it will use that instead of creating one, but you must only do this if
117 1.11 pk * you get it from ../sparc/vaddrs.h.
118 1.11 pk */
119 1.11 pk void *mapdev __P((struct rom_reg *pa, int va,
120 1.11 pk int offset, int size, int bustype));
121 1.11 pk #define mapiodev(pa, offset, size, bustype) \
122 1.11 pk mapdev(pa, 0, offset, size, bustype)
123 1.11 pk /*
124 1.11 pk * REG2PHYS is provided for drivers with a `d_mmap' function.
125 1.11 pk */
126 1.11 pk #define REG2PHYS(rr, offset, bt) \
127 1.11 pk (((u_int)(rr)->rr_paddr + (offset)) | \
128 1.15 pk ((CPU_ISSUN4M) \
129 1.11 pk ? ((rr)->rr_iospace << PMAP_SHFT4M) \
130 1.11 pk : bt2pmt[bt]) \
131 1.11 pk )
132 1.11 pk
133 1.15 pk /* For VME and sun4/obio busses */
134 1.15 pk void *bus_map __P((struct rom_reg *, int, int));
135 1.15 pk void *bus_tmp __P((void *, int));
136 1.15 pk void bus_untmp __P((void));
137 1.11 pk
138 1.11 pk /*
139 1.1 deraadt * The various getprop* functions obtain `properties' from the ROMs.
140 1.1 deraadt * getprop() obtains a property as a byte-sequence, and returns its
141 1.1 deraadt * length; the others convert or make some other guarantee.
142 1.1 deraadt */
143 1.18 pk int getproplen __P((int node, char *name));
144 1.1 deraadt int getprop __P((int node, char *name, void *buf, int bufsiz));
145 1.1 deraadt char *getpropstring __P((int node, char *name));
146 1.1 deraadt int getpropint __P((int node, char *name, int deflt));
147 1.1 deraadt
148 1.1 deraadt /* Frequently used options node */
149 1.1 deraadt extern int optionsnode;
150 1.1 deraadt
151 1.1 deraadt /*
152 1.1 deraadt * The romprop function gets physical and virtual addresses from the PROM
153 1.1 deraadt * and fills in a romaux. It returns 1 on success, 0 if the physical
154 1.1 deraadt * address is not available as a "reg" property.
155 1.1 deraadt */
156 1.1 deraadt int romprop __P((struct romaux *ra, const char *name, int node));
157 1.1 deraadt
158 1.1 deraadt /*
159 1.1 deraadt * The matchbyname function is useful in drivers that are matched
160 1.1 deraadt * by romaux name, i.e., all `mainbus attached' devices. It expects
161 1.1 deraadt * its aux pointer to point to a pointer to the name (the address of
162 1.1 deraadt * a romaux structure suffices, for instance).
163 1.1 deraadt */
164 1.14 christos struct device;
165 1.17 pk struct cfdata;
166 1.17 pk int matchbyname __P((struct device *, struct cfdata *cf, void *aux));
167 1.1 deraadt
168 1.1 deraadt /*
169 1.1 deraadt * `clockfreq' produces a printable representation of a clock frequency
170 1.1 deraadt * (this is just a frill).
171 1.1 deraadt */
172 1.1 deraadt char *clockfreq __P((int freq));
173 1.1 deraadt
174 1.1 deraadt /*
175 1.1 deraadt * Memory description arrays. Shared between pmap.c and autoconf.c; no
176 1.1 deraadt * one else should use this (except maybe mem.c, e.g., if we fix the VM to
177 1.1 deraadt * handle discontiguous physical memory).
178 1.1 deraadt */
179 1.1 deraadt struct memarr {
180 1.1 deraadt u_int addr;
181 1.1 deraadt u_int len;
182 1.1 deraadt };
183 1.1 deraadt int makememarr(struct memarr *, int max, int which);
184 1.1 deraadt #define MEMARR_AVAILPHYS 0
185 1.1 deraadt #define MEMARR_TOTALPHYS 1
186 1.1 deraadt
187 1.1 deraadt /* Pass a string to the FORTH interpreter. May fail silently. */
188 1.1 deraadt void rominterpret __P((char *));
189 1.1 deraadt
190 1.1 deraadt /* Openprom V2 style boot path */
191 1.1 deraadt struct bootpath {
192 1.16 pk char name[16]; /* name of this node */
193 1.16 pk int val[3]; /* up to three optional values */
194 1.16 pk struct device *dev; /* device that recognised this component */
195 1.1 deraadt };
196 1.1 deraadt
197 1.10 pk struct bootpath *bootpath_store __P((int, struct bootpath *));
198 1.10 pk int sd_crazymap __P((int));
199 1.2 deraadt
200 1.2 deraadt /* Parse a disk string into a dev_t, return device struct pointer */
201 1.2 deraadt struct device *parsedisk __P((char *, int, int, dev_t *));
202 1.13 thorpej
203 1.13 thorpej /* Establish a mountroot_hook, for benefit of floppy drive, mostly. */
204 1.16 pk void mountroot_hook_establish __P((void (*) __P((struct device *)),
205 1.16 pk struct device *));
206 1.14 christos
207 1.14 christos void configure __P((void));
208 1.14 christos void bootstrap __P((void));
209 1.14 christos int firstchild __P((int));
210 1.14 christos int nextsibling __P((int));
211 1.14 christos void callrom __P((void));
212 1.14 christos struct device *getdevunit __P((char *, int));
213 1.16 pk void *findzs __P((int));
214 1.14 christos int romgetcursoraddr __P((int **, int **));
215 1.14 christos int findroot __P((void));
216 1.15 pk int findnode __P((int, const char *));
217 1.15 pk int opennode __P((char *));
218 1.15 pk int node_has_property __P((int, const char *));
219