Lines 44-49
Link Here
|
44 |
|
44 |
|
45 |
#define MBRSIZE 512 /* master boot record size */ |
45 |
#define MBRSIZE 512 /* master boot record size */ |
46 |
|
46 |
|
|
|
47 |
#define OFF_OPT 0x1b9 /* offset: default boot option */ |
47 |
#define OFF_DRIVE 0x1ba /* offset: setdrv drive */ |
48 |
#define OFF_DRIVE 0x1ba /* offset: setdrv drive */ |
48 |
#define OFF_FLAGS 0x1bb /* offset: option flags */ |
49 |
#define OFF_FLAGS 0x1bb /* offset: option flags */ |
49 |
#define OFF_TICKS 0x1bc /* offset: clock ticks */ |
50 |
#define OFF_TICKS 0x1bc /* offset: clock ticks */ |
Lines 89-105
Link Here
|
89 |
const char *bpath, *fpath, *disk; |
90 |
const char *bpath, *fpath, *disk; |
90 |
ssize_t n; |
91 |
ssize_t n; |
91 |
int B_flag, v_flag, o_flag; |
92 |
int B_flag, v_flag, o_flag; |
92 |
int d_arg, m_arg, t_arg; |
93 |
int d_arg, m_arg, s_arg, t_arg; |
93 |
int o_and, o_or; |
94 |
int o_and, o_or; |
94 |
int fd, fd1, up, c, i; |
95 |
int fd, fd1, up, c, i; |
95 |
|
96 |
|
96 |
bpath = "/boot/boot0"; |
97 |
bpath = "/boot/boot0"; |
97 |
fpath = NULL; |
98 |
fpath = NULL; |
98 |
B_flag = v_flag = o_flag = 0; |
99 |
B_flag = v_flag = o_flag = 0; |
99 |
d_arg = m_arg = t_arg = -1; |
100 |
d_arg = m_arg = s_arg = t_arg = -1; |
100 |
o_and = 0xff; |
101 |
o_and = 0xff; |
101 |
o_or = 0; |
102 |
o_or = 0; |
102 |
while ((c = getopt(argc, argv, "Bvb:d:f:m:o:t:")) != -1) |
103 |
while ((c = getopt(argc, argv, "Bvb:d:f:m:o:s:t:")) != -1) |
103 |
switch (c) { |
104 |
switch (c) { |
104 |
case 'B': |
105 |
case 'B': |
105 |
B_flag = 1; |
106 |
B_flag = 1; |
Lines 123-128
Link Here
|
123 |
stropt(optarg, &o_and, &o_or); |
124 |
stropt(optarg, &o_and, &o_or); |
124 |
o_flag = 1; |
125 |
o_flag = 1; |
125 |
break; |
126 |
break; |
|
|
127 |
case 's': |
128 |
s_arg = argtoi(optarg, 1, 5, 's'); |
129 |
break; |
126 |
case 't': |
130 |
case 't': |
127 |
t_arg = argtoi(optarg, 1, 0xffff, 't'); |
131 |
t_arg = argtoi(optarg, 1, 0xffff, 't'); |
128 |
break; |
132 |
break; |
Lines 134-140
Link Here
|
134 |
if (argc != 1) |
138 |
if (argc != 1) |
135 |
usage(); |
139 |
usage(); |
136 |
disk = mkrdev(*argv); |
140 |
disk = mkrdev(*argv); |
137 |
up = B_flag || d_arg != -1 || m_arg != -1 || o_flag || t_arg != -1; |
141 |
up = B_flag || d_arg != -1 || m_arg != -1 || o_flag || s_arg != -1 || |
|
|
142 |
t_arg != -1; |
138 |
if ((fd = open(disk, up ? O_RDWR : O_RDONLY)) == -1) |
143 |
if ((fd = open(disk, up ? O_RDWR : O_RDONLY)) == -1) |
139 |
err(1, "%s", disk); |
144 |
err(1, "%s", disk); |
140 |
if ((n = read(fd, buf, MBRSIZE)) == -1) |
145 |
if ((n = read(fd, buf, MBRSIZE)) == -1) |
Lines 174-179
Link Here
|
174 |
buf[OFF_FLAGS] &= o_and; |
179 |
buf[OFF_FLAGS] &= o_and; |
175 |
buf[OFF_FLAGS] |= o_or; |
180 |
buf[OFF_FLAGS] |= o_or; |
176 |
} |
181 |
} |
|
|
182 |
if (s_arg != -1) |
183 |
buf[OFF_OPT] = s_arg - 1; |
177 |
if (t_arg != -1) |
184 |
if (t_arg != -1) |
178 |
mk2(buf + OFF_TICKS, t_arg); |
185 |
mk2(buf + OFF_TICKS, t_arg); |
179 |
if (up) { |
186 |
if (up) { |
Lines 211-216
Link Here
|
211 |
printf("%s", opttbl[i].tok); |
218 |
printf("%s", opttbl[i].tok); |
212 |
} |
219 |
} |
213 |
printf(" ticks=%u\n", cv2(buf + OFF_TICKS)); |
220 |
printf(" ticks=%u\n", cv2(buf + OFF_TICKS)); |
|
|
221 |
printf("default_selection=F%d (", buf[OFF_OPT] + 1); |
222 |
if (buf[OFF_OPT] < 4) |
223 |
printf("Slice %d", buf[OFF_OPT] + 1); |
224 |
else |
225 |
printf("Drive 1"); |
226 |
printf(")\n"); |
214 |
} |
227 |
} |
215 |
return 0; |
228 |
return 0; |
216 |
} |
229 |
} |
Lines 316-321
Link Here
|
316 |
{ |
329 |
{ |
317 |
fprintf(stderr, "%s\n%s\n", |
330 |
fprintf(stderr, "%s\n%s\n", |
318 |
"usage: boot0cfg [-Bv] [-b boot0] [-d drive] [-f file] [-m mask]", |
331 |
"usage: boot0cfg [-Bv] [-b boot0] [-d drive] [-f file] [-m mask]", |
319 |
" [-o options] [-t ticks] disk"); |
332 |
" [-o options] [-s slice] [-t ticks] disk"); |
320 |
exit(1); |
333 |
exit(1); |
321 |
} |
334 |
} |