autoconf.h revision 1.4 1 /*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This software was developed by the Computer Systems Engineering group
6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 * contributed to Berkeley.
8 *
9 * All advertising materials mentioning features or use of this software
10 * must display the following acknowledgement:
11 * This product includes software developed by the University of
12 * California, Lawrence Berkeley Laboratory.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by the University of
25 * California, Berkeley and its contributors.
26 * 4. Neither the name of the University nor the names of its contributors
27 * may be used to endorse or promote products derived from this software
28 * without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 * @(#)autoconf.h 8.2 (Berkeley) 9/30/93
43 *
44 * from: Header: autoconf.h,v 1.11 93/09/28 05:26:41 leres Exp (LBL)
45 * $Id: autoconf.h,v 1.4 1994/09/17 23:46:32 deraadt Exp $
46 */
47
48 /*
49 * Autoconfiguration information.
50 */
51
52 /*
53 * Most devices are configured according to information kept in
54 * the FORTH PROMs. In particular, we extract the `name', `reg',
55 * and `address' properties of each device attached to the mainbus;
56 * other drives may also use this information. The mainbus itself
57 * (which `is' the CPU, in some sense) gets just the node, with a
58 * fake name ("mainbus").
59 */
60 #define RA_MAXINTR 8 /* max interrupts per device */
61 struct romaux {
62 const char *ra_name; /* name from FORTH PROM */
63 int ra_node; /* FORTH PROM node ID */
64 int ra_iospace; /* register space (obio, etc) */
65 void *ra_paddr; /* register physical address */
66 int ra_len; /* register length */
67 void *ra_vaddr; /* ROM mapped virtual address, or 0 */
68 struct rom_intr { /* interrupt information: */
69 int int_pri; /* priority (IPL) */
70 int int_vec; /* vector (always 0?) */
71 } ra_intr[RA_MAXINTR];
72 int ra_nintr; /* number of interrupt info elements */
73 struct bootpath *ra_bp; /* used for locating boot device */
74 };
75
76
77 struct confargs {
78 int ca_bustype;
79 struct romaux ca_ra;
80 int ca_slot;
81 int ca_offset;
82 };
83 #define BUS_MAIN 0
84 #define BUS_SBUS 1
85 #define BUS_OBIO 2
86 #define BUS_VME 3
87
88 /*
89 * The various getprop* functions obtain `properties' from the ROMs.
90 * getprop() obtains a property as a byte-sequence, and returns its
91 * length; the others convert or make some other guarantee.
92 */
93 int getprop __P((int node, char *name, void *buf, int bufsiz));
94 char *getpropstring __P((int node, char *name));
95 int getpropint __P((int node, char *name, int deflt));
96
97 /* Frequently used options node */
98 extern int optionsnode;
99
100 /*
101 * The romprop function gets physical and virtual addresses from the PROM
102 * and fills in a romaux. It returns 1 on success, 0 if the physical
103 * address is not available as a "reg" property.
104 */
105 int romprop __P((struct romaux *ra, const char *name, int node));
106
107 /*
108 * The matchbyname function is useful in drivers that are matched
109 * by romaux name, i.e., all `mainbus attached' devices. It expects
110 * its aux pointer to point to a pointer to the name (the address of
111 * a romaux structure suffices, for instance).
112 */
113 int matchbyname __P((struct device *, struct cfdata *cf, void *aux));
114
115 /*
116 * `clockfreq' produces a printable representation of a clock frequency
117 * (this is just a frill).
118 */
119 char *clockfreq __P((int freq));
120
121 /*
122 * mapiodev maps an I/O device to a virtual address, returning the address.
123 * mapdev does the real work: you can supply a special virtual address and
124 * it will use that instead of creating one, but you must only do this if
125 * you get it from ../sparc/vaddrs.h.
126 */
127 void *mapdev __P((void *pa, int va, int size));
128 #define mapiodev(pa, size) mapdev(pa, 0, size)
129
130 /*
131 * Memory description arrays. Shared between pmap.c and autoconf.c; no
132 * one else should use this (except maybe mem.c, e.g., if we fix the VM to
133 * handle discontiguous physical memory).
134 */
135 struct memarr {
136 u_int addr;
137 u_int len;
138 };
139 int makememarr(struct memarr *, int max, int which);
140 #define MEMARR_AVAILPHYS 0
141 #define MEMARR_TOTALPHYS 1
142
143 /* Pass a string to the FORTH interpreter. May fail silently. */
144 void rominterpret __P((char *));
145
146 /* Openprom V2 style boot path */
147 struct bootpath {
148 char name[8]; /* name of this node */
149 int val[2]; /* up to two optional values */
150 };
151
152 struct device *bootdv; /* found during autoconfiguration */
153
154 /* Parse a disk string into a dev_t, return device struct pointer */
155 struct device *parsedisk __P((char *, int, int, dev_t *));
156