Add support to pass boothowto and bootdev info from bootloader to kernel. Bootloader side changes: - make boot command parse boothowto flags (-ads etc.) - pass boothowto and bootdev info to the kernel via %d7 and %d6 as the old 4.4BSD/luna68k kernel expected - remove unused and now unnecessary "howto" (how_to_boot) command - export and tweak make_device() in devopen.c to prepare bootdev info - remove unused and commented out get_boot_device()diff -r1.5 -r1.6 src/sys/arch/luna68k/stand/boot/boot.c
(tsutsui)
--- src/sys/arch/luna68k/stand/boot/boot.c 2014/01/10 11:12:03 1.5
+++ src/sys/arch/luna68k/stand/boot/boot.c 2014/01/11 08:08:23 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: boot.c,v 1.5 2014/01/10 11:12:03 tsutsui Exp $ */ | 1 | /* $NetBSD: boot.c,v 1.6 2014/01/11 08:08:23 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992 OMRON Corporation. | 4 | * Copyright (c) 1992 OMRON Corporation. | |
5 | * | 5 | * | |
6 | * This code is derived from software contributed to Berkeley by | 6 | * This code is derived from software contributed to Berkeley by | |
7 | * OMRON Corporation. | 7 | * OMRON Corporation. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -66,161 +66,88 @@ | @@ -66,161 +66,88 @@ | |||
66 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 66 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
67 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 67 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
68 | * SUCH DAMAGE. | 68 | * SUCH DAMAGE. | |
69 | * | 69 | * | |
70 | * @(#)boot.c 8.1 (Berkeley) 6/10/93 | 70 | * @(#)boot.c 8.1 (Berkeley) 6/10/93 | |
71 | */ | 71 | */ | |
72 | 72 | |||
73 | /* | 73 | /* | |
74 | * boot.c -- boot program | 74 | * boot.c -- boot program | |
75 | * by A.Fujita, MAR-01-1992 | 75 | * by A.Fujita, MAR-01-1992 | |
76 | */ | 76 | */ | |
77 | 77 | |||
78 | #include <sys/param.h> | 78 | #include <sys/param.h> | |
79 | #include <sys/boot_flag.h> | |||
79 | #include <sys/reboot.h> | 80 | #include <sys/reboot.h> | |
80 | #include <sys/exec.h> | 81 | #include <sys/exec.h> | |
81 | #include <luna68k/stand/boot/samachdep.h> | 82 | #include <luna68k/stand/boot/samachdep.h> | |
82 | #include <luna68k/stand/boot/stinger.h> | 83 | #include <luna68k/stand/boot/stinger.h> | |
83 | #include <luna68k/stand/boot/status.h> | 84 | #include <luna68k/stand/boot/status.h> | |
84 | #include <lib/libsa/loadfile.h> | 85 | #include <lib/libsa/loadfile.h> | |
85 | 86 | |||
86 | int howto; | |||
87 | ||||
88 | #if 0 | |||
89 | static int get_boot_device(const char *, int *, int *, int *); | |||
90 | #endif | |||
91 | ||||
92 | struct exec header; | |||
93 | ||||
94 | char *how_to_info[] = { | |||
95 | "RB_ASKNAME ask for file name to reboot from", | |||
96 | "RB_SINGLE reboot to single user only", | |||
97 | "RB_NOSYNC dont sync before reboot", | |||
98 | "RB_HALT don't reboot, just halt", | |||
99 | "RB_INITNAME name given for /etc/init (unused)", | |||
100 | "RB_DFLTROOT use compiled-in rootdev", | |||
101 | "RB_KDB give control to kernel debugger", | |||
102 | "RB_RDONLY mount root fs read-only" | |||
103 | }; | |||
104 | ||||
105 | int | |||
106 | how_to_boot(int argc, char *argv[]) | |||
107 | { | |||
108 | int i, h = howto; | |||
109 | ||||
110 | if (argc < 2) { | |||
111 | printf("howto: 0x%s\n\n", hexstr(howto, 2)); | |||
112 | ||||
113 | if (h == 0) { | |||
114 | printf("\t%s\n", "RB_AUTOBOOT flags for system auto-booting itself"); | |||
115 | } else { | |||
116 | for (i = 0; i < 8; i++, h >>= 1) { | |||
117 | if (h & 0x01) { | |||
118 | printf("\t%s\n", how_to_info[i]); | |||
119 | } | |||
120 | } | |||
121 | } | |||
122 | ||||
123 | printf("\n"); | |||
124 | } | |||
125 | return ST_NORMAL; | |||
126 | } | |||
127 | ||||
128 | #if 0 | |||
129 | int | |||
130 | get_boot_device(const char *s, int *devp, int *unitp, int *partp) | |||
131 | { | |||
132 | const char *p = s; | |||
133 | int unit, part; | |||
134 | ||||
135 | uint = 0; | |||
136 | part = 0; | |||
137 | ||||
138 | while (*p != '(') { | |||
139 | if (*p == '\0') | |||
140 | goto error; | |||
141 | p++; | |||
142 | } | |||
143 | ||||
144 | p++; | |||
145 | for (; *p != ',' && *p != ')') { | |||
146 | if (*p == '\0') | |||
147 | goto error; | |||
148 | if (*p >= '0' && *p <= '9') | |||
149 | unit = (unit * 10) + (*p - '0'); | |||
150 | } | |||
151 | ||||
152 | if (*p == ',') | |||
153 | p++; | |||
154 | for (; *p != ')'; p++) { | |||
155 | if (*p == '\0') | |||
156 | goto error; | |||
157 | if (*p >= '0' && *p <= '9') | |||
158 | part = (part * 10) + (*p - '0'); | |||
159 | } | |||
160 | ||||
161 | *devp = 0; /* XXX not yet */ | |||
162 | *unitp = unit; | |||
163 | *partp = part; | |||
164 | ||||
165 | return 0; | |||
166 | ||||
167 | error: | |||
168 | return -1; | |||
169 | } | |||
170 | #endif | |||
171 | ||||
172 | int | 87 | int | |
173 | boot(int argc, char *argv[]) | 88 | boot(int argc, char *argv[]) | |
174 | { | 89 | { | |
175 | char *line; | 90 | char *line, *opts; | |
176 | 91 | int i, howto; | ||
177 | if (argc < 2) | 92 | char c; | |
93 | ||||
94 | line = NULL; | |||
95 | howto = 0; | |||
96 | for (i = 1; i < argc; i++) { | |||
97 | if (argv[i][0] == '-') { | |||
98 | opts = argv[i]; | |||
99 | while ((c = *++opts) && c != '\0') | |||
100 | BOOT_FLAG(c, howto); | |||
101 | } else if (line == NULL) | |||
102 | line = argv[i]; | |||
103 | } | |||
104 | if (line == NULL) | |||
178 | line = default_file; | 105 | line = default_file; | |
179 | else | |||
180 | line = argv[1]; | |||
181 | 106 | |||
182 | printf("Booting %s\n", line); | 107 | printf("Booting %s", line); | |
108 | if (howto != 0) | |||
109 | printf(" (howto 0x%x)", howto); | |||
110 | printf("\n"); | |||
183 | 111 | |||
184 | return bootnetbsd(line); | 112 | return bootnetbsd(line, howto); | |
185 | } | 113 | } | |
186 | 114 | |||
187 | int | 115 | int | |
188 | bootnetbsd(char *line) | 116 | bootnetbsd(char *line, int howto) | |
189 | { | 117 | { | |
190 | int io; | 118 | int io; | |
191 | #if 0 | |||
192 | int dev, unit, part; | |||
193 | #endif | |||
194 | u_long marks[MARK_MAX]; | 119 | u_long marks[MARK_MAX]; | |
195 | void (*entry)(void); | |||
196 | ||||
197 | #if 0 | |||
198 | if (get_boot_device(line, &dev, &unit, &part) != 0) { | |||
199 | printf("Bad file name %s\n", line); | |||
200 | return ST_ERROR; | |||
201 | } | |||
202 | #endif | |||
203 | 120 | |||
204 | /* Note marks[MARK_START] is passed as an load address offset */ | 121 | /* Note marks[MARK_START] is passed as an load address offset */ | |
205 | memset(marks, 0, sizeof(marks)); | 122 | memset(marks, 0, sizeof(marks)); | |
206 | 123 | |||
207 | io = loadfile(line, marks, LOAD_KERNEL); | 124 | io = loadfile(line, marks, LOAD_KERNEL); | |
208 | if (io >= 0) { | 125 | if (io >= 0) { | |
126 | int dev = 0, unit = 0, part = 0; | |||
127 | uint adpt, ctlr, id; | |||
128 | uint32_t bootdev; | |||
129 | ||||
130 | make_device(line, &dev, &unit, &part, NULL); | |||
131 | adpt = dev2adpt[dev]; | |||
132 | ctlr = CTLR(unit); | |||
133 | id = TARGET(unit); | |||
134 | bootdev = MAKEBOOTDEV(0, adpt, ctlr, id, part); | |||
209 | #ifdef DEBUG | 135 | #ifdef DEBUG | |
210 | printf("entry = 0x%lx\n", marks[MARK_ENTRY]); | 136 | printf("entry = 0x%lx\n", marks[MARK_ENTRY]); | |
211 | printf("ssym = 0x%lx\n", marks[MARK_SYM]); | 137 | printf("ssym = 0x%lx\n", marks[MARK_SYM]); | |
212 | printf("esym = 0x%lx\n", marks[MARK_END]); | 138 | printf("esym = 0x%lx\n", marks[MARK_END]); | |
213 | #endif | 139 | #endif | |
214 | 140 | __asm volatile ( | ||
215 | /* | 141 | "movl %0,%%d7;" | |
216 | * XXX TODO: fill bootinfo about symbols, boot device etc. | 142 | "movl %1,%%d6;" | |
217 | */ | 143 | "movl %2,%%a0;" | |
218 | 144 | "jbsr %%a0@" | ||
219 | entry = (void *)marks[MARK_ENTRY]; | 145 | : | |
220 | 146 | : "g" (howto), "g" (bootdev), | ||
221 | (*entry)(); | 147 | "g" ((void *)marks[MARK_ENTRY]) | |
148 | : "d6", "d7", "a0"); | |||
222 | } | 149 | } | |
223 | printf("Booting kernel failed. (%s)\n", strerror(errno)); | 150 | printf("Booting kernel failed. (%s)\n", strerror(errno)); | |
224 | 151 | |||
225 | return ST_ERROR; | 152 | return ST_ERROR; | |
226 | } | 153 | } |
--- src/sys/arch/luna68k/stand/boot/devopen.c 2014/01/10 11:12:03 1.5
+++ src/sys/arch/luna68k/stand/boot/devopen.c 2014/01/11 08:08:23 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: devopen.c,v 1.5 2014/01/10 11:12:03 tsutsui Exp $ */ | 1 | /* $NetBSD: devopen.c,v 1.6 2014/01/11 08:08:23 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992 OMRON Corporation. | 4 | * Copyright (c) 1992 OMRON Corporation. | |
5 | * | 5 | * | |
6 | * This code is derived from software contributed to Berkeley by | 6 | * This code is derived from software contributed to Berkeley by | |
7 | * OMRON Corporation. | 7 | * OMRON Corporation. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -66,28 +66,26 @@ | @@ -66,28 +66,26 @@ | |||
66 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 66 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
67 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 67 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
68 | * SUCH DAMAGE. | 68 | * SUCH DAMAGE. | |
69 | * | 69 | * | |
70 | * @(#)conf.c 8.1 (Berkeley) 6/10/93 | 70 | * @(#)conf.c 8.1 (Berkeley) 6/10/93 | |
71 | */ | 71 | */ | |
72 | 72 | |||
73 | #include <lib/libkern/libkern.h> | 73 | #include <lib/libkern/libkern.h> | |
74 | #include <luna68k/stand/boot/samachdep.h> | 74 | #include <luna68k/stand/boot/samachdep.h> | |
75 | #include <machine/disklabel.h> | 75 | #include <machine/disklabel.h> | |
76 | 76 | |||
77 | #define MAXDEVNAME 16 | 77 | #define MAXDEVNAME 16 | |
78 | 78 | |||
79 | static int make_device(const char *, int *, int *, int *, char **); | |||
80 | ||||
81 | int | 79 | int | |
82 | devopen(struct open_file *f, const char *fname, char **file) | 80 | devopen(struct open_file *f, const char *fname, char **file) | |
83 | { | 81 | { | |
84 | int dev, unit, part; | 82 | int dev, unit, part; | |
85 | int error; | 83 | int error; | |
86 | struct devsw *dp; | 84 | struct devsw *dp; | |
87 | int i; | 85 | int i; | |
88 | 86 | |||
89 | if (make_device(fname, &dev, &unit, &part, file) != 0) | 87 | if (make_device(fname, &dev, &unit, &part, file) != 0) | |
90 | return ENXIO; | 88 | return ENXIO; | |
91 | 89 | |||
92 | #ifdef DEBUG | 90 | #ifdef DEBUG | |
93 | printf("%s: %s(%d,%d)%s\n", __func__, | 91 | printf("%s: %s(%d,%d)%s\n", __func__, | |
@@ -115,49 +113,49 @@ devopen(struct open_file *f, const char | @@ -115,49 +113,49 @@ devopen(struct open_file *f, const char | |||
115 | } | 113 | } | |
116 | #endif | 114 | #endif | |
117 | 115 | |||
118 | f->f_dev = dp; | 116 | f->f_dev = dp; | |
119 | 117 | |||
120 | return 0; | 118 | return 0; | |
121 | } | 119 | } | |
122 | 120 | |||
123 | int | 121 | int | |
124 | make_device(const char *str, int *devp, int *unitp, int *partp, char **fname) | 122 | make_device(const char *str, int *devp, int *unitp, int *partp, char **fname) | |
125 | { | 123 | { | |
126 | const char *cp; | 124 | const char *cp; | |
127 | struct devsw *dp; | 125 | struct devsw *dp; | |
128 | int major, unit = 0, part = 0; | 126 | int dev, unit = 0, part = 0; | |
129 | int i; | 127 | int i; | |
130 | char devname[MAXDEVNAME + 1]; | 128 | char devname[MAXDEVNAME + 1]; | |
131 | 129 | |||
132 | /* | 130 | /* | |
133 | * parse path strings | 131 | * parse path strings | |
134 | */ | 132 | */ | |
135 | /* find end of dev type name */ | 133 | /* find end of dev type name */ | |
136 | for (cp = str, i = 0; *cp != '\0' && *cp != '(' && i < MAXDEVNAME; i++) | 134 | for (cp = str, i = 0; *cp != '\0' && *cp != '(' && i < MAXDEVNAME; i++) | |
137 | devname[i] = *cp++; | 135 | devname[i] = *cp++; | |
138 | if (*cp != '(') { | 136 | if (*cp != '(') { | |
139 | return (-1); | 137 | return (-1); | |
140 | } | 138 | } | |
141 | devname[i] = '\0'; | 139 | devname[i] = '\0'; | |
142 | /* compare dev type name */ | 140 | /* compare dev type name */ | |
143 | for (dp = devsw; dp->dv_name; dp++) | 141 | for (dp = devsw; dp->dv_name; dp++) | |
144 | if (!strcmp(devname, dp->dv_name)) | 142 | if (!strcmp(devname, dp->dv_name)) | |
145 | break; | 143 | break; | |
146 | cp++; | 144 | cp++; | |
147 | if (dp->dv_name == NULL) { | 145 | if (dp->dv_name == NULL) { | |
148 | return (-1); | 146 | return (-1); | |
149 | } | 147 | } | |
150 | major = dp - devsw; | 148 | dev = dp - devsw; | |
151 | /* get mixed controller and unit number */ | 149 | /* get mixed controller and unit number */ | |
152 | for (; *cp != ',' && *cp != ')'; cp++) { | 150 | for (; *cp != ',' && *cp != ')'; cp++) { | |
153 | if (*cp == '\0') | 151 | if (*cp == '\0') | |
154 | return -1; | 152 | return -1; | |
155 | if (*cp >= '0' && *cp <= '9') | 153 | if (*cp >= '0' && *cp <= '9') | |
156 | unit = unit * 10 + *cp - '0'; | 154 | unit = unit * 10 + *cp - '0'; | |
157 | } | 155 | } | |
158 | if (unit < 0 || CTLR(unit) >= 2 || TARGET(unit) > 7) { | 156 | if (unit < 0 || CTLR(unit) >= 2 || TARGET(unit) > 7) { | |
159 | #ifdef DEBUG | 157 | #ifdef DEBUG | |
160 | printf("%s: invalid unit number (%d)\n", __func__, unit); | 158 | printf("%s: invalid unit number (%d)\n", __func__, unit); | |
161 | #endif | 159 | #endif | |
162 | return (-1); | 160 | return (-1); | |
163 | } | 161 | } | |
@@ -168,28 +166,30 @@ make_device(const char *str, int *devp, | @@ -168,28 +166,30 @@ make_device(const char *str, int *devp, | |||
168 | for (; /* *cp != ',' && */ *cp != ')'; cp++) { | 166 | for (; /* *cp != ',' && */ *cp != ')'; cp++) { | |
169 | if (*cp == '\0') | 167 | if (*cp == '\0') | |
170 | return -1; | 168 | return -1; | |
171 | if (*cp >= '0' && *cp <= '9') | 169 | if (*cp >= '0' && *cp <= '9') | |
172 | part = part * 10 + *cp - '0'; | 170 | part = part * 10 + *cp - '0'; | |
173 | } | 171 | } | |
174 | if (part < 0 || part >= MAXPARTITIONS) { | 172 | if (part < 0 || part >= MAXPARTITIONS) { | |
175 | #ifdef DEBUG | 173 | #ifdef DEBUG | |
176 | printf("%s: invalid partition number (%d)\n", __func__, part); | 174 | printf("%s: invalid partition number (%d)\n", __func__, part); | |
177 | #endif | 175 | #endif | |
178 | return (-1); | 176 | return (-1); | |
179 | } | 177 | } | |
180 | /* check out end of dev spec */ | 178 | /* check out end of dev spec */ | |
181 | *devp = major; | 179 | *devp = dev; | |
182 | *unitp = unit; | 180 | *unitp = unit; | |
183 | *partp = part; | 181 | *partp = part; | |
184 | cp++; | 182 | if (fname != NULL) { | |
185 | if (*cp == '\0') | 183 | cp++; | |
186 | *fname = "netbsd"; | 184 | if (*cp == '\0') | |
187 | else | 185 | *fname = "netbsd"; | |
188 | *fname = __UNCONST(cp); /* XXX */ | 186 | else | |
187 | *fname = __UNCONST(cp); /* XXX */ | |||
188 | } | |||
189 | #ifdef DEBUG | 189 | #ifdef DEBUG | |
190 | printf("%s: major = %d, unit = %d, part = %d, fname = %s\n", | 190 | printf("%s: dev = %d, unit = %d, part = %d, fname = %s\n", | |
191 | __func__, major, unit, part, *fname); | 191 | __func__, dev, unit, part, fname != NULL ? *fname : ""); | |
192 | #endif | 192 | #endif | |
193 | 193 | |||
194 | return 0; | 194 | return 0; | |
195 | } | 195 | } |
--- src/sys/arch/luna68k/stand/boot/conf.c 2013/01/16 15:46:20 1.3
+++ src/sys/arch/luna68k/stand/boot/conf.c 2014/01/11 08:08:23 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: conf.c,v 1.3 2013/01/16 15:46:20 tsutsui Exp $ */ | 1 | /* $NetBSD: conf.c,v 1.4 2014/01/11 08:08:23 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1982, 1986, 1990, 1993 | 4 | * Copyright (c) 1982, 1986, 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * 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. | |
@@ -33,26 +33,27 @@ | @@ -33,26 +33,27 @@ | |||
33 | 33 | |||
34 | #include <sys/param.h> | 34 | #include <sys/param.h> | |
35 | #include <sys/socket.h> | 35 | #include <sys/socket.h> | |
36 | 36 | |||
37 | #include <net/if.h> | 37 | #include <net/if.h> | |
38 | #include <netinet/in.h> | 38 | #include <netinet/in.h> | |
39 | #include <netinet/in_systm.h> | 39 | #include <netinet/in_systm.h> | |
40 | 40 | |||
41 | #include <lib/libsa/stand.h> | 41 | #include <lib/libsa/stand.h> | |
42 | #include <lib/libsa/dev_net.h> | 42 | #include <lib/libsa/dev_net.h> | |
43 | #include <lib/libsa/nfs.h> | 43 | #include <lib/libsa/nfs.h> | |
44 | #include <lib/libsa/ufs.h> | 44 | #include <lib/libsa/ufs.h> | |
45 | 45 | |||
46 | #include <machine/bootinfo.h> | |||
46 | #include <luna68k/stand/boot/samachdep.h> | 47 | #include <luna68k/stand/boot/samachdep.h> | |
47 | 48 | |||
48 | #define xxstrategy \ | 49 | #define xxstrategy \ | |
49 | (int (*)(void *, int, daddr_t, size_t, void *, size_t *))nullsys | 50 | (int (*)(void *, int, daddr_t, size_t, void *, size_t *))nullsys | |
50 | #define xxopen (int (*)(struct open_file *, ...))nodev | 51 | #define xxopen (int (*)(struct open_file *, ...))nodev | |
51 | #define xxclose (int (*)(struct open_file *))nullsys | 52 | #define xxclose (int (*)(struct open_file *))nullsys | |
52 | 53 | |||
53 | /* | 54 | /* | |
54 | * Device configuration | 55 | * Device configuration | |
55 | */ | 56 | */ | |
56 | #ifndef SUPPORT_ETHERNET | 57 | #ifndef SUPPORT_ETHERNET | |
57 | #define netstrategy xxstrategy | 58 | #define netstrategy xxstrategy | |
58 | #define netopen xxopen | 59 | #define netopen xxopen | |
@@ -70,26 +71,32 @@ | @@ -70,26 +71,32 @@ | |||
70 | #define sdclose xxclose | 71 | #define sdclose xxclose | |
71 | #endif | 72 | #endif | |
72 | #define sdioctl noioctl | 73 | #define sdioctl noioctl | |
73 | 74 | |||
74 | /* | 75 | /* | |
75 | * Note: "le" isn't a major offset. | 76 | * Note: "le" isn't a major offset. | |
76 | */ | 77 | */ | |
77 | struct devsw devsw[] = { | 78 | struct devsw devsw[] = { | |
78 | { "sd", sdstrategy, sdopen, sdclose, sdioctl }, | 79 | { "sd", sdstrategy, sdopen, sdclose, sdioctl }, | |
79 | { "le", netstrategy, netopen, netclose, netioctl }, | 80 | { "le", netstrategy, netopen, netclose, netioctl }, | |
80 | }; | 81 | }; | |
81 | int ndevs = __arraycount(devsw); | 82 | int ndevs = __arraycount(devsw); | |
82 | 83 | |||
84 | /* XXX: These indices must sync with the above devsw */ | |||
85 | const int dev2adpt[] = { | |||
86 | LUNA68K_BOOTADPT_SPC, | |||
87 | LUNA68K_BOOTADPT_LANCE, | |||
88 | }; | |||
89 | ||||
83 | #ifdef SUPPORT_ETHERNET | 90 | #ifdef SUPPORT_ETHERNET | |
84 | extern struct netif_driver le_netif_driver; | 91 | extern struct netif_driver le_netif_driver; | |
85 | struct netif_driver *netif_drivers[] = { | 92 | struct netif_driver *netif_drivers[] = { | |
86 | &le_netif_driver, | 93 | &le_netif_driver, | |
87 | }; | 94 | }; | |
88 | int n_netif_drivers = __arraycount(netif_drivers); | 95 | int n_netif_drivers = __arraycount(netif_drivers); | |
89 | #endif | 96 | #endif | |
90 | 97 | |||
91 | /* | 98 | /* | |
92 | * Filesystem configuration | 99 | * Filesystem configuration | |
93 | */ | 100 | */ | |
94 | #ifdef SUPPORT_DISK | 101 | #ifdef SUPPORT_DISK | |
95 | struct fs_ops file_system_disk[] = { | 102 | struct fs_ops file_system_disk[] = { |
--- src/sys/arch/luna68k/stand/boot/init_main.c 2014/01/10 11:12:03 1.9
+++ src/sys/arch/luna68k/stand/boot/init_main.c 2014/01/11 08:08:23 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: init_main.c,v 1.9 2014/01/10 11:12:03 tsutsui Exp $ */ | 1 | /* $NetBSD: init_main.c,v 1.10 2014/01/11 08:08:23 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992 OMRON Corporation. | 4 | * Copyright (c) 1992 OMRON Corporation. | |
5 | * | 5 | * | |
6 | * This code is derived from software contributed to Berkeley by | 6 | * This code is derived from software contributed to Berkeley by | |
7 | * OMRON Corporation. | 7 | * OMRON Corporation. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -169,26 +169,27 @@ struct luna2_bootinfo { | @@ -169,26 +169,27 @@ struct luna2_bootinfo { | |||
169 | uint8_t bd_xxx5[4]; /* 12: ??? */ | 169 | uint8_t bd_xxx5[4]; /* 12: ??? */ | |
170 | uint8_t bd_xxx6[4]; /* 16: ??? */ | 170 | uint8_t bd_xxx6[4]; /* 16: ??? */ | |
171 | } bi_devinfo[LUNA2_NBTDEV]; | 171 | } bi_devinfo[LUNA2_NBTDEV]; | |
172 | } __packed; | 172 | } __packed; | |
173 | 173 | |||
174 | /* #define BTINFO_DEBUG */ | 174 | /* #define BTINFO_DEBUG */ | |
175 | 175 | |||
176 | void | 176 | void | |
177 | main(void) | 177 | main(void) | |
178 | { | 178 | { | |
179 | int i, status = 0; | 179 | int i, status = 0; | |
180 | const char *machstr; | 180 | const char *machstr; | |
181 | const char *bootdev; | 181 | const char *bootdev; | |
182 | uint32_t howto; | |||
182 | int unit, part; | 183 | int unit, part; | |
183 | int bdev, ctlr, id; | 184 | int bdev, ctlr, id; | |
184 | 185 | |||
185 | /* | 186 | /* | |
186 | * Initialize the console before we print anything out. | 187 | * Initialize the console before we print anything out. | |
187 | */ | 188 | */ | |
188 | if (cputype == CPU_68030) { | 189 | if (cputype == CPU_68030) { | |
189 | machtype = LUNA_I; | 190 | machtype = LUNA_I; | |
190 | machstr = "LUNA-I"; | 191 | machstr = "LUNA-I"; | |
191 | cpuspeed = MHZ_25; | 192 | cpuspeed = MHZ_25; | |
192 | hz = 60; | 193 | hz = 60; | |
193 | } else { | 194 | } else { | |
194 | machtype = LUNA_II; | 195 | machtype = LUNA_II; | |
@@ -297,27 +298,27 @@ main(void) | @@ -297,27 +298,27 @@ main(void) | |||
297 | "%s(%d,%d)%s", bootdev, unit, part, "netbsd"); | 298 | "%s(%d,%d)%s", bootdev, unit, part, "netbsd"); | |
298 | 299 | |||
299 | howto = reorder_dipsw(dipsw2); | 300 | howto = reorder_dipsw(dipsw2); | |
300 | 301 | |||
301 | if ((howto & 0xFE) == 0) { | 302 | if ((howto & 0xFE) == 0) { | |
302 | char c; | 303 | char c; | |
303 | 304 | |||
304 | printf("Press return to boot now," | 305 | printf("Press return to boot now," | |
305 | " any other key for boot menu\n"); | 306 | " any other key for boot menu\n"); | |
306 | printf("booting %s - starting in ", default_file); | 307 | printf("booting %s - starting in ", default_file); | |
307 | c = awaitkey("%d seconds. ", boot_timeout, true); | 308 | c = awaitkey("%d seconds. ", boot_timeout, true); | |
308 | if (c == '\r' || c == '\n' || c == 0) { | 309 | if (c == '\r' || c == '\n' || c == 0) { | |
309 | printf("auto-boot %s\n", default_file); | 310 | printf("auto-boot %s\n", default_file); | |
310 | bootnetbsd(default_file); | 311 | bootnetbsd(default_file, 0); | |
311 | } | 312 | } | |
312 | } | 313 | } | |
313 | 314 | |||
314 | /* | 315 | /* | |
315 | * Main Loop | 316 | * Main Loop | |
316 | */ | 317 | */ | |
317 | 318 | |||
318 | printf("type \"help\" for help.\n"); | 319 | printf("type \"help\" for help.\n"); | |
319 | 320 | |||
320 | do { | 321 | do { | |
321 | memset(buffer, 0, BUFFSIZE); | 322 | memset(buffer, 0, BUFFSIZE); | |
322 | if (getline(prompt, buffer) > 0) { | 323 | if (getline(prompt, buffer) > 0) { | |
323 | argc = getargs(buffer, argv, sizeof(argv)/sizeof(char *)); | 324 | argc = getargs(buffer, argv, sizeof(argv)/sizeof(char *)); |
--- src/sys/arch/luna68k/stand/boot/parse.c 2013/01/22 15:48:40 1.4
+++ src/sys/arch/luna68k/stand/boot/parse.c 2014/01/11 08:08:23 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: parse.c,v 1.4 2013/01/22 15:48:40 tsutsui Exp $ */ | 1 | /* $NetBSD: parse.c,v 1.5 2014/01/11 08:08:23 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992 OMRON Corporation. | 4 | * Copyright (c) 1992 OMRON Corporation. | |
5 | * | 5 | * | |
6 | * This code is derived from software contributed to Berkeley by | 6 | * This code is derived from software contributed to Berkeley by | |
7 | * OMRON Corporation. | 7 | * OMRON Corporation. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -90,28 +90,29 @@ check_args(int argc, char *argv[]) | @@ -90,28 +90,29 @@ check_args(int argc, char *argv[]) | |||
90 | printf("argv[%d] = \"%s\"\n", i, argv[i]); | 90 | printf("argv[%d] = \"%s\"\n", i, argv[i]); | |
91 | 91 | |||
92 | return(ST_NORMAL); | 92 | return(ST_NORMAL); | |
93 | } | 93 | } | |
94 | 94 | |||
95 | int | 95 | int | |
96 | exit_program(int argc, char *argv[]) | 96 | exit_program(int argc, char *argv[]) | |
97 | { | 97 | { | |
98 | return(ST_EXIT); | 98 | return(ST_EXIT); | |
99 | } | 99 | } | |
100 | 100 | |||
101 | static const char helpmsg[] = | 101 | static const char helpmsg[] = | |
102 | "commands are:\n" | 102 | "commands are:\n" | |
103 | "boot [device(unit,part)filename]\n" | 103 | "boot [device(unit,part)filename] [-ads]\n" | |
104 | " (ex. \"boot sd(0,0)netbsd\", \"boot le(0,0)netbsd.old\" etc.)\n" | 104 | " (ex. \"boot sd(6,0)netbsd\", \"boot le()netbsd.old\" etc.)\n" | |
105 | " Note unit number for SCSI device is (ctlr) * 10 + (id)." | |||
105 | "ls [device(unit, part)[path]]\n" | 106 | "ls [device(unit, part)[path]]\n" | |
106 | " (ex. \"ls sd(0,0)/bin\")\n" | 107 | " (ex. \"ls sd(0,0)/bin\")\n" | |
107 | "help\n" | 108 | "help\n" | |
108 | "exit\n" | 109 | "exit\n" | |
109 | #if 0 /* debug commands */ | 110 | #if 0 /* debug commands */ | |
110 | "checkargs\n" | 111 | "checkargs\n" | |
111 | "disklabel\n" | 112 | "disklabel\n" | |
112 | "howto\n" | 113 | "howto\n" | |
113 | "screen\n" | 114 | "screen\n" | |
114 | "scsi\n" | 115 | "scsi\n" | |
115 | #endif | 116 | #endif | |
116 | ; | 117 | ; | |
117 | 118 | |||
@@ -129,27 +130,26 @@ struct command_entry { | @@ -129,27 +130,26 @@ struct command_entry { | |||
129 | }; | 130 | }; | |
130 | 131 | |||
131 | struct command_entry entries[] = { | 132 | struct command_entry entries[] = { | |
132 | { "b", boot }, | 133 | { "b", boot }, | |
133 | { "boot", boot }, | 134 | { "boot", boot }, | |
134 | { "chkargs", check_args }, | 135 | { "chkargs", check_args }, | |
135 | { "disklabel", disklabel }, | 136 | { "disklabel", disklabel }, | |
136 | { "exit", exit_program }, | 137 | { "exit", exit_program }, | |
137 | #ifdef notyet | 138 | #ifdef notyet | |
138 | { "fsdump", fsdump }, | 139 | { "fsdump", fsdump }, | |
139 | { "fsrestore", fsrestore }, | 140 | { "fsrestore", fsrestore }, | |
140 | #endif | 141 | #endif | |
141 | { "help", cmd_help }, | 142 | { "help", cmd_help }, | |
142 | { "howto", how_to_boot }, | |||
143 | { "ls", cmd_ls }, | 143 | { "ls", cmd_ls }, | |
144 | { "screen", screen }, | 144 | { "screen", screen }, | |
145 | #ifdef notyet | 145 | #ifdef notyet | |
146 | { "tape", tape }, | 146 | { "tape", tape }, | |
147 | { "tp", tape }, | 147 | { "tp", tape }, | |
148 | #endif | 148 | #endif | |
149 | { "scsi", scsi }, | 149 | { "scsi", scsi }, | |
150 | { "quit", exit_program }, | 150 | { "quit", exit_program }, | |
151 | { 0, 0 } | 151 | { 0, 0 } | |
152 | }; | 152 | }; | |
153 | 153 | |||
154 | 154 | |||
155 | int | 155 | int |
--- src/sys/arch/luna68k/stand/boot/samachdep.h 2014/01/10 11:12:03 1.15
+++ src/sys/arch/luna68k/stand/boot/samachdep.h 2014/01/11 08:08:23 1.16
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: samachdep.h,v 1.15 2014/01/10 11:12:03 tsutsui Exp $ */ | 1 | /* $NetBSD: samachdep.h,v 1.16 2014/01/11 08:08:23 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1982, 1990, 1993 | 4 | * Copyright (c) 1982, 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * 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. | |
@@ -44,56 +44,58 @@ | @@ -44,56 +44,58 @@ | |||
44 | #define MHZ_25 3 | 44 | #define MHZ_25 3 | |
45 | #define MHZ_33 4 | 45 | #define MHZ_33 4 | |
46 | #define MHZ_50 6 | 46 | #define MHZ_50 6 | |
47 | 47 | |||
48 | struct consdev; | 48 | struct consdev; | |
49 | struct frame; | 49 | struct frame; | |
50 | typedef struct label_t { | 50 | typedef struct label_t { | |
51 | int val[15]; | 51 | int val[15]; | |
52 | } label_t; | 52 | } label_t; | |
53 | 53 | |||
54 | /* autoconf.c */ | 54 | /* autoconf.c */ | |
55 | void configure(void); | 55 | void configure(void); | |
56 | void find_devs(void); | 56 | void find_devs(void); | |
57 | extern const int dev2adpt[]; | |||
57 | 58 | |||
58 | /* awaitkey.c */ | 59 | /* awaitkey.c */ | |
59 | char awaitkey(const char *, int, bool); | 60 | char awaitkey(const char *, int, bool); | |
60 | 61 | |||
61 | /* bmc.c */ | 62 | /* bmc.c */ | |
62 | void bmccnprobe(struct consdev *); | 63 | void bmccnprobe(struct consdev *); | |
63 | void bmccninit(struct consdev *); | 64 | void bmccninit(struct consdev *); | |
64 | int bmccngetc(dev_t); | 65 | int bmccngetc(dev_t); | |
65 | void bmccnputc(dev_t, int); | 66 | void bmccnputc(dev_t, int); | |
66 | 67 | |||
67 | /* bmd.c */ | 68 | /* bmd.c */ | |
68 | void bmdinit(void); | 69 | void bmdinit(void); | |
69 | int bmdputc(int); | 70 | int bmdputc(int); | |
70 | void bmdadjust(short, short); | 71 | void bmdadjust(short, short); | |
71 | void bmdclear(void); | 72 | void bmdclear(void); | |
72 | 73 | |||
73 | /* boot.c */ | 74 | /* boot.c */ | |
74 | extern int howto; | |||
75 | int how_to_boot(int, char **); | |||
76 | int boot(int, char **); | 75 | int boot(int, char **); | |
77 | int bootnetbsd(char *); | 76 | int bootnetbsd(char *, int); | |
78 | 77 | |||
79 | /* clock.c */ | 78 | /* clock.c */ | |
80 | /* not yet */ | 79 | /* not yet */ | |
81 | 80 | |||
82 | /* cons.c */ | 81 | /* cons.c */ | |
83 | void cninit(void); | 82 | void cninit(void); | |
84 | int cngetc(void); | 83 | int cngetc(void); | |
85 | void cnputc(int); | 84 | void cnputc(int); | |
86 | 85 | |||
86 | /* devopen.c */ | |||
87 | int make_device(const char *, int *, int *, int *, char **); | |||
88 | ||||
87 | /* disklabel.c */ | 89 | /* disklabel.c */ | |
88 | extern u_char lbl_buff[]; | 90 | extern u_char lbl_buff[]; | |
89 | int disklabel(int, char **); | 91 | int disklabel(int, char **); | |
90 | 92 | |||
91 | /* exec.c */ | 93 | /* exec.c */ | |
92 | void exec_hp300(char *, u_long, int); | 94 | void exec_hp300(char *, u_long, int); | |
93 | 95 | |||
94 | /* font.c */ | 96 | /* font.c */ | |
95 | extern const uint16_t bmdfont[][20]; | 97 | extern const uint16_t bmdfont[][20]; | |
96 | 98 | |||
97 | /* fsdump.c */ | 99 | /* fsdump.c */ | |
98 | int fsdump(int, char **); | 100 | int fsdump(int, char **); | |
99 | int fsrestore(int, char **); | 101 | int fsrestore(int, char **); |