xref: /openbsd/sys/arch/sparc64/include/autoconf.h (revision fb1ca35c)
1*fb1ca35cSkettenis /*	$OpenBSD: autoconf.h,v 1.13 2007/04/07 14:20:10 kettenis Exp $	*/
2df39fa9dSjason /*	$NetBSD: autoconf.h,v 1.10 2001/07/24 19:32:11 eeh Exp $ */
3df39fa9dSjason 
4df39fa9dSjason /*-
5df39fa9dSjason  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
6df39fa9dSjason  * All rights reserved.
7df39fa9dSjason  *
8df39fa9dSjason  * This code is derived from software contributed to The NetBSD Foundation
9df39fa9dSjason  * by Paul Kranenburg.
10df39fa9dSjason  *
11df39fa9dSjason  * Redistribution and use in source and binary forms, with or without
12df39fa9dSjason  * modification, are permitted provided that the following conditions
13df39fa9dSjason  * are met:
14df39fa9dSjason  * 1. Redistributions of source code must retain the above copyright
15df39fa9dSjason  *    notice, this list of conditions and the following disclaimer.
16df39fa9dSjason  * 2. Redistributions in binary form must reproduce the above copyright
17df39fa9dSjason  *    notice, this list of conditions and the following disclaimer in the
18df39fa9dSjason  *    documentation and/or other materials provided with the distribution.
19df39fa9dSjason  * 3. All advertising materials mentioning features or use of this software
20df39fa9dSjason  *    must display the following acknowledgement:
21df39fa9dSjason  *        This product includes software developed by the NetBSD
22df39fa9dSjason  *        Foundation, Inc. and its contributors.
23df39fa9dSjason  * 4. Neither the name of The NetBSD Foundation nor the names of its
24df39fa9dSjason  *    contributors may be used to endorse or promote products derived
25df39fa9dSjason  *    from this software without specific prior written permission.
26df39fa9dSjason  *
27df39fa9dSjason  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28df39fa9dSjason  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29df39fa9dSjason  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30df39fa9dSjason  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31df39fa9dSjason  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32df39fa9dSjason  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33df39fa9dSjason  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34df39fa9dSjason  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35df39fa9dSjason  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36df39fa9dSjason  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37df39fa9dSjason  * POSSIBILITY OF SUCH DAMAGE.
38df39fa9dSjason  */
39df39fa9dSjason 
40df39fa9dSjason /*
41df39fa9dSjason  * Copyright (c) 1992, 1993
42df39fa9dSjason  *	The Regents of the University of California.  All rights reserved.
43df39fa9dSjason  *
44df39fa9dSjason  * This software was developed by the Computer Systems Engineering group
45df39fa9dSjason  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
46df39fa9dSjason  * contributed to Berkeley.
47df39fa9dSjason  *
48df39fa9dSjason  * All advertising materials mentioning features or use of this software
49df39fa9dSjason  * must display the following acknowledgement:
50df39fa9dSjason  *	This product includes software developed by the University of
51df39fa9dSjason  *	California, Lawrence Berkeley Laboratory.
52df39fa9dSjason  *
53df39fa9dSjason  * Redistribution and use in source and binary forms, with or without
54df39fa9dSjason  * modification, are permitted provided that the following conditions
55df39fa9dSjason  * are met:
56df39fa9dSjason  * 1. Redistributions of source code must retain the above copyright
57df39fa9dSjason  *    notice, this list of conditions and the following disclaimer.
58df39fa9dSjason  * 2. Redistributions in binary form must reproduce the above copyright
59df39fa9dSjason  *    notice, this list of conditions and the following disclaimer in the
60df39fa9dSjason  *    documentation and/or other materials provided with the distribution.
6129295d1cSmillert  * 3. Neither the name of the University nor the names of its contributors
62df39fa9dSjason  *    may be used to endorse or promote products derived from this software
63df39fa9dSjason  *    without specific prior written permission.
64df39fa9dSjason  *
65df39fa9dSjason  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
66df39fa9dSjason  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
67df39fa9dSjason  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
68df39fa9dSjason  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
69df39fa9dSjason  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
70df39fa9dSjason  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
71df39fa9dSjason  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
72df39fa9dSjason  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
73df39fa9dSjason  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
74df39fa9dSjason  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
75df39fa9dSjason  * SUCH DAMAGE.
76df39fa9dSjason  *
77df39fa9dSjason  *	@(#)autoconf.h	8.2 (Berkeley) 9/30/93
78df39fa9dSjason  */
79df39fa9dSjason 
80df39fa9dSjason /*
81df39fa9dSjason  * Autoconfiguration information.
82df39fa9dSjason  */
83df39fa9dSjason 
84df39fa9dSjason #include <machine/bus.h>
85df39fa9dSjason #include <dev/sbus/sbusvar.h>
86df39fa9dSjason 
87df39fa9dSjason /* This is used to map device classes to IPLs */
88df39fa9dSjason struct intrmap {
89df39fa9dSjason 	char	*in_class;
90df39fa9dSjason 	int	in_lev;
91df39fa9dSjason };
92df39fa9dSjason extern struct intrmap intrmap[];
93df39fa9dSjason 
94df39fa9dSjason /* The "mainbus" on ultra desktops is actually the UPA bus.  We need to
95df39fa9dSjason  * separate this from peripheral buses like SBUS and PCI because each bus may
96df39fa9dSjason  * have different ways of encoding properties, such as "reg" and "interrupts".
97df39fa9dSjason  */
98df39fa9dSjason 
994f2edc4eSmiod /* Device register space description */
1004f2edc4eSmiod struct upa_reg {
1014f2edc4eSmiod 	int64_t	ur_paddr;
1024f2edc4eSmiod 	int64_t	ur_len;
1034f2edc4eSmiod };
1044f2edc4eSmiod 
105df39fa9dSjason /*
106df39fa9dSjason  * Attach arguments presented by mainbus_attach()
107df39fa9dSjason  *
108df39fa9dSjason  * Large fields first followed by smaller ones to minimize stack space used.
109df39fa9dSjason  */
110df39fa9dSjason struct mainbus_attach_args {
111df39fa9dSjason 	bus_space_tag_t	ma_bustag;	/* parent bus tag */
112df39fa9dSjason 	bus_dma_tag_t	ma_dmatag;
113df39fa9dSjason 	char		*ma_name;	/* PROM node name */
114df39fa9dSjason 	struct upa_reg	*ma_reg;	/* "reg" properties */
115df39fa9dSjason 	u_int		*ma_address;	/* "address" properties -- 32 bits */
116df39fa9dSjason 	u_int		*ma_interrupts;	/* "interrupts" properties */
117df39fa9dSjason 	int		ma_upaid;	/* UPA bus ID */
118df39fa9dSjason 	int		ma_node;	/* PROM handle */
119df39fa9dSjason 	int		ma_nreg;	/* Counts for those properties */
120df39fa9dSjason 	int		ma_naddress;
121df39fa9dSjason 	int		ma_ninterrupts;
122df39fa9dSjason 	int		ma_pri;		/* priority (IPL) */
123df39fa9dSjason };
124df39fa9dSjason 
125df39fa9dSjason /*
126df39fa9dSjason  * length; the others convert or make some other guarantee.
127df39fa9dSjason  */
128c4071fd1Smillert long	getproplen(int node, char *name);
129c4071fd1Smillert int	getprop(int, char *, size_t, int *, void **);
130c4071fd1Smillert char	*getpropstring(int node, char *name);
131c4071fd1Smillert int	getpropint(int node, char *name, int deflt);
132df39fa9dSjason 
133df39fa9dSjason /* Frequently used options node */
134df39fa9dSjason extern int optionsnode;
135df39fa9dSjason 
136df39fa9dSjason 	/* new interfaces: */
137c4071fd1Smillert char	*getpropstringA(int, char *, char *);
138df39fa9dSjason 
139df39fa9dSjason /*
140df39fa9dSjason  * `clockfreq' produces a printable representation of a clock frequency
141df39fa9dSjason  * (this is just a frill).
142df39fa9dSjason  */
143c4071fd1Smillert char	*clockfreq(long freq);
144df39fa9dSjason 
145df39fa9dSjason /* Openprom V2 style boot path */
146e4c60fd4Smiod struct device;
147df39fa9dSjason struct bootpath {
148*fb1ca35cSkettenis 	int	node;
149df39fa9dSjason 	char	name[16];	/* name of this node */
150c5632f19Sjason 	long	val[3];		/* up to three optional values */
151df39fa9dSjason 	struct device *dev;	/* device that recognised this component */
152df39fa9dSjason };
153c4071fd1Smillert struct bootpath	*bootpath_store(int, struct bootpath *);
154df39fa9dSjason 
155df39fa9dSjason /* Parse a disk string into a dev_t, return device struct pointer */
156c4071fd1Smillert struct	device *parsedisk(char *, int, int, dev_t *);
157df39fa9dSjason 
158df39fa9dSjason /* Establish a mountroot_hook, for benefit of floppy drive, mostly. */
1594f9e30d0Smillert void	mountroot_hook_establish(void (*)(struct device *), struct device *);
160df39fa9dSjason 
161c4071fd1Smillert void	bootstrap(int);
162c4071fd1Smillert int	firstchild(int);
163c4071fd1Smillert int	nextsibling(int);
164c4071fd1Smillert void	callrom(void);
165c4071fd1Smillert struct device *getdevunit(char *, int);
166c4071fd1Smillert void	*findzs(int);
167c4071fd1Smillert int	romgetcursoraddr(int **, int **);
168c4071fd1Smillert int	findroot(void);
169c4071fd1Smillert int	findnode(int, const char *);
170c4071fd1Smillert int	node_has_property(int, const char *);
171c4071fd1Smillert void	device_register(struct device *, void *);
172