| @@ -1,1681 +1,1681 @@ | | | @@ -1,1681 +1,1681 @@ |
1 | /* $NetBSD: autoconf.c,v 1.219 2020/06/12 03:32:30 thorpej Exp $ */ | | 1 | /* $NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1996 | | 4 | * Copyright (c) 1996 |
5 | * The President and Fellows of Harvard College. All rights reserved. | | 5 | * The President and Fellows of Harvard College. All rights reserved. |
6 | * Copyright (c) 1992, 1993 | | 6 | * Copyright (c) 1992, 1993 |
7 | * The Regents of the University of California. All rights reserved. | | 7 | * The Regents of the University of California. All rights reserved. |
8 | * | | 8 | * |
9 | * This software was developed by the Computer Systems Engineering group | | 9 | * This software was developed by the Computer Systems Engineering group |
10 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | | 10 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and |
11 | * contributed to Berkeley. | | 11 | * contributed to Berkeley. |
12 | * | | 12 | * |
13 | * All advertising materials mentioning features or use of this software | | 13 | * All advertising materials mentioning features or use of this software |
14 | * must display the following acknowledgement: | | 14 | * must display the following acknowledgement: |
15 | * This product includes software developed by Harvard University. | | 15 | * This product includes software developed by Harvard University. |
16 | * This product includes software developed by the University of | | 16 | * This product includes software developed by the University of |
17 | * California, Lawrence Berkeley Laboratory. | | 17 | * California, Lawrence Berkeley Laboratory. |
18 | * | | 18 | * |
19 | * Redistribution and use in source and binary forms, with or without | | 19 | * Redistribution and use in source and binary forms, with or without |
20 | * modification, are permitted provided that the following conditions | | 20 | * modification, are permitted provided that the following conditions |
21 | * are met: | | 21 | * are met: |
22 | * 1. Redistributions of source code must retain the above copyright | | 22 | * 1. Redistributions of source code must retain the above copyright |
23 | * notice, this list of conditions and the following disclaimer. | | 23 | * notice, this list of conditions and the following disclaimer. |
24 | * 2. Redistributions in binary form must reproduce the above copyright | | 24 | * 2. Redistributions in binary form must reproduce the above copyright |
25 | * notice, this list of conditions and the following disclaimer in the | | 25 | * notice, this list of conditions and the following disclaimer in the |
26 | * documentation and/or other materials provided with the distribution. | | 26 | * documentation and/or other materials provided with the distribution. |
27 | * 3. All advertising materials mentioning features or use of this software | | 27 | * 3. All advertising materials mentioning features or use of this software |
28 | * must display the following acknowledgement: | | 28 | * must display the following acknowledgement: |
29 | * This product includes software developed by the University of | | 29 | * This product includes software developed by the University of |
30 | * California, Berkeley and its contributors. | | 30 | * California, Berkeley and its contributors. |
31 | * 4. Neither the name of the University nor the names of its contributors | | 31 | * 4. Neither the name of the University nor the names of its contributors |
32 | * may be used to endorse or promote products derived from this software | | 32 | * may be used to endorse or promote products derived from this software |
33 | * without specific prior written permission. | | 33 | * without specific prior written permission. |
34 | * | | 34 | * |
35 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 35 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
36 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 36 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
38 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 38 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
39 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 39 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
40 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 40 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
41 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 41 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
42 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 42 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
43 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 43 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
44 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 44 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
45 | * SUCH DAMAGE. | | 45 | * SUCH DAMAGE. |
46 | * | | 46 | * |
47 | * @(#)autoconf.c 8.4 (Berkeley) 10/1/93 | | 47 | * @(#)autoconf.c 8.4 (Berkeley) 10/1/93 |
48 | */ | | 48 | */ |
49 | | | 49 | |
50 | #include <sys/cdefs.h> | | 50 | #include <sys/cdefs.h> |
51 | __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.219 2020/06/12 03:32:30 thorpej Exp $"); | | 51 | __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $"); |
52 | | | 52 | |
53 | #include "opt_ddb.h" | | 53 | #include "opt_ddb.h" |
54 | #include "opt_kgdb.h" | | 54 | #include "opt_kgdb.h" |
55 | #include "opt_modular.h" | | 55 | #include "opt_modular.h" |
56 | #include "opt_multiprocessor.h" | | 56 | #include "opt_multiprocessor.h" |
57 | | | 57 | |
58 | #include <sys/param.h> | | 58 | #include <sys/param.h> |
59 | #include <sys/kernel.h> | | 59 | #include <sys/kernel.h> |
60 | #include <sys/systm.h> | | 60 | #include <sys/systm.h> |
61 | #include <sys/buf.h> | | 61 | #include <sys/buf.h> |
62 | #include <sys/disklabel.h> | | 62 | #include <sys/disklabel.h> |
63 | #include <sys/device.h> | | 63 | #include <sys/device.h> |
64 | #include <sys/disk.h> | | 64 | #include <sys/disk.h> |
65 | #include <sys/conf.h> | | 65 | #include <sys/conf.h> |
66 | #include <sys/reboot.h> | | 66 | #include <sys/reboot.h> |
67 | #include <sys/socket.h> | | 67 | #include <sys/socket.h> |
68 | #include <sys/malloc.h> | | 68 | #include <sys/malloc.h> |
69 | #include <sys/vnode.h> | | 69 | #include <sys/vnode.h> |
70 | #include <sys/fcntl.h> | | 70 | #include <sys/fcntl.h> |
71 | #include <sys/queue.h> | | 71 | #include <sys/queue.h> |
72 | #include <sys/msgbuf.h> | | 72 | #include <sys/msgbuf.h> |
73 | #include <sys/boot_flag.h> | | 73 | #include <sys/boot_flag.h> |
74 | #include <sys/ksyms.h> | | 74 | #include <sys/ksyms.h> |
75 | #include <sys/kauth.h> | | 75 | #include <sys/kauth.h> |
76 | #include <sys/userconf.h> | | 76 | #include <sys/userconf.h> |
77 | #include <prop/proplib.h> | | 77 | #include <prop/proplib.h> |
78 | | | 78 | |
79 | #include <net/if.h> | | 79 | #include <net/if.h> |
80 | #include <net/if_ether.h> | | 80 | #include <net/if_ether.h> |
81 | | | 81 | |
82 | #include <dev/cons.h> | | 82 | #include <dev/cons.h> |
83 | #include <sparc64/dev/cons.h> | | 83 | #include <sparc64/dev/cons.h> |
84 | | | 84 | |
85 | #include <uvm/uvm_extern.h> | | 85 | #include <uvm/uvm_extern.h> |
86 | | | 86 | |
87 | #include <sys/bus.h> | | 87 | #include <sys/bus.h> |
88 | #include <machine/autoconf.h> | | 88 | #include <machine/autoconf.h> |
89 | #include <machine/openfirm.h> | | 89 | #include <machine/openfirm.h> |
90 | #include <machine/sparc64.h> | | 90 | #include <machine/sparc64.h> |
91 | #include <machine/cpu.h> | | 91 | #include <machine/cpu.h> |
92 | #include <machine/pmap.h> | | 92 | #include <machine/pmap.h> |
93 | #include <machine/bootinfo.h> | | 93 | #include <machine/bootinfo.h> |
94 | #include <sparc64/sparc64/cache.h> | | 94 | #include <sparc64/sparc64/cache.h> |
95 | #include <sparc64/sparc64/timerreg.h> | | 95 | #include <sparc64/sparc64/timerreg.h> |
96 | #include <sparc64/dev/cbusvar.h> | | 96 | #include <sparc64/dev/cbusvar.h> |
97 | | | 97 | |
98 | #include <dev/ata/atavar.h> | | 98 | #include <dev/ata/atavar.h> |
99 | #include <dev/pci/pcivar.h> | | 99 | #include <dev/pci/pcivar.h> |
100 | #include <dev/ebus/ebusvar.h> | | 100 | #include <dev/ebus/ebusvar.h> |
101 | #include <dev/sbus/sbusvar.h> | | 101 | #include <dev/sbus/sbusvar.h> |
102 | #include <dev/i2c/i2cvar.h> | | 102 | #include <dev/i2c/i2cvar.h> |
103 | | | 103 | |
104 | #ifdef DDB | | 104 | #ifdef DDB |
105 | #include <machine/db_machdep.h> | | 105 | #include <machine/db_machdep.h> |
106 | #include <ddb/db_sym.h> | | 106 | #include <ddb/db_sym.h> |
107 | #include <ddb/db_extern.h> | | 107 | #include <ddb/db_extern.h> |
108 | #endif | | 108 | #endif |
109 | | | 109 | |
110 | #ifdef RASTERCONSOLE | | 110 | #ifdef RASTERCONSOLE |
111 | #error options RASTERCONSOLE is obsolete for sparc64 - remove it from your config file | | 111 | #error options RASTERCONSOLE is obsolete for sparc64 - remove it from your config file |
112 | #endif | | 112 | #endif |
113 | | | 113 | |
114 | #include <dev/wsfb/genfbvar.h> | | 114 | #include <dev/wsfb/genfbvar.h> |
115 | | | 115 | |
116 | #include "ksyms.h" | | 116 | #include "ksyms.h" |
117 | | | 117 | |
118 | struct evcnt intr_evcnts[] = { | | 118 | struct evcnt intr_evcnts[] = { |
119 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "spur"), | | 119 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "spur"), |
120 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev1"), | | 120 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev1"), |
121 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev2"), | | 121 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev2"), |
122 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev3"), | | 122 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev3"), |
123 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev4"), | | 123 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev4"), |
124 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev5"), | | 124 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev5"), |
125 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev6"), | | 125 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev6"), |
126 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev7"), | | 126 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev7"), |
127 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev8"), | | 127 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev8"), |
128 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev9"), | | 128 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev9"), |
129 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "clock"), | | 129 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "clock"), |
130 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev11"), | | 130 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev11"), |
131 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev12"), | | 131 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev12"), |
132 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev13"), | | 132 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev13"), |
133 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "prof"), | | 133 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "prof"), |
134 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev15") | | 134 | EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev15") |
135 | }; | | 135 | }; |
136 | | | 136 | |
137 | void *bootinfo = 0; | | 137 | void *bootinfo = 0; |
138 | | | 138 | |
139 | #ifdef KGDB | | 139 | #ifdef KGDB |
140 | int kgdb_break_at_attach; | | 140 | int kgdb_break_at_attach; |
141 | #endif | | 141 | #endif |
142 | | | 142 | |
143 | #define OFPATHLEN 128 | | 143 | #define OFPATHLEN 128 |
144 | #define OFNODEKEY "OFpnode" | | 144 | #define OFNODEKEY "OFpnode" |
145 | | | 145 | |
146 | char machine_banner[100]; | | 146 | char machine_banner[100]; |
147 | char machine_model[100]; | | 147 | char machine_model[100]; |
148 | char ofbootpath[OFPATHLEN], *ofboottarget, *ofbootpartition; | | 148 | char ofbootpath[OFPATHLEN], *ofboottarget, *ofbootpartition; |
149 | char ofbootargs[OFPATHLEN], *ofbootfile, *ofbootflags; | | 149 | char ofbootargs[OFPATHLEN], *ofbootfile, *ofbootflags; |
150 | int ofbootpackage; | | 150 | int ofbootpackage; |
151 | | | 151 | |
152 | static int mbprint(void *, const char *); | | 152 | static int mbprint(void *, const char *); |
153 | int mainbus_match(device_t, cfdata_t, void *); | | 153 | int mainbus_match(device_t, cfdata_t, void *); |
154 | static void mainbus_attach(device_t, device_t, void *); | | 154 | static void mainbus_attach(device_t, device_t, void *); |
155 | static void get_ncpus(void); | | 155 | static void get_ncpus(void); |
156 | static void get_bootpath_from_prom(void); | | 156 | static void get_bootpath_from_prom(void); |
157 | | | 157 | |
158 | /* | | 158 | /* |
159 | * Kernel 4MB mappings. | | 159 | * Kernel 4MB mappings. |
160 | */ | | 160 | */ |
161 | struct tlb_entry *kernel_tlbs; | | 161 | struct tlb_entry *kernel_tlbs; |
162 | int kernel_dtlb_slots; | | 162 | int kernel_dtlb_slots; |
163 | int kernel_itlb_slots; | | 163 | int kernel_itlb_slots; |
164 | | | 164 | |
165 | /* Global interrupt mappings for all device types. Match against the OBP | | 165 | /* Global interrupt mappings for all device types. Match against the OBP |
166 | * 'device_type' property. | | 166 | * 'device_type' property. |
167 | */ | | 167 | */ |
168 | struct intrmap intrmap[] = { | | 168 | struct intrmap intrmap[] = { |
169 | { "block", PIL_FD }, /* Floppy disk */ | | 169 | { "block", PIL_FD }, /* Floppy disk */ |
170 | { "serial", PIL_SER }, /* zs */ | | 170 | { "serial", PIL_SER }, /* zs */ |
171 | { "scsi", PIL_SCSI }, | | 171 | { "scsi", PIL_SCSI }, |
172 | { "scsi-2", PIL_SCSI }, | | 172 | { "scsi-2", PIL_SCSI }, |
173 | { "network", PIL_NET }, | | 173 | { "network", PIL_NET }, |
174 | { "display", PIL_VIDEO }, | | 174 | { "display", PIL_VIDEO }, |
175 | { "audio", PIL_AUD }, | | 175 | { "audio", PIL_AUD }, |
176 | { "ide", PIL_SCSI }, | | 176 | { "ide", PIL_SCSI }, |
177 | /* The following devices don't have device types: */ | | 177 | /* The following devices don't have device types: */ |
178 | { "SUNW,CS4231", PIL_AUD }, | | 178 | { "SUNW,CS4231", PIL_AUD }, |
179 | { NULL, 0 } | | 179 | { NULL, 0 } |
180 | }; | | 180 | }; |
181 | | | 181 | |
182 | #ifdef DEBUG | | 182 | #ifdef DEBUG |
183 | #define ACDB_BOOTDEV 0x1 | | 183 | #define ACDB_BOOTDEV 0x1 |
184 | #define ACDB_PROBE 0x2 | | 184 | #define ACDB_PROBE 0x2 |
185 | #define ACDB_BOOTARGS 0x4 | | 185 | #define ACDB_BOOTARGS 0x4 |
186 | int autoconf_debug = 0x0; | | 186 | int autoconf_debug = 0x0; |
187 | #define DPRINTF(l, s) do { if (autoconf_debug & l) printf s; } while (0) | | 187 | #define DPRINTF(l, s) do { if (autoconf_debug & l) printf s; } while (0) |
188 | #else | | 188 | #else |
189 | #define DPRINTF(l, s) | | 189 | #define DPRINTF(l, s) |
190 | #endif | | 190 | #endif |
191 | | | 191 | |
192 | int console_node, console_instance; | | 192 | int console_node, console_instance; |
193 | struct genfb_colormap_callback gfb_cb; | | 193 | struct genfb_colormap_callback gfb_cb; |
194 | static void of_set_palette(void *, int, int, int, int); | | 194 | static void of_set_palette(void *, int, int, int, int); |
195 | static void copyprops(device_t, int, prop_dictionary_t, int); | | 195 | static void copyprops(device_t, int, prop_dictionary_t, int); |
196 | | | 196 | |
197 | static void | | 197 | static void |
198 | get_ncpus(void) | | 198 | get_ncpus(void) |
199 | { | | 199 | { |
200 | #ifdef MULTIPROCESSOR | | 200 | #ifdef MULTIPROCESSOR |
201 | int node, l; | | 201 | int node, l; |
202 | char sbuf[32]; | | 202 | char sbuf[32]; |
203 | | | 203 | |
204 | node = findroot(); | | 204 | node = findroot(); |
205 | | | 205 | |
206 | sparc_ncpus = 0; | | 206 | sparc_ncpus = 0; |
207 | for (node = OF_child(node); node; node = OF_peer(node)) { | | 207 | for (node = OF_child(node); node; node = OF_peer(node)) { |
208 | if (OF_getprop(node, "device_type", sbuf, sizeof(sbuf)) <= 0) | | 208 | if (OF_getprop(node, "device_type", sbuf, sizeof(sbuf)) <= 0) |
209 | continue; | | 209 | continue; |
210 | if (strcmp(sbuf, "cpu") != 0) | | 210 | if (strcmp(sbuf, "cpu") != 0) |
211 | continue; | | 211 | continue; |
212 | sparc_ncpus++; | | 212 | sparc_ncpus++; |
213 | l = prom_getpropint(node, "dcache-line-size", 0); | | 213 | l = prom_getpropint(node, "dcache-line-size", 0); |
214 | if (l > dcache_line_size) | | 214 | if (l > dcache_line_size) |
215 | dcache_line_size = l; | | 215 | dcache_line_size = l; |
216 | l = prom_getpropint(node, "icache-line-size", 0); | | 216 | l = prom_getpropint(node, "icache-line-size", 0); |
217 | if (l > icache_line_size) | | 217 | if (l > icache_line_size) |
218 | icache_line_size = l; | | 218 | icache_line_size = l; |
219 | } | | 219 | } |
220 | #else | | 220 | #else |
221 | /* #define sparc_ncpus 1 */ | | 221 | /* #define sparc_ncpus 1 */ |
222 | icache_line_size = dcache_line_size = 8; /* will be fixed later */ | | 222 | icache_line_size = dcache_line_size = 8; /* will be fixed later */ |
223 | #endif | | 223 | #endif |
224 | } | | 224 | } |
225 | | | 225 | |
226 | /* | | 226 | /* |
227 | * lookup_bootinfo: | | 227 | * lookup_bootinfo: |
228 | * Look up information in bootinfo of boot loader. | | 228 | * Look up information in bootinfo of boot loader. |
229 | */ | | 229 | */ |
230 | void * | | 230 | void * |
231 | lookup_bootinfo(int type) | | 231 | lookup_bootinfo(int type) |
232 | { | | 232 | { |
233 | struct btinfo_common *bt; | | 233 | struct btinfo_common *bt; |
234 | char *help = bootinfo; | | 234 | char *help = bootinfo; |
235 | | | 235 | |
236 | /* Check for a bootinfo record first. */ | | 236 | /* Check for a bootinfo record first. */ |
237 | if (help == NULL) | | 237 | if (help == NULL) |
238 | return (NULL); | | 238 | return (NULL); |
239 | | | 239 | |
240 | do { | | 240 | do { |
241 | bt = (struct btinfo_common *)help; | | 241 | bt = (struct btinfo_common *)help; |
242 | if (bt->type == type) | | 242 | if (bt->type == type) |
243 | return ((void *)help); | | 243 | return ((void *)help); |
244 | help += bt->next; | | 244 | help += bt->next; |
245 | } while (bt->next != 0 && | | 245 | } while (bt->next != 0 && |
246 | (size_t)help < (size_t)bootinfo + BOOTINFO_SIZE); | | 246 | (size_t)help < (size_t)bootinfo + BOOTINFO_SIZE); |
247 | | | 247 | |
248 | return (NULL); | | 248 | return (NULL); |
249 | } | | 249 | } |
250 | | | 250 | |
251 | /* | | 251 | /* |
252 | * locore.s code calls bootstrap() just before calling main(). | | 252 | * locore.s code calls bootstrap() just before calling main(). |
253 | * | | 253 | * |
254 | * What we try to do is as follows: | | 254 | * What we try to do is as follows: |
255 | * - Initialize PROM and the console | | 255 | * - Initialize PROM and the console |
256 | * - Read in part of information provided by a bootloader and find out | | 256 | * - Read in part of information provided by a bootloader and find out |
257 | * kernel load and end addresses | | 257 | * kernel load and end addresses |
258 | * - Initialize ksyms | | 258 | * - Initialize ksyms |
259 | * - Find out number of active CPUs | | 259 | * - Find out number of active CPUs |
260 | * - Finalize the bootstrap by calling pmap_bootstrap() | | 260 | * - Finalize the bootstrap by calling pmap_bootstrap() |
261 | * | | 261 | * |
262 | * We will try to run out of the prom until we get out of pmap_bootstrap(). | | 262 | * We will try to run out of the prom until we get out of pmap_bootstrap(). |
263 | */ | | 263 | */ |
264 | void | | 264 | void |
265 | bootstrap(void *o0, void *bootargs, void *bootsize, void *o3, void *ofw) | | 265 | bootstrap(void *o0, void *bootargs, void *bootsize, void *o3, void *ofw) |
266 | { | | 266 | { |
267 | void *bi; | | 267 | void *bi; |
268 | long bmagic; | | 268 | long bmagic; |
269 | char buf[32]; | | 269 | char buf[32]; |
270 | | | 270 | |
271 | #if NKSYMS || defined(DDB) || defined(MODULAR) | | 271 | #if NKSYMS || defined(DDB) || defined(MODULAR) |
272 | struct btinfo_symtab *bi_sym; | | 272 | struct btinfo_symtab *bi_sym; |
273 | #endif | | 273 | #endif |
274 | struct btinfo_count *bi_count; | | 274 | struct btinfo_count *bi_count; |
275 | struct btinfo_kernend *bi_kend; | | 275 | struct btinfo_kernend *bi_kend; |
276 | struct btinfo_tlb *bi_tlb; | | 276 | struct btinfo_tlb *bi_tlb; |
277 | struct btinfo_boothowto *bi_howto; | | 277 | struct btinfo_boothowto *bi_howto; |
278 | | | 278 | |
279 | extern void *romtba; | | 279 | extern void *romtba; |
280 | extern void* get_romtba(void); | | 280 | extern void* get_romtba(void); |
281 | extern void OF_val2sym32(void *); | | 281 | extern void OF_val2sym32(void *); |
282 | extern void OF_sym2val32(void *); | | 282 | extern void OF_sym2val32(void *); |
283 | extern struct consdev consdev_prom; | | 283 | extern struct consdev consdev_prom; |
284 | | | 284 | |
285 | /* Save OpenFrimware entry point */ | | 285 | /* Save OpenFrimware entry point */ |
286 | romp = ofw; | | 286 | romp = ofw; |
287 | romtba = get_romtba(); | | 287 | romtba = get_romtba(); |
288 | | | 288 | |
289 | prom_init(); | | 289 | prom_init(); |
290 | console_instance = promops.po_stdout; | | 290 | console_instance = promops.po_stdout; |
291 | console_node = OF_instance_to_package(promops.po_stdout); | | 291 | console_node = OF_instance_to_package(promops.po_stdout); |
292 | | | 292 | |
293 | /* Initialize the PROM console so printf will not panic */ | | 293 | /* Initialize the PROM console so printf will not panic */ |
294 | cn_tab = &consdev_prom; | | 294 | cn_tab = &consdev_prom; |
295 | (*cn_tab->cn_init)(cn_tab); | | 295 | (*cn_tab->cn_init)(cn_tab); |
296 | | | 296 | |
297 | DPRINTF(ACDB_BOOTARGS, | | 297 | DPRINTF(ACDB_BOOTARGS, |
298 | ("sparc64_init(%p, %p, %p, %p, %p)\n", o0, bootargs, bootsize, | | 298 | ("sparc64_init(%p, %p, %p, %p, %p)\n", o0, bootargs, bootsize, |
299 | o3, ofw)); | | 299 | o3, ofw)); |
300 | | | 300 | |
301 | /* Extract bootinfo pointer */ | | 301 | /* Extract bootinfo pointer */ |
302 | if ((long)bootsize >= (4 * sizeof(uint64_t))) { | | 302 | if ((long)bootsize >= (4 * sizeof(uint64_t))) { |
303 | /* Loaded by 64-bit bootloader */ | | 303 | /* Loaded by 64-bit bootloader */ |
304 | bi = (void*)(u_long)(((uint64_t*)bootargs)[3]); | | 304 | bi = (void*)(u_long)(((uint64_t*)bootargs)[3]); |
305 | bmagic = (long)(((uint64_t*)bootargs)[0]); | | 305 | bmagic = (long)(((uint64_t*)bootargs)[0]); |
306 | } else if ((long)bootsize >= (4 * sizeof(uint32_t))) { | | 306 | } else if ((long)bootsize >= (4 * sizeof(uint32_t))) { |
307 | /* Loaded by 32-bit bootloader */ | | 307 | /* Loaded by 32-bit bootloader */ |
308 | bi = (void*)(u_long)(((uint32_t*)bootargs)[3]); | | 308 | bi = (void*)(u_long)(((uint32_t*)bootargs)[3]); |
309 | bmagic = (long)(((uint32_t*)bootargs)[0]); | | 309 | bmagic = (long)(((uint32_t*)bootargs)[0]); |
310 | } else { | | 310 | } else { |
311 | printf("Bad bootinfo size.\n"); | | 311 | printf("Bad bootinfo size.\n"); |
312 | die_old_boot_loader: | | 312 | die_old_boot_loader: |
313 | printf("This kernel requires NetBSD boot loader version 1.9 " | | 313 | printf("This kernel requires NetBSD boot loader version 1.9 " |
314 | "or newer\n"); | | 314 | "or newer\n"); |
315 | panic("sparc64_init."); | | 315 | panic("sparc64_init."); |
316 | } | | 316 | } |
317 | | | 317 | |
318 | DPRINTF(ACDB_BOOTARGS, | | 318 | DPRINTF(ACDB_BOOTARGS, |
319 | ("sparc64_init: bmagic=%lx, bi=%p\n", bmagic, bi)); | | 319 | ("sparc64_init: bmagic=%lx, bi=%p\n", bmagic, bi)); |
320 | | | 320 | |
321 | /* Read in the information provided by NetBSD boot loader */ | | 321 | /* Read in the information provided by NetBSD boot loader */ |
322 | if (SPARC_MACHINE_OPENFIRMWARE != bmagic) { | | 322 | if (SPARC_MACHINE_OPENFIRMWARE != bmagic) { |
323 | printf("No bootinfo information.\n"); | | 323 | printf("No bootinfo information.\n"); |
324 | goto die_old_boot_loader; | | 324 | goto die_old_boot_loader; |
325 | } | | 325 | } |
326 | | | 326 | |
327 | bootinfo = (void*)(u_long)((uint64_t*)bi)[1]; | | 327 | bootinfo = (void*)(u_long)((uint64_t*)bi)[1]; |
328 | LOOKUP_BOOTINFO(bi_kend, BTINFO_KERNEND); | | 328 | LOOKUP_BOOTINFO(bi_kend, BTINFO_KERNEND); |
329 | | | 329 | |
330 | if (bi_kend->addr == (vaddr_t)0) { | | 330 | if (bi_kend->addr == (vaddr_t)0) { |
331 | panic("Kernel end address is not found in bootinfo.\n"); | | 331 | panic("Kernel end address is not found in bootinfo.\n"); |
332 | } | | 332 | } |
333 | | | 333 | |
334 | #if NKSYMS || defined(DDB) || defined(MODULAR) | | 334 | #if NKSYMS || defined(DDB) || defined(MODULAR) |
335 | LOOKUP_BOOTINFO(bi_sym, BTINFO_SYMTAB); | | 335 | LOOKUP_BOOTINFO(bi_sym, BTINFO_SYMTAB); |
336 | ksyms_addsyms_elf(bi_sym->nsym, (int *)(u_long)bi_sym->ssym, | | 336 | ksyms_addsyms_elf(bi_sym->nsym, (int *)(u_long)bi_sym->ssym, |
337 | (int *)(u_long)bi_sym->esym); | | 337 | (int *)(u_long)bi_sym->esym); |
338 | #ifdef DDB | | 338 | #ifdef DDB |
339 | #ifdef __arch64__ | | 339 | #ifdef __arch64__ |
340 | /* This can only be installed on an 64-bit system cause otherwise our stack is screwed */ | | 340 | /* This can only be installed on an 64-bit system cause otherwise our stack is screwed */ |
341 | OF_set_symbol_lookup(OF_sym2val, OF_val2sym); | | 341 | OF_set_symbol_lookup(OF_sym2val, OF_val2sym); |
342 | #else | | 342 | #else |
343 | OF_set_symbol_lookup(OF_sym2val32, OF_val2sym32); | | 343 | OF_set_symbol_lookup(OF_sym2val32, OF_val2sym32); |
344 | #endif | | 344 | #endif |
345 | #endif | | 345 | #endif |
346 | #endif | | 346 | #endif |
347 | if (OF_getprop(findroot(), "compatible", buf, sizeof(buf)) > 0) { | | 347 | if (OF_getprop(findroot(), "compatible", buf, sizeof(buf)) > 0) { |
348 | if (strcmp(buf, "sun4us") == 0) | | 348 | if (strcmp(buf, "sun4us") == 0) |
349 | setcputyp(CPU_SUN4US); | | 349 | setcputyp(CPU_SUN4US); |
350 | else if (strcmp(buf, "sun4v") == 0) | | 350 | else if (strcmp(buf, "sun4v") == 0) |
351 | setcputyp(CPU_SUN4V); | | 351 | setcputyp(CPU_SUN4V); |
352 | } | | 352 | } |
353 | | | 353 | |
354 | bi_howto = lookup_bootinfo(BTINFO_BOOTHOWTO); | | 354 | bi_howto = lookup_bootinfo(BTINFO_BOOTHOWTO); |
355 | if (bi_howto) | | 355 | if (bi_howto) |
356 | boothowto = bi_howto->boothowto; | | 356 | boothowto = bi_howto->boothowto; |
357 | | | 357 | |
358 | LOOKUP_BOOTINFO(bi_count, BTINFO_DTLB_SLOTS); | | 358 | LOOKUP_BOOTINFO(bi_count, BTINFO_DTLB_SLOTS); |
359 | kernel_dtlb_slots = bi_count->count; | | 359 | kernel_dtlb_slots = bi_count->count; |
360 | kernel_itlb_slots = kernel_dtlb_slots-1; | | 360 | kernel_itlb_slots = kernel_dtlb_slots-1; |
361 | bi_count = lookup_bootinfo(BTINFO_ITLB_SLOTS); | | 361 | bi_count = lookup_bootinfo(BTINFO_ITLB_SLOTS); |
362 | if (bi_count) | | 362 | if (bi_count) |
363 | kernel_itlb_slots = bi_count->count; | | 363 | kernel_itlb_slots = bi_count->count; |
364 | LOOKUP_BOOTINFO(bi_tlb, BTINFO_DTLB); | | 364 | LOOKUP_BOOTINFO(bi_tlb, BTINFO_DTLB); |
365 | kernel_tlbs = &bi_tlb->tlb[0]; | | 365 | kernel_tlbs = &bi_tlb->tlb[0]; |
366 | | | 366 | |
367 | get_ncpus(); | | 367 | get_ncpus(); |
368 | pmap_bootstrap(KERNBASE, bi_kend->addr); | | 368 | pmap_bootstrap(KERNBASE, bi_kend->addr); |
369 | } | | 369 | } |
370 | | | 370 | |
371 | /* | | 371 | /* |
372 | * get_bootpath_from_prom() | | 372 | * get_bootpath_from_prom() |
373 | * fetch the OF settings to identify our boot device during autoconfiguration | | 373 | * fetch the OF settings to identify our boot device during autoconfiguration |
374 | */ | | 374 | */ |
375 | | | 375 | |
376 | static void | | 376 | static void |
377 | get_bootpath_from_prom(void) | | 377 | get_bootpath_from_prom(void) |
378 | { | | 378 | { |
379 | struct btinfo_bootdev *bdev = NULL; | | 379 | struct btinfo_bootdev *bdev = NULL; |
380 | char sbuf[OFPATHLEN], *cp; | | 380 | char sbuf[OFPATHLEN], *cp; |
381 | int chosen; | | 381 | int chosen; |
382 | | | 382 | |
383 | /* | | 383 | /* |
384 | * Grab boot path from PROM | | 384 | * Grab boot path from PROM |
385 | */ | | 385 | */ |
386 | if ((chosen = OF_finddevice("/chosen")) == -1) | | 386 | if ((chosen = OF_finddevice("/chosen")) == -1) |
387 | return; | | 387 | return; |
388 | | | 388 | |
389 | bdev = lookup_bootinfo(BTINFO_BOOTDEV); | | 389 | bdev = lookup_bootinfo(BTINFO_BOOTDEV); |
390 | if (bdev != NULL) { | | 390 | if (bdev != NULL) { |
391 | strcpy(ofbootpath, bdev->name); | | 391 | strcpy(ofbootpath, bdev->name); |
392 | } else { | | 392 | } else { |
393 | if (OF_getprop(chosen, "bootpath", sbuf, sizeof(sbuf)) < 0) | | 393 | if (OF_getprop(chosen, "bootpath", sbuf, sizeof(sbuf)) < 0) |
394 | return; | | 394 | return; |
395 | strcpy(ofbootpath, sbuf); | | 395 | strcpy(ofbootpath, sbuf); |
396 | } | | 396 | } |
397 | DPRINTF(ACDB_BOOTDEV, ("bootpath: %s\n", ofbootpath)); | | 397 | DPRINTF(ACDB_BOOTDEV, ("bootpath: %s\n", ofbootpath)); |
398 | ofbootpackage = prom_finddevice(ofbootpath); | | 398 | ofbootpackage = prom_finddevice(ofbootpath); |
399 | | | 399 | |
400 | /* | | 400 | /* |
401 | * Strip partition or boot protocol | | 401 | * Strip partition or boot protocol |
402 | */ | | 402 | */ |
403 | cp = strrchr(ofbootpath, ':'); | | 403 | cp = strrchr(ofbootpath, ':'); |
404 | if (cp) { | | 404 | if (cp) { |
405 | *cp = '\0'; | | 405 | *cp = '\0'; |
406 | ofbootpartition = cp+1; | | 406 | ofbootpartition = cp+1; |
407 | } | | 407 | } |
408 | cp = strrchr(ofbootpath, '@'); | | 408 | cp = strrchr(ofbootpath, '@'); |
409 | if (cp) { | | 409 | if (cp) { |
410 | for (; cp != ofbootpath; cp--) { | | 410 | for (; cp != ofbootpath; cp--) { |
411 | if (*cp == '/') { | | 411 | if (*cp == '/') { |
412 | ofboottarget = cp+1; | | 412 | ofboottarget = cp+1; |
413 | break; | | 413 | break; |
414 | } | | 414 | } |
415 | } | | 415 | } |
416 | } | | 416 | } |
417 | | | 417 | |
418 | DPRINTF(ACDB_BOOTDEV, ("bootpath phandle: 0x%x\n", ofbootpackage)); | | 418 | DPRINTF(ACDB_BOOTDEV, ("bootpath phandle: 0x%x\n", ofbootpackage)); |
419 | DPRINTF(ACDB_BOOTDEV, ("boot target: %s\n", | | 419 | DPRINTF(ACDB_BOOTDEV, ("boot target: %s\n", |
420 | ofboottarget ? ofboottarget : "<none>")); | | 420 | ofboottarget ? ofboottarget : "<none>")); |
421 | DPRINTF(ACDB_BOOTDEV, ("boot partition: %s\n", | | 421 | DPRINTF(ACDB_BOOTDEV, ("boot partition: %s\n", |
422 | ofbootpartition ? ofbootpartition : "<none>")); | | 422 | ofbootpartition ? ofbootpartition : "<none>")); |
423 | | | 423 | |
424 | /* Setup pointer to boot flags */ | | 424 | /* Setup pointer to boot flags */ |
425 | if (OF_getprop(chosen, "bootargs", sbuf, sizeof(sbuf)) == -1) | | 425 | if (OF_getprop(chosen, "bootargs", sbuf, sizeof(sbuf)) == -1) |
426 | return; | | 426 | return; |
427 | strcpy(ofbootargs, sbuf); | | 427 | strcpy(ofbootargs, sbuf); |
428 | | | 428 | |
429 | cp = ofbootargs; | | 429 | cp = ofbootargs; |
430 | | | 430 | |
431 | /* Find start of boot flags */ | | 431 | /* Find start of boot flags */ |
432 | while (*cp) { | | 432 | while (*cp) { |
433 | while(*cp == ' ' || *cp == '\t') cp++; | | 433 | while(*cp == ' ' || *cp == '\t') cp++; |
434 | if (*cp == '-' || *cp == '\0') | | 434 | if (*cp == '-' || *cp == '\0') |
435 | break; | | 435 | break; |
436 | while(*cp != ' ' && *cp != '\t' && *cp != '\0') cp++; | | 436 | while(*cp != ' ' && *cp != '\t' && *cp != '\0') cp++; |
437 | if (*cp != '\0') | | 437 | if (*cp != '\0') |
438 | *cp++ = '\0'; | | 438 | *cp++ = '\0'; |
439 | } | | 439 | } |
440 | if (cp != ofbootargs) | | 440 | if (cp != ofbootargs) |
441 | ofbootfile = ofbootargs; | | 441 | ofbootfile = ofbootargs; |
442 | ofbootflags = cp; | | 442 | ofbootflags = cp; |
443 | if (*cp != '-') | | 443 | if (*cp != '-') |
444 | return; | | 444 | return; |
445 | | | 445 | |
446 | for (;*++cp;) { | | 446 | for (;*++cp;) { |
447 | int fl; | | 447 | int fl; |
448 | | | 448 | |
449 | fl = 0; | | 449 | fl = 0; |
450 | BOOT_FLAG(*cp, fl); | | 450 | BOOT_FLAG(*cp, fl); |
451 | if (!fl) { | | 451 | if (!fl) { |
452 | printf("unknown option `%c'\n", *cp); | | 452 | printf("unknown option `%c'\n", *cp); |
453 | continue; | | 453 | continue; |
454 | } | | 454 | } |
455 | boothowto |= fl; | | 455 | boothowto |= fl; |
456 | | | 456 | |
457 | /* specialties */ | | 457 | /* specialties */ |
458 | if (*cp == 'd') { | | 458 | if (*cp == 'd') { |
459 | #if defined(KGDB) | | 459 | #if defined(KGDB) |
460 | kgdb_break_at_attach = 1; | | 460 | kgdb_break_at_attach = 1; |
461 | #elif defined(DDB) | | 461 | #elif defined(DDB) |
462 | Debugger(); | | 462 | Debugger(); |
463 | #else | | 463 | #else |
464 | printf("kernel has no debugger\n"); | | 464 | printf("kernel has no debugger\n"); |
465 | #endif | | 465 | #endif |
466 | } else if (*cp == 't') { | | 466 | } else if (*cp == 't') { |
467 | /* turn on traptrace w/o breaking into kdb */ | | 467 | /* turn on traptrace w/o breaking into kdb */ |
468 | extern int trap_trace_dis; | | 468 | extern int trap_trace_dis; |
469 | | | 469 | |
470 | trap_trace_dis = 0; | | 470 | trap_trace_dis = 0; |
471 | } | | 471 | } |
472 | } | | 472 | } |
473 | } | | 473 | } |
474 | | | 474 | |
475 | /* | | 475 | /* |
476 | * Determine mass storage and memory configuration for a machine. | | 476 | * Determine mass storage and memory configuration for a machine. |
477 | * We get the PROM's root device and make sure we understand it, then | | 477 | * We get the PROM's root device and make sure we understand it, then |
478 | * attach it as `mainbus0'. We also set up to handle the PROM `sync' | | 478 | * attach it as `mainbus0'. We also set up to handle the PROM `sync' |
479 | * command. | | 479 | * command. |
480 | */ | | 480 | */ |
481 | void | | 481 | void |
482 | cpu_configure(void) | | 482 | cpu_configure(void) |
483 | { | | 483 | { |
484 | | | 484 | |
485 | bool userconf = (boothowto & RB_USERCONF) != 0; | | 485 | bool userconf = (boothowto & RB_USERCONF) != 0; |
486 | | | 486 | |
487 | /* fetch boot device settings */ | | 487 | /* fetch boot device settings */ |
488 | get_bootpath_from_prom(); | | 488 | get_bootpath_from_prom(); |
489 | if (((boothowto & RB_USERCONF) != 0) && !userconf) | | 489 | if (((boothowto & RB_USERCONF) != 0) && !userconf) |
490 | /* | | 490 | /* |
491 | * Old bootloaders do not pass boothowto, and MI code | | 491 | * Old bootloaders do not pass boothowto, and MI code |
492 | * has already handled userconfig before we get here | | 492 | * has already handled userconfig before we get here |
493 | * and finally fetch the right options. So if we missed | | 493 | * and finally fetch the right options. So if we missed |
494 | * it, just do it here. | | 494 | * it, just do it here. |
495 | */ | | 495 | */ |
496 | userconf_prompt(); | | 496 | userconf_prompt(); |
497 | | | 497 | |
498 | /* block clock interrupts and anything below */ | | 498 | /* block clock interrupts and anything below */ |
499 | splclock(); | | 499 | splclock(); |
500 | /* Enable device interrupts */ | | 500 | /* Enable device interrupts */ |
501 | setpstate(getpstate()|PSTATE_IE); | | 501 | setpstate(getpstate()|PSTATE_IE); |
502 | | | 502 | |
503 | if (config_rootfound("mainbus", NULL) == NULL) | | 503 | if (config_rootfound("mainbus", NULL) == NULL) |
504 | panic("mainbus not configured"); | | 504 | panic("mainbus not configured"); |
505 | | | 505 | |
506 | /* Enable device interrupts */ | | 506 | /* Enable device interrupts */ |
507 | setpstate(getpstate()|PSTATE_IE); | | 507 | setpstate(getpstate()|PSTATE_IE); |
508 | | | 508 | |
509 | (void)spl0(); | | 509 | (void)spl0(); |
510 | } | | 510 | } |
511 | | | 511 | |
512 | void | | 512 | void |
513 | cpu_rootconf(void) | | 513 | cpu_rootconf(void) |
514 | { | | 514 | { |
515 | if (booted_device == NULL) { | | 515 | if (booted_device == NULL) { |
516 | printf("FATAL: boot device not found, check your firmware " | | 516 | printf("FATAL: boot device not found, check your firmware " |
517 | "settings!\n"); | | 517 | "settings!\n"); |
518 | } | | 518 | } |
519 | | | 519 | |
520 | rootconf(); | | 520 | rootconf(); |
521 | } | | 521 | } |
522 | | | 522 | |
523 | char * | | 523 | char * |
524 | clockfreq(uint64_t freq) | | 524 | clockfreq(uint64_t freq) |
525 | { | | 525 | { |
526 | static char buf[10]; | | 526 | static char buf[10]; |
527 | size_t len; | | 527 | size_t len; |
528 | | | 528 | |
529 | freq /= 1000; | | 529 | freq /= 1000; |
530 | len = snprintf(buf, sizeof(buf), "%" PRIu64, freq / 1000); | | 530 | len = snprintf(buf, sizeof(buf), "%" PRIu64, freq / 1000); |
531 | freq %= 1000; | | 531 | freq %= 1000; |
532 | if (freq) | | 532 | if (freq) |
533 | snprintf(buf + len, sizeof(buf) - len, ".%03" PRIu64, freq); | | 533 | snprintf(buf + len, sizeof(buf) - len, ".%03" PRIu64, freq); |
534 | return buf; | | 534 | return buf; |
535 | } | | 535 | } |
536 | | | 536 | |
537 | /* ARGSUSED */ | | 537 | /* ARGSUSED */ |
538 | static int | | 538 | static int |
539 | mbprint(void *aux, const char *name) | | 539 | mbprint(void *aux, const char *name) |
540 | { | | 540 | { |
541 | struct mainbus_attach_args *ma = aux; | | 541 | struct mainbus_attach_args *ma = aux; |
542 | | | 542 | |
543 | if (name) | | 543 | if (name) |
544 | aprint_normal("%s at %s", ma->ma_name, name); | | 544 | aprint_normal("%s at %s", ma->ma_name, name); |
545 | if (ma->ma_address) | | 545 | if (ma->ma_address) |
546 | aprint_normal(" addr 0x%08lx", (u_long)ma->ma_address[0]); | | 546 | aprint_normal(" addr 0x%08lx", (u_long)ma->ma_address[0]); |
547 | if (ma->ma_pri) | | 547 | if (ma->ma_pri) |
548 | aprint_normal(" ipl %d", ma->ma_pri); | | 548 | aprint_normal(" ipl %d", ma->ma_pri); |
549 | return (UNCONF); | | 549 | return (UNCONF); |
550 | } | | 550 | } |
551 | | | 551 | |
552 | int | | 552 | int |
553 | mainbus_match(device_t parent, cfdata_t cf, void *aux) | | 553 | mainbus_match(device_t parent, cfdata_t cf, void *aux) |
554 | { | | 554 | { |
555 | | | 555 | |
556 | return (1); | | 556 | return (1); |
557 | } | | 557 | } |
558 | | | 558 | |
559 | /* | | 559 | /* |
560 | * Attach the mainbus. | | 560 | * Attach the mainbus. |
561 | * | | 561 | * |
562 | * Our main job is to attach the CPU (the root node we got in configure()) | | 562 | * Our main job is to attach the CPU (the root node we got in configure()) |
563 | * and iterate down the list of `mainbus devices' (children of that node). | | 563 | * and iterate down the list of `mainbus devices' (children of that node). |
564 | * We also record the `node id' of the default frame buffer, if any. | | 564 | * We also record the `node id' of the default frame buffer, if any. |
565 | */ | | 565 | */ |
566 | static void | | 566 | static void |
567 | mainbus_attach(device_t parent, device_t dev, void *aux) | | 567 | mainbus_attach(device_t parent, device_t dev, void *aux) |
568 | { | | 568 | { |
569 | extern struct sparc_bus_dma_tag mainbus_dma_tag; | | 569 | extern struct sparc_bus_dma_tag mainbus_dma_tag; |
570 | extern struct sparc_bus_space_tag mainbus_space_tag; | | 570 | extern struct sparc_bus_space_tag mainbus_space_tag; |
571 | | | 571 | |
572 | struct mainbus_attach_args ma; | | 572 | struct mainbus_attach_args ma; |
573 | char sbuf[32]; | | 573 | char sbuf[32]; |
574 | const char *const *ssp, *sp = NULL; | | 574 | const char *const *ssp, *sp = NULL; |
575 | char *c; | | 575 | char *c; |
576 | int node0, node, rv, i; | | 576 | int node0, node, rv, i; |
577 | | | 577 | |
578 | static const char *const openboot_special[] = { | | 578 | static const char *const openboot_special[] = { |
579 | /* ignore these (end with NULL) */ | | 579 | /* ignore these (end with NULL) */ |
580 | /* | | 580 | /* |
581 | * These are _root_ devices to ignore. Others must be handled | | 581 | * These are _root_ devices to ignore. Others must be handled |
582 | * elsewhere. | | 582 | * elsewhere. |
583 | */ | | 583 | */ |
584 | "virtual-memory", | | 584 | "virtual-memory", |
585 | "aliases", | | 585 | "aliases", |
586 | "memory", | | 586 | "memory", |
587 | "openprom", | | 587 | "openprom", |
588 | "options", | | 588 | "options", |
589 | "packages", | | 589 | "packages", |
590 | "chosen", | | 590 | "chosen", |
591 | NULL | | 591 | NULL |
592 | }; | | 592 | }; |
593 | | | 593 | |
594 | if (OF_getprop(findroot(), "banner-name", machine_banner, | | 594 | if (OF_getprop(findroot(), "banner-name", machine_banner, |
595 | sizeof machine_banner) < 0) | | 595 | sizeof machine_banner) < 0) |
596 | i = 0; | | 596 | i = 0; |
597 | else { | | 597 | else { |
598 | i = 1; | | 598 | i = 1; |
599 | if (((c = strchr(machine_banner, '(')) != NULL) && | | 599 | if (((c = strchr(machine_banner, '(')) != NULL) && |
600 | c != &machine_banner[0]) { | | 600 | c != &machine_banner[0]) { |
601 | while (*c == '(' || *c == ' ') { | | 601 | while (*c == '(' || *c == ' ') { |
602 | *c = '\0'; | | 602 | *c = '\0'; |
603 | c--; | | 603 | c--; |
604 | } | | 604 | } |
605 | } | | 605 | } |
606 | } | | 606 | } |
607 | OF_getprop(findroot(), "name", machine_model, sizeof machine_model); | | 607 | OF_getprop(findroot(), "name", machine_model, sizeof machine_model); |
608 | prom_getidprom(); | | 608 | prom_getidprom(); |
609 | if (i) | | 609 | if (i) |
610 | aprint_normal(": %s (%s): hostid %lx\n", machine_model, | | 610 | aprint_normal(": %s (%s): hostid %lx\n", machine_model, |
611 | machine_banner, hostid); | | 611 | machine_banner, hostid); |
612 | else | | 612 | else |
613 | aprint_normal(": %s: hostid %lx\n", machine_model, hostid); | | 613 | aprint_normal(": %s: hostid %lx\n", machine_model, hostid); |
614 | aprint_naive("\n"); | | 614 | aprint_naive("\n"); |
615 | | | 615 | |
616 | /* | | 616 | /* |
617 | * Locate and configure the ``early'' devices. These must be | | 617 | * Locate and configure the ``early'' devices. These must be |
618 | * configured before we can do the rest. For instance, the | | 618 | * configured before we can do the rest. For instance, the |
619 | * EEPROM contains the Ethernet address for the LANCE chip. | | 619 | * EEPROM contains the Ethernet address for the LANCE chip. |
620 | * If the device cannot be located or configured, panic. | | 620 | * If the device cannot be located or configured, panic. |
621 | */ | | 621 | */ |
622 | if (sparc_ncpus == 0) | | 622 | if (sparc_ncpus == 0) |
623 | panic("None of the CPUs found"); | | 623 | panic("None of the CPUs found"); |
624 | | | 624 | |
625 | /* | | 625 | /* |
626 | * Init static interrupt eventcounters | | 626 | * Init static interrupt eventcounters |
627 | */ | | 627 | */ |
628 | for (i = 0; i < __arraycount(intr_evcnts); i++) | | 628 | for (i = 0; i < __arraycount(intr_evcnts); i++) |
629 | evcnt_attach_static(&intr_evcnts[i]); | | 629 | evcnt_attach_static(&intr_evcnts[i]); |
630 | | | 630 | |
631 | node = findroot(); | | 631 | node = findroot(); |
632 | | | 632 | |
633 | /* first early device to be configured is the CPU */ | | 633 | /* first early device to be configured is the CPU */ |
634 | for (node = OF_child(node); node; node = OF_peer(node)) { | | 634 | for (node = OF_child(node); node; node = OF_peer(node)) { |
635 | if (OF_getprop(node, "device_type", sbuf, sizeof(sbuf)) <= 0) | | 635 | if (OF_getprop(node, "device_type", sbuf, sizeof(sbuf)) <= 0) |
636 | continue; | | 636 | continue; |
637 | if (strcmp(sbuf, "cpu") != 0) | | 637 | if (strcmp(sbuf, "cpu") != 0) |
638 | continue; | | 638 | continue; |
639 | memset(&ma, 0, sizeof(ma)); | | 639 | memset(&ma, 0, sizeof(ma)); |
640 | ma.ma_bustag = &mainbus_space_tag; | | 640 | ma.ma_bustag = &mainbus_space_tag; |
641 | ma.ma_dmatag = &mainbus_dma_tag; | | 641 | ma.ma_dmatag = &mainbus_dma_tag; |
642 | ma.ma_node = node; | | 642 | ma.ma_node = node; |
643 | ma.ma_name = "cpu"; | | 643 | ma.ma_name = "cpu"; |
644 | config_found(dev, &ma, mbprint); | | 644 | config_found(dev, &ma, mbprint); |
645 | } | | 645 | } |
646 | | | 646 | |
647 | node = findroot(); /* re-init root node */ | | 647 | node = findroot(); /* re-init root node */ |
648 | | | 648 | |
649 | /* Find the "options" node */ | | 649 | /* Find the "options" node */ |
650 | node0 = OF_child(node); | | 650 | node0 = OF_child(node); |
651 | | | 651 | |
652 | /* | | 652 | /* |
653 | * Configure the devices, in PROM order. Skip | | 653 | * Configure the devices, in PROM order. Skip |
654 | * PROM entries that are not for devices, or which must be | | 654 | * PROM entries that are not for devices, or which must be |
655 | * done before we get here. | | 655 | * done before we get here. |
656 | */ | | 656 | */ |
657 | for (node = node0; node; node = OF_peer(node)) { | | 657 | for (node = node0; node; node = OF_peer(node)) { |
658 | int portid; | | 658 | int portid; |
659 | | | 659 | |
660 | DPRINTF(ACDB_PROBE, ("Node: %x", node)); | | 660 | DPRINTF(ACDB_PROBE, ("Node: %x", node)); |
661 | if ((OF_getprop(node, "device_type", sbuf, sizeof(sbuf)) > 0) && | | 661 | if ((OF_getprop(node, "device_type", sbuf, sizeof(sbuf)) > 0) && |
662 | strcmp(sbuf, "cpu") == 0) | | 662 | strcmp(sbuf, "cpu") == 0) |
663 | continue; | | 663 | continue; |
664 | OF_getprop(node, "name", sbuf, sizeof(sbuf)); | | 664 | OF_getprop(node, "name", sbuf, sizeof(sbuf)); |
665 | DPRINTF(ACDB_PROBE, (" name %s\n", sbuf)); | | 665 | DPRINTF(ACDB_PROBE, (" name %s\n", sbuf)); |
666 | for (ssp = openboot_special; (sp = *ssp) != NULL; ssp++) | | 666 | for (ssp = openboot_special; (sp = *ssp) != NULL; ssp++) |
667 | if (strcmp(sbuf, sp) == 0) | | 667 | if (strcmp(sbuf, sp) == 0) |
668 | break; | | 668 | break; |
669 | if (sp != NULL) | | 669 | if (sp != NULL) |
670 | continue; /* an "early" device already configured */ | | 670 | continue; /* an "early" device already configured */ |
671 | | | 671 | |
672 | memset(&ma, 0, sizeof ma); | | 672 | memset(&ma, 0, sizeof ma); |
673 | ma.ma_bustag = &mainbus_space_tag; | | 673 | ma.ma_bustag = &mainbus_space_tag; |
674 | ma.ma_dmatag = &mainbus_dma_tag; | | 674 | ma.ma_dmatag = &mainbus_dma_tag; |
675 | ma.ma_name = sbuf; | | 675 | ma.ma_name = sbuf; |
676 | ma.ma_node = node; | | 676 | ma.ma_node = node; |
677 | if (OF_getprop(node, "upa-portid", &portid, sizeof(portid)) != | | 677 | if (OF_getprop(node, "upa-portid", &portid, sizeof(portid)) != |
678 | sizeof(portid) && | | 678 | sizeof(portid) && |
679 | OF_getprop(node, "portid", &portid, sizeof(portid)) != | | 679 | OF_getprop(node, "portid", &portid, sizeof(portid)) != |
680 | sizeof(portid)) | | 680 | sizeof(portid)) |
681 | portid = -1; | | 681 | portid = -1; |
682 | ma.ma_upaid = portid; | | 682 | ma.ma_upaid = portid; |
683 | | | 683 | |
684 | if (prom_getprop(node, "reg", sizeof(*ma.ma_reg), | | 684 | if (prom_getprop(node, "reg", sizeof(*ma.ma_reg), |
685 | &ma.ma_nreg, &ma.ma_reg) != 0) | | 685 | &ma.ma_nreg, &ma.ma_reg) != 0) |
686 | continue; | | 686 | continue; |
687 | #ifdef DEBUG | | 687 | #ifdef DEBUG |
688 | if (autoconf_debug & ACDB_PROBE) { | | 688 | if (autoconf_debug & ACDB_PROBE) { |
689 | if (ma.ma_nreg) | | 689 | if (ma.ma_nreg) |
690 | printf(" reg %08lx.%08lx\n", | | 690 | printf(" reg %08lx.%08lx\n", |
691 | (long)ma.ma_reg->ur_paddr, | | 691 | (long)ma.ma_reg->ur_paddr, |
692 | (long)ma.ma_reg->ur_len); | | 692 | (long)ma.ma_reg->ur_len); |
693 | else | | 693 | else |
694 | printf(" no reg\n"); | | 694 | printf(" no reg\n"); |
695 | } | | 695 | } |
696 | #endif | | 696 | #endif |
697 | rv = prom_getprop(node, "interrupts", sizeof(*ma.ma_interrupts), | | 697 | rv = prom_getprop(node, "interrupts", sizeof(*ma.ma_interrupts), |
698 | &ma.ma_ninterrupts, &ma.ma_interrupts); | | 698 | &ma.ma_ninterrupts, &ma.ma_interrupts); |
699 | if (rv != 0 && rv != ENOENT) { | | 699 | if (rv != 0 && rv != ENOENT) { |
700 | free(ma.ma_reg, M_DEVBUF); | | 700 | free(ma.ma_reg, M_DEVBUF); |
701 | continue; | | 701 | continue; |
702 | } | | 702 | } |
703 | #ifdef DEBUG | | 703 | #ifdef DEBUG |
704 | if (autoconf_debug & ACDB_PROBE) { | | 704 | if (autoconf_debug & ACDB_PROBE) { |
705 | if (ma.ma_interrupts) | | 705 | if (ma.ma_interrupts) |
706 | printf(" interrupts %08x\n", *ma.ma_interrupts); | | 706 | printf(" interrupts %08x\n", *ma.ma_interrupts); |
707 | else | | 707 | else |
708 | printf(" no interrupts\n"); | | 708 | printf(" no interrupts\n"); |
709 | } | | 709 | } |
710 | #endif | | 710 | #endif |
711 | rv = prom_getprop(node, "address", sizeof(*ma.ma_address), | | 711 | rv = prom_getprop(node, "address", sizeof(*ma.ma_address), |
712 | &ma.ma_naddress, &ma.ma_address); | | 712 | &ma.ma_naddress, &ma.ma_address); |
713 | if (rv != 0 && rv != ENOENT) { | | 713 | if (rv != 0 && rv != ENOENT) { |
714 | free(ma.ma_reg, M_DEVBUF); | | 714 | free(ma.ma_reg, M_DEVBUF); |
715 | if (ma.ma_ninterrupts) | | 715 | if (ma.ma_ninterrupts) |
716 | free(ma.ma_interrupts, M_DEVBUF); | | 716 | free(ma.ma_interrupts, M_DEVBUF); |
717 | continue; | | 717 | continue; |
718 | } | | 718 | } |
719 | #ifdef DEBUG | | 719 | #ifdef DEBUG |
720 | if (autoconf_debug & ACDB_PROBE) { | | 720 | if (autoconf_debug & ACDB_PROBE) { |
721 | if (ma.ma_naddress) | | 721 | if (ma.ma_naddress) |
722 | printf(" address %08x\n", *ma.ma_address); | | 722 | printf(" address %08x\n", *ma.ma_address); |
723 | else | | 723 | else |
724 | printf(" no address\n"); | | 724 | printf(" no address\n"); |
725 | } | | 725 | } |
726 | #endif | | 726 | #endif |
727 | (void) config_found(dev, (void *)&ma, mbprint); | | 727 | (void) config_found(dev, (void *)&ma, mbprint); |
728 | free(ma.ma_reg, M_DEVBUF); | | 728 | free(ma.ma_reg, M_DEVBUF); |
729 | if (ma.ma_ninterrupts) | | 729 | if (ma.ma_ninterrupts) |
730 | free(ma.ma_interrupts, M_DEVBUF); | | 730 | free(ma.ma_interrupts, M_DEVBUF); |
731 | if (ma.ma_naddress) | | 731 | if (ma.ma_naddress) |
732 | free(ma.ma_address, M_DEVBUF); | | 732 | free(ma.ma_address, M_DEVBUF); |
733 | } | | 733 | } |
734 | /* Try to attach PROM console */ | | 734 | /* Try to attach PROM console */ |
735 | memset(&ma, 0, sizeof ma); | | 735 | memset(&ma, 0, sizeof ma); |
736 | ma.ma_name = "pcons"; | | 736 | ma.ma_name = "pcons"; |
737 | (void) config_found(dev, (void *)&ma, mbprint); | | 737 | (void) config_found(dev, (void *)&ma, mbprint); |
738 | } | | 738 | } |
739 | | | 739 | |
740 | CFATTACH_DECL_NEW(mainbus, 0, | | 740 | CFATTACH_DECL_NEW(mainbus, 0, |
741 | mainbus_match, mainbus_attach, NULL, NULL); | | 741 | mainbus_match, mainbus_attach, NULL, NULL); |
742 | | | 742 | |
743 | | | 743 | |
744 | /* | | 744 | /* |
745 | * Try to figure out where the PROM stores the cursor row & column | | 745 | * Try to figure out where the PROM stores the cursor row & column |
746 | * variables. Returns nonzero on error. | | 746 | * variables. Returns nonzero on error. |
747 | */ | | 747 | */ |
748 | int | | 748 | int |
749 | romgetcursoraddr(int **rowp, int **colp) | | 749 | romgetcursoraddr(int **rowp, int **colp) |
750 | { | | 750 | { |
751 | cell_t row = 0UL, col = 0UL; | | 751 | cell_t row = 0UL, col = 0UL; |
752 | | | 752 | |
753 | OF_interpret("stdout @ is my-self addr line# addr column# ", 0, 2, | | 753 | OF_interpret("stdout @ is my-self addr line# addr column# ", 0, 2, |
754 | &col, &row); | | 754 | &col, &row); |
755 | /* | | 755 | /* |
756 | * We are running on a 64-bit machine, so these things point to | | 756 | * We are running on a 64-bit machine, so these things point to |
757 | * 64-bit values. To convert them to pointers to integers, add | | 757 | * 64-bit values. To convert them to pointers to integers, add |
758 | * 4 to the address. | | 758 | * 4 to the address. |
759 | */ | | 759 | */ |
760 | *rowp = (int *)(intptr_t)(row+4); | | 760 | *rowp = (int *)(intptr_t)(row+4); |
761 | *colp = (int *)(intptr_t)(col+4); | | 761 | *colp = (int *)(intptr_t)(col+4); |
762 | return (row == 0UL || col == 0UL); | | 762 | return (row == 0UL || col == 0UL); |
763 | } | | 763 | } |
764 | | | 764 | |
765 | /* | | 765 | /* |
766 | * Match a device_t against the bootpath, by | | 766 | * Match a device_t against the bootpath, by |
767 | * comparing its firmware package handle. If they match | | 767 | * comparing its firmware package handle. If they match |
768 | * exactly, we found the boot device. | | 768 | * exactly, we found the boot device. |
769 | */ | | 769 | */ |
770 | static void | | 770 | static void |
771 | dev_path_exact_match(device_t dev, int ofnode) | | 771 | dev_path_exact_match(device_t dev, int ofnode) |
772 | { | | 772 | { |
773 | | | 773 | |
774 | if (ofnode != ofbootpackage) | | 774 | if (ofnode != ofbootpackage) |
775 | return; | | 775 | return; |
776 | | | 776 | |
777 | booted_device = dev; | | 777 | booted_device = dev; |
778 | DPRINTF(ACDB_BOOTDEV, ("found bootdevice: %s\n", device_xname(dev))); | | 778 | DPRINTF(ACDB_BOOTDEV, ("found bootdevice: %s\n", device_xname(dev))); |
779 | } | | 779 | } |
780 | | | 780 | |
781 | /* | | 781 | /* |
782 | * Match a device_t against the bootpath, by | | 782 | * Match a device_t against the bootpath, by |
783 | * comparing its firmware package handle and calculating | | 783 | * comparing its firmware package handle and calculating |
784 | * the target/lun suffix and comparing that against | | 784 | * the target/lun suffix and comparing that against |
785 | * the bootpath remainder. | | 785 | * the bootpath remainder. |
786 | */ | | 786 | */ |
787 | static void | | 787 | static void |
788 | dev_path_drive_match(device_t dev, int ctrlnode, int target, | | 788 | dev_path_drive_match(device_t dev, int ctrlnode, int target, |
789 | uint64_t wwn, int lun) | | 789 | uint64_t wwn, int lun) |
790 | { | | 790 | { |
791 | int child = 0, ide_node = 0; | | 791 | int child = 0, ide_node = 0; |
792 | char buf[OFPATHLEN]; | | 792 | char buf[OFPATHLEN]; |
793 | | | 793 | |
794 | DPRINTF(ACDB_BOOTDEV, ("dev_path_drive_match: %s, controller %x, " | | 794 | DPRINTF(ACDB_BOOTDEV, ("dev_path_drive_match: %s, controller %x, " |
795 | "target %d wwn %016" PRIx64 " lun %d\n", device_xname(dev), | | 795 | "target %d wwn %016" PRIx64 " lun %d\n", device_xname(dev), |
796 | ctrlnode, target, wwn, lun)); | | 796 | ctrlnode, target, wwn, lun)); |
797 | | | 797 | |
798 | /* | | 798 | /* |
799 | * The ofbootpackage points to a disk on this controller, so | | 799 | * The ofbootpackage points to a disk on this controller, so |
800 | * iterate over all child nodes and compare. | | 800 | * iterate over all child nodes and compare. |
801 | */ | | 801 | */ |
802 | for (child = prom_firstchild(ctrlnode); child != 0; | | 802 | for (child = prom_firstchild(ctrlnode); child != 0; |
803 | child = prom_nextsibling(child)) | | 803 | child = prom_nextsibling(child)) |
804 | if (child == ofbootpackage) | | 804 | if (child == ofbootpackage) |
805 | break; | | 805 | break; |
806 | | | 806 | |
807 | if (child != ofbootpackage) { | | 807 | if (child != ofbootpackage) { |
808 | /* | | 808 | /* |
809 | * Try Mac firmware style (also used by QEMU/OpenBIOS): | | 809 | * Try Mac firmware style (also used by QEMU/OpenBIOS): |
810 | * below the controller there is an intermediate node | | 810 | * below the controller there is an intermediate node |
811 | * for each IDE channel, and individual targets always | | 811 | * for each IDE channel, and individual targets always |
812 | * are "@0" | | 812 | * are "@0" |
813 | */ | | 813 | */ |
814 | for (ide_node = prom_firstchild(ctrlnode); ide_node != 0; | | 814 | for (ide_node = prom_firstchild(ctrlnode); ide_node != 0; |
815 | ide_node = prom_nextsibling(ide_node)) { | | 815 | ide_node = prom_nextsibling(ide_node)) { |
816 | const char * name = prom_getpropstring(ide_node, | | 816 | const char * name = prom_getpropstring(ide_node, |
817 | "device_type"); | | 817 | "device_type"); |
818 | if (strcmp(name, "ide") != 0) continue; | | 818 | if (strcmp(name, "ide") != 0) continue; |
819 | for (child = prom_firstchild(ide_node); child != 0; | | 819 | for (child = prom_firstchild(ide_node); child != 0; |
820 | child = prom_nextsibling(child)) | | 820 | child = prom_nextsibling(child)) |
821 | if (child == ofbootpackage) | | 821 | if (child == ofbootpackage) |
822 | break; | | 822 | break; |
823 | if (child == ofbootpackage) | | 823 | if (child == ofbootpackage) |
824 | break; | | 824 | break; |
825 | } | | 825 | } |
826 | } | | 826 | } |
827 | | | 827 | |
828 | if (child == ofbootpackage) { | | 828 | if (child == ofbootpackage) { |
829 | const char * name = prom_getpropstring(child, "name"); | | 829 | const char * name = prom_getpropstring(child, "name"); |
830 | | | 830 | |
831 | /* boot device is on this controller */ | | 831 | /* boot device is on this controller */ |
832 | DPRINTF(ACDB_BOOTDEV, ("found controller of bootdevice\n")); | | 832 | DPRINTF(ACDB_BOOTDEV, ("found controller of bootdevice\n")); |
833 | | | 833 | |
834 | /* | | 834 | /* |
835 | * Note: "child" here is == ofbootpackage (s.a.), which | | 835 | * Note: "child" here is == ofbootpackage (s.a.), which |
836 | * may be completely wrong for the device we are checking, | | 836 | * may be completely wrong for the device we are checking, |
837 | * what we realy do here is to match "target" and "lun". | | 837 | * what we realy do here is to match "target" and "lun". |
838 | */ | | 838 | */ |
839 | if (wwn) | | 839 | if (wwn) |
840 | snprintf(buf, sizeof(buf), "%s@w%016" PRIx64 ",%d", | | 840 | snprintf(buf, sizeof(buf), "%s@w%016" PRIx64 ",%d", |
841 | name, wwn, lun); | | 841 | name, wwn, lun); |
842 | else if (ide_node) | | 842 | else if (ide_node) |
843 | snprintf(buf, sizeof(buf), "%s@0", | | 843 | snprintf(buf, sizeof(buf), "%s@0", |
844 | device_is_a(dev, "cd") ? "cdrom" : "disk"); | | 844 | device_is_a(dev, "cd") ? "cdrom" : "disk"); |
845 | else | | 845 | else |
846 | snprintf(buf, sizeof(buf), "%s@%d,%d", | | 846 | snprintf(buf, sizeof(buf), "%s@%d,%d", |
847 | name, target, lun); | | 847 | name, target, lun); |
848 | if (ofboottarget && strcmp(buf, ofboottarget) == 0) { | | 848 | if (ofboottarget && strcmp(buf, ofboottarget) == 0) { |
849 | booted_device = dev; | | 849 | booted_device = dev; |
850 | if (ofbootpartition) | | 850 | if (ofbootpartition) |
851 | booted_partition = *ofbootpartition - 'a'; | | 851 | booted_partition = *ofbootpartition - 'a'; |
852 | DPRINTF(ACDB_BOOTDEV, ("found boot device: %s" | | 852 | DPRINTF(ACDB_BOOTDEV, ("found boot device: %s" |
853 | ", partition %d\n", device_xname(dev), | | 853 | ", partition %d\n", device_xname(dev), |
854 | booted_partition)); | | 854 | booted_partition)); |
855 | } | | 855 | } |
856 | } | | 856 | } |
857 | } | | 857 | } |
858 | | | 858 | |
859 | /* | | 859 | /* |
860 | * Recursively check for a child node. | | 860 | * Recursively check for a child node. |
861 | */ | | 861 | */ |
862 | static bool | | 862 | static bool |
863 | has_child_node(int parent, int search) | | 863 | has_child_node(int parent, int search) |
864 | { | | 864 | { |
865 | int child; | | 865 | int child; |
866 | | | 866 | |
867 | for (child = prom_firstchild(parent); child != 0; | | 867 | for (child = prom_firstchild(parent); child != 0; |
868 | child = prom_nextsibling(child)) { | | 868 | child = prom_nextsibling(child)) { |
869 | if (child == search) | | 869 | if (child == search) |
870 | return true; | | 870 | return true; |
871 | if (has_child_node(child, search)) | | 871 | if (has_child_node(child, search)) |
872 | return true; | | 872 | return true; |
873 | } | | 873 | } |
874 | | | 874 | |
875 | return false; | | 875 | return false; |
876 | } | | 876 | } |
877 | | | 877 | |
878 | /* | | 878 | /* |
879 | * The interposed pseudo-parent node in OpenBIOS has a | | 879 | * The interposed pseudo-parent node in OpenBIOS has a |
880 | * device_type = "ide" and no "compatible" property. | | 880 | * device_type = "ide" and no "compatible" property. |
881 | * It is the secondary bus if the name is "ide1" or "ide" | | 881 | * It is the secondary bus if the name is "ide1" or "ide" |
882 | * with newer OpenBIOS versions. In the latter case, read | | 882 | * with newer OpenBIOS versions. In the latter case, read |
883 | * the first reg value to discriminate the two channels. | | 883 | * the first reg value to discriminate the two channels. |
884 | */ | | 884 | */ |
885 | static bool | | 885 | static bool |
886 | openbios_secondary_ata_heuristic(int parent) | | 886 | openbios_secondary_ata_heuristic(int parent) |
887 | { | | 887 | { |
888 | char tmp[OFPATHLEN]; | | 888 | char tmp[OFPATHLEN]; |
889 | int regs[4]; | | 889 | int regs[4]; |
890 | | | 890 | |
891 | if (OF_getprop(parent, "device_type", tmp, sizeof(tmp)) <= 0) | | 891 | if (OF_getprop(parent, "device_type", tmp, sizeof(tmp)) <= 0) |
892 | return false; | | 892 | return false; |
893 | if (strcmp(tmp, "ide") != 0) | | 893 | if (strcmp(tmp, "ide") != 0) |
894 | return false; | | 894 | return false; |
895 | DPRINTF(ACDB_BOOTDEV, ("parent device_type is ide\n")); | | 895 | DPRINTF(ACDB_BOOTDEV, ("parent device_type is ide\n")); |
896 | | | 896 | |
897 | if (OF_getprop(parent, "compatible", tmp, sizeof(tmp)) > 0) | | 897 | if (OF_getprop(parent, "compatible", tmp, sizeof(tmp)) > 0) |
898 | return false; | | 898 | return false; |
899 | DPRINTF(ACDB_BOOTDEV, ("parent has no compatible property\n")); | | 899 | DPRINTF(ACDB_BOOTDEV, ("parent has no compatible property\n")); |
900 | | | 900 | |
901 | if (OF_getprop(parent, "name", tmp, sizeof(tmp)) <= 0) | | 901 | if (OF_getprop(parent, "name", tmp, sizeof(tmp)) <= 0) |
902 | return false; | | 902 | return false; |
903 | if (strcmp(tmp, "ide1") == 0) { | | 903 | if (strcmp(tmp, "ide1") == 0) { |
904 | DPRINTF(ACDB_BOOTDEV, ("parent seems to be an (old) OpenBIOS" | | 904 | DPRINTF(ACDB_BOOTDEV, ("parent seems to be an (old) OpenBIOS" |
905 | " secondary ATA bus, applying workaround target+2\n")); | | 905 | " secondary ATA bus, applying workaround target+2\n")); |
906 | return true; | | 906 | return true; |
907 | } else if (strcmp(tmp, "ide") == 0) { | | 907 | } else if (strcmp(tmp, "ide") == 0) { |
908 | if (OF_getprop(parent, "reg", ®s, sizeof(regs)) | | 908 | if (OF_getprop(parent, "reg", ®s, sizeof(regs)) |
909 | >= sizeof(regs[0])) { | | 909 | >= sizeof(regs[0])) { |
910 | DPRINTF(ACDB_BOOTDEV, ("parent seems to be an OpenBIOS" | | 910 | DPRINTF(ACDB_BOOTDEV, ("parent seems to be an OpenBIOS" |
911 | " ATA bus #%u\n", regs[0])); | | 911 | " ATA bus #%u\n", regs[0])); |
912 | | | 912 | |
913 | return regs[0] == 1; | | 913 | return regs[0] == 1; |
914 | } | | 914 | } |
915 | | | 915 | |
916 | } | | 916 | } |
917 | | | 917 | |
918 | return false; | | 918 | return false; |
919 | } | | 919 | } |
920 | | | 920 | |
921 | /* | | 921 | /* |
922 | * Match a device_t against the controller/target/lun/wwn | | 922 | * Match a device_t against the controller/target/lun/wwn |
923 | * info passed in from the bootloader (if available), | | 923 | * info passed in from the bootloader (if available), |
924 | * otherwise fall back to old style string matching | | 924 | * otherwise fall back to old style string matching |
925 | * heuristics. | | 925 | * heuristics. |
926 | */ | | 926 | */ |
927 | static void | | 927 | static void |
928 | dev_bi_unit_drive_match(device_t dev, int ctrlnode, int target, | | 928 | dev_bi_unit_drive_match(device_t dev, int ctrlnode, int target, |
929 | uint64_t wwn, int lun) | | 929 | uint64_t wwn, int lun) |
930 | { | | 930 | { |
931 | static struct btinfo_bootdev_unit *bi_unit = NULL; | | 931 | static struct btinfo_bootdev_unit *bi_unit = NULL; |
932 | uint32_t off = 0; | | 932 | uint32_t off = 0; |
933 | static bool passed = false; | | 933 | static bool passed = false; |
934 | #ifdef DEBUG | | 934 | #ifdef DEBUG |
935 | char ctrl_path[OFPATHLEN], parent_path[OFPATHLEN], dev_path[OFPATHLEN]; | | 935 | char ctrl_path[OFPATHLEN], parent_path[OFPATHLEN], dev_path[OFPATHLEN]; |
936 | #endif | | 936 | #endif |
937 | | | 937 | |
938 | if (!passed) { | | 938 | if (!passed) { |
939 | bi_unit = lookup_bootinfo(BTINFO_BOOTDEV_UNIT); | | 939 | bi_unit = lookup_bootinfo(BTINFO_BOOTDEV_UNIT); |
940 | passed = true; | | 940 | passed = true; |
941 | } | | 941 | } |
942 | | | 942 | |
943 | if (bi_unit == NULL) { | | 943 | if (bi_unit == NULL) { |
944 | dev_path_drive_match(dev, ctrlnode, target, wwn, lun); | | 944 | dev_path_drive_match(dev, ctrlnode, target, wwn, lun); |
945 | return; | | 945 | return; |
946 | } | | 946 | } |
947 | | | 947 | |
948 | #ifdef DEBUG | | 948 | #ifdef DEBUG |
949 | DPRINTF(ACDB_BOOTDEV, ("dev_bi_unit_drive_match: %s, controller %x, " | | 949 | DPRINTF(ACDB_BOOTDEV, ("dev_bi_unit_drive_match: %s, controller %x, " |
950 | "target %d wwn %016" PRIx64 " lun %d\n", device_xname(dev), | | 950 | "target %d wwn %016" PRIx64 " lun %d\n", device_xname(dev), |
951 | ctrlnode, target, wwn, lun)); | | 951 | ctrlnode, target, wwn, lun)); |
952 | | | 952 | |
953 | OF_package_to_path(ctrlnode, ctrl_path, sizeof(ctrl_path)); | | 953 | OF_package_to_path(ctrlnode, ctrl_path, sizeof(ctrl_path)); |
954 | OF_package_to_path(bi_unit->phandle, dev_path, sizeof(dev_path)); | | 954 | OF_package_to_path(bi_unit->phandle, dev_path, sizeof(dev_path)); |
955 | OF_package_to_path(bi_unit->parent, parent_path, sizeof(parent_path)); | | 955 | OF_package_to_path(bi_unit->parent, parent_path, sizeof(parent_path)); |
956 | DPRINTF(ACDB_BOOTDEV, ("controller %x : %s\n", ctrlnode, ctrl_path)); | | 956 | DPRINTF(ACDB_BOOTDEV, ("controller %x : %s\n", ctrlnode, ctrl_path)); |
957 | DPRINTF(ACDB_BOOTDEV, ("phandle %x : %s\n", bi_unit->phandle, dev_path)); | | 957 | DPRINTF(ACDB_BOOTDEV, ("phandle %x : %s\n", bi_unit->phandle, dev_path)); |
958 | DPRINTF(ACDB_BOOTDEV, ("parent %x : %s\n", bi_unit->parent, parent_path)); | | 958 | DPRINTF(ACDB_BOOTDEV, ("parent %x : %s\n", bi_unit->parent, parent_path)); |
959 | #endif | | 959 | #endif |
960 | if (ctrlnode != bi_unit->parent | | 960 | if (ctrlnode != bi_unit->parent |
961 | && !has_child_node(ctrlnode, bi_unit->phandle)) { | | 961 | && !has_child_node(ctrlnode, bi_unit->phandle)) { |
962 | DPRINTF(ACDB_BOOTDEV, ("controller %x : %s does not match " | | 962 | DPRINTF(ACDB_BOOTDEV, ("controller %x : %s does not match " |
963 | "bootinfo: %x : %s\n", | | 963 | "bootinfo: %x : %s\n", |
964 | ctrlnode, ctrl_path, bi_unit->parent, parent_path)); | | 964 | ctrlnode, ctrl_path, bi_unit->parent, parent_path)); |
965 | return; | | 965 | return; |
966 | } | | 966 | } |
967 | if (ctrlnode == bi_unit->parent) { | | 967 | if (ctrlnode == bi_unit->parent) { |
968 | DPRINTF(ACDB_BOOTDEV, ("controller %x : %s is bootinfo" | | 968 | DPRINTF(ACDB_BOOTDEV, ("controller %x : %s is bootinfo" |
969 | " parent\n", ctrlnode, ctrl_path)); | | 969 | " parent\n", ctrlnode, ctrl_path)); |
970 | } else { | | 970 | } else { |
971 | DPRINTF(ACDB_BOOTDEV, ("controller %x : %s is parent of" | | 971 | DPRINTF(ACDB_BOOTDEV, ("controller %x : %s is parent of" |
972 | " %x : %s\n", ctrlnode, ctrl_path, bi_unit->parent, | | 972 | " %x : %s\n", ctrlnode, ctrl_path, bi_unit->parent, |
973 | parent_path)); | | 973 | parent_path)); |
974 | | | 974 | |
975 | /* | | 975 | /* |
976 | * Our kernel and "real" OpenFirmware use a 0 .. 3 numbering | | 976 | * Our kernel and "real" OpenFirmware use a 0 .. 3 numbering |
977 | * scheme for IDE devices, but OpenBIOS splits it into | | 977 | * scheme for IDE devices, but OpenBIOS splits it into |
978 | * two "buses" and numbers each 0..1. | | 978 | * two "buses" and numbers each 0..1. |
979 | * Check if we are on the secondary "bus" and adjust | | 979 | * Check if we are on the secondary "bus" and adjust |
980 | * if needed... | | 980 | * if needed... |
981 | */ | | 981 | */ |
982 | if (openbios_secondary_ata_heuristic(bi_unit->parent)) | | 982 | if (openbios_secondary_ata_heuristic(bi_unit->parent)) |
983 | off = 2; | | 983 | off = 2; |
984 | } | | 984 | } |
985 | | | 985 | |
986 | if (bi_unit->wwn != wwn || (bi_unit->target+off) != target | | 986 | if (bi_unit->wwn != wwn || (bi_unit->target+off) != target |
987 | || bi_unit->lun != lun) { | | 987 | || bi_unit->lun != lun) { |
988 | DPRINTF(ACDB_BOOTDEV, ("mismatch: wwn %016" PRIx64 " - %016" PRIx64 | | 988 | DPRINTF(ACDB_BOOTDEV, ("mismatch: wwn %016" PRIx64 " - %016" PRIx64 |
989 | ", target %d - %d, lun %d - %d\n", | | 989 | ", target %d - %d, lun %d - %d\n", |
990 | bi_unit->wwn, wwn, bi_unit->target, target, bi_unit->lun, lun)); | | 990 | bi_unit->wwn, wwn, bi_unit->target, target, bi_unit->lun, lun)); |
991 | return; | | 991 | return; |
992 | } | | 992 | } |
993 | | | 993 | |
994 | booted_device = dev; | | 994 | booted_device = dev; |
995 | if (ofbootpartition) | | 995 | if (ofbootpartition) |
996 | booted_partition = *ofbootpartition - 'a'; | | 996 | booted_partition = *ofbootpartition - 'a'; |
997 | DPRINTF(ACDB_BOOTDEV, ("found boot device: %s" | | 997 | DPRINTF(ACDB_BOOTDEV, ("found boot device: %s" |
998 | ", partition %d\n", device_xname(dev), | | 998 | ", partition %d\n", device_xname(dev), |
999 | booted_partition)); | | 999 | booted_partition)); |
1000 | } | | 1000 | } |
1001 | | | 1001 | |
1002 | /* | | 1002 | /* |
1003 | * Get the firmware package handle from a device_t. | | 1003 | * Get the firmware package handle from a device_t. |
1004 | * Assuming we have previously stored it in the device properties | | 1004 | * Assuming we have previously stored it in the device properties |
1005 | * dictionary. | | 1005 | * dictionary. |
1006 | */ | | 1006 | */ |
1007 | static int | | 1007 | static int |
1008 | device_ofnode(device_t dev) | | 1008 | device_ofnode(device_t dev) |
1009 | { | | 1009 | { |
1010 | prop_dictionary_t props; | | 1010 | prop_dictionary_t props; |
1011 | prop_object_t obj; | | 1011 | prop_object_t obj; |
1012 | | | 1012 | |
1013 | if (dev == NULL) | | 1013 | if (dev == NULL) |
1014 | return 0; | | 1014 | return 0; |
1015 | props = device_properties(dev); | | 1015 | props = device_properties(dev); |
1016 | if (props == NULL) | | 1016 | if (props == NULL) |
1017 | return 0; | | 1017 | return 0; |
1018 | obj = prop_dictionary_get(props, OFNODEKEY); | | 1018 | obj = prop_dictionary_get(props, OFNODEKEY); |
1019 | if (obj == NULL) | | 1019 | if (obj == NULL) |
1020 | return 0; | | 1020 | return 0; |
1021 | | | 1021 | |
1022 | return prop_number_signed_value(obj); | | 1022 | return prop_number_signed_value(obj); |
1023 | } | | 1023 | } |
1024 | | | 1024 | |
1025 | /* | | 1025 | /* |
1026 | * Save the firmware package handle inside the properties dictionary | | 1026 | * Save the firmware package handle inside the properties dictionary |
1027 | * of a device_t. | | 1027 | * of a device_t. |
1028 | */ | | 1028 | */ |
1029 | static void | | 1029 | static void |
1030 | device_setofnode(device_t dev, int node) | | 1030 | device_setofnode(device_t dev, int node) |
1031 | { | | 1031 | { |
1032 | prop_dictionary_t props; | | 1032 | prop_dictionary_t props; |
1033 | prop_object_t obj; | | 1033 | prop_object_t obj; |
1034 | | | 1034 | |
1035 | if (dev == NULL) | | 1035 | if (dev == NULL) |
1036 | return; | | 1036 | return; |
1037 | props = device_properties(dev); | | 1037 | props = device_properties(dev); |
1038 | if (props == NULL) | | 1038 | if (props == NULL) |
1039 | return; | | 1039 | return; |
1040 | obj = prop_number_create_signed(node); | | 1040 | obj = prop_number_create_signed(node); |
1041 | if (obj == NULL) | | 1041 | if (obj == NULL) |
1042 | return; | | 1042 | return; |
1043 | prop_dictionary_set(props, OFNODEKEY, obj); | | 1043 | prop_dictionary_set(props, OFNODEKEY, obj); |
1044 | prop_object_release(obj); | | 1044 | prop_object_release(obj); |
1045 | DPRINTF(ACDB_BOOTDEV, (" [device %s has node %x] ", | | 1045 | DPRINTF(ACDB_BOOTDEV, (" [device %s has node %x] ", |
1046 | device_xname(dev), node)); | | 1046 | device_xname(dev), node)); |
1047 | } | | 1047 | } |
1048 | | | 1048 | |
1049 | static void | | 1049 | static void |
1050 | add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def) | | 1050 | add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def) |
1051 | { | | 1051 | { |
1052 | prop_dictionary_t pin = prop_dictionary_create(); | | 1052 | prop_dictionary_t pin = prop_dictionary_create(); |
1053 | prop_dictionary_set_cstring(pin, "name", name); | | 1053 | prop_dictionary_set_string(pin, "name", name); |
1054 | prop_dictionary_set_uint32(pin, "type", 0); /* 0 for LED, for now */ | | 1054 | prop_dictionary_set_uint32(pin, "type", 0); /* 0 for LED, for now */ |
1055 | prop_dictionary_set_uint32(pin, "pin", num); | | 1055 | prop_dictionary_set_uint32(pin, "pin", num); |
1056 | prop_dictionary_set_bool(pin, "active_high", act); | | 1056 | prop_dictionary_set_bool(pin, "active_high", act); |
1057 | if (def != -1) | | 1057 | if (def != -1) |
1058 | prop_dictionary_set_int32(pin, "default_state", def); | | 1058 | prop_dictionary_set_int32(pin, "default_state", def); |
1059 | prop_array_add(pins, pin); | | 1059 | prop_array_add(pins, pin); |
1060 | prop_object_release(pin); | | 1060 | prop_object_release(pin); |
1061 | } | | 1061 | } |
1062 | | | 1062 | |
1063 | static void | | 1063 | static void |
1064 | add_gpio_props_v210(device_t dev, void *aux) | | 1064 | add_gpio_props_v210(device_t dev, void *aux) |
1065 | { | | 1065 | { |
1066 | struct i2c_attach_args *ia = aux; | | 1066 | struct i2c_attach_args *ia = aux; |
1067 | prop_dictionary_t dict = device_properties(dev); | | 1067 | prop_dictionary_t dict = device_properties(dev); |
1068 | prop_array_t pins; | | 1068 | prop_array_t pins; |
1069 | | | 1069 | |
1070 | switch (ia->ia_addr) { | | 1070 | switch (ia->ia_addr) { |
1071 | case 0x38: /* front panel LEDs */ | | 1071 | case 0x38: /* front panel LEDs */ |
1072 | pins = prop_array_create(); | | 1072 | pins = prop_array_create(); |
1073 | add_gpio_LED(pins, "indicator", 7, 0, -1); | | 1073 | add_gpio_LED(pins, "indicator", 7, 0, -1); |
1074 | add_gpio_LED(pins, "fault", 5, 0, 0); | | 1074 | add_gpio_LED(pins, "fault", 5, 0, 0); |
1075 | add_gpio_LED(pins, "power", 4, 0, 1); | | 1075 | add_gpio_LED(pins, "power", 4, 0, 1); |
1076 | prop_dictionary_set(dict, "pins", pins); | | 1076 | prop_dictionary_set(dict, "pins", pins); |
1077 | prop_object_release(pins); | | 1077 | prop_object_release(pins); |
1078 | break; | | 1078 | break; |
1079 | case 0x23: /* drive bay LEDs */ | | 1079 | case 0x23: /* drive bay LEDs */ |
1080 | pins = prop_array_create(); | | 1080 | pins = prop_array_create(); |
1081 | add_gpio_LED(pins, "bay0_fault", 10, 0, 0); | | 1081 | add_gpio_LED(pins, "bay0_fault", 10, 0, 0); |
1082 | add_gpio_LED(pins, "bay1_fault", 11, 0, 0); | | 1082 | add_gpio_LED(pins, "bay1_fault", 11, 0, 0); |
1083 | add_gpio_LED(pins, "bay0_remove", 12, 0, 0); | | 1083 | add_gpio_LED(pins, "bay0_remove", 12, 0, 0); |
1084 | add_gpio_LED(pins, "bay1_remove", 13, 0, 0); | | 1084 | add_gpio_LED(pins, "bay1_remove", 13, 0, 0); |
1085 | prop_dictionary_set(dict, "pins", pins); | | 1085 | prop_dictionary_set(dict, "pins", pins); |
1086 | prop_object_release(pins); | | 1086 | prop_object_release(pins); |
1087 | break; | | 1087 | break; |
1088 | } | | 1088 | } |
1089 | } | | 1089 | } |
1090 | | | 1090 | |
1091 | static void | | 1091 | static void |
1092 | add_drivebay_props_v210(device_t dev, int ofnode, void *aux) | | 1092 | add_drivebay_props_v210(device_t dev, int ofnode, void *aux) |
1093 | { | | 1093 | { |
1094 | struct scsipibus_attach_args *sa = aux; | | 1094 | struct scsipibus_attach_args *sa = aux; |
1095 | int target = sa->sa_periph->periph_target; | | 1095 | int target = sa->sa_periph->periph_target; |
1096 | char path[256]= ""; | | 1096 | char path[256]= ""; |
1097 | | | 1097 | |
1098 | OF_package_to_path(ofnode, path, sizeof(path)); | | 1098 | OF_package_to_path(ofnode, path, sizeof(path)); |
1099 | | | 1099 | |
1100 | /* see if we're on the onboard controller's 1st channel */ | | 1100 | /* see if we're on the onboard controller's 1st channel */ |
1101 | if (strcmp(path, "/pci@1c,600000/scsi@2") != 0) | | 1101 | if (strcmp(path, "/pci@1c,600000/scsi@2") != 0) |
1102 | return; | | 1102 | return; |
1103 | /* yes, yes we are */ | | 1103 | /* yes, yes we are */ |
1104 | if ( target < 2) { | | 1104 | if ( target < 2) { |
1105 | prop_dictionary_t dict = device_properties(dev); | | 1105 | prop_dictionary_t dict = device_properties(dev); |
1106 | char name[16]; | | 1106 | char name[16]; |
1107 | | | 1107 | |
1108 | snprintf(name, sizeof(name), "bay%d", target); | | 1108 | snprintf(name, sizeof(name), "bay%d", target); |
1109 | prop_dictionary_set_cstring(dict, "location", name); | | 1109 | prop_dictionary_set_string(dict, "location", name); |
1110 | } | | 1110 | } |
1111 | } | | 1111 | } |
1112 | | | 1112 | |
1113 | /* | | 1113 | /* |
1114 | * Called back during autoconfiguration for each device found | | 1114 | * Called back during autoconfiguration for each device found |
1115 | */ | | 1115 | */ |
1116 | void | | 1116 | void |
1117 | device_register(device_t dev, void *aux) | | 1117 | device_register(device_t dev, void *aux) |
1118 | { | | 1118 | { |
1119 | device_t busdev = device_parent(dev); | | 1119 | device_t busdev = device_parent(dev); |
1120 | int ofnode = 0; | | 1120 | int ofnode = 0; |
1121 | | | 1121 | |
1122 | /* | | 1122 | /* |
1123 | * We don't know the type of 'aux' - it depends on the | | 1123 | * We don't know the type of 'aux' - it depends on the |
1124 | * bus this device attaches to. We are only interested in | | 1124 | * bus this device attaches to. We are only interested in |
1125 | * certain bus types, this only is used to find the boot | | 1125 | * certain bus types, this only is used to find the boot |
1126 | * device. | | 1126 | * device. |
1127 | */ | | 1127 | */ |
1128 | if (busdev == NULL) { | | 1128 | if (busdev == NULL) { |
1129 | /* | | 1129 | /* |
1130 | * Ignore mainbus0 itself, it certainly is not a boot | | 1130 | * Ignore mainbus0 itself, it certainly is not a boot |
1131 | * device. | | 1131 | * device. |
1132 | */ | | 1132 | */ |
1133 | } else if (device_is_a(busdev, "mainbus")) { | | 1133 | } else if (device_is_a(busdev, "mainbus")) { |
1134 | struct mainbus_attach_args *ma = aux; | | 1134 | struct mainbus_attach_args *ma = aux; |
1135 | | | 1135 | |
1136 | ofnode = ma->ma_node; | | 1136 | ofnode = ma->ma_node; |
1137 | } else if (device_is_a(busdev, "pci")) { | | 1137 | } else if (device_is_a(busdev, "pci")) { |
1138 | struct pci_attach_args *pa = aux; | | 1138 | struct pci_attach_args *pa = aux; |
1139 | | | 1139 | |
1140 | ofnode = PCITAG_NODE(pa->pa_tag); | | 1140 | ofnode = PCITAG_NODE(pa->pa_tag); |
1141 | } else if (device_is_a(busdev, "sbus") || device_is_a(busdev, "dma") | | 1141 | } else if (device_is_a(busdev, "sbus") || device_is_a(busdev, "dma") |
1142 | || device_is_a(busdev, "ledma")) { | | 1142 | || device_is_a(busdev, "ledma")) { |
1143 | struct sbus_attach_args *sa = aux; | | 1143 | struct sbus_attach_args *sa = aux; |
1144 | | | 1144 | |
1145 | ofnode = sa->sa_node; | | 1145 | ofnode = sa->sa_node; |
1146 | } else if (device_is_a(busdev, "ebus")) { | | 1146 | } else if (device_is_a(busdev, "ebus")) { |
1147 | struct ebus_attach_args *ea = aux; | | 1147 | struct ebus_attach_args *ea = aux; |
1148 | | | 1148 | |
1149 | ofnode = ea->ea_node; | | 1149 | ofnode = ea->ea_node; |
1150 | } else if (device_is_a(busdev, "iic")) { | | 1150 | } else if (device_is_a(busdev, "iic")) { |
1151 | struct i2c_attach_args *ia = aux; | | 1151 | struct i2c_attach_args *ia = aux; |
1152 | | | 1152 | |
1153 | if (ia->ia_name == NULL) /* indirect config */ | | 1153 | if (ia->ia_name == NULL) /* indirect config */ |
1154 | return; | | 1154 | return; |
1155 | | | 1155 | |
1156 | ofnode = (int)ia->ia_cookie; | | 1156 | ofnode = (int)ia->ia_cookie; |
1157 | if (device_is_a(dev, "pcagpio")) { | | 1157 | if (device_is_a(dev, "pcagpio")) { |
1158 | if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) { | | 1158 | if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) { |
1159 | add_gpio_props_v210(dev, aux); | | 1159 | add_gpio_props_v210(dev, aux); |
1160 | } | | 1160 | } |
1161 | } | | 1161 | } |
1162 | } else if (device_is_a(dev, "sd") || device_is_a(dev, "cd")) { | | 1162 | } else if (device_is_a(dev, "sd") || device_is_a(dev, "cd")) { |
1163 | struct scsipibus_attach_args *sa = aux; | | 1163 | struct scsipibus_attach_args *sa = aux; |
1164 | struct scsipi_periph *periph = sa->sa_periph; | | 1164 | struct scsipi_periph *periph = sa->sa_periph; |
1165 | int off = 0; | | 1165 | int off = 0; |
1166 | | | 1166 | |
1167 | /* | | 1167 | /* |
1168 | * There are two "cd" attachments: | | 1168 | * There are two "cd" attachments: |
1169 | * atapibus -> atabus -> controller | | 1169 | * atapibus -> atabus -> controller |
1170 | * scsibus -> controller | | 1170 | * scsibus -> controller |
1171 | * We want the node of the controller. | | 1171 | * We want the node of the controller. |
1172 | */ | | 1172 | */ |
1173 | if (device_is_a(busdev, "atapibus")) { | | 1173 | if (device_is_a(busdev, "atapibus")) { |
1174 | busdev = device_parent(busdev); | | 1174 | busdev = device_parent(busdev); |
1175 | /* | | 1175 | /* |
1176 | * if the atapibus is connected to the secondary | | 1176 | * if the atapibus is connected to the secondary |
1177 | * channel of the atabus, we need an offset of 2 | | 1177 | * channel of the atabus, we need an offset of 2 |
1178 | * to match OF's idea of the target number. | | 1178 | * to match OF's idea of the target number. |
1179 | * (i.e. on U5/U10 "cdrom" and "disk2" have the | | 1179 | * (i.e. on U5/U10 "cdrom" and "disk2" have the |
1180 | * same target encoding, though different names) | | 1180 | * same target encoding, though different names) |
1181 | */ | | 1181 | */ |
1182 | if (periph->periph_channel->chan_channel == 1) | | 1182 | if (periph->periph_channel->chan_channel == 1) |
1183 | off = 2; | | 1183 | off = 2; |
1184 | } | | 1184 | } |
1185 | ofnode = device_ofnode(device_parent(busdev)); | | 1185 | ofnode = device_ofnode(device_parent(busdev)); |
1186 | dev_bi_unit_drive_match(dev, ofnode, periph->periph_target + off, | | 1186 | dev_bi_unit_drive_match(dev, ofnode, periph->periph_target + off, |
1187 | 0, periph->periph_lun); | | 1187 | 0, periph->periph_lun); |
1188 | if (device_is_a(busdev, "scsibus")) { | | 1188 | if (device_is_a(busdev, "scsibus")) { |
1189 | /* see if we're in a known SCA drivebay */ | | 1189 | /* see if we're in a known SCA drivebay */ |
1190 | if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) { | | 1190 | if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) { |
1191 | add_drivebay_props_v210(dev, ofnode, aux); | | 1191 | add_drivebay_props_v210(dev, ofnode, aux); |
1192 | } | | 1192 | } |
1193 | } | | 1193 | } |
1194 | return; | | 1194 | return; |
1195 | } else if (device_is_a(dev, "wd")) { | | 1195 | } else if (device_is_a(dev, "wd")) { |
1196 | struct ata_device *adev = aux; | | 1196 | struct ata_device *adev = aux; |
1197 | | | 1197 | |
1198 | ofnode = device_ofnode(device_parent(busdev)); | | 1198 | ofnode = device_ofnode(device_parent(busdev)); |
1199 | dev_bi_unit_drive_match(dev, ofnode, adev->adev_channel*2+ | | 1199 | dev_bi_unit_drive_match(dev, ofnode, adev->adev_channel*2+ |
1200 | adev->adev_drv_data->drive, 0, 0); | | 1200 | adev->adev_drv_data->drive, 0, 0); |
1201 | return; | | 1201 | return; |
1202 | } else if (device_is_a(dev, "ld")) { | | 1202 | } else if (device_is_a(dev, "ld")) { |
1203 | ofnode = device_ofnode(busdev); | | 1203 | ofnode = device_ofnode(busdev); |
1204 | } else if (device_is_a(dev, "vdsk")) { | | 1204 | } else if (device_is_a(dev, "vdsk")) { |
1205 | struct cbus_attach_args *ca = aux; | | 1205 | struct cbus_attach_args *ca = aux; |
1206 | ofnode = ca->ca_node; | | 1206 | ofnode = ca->ca_node; |
1207 | /* Ensure that the devices ofnode is stored for later use */ | | 1207 | /* Ensure that the devices ofnode is stored for later use */ |
1208 | device_setofnode(dev, ofnode); | | 1208 | device_setofnode(dev, ofnode); |
1209 | } | | 1209 | } |
1210 | | | 1210 | |
1211 | if (busdev == NULL) | | 1211 | if (busdev == NULL) |
1212 | return; | | 1212 | return; |
1213 | | | 1213 | |
1214 | if (ofnode != 0) { | | 1214 | if (ofnode != 0) { |
1215 | uint8_t eaddr[ETHER_ADDR_LEN]; | | 1215 | uint8_t eaddr[ETHER_ADDR_LEN]; |
1216 | char tmpstr[32]; | | 1216 | char tmpstr[32]; |
1217 | char tmpstr2[32]; | | 1217 | char tmpstr2[32]; |
1218 | int node; | | 1218 | int node; |
1219 | uint32_t id = 0; | | 1219 | uint32_t id = 0; |
1220 | uint64_t nwwn = 0, pwwn = 0; | | 1220 | uint64_t nwwn = 0, pwwn = 0; |
1221 | prop_dictionary_t dict; | | 1221 | prop_dictionary_t dict; |
1222 | prop_data_t blob; | | 1222 | prop_data_t blob; |
1223 | prop_number_t pwwnd = NULL, nwwnd = NULL; | | 1223 | prop_number_t pwwnd = NULL, nwwnd = NULL; |
1224 | prop_number_t idd = NULL; | | 1224 | prop_number_t idd = NULL; |
1225 | | | 1225 | |
1226 | device_setofnode(dev, ofnode); | | 1226 | device_setofnode(dev, ofnode); |
1227 | dev_path_exact_match(dev, ofnode); | | 1227 | dev_path_exact_match(dev, ofnode); |
1228 | | | 1228 | |
1229 | if (OF_getprop(ofnode, "name", tmpstr, sizeof(tmpstr)) <= 0) | | 1229 | if (OF_getprop(ofnode, "name", tmpstr, sizeof(tmpstr)) <= 0) |
1230 | tmpstr[0] = 0; | | 1230 | tmpstr[0] = 0; |
1231 | if (OF_getprop(ofnode, "device_type", tmpstr2, sizeof(tmpstr2)) <= 0) | | 1231 | if (OF_getprop(ofnode, "device_type", tmpstr2, sizeof(tmpstr2)) <= 0) |
1232 | tmpstr2[0] = 0; | | 1232 | tmpstr2[0] = 0; |
1233 | | | 1233 | |
1234 | /* | | 1234 | /* |
1235 | * If this is a network interface, note the | | 1235 | * If this is a network interface, note the |
1236 | * mac address. | | 1236 | * mac address. |
1237 | */ | | 1237 | */ |
1238 | if (strcmp(tmpstr, "network") == 0 | | 1238 | if (strcmp(tmpstr, "network") == 0 |
1239 | || strcmp(tmpstr, "ethernet") == 0 | | 1239 | || strcmp(tmpstr, "ethernet") == 0 |
1240 | || strcmp(tmpstr2, "network") == 0 | | 1240 | || strcmp(tmpstr2, "network") == 0 |
1241 | || strcmp(tmpstr2, "ethernet") == 0 | | 1241 | || strcmp(tmpstr2, "ethernet") == 0 |
1242 | || OF_getprop(ofnode, "mac-address", &eaddr, sizeof(eaddr)) | | 1242 | || OF_getprop(ofnode, "mac-address", &eaddr, sizeof(eaddr)) |
1243 | >= ETHER_ADDR_LEN | | 1243 | >= ETHER_ADDR_LEN |
1244 | || OF_getprop(ofnode, "local-mac-address", &eaddr, sizeof(eaddr)) | | 1244 | || OF_getprop(ofnode, "local-mac-address", &eaddr, sizeof(eaddr)) |
1245 | >= ETHER_ADDR_LEN) { | | 1245 | >= ETHER_ADDR_LEN) { |
1246 | | | 1246 | |
1247 | dict = device_properties(dev); | | 1247 | dict = device_properties(dev); |
1248 | | | 1248 | |
1249 | /* | | 1249 | /* |
1250 | * Is it a network interface with FCode? | | 1250 | * Is it a network interface with FCode? |
1251 | */ | | 1251 | */ |
1252 | if (strcmp(tmpstr, "network") == 0 || | | 1252 | if (strcmp(tmpstr, "network") == 0 || |
1253 | strcmp(tmpstr2, "network") == 0) { | | 1253 | strcmp(tmpstr2, "network") == 0) { |
1254 | prop_dictionary_set_bool(dict, | | 1254 | prop_dictionary_set_bool(dict, |
1255 | "without-seeprom", true); | | 1255 | "without-seeprom", true); |
1256 | prom_getether(ofnode, eaddr); | | 1256 | prom_getether(ofnode, eaddr); |
1257 | } else { | | 1257 | } else { |
1258 | if (!prom_get_node_ether(ofnode, eaddr)) | | 1258 | if (!prom_get_node_ether(ofnode, eaddr)) |
1259 | goto noether; | | 1259 | goto noether; |
1260 | } | | 1260 | } |
1261 | blob = prop_data_create_data(eaddr, ETHER_ADDR_LEN); | | 1261 | blob = prop_data_create_copy(eaddr, ETHER_ADDR_LEN); |
1262 | prop_dictionary_set(dict, "mac-address", blob); | | 1262 | prop_dictionary_set(dict, "mac-address", blob); |
1263 | prop_object_release(blob); | | 1263 | prop_object_release(blob); |
1264 | of_to_dataprop(dict, ofnode, "shared-pins", | | 1264 | of_to_dataprop(dict, ofnode, "shared-pins", |
1265 | "shared-pins"); | | 1265 | "shared-pins"); |
1266 | } | | 1266 | } |
1267 | noether: | | 1267 | noether: |
1268 | | | 1268 | |
1269 | /* is this a FC node? */ | | 1269 | /* is this a FC node? */ |
1270 | if (strcmp(tmpstr, "scsi-fcp") == 0) { | | 1270 | if (strcmp(tmpstr, "scsi-fcp") == 0) { |
1271 | | | 1271 | |
1272 | dict = device_properties(dev); | | 1272 | dict = device_properties(dev); |
1273 | | | 1273 | |
1274 | if (OF_getprop(ofnode, "port-wwn", &pwwn, sizeof(pwwn)) | | 1274 | if (OF_getprop(ofnode, "port-wwn", &pwwn, sizeof(pwwn)) |
1275 | == sizeof(pwwn)) { | | 1275 | == sizeof(pwwn)) { |
1276 | pwwnd = | | 1276 | pwwnd = |
1277 | prop_number_create_unsigned(pwwn); | | 1277 | prop_number_create_unsigned(pwwn); |
1278 | prop_dictionary_set(dict, "port-wwn", pwwnd); | | 1278 | prop_dictionary_set(dict, "port-wwn", pwwnd); |
1279 | prop_object_release(pwwnd); | | 1279 | prop_object_release(pwwnd); |
1280 | } | | 1280 | } |
1281 | | | 1281 | |
1282 | if (OF_getprop(ofnode, "node-wwn", &nwwn, sizeof(nwwn)) | | 1282 | if (OF_getprop(ofnode, "node-wwn", &nwwn, sizeof(nwwn)) |
1283 | == sizeof(nwwn)) { | | 1283 | == sizeof(nwwn)) { |
1284 | nwwnd = | | 1284 | nwwnd = |
1285 | prop_number_create_unsigned(nwwn); | | 1285 | prop_number_create_unsigned(nwwn); |
1286 | prop_dictionary_set(dict, "node-wwn", nwwnd); | | 1286 | prop_dictionary_set(dict, "node-wwn", nwwnd); |
1287 | prop_object_release(nwwnd); | | 1287 | prop_object_release(nwwnd); |
1288 | } | | 1288 | } |
1289 | } | | 1289 | } |
1290 | | | 1290 | |
1291 | /* is this an spi device? look for scsi-initiator-id */ | | 1291 | /* is this an spi device? look for scsi-initiator-id */ |
1292 | if (strcmp(tmpstr2, "scsi") == 0 || | | 1292 | if (strcmp(tmpstr2, "scsi") == 0 || |
1293 | strcmp(tmpstr2, "scsi-2") == 0) { | | 1293 | strcmp(tmpstr2, "scsi-2") == 0) { |
1294 | | | 1294 | |
1295 | dict = device_properties(dev); | | 1295 | dict = device_properties(dev); |
1296 | | | 1296 | |
1297 | for (node = ofnode; node != 0; node = OF_parent(node)) { | | 1297 | for (node = ofnode; node != 0; node = OF_parent(node)) { |
1298 | if (OF_getprop(node, "scsi-initiator-id", &id, | | 1298 | if (OF_getprop(node, "scsi-initiator-id", &id, |
1299 | sizeof(id)) <= 0) | | 1299 | sizeof(id)) <= 0) |
1300 | continue; | | 1300 | continue; |
1301 | | | 1301 | |
1302 | idd = prop_number_create_unsigned(id); | | 1302 | idd = prop_number_create_unsigned(id); |
1303 | prop_dictionary_set(dict, | | 1303 | prop_dictionary_set(dict, |
1304 | "scsi-initiator-id", idd); | | 1304 | "scsi-initiator-id", idd); |
1305 | prop_object_release(idd); | | 1305 | prop_object_release(idd); |
1306 | break; | | 1306 | break; |
1307 | } | | 1307 | } |
1308 | } | | 1308 | } |
1309 | } | | 1309 | } |
1310 | | | 1310 | |
1311 | /* | | 1311 | /* |
1312 | * Check for I2C busses and add data for their direct configuration. | | 1312 | * Check for I2C busses and add data for their direct configuration. |
1313 | */ | | 1313 | */ |
1314 | if (device_is_a(dev, "iic")) { | | 1314 | if (device_is_a(dev, "iic")) { |
1315 | int busnode = device_ofnode(busdev); | | 1315 | int busnode = device_ofnode(busdev); |
1316 | | | 1316 | |
1317 | if (busnode) { | | 1317 | if (busnode) { |
1318 | prop_dictionary_t props = device_properties(busdev); | | 1318 | prop_dictionary_t props = device_properties(busdev); |
1319 | prop_object_t cfg = prop_dictionary_get(props, | | 1319 | prop_object_t cfg = prop_dictionary_get(props, |
1320 | "i2c-child-devices"); | | 1320 | "i2c-child-devices"); |
1321 | if (!cfg) { | | 1321 | if (!cfg) { |
1322 | int node; | | 1322 | int node; |
1323 | const char *name; | | 1323 | const char *name; |
1324 | | | 1324 | |
1325 | /* | | 1325 | /* |
1326 | * pmu's i2c devices are under the "i2c" node, | | 1326 | * pmu's i2c devices are under the "i2c" node, |
1327 | * so find it out. | | 1327 | * so find it out. |
1328 | */ | | 1328 | */ |
1329 | name = prom_getpropstring(busnode, "name"); | | 1329 | name = prom_getpropstring(busnode, "name"); |
1330 | if (strcmp(name, "pmu") == 0) { | | 1330 | if (strcmp(name, "pmu") == 0) { |
1331 | for (node = OF_child(busnode); | | 1331 | for (node = OF_child(busnode); |
1332 | node != 0; node = OF_peer(node)) { | | 1332 | node != 0; node = OF_peer(node)) { |
1333 | name = prom_getpropstring(node, | | 1333 | name = prom_getpropstring(node, |
1334 | "name"); | | 1334 | "name"); |
1335 | if (strcmp(name, "i2c") == 0) { | | 1335 | if (strcmp(name, "i2c") == 0) { |
1336 | busnode = node; | | 1336 | busnode = node; |
1337 | break; | | 1337 | break; |
1338 | } | | 1338 | } |
1339 | } | | 1339 | } |
1340 | } | | 1340 | } |
1341 | | | 1341 | |
1342 | of_enter_i2c_devs(props, busnode, | | 1342 | of_enter_i2c_devs(props, busnode, |
1343 | sizeof(cell_t), 1); | | 1343 | sizeof(cell_t), 1); |
1344 | } | | 1344 | } |
1345 | } | | 1345 | } |
1346 | | | 1346 | |
1347 | /* | | 1347 | /* |
1348 | * Add SPARCle spdmem devices (0x50 and 0x51) that the | | 1348 | * Add SPARCle spdmem devices (0x50 and 0x51) that the |
1349 | * firmware does not know about. | | 1349 | * firmware does not know about. |
1350 | */ | | 1350 | */ |
1351 | if (!strcmp(machine_model, "TAD,SPARCLE")) { | | 1351 | if (!strcmp(machine_model, "TAD,SPARCLE")) { |
1352 | prop_dictionary_t props = device_properties(busdev); | | 1352 | prop_dictionary_t props = device_properties(busdev); |
1353 | prop_array_t cfg = prop_array_create(); | | 1353 | prop_array_t cfg = prop_array_create(); |
1354 | int i; | | 1354 | int i; |
1355 | | | 1355 | |
1356 | DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle ")); | | 1356 | DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle ")); |
1357 | for (i = 0x50; i <= 0x51; i++) { | | 1357 | for (i = 0x50; i <= 0x51; i++) { |
1358 | prop_dictionary_t spd = | | 1358 | prop_dictionary_t spd = |
1359 | prop_dictionary_create(); | | 1359 | prop_dictionary_create(); |
1360 | prop_dictionary_set_cstring(spd, "name", | | 1360 | prop_dictionary_set_string(spd, "name", |
1361 | "dimm-spd"); | | 1361 | "dimm-spd"); |
1362 | prop_dictionary_set_uint32(spd, "addr", i); | | 1362 | prop_dictionary_set_uint32(spd, "addr", i); |
1363 | prop_dictionary_set_uint64(spd, "cookie", 0); | | 1363 | prop_dictionary_set_uint64(spd, "cookie", 0); |
1364 | prop_array_add(cfg, spd); | | 1364 | prop_array_add(cfg, spd); |
1365 | prop_object_release(spd); | | 1365 | prop_object_release(spd); |
1366 | } | | 1366 | } |
1367 | prop_dictionary_set(props, "i2c-child-devices", cfg); | | 1367 | prop_dictionary_set(props, "i2c-child-devices", cfg); |
1368 | prop_object_release(cfg); | | 1368 | prop_object_release(cfg); |
1369 | | | 1369 | |
1370 | } | | 1370 | } |
1371 | | | 1371 | |
1372 | /* | | 1372 | /* |
1373 | * Add V210/V240 environmental sensors that are not in | | 1373 | * Add V210/V240 environmental sensors that are not in |
1374 | * the OFW tree. | | 1374 | * the OFW tree. |
1375 | */ | | 1375 | */ |
1376 | if (device_is_a(busdev, "pcfiic") && | | 1376 | if (device_is_a(busdev, "pcfiic") && |
1377 | (!strcmp(machine_model, "SUNW,Sun-Fire-V240") || | | 1377 | (!strcmp(machine_model, "SUNW,Sun-Fire-V240") || |
1378 | !strcmp(machine_model, "SUNW,Sun-Fire-V210"))) { | | 1378 | !strcmp(machine_model, "SUNW,Sun-Fire-V210"))) { |
1379 | prop_dictionary_t props = device_properties(busdev); | | 1379 | prop_dictionary_t props = device_properties(busdev); |
1380 | prop_array_t cfg = NULL; | | 1380 | prop_array_t cfg = NULL; |
1381 | prop_dictionary_t sens; | | 1381 | prop_dictionary_t sens; |
1382 | prop_data_t data; | | 1382 | prop_data_t data; |
1383 | const char name_lm[] = "i2c-lm75"; | | 1383 | const char name_lm[] = "i2c-lm75"; |
1384 | const char name_adm[] = "i2c-adm1026"; | | 1384 | const char name_adm[] = "i2c-adm1026"; |
1385 | | | 1385 | |
1386 | DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ", | | 1386 | DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ", |
1387 | machine_model)); | | 1387 | machine_model)); |
1388 | cfg = prop_dictionary_get(props, "i2c-child-devices"); | | 1388 | cfg = prop_dictionary_get(props, "i2c-child-devices"); |
1389 | if (!cfg) { | | 1389 | if (!cfg) { |
1390 | cfg = prop_array_create(); | | 1390 | cfg = prop_array_create(); |
1391 | prop_dictionary_set(props, "i2c-child-devices", | | 1391 | prop_dictionary_set(props, "i2c-child-devices", |
1392 | cfg); | | 1392 | cfg); |
1393 | prop_dictionary_set_bool(props, | | 1393 | prop_dictionary_set_bool(props, |
1394 | "i2c-no-indirect-config", true); | | 1394 | "i2c-no-indirect-config", true); |
1395 | } | | 1395 | } |
1396 | | | 1396 | |
1397 | /* ADM1026 at 0x2e */ | | 1397 | /* ADM1026 at 0x2e */ |
1398 | sens = prop_dictionary_create(); | | 1398 | sens = prop_dictionary_create(); |
1399 | prop_dictionary_set_uint32(sens, "addr", 0x2e); | | 1399 | prop_dictionary_set_uint32(sens, "addr", 0x2e); |
1400 | prop_dictionary_set_uint64(sens, "cookie", 0); | | 1400 | prop_dictionary_set_uint64(sens, "cookie", 0); |
1401 | prop_dictionary_set_cstring(sens, "name", | | 1401 | prop_dictionary_set_string(sens, "name", |
1402 | "hardware-monitor"); | | 1402 | "hardware-monitor"); |
1403 | data = prop_data_create_data(&name_adm[0], | | 1403 | data = prop_data_create_copy(&name_adm[0], |
1404 | sizeof(name_adm)); | | 1404 | sizeof(name_adm)); |
1405 | prop_dictionary_set(sens, "compatible", data); | | 1405 | prop_dictionary_set(sens, "compatible", data); |
1406 | prop_object_release(data); | | 1406 | prop_object_release(data); |
1407 | prop_array_add(cfg, sens); | | 1407 | prop_array_add(cfg, sens); |
1408 | prop_object_release(sens); | | 1408 | prop_object_release(sens); |
1409 | | | 1409 | |
1410 | /* LM75 at 0x4e */ | | 1410 | /* LM75 at 0x4e */ |
1411 | sens = prop_dictionary_create(); | | 1411 | sens = prop_dictionary_create(); |
1412 | prop_dictionary_set_uint32(sens, "addr", 0x4e); | | 1412 | prop_dictionary_set_uint32(sens, "addr", 0x4e); |
1413 | prop_dictionary_set_uint64(sens, "cookie", 0); | | 1413 | prop_dictionary_set_uint64(sens, "cookie", 0); |
1414 | prop_dictionary_set_cstring(sens, "name", | | 1414 | prop_dictionary_set_string(sens, "name", |
1415 | "temperature-sensor"); | | 1415 | "temperature-sensor"); |
1416 | data = prop_data_create_data(&name_lm[0], | | 1416 | data = prop_data_create_data(&name_lm[0], |
1417 | sizeof(name_lm)); | | 1417 | sizeof(name_lm)); |
1418 | prop_dictionary_set(sens, "compatible", data); | | 1418 | prop_dictionary_set(sens, "compatible", data); |
1419 | prop_object_release(data); | | 1419 | prop_object_release(data); |
1420 | prop_array_add(cfg, sens); | | 1420 | prop_array_add(cfg, sens); |
1421 | prop_object_release(sens); | | 1421 | prop_object_release(sens); |
1422 | } | | 1422 | } |
1423 | } | | 1423 | } |
1424 | | | 1424 | |
1425 | /* set properties for PCI framebuffers */ | | 1425 | /* set properties for PCI framebuffers */ |
1426 | if (device_is_a(busdev, "pci")) { | | 1426 | if (device_is_a(busdev, "pci")) { |
1427 | /* see if this is going to be console */ | | 1427 | /* see if this is going to be console */ |
1428 | struct pci_attach_args *pa = aux; | | 1428 | struct pci_attach_args *pa = aux; |
1429 | prop_dictionary_t dict; | | 1429 | prop_dictionary_t dict; |
1430 | int sub; | | 1430 | int sub; |
1431 | int console = 0; | | 1431 | int console = 0; |
1432 | | | 1432 | |
1433 | dict = device_properties(dev); | | 1433 | dict = device_properties(dev); |
1434 | | | 1434 | |
1435 | /* we only care about display devices from here on */ | | 1435 | /* we only care about display devices from here on */ |
1436 | if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY) | | 1436 | if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY) |
1437 | return; | | 1437 | return; |
1438 | | | 1438 | |
1439 | console = (ofnode == console_node); | | 1439 | console = (ofnode == console_node); |
1440 | | | 1440 | |
1441 | if (!console) { | | 1441 | if (!console) { |
1442 | /* | | 1442 | /* |
1443 | * see if any child matches since OF attaches | | 1443 | * see if any child matches since OF attaches |
1444 | * nodes for each head and /chosen/stdout | | 1444 | * nodes for each head and /chosen/stdout |
1445 | * points to the head rather than the device | | 1445 | * points to the head rather than the device |
1446 | * itself in this case | | 1446 | * itself in this case |
1447 | */ | | 1447 | */ |
1448 | sub = OF_child(ofnode); | | 1448 | sub = OF_child(ofnode); |
1449 | while ((sub != 0) && (sub != console_node)) { | | 1449 | while ((sub != 0) && (sub != console_node)) { |
1450 | sub = OF_peer(sub); | | 1450 | sub = OF_peer(sub); |
1451 | } | | 1451 | } |
1452 | if (sub == console_node) { | | 1452 | if (sub == console_node) { |
1453 | console = true; | | 1453 | console = true; |
1454 | } | | 1454 | } |
1455 | } | | 1455 | } |
1456 | | | 1456 | |
1457 | copyprops(busdev, ofnode, dict, console); | | 1457 | copyprops(busdev, ofnode, dict, console); |
1458 | | | 1458 | |
1459 | if (console) { | | 1459 | if (console) { |
1460 | uint64_t cmap_cb; | | 1460 | uint64_t cmap_cb; |
1461 | prop_dictionary_set_uint32(dict, | | 1461 | prop_dictionary_set_uint32(dict, |
1462 | "instance_handle", console_instance); | | 1462 | "instance_handle", console_instance); |
1463 | | | 1463 | |
1464 | gfb_cb.gcc_cookie = | | 1464 | gfb_cb.gcc_cookie = |
1465 | (void *)(intptr_t)console_instance; | | 1465 | (void *)(intptr_t)console_instance; |
1466 | gfb_cb.gcc_set_mapreg = of_set_palette; | | 1466 | gfb_cb.gcc_set_mapreg = of_set_palette; |
1467 | cmap_cb = (uint64_t)(uintptr_t)&gfb_cb; | | 1467 | cmap_cb = (uint64_t)(uintptr_t)&gfb_cb; |
1468 | prop_dictionary_set_uint64(dict, | | 1468 | prop_dictionary_set_uint64(dict, |
1469 | "cmap_callback", cmap_cb); | | 1469 | "cmap_callback", cmap_cb); |
1470 | } | | 1470 | } |
1471 | #ifdef notyet | | 1471 | #ifdef notyet |
1472 | else { | | 1472 | else { |
1473 | int width; | | 1473 | int width; |
1474 | | | 1474 | |
1475 | /* | | 1475 | /* |
1476 | * the idea is to 'open' display devices with no useful | | 1476 | * the idea is to 'open' display devices with no useful |
1477 | * properties, in the hope that the firmware will | | 1477 | * properties, in the hope that the firmware will |
1478 | * properly initialize them and we can run things like | | 1478 | * properly initialize them and we can run things like |
1479 | * genfb on them | | 1479 | * genfb on them |
1480 | */ | | 1480 | */ |
1481 | if (OF_getprop(node, "width", &width, sizeof(width)) | | 1481 | if (OF_getprop(node, "width", &width, sizeof(width)) |
1482 | != 4) { | | 1482 | != 4) { |
1483 | instance = OF_open(name); | | 1483 | instance = OF_open(name); |
1484 | #endif | | 1484 | #endif |
1485 | } | | 1485 | } |
1486 | | | 1486 | |
1487 | /* Hardware specific device properties */ | | 1487 | /* Hardware specific device properties */ |
1488 | if ((!strcmp(machine_model, "SUNW,Sun-Fire-V240") || | | 1488 | if ((!strcmp(machine_model, "SUNW,Sun-Fire-V240") || |
1489 | !strcmp(machine_model, "SUNW,Sun-Fire-V210"))) { | | 1489 | !strcmp(machine_model, "SUNW,Sun-Fire-V210"))) { |
1490 | device_t busparent = device_parent(busdev); | | 1490 | device_t busparent = device_parent(busdev); |
1491 | prop_dictionary_t props = device_properties(dev); | | 1491 | prop_dictionary_t props = device_properties(dev); |
1492 | | | 1492 | |
1493 | if (busparent != NULL && device_is_a(busparent, "pcfiic") && | | 1493 | if (busparent != NULL && device_is_a(busparent, "pcfiic") && |
1494 | device_is_a(dev, "adm1026hm") && props != NULL) { | | 1494 | device_is_a(dev, "adm1026hm") && props != NULL) { |
1495 | prop_dictionary_set_uint8(props, "fan_div2", 0x55); | | 1495 | prop_dictionary_set_uint8(props, "fan_div2", 0x55); |
1496 | prop_dictionary_set_bool(props, "multi_read", true); | | 1496 | prop_dictionary_set_bool(props, "multi_read", true); |
1497 | } | | 1497 | } |
1498 | } | | 1498 | } |
1499 | if (!strcmp(machine_model, "SUNW,Sun-Fire-V440")) { | | 1499 | if (!strcmp(machine_model, "SUNW,Sun-Fire-V440")) { |
1500 | device_t busparent = device_parent(busdev); | | 1500 | device_t busparent = device_parent(busdev); |
1501 | prop_dictionary_t props = device_properties(dev); | | 1501 | prop_dictionary_t props = device_properties(dev); |
1502 | if (busparent != NULL && device_is_a(busparent, "pcfiic") && | | 1502 | if (busparent != NULL && device_is_a(busparent, "pcfiic") && |
1503 | device_is_a(dev, "adm1026hm") && props != NULL) { | | 1503 | device_is_a(dev, "adm1026hm") && props != NULL) { |
1504 | prop_dictionary_set_bool(props, "multi_read", true); | | 1504 | prop_dictionary_set_bool(props, "multi_read", true); |
1505 | } | | 1505 | } |
1506 | } | | 1506 | } |
1507 | } | | 1507 | } |
1508 | | | 1508 | |
1509 | /* | | 1509 | /* |
1510 | * Called back after autoconfiguration of a device is done | | 1510 | * Called back after autoconfiguration of a device is done |
1511 | */ | | 1511 | */ |
1512 | void | | 1512 | void |
1513 | device_register_post_config(device_t dev, void *aux) | | 1513 | device_register_post_config(device_t dev, void *aux) |
1514 | { | | 1514 | { |
1515 | if (booted_device == NULL && device_is_a(dev, "sd")) { | | 1515 | if (booted_device == NULL && device_is_a(dev, "sd")) { |
1516 | struct scsipibus_attach_args *sa = aux; | | 1516 | struct scsipibus_attach_args *sa = aux; |
1517 | struct scsipi_periph *periph = sa->sa_periph; | | 1517 | struct scsipi_periph *periph = sa->sa_periph; |
1518 | uint64_t wwn = 0; | | 1518 | uint64_t wwn = 0; |
1519 | int ofnode; | | 1519 | int ofnode; |
1520 | | | 1520 | |
1521 | /* | | 1521 | /* |
1522 | * If this is a FC-AL drive it will have | | 1522 | * If this is a FC-AL drive it will have |
1523 | * aquired its WWN device property by now, | | 1523 | * aquired its WWN device property by now, |
1524 | * so we can properly match it. | | 1524 | * so we can properly match it. |
1525 | */ | | 1525 | */ |
1526 | if (prop_dictionary_get_uint64(device_properties(dev), | | 1526 | if (prop_dictionary_get_uint64(device_properties(dev), |
1527 | "port-wwn", &wwn)) { | | 1527 | "port-wwn", &wwn)) { |
1528 | /* | | 1528 | /* |
1529 | * Different to what we do in device_register, | | 1529 | * Different to what we do in device_register, |
1530 | * we do not pass the "controller" ofnode, | | 1530 | * we do not pass the "controller" ofnode, |
1531 | * because FC-AL devices attach below a "fp" node, | | 1531 | * because FC-AL devices attach below a "fp" node, |
1532 | * E.g.: /pci/SUNW,qlc@4/fp@0,0/disk | | 1532 | * E.g.: /pci/SUNW,qlc@4/fp@0,0/disk |
1533 | * and we need the parent of "disk" here. | | 1533 | * and we need the parent of "disk" here. |
1534 | */ | | 1534 | */ |
1535 | ofnode = device_ofnode( | | 1535 | ofnode = device_ofnode( |
1536 | device_parent(device_parent(dev))); | | 1536 | device_parent(device_parent(dev))); |
1537 | for (ofnode = OF_child(ofnode); | | 1537 | for (ofnode = OF_child(ofnode); |
1538 | ofnode != 0 && booted_device == NULL; | | 1538 | ofnode != 0 && booted_device == NULL; |
1539 | ofnode = OF_peer(ofnode)) { | | 1539 | ofnode = OF_peer(ofnode)) { |
1540 | dev_bi_unit_drive_match(dev, ofnode, | | 1540 | dev_bi_unit_drive_match(dev, ofnode, |
1541 | periph->periph_target, | | 1541 | periph->periph_target, |
1542 | wwn, periph->periph_lun); | | 1542 | wwn, periph->periph_lun); |
1543 | } | | 1543 | } |
1544 | } | | 1544 | } |
1545 | } | | 1545 | } |
1546 | | | 1546 | |
1547 | if (CPU_ISSUN4V) { | | 1547 | if (CPU_ISSUN4V) { |
1548 | | | 1548 | |
1549 | /* | | 1549 | /* |
1550 | * Special sun4v handling in case the kernel is running in a | | 1550 | * Special sun4v handling in case the kernel is running in a |
1551 | * secondary logical domain | | 1551 | * secondary logical domain |
1552 | * | | 1552 | * |
1553 | * The bootpath looks something like this: | | 1553 | * The bootpath looks something like this: |
1554 | * /virtual-devices@100/channel-devices@200/disk@1:a | | 1554 | * /virtual-devices@100/channel-devices@200/disk@1:a |
1555 | * | | 1555 | * |
1556 | * The device hierarchy constructed during autoconfiguration is: | | 1556 | * The device hierarchy constructed during autoconfiguration is: |
1557 | * mainbus/vbus/vdsk/scsibus/sd | | 1557 | * mainbus/vbus/vdsk/scsibus/sd |
1558 | * | | 1558 | * |
1559 | * The logic to figure out the boot device is to look at the | | 1559 | * The logic to figure out the boot device is to look at the |
1560 | * grandparent to the 'sd' device and if this is a 'vdsk' device | | 1560 | * grandparent to the 'sd' device and if this is a 'vdsk' device |
1561 | * and the ofnode matches the bootpaths ofnode then we have located | | 1561 | * and the ofnode matches the bootpaths ofnode then we have located |
1562 | * the boot device. | | 1562 | * the boot device. |
1563 | */ | | 1563 | */ |
1564 | | | 1564 | |
1565 | int ofnode; | | 1565 | int ofnode; |
1566 | | | 1566 | |
1567 | /* Cache the vdsk ofnode for later use later/below with sd device */ | | 1567 | /* Cache the vdsk ofnode for later use later/below with sd device */ |
1568 | if (device_is_a(dev, "vdsk")) { | | 1568 | if (device_is_a(dev, "vdsk")) { |
1569 | ofnode = device_ofnode(dev); | | 1569 | ofnode = device_ofnode(dev); |
1570 | device_setofnode(dev, ofnode); | | 1570 | device_setofnode(dev, ofnode); |
1571 | } | | 1571 | } |
1572 | | | 1572 | |
1573 | /* Examine if this is a sd device */ | | 1573 | /* Examine if this is a sd device */ |
1574 | if (device_is_a(dev, "sd")) { | | 1574 | if (device_is_a(dev, "sd")) { |
1575 | device_t parent = device_parent(dev); | | 1575 | device_t parent = device_parent(dev); |
1576 | device_t parent_parent = device_parent(parent); | | 1576 | device_t parent_parent = device_parent(parent); |
1577 | if (device_is_a(parent_parent, "vdsk")) { | | 1577 | if (device_is_a(parent_parent, "vdsk")) { |
1578 | ofnode = device_ofnode(parent_parent); | | 1578 | ofnode = device_ofnode(parent_parent); |
1579 | if (ofnode == ofbootpackage) { | | 1579 | if (ofnode == ofbootpackage) { |
1580 | booted_device = dev; | | 1580 | booted_device = dev; |
1581 | DPRINTF(ACDB_BOOTDEV, ("booted_device: %s\n", | | 1581 | DPRINTF(ACDB_BOOTDEV, ("booted_device: %s\n", |
1582 | device_xname(dev))); | | 1582 | device_xname(dev))); |
1583 | return; | | 1583 | return; |
1584 | } | | 1584 | } |
1585 | } | | 1585 | } |
1586 | } | | 1586 | } |
1587 | } | | 1587 | } |
1588 | | | 1588 | |
1589 | } | | 1589 | } |
1590 | | | 1590 | |
1591 | static void | | 1591 | static void |
1592 | copyprops(device_t busdev, int node, prop_dictionary_t dict, int is_console) | | 1592 | copyprops(device_t busdev, int node, prop_dictionary_t dict, int is_console) |
1593 | { | | 1593 | { |
1594 | device_t cntrlr; | | 1594 | device_t cntrlr; |
1595 | prop_dictionary_t psycho; | | 1595 | prop_dictionary_t psycho; |
1596 | paddr_t fbpa, mem_base = 0; | | 1596 | paddr_t fbpa, mem_base = 0; |
1597 | uint32_t temp, fboffset; | | 1597 | uint32_t temp, fboffset; |
1598 | uint32_t fbaddr = 0; | | 1598 | uint32_t fbaddr = 0; |
1599 | int options; | | 1599 | int options; |
1600 | char output_device[OFPATHLEN]; | | 1600 | char output_device[OFPATHLEN]; |
1601 | char *pos; | | 1601 | char *pos; |
1602 | | | 1602 | |
1603 | cntrlr = device_parent(busdev); | | 1603 | cntrlr = device_parent(busdev); |
1604 | if (cntrlr != NULL) { | | 1604 | if (cntrlr != NULL) { |
1605 | psycho = device_properties(cntrlr); | | 1605 | psycho = device_properties(cntrlr); |
1606 | prop_dictionary_get_uint64(psycho, "mem_base", &mem_base); | | 1606 | prop_dictionary_get_uint64(psycho, "mem_base", &mem_base); |
1607 | } | | 1607 | } |
1608 | | | 1608 | |
1609 | if (is_console) | | 1609 | if (is_console) |
1610 | prop_dictionary_set_bool(dict, "is_console", 1); | | 1610 | prop_dictionary_set_bool(dict, "is_console", 1); |
1611 | | | 1611 | |
1612 | of_to_uint32_prop(dict, node, "width", "width"); | | 1612 | of_to_uint32_prop(dict, node, "width", "width"); |
1613 | of_to_uint32_prop(dict, node, "height", "height"); | | 1613 | of_to_uint32_prop(dict, node, "height", "height"); |
1614 | of_to_uint32_prop(dict, node, "linebytes", "linebytes"); | | 1614 | of_to_uint32_prop(dict, node, "linebytes", "linebytes"); |
1615 | if (!of_to_uint32_prop(dict, node, "depth", "depth") && | | 1615 | if (!of_to_uint32_prop(dict, node, "depth", "depth") && |
1616 | /* Some cards have an extra space in the property name */ | | 1616 | /* Some cards have an extra space in the property name */ |
1617 | !of_to_uint32_prop(dict, node, "depth ", "depth")) { | | 1617 | !of_to_uint32_prop(dict, node, "depth ", "depth")) { |
1618 | /* | | 1618 | /* |
1619 | * XXX we should check linebytes vs. width but those | | 1619 | * XXX we should check linebytes vs. width but those |
1620 | * FBs that don't have a depth property ( /chaos/control... ) | | 1620 | * FBs that don't have a depth property ( /chaos/control... ) |
1621 | * won't have linebytes either | | 1621 | * won't have linebytes either |
1622 | */ | | 1622 | */ |
1623 | prop_dictionary_set_uint32(dict, "depth", 8); | | 1623 | prop_dictionary_set_uint32(dict, "depth", 8); |
1624 | } | | 1624 | } |
1625 | | | 1625 | |
1626 | OF_getprop(node, "address", &fbaddr, sizeof(fbaddr)); | | 1626 | OF_getprop(node, "address", &fbaddr, sizeof(fbaddr)); |
1627 | if (fbaddr != 0) { | | 1627 | if (fbaddr != 0) { |
1628 | | | 1628 | |
1629 | pmap_extract(pmap_kernel(), fbaddr, &fbpa); | | 1629 | pmap_extract(pmap_kernel(), fbaddr, &fbpa); |
1630 | #ifdef DEBUG | | 1630 | #ifdef DEBUG |
1631 | printf("membase: %lx fbpa: %lx\n", (unsigned long)mem_base, | | 1631 | printf("membase: %lx fbpa: %lx\n", (unsigned long)mem_base, |
1632 | (unsigned long)fbpa); | | 1632 | (unsigned long)fbpa); |
1633 | #endif | | 1633 | #endif |
1634 | if (mem_base == 0) { | | 1634 | if (mem_base == 0) { |
1635 | /* XXX this is guesswork */ | | 1635 | /* XXX this is guesswork */ |
1636 | fboffset = (uint32_t)(fbpa & 0xffffffff); | | 1636 | fboffset = (uint32_t)(fbpa & 0xffffffff); |
1637 | } | | 1637 | } |
1638 | fboffset = (uint32_t)(fbpa - mem_base); | | 1638 | fboffset = (uint32_t)(fbpa - mem_base); |
1639 | prop_dictionary_set_uint32(dict, "address", fboffset); | | 1639 | prop_dictionary_set_uint32(dict, "address", fboffset); |
1640 | } | | 1640 | } |
1641 | | | 1641 | |
1642 | if (!of_to_dataprop(dict, node, "EDID", "EDID")) | | 1642 | if (!of_to_dataprop(dict, node, "EDID", "EDID")) |
1643 | of_to_dataprop(dict, node, "edid", "EDID"); | | 1643 | of_to_dataprop(dict, node, "edid", "EDID"); |
1644 | | | 1644 | |
1645 | temp = 0; | | 1645 | temp = 0; |
1646 | if (OF_getprop(node, "ATY,RefCLK", &temp, sizeof(temp)) != 4) { | | 1646 | if (OF_getprop(node, "ATY,RefCLK", &temp, sizeof(temp)) != 4) { |
1647 | | | 1647 | |
1648 | OF_getprop(OF_parent(node), "ATY,RefCLK", &temp, | | 1648 | OF_getprop(OF_parent(node), "ATY,RefCLK", &temp, |
1649 | sizeof(temp)); | | 1649 | sizeof(temp)); |
1650 | } | | 1650 | } |
1651 | if (temp != 0) | | 1651 | if (temp != 0) |
1652 | prop_dictionary_set_uint32(dict, "refclk", temp / 10); | | 1652 | prop_dictionary_set_uint32(dict, "refclk", temp / 10); |
1653 | | | 1653 | |
1654 | /* | | 1654 | /* |
1655 | * finally, let's see if there's a video mode specified in | | 1655 | * finally, let's see if there's a video mode specified in |
1656 | * output-device and pass it on so drivers like radeonfb | | 1656 | * output-device and pass it on so drivers like radeonfb |
1657 | * can do their thing | | 1657 | * can do their thing |
1658 | */ | | 1658 | */ |
1659 | | | 1659 | |
1660 | if (!is_console) | | 1660 | if (!is_console) |
1661 | return; | | 1661 | return; |
1662 | | | 1662 | |
1663 | options = OF_finddevice("/options"); | | 1663 | options = OF_finddevice("/options"); |
1664 | if ((options == 0) || (options == -1)) | | 1664 | if ((options == 0) || (options == -1)) |
1665 | return; | | 1665 | return; |
1666 | if (OF_getprop(options, "output-device", output_device, OFPATHLEN) == 0) | | 1666 | if (OF_getprop(options, "output-device", output_device, OFPATHLEN) == 0) |
1667 | return; | | 1667 | return; |
1668 | /* find the mode string if there is one */ | | 1668 | /* find the mode string if there is one */ |
1669 | pos = strstr(output_device, ":r"); | | 1669 | pos = strstr(output_device, ":r"); |
1670 | if (pos == NULL) | | 1670 | if (pos == NULL) |
1671 | return; | | 1671 | return; |
1672 | prop_dictionary_set_cstring(dict, "videomode", pos + 2); | | 1672 | prop_dictionary_set_string(dict, "videomode", pos + 2); |
1673 | } | | 1673 | } |
1674 | | | 1674 | |
1675 | static void | | 1675 | static void |
1676 | of_set_palette(void *cookie, int index, int r, int g, int b) | | 1676 | of_set_palette(void *cookie, int index, int r, int g, int b) |
1677 | { | | 1677 | { |
1678 | int ih = (int)((intptr_t)cookie); | | 1678 | int ih = (int)((intptr_t)cookie); |
1679 | | | 1679 | |
1680 | OF_call_method_1("color!", ih, 4, r, g, b, index); | | 1680 | OF_call_method_1("color!", ih, 4, r, g, b, index); |
1681 | } | | 1681 | } |