Deleted Added
full compact
boot2.c (148767) boot2.c (149212)
1/*-
2 * Copyright (c) 1998 Robert Nordier
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are freely
6 * permitted provided that the above copyright notice and this
7 * paragraph and the following disclaimer are duplicated in all
8 * such forms.
9 *
10 * This software is provided "AS IS" and without any express or
11 * implied warranties, including, without limitation, the implied
12 * warranties of merchantability and fitness for a particular
13 * purpose.
14 */
15
16#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 Robert Nordier
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are freely
6 * permitted provided that the above copyright notice and this
7 * paragraph and the following disclaimer are duplicated in all
8 * such forms.
9 *
10 * This software is provided "AS IS" and without any express or
11 * implied warranties, including, without limitation, the implied
12 * warranties of merchantability and fitness for a particular
13 * purpose.
14 */
15
16#include <sys/cdefs.h>
17__FBSDID("$FreeBSD: head/sys/boot/i386/boot2/boot2.c 148767 2005-08-06 00:33:42Z ssouhlal $");
17__FBSDID("$FreeBSD: head/sys/boot/i386/boot2/boot2.c 149212 2005-08-18 00:42:45Z iedowse $");
18
19#include <sys/param.h>
20#include <sys/disklabel.h>
21#include <sys/diskmbr.h>
22#include <sys/dirent.h>
23#include <sys/reboot.h>
24
25#include <machine/bootinfo.h>

--- 32 unchanged lines hidden (view full) ---

58#define RBX_MUTE 0x10 /* -m */
59/* 0x11 is reserved for log2(RB_SELFTEST). */
60/* 0x12 is reserved for boot programs. */
61/* 0x13 is reserved for boot programs. */
62#define RBX_PAUSE 0x14 /* -p */
63#define RBX_NOINTR 0x1c /* -n */
64/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
65#define RBX_DUAL 0x1d /* -D */
18
19#include <sys/param.h>
20#include <sys/disklabel.h>
21#include <sys/diskmbr.h>
22#include <sys/dirent.h>
23#include <sys/reboot.h>
24
25#include <machine/bootinfo.h>

--- 32 unchanged lines hidden (view full) ---

58#define RBX_MUTE 0x10 /* -m */
59/* 0x11 is reserved for log2(RB_SELFTEST). */
60/* 0x12 is reserved for boot programs. */
61/* 0x13 is reserved for boot programs. */
62#define RBX_PAUSE 0x14 /* -p */
63#define RBX_NOINTR 0x1c /* -n */
64/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
65#define RBX_DUAL 0x1d /* -D */
66#define RBX_PROBEKBD 0x1e /* -P */
67/* 0x1f is reserved for log2(RB_BOOTINFO). */
68
69/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */
70#define RBX_MASK 0x2005ffff
71
72#define PATH_CONFIG "/boot.config"
73#define PATH_BOOT3 "/boot/loader"
74#define PATH_KERNEL "/boot/kernel/kernel"

--- 11 unchanged lines hidden (view full) ---

86
87#define TYPE_AD 0
88#define TYPE_DA 1
89#define TYPE_MAXHARD TYPE_DA
90#define TYPE_FD 2
91
92extern uint32_t _end;
93
66/* 0x1f is reserved for log2(RB_BOOTINFO). */
67
68/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */
69#define RBX_MASK 0x2005ffff
70
71#define PATH_CONFIG "/boot.config"
72#define PATH_BOOT3 "/boot/loader"
73#define PATH_KERNEL "/boot/kernel/kernel"

--- 11 unchanged lines hidden (view full) ---

85
86#define TYPE_AD 0
87#define TYPE_DA 1
88#define TYPE_MAXHARD TYPE_DA
89#define TYPE_FD 2
90
91extern uint32_t _end;
92
94static const char optstr[NOPT] = "DhaCgmnPprsv";
93static const char optstr[NOPT] = "DhaCgmnprsv"; /* Also 'P', 'S' */
95static const unsigned char flags[NOPT] = {
96 RBX_DUAL,
97 RBX_SERIAL,
98 RBX_ASKNAME,
99 RBX_CDROM,
100 RBX_GDB,
101 RBX_MUTE,
102 RBX_NOINTR,
94static const unsigned char flags[NOPT] = {
95 RBX_DUAL,
96 RBX_SERIAL,
97 RBX_ASKNAME,
98 RBX_CDROM,
99 RBX_GDB,
100 RBX_MUTE,
101 RBX_NOINTR,
103 RBX_PROBEKBD,
104 RBX_PAUSE,
105 RBX_DFLTROOT,
106 RBX_SINGLE,
107 RBX_VERBOSE
108};
109
110static const char *const dev_nm[NDEV] = {"ad", "da", "fd"};
111static const unsigned char dev_maj[NDEV] = {30, 4, 2};

--- 5 unchanged lines hidden (view full) ---

117 unsigned slice;
118 unsigned part;
119 unsigned start;
120 int init;
121} dsk;
122static char cmd[512];
123static char kname[1024];
124static uint32_t opts;
102 RBX_PAUSE,
103 RBX_DFLTROOT,
104 RBX_SINGLE,
105 RBX_VERBOSE
106};
107
108static const char *const dev_nm[NDEV] = {"ad", "da", "fd"};
109static const unsigned char dev_maj[NDEV] = {30, 4, 2};

--- 5 unchanged lines hidden (view full) ---

