| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: isa.c,v 1.138.76.3 2021/03/22 16:23:45 thorpej Exp $ */ | | 1 | /* $NetBSD: isa.c,v 1.138.76.4 2021/03/28 20:34:44 thorpej Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1998, 2001, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1998, 2001, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Charles M. Hannum; by Jason R. Thorpe of Wasabi Systems, Inc. | | 8 | * by Charles M. Hannum; by Jason R. Thorpe of Wasabi Systems, Inc. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: isa.c,v 1.138.76.3 2021/03/22 16:23:45 thorpej Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: isa.c,v 1.138.76.4 2021/03/28 20:34:44 thorpej Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/systm.h> | | 36 | #include <sys/systm.h> |
37 | #include <sys/kernel.h> | | 37 | #include <sys/kernel.h> |
38 | #include <sys/malloc.h> | | 38 | #include <sys/malloc.h> |
39 | #include <sys/device.h> | | 39 | #include <sys/device.h> |
40 | | | 40 | |
41 | #include <sys/intr.h> | | 41 | #include <sys/intr.h> |
42 | | | 42 | |
43 | #include <dev/isa/isareg.h> | | 43 | #include <dev/isa/isareg.h> |
44 | #include <dev/isa/isavar.h> | | 44 | #include <dev/isa/isavar.h> |
45 | #include <dev/isa/isadmareg.h> | | 45 | #include <dev/isa/isadmareg.h> |
46 | | | 46 | |
| @@ -76,29 +76,33 @@ int | | | @@ -76,29 +76,33 @@ int |
76 | isamatch(device_t parent, cfdata_t cf, void *aux) | | 76 | isamatch(device_t parent, cfdata_t cf, void *aux) |
77 | { | | 77 | { |
78 | /* XXX check other indicators */ | | 78 | /* XXX check other indicators */ |
79 | | | 79 | |
80 | return (1); | | 80 | return (1); |
81 | } | | 81 | } |
82 | | | 82 | |
83 | void | | 83 | void |
84 | isaattach(device_t parent, device_t self, void *aux) | | 84 | isaattach(device_t parent, device_t self, void *aux) |
85 | { | | 85 | { |
86 | struct isa_softc *sc = device_private(self); | | 86 | struct isa_softc *sc = device_private(self); |
87 | struct isabus_attach_args *iba = aux; | | 87 | struct isabus_attach_args *iba = aux; |
88 | static const int wildcard[ISACF_NLOCS] = { | | 88 | static const int wildcard[ISACF_NLOCS] = { |
89 | ISACF_PORT_DEFAULT, ISACF_SIZE_DEFAULT, | | 89 | [ISACF_PORT] = ISACF_PORT_DEFAULT, |
90 | ISACF_IOMEM_DEFAULT, ISACF_IOSIZ_DEFAULT, | | 90 | [ISACF_SIZE] = ISACF_SIZE_DEFAULT, |
91 | ISACF_IRQ_DEFAULT, ISACF_DRQ_DEFAULT, ISACF_DRQ2_DEFAULT | | 91 | [ISACF_IOMEM] = ISACF_IOMEM_DEFAULT, |
| | | 92 | [ISACF_IOSIZ] = ISACF_IOSIZ_DEFAULT, |
| | | 93 | [ISACF_IRQ] = ISACF_IRQ_DEFAULT, |
| | | 94 | [ISACF_DRQ] = ISACF_DRQ_DEFAULT, |
| | | 95 | [ISACF_DRQ2] = ISACF_DRQ2_DEFAULT, |
92 | }; | | 96 | }; |
93 | | | 97 | |
94 | TAILQ_INIT(&sc->sc_knowndevs); | | 98 | TAILQ_INIT(&sc->sc_knowndevs); |
95 | sc->sc_dynamicdevs = 0; | | 99 | sc->sc_dynamicdevs = 0; |
96 | | | 100 | |
97 | sc->sc_dev = self; | | 101 | sc->sc_dev = self; |
98 | | | 102 | |
99 | isa_attach_hook(parent, self, iba); | | 103 | isa_attach_hook(parent, self, iba); |
100 | aprint_naive("\n"); | | 104 | aprint_naive("\n"); |
101 | aprint_normal("\n"); | | 105 | aprint_normal("\n"); |
102 | | | 106 | |
103 | /* XXX Add code to fetch known-devices. */ | | 107 | /* XXX Add code to fetch known-devices. */ |
104 | | | 108 | |
| @@ -122,27 +126,27 @@ isaattach(device_t parent, device_t self | | | @@ -122,27 +126,27 @@ isaattach(device_t parent, device_t self |
122 | #endif | | 126 | #endif |
123 | | | 127 | |
124 | /* Attach all direct-config children. */ | | 128 | /* Attach all direct-config children. */ |
125 | isa_attach_knowndevs(sc); | | 129 | isa_attach_knowndevs(sc); |
126 | | | 130 | |
127 | /* | | 131 | /* |
128 | * If we don't support dynamic hello/goodbye of devices, | | 132 | * If we don't support dynamic hello/goodbye of devices, |
129 | * then free the knowndevs info now. | | 133 | * then free the knowndevs info now. |
130 | */ | | 134 | */ |
131 | if (sc->sc_dynamicdevs == 0) | | 135 | if (sc->sc_dynamicdevs == 0) |
132 | isa_free_knowndevs(sc); | | 136 | isa_free_knowndevs(sc); |
133 | | | 137 | |
134 | /* Attach all indirect-config children. */ | | 138 | /* Attach all indirect-config children. */ |
135 | isarescan(self, "isa", wildcard); | | 139 | isarescan(self, NULL, wildcard); |
136 | | | 140 | |
137 | if (!pmf_device_register(self, NULL, NULL)) | | 141 | if (!pmf_device_register(self, NULL, NULL)) |
138 | aprint_error_dev(self, "couldn't establish power handler\n"); | | 142 | aprint_error_dev(self, "couldn't establish power handler\n"); |
139 | } | | 143 | } |
140 | | | 144 | |
141 | int | | 145 | int |
142 | isadetach(device_t self, int flags) | | 146 | isadetach(device_t self, int flags) |
143 | { | | 147 | { |
144 | struct isa_softc *sc = device_private(self); | | 148 | struct isa_softc *sc = device_private(self); |
145 | int rc; | | 149 | int rc; |
146 | | | 150 | |
147 | if ((rc = config_detach_children(self, flags)) != 0) | | 151 | if ((rc = config_detach_children(self, flags)) != 0) |
148 | return rc; | | 152 | return rc; |
| @@ -178,27 +182,26 @@ isarescan(device_t self, const char *ifa | | | @@ -178,27 +182,26 @@ isarescan(device_t self, const char *ifa |
178 | /* | | 182 | /* |
179 | * XXX Bus independent code calling this function does not | | 183 | * XXX Bus independent code calling this function does not |
180 | * know the locator default values. It assumes "-1" for now. | | 184 | * know the locator default values. It assumes "-1" for now. |
181 | * (should be made available by "config" one day) | | 185 | * (should be made available by "config" one day) |
182 | * So fixup where the "-1" is not correct. | | 186 | * So fixup where the "-1" is not correct. |
183 | */ | | 187 | */ |
184 | if (locs[ISACF_SIZE] == -1) | | 188 | if (locs[ISACF_SIZE] == -1) |
185 | locs[ISACF_SIZE] = ISACF_SIZE_DEFAULT; | | 189 | locs[ISACF_SIZE] = ISACF_SIZE_DEFAULT; |
186 | if (locs[ISACF_IOSIZ] == -1) | | 190 | if (locs[ISACF_IOSIZ] == -1) |
187 | locs[ISACF_IOSIZ] = ISACF_IOSIZ_DEFAULT; | | 191 | locs[ISACF_IOSIZ] = ISACF_IOSIZ_DEFAULT; |
188 | | | 192 | |
189 | config_search(self, NULL, | | 193 | config_search(self, NULL, |
190 | CFARG_SUBMATCH, isasearch, | | 194 | CFARG_SUBMATCH, isasearch, |
191 | CFARG_IATTR, ifattr, | | | |
192 | CFARG_LOCATORS, locs, | | 195 | CFARG_LOCATORS, locs, |
193 | CFARG_EOL); | | 196 | CFARG_EOL); |
194 | return (0); | | 197 | return (0); |
195 | } | | 198 | } |
196 | | | 199 | |
197 | void | | 200 | void |
198 | isachilddetached(device_t self, device_t child) | | 201 | isachilddetached(device_t self, device_t child) |
199 | { | | 202 | { |
200 | struct isa_knowndev *ik; | | 203 | struct isa_knowndev *ik; |
201 | struct isa_softc *sc = device_private(self); | | 204 | struct isa_softc *sc = device_private(self); |
202 | | | 205 | |
203 | TAILQ_FOREACH(ik, &sc->sc_knowndevs, ik_list) { | | 206 | TAILQ_FOREACH(ik, &sc->sc_knowndevs, ik_list) { |
204 | if (ik->ik_claimed == child) | | 207 | if (ik->ik_claimed == child) |