| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: autoconf.c,v 1.49 2011/07/26 14:59:03 njoly Exp $ */ | | 1 | /* $NetBSD: autoconf.c,v 1.50 2011/07/27 15:08:42 njoly Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1992, 1993 | | 4 | * Copyright (c) 1992, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This software was developed by the Computer Systems Engineering group | | 7 | * This software was developed by the Computer Systems Engineering group |
8 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | | 8 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and |
9 | * contributed to Berkeley. | | 9 | * contributed to Berkeley. |
10 | * | | 10 | * |
11 | * All advertising materials mentioning features or use of this software | | 11 | * All advertising materials mentioning features or use of this software |
12 | * must display the following acknowledgement: | | 12 | * must display the following acknowledgement: |
13 | * This product includes software developed by the University of | | 13 | * This product includes software developed by the University of |
14 | * California, Lawrence Berkeley Laboratory. | | 14 | * California, Lawrence Berkeley Laboratory. |
| @@ -32,48 +32,48 @@ | | | @@ -32,48 +32,48 @@ |
32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
38 | * SUCH DAMAGE. | | 38 | * SUCH DAMAGE. |
39 | * | | 39 | * |
40 | * @(#)autoconf.c 8.4 (Berkeley) 10/1/93 | | 40 | * @(#)autoconf.c 8.4 (Berkeley) 10/1/93 |
41 | */ | | 41 | */ |
42 | | | 42 | |
43 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | | 43 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ |
44 | | | 44 | |
45 | __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.49 2011/07/26 14:59:03 njoly Exp $"); | | 45 | __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.50 2011/07/27 15:08:42 njoly Exp $"); |
46 | | | 46 | |
47 | #include <sys/param.h> | | 47 | #include <sys/param.h> |
48 | #include <sys/systm.h> | | 48 | #include <sys/systm.h> |
49 | #include <sys/buf.h> | | 49 | #include <sys/buf.h> |
50 | #include <sys/disklabel.h> | | 50 | #include <sys/disklabel.h> |
51 | #include <sys/reboot.h> | | 51 | #include <sys/reboot.h> |
52 | #include <sys/device.h> | | 52 | #include <sys/device.h> |
53 | #include <sys/conf.h> | | 53 | #include <sys/conf.h> |
54 | #include <dev/cons.h> | | 54 | #include <dev/cons.h> |
55 | | | 55 | |
56 | #include <machine/autoconf.h> | | 56 | #include <machine/autoconf.h> |
57 | #include <machine/alpha.h> | | 57 | #include <machine/alpha.h> |
58 | #include <machine/cpu.h> | | 58 | #include <machine/cpu.h> |
59 | #include <machine/prom.h> | | 59 | #include <machine/prom.h> |
60 | #include <machine/cpuconf.h> | | 60 | #include <machine/cpuconf.h> |
61 | #include <machine/intr.h> | | 61 | #include <machine/intr.h> |
62 | | | 62 | |
63 | struct bootdev_data *bootdev_data; | | 63 | struct bootdev_data *bootdev_data; |
64 | | | 64 | |
65 | void parse_prom_bootdev(void); | | 65 | void parse_prom_bootdev(void); |
66 | static int atoi(const char *); | | 66 | static inline int atoi(const char *); |
67 | | | 67 | |
68 | /* | | 68 | /* |
69 | * cpu_configure: | | 69 | * cpu_configure: |
70 | * called at boot time, configure all devices on system | | 70 | * called at boot time, configure all devices on system |
71 | */ | | 71 | */ |
72 | void | | 72 | void |
73 | cpu_configure(void) | | 73 | cpu_configure(void) |
74 | { | | 74 | { |
75 | | | 75 | |
76 | parse_prom_bootdev(); | | 76 | parse_prom_bootdev(); |
77 | | | 77 | |
78 | /* | | 78 | /* |
79 | * Disable interrupts during autoconfiguration. splhigh() won't | | 79 | * Disable interrupts during autoconfiguration. splhigh() won't |
| @@ -153,48 +153,30 @@ parse_prom_bootdev(void) | | | @@ -153,48 +153,30 @@ parse_prom_bootdev(void) |
153 | bd.boot_dev_type = atoi(boot_fields[6]); | | 153 | bd.boot_dev_type = atoi(boot_fields[6]); |
154 | bd.ctrl_dev_type = boot_fields[7]; | | 154 | bd.ctrl_dev_type = boot_fields[7]; |
155 | | | 155 | |
156 | #if 0 | | 156 | #if 0 |
157 | printf("parsed: proto = %s, bus = %d, slot = %d, channel = %d,\n", | | 157 | printf("parsed: proto = %s, bus = %d, slot = %d, channel = %d,\n", |
158 | bd.protocol, bd.bus, bd.slot, bd.channel); | | 158 | bd.protocol, bd.bus, bd.slot, bd.channel); |
159 | printf("\tremote = %s, unit = %d, dev_type = %d, ctrl_type = %s\n", | | 159 | printf("\tremote = %s, unit = %d, dev_type = %d, ctrl_type = %s\n", |
160 | bd.remote_address, bd.unit, bd.boot_dev_type, bd.ctrl_dev_type); | | 160 | bd.remote_address, bd.unit, bd.boot_dev_type, bd.ctrl_dev_type); |
161 | #endif | | 161 | #endif |
162 | | | 162 | |
163 | bootdev_data = &bd; | | 163 | bootdev_data = &bd; |
164 | } | | 164 | } |
165 | | | 165 | |
166 | static int | | 166 | static inline int |
167 | atoi(const char *s) | | 167 | atoi(const char *s) |
168 | { | | 168 | { |
169 | int n, neg; | | 169 | return (int)strtoll(s, NULL, 10); |
170 | | | | |
171 | n = 0; | | | |
172 | neg = 0; | | | |
173 | | | | |
174 | while (*s == '-') { | | | |
175 | s++; | | | |
176 | neg = !neg; | | | |
177 | } | | | |
178 | | | | |
179 | while (*s != '\0') { | | | |
180 | if (*s < '0' && *s > '9') | | | |
181 | break; | | | |
182 | | | | |
183 | n = (10 * n) + (*s - '0'); | | | |
184 | s++; | | | |
185 | } | | | |
186 | | | | |
187 | return (neg ? -n : n); | | | |
188 | } | | 170 | } |
189 | | | 171 | |
190 | void | | 172 | void |
191 | device_register(device_t dev, void *aux) | | 173 | device_register(device_t dev, void *aux) |
192 | { | | 174 | { |
193 | if (bootdev_data == NULL) { | | 175 | if (bootdev_data == NULL) { |
194 | /* | | 176 | /* |
195 | * There is no hope. | | 177 | * There is no hope. |
196 | */ | | 178 | */ |
197 | return; | | 179 | return; |
198 | } | | 180 | } |
199 | if (platform.device_register) | | 181 | if (platform.device_register) |
200 | (*platform.device_register)(dev, aux); | | 182 | (*platform.device_register)(dev, aux); |