xref: /openbsd/sys/arch/alpha/alpha/mainbus.c (revision 6aef9a4e)
1 /* $OpenBSD: mainbus.c,v 1.15 2022/03/13 08:04:13 mpi Exp $ */
2 /* $NetBSD: mainbus.c,v 1.27 1998/06/24 01:10:35 ross Exp $ */
3 
4 /*
5  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
6  * All rights reserved.
7  *
8  * Author: Chris G. Demetriou
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 #include <sys/conf.h>
36 
37 #include <machine/autoconf.h>
38 #include <machine/rpb.h>
39 #include <machine/cpuconf.h>
40 
41 /* Definition of the mainbus driver. */
42 static int	mbmatch(struct device *, void *, void *);
43 static void	mbattach(struct device *, struct device *, void *);
44 static int	mbprint(void *, const char *);
45 
46 const struct cfattach mainbus_ca = {
47 	sizeof(struct device), mbmatch, mbattach
48 };
49 
50 struct cfdriver mainbus_cd = {
51 	NULL, "mainbus", DV_DULL
52 };
53 
54 /* There can be only one. */
55 int	mainbus_found;
56 
57 static int
mbmatch(parent,cf,aux)58 mbmatch(parent, cf, aux)
59 	struct device *parent;
60 	void *cf;
61 	void *aux;
62 {
63 
64 	if (mainbus_found)
65 		return (0);
66 
67 	return (1);
68 }
69 
70 static void
mbattach(parent,self,aux)71 mbattach(parent, self, aux)
72 	struct device *parent;
73 	struct device *self;
74 	void *aux;
75 {
76 	struct mainbus_attach_args ma;
77 	struct pcs *pcsp;
78 	int i;
79 
80 	mainbus_found = 1;
81 
82 	printf("\n");
83 
84 	/*
85 	 * Try to find and attach all of the CPUs in the machine.
86 	 */
87 	for (i = 0; i < hwrpb->rpb_pcs_cnt; i++) {
88 		pcsp = LOCATE_PCS(hwrpb, i);
89 		if ((pcsp->pcs_flags & PCS_PP) == 0)
90 			continue;
91 
92 		ma.ma_name = "cpu";
93 		ma.ma_slot = i;
94 		config_found(self, &ma, mbprint);
95 	}
96 
97 	if (platform.iobus != NULL) {
98 		ma.ma_name = platform.iobus;
99 		ma.ma_slot = 0;			/* meaningless */
100 		config_found(self, &ma, mbprint);
101 	}
102 }
103 
104 static int
mbprint(aux,pnp)105 mbprint(aux, pnp)
106 	void *aux;
107 	const char *pnp;
108 {
109 	struct mainbus_attach_args *ma = aux;
110 
111 	if (pnp)
112 		printf("%s at %s", ma->ma_name, pnp);
113 
114 	return (UNCONF);
115 }
116