xref: /netbsd/sys/arch/news68k/news68k/mainbus.c (revision c4a72b64)
1 /*	$NetBSD: mainbus.c,v 1.6 2002/10/02 04:40:09 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 
35 #include <machine/autoconf.h>
36 #include <machine/cpu.h>
37 
38 #include <news68k/news68k/machid.h>
39 
40 struct mainbus_softc {
41 	struct device sc_dev;
42 };
43 
44 /* Definition of the mainbus driver. */
45 static int	mainbus_match __P((struct device *, struct cfdata *, void *));
46 static void	mainbus_attach __P((struct device *, struct device *, void *));
47 static int	mainbus_search __P((struct device *, struct cfdata *, void *));
48 static int	mainbus_print __P((void *, const char *));
49 
50 CFATTACH_DECL(mainbus, sizeof(struct mainbus_softc),
51     mainbus_match, mainbus_attach, NULL, NULL);
52 
53 static int mainbus_found;
54 
55 static int
56 mainbus_match(parent, cfdata, aux)
57 	struct device *parent;
58 	struct cfdata *cfdata;
59 	void *aux;
60 {
61 
62 	if (mainbus_found)
63 		return 0;
64 
65 	return 1;
66 }
67 
68 static void
69 mainbus_attach(parent, self, aux)
70 	struct device *parent;
71 	struct device *self;
72 	void *aux;
73 {
74 	struct mainbus_attach_args ma;
75 
76 	mainbus_found = 1;
77 	printf("\n");
78 
79 	config_search(mainbus_search, self, &ma);
80 }
81 
82 static int
83 mainbus_search(parent, cf, aux)
84 	struct device *parent;
85 	struct cfdata *cf;
86 	void *aux;
87 {
88 	struct mainbus_attach_args *ma = aux;
89 
90 	ma->ma_name = cf->cf_name;
91 	ma->ma_systype = cf->cf_systype;
92 
93 	if (config_match(parent, cf, ma) > 0)
94 		config_attach(parent, cf, ma, mainbus_print);
95 
96 	return 0;
97 }
98 
99 static int
100 mainbus_print(aux, cp)
101 	void *aux;
102 	const char *cp;
103 {
104 	struct mainbus_attach_args *ma = aux;
105 
106 	if (cp)
107 		printf("%s at %s", ma->ma_name, cp);
108 
109 	return (UNCONF);
110 }
111