| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: boot.c,v 1.2 2012/11/01 14:46:26 isaki Exp $ */ | | 1 | /* $NetBSD: boot.c,v 1.3 2014/07/06 05:31:03 tsutsui Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001 Minoura Makoto | | 4 | * Copyright (c) 2001 Minoura Makoto |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -36,27 +36,28 @@ | | | @@ -36,27 +36,28 @@ |
36 | #include <lib/libkern/libkern.h> | | 36 | #include <lib/libkern/libkern.h> |
37 | | | 37 | |
38 | #include "libx68k.h" | | 38 | #include "libx68k.h" |
39 | #include "iocs.h" | | 39 | #include "iocs.h" |
40 | | | 40 | |
41 | #include "exec_image.h" | | 41 | #include "exec_image.h" |
42 | | | 42 | |
43 | | | 43 | |
44 | #define HEAP_START ((void*) 0x00080000) | | 44 | #define HEAP_START ((void*) 0x00080000) |
45 | #define HEAP_END ((void*) 0x000fffff) | | 45 | #define HEAP_END ((void*) 0x000fffff) |
46 | #define EXSCSI_BDID ((void*) 0x00ea0001) | | 46 | #define EXSCSI_BDID ((void*) 0x00ea0001) |
47 | #define SRAM_MEMSIZE (*((long*) 0x00ed0008)) | | 47 | #define SRAM_MEMSIZE (*((long*) 0x00ed0008)) |
48 | | | 48 | |
49 | char default_kernel[20] = "nfs:netbsd"; | | 49 | char default_kernel[20] = |
| | | 50 | "nfs:netbsd"; |
50 | int mpu; | | 51 | int mpu; |
51 | int console_device = -1; | | 52 | int console_device = -1; |
52 | | | 53 | |
53 | #ifdef DEBUG | | 54 | #ifdef DEBUG |
54 | int debug = 1; | | 55 | int debug = 1; |
55 | #endif | | 56 | #endif |
56 | | | 57 | |
57 | static void help(void); | | 58 | static void help(void); |
58 | static void doboot(const char *, int); | | 59 | static void doboot(const char *, int); |
59 | static void boot(char *); | | 60 | static void boot(char *); |
60 | int bootmenu(void); | | 61 | int bootmenu(void); |
61 | void bootmain(int); | | 62 | void bootmain(int); |
62 | extern int detectmpu(void); | | 63 | extern int detectmpu(void); |
| @@ -90,37 +91,43 @@ doboot(const char *file, int flags) | | | @@ -90,37 +91,43 @@ doboot(const char *file, int flags) |
90 | loadflag &= ~LOAD_BACKWARDS; | | 91 | loadflag &= ~LOAD_BACKWARDS; |
91 | | | 92 | |
92 | marks[MARK_START] = 0x100000; | | 93 | marks[MARK_START] = 0x100000; |
93 | if ((fd = loadfile(file, marks, loadflag)) == -1) { | | 94 | if ((fd = loadfile(file, marks, loadflag)) == -1) { |
94 | printf("loadfile failed\n"); | | 95 | printf("loadfile failed\n"); |
95 | return; | | 96 | return; |
96 | } | | 97 | } |
97 | close(fd); | | 98 | close(fd); |
98 | | | 99 | |
99 | if (devparse(file, &dev, &unit, &part, &name) != 0) { | | 100 | if (devparse(file, &dev, &unit, &part, &name) != 0) { |
100 | printf("XXX: unknown corruption in /boot.\n"); | | 101 | printf("XXX: unknown corruption in /boot.\n"); |
101 | } | | 102 | } |
102 | | | 103 | |
| | | 104 | #ifdef DEBUG |
103 | printf("dev = %x, unit = %d, name = %s\n", | | 105 | printf("dev = %x, unit = %d, name = %s\n", |
104 | dev, unit, name); | | 106 | dev, unit, name); |
| | | 107 | #endif |
105 | | | 108 | |
106 | dev = X68K_MAKEBOOTDEV(X68K_MAJOR_NE, unit, 0); | | 109 | dev = X68K_MAKEBOOTDEV(X68K_MAJOR_NE, unit, 0); |
| | | 110 | #ifdef DEBUG |
107 | printf("boot device = %x\n", dev); | | 111 | printf("boot device = %x\n", dev); |
108 | printf("if = %d, unit = %d\n", | | 112 | printf("if = %d, unit = %d\n", |
109 | B_X68K_SCSI_IF(dev), | | 113 | B_X68K_SCSI_IF(dev), |
110 | B_X68K_SCSI_IF_UN(dev)); | | 114 | B_X68K_SCSI_IF_UN(dev)); |
| | | 115 | #endif |
111 | | | 116 | |
112 | p = ((short*) marks[MARK_ENTRY]) - 1; | | 117 | p = ((short*) marks[MARK_ENTRY]) - 1; |
| | | 118 | #ifdef DEBUG |
113 | printf("Kernel Version: 0x%x\n", *p); | | 119 | printf("Kernel Version: 0x%x\n", *p); |
| | | 120 | #endif |
114 | if (*p != 0x4e73 && *p != 0) { | | 121 | if (*p != 0x4e73 && *p != 0) { |
115 | /* | | 122 | /* |
116 | * XXX temporary solution; compatibility loader | | 123 | * XXX temporary solution; compatibility loader |
117 | * must be written. | | 124 | * must be written. |
118 | */ | | 125 | */ |
119 | printf("This kernel is too new to be loaded by " | | 126 | printf("This kernel is too new to be loaded by " |
120 | "this version of /boot.\n"); | | 127 | "this version of /boot.\n"); |
121 | return; | | 128 | return; |
122 | } | | 129 | } |
123 | | | 130 | |
124 | exec_image(marks[MARK_START], 0, marks[MARK_ENTRY]-marks[MARK_START], | | 131 | exec_image(marks[MARK_START], 0, marks[MARK_ENTRY]-marks[MARK_START], |
125 | marks[MARK_END]-marks[MARK_START], dev, flags); | | 132 | marks[MARK_END]-marks[MARK_START], dev, flags); |
126 | | | 133 | |
| @@ -196,50 +203,53 @@ bootmenu(void) | | | @@ -196,50 +203,53 @@ bootmenu(void) |
196 | printf("Please use the absolute unit# (e.g. SCSI ID)" | | 203 | printf("Please use the absolute unit# (e.g. SCSI ID)" |
197 | " instead of the NetBSD logical #.\n"); | | 204 | " instead of the NetBSD logical #.\n"); |
198 | for (;;) { | | 205 | for (;;) { |
199 | char *p, *options; | | 206 | char *p, *options; |
200 | | | 207 | |
201 | printf("> "); | | 208 | printf("> "); |
202 | gets(input); | | 209 | gets(input); |
203 | | | 210 | |
204 | for (p = &input[0]; p - &input[0] < 80 && *p == ' '; p++) | | 211 | for (p = &input[0]; p - &input[0] < 80 && *p == ' '; p++) |
205 | ; | | 212 | ; |
206 | options = gettrailer(p); | | 213 | options = gettrailer(p); |
207 | if (strcmp("boot", p) == 0) | | 214 | if (strcmp("boot", p) == 0) |
208 | boot(options); | | 215 | boot(options); |
209 | else if (strcmp("help", p) == 0 || strcmp("?", p) == 0) | | 216 | else if (strcmp("help", p) == 0 || |
| | | 217 | strcmp("?", p) == 0) |
210 | help(); | | 218 | help(); |
211 | else if (strcmp("halt", p) == 0 || strcmp("reboot", p) == 0) | | 219 | else if (strcmp("halt", p) == 0 || |
| | | 220 | strcmp("reboot", p) == 0) |
212 | exit(0); | | 221 | exit(0); |
213 | else | | 222 | else |
214 | printf("Unknown command %s\n", p); | | 223 | printf("Unknown command %s\n", p); |
215 | } | | 224 | } |
216 | } | | 225 | } |
217 | | | 226 | |
218 | | | 227 | |
219 | extern const char bootprog_rev[]; | | 228 | extern const char bootprog_rev[]; |
220 | extern const char bootprog_name[]; | | 229 | extern const char bootprog_name[]; |
221 | | | 230 | |
222 | /* | | 231 | /* |
223 | * Arguments from the boot block: | | 232 | * Arguments from the boot block: |
224 | * bootdev - specifies the device from which /boot was read, in | | 233 | * bootdev - specifies the device from which /boot was read, in |
225 | * bootdev format. | | 234 | * bootdev format. |
226 | */ | | 235 | */ |
227 | void | | 236 | void |
228 | bootmain(int bootdev) | | 237 | bootmain(int bootdev) |
229 | { | | 238 | { |
230 | mpu = detectmpu(); | | 239 | |
231 | rtc_offset = RTC_OFFSET; | | 240 | rtc_offset = RTC_OFFSET; |
232 | try_bootp = 1; | | 241 | try_bootp = 1; |
| | | 242 | mpu = detectmpu(); |
233 | | | 243 | |
234 | if (mpu < 3) { /* not tested on 68020 */ | | 244 | if (mpu < 3) { /* not tested on 68020 */ |
235 | printf("This MPU cannot run NetBSD.\n"); | | 245 | printf("This MPU cannot run NetBSD.\n"); |
236 | exit(1); | | 246 | exit(1); |
237 | } | | 247 | } |
238 | if (SRAM_MEMSIZE < 4*1024*1024) { | | 248 | if (SRAM_MEMSIZE < 4*1024*1024) { |
239 | printf("Main memory too small.\n"); | | 249 | printf("Main memory too small.\n"); |
240 | exit(1); | | 250 | exit(1); |
241 | } | | 251 | } |
242 | | | 252 | |
243 | console_device = consio_init(console_device); | | 253 | console_device = consio_init(console_device); |
244 | setheap(HEAP_START, HEAP_END); | | 254 | setheap(HEAP_START, HEAP_END); |
245 | | | 255 | |