Annotation of sys/arch/mips64/mips64/mainbus.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: mainbus.c,v 1.4 2005/01/31 21:35:50 grange Exp $ */
2:
3: /*
4: * Copyright (c) 2001-2003 Opsycon AB (www.opsycon.se / www.opsycon.com)
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
9: * 1. Redistributions of source code must retain the above copyright
10: * notice, this list of conditions and the following disclaimer.
11: * 2. Redistributions in binary form must reproduce the above copyright
12: * notice, this list of conditions and the following disclaimer in the
13: * documentation and/or other materials provided with the distribution.
14: *
15: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16: * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25: * SUCH DAMAGE.
26: *
27: */
28:
29: #include <sys/param.h>
30: #include <sys/systm.h>
31: #include <sys/device.h>
32: #include <sys/reboot.h>
33:
34: #include <mips64/archtype.h>
35: #include <machine/autoconf.h>
36:
37: struct mainbus_softc {
38: struct device sc_dv;
39: struct abus sc_bus;
40: };
41:
42: /* Definition of the mainbus driver. */
43: static int mbmatch(struct device *, void *, void *);
44: static void mbattach(struct device *, struct device *, void *);
45: static int mbprint(void *, const char *);
46:
47: struct cfattach mainbus_ca = {
48: sizeof(struct mainbus_softc), mbmatch, mbattach
49: };
50: struct cfdriver mainbus_cd = {
51: NULL, "mainbus", DV_DULL, NULL, 0
52: };
53:
54: void *mb_intr_establish(void *, u_long, int, int, int (*)(void *),
55: void *, char *);
56: void mb_intr_disestablish(void *, void *);
57: caddr_t mb_cvtaddr(struct confargs *);
58: int mb_matchname(struct confargs *, char *);
59:
60: static int
61: mbmatch(parent, cfdata, aux)
62: struct device *parent;
63: void *cfdata;
64: void *aux;
65: {
66: struct cfdata *cf = cfdata;
67:
68: if (cf->cf_unit > 0)
69: return(0);
70: return(1);
71: }
72:
73: static void
74: mbattach(parent, self, aux)
75: struct device *parent;
76: struct device *self;
77: void *aux;
78: {
79: struct mainbus_softc *sc = (struct mainbus_softc *)self;
80: struct confargs nca;
81:
82: printf("\n");
83:
84: sc->sc_bus.ab_dv = (struct device *)sc;
85: sc->sc_bus.ab_type = BUS_MAIN;
86: sc->sc_bus.ab_intr_establish = mb_intr_establish;
87: sc->sc_bus.ab_intr_disestablish = mb_intr_disestablish;
88: sc->sc_bus.ab_cvtaddr = mb_cvtaddr;
89: sc->sc_bus.ab_matchname = mb_matchname;
90:
91: /*
92: * Try to find and attach all of the CPUs in the machine.
93: * ( Right now only one CPU so code is simple )
94: */
95:
96: nca.ca_name = "cpu";
97: nca.ca_bus = &sc->sc_bus;
98: config_found(self, &nca, mbprint);
99:
100: /*
101: * Attach the clocks.
102: */
103: nca.ca_name = "clock";
104: nca.ca_bus = &sc->sc_bus;
105: config_found(self, &nca, mbprint);
106:
107: if (sys_config.system_type == SGI_INDY) {
108: nca.ca_name = "indy";
109: nca.ca_bus = &sc->sc_bus;
110: config_found(self, &nca, mbprint);
111: }
112: else if (sys_config.system_type == SGI_O2) {
113: nca.ca_name = "macebus";
114: nca.ca_bus = &sc->sc_bus;
115: config_found(self, &nca, mbprint);
116:
117: nca.ca_name = "macepcibr";
118: nca.ca_bus = &sc->sc_bus;
119: nca.ca_num = 0;
120: config_found(self, &nca, mbprint);
121: }
122: else if (sys_config.system_type == ALGOR_P4032 ||
123: sys_config.system_type == ALGOR_P5064 ||
124: sys_config.system_type == MOMENTUM_CP7000 ||
125: sys_config.system_type == MOMENTUM_CP7000G ||
126: sys_config.system_type == MOMENTUM_JAGUAR ||
127: sys_config.system_type == GALILEO_EV64240) {
128:
129: nca.ca_name = "localbus";
130: nca.ca_bus = &sc->sc_bus;
131: config_found(self, &nca, mbprint);
132:
133: nca.ca_name = "pcibr";
134: nca.ca_bus = &sc->sc_bus;
135: nca.ca_num = 0;
136: config_found(self, &nca, mbprint);
137:
138: nca.ca_name = "pcibr";
139: nca.ca_bus = &sc->sc_bus;
140: nca.ca_num = 1;
141: config_found(self, &nca, mbprint);
142: }
143: }
144:
145: static int
146: mbprint(aux, pnp)
147: void *aux;
148: const char *pnp;
149: {
150: if (pnp)
151: return (QUIET);
152: return (UNCONF);
153: }
154:
155: void *
156: mb_intr_establish(icp, irq, type, level, ih_fun, ih_arg, ih_what)
157: void *icp;
158: u_long irq; /* XXX pci_intr_handle_t compatible XXX */
159: int type;
160: int level;
161: int (*ih_fun)(void *);
162: void *ih_arg;
163: char *ih_what;
164: {
165: panic("can never mb_intr_establish");
166: }
167:
168: void
169: mb_intr_disestablish(void *p1, void *p2)
170: {
171: panic("can never mb_intr_disestablish");
172: }
173:
174: caddr_t
175: mb_cvtaddr(ca)
176: struct confargs *ca;
177: {
178: return (NULL);
179: }
180:
181: int
182: mb_matchname(ca, name)
183: struct confargs *ca;
184: char *name;
185: {
186: return (strcmp(name, ca->ca_name) == 0);
187: }
CVSweb