| @@ -1,359 +1,359 @@ | | | @@ -1,359 +1,359 @@ |
1 | /* $NetBSD: boot.c,v 1.29 2018/06/06 22:56:25 uwe Exp $ */ | | 1 | /* $NetBSD: boot.c,v 1.30 2020/04/23 00:12:28 joerg Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe. | | 8 | * by Jason R. Thorpe. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * | | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Copyright (C) 1995, 1996 Wolfgang Solfrank. | | 33 | * Copyright (C) 1995, 1996 Wolfgang Solfrank. |
34 | * Copyright (C) 1995, 1996 TooLs GmbH. | | 34 | * Copyright (C) 1995, 1996 TooLs GmbH. |
35 | * All rights reserved. | | 35 | * All rights reserved. |
36 | * | | 36 | * |
37 | * ELF support derived from NetBSD/alpha's boot loader, written | | 37 | * ELF support derived from NetBSD/alpha's boot loader, written |
38 | * by Christopher G. Demetriou. | | 38 | * by Christopher G. Demetriou. |
39 | * | | 39 | * |
40 | * Redistribution and use in source and binary forms, with or without | | 40 | * Redistribution and use in source and binary forms, with or without |
41 | * modification, are permitted provided that the following conditions | | 41 | * modification, are permitted provided that the following conditions |
42 | * are met: | | 42 | * are met: |
43 | * 1. Redistributions of source code must retain the above copyright | | 43 | * 1. Redistributions of source code must retain the above copyright |
44 | * notice, this list of conditions and the following disclaimer. | | 44 | * notice, this list of conditions and the following disclaimer. |
45 | * 2. Redistributions in binary form must reproduce the above copyright | | 45 | * 2. Redistributions in binary form must reproduce the above copyright |
46 | * notice, this list of conditions and the following disclaimer in the | | 46 | * notice, this list of conditions and the following disclaimer in the |
47 | * documentation and/or other materials provided with the distribution. | | 47 | * documentation and/or other materials provided with the distribution. |
48 | * 3. All advertising materials mentioning features or use of this software | | 48 | * 3. All advertising materials mentioning features or use of this software |
49 | * must display the following acknowledgement: | | 49 | * must display the following acknowledgement: |
50 | * This product includes software developed by TooLs GmbH. | | 50 | * This product includes software developed by TooLs GmbH. |
51 | * 4. The name of TooLs GmbH may not be used to endorse or promote products | | 51 | * 4. The name of TooLs GmbH may not be used to endorse or promote products |
52 | * derived from this software without specific prior written permission. | | 52 | * derived from this software without specific prior written permission. |
53 | * | | 53 | * |
54 | * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR | | 54 | * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR |
55 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 55 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
56 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 56 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
57 | * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | | 57 | * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
58 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | | 58 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
59 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | | 59 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
60 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | | 60 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
61 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | | 61 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
62 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | | 62 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
63 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 63 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
64 | */ | | 64 | */ |
65 | | | 65 | |
66 | /* | | 66 | /* |
67 | * First try for the boot code | | 67 | * First try for the boot code |
68 | * | | 68 | * |
69 | * Input syntax is: | | 69 | * Input syntax is: |
70 | * [promdev[{:|,}partition]]/[filename] [flags] | | 70 | * [promdev[{:|,}partition]]/[filename] [flags] |
71 | */ | | 71 | */ |
72 | | | 72 | |
73 | #include "boot.h" | | 73 | #include "boot.h" |
74 | | | 74 | |
75 | #include <sys/param.h> | | 75 | #include <sys/param.h> |
76 | #include <sys/boot_flag.h> | | 76 | #include <sys/boot_flag.h> |
77 | #include <sys/disklabel.h> | | 77 | #include <sys/disklabel.h> |
78 | | | 78 | |
79 | #include <lib/libsa/stand.h> | | 79 | #include <lib/libsa/stand.h> |
80 | #include <lib/libsa/loadfile.h> | | 80 | #include <lib/libsa/loadfile.h> |
81 | #include <lib/libkern/libkern.h> | | 81 | #include <lib/libkern/libkern.h> |
82 | | | 82 | |
83 | #include "ofdev.h" | | 83 | #include "ofdev.h" |
84 | #include "openfirm.h" | | 84 | #include "openfirm.h" |
85 | | | 85 | |
86 | extern void __syncicache(void *, size_t); /* in libkern */ | | 86 | extern void __syncicache(void *, size_t); /* in libkern */ |
87 | | | 87 | |
88 | | | 88 | |
89 | #ifdef DEBUG | | 89 | #ifdef DEBUG |
90 | # define DPRINTF printf | | 90 | # define DPRINTF printf |
91 | #else | | 91 | #else |
92 | # define DPRINTF while (0) printf | | 92 | # define DPRINTF while (0) printf |
93 | #endif | | 93 | #endif |
94 | | | 94 | |
95 | char bootdev[MAXBOOTPATHLEN]; | | 95 | char bootdev[MAXBOOTPATHLEN]; |
96 | char bootfile[MAXBOOTPATHLEN]; | | 96 | extern char bootfile[MAXBOOTPATHLEN]; |
97 | int boothowto; | | 97 | int boothowto; |
98 | bool floppyboot; | | 98 | bool floppyboot; |
99 | int ofw_version = 0; | | 99 | int ofw_version = 0; |
100 | | | 100 | |
101 | static const char *kernels[] = { "/netbsd", "/netbsd.gz", "/netbsd.macppc", NULL }; | | 101 | static const char *kernels[] = { "/netbsd", "/netbsd.gz", "/netbsd.macppc", NULL }; |
102 | | | 102 | |
103 | static void | | 103 | static void |
104 | prom2boot(char *dev) | | 104 | prom2boot(char *dev) |
105 | { | | 105 | { |
106 | char *cp; | | 106 | char *cp; |
107 | | | 107 | |
108 | cp = dev + strlen(dev) - 1; | | 108 | cp = dev + strlen(dev) - 1; |
109 | for (; *cp; cp--) { | | 109 | for (; *cp; cp--) { |
110 | if (*cp == ':') { | | 110 | if (*cp == ':') { |
111 | if (ofw_version < 3) { | | 111 | if (ofw_version < 3) { |
112 | /* sd@0:0 -> sd@0 */ | | 112 | /* sd@0:0 -> sd@0 */ |
113 | *cp = 0; | | 113 | *cp = 0; |
114 | break; | | 114 | break; |
115 | } else { | | 115 | } else { |
116 | /* disk@0:5,boot -> disk@0:0 */ | | 116 | /* disk@0:5,boot -> disk@0:0 */ |
117 | strcpy(cp, ":0"); | | 117 | strcpy(cp, ":0"); |
118 | break; | | 118 | break; |
119 | } | | 119 | } |
120 | } | | 120 | } |
121 | } | | 121 | } |
122 | } | | 122 | } |
123 | | | 123 | |
124 | static void | | 124 | static void |
125 | parseargs(char *str, int *howtop) | | 125 | parseargs(char *str, int *howtop) |
126 | { | | 126 | { |
127 | char *cp; | | 127 | char *cp; |
128 | | | 128 | |
129 | /* Allow user to drop back to the PROM. */ | | 129 | /* Allow user to drop back to the PROM. */ |
130 | if (strcmp(str, "exit") == 0) | | 130 | if (strcmp(str, "exit") == 0) |
131 | OF_exit(); | | 131 | OF_exit(); |
132 | | | 132 | |
133 | *howtop = 0; | | 133 | *howtop = 0; |
134 | | | 134 | |
135 | cp = str; | | 135 | cp = str; |
136 | if (*cp == '-') | | 136 | if (*cp == '-') |
137 | goto found; | | 137 | goto found; |
138 | for (cp = str; *cp; cp++) | | 138 | for (cp = str; *cp; cp++) |
139 | if (*cp == ' ') | | 139 | if (*cp == ' ') |
140 | goto found; | | 140 | goto found; |
141 | return; | | 141 | return; |
142 | | | 142 | |
143 | found: | | 143 | found: |
144 | *cp++ = 0; | | 144 | *cp++ = 0; |
145 | while (*cp) | | 145 | while (*cp) |
146 | BOOT_FLAG(*cp++, *howtop); | | 146 | BOOT_FLAG(*cp++, *howtop); |
147 | } | | 147 | } |
148 | | | 148 | |
149 | static bool | | 149 | static bool |
150 | is_floppyboot(const char *path, const char *defaultdev) | | 150 | is_floppyboot(const char *path, const char *defaultdev) |
151 | { | | 151 | { |
152 | char dev[MAXBOOTPATHLEN]; | | 152 | char dev[MAXBOOTPATHLEN]; |
153 | char nam[16]; | | 153 | char nam[16]; |
154 | int handle, rv; | | 154 | int handle, rv; |
155 | | | 155 | |
156 | if (parsefilepath(path, dev, NULL, NULL)) { | | 156 | if (parsefilepath(path, dev, NULL, NULL)) { |
157 | if (dev[0] == '\0' && defaultdev != NULL) | | 157 | if (dev[0] == '\0' && defaultdev != NULL) |
158 | strlcpy(dev, defaultdev, sizeof(dev)); | | 158 | strlcpy(dev, defaultdev, sizeof(dev)); |
159 | | | 159 | |
160 | /* check properties */ | | 160 | /* check properties */ |
161 | handle = OF_finddevice(dev); | | 161 | handle = OF_finddevice(dev); |
162 | if (handle != -1) { | | 162 | if (handle != -1) { |
163 | rv = OF_getprop(handle, "name", nam, sizeof(nam)); | | 163 | rv = OF_getprop(handle, "name", nam, sizeof(nam)); |
164 | if (rv >= 0 && | | 164 | if (rv >= 0 && |
165 | (strcmp(nam, "swim3") == 0 || | | 165 | (strcmp(nam, "swim3") == 0 || |
166 | strcmp(nam, "floppy") == 0)) | | 166 | strcmp(nam, "floppy") == 0)) |
167 | return true; | | 167 | return true; |
168 | } | | 168 | } |
169 | | | 169 | |
170 | /* also check devalias */ | | 170 | /* also check devalias */ |
171 | if (strcmp(dev, "fd") == 0) | | 171 | if (strcmp(dev, "fd") == 0) |
172 | return true; | | 172 | return true; |
173 | } | | 173 | } |
174 | | | 174 | |
175 | return false; | | 175 | return false; |
176 | } | | 176 | } |
177 | | | 177 | |
178 | static void | | 178 | static void |
179 | chain(boot_entry_t entry, char *args, void *ssym, void *esym) | | 179 | chain(boot_entry_t entry, char *args, void *ssym, void *esym) |
180 | { | | 180 | { |
181 | extern char end[]; | | 181 | extern char end[]; |
182 | int l; | | 182 | int l; |
183 | | | 183 | |
184 | #if !defined(HEAP_VARIABLE) | | 184 | #if !defined(HEAP_VARIABLE) |
185 | freeall(); | | 185 | freeall(); |
186 | #endif | | 186 | #endif |
187 | | | 187 | |
188 | /* | | 188 | /* |
189 | * Stash pointer to end of symbol table after the argument | | 189 | * Stash pointer to end of symbol table after the argument |
190 | * strings. | | 190 | * strings. |
191 | */ | | 191 | */ |
192 | l = strlen(args) + 1; | | 192 | l = strlen(args) + 1; |
193 | memcpy(args + l, &ssym, sizeof(ssym)); | | 193 | memcpy(args + l, &ssym, sizeof(ssym)); |
194 | l += sizeof(ssym); | | 194 | l += sizeof(ssym); |
195 | memcpy(args + l, &esym, sizeof(esym)); | | 195 | memcpy(args + l, &esym, sizeof(esym)); |
196 | l += sizeof(esym); | | 196 | l += sizeof(esym); |
197 | l += sizeof(int); /* XXX */ | | 197 | l += sizeof(int); /* XXX */ |
198 | | | 198 | |
199 | OF_chain((void *) RELOC, end - (char *) RELOC, entry, args, l); | | 199 | OF_chain((void *) RELOC, end - (char *) RELOC, entry, args, l); |
200 | panic("chain"); | | 200 | panic("chain"); |
201 | } | | 201 | } |
202 | | | 202 | |
203 | __dead void | | 203 | __dead void |
204 | _rtt(void) | | 204 | _rtt(void) |
205 | { | | 205 | { |
206 | | | 206 | |
207 | OF_exit(); | | 207 | OF_exit(); |
208 | } | | 208 | } |
209 | | | 209 | |
210 | void | | 210 | void |
211 | main(void) | | 211 | main(void) |
212 | { | | 212 | { |
213 | extern char bootprog_name[], bootprog_rev[]; | | 213 | extern char bootprog_name[], bootprog_rev[]; |
214 | int chosen, options, openprom; | | 214 | int chosen, options, openprom; |
215 | char bootline[512]; /* Should check size? */ | | 215 | char bootline[512]; /* Should check size? */ |
216 | char *cp; | | 216 | char *cp; |
217 | u_long marks[MARK_MAX]; | | 217 | u_long marks[MARK_MAX]; |
218 | u_int32_t entry; | | 218 | u_int32_t entry; |
219 | void *ssym, *esym; | | 219 | void *ssym, *esym; |
220 | | | 220 | |
221 | printf("\n"); | | 221 | printf("\n"); |
222 | printf(">> %s, Revision %s\n", bootprog_name, bootprog_rev); | | 222 | printf(">> %s, Revision %s\n", bootprog_name, bootprog_rev); |
223 | | | 223 | |
224 | /* | | 224 | /* |
225 | * Figure out what version of Open Firmware... | | 225 | * Figure out what version of Open Firmware... |
226 | */ | | 226 | */ |
227 | if ((openprom = OF_finddevice("/openprom")) != -1) { | | 227 | if ((openprom = OF_finddevice("/openprom")) != -1) { |
228 | char model[32]; | | 228 | char model[32]; |
229 | | | 229 | |
230 | memset(model, 0, sizeof model); | | 230 | memset(model, 0, sizeof model); |
231 | OF_getprop(openprom, "model", model, sizeof model); | | 231 | OF_getprop(openprom, "model", model, sizeof model); |
232 | for (cp = model; *cp; cp++) | | 232 | for (cp = model; *cp; cp++) |
233 | if (*cp >= '0' && *cp <= '9') { | | 233 | if (*cp >= '0' && *cp <= '9') { |
234 | ofw_version = *cp - '0'; | | 234 | ofw_version = *cp - '0'; |
235 | break; | | 235 | break; |
236 | } | | 236 | } |
237 | DPRINTF(">> Open Firmware version %d.x\n", ofw_version); | | 237 | DPRINTF(">> Open Firmware version %d.x\n", ofw_version); |
238 | } | | 238 | } |
239 | | | 239 | |
240 | /* | | 240 | /* |
241 | * Get the boot arguments from Openfirmware | | 241 | * Get the boot arguments from Openfirmware |
242 | */ | | 242 | */ |
243 | if ((chosen = OF_finddevice("/chosen")) == -1 || | | 243 | if ((chosen = OF_finddevice("/chosen")) == -1 || |
244 | OF_getprop(chosen, "bootpath", bootdev, sizeof bootdev) < 0 || | | 244 | OF_getprop(chosen, "bootpath", bootdev, sizeof bootdev) < 0 || |
245 | OF_getprop(chosen, "bootargs", bootline, sizeof bootline) < 0) { | | 245 | OF_getprop(chosen, "bootargs", bootline, sizeof bootline) < 0) { |
246 | printf("Invalid Openfirmware environment\n"); | | 246 | printf("Invalid Openfirmware environment\n"); |
247 | OF_exit(); | | 247 | OF_exit(); |
248 | } | | 248 | } |
249 | | | 249 | |
250 | /* | | 250 | /* |
251 | * Some versions of Openfirmware sets bootpath to "". | | 251 | * Some versions of Openfirmware sets bootpath to "". |
252 | * We use boot-device instead if it occurs. | | 252 | * We use boot-device instead if it occurs. |
253 | */ | | 253 | */ |
254 | if (bootdev[0] == 0) { | | 254 | if (bootdev[0] == 0) { |
255 | printf("Cannot use bootpath\n"); | | 255 | printf("Cannot use bootpath\n"); |
256 | if ((options = OF_finddevice("/options")) == -1 || | | 256 | if ((options = OF_finddevice("/options")) == -1 || |
257 | OF_getprop(options, "boot-device", bootdev, | | 257 | OF_getprop(options, "boot-device", bootdev, |
258 | sizeof bootdev) < 0) { | | 258 | sizeof bootdev) < 0) { |
259 | printf("Invalid Openfirmware environment\n"); | | 259 | printf("Invalid Openfirmware environment\n"); |
260 | OF_exit(); | | 260 | OF_exit(); |
261 | } | | 261 | } |
262 | printf("Using boot-device instead\n"); | | 262 | printf("Using boot-device instead\n"); |
263 | } | | 263 | } |
264 | | | 264 | |
265 | prom2boot(bootdev); | | 265 | prom2boot(bootdev); |
266 | parseargs(bootline, &boothowto); | | 266 | parseargs(bootline, &boothowto); |
267 | DPRINTF("bootline=%s\n", bootline); | | 267 | DPRINTF("bootline=%s\n", bootline); |
268 | | | 268 | |
269 | for (;;) { | | 269 | for (;;) { |
270 | int i, loadflag; | | 270 | int i, loadflag; |
271 | | | 271 | |
272 | if (boothowto & RB_ASKNAME) { | | 272 | if (boothowto & RB_ASKNAME) { |
273 | printf("Boot: "); | | 273 | printf("Boot: "); |
274 | kgets(bootline, sizeof(bootline)); | | 274 | kgets(bootline, sizeof(bootline)); |
275 | parseargs(bootline, &boothowto); | | 275 | parseargs(bootline, &boothowto); |
276 | } | | 276 | } |
277 | | | 277 | |
278 | if (bootline[0]) { | | 278 | if (bootline[0]) { |
279 | kernels[0] = bootline; | | 279 | kernels[0] = bootline; |
280 | kernels[1] = NULL; | | 280 | kernels[1] = NULL; |
281 | } | | 281 | } |
282 | | | 282 | |
283 | for (i = 0; kernels[i]; i++) { | | 283 | for (i = 0; kernels[i]; i++) { |
284 | floppyboot = is_floppyboot(kernels[i], bootdev); | | 284 | floppyboot = is_floppyboot(kernels[i], bootdev); |
285 | | | 285 | |
286 | DPRINTF("Trying %s%s\n", kernels[i], | | 286 | DPRINTF("Trying %s%s\n", kernels[i], |
287 | floppyboot ? " (floppyboot)" : ""); | | 287 | floppyboot ? " (floppyboot)" : ""); |
288 | | | 288 | |
289 | loadflag = LOAD_KERNEL; | | 289 | loadflag = LOAD_KERNEL; |
290 | if (floppyboot) | | 290 | if (floppyboot) |
291 | loadflag &= ~LOAD_BACKWARDS; | | 291 | loadflag &= ~LOAD_BACKWARDS; |
292 | | | 292 | |
293 | marks[MARK_START] = 0; | | 293 | marks[MARK_START] = 0; |
294 | if (loadfile(kernels[i], marks, loadflag) >= 0) | | 294 | if (loadfile(kernels[i], marks, loadflag) >= 0) |
295 | goto loaded; | | 295 | goto loaded; |
296 | } | | 296 | } |
297 | boothowto |= RB_ASKNAME; | | 297 | boothowto |= RB_ASKNAME; |
298 | } | | 298 | } |
299 | loaded: | | 299 | loaded: |
300 | | | 300 | |
301 | #ifdef __notyet__ | | 301 | #ifdef __notyet__ |
302 | OF_setprop(chosen, "bootpath", opened_name, strlen(opened_name) + 1); | | 302 | OF_setprop(chosen, "bootpath", opened_name, strlen(opened_name) + 1); |
303 | cp = bootline; | | 303 | cp = bootline; |
304 | #else | | 304 | #else |
305 | strcpy(bootline, opened_name); | | 305 | strcpy(bootline, opened_name); |
306 | cp = bootline + strlen(bootline); | | 306 | cp = bootline + strlen(bootline); |
307 | *cp++ = ' '; | | 307 | *cp++ = ' '; |
308 | #endif | | 308 | #endif |
309 | *cp = '-'; | | 309 | *cp = '-'; |
310 | if (boothowto & RB_ASKNAME) | | 310 | if (boothowto & RB_ASKNAME) |
311 | *++cp = 'a'; | | 311 | *++cp = 'a'; |
312 | if (boothowto & RB_USERCONF) | | 312 | if (boothowto & RB_USERCONF) |
313 | *++cp = 'c'; | | 313 | *++cp = 'c'; |
314 | if (boothowto & RB_SINGLE) | | 314 | if (boothowto & RB_SINGLE) |
315 | *++cp = 's'; | | 315 | *++cp = 's'; |
316 | if (boothowto & RB_KDB) | | 316 | if (boothowto & RB_KDB) |
317 | *++cp = 'd'; | | 317 | *++cp = 'd'; |
318 | if (*cp == '-') | | 318 | if (*cp == '-') |
319 | #ifdef __notyet__ | | 319 | #ifdef __notyet__ |
320 | *cp = 0; | | 320 | *cp = 0; |
321 | #else | | 321 | #else |
322 | *--cp = 0; | | 322 | *--cp = 0; |
323 | #endif | | 323 | #endif |
324 | else | | 324 | else |
325 | *++cp = 0; | | 325 | *++cp = 0; |
326 | #ifdef __notyet__ | | 326 | #ifdef __notyet__ |
327 | OF_setprop(chosen, "bootargs", bootline, strlen(bootline) + 1); | | 327 | OF_setprop(chosen, "bootargs", bootline, strlen(bootline) + 1); |
328 | #endif | | 328 | #endif |
329 | | | 329 | |
330 | entry = marks[MARK_ENTRY]; | | 330 | entry = marks[MARK_ENTRY]; |
331 | ssym = (void *)marks[MARK_SYM]; | | 331 | ssym = (void *)marks[MARK_SYM]; |
332 | esym = (void *)marks[MARK_END]; | | 332 | esym = (void *)marks[MARK_END]; |
333 | | | 333 | |
334 | printf(" start=0x%x\n", entry); | | 334 | printf(" start=0x%x\n", entry); |
335 | __syncicache((void *)(uintptr_t)entry, (size_t)ssym - entry); | | 335 | __syncicache((void *)(uintptr_t)entry, (size_t)ssym - entry); |
336 | chain((boot_entry_t)(uintptr_t)entry, bootline, ssym, esym); | | 336 | chain((boot_entry_t)(uintptr_t)entry, bootline, ssym, esym); |
337 | | | 337 | |
338 | OF_exit(); | | 338 | OF_exit(); |
339 | } | | 339 | } |
340 | | | 340 | |
341 | #ifdef HAVE_CHANGEDISK_HOOK | | 341 | #ifdef HAVE_CHANGEDISK_HOOK |
342 | void | | 342 | void |
343 | changedisk_hook(struct open_file *of) | | 343 | changedisk_hook(struct open_file *of) |
344 | { | | 344 | { |
345 | struct of_dev *op = of->f_devdata; | | 345 | struct of_dev *op = of->f_devdata; |
346 | int c; | | 346 | int c; |
347 | | | 347 | |
348 | OF_call_method("eject", op->handle, 0, 0); | | 348 | OF_call_method("eject", op->handle, 0, 0); |
349 | | | 349 | |
350 | c = getchar(); | | 350 | c = getchar(); |
351 | if (c == 'q') { | | 351 | if (c == 'q') { |
352 | printf("quit\n"); | | 352 | printf("quit\n"); |
353 | OF_exit(); | | 353 | OF_exit(); |
354 | } | | 354 | } |
355 | | | 355 | |
356 | OF_call_method("close", op->handle, 0, 0); | | 356 | OF_call_method("close", op->handle, 0, 0); |
357 | OF_call_method("open", op->handle, 0, 0); | | 357 | OF_call_method("open", op->handle, 0, 0); |
358 | } | | 358 | } |
359 | #endif | | 359 | #endif |