xref: /netbsd/sys/arch/newsmips/newsmips/mainbus.c (revision c4a72b64)
1 /*	$NetBSD: mainbus.c,v 1.6 2002/10/02 04:27:52 thorpej Exp $	*/
2 
3 /*
4  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  * DECstation port: Jonathan Stone
9  *
10  * Permission to use, copy, modify and distribute this software and
11  * its documentation is hereby granted, provided that both the copyright
12  * notice and this permission notice appear in all copies of the
13  * software, derivative works or modified versions, and any portions
14  * thereof, and that both notices appear in supporting documentation.
15  *
16  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19  *
20  * Carnegie Mellon requests users of this software to return to
21  *
22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
23  *  School of Computer Science
24  *  Carnegie Mellon University
25  *  Pittsburgh PA 15213-3890
26  *
27  * any improvements or extensions that they make and grant Carnegie the
28  * rights to redistribute these changes.
29  */
30 
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/device.h>
34 #include <sys/reboot.h>
35 
36 #include <machine/autoconf.h>
37 #include <machine/apbus.h>
38 
39 struct mainbus_softc {
40 	struct device sc_dev;
41 };
42 
43 /* Definition of the mainbus driver. */
44 static int	mbmatch __P((struct device *, struct cfdata *, void *));
45 static void	mbattach __P((struct device *, struct device *, void *));
46 static int	mbprint __P((void *, const char *));
47 
48 CFATTACH_DECL(mainbus, sizeof(struct mainbus_softc),
49     mbmatch, mbattach, NULL, NULL);
50 
51 /* There can be only one. */
52 static int mainbus_found;
53 
54 static int
55 mbmatch(parent, cf, aux)
56 	struct device *parent;
57 	struct cfdata *cf;
58 	void *aux;
59 {
60 	if (mainbus_found)
61 		return 0;
62 
63 	return 1;
64 }
65 
66 static void
67 mbattach(parent, self, aux)
68 	struct device *parent;
69 	struct device *self;
70 	void *aux;
71 {
72 	register struct device *mb = self;
73 	struct confargs nca;
74 
75 	mainbus_found = 1;
76 	printf("\n");
77 
78 	nca.ca_name = "cpu";
79 	nca.ca_slot = 0;
80 	nca.ca_offset = 0;
81 	nca.ca_addr = 0;
82 	config_found(mb, &nca, mbprint);
83 
84 	/* XXX */
85 	if (_sip != NULL) {
86 		nca.ca_name = "ap";
87 		config_found(self, &nca, NULL);
88 	} else {
89 		nca.ca_name = "hb";
90 		config_found(self, &nca, NULL);
91 	}
92 }
93 
94 static int
95 mbprint(aux, pnp)
96 	void *aux;
97 	const char *pnp;
98 {
99 
100 	if (pnp)
101 		return QUIET;
102 	return UNCONF;
103 }
104