115 unsigned slice;
116 unsigned part;
117 unsigned start;
118 int init;
119} dsk;
120static char cmd[512];
121static char kname[1024];
122static uint32_t opts;
123static int comspeed = SIOSPD;
125static struct bootinfo bootinfo;
126static uint8_t ioctrl = IO_KEYBOARD;
127
128void exit(int);
129static void load(void);
130static int parse(void);
131static int xfsread(ino_t, void *, size_t);
132static int dskread(void *, unsigned, unsigned);

--- 252 unchanged lines hidden (view full) ---

385 MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part),
386 0, 0, 0, VTOP(&bootinfo));
387}
388
389static int
390parse()
391{
392 char *arg = cmd;
124static struct bootinfo bootinfo;
125static uint8_t ioctrl = IO_KEYBOARD;
126
127void exit(int);
128static void load(void);
129static int parse(void);
130static int xfsread(ino_t, void *, size_t);
131static int dskread(void *, unsigned, unsigned);

--- 252 unchanged lines hidden (view full) ---

384 MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part),
385 0, 0, 0, VTOP(&bootinfo));
386}
387
388static int
389parse()
390{
391 char *arg = cmd;
393 char *p, *q;
392 char *ep, *p, *q;
393 const char *cp;
394 unsigned int drv;
394 unsigned int drv;
395 int c, i;
395 int c, i, j;
396
397 while ((c = *arg++)) {
398 if (c == ' ' || c == '\t' || c == '\n')
399 continue;
400 for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++);
396
397 while ((c = *arg++)) {
398 if (c == ' ' || c == '\t' || c == '\n')
399 continue;
400 for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++);
401 ep = p;
401 if (*p)
402 *p++ = 0;
403 if (c == '-') {
404 while ((c = *arg++)) {
402 if (*p)
403 *p++ = 0;
404 if (c == '-') {
405 while ((c = *arg++)) {
406 if (c == 'P') {
407 if (*(uint8_t *)PTOV(0x496) & 0x10) {
408 cp = "yes";
409 } else {
410 opts |= 1 << RBX_DUAL | 1 << RBX_SERIAL;
411 cp = "no";
412 }
413 printf("Keyboard: %s\n", cp);
414 continue;
415 } else if (c == 'S') {
416 j = 0;
417 while ((unsigned int)(i = *arg++ - '0') <= 9)
418 j = j * 10 + i;
419 if (j > 0 && i == -'0') {
420 comspeed = j;
421 break;
422 }
423 /* Fall through to error below ('S' not in optstr[]). */
424 }
405 for (i = 0; c != optstr[i]; i++)
406 if (i == NOPT - 1)
407 return -1;
408 opts ^= 1 << flags[i];
409 }
425 for (i = 0; c != optstr[i]; i++)
426 if (i == NOPT - 1)
427 return -1;
428 opts ^= 1 << flags[i];
429 }
410 if (opts & 1 << RBX_PROBEKBD) {
411 i = *(uint8_t *)PTOV(0x496) & 0x10;
412 printf("Keyboard: %s\n", i ? "yes" : "no");
413 if (!i)
414 opts |= 1 << RBX_DUAL | 1 << RBX_SERIAL;
415 opts &= ~(1 << RBX_PROBEKBD);
416 }
417 ioctrl = opts & 1 << RBX_DUAL ? (IO_SERIAL|IO_KEYBOARD) :
418 opts & 1 << RBX_SERIAL ? IO_SERIAL : IO_KEYBOARD;
419 if (ioctrl & IO_SERIAL)
430 ioctrl = opts & 1 << RBX_DUAL ? (IO_SERIAL|IO_KEYBOARD) :
431 opts & 1 << RBX_SERIAL ? IO_SERIAL : IO_KEYBOARD;
432 if (ioctrl & IO_SERIAL)
420 sio_init();
433 sio_init(115200 / comspeed);
421 } else {
422 for (q = arg--; *q && *q != '('; q++);
423 if (*q) {
424 drv = -1;
425 if (arg[1] == ':') {
426 drv = *arg - '0';
427 if (drv > 9)
428 return (-1);

--- 25 unchanged lines hidden (view full) ---

454 return (-1);
455 arg += 2;
456 if (drv == -1)
457 drv = dsk.unit;
458 dsk.drive = (dsk.type <= TYPE_MAXHARD
459 ? DRV_HARD : 0) + drv;
460 dsk_meta = 0;
461 }
434 } else {
435 for (q = arg--; *q && *q != '('; q++);
436 if (*q) {
437 drv = -1;
438 if (arg[1] == ':') {
439 drv = *arg - '0';
440 if (drv > 9)
441 return (-1);

--- 25 unchanged lines hidden (view full) ---

467 return (-1);
468 arg += 2;
469 if (drv == -1)
470 drv = dsk.unit;
471 dsk.drive = (dsk.type <= TYPE_MAXHARD
472 ? DRV_HARD : 0) + drv;
473 dsk_meta = 0;
474 }
462 if ((i = p - arg - !*(p - 1))) {
475 if ((i = ep - arg)) {
463 if ((size_t)i >= sizeof(kname))
464 return -1;
465 memcpy(kname, arg, i + 1);
466 }
467 }
468 arg = p;
469 }
470 return 0;

--- 184 unchanged lines hidden ---
476 if ((size_t)i >= sizeof(kname))
477 return -1;
478 memcpy(kname, arg, i + 1);
479 }
480 }
481 arg = p;
482 }
483 return 0;

--- 184 unchanged lines hidden ---