Backout previous commit - for some reason it overflows space constrains on

amd64. Better version will follow.
This commit is contained in:
Maxim Sobolev 2005-10-16 19:49:44 +00:00
parent 7a1b87774c
commit 6267ee870d
2 changed files with 48 additions and 64 deletions

View File

@ -60,22 +60,20 @@ __FBSDID("$FreeBSD$");
/* 0x12 is reserved for boot programs. */ /* 0x12 is reserved for boot programs. */
/* 0x13 is reserved for boot programs. */ /* 0x13 is reserved for boot programs. */
#define RBX_PAUSE 0x14 /* -p */ #define RBX_PAUSE 0x14 /* -p */
#define RBX_NOINTR 0x1c /* -n */
/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */ /* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
#define RBX_DUAL 0x1d /* -D */ #define RBX_DUAL 0x1d /* -D */
/* 0x1f is reserved for log2(RB_BOOTINFO). */ /* 0x1f is reserved for log2(RB_BOOTINFO). */
/* group of internal options below */
#define RBX_NOINTR 0x20 /* -n */
#define RBX_QUIET 0x21 /* -q */
/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */ /* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */
#define RBX_MASK 0xffffffff #define RBX_MASK 0x2011ffff
#define PATH_CONFIG "/boot.config" #define PATH_CONFIG "/boot.config"
#define PATH_BOOT3 "/boot/loader" #define PATH_BOOT3 "/boot/loader"
#define PATH_KERNEL "/boot/kernel/kernel" #define PATH_KERNEL "/boot/kernel/kernel"
#define ARGS 0x900 #define ARGS 0x900
#define NOPT 12 #define NOPT 11
#define NDEV 3 #define NDEV 3
#define MEM_BASE 0x12 #define MEM_BASE 0x12
#define MEM_EXT 0x15 #define MEM_EXT 0x15
@ -90,11 +88,9 @@ __FBSDID("$FreeBSD$");
#define TYPE_MAXHARD TYPE_DA #define TYPE_MAXHARD TYPE_DA
#define TYPE_FD 2 #define TYPE_FD 2
#define OPT_CHECK(opt) ((opts >> (opt)) & 0x1)
extern uint32_t _end; extern uint32_t _end;
static const char optstr[NOPT] = "DhaCgmnpqrsv"; /* Also 'P', 'S' */ static const char optstr[NOPT] = "DhaCgmnprsv"; /* Also 'P', 'S' */
static const unsigned char flags[NOPT] = { static const unsigned char flags[NOPT] = {
RBX_DUAL, RBX_DUAL,
RBX_SERIAL, RBX_SERIAL,
@ -104,7 +100,6 @@ static const unsigned char flags[NOPT] = {
RBX_MUTE, RBX_MUTE,
RBX_NOINTR, RBX_NOINTR,
RBX_PAUSE, RBX_PAUSE,
RBX_QUIET,
RBX_DFLTROOT, RBX_DFLTROOT,
RBX_SINGLE, RBX_SINGLE,
RBX_VERBOSE RBX_VERBOSE
@ -124,7 +119,7 @@ static struct dsk {
} dsk; } dsk;
static char cmd[512]; static char cmd[512];
static char kname[1024]; static char kname[1024];
static uint64_t opts; static uint32_t opts;
static int comspeed = SIOSPD; static int comspeed = SIOSPD;
static struct bootinfo bootinfo; static struct bootinfo bootinfo;
static uint8_t ioctrl = IO_KEYBOARD; static uint8_t ioctrl = IO_KEYBOARD;
@ -163,7 +158,7 @@ strcmp(const char *s1, const char *s2)
#include "ufsread.c" #include "ufsread.c"
static inline int static int
xfsread(ino_t inode, void *buf, size_t nbyte) xfsread(ino_t inode, void *buf, size_t nbyte)
{ {
if ((size_t)fsread(inode, buf, nbyte) != nbyte) { if ((size_t)fsread(inode, buf, nbyte) != nbyte) {
@ -249,8 +244,7 @@ main(void)
if (*cmd) { if (*cmd) {
if (parse()) if (parse())
autoboot = 0; autoboot = 0;
if (!OPT_CHECK(RBX_QUIET)) printf("%s: %s", PATH_CONFIG, cmd);
printf("%s: %s", PATH_CONFIG, cmd);
/* Do not process this command twice */ /* Do not process this command twice */
*cmd = 0; *cmd = 0;
} }
@ -271,17 +265,16 @@ main(void)
/* Present the user with the boot2 prompt. */ /* Present the user with the boot2 prompt. */
for (;;) { for (;;) {
if (!autoboot || !OPT_CHECK(RBX_QUIET)) printf("\nFreeBSD/i386 boot\n"
printf("\nFreeBSD/i386 boot\n" "Default: %u:%s(%u,%c)%s\n"
"Default: %u:%s(%u,%c)%s\n" "boot: ",
"boot: ", dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit, 'a' + dsk.part, kname);
'a' + dsk.part, kname);
if (ioctrl & IO_SERIAL) if (ioctrl & IO_SERIAL)
sio_flush(); sio_flush();
if (!autoboot || keyhit(5*SECOND)) if (!autoboot || keyhit(5*SECOND))
getstr(); getstr();
else if (!autoboot || !OPT_CHECK(RBX_QUIET)) else
putchar('\n'); putchar('\n');
autoboot = 0; autoboot = 0;
if (parse()) if (parse())
@ -300,12 +293,12 @@ exit(int x)
static void static void
load(void) load(void)
{ {
static union { union {
struct exec ex; struct exec ex;
Elf32_Ehdr eh; Elf32_Ehdr eh;
} hdr; } hdr;
static Elf32_Phdr ep[2]; Elf32_Phdr ep[2];
static Elf32_Shdr es[2]; Elf32_Shdr es[2];
caddr_t p; caddr_t p;
ino_t ino; ino_t ino;
uint32_t addr, x; uint32_t addr, x;
@ -387,7 +380,7 @@ load(void)
bootinfo.bi_esymtab = VTOP(p); bootinfo.bi_esymtab = VTOP(p);
bootinfo.bi_kernelname = VTOP(kname); bootinfo.bi_kernelname = VTOP(kname);
bootinfo.bi_bios_dev = dsk.drive; bootinfo.bi_bios_dev = dsk.drive;
__exec((caddr_t)addr, RB_BOOTINFO | (uint32_t)(opts & RBX_MASK), __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part), MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part),
0, 0, 0, VTOP(&bootinfo)); 0, 0, 0, VTOP(&bootinfo));
} }
@ -414,7 +407,7 @@ parse()
if (*(uint8_t *)PTOV(0x496) & 0x10) { if (*(uint8_t *)PTOV(0x496) & 0x10) {
cp = "yes"; cp = "yes";
} else { } else {
opts |= (uint64_t)1 << RBX_DUAL | (uint64_t)1 << RBX_SERIAL; opts |= 1 << RBX_DUAL | 1 << RBX_SERIAL;
cp = "no"; cp = "no";
} }
printf("Keyboard: %s\n", cp); printf("Keyboard: %s\n", cp);
@ -432,10 +425,10 @@ parse()
for (i = 0; c != optstr[i]; i++) for (i = 0; c != optstr[i]; i++)
if (i == NOPT - 1) if (i == NOPT - 1)
return -1; return -1;
opts ^= (uint64_t)1 << flags[i]; opts ^= 1 << flags[i];
} }
ioctrl = opts & (uint64_t)1 << RBX_DUAL ? (IO_SERIAL|IO_KEYBOARD) : ioctrl = opts & 1 << RBX_DUAL ? (IO_SERIAL|IO_KEYBOARD) :
opts & (uint64_t)1 << RBX_SERIAL ? IO_SERIAL : IO_KEYBOARD; opts & 1 << RBX_SERIAL ? IO_SERIAL : IO_KEYBOARD;
if (ioctrl & IO_SERIAL) if (ioctrl & IO_SERIAL)
sio_init(115200 / comspeed); sio_init(115200 / comspeed);
} else { } else {
@ -603,8 +596,7 @@ drvread(void *buf, unsigned lba, unsigned nblk)
{ {
static unsigned c = 0x2d5c7c2f; static unsigned c = 0x2d5c7c2f;
if (!OPT_CHECK(RBX_QUIET)) printf("%c\b", c = c << 8 | c >> 24);
printf("%c\b", c = c << 8 | c >> 24);
v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
v86.addr = XREADORG; /* call to xread in boot1 */ v86.addr = XREADORG; /* call to xread in boot1 */
v86.es = VTOPSEG(buf); v86.es = VTOPSEG(buf);
@ -626,7 +618,7 @@ keyhit(unsigned ticks)
{ {
uint32_t t0, t1; uint32_t t0, t1;
if (OPT_CHECK(RBX_NOINTR)) if (opts & 1 << RBX_NOINTR)
return 0; return 0;
t0 = 0; t0 = 0;
for (;;) { for (;;) {
@ -653,7 +645,7 @@ xputc(int c)
static int static int
xgetc(int fn) xgetc(int fn)
{ {
if (OPT_CHECK(RBX_NOINTR)) if (opts & 1 << RBX_NOINTR)
return 0; return 0;
for (;;) { for (;;) {
if (ioctrl & IO_KEYBOARD && getc(1)) if (ioctrl & IO_KEYBOARD && getc(1))

View File

@ -60,22 +60,20 @@ __FBSDID("$FreeBSD$");
/* 0x12 is reserved for boot programs. */ /* 0x12 is reserved for boot programs. */
/* 0x13 is reserved for boot programs. */ /* 0x13 is reserved for boot programs. */
#define RBX_PAUSE 0x14 /* -p */ #define RBX_PAUSE 0x14 /* -p */
#define RBX_NOINTR 0x1c /* -n */
/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */ /* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
#define RBX_DUAL 0x1d /* -D */ #define RBX_DUAL 0x1d /* -D */
/* 0x1f is reserved for log2(RB_BOOTINFO). */ /* 0x1f is reserved for log2(RB_BOOTINFO). */
/* group of internal options below */
#define RBX_NOINTR 0x20 /* -n */
#define RBX_QUIET 0x21 /* -q */
/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */ /* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */
#define RBX_MASK 0xffffffff #define RBX_MASK 0x2011ffff
#define PATH_CONFIG "/boot.config" #define PATH_CONFIG "/boot.config"
#define PATH_BOOT3 "/boot/loader" #define PATH_BOOT3 "/boot/loader"
#define PATH_KERNEL "/boot/kernel/kernel" #define PATH_KERNEL "/boot/kernel/kernel"
#define ARGS 0x900 #define ARGS 0x900
#define NOPT 12 #define NOPT 11
#define NDEV 3 #define NDEV 3
#define MEM_BASE 0x12 #define MEM_BASE 0x12
#define MEM_EXT 0x15 #define MEM_EXT 0x15
@ -90,11 +88,9 @@ __FBSDID("$FreeBSD$");
#define TYPE_MAXHARD TYPE_DA #define TYPE_MAXHARD TYPE_DA
#define TYPE_FD 2 #define TYPE_FD 2
#define OPT_CHECK(opt) ((opts >> (opt)) & 0x1)
extern uint32_t _end; extern uint32_t _end;
static const char optstr[NOPT] = "DhaCgmnpqrsv"; /* Also 'P', 'S' */ static const char optstr[NOPT] = "DhaCgmnprsv"; /* Also 'P', 'S' */
static const unsigned char flags[NOPT] = { static const unsigned char flags[NOPT] = {
RBX_DUAL, RBX_DUAL,
RBX_SERIAL, RBX_SERIAL,
@ -104,7 +100,6 @@ static const unsigned char flags[NOPT] = {
RBX_MUTE, RBX_MUTE,
RBX_NOINTR, RBX_NOINTR,
RBX_PAUSE, RBX_PAUSE,
RBX_QUIET,
RBX_DFLTROOT, RBX_DFLTROOT,
RBX_SINGLE, RBX_SINGLE,
RBX_VERBOSE RBX_VERBOSE
@ -124,7 +119,7 @@ static struct dsk {
} dsk; } dsk;
static char cmd[512]; static char cmd[512];
static char kname[1024]; static char kname[1024];
static uint64_t opts; static uint32_t opts;
static int comspeed = SIOSPD; static int comspeed = SIOSPD;
static struct bootinfo bootinfo; static struct bootinfo bootinfo;
static uint8_t ioctrl = IO_KEYBOARD; static uint8_t ioctrl = IO_KEYBOARD;
@ -163,7 +158,7 @@ strcmp(const char *s1, const char *s2)
#include "ufsread.c" #include "ufsread.c"
static inline int static int
xfsread(ino_t inode, void *buf, size_t nbyte) xfsread(ino_t inode, void *buf, size_t nbyte)
{ {
if ((size_t)fsread(inode, buf, nbyte) != nbyte) { if ((size_t)fsread(inode, buf, nbyte) != nbyte) {
@ -249,8 +244,7 @@ main(void)
if (*cmd) { if (*cmd) {
if (parse()) if (parse())
autoboot = 0; autoboot = 0;
if (!OPT_CHECK(RBX_QUIET)) printf("%s: %s", PATH_CONFIG, cmd);
printf("%s: %s", PATH_CONFIG, cmd);
/* Do not process this command twice */ /* Do not process this command twice */
*cmd = 0; *cmd = 0;
} }
@ -271,17 +265,16 @@ main(void)
/* Present the user with the boot2 prompt. */ /* Present the user with the boot2 prompt. */
for (;;) { for (;;) {
if (!autoboot || !OPT_CHECK(RBX_QUIET)) printf("\nFreeBSD/i386 boot\n"
printf("\nFreeBSD/i386 boot\n" "Default: %u:%s(%u,%c)%s\n"
"Default: %u:%s(%u,%c)%s\n" "boot: ",
"boot: ", dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit, 'a' + dsk.part, kname);
'a' + dsk.part, kname);
if (ioctrl & IO_SERIAL) if (ioctrl & IO_SERIAL)
sio_flush(); sio_flush();
if (!autoboot || keyhit(5*SECOND)) if (!autoboot || keyhit(5*SECOND))
getstr(); getstr();
else if (!autoboot || !OPT_CHECK(RBX_QUIET)) else
putchar('\n'); putchar('\n');
autoboot = 0; autoboot = 0;
if (parse()) if (parse())
@ -300,12 +293,12 @@ exit(int x)
static void static void
load(void) load(void)
{ {
static union { union {
struct exec ex; struct exec ex;
Elf32_Ehdr eh; Elf32_Ehdr eh;
} hdr; } hdr;
static Elf32_Phdr ep[2]; Elf32_Phdr ep[2];
static Elf32_Shdr es[2]; Elf32_Shdr es[2];
caddr_t p; caddr_t p;
ino_t ino; ino_t ino;
uint32_t addr, x; uint32_t addr, x;
@ -387,7 +380,7 @@ load(void)
bootinfo.bi_esymtab = VTOP(p); bootinfo.bi_esymtab = VTOP(p);
bootinfo.bi_kernelname = VTOP(kname); bootinfo.bi_kernelname = VTOP(kname);
bootinfo.bi_bios_dev = dsk.drive; bootinfo.bi_bios_dev = dsk.drive;
__exec((caddr_t)addr, RB_BOOTINFO | (uint32_t)(opts & RBX_MASK), __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part), MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part),
0, 0, 0, VTOP(&bootinfo)); 0, 0, 0, VTOP(&bootinfo));
} }
@ -414,7 +407,7 @@ parse()
if (*(uint8_t *)PTOV(0x496) & 0x10) { if (*(uint8_t *)PTOV(0x496) & 0x10) {
cp = "yes"; cp = "yes";
} else { } else {
opts |= (uint64_t)1 << RBX_DUAL | (uint64_t)1 << RBX_SERIAL; opts |= 1 << RBX_DUAL | 1 << RBX_SERIAL;
cp = "no"; cp = "no";
} }
printf("Keyboard: %s\n", cp); printf("Keyboard: %s\n", cp);
@ -432,10 +425,10 @@ parse()
for (i = 0; c != optstr[i]; i++) for (i = 0; c != optstr[i]; i++)
if (i == NOPT - 1) if (i == NOPT - 1)
return -1; return -1;
opts ^= (uint64_t)1 << flags[i]; opts ^= 1 << flags[i];
} }
ioctrl = opts & (uint64_t)1 << RBX_DUAL ? (IO_SERIAL|IO_KEYBOARD) : ioctrl = opts & 1 << RBX_DUAL ? (IO_SERIAL|IO_KEYBOARD) :
opts & (uint64_t)1 << RBX_SERIAL ? IO_SERIAL : IO_KEYBOARD; opts & 1 << RBX_SERIAL ? IO_SERIAL : IO_KEYBOARD;
if (ioctrl & IO_SERIAL) if (ioctrl & IO_SERIAL)
sio_init(115200 / comspeed); sio_init(115200 / comspeed);
} else { } else {
@ -603,8 +596,7 @@ drvread(void *buf, unsigned lba, unsigned nblk)
{ {
static unsigned c = 0x2d5c7c2f; static unsigned c = 0x2d5c7c2f;
if (!OPT_CHECK(RBX_QUIET)) printf("%c\b", c = c << 8 | c >> 24);
printf("%c\b", c = c << 8 | c >> 24);
v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
v86.addr = XREADORG; /* call to xread in boot1 */ v86.addr = XREADORG; /* call to xread in boot1 */
v86.es = VTOPSEG(buf); v86.es = VTOPSEG(buf);
@ -626,7 +618,7 @@ keyhit(unsigned ticks)
{ {
uint32_t t0, t1; uint32_t t0, t1;
if (OPT_CHECK(RBX_NOINTR)) if (opts & 1 << RBX_NOINTR)
return 0; return 0;
t0 = 0; t0 = 0;
for (;;) { for (;;) {
@ -653,7 +645,7 @@ xputc(int c)
static int static int
xgetc(int fn) xgetc(int fn)
{ {
if (OPT_CHECK(RBX_NOINTR)) if (opts & 1 << RBX_NOINTR)
return 0; return 0;
for (;;) { for (;;) {
if (ioctrl & IO_KEYBOARD && getc(1)) if (ioctrl & IO_KEYBOARD && getc(1))