loadbsd.c revision 1.13 1 1.1 itohy /*
2 1.1 itohy * Load and boot NetBSD kernel on Human68k
3 1.1 itohy *
4 1.1 itohy * written by Yasha (ITOH Yasufumi)
5 1.1 itohy * public domain
6 1.1 itohy *
7 1.1 itohy * loadbsd [-hvV] [-abDs] [-r root_device] netbsd
8 1.1 itohy *
9 1.1 itohy * loadbsd options:
10 1.1 itohy * -h help
11 1.1 itohy * -V print version and exit
12 1.1 itohy *
13 1.1 itohy * kernel options:
14 1.1 itohy * -a auto boot, opposite of -s
15 1.1 itohy * -s single user boot (default)
16 1.1 itohy * -D enter kernel debugger
17 1.1 itohy * -b ask root device
18 1.1 itohy * -r specify root device
19 1.6 jdolecek * -q quiet boot
20 1.6 jdolecek * -v verbose boot (also turn on verbosity of loadbsd)
21 1.1 itohy *
22 1.13 cegger * $NetBSD: loadbsd.c,v 1.13 2009/03/18 10:22:38 cegger Exp $
23 1.1 itohy */
24 1.1 itohy
25 1.1 itohy #include <sys/cdefs.h>
26 1.1 itohy
27 1.13 cegger __RCSID("$NetBSD: loadbsd.c,v 1.13 2009/03/18 10:22:38 cegger Exp $");
28 1.13 cegger #define VERSION "$Revision: 1.13 $ $Date: 2009/03/18 10:22:38 $"
29 1.1 itohy
30 1.1 itohy #include <sys/types.h> /* ntohl */
31 1.1 itohy #include <sys/reboot.h>
32 1.1 itohy #include <sys/param.h> /* ALIGN, ALIGNBYTES */
33 1.1 itohy #include <a.out.h>
34 1.8 isaki #include <sys/exec_elf.h>
35 1.1 itohy #include <string.h>
36 1.1 itohy #include <machine/bootinfo.h>
37 1.1 itohy
38 1.1 itohy #include <dos.h>
39 1.1 itohy #include <iocs.h>
40 1.1 itohy #include "../common/xprintf.h"
41 1.1 itohy #include "trampoline.h"
42 1.1 itohy
43 1.1 itohy #define DEFAULT_ROOTDEVNAME "sd@0,0:a"
44 1.1 itohy
45 1.1 itohy #define ISDIGIT(c) ((c) >= '0' && (c) <= '9')
46 1.1 itohy
47 1.1 itohy #define GETDECIMAL(var, str) \
48 1.1 itohy do { var *= 10; var += *str++ - '0'; } while (ISDIGIT(*str))
49 1.1 itohy
50 1.10 dsl static const char *lookupif(const char *name,
51 1.10 dsl unsigned *pif, unsigned *punit);
52 1.10 dsl static void get_current_scsi_interface(unsigned *pif, unsigned *punit);
53 1.10 dsl static int bootdev(const char *devstr);
54 1.10 dsl static struct tramparg *read_kernel(const char *fn);
55 1.10 dsl static int chkmpu(void);
56 1.10 dsl static __dead void usage(int status, const char *msg)
57 1.1 itohy __attribute__((noreturn));
58 1.1 itohy
59 1.10 dsl int main(int argc, char *argv[]);
60 1.1 itohy
61 1.1 itohy int opt_v;
62 1.1 itohy int opt_N;
63 1.8 isaki const char *kernel_fn;
64 1.1 itohy
65 1.1 itohy const struct hatbl {
66 1.1 itohy char name[4];
67 1.1 itohy unsigned short id;
68 1.1 itohy } hatable[] = {
69 1.1 itohy X68K_BOOT_SCSIIF_LIST
70 1.1 itohy };
71 1.1 itohy
72 1.1 itohy /*
73 1.1 itohy * parse interface name
74 1.3 itohy * return the next position
75 1.1 itohy */
76 1.1 itohy static const char *
77 1.12 dsl lookupif(const char *name, unsigned *pif, unsigned *punit)
78 1.1 itohy {
79 1.1 itohy unsigned u, unit;
80 1.1 itohy const char *p;
81 1.1 itohy
82 1.1 itohy for (u = 0; u < sizeof hatable / sizeof hatable[0]; u++) {
83 1.1 itohy const char *n;
84 1.1 itohy
85 1.1 itohy for (n = hatable[u].name, p = name; *n && *n == *p; n++, p++)
86 1.1 itohy ;
87 1.1 itohy if (!*n)
88 1.1 itohy goto found;
89 1.1 itohy }
90 1.1 itohy /* not found */
91 1.1 itohy return (char *) 0;
92 1.1 itohy
93 1.1 itohy found:
94 1.1 itohy if (*p == '@')
95 1.1 itohy p++;
96 1.1 itohy
97 1.1 itohy /* get unit # */
98 1.1 itohy if (!ISDIGIT(*p))
99 1.1 itohy return (char *) 0;
100 1.1 itohy
101 1.1 itohy unit = 0;
102 1.1 itohy GETDECIMAL(unit, p);
103 1.1 itohy
104 1.1 itohy *pif = hatable[u].id;
105 1.1 itohy *punit = unit;
106 1.1 itohy
107 1.1 itohy return p;
108 1.1 itohy }
109 1.1 itohy
110 1.1 itohy /*
111 1.1 itohy * if the SCSI interface is not specified, use the current one
112 1.1 itohy */
113 1.1 itohy static void
114 1.12 dsl get_current_scsi_interface(unsigned *pif, unsigned *punit)
115 1.1 itohy {
116 1.1 itohy unsigned binf;
117 1.1 itohy char *bootrom;
118 1.1 itohy int bus_err_buf;
119 1.1 itohy
120 1.1 itohy binf = (unsigned) IOCS_BOOTINF();
121 1.1 itohy if (binf < 0x00fc0000)
122 1.1 itohy return; /* not booted from SCSI */
123 1.1 itohy
124 1.1 itohy bootrom = (char *) (binf & 0x00ffffe0);
125 1.1 itohy if (IOCS_B_LPEEK(bootrom + 0x24) == 0x53435349 && /* 'SCSI' */
126 1.1 itohy IOCS_B_WPEEK(bootrom + 0x28) == 0x494E) { /* 'IN' */
127 1.1 itohy /* spc0 */
128 1.1 itohy *pif = X68K_BOOT_SCSIIF_SPC;
129 1.1 itohy *punit = 0;
130 1.1 itohy } else if (DOS_BUS_ERR(&bus_err_buf, (void *)EXSPC_BDID, 1)) {
131 1.1 itohy /* mha0 */
132 1.1 itohy *pif = X68K_BOOT_SCSIIF_MHA;
133 1.1 itohy *punit = 0;
134 1.1 itohy } else {
135 1.1 itohy /* spc1 */
136 1.1 itohy *pif = X68K_BOOT_SCSIIF_SPC;
137 1.1 itohy *punit = 1;
138 1.1 itohy }
139 1.1 itohy }
140 1.1 itohy
141 1.1 itohy /*
142 1.1 itohy * parse device name
143 1.1 itohy *
144 1.1 itohy * [/<controller>@<unit>/]<device>@<unit>[,<lun>][:<partition>]
145 1.1 itohy *
146 1.1 itohy * <unit> must be target SCSI ID if <device> is a SCSI device
147 1.1 itohy *
148 1.1 itohy * full form:
149 1.1 itohy * /spc@0/sd@1,2:e
150 1.1 itohy *
151 1.1 itohy * partial form:
152 1.3 itohy * /mha@0/sd@1 = /mha@0/sd@1,0:a
153 1.1 itohy * sd@1:e = /current_device/sd@1,0e
154 1.1 itohy * sd@1,2:e = /current_device/sd@1,2:e
155 1.1 itohy */
156 1.1 itohy
157 1.1 itohy const struct devtbl {
158 1.1 itohy char name[3];
159 1.1 itohy u_char major;
160 1.1 itohy } devtable[] = {
161 1.4 minoura X68K_BOOT_DEV_LIST,
162 1.4 minoura X68K_BOOT_NETIF_LIST
163 1.1 itohy };
164 1.1 itohy
165 1.1 itohy static int
166 1.11 dsl bootdev(const char *devstr)
167 1.1 itohy {
168 1.1 itohy unsigned u;
169 1.1 itohy unsigned major, unit, lun, partition;
170 1.1 itohy int dev;
171 1.1 itohy const char *s = devstr;
172 1.1 itohy unsigned interface = 0, unit_if = 0;
173 1.1 itohy
174 1.1 itohy if (*s == '/') {
175 1.1 itohy /*
176 1.1 itohy * /<interface>/<device>"
177 1.1 itohy * "/spc@1/sd@2,3:e"
178 1.1 itohy */
179 1.1 itohy while (*++s == '/') /* skip slashes */
180 1.1 itohy ;
181 1.1 itohy if (!strchr(s, '/'))
182 1.1 itohy xerrx(1, "%s: bad format", devstr);
183 1.1 itohy
184 1.1 itohy if (!(s = lookupif(s, &interface, &unit_if)))
185 1.1 itohy xerrx(1, "%s: unknown interface", devstr);
186 1.1 itohy
187 1.1 itohy while (*s == '/') /* skip slashes */
188 1.1 itohy s++;
189 1.1 itohy } else {
190 1.1 itohy /* make lint happy */
191 1.1 itohy interface = 0;
192 1.1 itohy unit_if = 0;
193 1.1 itohy }
194 1.1 itohy
195 1.1 itohy /* allow r at the top */
196 1.1 itohy if (*s == 'r')
197 1.1 itohy s++;
198 1.1 itohy
199 1.1 itohy for (u = 0; u < sizeof devtable / sizeof devtable[0]; u++)
200 1.1 itohy if (s[0] == devtable[u].name[0] && s[1] == devtable[u].name[1])
201 1.1 itohy goto found;
202 1.1 itohy
203 1.1 itohy /* not found */
204 1.1 itohy xerrx(1, "%s: unknown device", devstr);
205 1.1 itohy
206 1.1 itohy found: major = devtable[u].major;
207 1.1 itohy
208 1.1 itohy /*
209 1.1 itohy * <type>@unit[,lun][:part]
210 1.1 itohy * "sd@1,3:a"
211 1.1 itohy */
212 1.1 itohy
213 1.1 itohy /* get device unit # */
214 1.1 itohy s += 2;
215 1.1 itohy if (*s == '@')
216 1.1 itohy s++;
217 1.1 itohy if (!*s)
218 1.1 itohy xerrx(1, "%s: missing unit number", devstr);
219 1.1 itohy if (!ISDIGIT(*s))
220 1.1 itohy xerrx(1, "%s: wrong device", devstr);
221 1.1 itohy
222 1.1 itohy unit = 0;
223 1.1 itohy GETDECIMAL(unit, s);
224 1.1 itohy
225 1.1 itohy lun = 0;
226 1.1 itohy if (*s == ',') {
227 1.1 itohy s++;
228 1.1 itohy if (!ISDIGIT(*s))
229 1.1 itohy xerrx(1, "%s: wrong device", devstr);
230 1.1 itohy GETDECIMAL(lun, s);
231 1.1 itohy }
232 1.1 itohy
233 1.1 itohy /* get device partition */
234 1.1 itohy if (*s == ':')
235 1.1 itohy s++;
236 1.1 itohy if (!*s)
237 1.1 itohy partition = 0; /* no partition letter -- assuming 'a' */
238 1.1 itohy else if (!s[1])
239 1.1 itohy partition = *s - 'a';
240 1.1 itohy else
241 1.1 itohy xerrx(1, "%s: wrong partition letter", devstr);
242 1.1 itohy
243 1.1 itohy /*
244 1.1 itohy * sanity check
245 1.1 itohy */
246 1.1 itohy if (unit_if >= 16)
247 1.1 itohy xerrx(1, "%s: interface unit # too large", devstr);
248 1.1 itohy if (unit >= 16)
249 1.1 itohy xerrx(1, "%s: device unit # too large", devstr);
250 1.1 itohy if (lun >= 8)
251 1.1 itohy xerrx(1, "%s: SCSI LUN >= 8 is not supported yet", devstr);
252 1.1 itohy if (partition >= 16)
253 1.1 itohy xerrx(1, "%s: unsupported partition", devstr);
254 1.1 itohy
255 1.1 itohy /*
256 1.1 itohy * encode device to be passed to kernel
257 1.1 itohy */
258 1.1 itohy if (X68K_BOOT_DEV_IS_SCSI(major)) {
259 1.1 itohy /*
260 1.1 itohy * encode SCSI device
261 1.1 itohy */
262 1.1 itohy if (interface == 0)
263 1.1 itohy get_current_scsi_interface(&interface, &unit_if);
264 1.1 itohy
265 1.1 itohy dev = X68K_MAKESCSIBOOTDEV(major, interface, unit_if,
266 1.1 itohy unit, lun, partition);
267 1.1 itohy } else {
268 1.1 itohy /* encode non-SCSI device */
269 1.1 itohy dev = X68K_MAKEBOOTDEV(major, unit, partition);
270 1.1 itohy }
271 1.1 itohy
272 1.1 itohy if (opt_v)
273 1.1 itohy xwarnx("%s: major %u, if %u, un_if %u, unit %u, lun %u, partition %u; bootdev 0x%x",
274 1.1 itohy devstr, major, interface, unit_if, unit, lun, partition, dev);
275 1.1 itohy
276 1.1 itohy return dev;
277 1.1 itohy }
278 1.1 itohy
279 1.8 isaki #define LOADBSD
280 1.8 isaki #include "../common/exec_sub.c"
281 1.8 isaki
282 1.1 itohy /*
283 1.1 itohy * read kernel and create trampoline
284 1.1 itohy *
285 1.1 itohy * |----------------------| <- allocated buf addr
286 1.1 itohy * | kernel image |
287 1.8 isaki * ~ (exec file contents) ~
288 1.1 itohy * | |
289 1.1 itohy * |----------------------| <- return value (entry addr of trampoline)
290 1.1 itohy * | struct tramparg |
291 1.1 itohy * | (trampoline args) |
292 1.1 itohy * |----------------------|
293 1.1 itohy * | trampoline code |
294 1.1 itohy * | (in assembly) |
295 1.1 itohy * |----------------------|
296 1.1 itohy */
297 1.1 itohy static struct tramparg *
298 1.11 dsl read_kernel(const char *fn)
299 1.1 itohy {
300 1.1 itohy int fd;
301 1.1 itohy union dos_fcb *fcb;
302 1.1 itohy size_t filesize, nread;
303 1.1 itohy void *buf;
304 1.1 itohy struct tramparg *arg;
305 1.1 itohy size_t size_tramp = end_trampoline - trampoline;
306 1.1 itohy
307 1.8 isaki kernel_fn = fn;
308 1.8 isaki
309 1.8 isaki if ((fd = DOS_OPEN(fn, 0x00)) < 0) /* read only */
310 1.1 itohy xerr(1, "%s: open", fn);
311 1.1 itohy
312 1.1 itohy if ((int)(fcb = DOS_GET_FCB_ADR(fd)) < 0)
313 1.1 itohy xerr(1, "%s: get_fcb_adr", fn);
314 1.1 itohy
315 1.1 itohy /*
316 1.1 itohy * XXX FCB is in supervisor area
317 1.1 itohy */
318 1.1 itohy /*if (fcb->blk.mode != 0)*/
319 1.1 itohy if (IOCS_B_BPEEK((char *)fcb + 1) & 0x80)
320 1.1 itohy xerrx(1, "%s: Not a regular file", fn);
321 1.1 itohy
322 1.1 itohy /*filesize = fcb->blk.size;*/
323 1.1 itohy filesize = IOCS_B_LPEEK(&fcb->blk.size);
324 1.1 itohy
325 1.8 isaki if (filesize < sizeof(Elf32_Ehdr))
326 1.8 isaki xerrx(1, "%s: Unknown format", fn);
327 1.1 itohy
328 1.1 itohy /*
329 1.8 isaki * read entire file
330 1.1 itohy */
331 1.8 isaki if ((int)(buf = DOS_MALLOC(filesize + ALIGNBYTES
332 1.1 itohy + sizeof(struct tramparg)
333 1.1 itohy + size_tramp + SIZE_TMPSTACK)) < 0)
334 1.1 itohy xerr(1, "read_kernel");
335 1.1 itohy
336 1.8 isaki if ((nread = DOS_READ(fd, buf, filesize)) != filesize) {
337 1.1 itohy if ((int)nread < 0)
338 1.1 itohy xerr(1, "%s: read", fn);
339 1.1 itohy else
340 1.1 itohy xerrx(1, "%s: short read", fn);
341 1.1 itohy }
342 1.1 itohy
343 1.1 itohy if (DOS_CLOSE(fd) < 0)
344 1.1 itohy xerr(1, "%s: close", fn);
345 1.1 itohy
346 1.1 itohy /*
347 1.8 isaki * address for argument for trampoline code
348 1.1 itohy */
349 1.8 isaki arg = (struct tramparg *) ALIGN((char *) buf + nread);
350 1.1 itohy
351 1.1 itohy if (opt_v)
352 1.1 itohy xwarnx("trampoline arg at %p", arg);
353 1.1 itohy
354 1.8 isaki xk_load(&arg->xk, buf, 0 /* XXX load addr should not be fixed */);
355 1.8 isaki
356 1.8 isaki /*
357 1.8 isaki * create argument for trampoline code
358 1.8 isaki */
359 1.2 minoura arg->bsr_inst = TRAMP_BSR + sizeof(struct tramparg) - 2;
360 1.1 itohy arg->tmp_stack = (char *) arg + sizeof(struct tramparg)
361 1.1 itohy + size_tramp + SIZE_TMPSTACK;
362 1.1 itohy arg->mpu_type = IOCS_MPU_STAT() & 0xff;
363 1.8 isaki
364 1.1 itohy arg->xk.d5 = IOCS_BOOTINF(); /* unused for now */
365 1.1 itohy #if 0
366 1.1 itohy /* filled afterwards */
367 1.1 itohy arg->xk.rootdev =
368 1.1 itohy arg->xk.boothowto =
369 1.1 itohy #endif
370 1.1 itohy
371 1.1 itohy if (opt_v)
372 1.1 itohy xwarnx("args: mpu %d, image %p, load 0x%x, entry 0x%x",
373 1.8 isaki arg->mpu_type, arg->xk.sec[0].sec_image,
374 1.8 isaki arg->xk.load_addr, arg->xk.entry_addr);
375 1.1 itohy
376 1.1 itohy /*
377 1.1 itohy * copy trampoline code
378 1.1 itohy */
379 1.1 itohy if (opt_v)
380 1.1 itohy xwarnx("trampoline code at %p (%u bytes)",
381 1.1 itohy (char *) arg + sizeof(struct tramparg), size_tramp);
382 1.1 itohy
383 1.1 itohy memcpy((char *) arg + sizeof(struct tramparg), trampoline, size_tramp);
384 1.1 itohy
385 1.1 itohy return arg;
386 1.1 itohy }
387 1.1 itohy
388 1.1 itohy /*
389 1.1 itohy * MC68000/010 -> return zero
390 1.1 itohy * MC68020 and later -> return nonzero
391 1.1 itohy */
392 1.1 itohy static int
393 1.13 cegger chkmpu(void)
394 1.1 itohy {
395 1.9 perry register int ret __asm("%d0");
396 1.1 itohy
397 1.9 perry __asm("| %0 <- this must be %%d0\n\
398 1.7 minoura moveq #1,%%d0\n\
399 1.7 minoura .long 0x103B02FF | foo: moveb %%pc@((foo+1)-foo-2:B,d0:W:2),%%d0\n\
400 1.1 itohy | ^ ^\n\
401 1.7 minoura | %%d0.b = 0x02 (68000/010)\n\
402 1.1 itohy | = 0xff (68020 and later)\n\
403 1.1 itohy bmis 1f\n\
404 1.7 minoura moveq #0,%%d0 | 68000/010\n\
405 1.1 itohy 1:" : "=d" (ret));
406 1.1 itohy
407 1.1 itohy return ret;
408 1.1 itohy }
409 1.1 itohy
410 1.1 itohy static __dead void
411 1.11 dsl usage(int status, const char *msg)
412 1.1 itohy {
413 1.1 itohy extern const char *const __progname;
414 1.1 itohy
415 1.1 itohy if (msg)
416 1.1 itohy xwarnx("%s", msg);
417 1.1 itohy
418 1.1 itohy xerrprintf("\
419 1.1 itohy %s [-hvV] [-abDs] [-r root_device] netbsd\n\
420 1.1 itohy \n\
421 1.1 itohy loadbsd options:\n\
422 1.1 itohy \t-h help\n\
423 1.1 itohy \t-v verbose\n\
424 1.1 itohy \t-V print version and exit\n\
425 1.1 itohy \n\
426 1.1 itohy kernel options:\n\
427 1.1 itohy \t-a auto boot, opposite of -s\n\
428 1.1 itohy \t-s single user boot (default)\n\
429 1.1 itohy \t-D enter kernel debugger\n\
430 1.1 itohy \t-b ask root device\n\
431 1.1 itohy \t-r specify root device (default %s)\n\
432 1.1 itohy \t format: [/interface/]device@unit[,lun][:partition]\n\
433 1.1 itohy \t interface: one of spc@0, spc@1, mha@0\n\
434 1.1 itohy \t (current boot interface if omitted)\n\
435 1.4 minoura \t device: one of fd, sd, cd, md, ne\n\
436 1.1 itohy \t unit: device unit number (SCSI ID for SCSI device)\n\
437 1.1 itohy \t lun: SCSI LUN # (0 if omitted)\n\
438 1.1 itohy \t partition: partition letter ('a' if omitted)\n\
439 1.1 itohy ", __progname, DEFAULT_ROOTDEVNAME);
440 1.1 itohy
441 1.1 itohy DOS_EXIT2(status);
442 1.1 itohy }
443 1.1 itohy
444 1.1 itohy int
445 1.12 dsl main(int argc, char *argv[])
446 1.1 itohy {
447 1.1 itohy char *rootdevname = 0;
448 1.1 itohy int rootdev;
449 1.1 itohy u_long boothowto = RB_SINGLE;
450 1.1 itohy const char *kernel;
451 1.1 itohy char *p, **flg, **arg;
452 1.1 itohy struct tramparg *tramp;
453 1.1 itohy struct dos_dregs regs; /* unused... */
454 1.1 itohy int i;
455 1.1 itohy
456 1.1 itohy /* parse options */
457 1.1 itohy for (arg = flg = argv + 1; (p = *flg) && *p == '-'; ) {
458 1.1 itohy int c;
459 1.1 itohy
460 1.1 itohy while ((c = *++p))
461 1.1 itohy switch (c) {
462 1.1 itohy case 'h':
463 1.1 itohy usage(0, (char *) 0);
464 1.1 itohy /* NOTREACHED */
465 1.1 itohy break;
466 1.1 itohy case 'N': /* don't actually execute kernel */
467 1.1 itohy opt_N = 1;
468 1.1 itohy break;
469 1.1 itohy case 'v':
470 1.1 itohy opt_v = 1;
471 1.6 jdolecek boothowto |= AB_VERBOSE; /* XXX */
472 1.1 itohy break;
473 1.1 itohy case 'V':
474 1.1 itohy xprintf("loadbsd %s\n", VERSION);
475 1.1 itohy return 0;
476 1.1 itohy
477 1.1 itohy /*
478 1.1 itohy * kernel boot flags
479 1.1 itohy */
480 1.1 itohy case 'r':
481 1.1 itohy if (rootdevname)
482 1.1 itohy usage(1, "multiple -r flags");
483 1.1 itohy else if (!*++arg)
484 1.1 itohy usage(1, "-r requires device name");
485 1.1 itohy else
486 1.1 itohy rootdevname = *arg;
487 1.1 itohy break;
488 1.1 itohy case 'b':
489 1.1 itohy boothowto |= RB_ASKNAME;
490 1.1 itohy break;
491 1.1 itohy case 'a':
492 1.1 itohy boothowto &= ~RB_SINGLE;
493 1.1 itohy break;
494 1.1 itohy case 's':
495 1.1 itohy boothowto |= RB_SINGLE;
496 1.1 itohy break;
497 1.1 itohy case 'D':
498 1.1 itohy boothowto |= RB_KDB;
499 1.6 jdolecek break;
500 1.6 jdolecek case 'q':
501 1.6 jdolecek boothowto |= AB_QUIET;
502 1.1 itohy break;
503 1.1 itohy
504 1.1 itohy default:
505 1.1 itohy usage(1, (char *) 0);
506 1.1 itohy /* NOTREACHED */
507 1.1 itohy break;
508 1.1 itohy }
509 1.1 itohy flg = ++arg;
510 1.1 itohy }
511 1.1 itohy
512 1.1 itohy /* check MPU */
513 1.1 itohy if (chkmpu() == 0)
514 1.1 itohy xerrx(1, "Can't boot NetBSD on 68000/010");
515 1.1 itohy
516 1.1 itohy argc -= arg - argv;
517 1.1 itohy argv = arg;
518 1.1 itohy
519 1.1 itohy if (argc != 1)
520 1.1 itohy usage(1, (char *) 0);
521 1.1 itohy
522 1.1 itohy kernel = *argv;
523 1.1 itohy
524 1.1 itohy rootdev = bootdev(rootdevname ? rootdevname : DEFAULT_ROOTDEVNAME);
525 1.1 itohy
526 1.1 itohy if (opt_v)
527 1.1 itohy xwarnx("boothowto 0x%x", boothowto);
528 1.1 itohy
529 1.1 itohy tramp = read_kernel(kernel);
530 1.1 itohy
531 1.1 itohy tramp->xk.rootdev = rootdev;
532 1.1 itohy tramp->xk.boothowto = boothowto;
533 1.1 itohy
534 1.1 itohy /*
535 1.3 itohy * we never return, and make sure the disk cache
536 1.1 itohy * be flushed (if write-back cache is enabled)
537 1.1 itohy */
538 1.1 itohy if (opt_v)
539 1.1 itohy xwarnx("flush disk cache...");
540 1.1 itohy
541 1.1 itohy i = DOS_FFLUSH_SET(1); /* enable fflush */
542 1.1 itohy DOS_FFLUSH(); /* then, issue fflush */
543 1.1 itohy (void) DOS_FFLUSH_SET(i); /* restore old mode just in case */
544 1.1 itohy
545 1.1 itohy /*
546 1.1 itohy * the program assumes the MPU caches off
547 1.1 itohy */
548 1.1 itohy if (opt_v)
549 1.1 itohy xwarnx("flush and disable MPU caches...");
550 1.1 itohy
551 1.1 itohy IOCS_CACHE_MD(-1); /* flush */
552 1.1 itohy if (!opt_N)
553 1.1 itohy IOCS_CACHE_MD(0); /* disable both caches */
554 1.1 itohy
555 1.1 itohy if (opt_v)
556 1.1 itohy xwarnx("Jumping to the kernel. Good Luck!");
557 1.1 itohy
558 1.1 itohy if (opt_N)
559 1.1 itohy xerrx(0, "But don't actually do it.");
560 1.1 itohy
561 1.10 dsl DOS_SUPER_JSR((void (*)(void)) tramp, ®s, ®s);
562 1.1 itohy
563 1.1 itohy /* NOTREACHED */
564 1.1 itohy
565 1.1 itohy xwarnx("??? return from kernel");
566 1.1 itohy
567 1.1 itohy return 1;
568 1.1 itohy }
569