| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: mainbus.c,v 1.25 2011/12/17 20:20:38 phx Exp $ */ | | 1 | /* $NetBSD: mainbus.c,v 1.26 2011/12/18 14:28:59 phx Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. | | 4 | * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * 3. All advertising materials mentioning features or use of this software | | 14 | * 3. All advertising materials mentioning features or use of this software |
| @@ -21,87 +21,83 @@ | | | @@ -21,87 +21,83 @@ |
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.25 2011/12/17 20:20:38 phx Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.26 2011/12/18 14:28:59 phx Exp $"); |
35 | | | 35 | |
36 | #include "opt_pci.h" | | 36 | #include "opt_pci.h" |
37 | #include "pci.h" | | 37 | #include "pci.h" |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/extent.h> | | 40 | #include <sys/extent.h> |
41 | #include <sys/device.h> | | 41 | #include <sys/device.h> |
42 | #include <sys/malloc.h> | | 42 | #include <sys/malloc.h> |
43 | #include <sys/systm.h> | | 43 | #include <sys/systm.h> |
44 | | | 44 | |
45 | #include <machine/autoconf.h> | | 45 | #include <machine/autoconf.h> |
46 | #include <machine/isa_machdep.h> | | 46 | #include <machine/isa_machdep.h> |
47 | | | 47 | |
48 | #include <dev/pci/pcivar.h> | | 48 | #include <dev/pci/pcivar.h> |
49 | #include <dev/pci/pciconf.h> | | 49 | #include <dev/pci/pciconf.h> |
50 | | | 50 | |
51 | /* XXX go away! */ | | | |
52 | struct conf_args { | | | |
53 | const char *ca_name; | | | |
54 | }; | | | |
55 | | | | |
56 | int mainbus_match(device_t, cfdata_t, void *); | | 51 | int mainbus_match(device_t, cfdata_t, void *); |
57 | void mainbus_attach(device_t, device_t, void *); | | 52 | void mainbus_attach(device_t, device_t, void *); |
58 | int mainbus_print(void *, const char *); | | 53 | int mainbus_print(void *, const char *); |
59 | | | 54 | |
60 | CFATTACH_DECL_NEW(mainbus, 0, | | 55 | CFATTACH_DECL_NEW(mainbus, 0, |
61 | mainbus_match, mainbus_attach, NULL, NULL); | | 56 | mainbus_match, mainbus_attach, NULL, NULL); |
62 | | | 57 | |
63 | struct powerpc_isa_chipset genppc_ict; | | 58 | struct powerpc_isa_chipset genppc_ict; |
64 | | | 59 | |
65 | /* | | 60 | /* |
66 | * Probe for the mainbus; always succeeds. | | 61 | * Probe for the mainbus; always succeeds. |
67 | */ | | 62 | */ |
68 | int | | 63 | int |
69 | mainbus_match(device_t parent, cfdata_t match, void *aux) | | 64 | mainbus_match(device_t parent, cfdata_t match, void *aux) |
70 | { | | 65 | { |
71 | | | 66 | |
72 | return 1; | | 67 | return 1; |
73 | } | | 68 | } |
74 | | | 69 | |
75 | /* | | 70 | /* |
76 | * Attach the mainbus. | | 71 | * Attach the mainbus. |
77 | */ | | 72 | */ |
78 | void | | 73 | void |
79 | mainbus_attach(device_t parent, device_t self, void *aux) | | 74 | mainbus_attach(device_t parent, device_t self, void *aux) |
80 | { | | 75 | { |
81 | struct conf_args ca; | | | |
82 | struct mainbus_attach_args mba; | | 76 | struct mainbus_attach_args mba; |
83 | struct pcibus_attach_args pba; | | 77 | struct pcibus_attach_args pba; |
84 | #if defined(PCI_NETBSD_CONFIGURE) | | 78 | #if defined(PCI_NETBSD_CONFIGURE) |
85 | struct extent *ioext, *memext; | | 79 | struct extent *ioext, *memext; |
86 | #endif | | 80 | #endif |
87 | | | 81 | |
88 | aprint_naive("\n"); | | 82 | aprint_naive("\n"); |
89 | aprint_normal("\n"); | | 83 | aprint_normal("\n"); |
90 | | | 84 | |
91 | ca.ca_name = "cpu"; | | 85 | mba.ma_name = "cpu"; |
92 | config_found_ia(self, "mainbus", &ca, mainbus_print); | | 86 | config_found_ia(self, "mainbus", &mba, mainbus_print); |
93 | ca.ca_name = "eumb"; | | 87 | |
94 | config_found_ia(self, "mainbus", &ca, mainbus_print); | | 88 | mba.ma_name = "eumb"; |
| | | 89 | mba.ma_bst = &sandpoint_eumb_space_tag; |
| | | 90 | config_found_ia(self, "mainbus", &mba, mainbus_print); |
95 | | | 91 | |
96 | mba.ma_name = "cfi"; | | 92 | mba.ma_name = "cfi"; |
97 | mba.ma_bst = &sandpoint_flash_space_tag; | | 93 | mba.ma_bst = &sandpoint_flash_space_tag; |
98 | mba.ma_addr = 0xffe00000; /* smallest flash is 2 MiB */ | | 94 | mba.ma_addr = 0xffe00000; /* smallest flash is 2 MiB */ |
99 | config_found_ia(self, "mainbus", &mba, mainbus_print); | | 95 | config_found_ia(self, "mainbus", &mba, mainbus_print); |
100 | | | 96 | |
101 | /* | | 97 | /* |
102 | * XXX Note also that the presence of a PCI bus should | | 98 | * XXX Note also that the presence of a PCI bus should |
103 | * XXX _always_ be checked, and if present the bus should be | | 99 | * XXX _always_ be checked, and if present the bus should be |
104 | * XXX 'found'. However, because of the structure of the code, | | 100 | * XXX 'found'. However, because of the structure of the code, |
105 | * XXX that's not currently possible. | | 101 | * XXX that's not currently possible. |
106 | */ | | 102 | */ |
107 | #if NPCI > 0 | | 103 | #if NPCI > 0 |
| @@ -130,39 +126,39 @@ mainbus_attach(device_t parent, device_t | | | @@ -130,39 +126,39 @@ mainbus_attach(device_t parent, device_t |
130 | #endif | | 126 | #endif |
131 | } | | 127 | } |
132 | | | 128 | |
133 | static int cpu_match(device_t, cfdata_t, void *); | | 129 | static int cpu_match(device_t, cfdata_t, void *); |
134 | static void cpu_attach(device_t, device_t, void *); | | 130 | static void cpu_attach(device_t, device_t, void *); |
135 | | | 131 | |
136 | CFATTACH_DECL_NEW(cpu, 0, cpu_match, cpu_attach, NULL, NULL); | | 132 | CFATTACH_DECL_NEW(cpu, 0, cpu_match, cpu_attach, NULL, NULL); |
137 | | | 133 | |
138 | extern struct cfdriver cpu_cd; | | 134 | extern struct cfdriver cpu_cd; |
139 | | | 135 | |
140 | int | | 136 | int |
141 | cpu_match(device_t parent, cfdata_t cf, void *aux) | | 137 | cpu_match(device_t parent, cfdata_t cf, void *aux) |
142 | { | | 138 | { |
143 | struct conf_args *ca = aux; | | 139 | struct mainbus_attach_args *mba = aux; |
144 | | | 140 | |
145 | if (strcmp(ca->ca_name, cpu_cd.cd_name) != 0) | | 141 | if (strcmp(mba->ma_name, cpu_cd.cd_name) != 0) |
146 | return 0; | | 142 | return 0; |
147 | if (cpu_info[0].ci_dev != NULL) | | 143 | if (cpu_info[0].ci_dev != NULL) |
148 | return 0; | | 144 | return 0; |
149 | | | 145 | |
150 | return 1; | | 146 | return 1; |
151 | } | | 147 | } |
152 | | | 148 | |
153 | void | | 149 | void |
154 | cpu_attach(device_t parent, device_t self, void *aux) | | 150 | cpu_attach(device_t parent, device_t self, void *aux) |
155 | { | | 151 | { |
156 | | | 152 | |
157 | (void) cpu_attach_common(self, 0); | | 153 | (void)cpu_attach_common(self, 0); |
158 | } | | 154 | } |
159 | | | 155 | |
160 | int | | 156 | int |
161 | mainbus_print(void *aux, const char *pnp) | | 157 | mainbus_print(void *aux, const char *pnp) |
162 | { | | 158 | { |
163 | struct conf_args *ca = aux; | | 159 | struct mainbus_attach_args *mba = aux; |
164 | | | 160 | |
165 | if (pnp) | | 161 | if (pnp) |
166 | aprint_normal("%s at %s", ca->ca_name, pnp); | | 162 | aprint_normal("%s at %s", mba->ma_name, pnp); |
167 | return (UNCONF); | | 163 | return UNCONF; |
168 | } | | 164 | } |