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