mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-29 00:12:45 +00:00
Make both UFS1 and UFS2 fit on the same boot blocks. These are a
subset of Peter's patchs that are believed to be safe. Makefile tweaks: o -fomit-frame-pointer o Change default to building both UFS1 and UFS2 bootblocks. Lots of boot2 tweaks: o lookup is only ever called with kname, so use it directly. o inline memsize o getstr are only ever called with cmd, so hardware that. o tweaks to the parsing code to test after the conversion rather than before since we tested after anyways. o eliminate support for %x in printf. o eliminate a few bytes in printfs. o Tweak the boot banner. o eliminate support for wd and " " devices (I might add wd back to keep bde happy). o eliminate support for a few arguments. This takes us from -162 bytes free to 67 bytes free. I've tested this only on a few systems, so be careful when updating to this change. Submitted by: peter, imp, ian
This commit is contained in:
parent
5f7d68b87e
commit
2db4f48c6a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=108000
@ -31,11 +31,11 @@ ORG2= 0x2000
|
||||
# Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit.
|
||||
|
||||
# BOOT2_UFS?= UFS2_ONLY
|
||||
# BOOT2_UFS?= UFS1_AND_UFS2
|
||||
BOOT2_UFS?= UFS1_ONLY
|
||||
BOOT2_UFS?= UFS1_AND_UFS2
|
||||
# BOOT2_UFS?= UFS1_ONLY
|
||||
|
||||
CFLAGS= -elf -ffreestanding -Os -fno-builtin \
|
||||
-fno-guess-branch-probability \
|
||||
-fno-guess-branch-probability -fomit-frame-pointer\
|
||||
-mrtd \
|
||||
-D${BOOT2_UFS} \
|
||||
-I${.CURDIR}/../../common \
|
||||
@ -44,7 +44,7 @@ CFLAGS= -elf -ffreestanding -Os -fno-builtin \
|
||||
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
|
||||
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
|
||||
|
||||
LDFLAGS=-nostdlib -static -N
|
||||
LDFLAGS=-nostdlib -static -N --gc-sections
|
||||
|
||||
all: boot1 boot2
|
||||
|
||||
@ -61,7 +61,6 @@ boot1.o: boot1.s
|
||||
boot2.o: boot2.c ${.CURDIR}/../../common/ufsread.c
|
||||
${CC} ${CFLAGS} -S -o boot2.s.tmp ${.IMPSRC}
|
||||
sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
|
||||
rm -f boot2.s.tmp
|
||||
${AS} ${AFLAGS} -o boot2.o boot2.s
|
||||
|
||||
boot2.h: boot1.out
|
||||
|
@ -62,8 +62,8 @@
|
||||
#define PATH_KERNEL "/kernel"
|
||||
|
||||
#define ARGS 0x900
|
||||
#define NOPT 14
|
||||
#define NDEV 5
|
||||
#define NOPT 12
|
||||
#define NDEV 3
|
||||
#define MEM_BASE 0x12
|
||||
#define MEM_EXT 0x15
|
||||
#define V86_CY(x) ((x) & 1)
|
||||
@ -73,20 +73,18 @@
|
||||
#define DRV_MASK 0x7f
|
||||
|
||||
#define TYPE_AD 0
|
||||
#define TYPE_DA 2
|
||||
#define TYPE_DA 1
|
||||
#define TYPE_MAXHARD TYPE_DA
|
||||
#define TYPE_FD 4
|
||||
#define TYPE_FD 2
|
||||
|
||||
extern uint32_t _end;
|
||||
|
||||
static const char optstr[NOPT] = "DhaCcdgmnPprsv";
|
||||
static const char optstr[NOPT] = "DhaCgmnPprsv";
|
||||
static const unsigned char flags[NOPT] = {
|
||||
RBX_DUAL,
|
||||
RBX_SERIAL,
|
||||
RBX_ASKNAME,
|
||||
RBX_CDROM,
|
||||
RBX_CONFIG,
|
||||
RBX_KDB,
|
||||
RBX_GDB,
|
||||
RBX_MUTE,
|
||||
RBX_NOINTR,
|
||||
@ -97,8 +95,8 @@ static const unsigned char flags[NOPT] = {
|
||||
RBX_VERBOSE
|
||||
};
|
||||
|
||||
static const char *const dev_nm[NDEV] = {"ad", "wd", "da", " ", "fd"};
|
||||
static const unsigned char dev_maj[NDEV] = {30, 0, 4, 1, 2};
|
||||
static const char *const dev_nm[NDEV] = {"ad", "da", "fd"};
|
||||
static const unsigned char dev_maj[NDEV] = {30, 4, 2};
|
||||
|
||||
static struct dsk {
|
||||
unsigned drive;
|
||||
@ -116,13 +114,13 @@ static struct bootinfo bootinfo;
|
||||
static uint8_t ioctrl = IO_KEYBOARD;
|
||||
|
||||
void exit(int);
|
||||
static void load(const char *);
|
||||
static int parse(char *);
|
||||
static void load(void);
|
||||
static int parse(void);
|
||||
static int xfsread(ino_t, void *, size_t);
|
||||
static int dskread(void *, unsigned, unsigned);
|
||||
static void printf(const char *,...);
|
||||
static void putchar(int);
|
||||
static uint32_t memsize(int);
|
||||
static uint32_t memsize(void);
|
||||
static int drvread(void *, unsigned, unsigned);
|
||||
static int keyhit(unsigned);
|
||||
static int xputc(int);
|
||||
@ -150,37 +148,42 @@ xfsread(ino_t inode, void *buf, size_t nbyte)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
memsize(void)
|
||||
{
|
||||
v86.addr = MEM_EXT;
|
||||
v86.eax = 0x8800;
|
||||
v86int();
|
||||
return v86.eax;
|
||||
}
|
||||
|
||||
static inline void
|
||||
getstr(char *str, int size)
|
||||
getstr(void)
|
||||
{
|
||||
char *s;
|
||||
int c;
|
||||
|
||||
s = str;
|
||||
s = cmd;
|
||||
for (;;) {
|
||||
switch (c = xgetc(0)) {
|
||||
case 0:
|
||||
break;
|
||||
continue;
|
||||
case '\177':
|
||||
c = '\b';
|
||||
case '\b':
|
||||
if (s > str) {
|
||||
if (s > cmd) {
|
||||
s--;
|
||||
putchar('\b');
|
||||
putchar(' ');
|
||||
} else
|
||||
c = 0;
|
||||
break;
|
||||
printf("\b \b");
|
||||
}
|
||||
continue;
|
||||
case '\n':
|
||||
case '\r':
|
||||
*s = 0;
|
||||
return;
|
||||
default:
|
||||
if (s - str < size - 1)
|
||||
if (s - cmd < sizeof(cmd) - 1)
|
||||
*s++ = c;
|
||||
}
|
||||
if (c)
|
||||
putchar(c);
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,7 +211,7 @@ main(void)
|
||||
bootinfo.bi_version = BOOTINFO_VERSION;
|
||||
bootinfo.bi_size = sizeof(bootinfo);
|
||||
bootinfo.bi_basemem = 0; /* XXX will be filled by loader or kernel */
|
||||
bootinfo.bi_extmem = memsize(MEM_EXT);
|
||||
bootinfo.bi_extmem = memsize();
|
||||
bootinfo.bi_memsizes_valid++;
|
||||
|
||||
/* Process configuration file */
|
||||
@ -220,7 +223,7 @@ main(void)
|
||||
|
||||
if (*cmd) {
|
||||
printf("%s: %s", PATH_CONFIG, cmd);
|
||||
if (parse(cmd))
|
||||
if (parse())
|
||||
autoboot = 0;
|
||||
/* Do not process this command twice */
|
||||
*cmd = 0;
|
||||
@ -234,7 +237,7 @@ main(void)
|
||||
if (autoboot && !*kname) {
|
||||
memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
|
||||
if (!keyhit(3*SECOND)) {
|
||||
load(kname);
|
||||
load();
|
||||
memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
|
||||
}
|
||||
}
|
||||
@ -242,11 +245,7 @@ main(void)
|
||||
/* Present the user with the boot2 prompt. */
|
||||
|
||||
for (;;) {
|
||||
#ifdef UFS1_ONLY
|
||||
printf(" \n>> FreeBSD/i386/UFS1 BOOT\n"
|
||||
#else
|
||||
printf(" \n>> FreeBSD/i386/UFS[12] BOOT\n"
|
||||
#endif
|
||||
printf("\nFreeBSD/i386 boot\n"
|
||||
"Default: %u:%s(%u,%c)%s\n"
|
||||
"boot: ",
|
||||
dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
|
||||
@ -254,14 +253,14 @@ main(void)
|
||||
if (ioctrl & IO_SERIAL)
|
||||
sio_flush();
|
||||
if (!autoboot || keyhit(5*SECOND))
|
||||
getstr(cmd, sizeof(cmd));
|
||||
getstr();
|
||||
else
|
||||
putchar('\n');
|
||||
autoboot = 0;
|
||||
if (parse(cmd))
|
||||
if (parse())
|
||||
putchar('\a');
|
||||
else
|
||||
load(kname);
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +271,7 @@ exit(int x)
|
||||
}
|
||||
|
||||
static void
|
||||
load(const char *fname)
|
||||
load(void)
|
||||
{
|
||||
union {
|
||||
struct exec ex;
|
||||
@ -285,9 +284,9 @@ load(const char *fname)
|
||||
uint32_t addr, x;
|
||||
int fmt, i, j;
|
||||
|
||||
if (!(ino = lookup(fname))) {
|
||||
if (!(ino = lookup(kname))) {
|
||||
if (!ls)
|
||||
printf("No %s\n", fname);
|
||||
printf("No %s\n", kname);
|
||||
return;
|
||||
}
|
||||
if (xfsread(ino, &hdr, sizeof(hdr)))
|
||||
@ -359,7 +358,7 @@ load(const char *fname)
|
||||
addr = hdr.eh.e_entry & 0xffffff;
|
||||
}
|
||||
bootinfo.bi_esymtab = VTOP(p);
|
||||
bootinfo.bi_kernelname = VTOP(fname);
|
||||
bootinfo.bi_kernelname = VTOP(kname);
|
||||
bootinfo.bi_bios_dev = dsk.drive;
|
||||
__exec((caddr_t)addr, opts & RBX_MASK,
|
||||
MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part),
|
||||
@ -367,10 +366,12 @@ load(const char *fname)
|
||||
}
|
||||
|
||||
static int
|
||||
parse(char *arg)
|
||||
parse()
|
||||
{
|
||||
char *arg = cmd;
|
||||
char *p, *q;
|
||||
int drv, c, i;
|
||||
unsigned int drv;
|
||||
int c, i;
|
||||
|
||||
while ((c = *arg++)) {
|
||||
if (c == ' ' || c == '\t' || c == '\n')
|
||||
@ -401,9 +402,9 @@ parse(char *arg)
|
||||
if (*q) {
|
||||
drv = -1;
|
||||
if (arg[1] == ':') {
|
||||
if (*arg < '0' || *arg > '9')
|
||||
return -1;
|
||||
drv = *arg - '0';
|
||||
if (drv > 9)
|
||||
return (-1);
|
||||
arg += 2;
|
||||
}
|
||||
if (q - arg != 2)
|
||||
@ -414,21 +415,22 @@ parse(char *arg)
|
||||
return -1;
|
||||
dsk.type = i;
|
||||
arg += 3;
|
||||
if (arg[1] != ',' || *arg < '0' || *arg > '9')
|
||||
return -1;
|
||||
dsk.unit = *arg - '0';
|
||||
if (arg[1] != ',' || dsk.unit > 9)
|
||||
return -1;
|
||||
arg += 2;
|
||||
dsk.slice = WHOLE_DISK_SLICE;
|
||||
if (arg[1] == ',') {
|
||||
if (*arg < '0' || *arg > '0' + NDOSPART)
|
||||
dsk.slice = *arg - '0' + 1;
|
||||
if (dsk.slice > NDOSPART)
|
||||
return -1;
|
||||
if ((dsk.slice = *arg - '0'))
|
||||
dsk.slice++;
|
||||
arg += 2;
|
||||
}
|
||||
if (arg[1] != ')' || *arg < 'a' || *arg > 'p')
|
||||
if (arg[1] != ')')
|
||||
return -1;
|
||||
dsk.part = *arg - 'a';
|
||||
if (dsk.part > 7)
|
||||
return (-1);
|
||||
arg += 2;
|
||||
if (drv == -1)
|
||||
drv = dsk.unit;
|
||||
@ -512,11 +514,10 @@ dskread(void *buf, unsigned lba, unsigned nblk)
|
||||
static void
|
||||
printf(const char *fmt,...)
|
||||
{
|
||||
static const char digits[16] = "0123456789abcdef";
|
||||
va_list ap;
|
||||
char buf[10];
|
||||
char *s;
|
||||
unsigned r, u;
|
||||
unsigned u;
|
||||
int c;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@ -532,13 +533,11 @@ printf(const char *fmt,...)
|
||||
putchar(*s);
|
||||
continue;
|
||||
case 'u':
|
||||
case 'x':
|
||||
r = c == 'u' ? 10U : 16U;
|
||||
u = va_arg(ap, unsigned);
|
||||
s = buf;
|
||||
do
|
||||
*s++ = digits[u % r];
|
||||
while (u /= r);
|
||||
*s++ = '0' + u % 10U;
|
||||
while (u /= 10U);
|
||||
while (--s >= buf)
|
||||
putchar(*s);
|
||||
continue;
|
||||
@ -558,15 +557,6 @@ putchar(int c)
|
||||
xputc(c);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
memsize(int type)
|
||||
{
|
||||
v86.addr = type;
|
||||
v86.eax = 0x8800;
|
||||
v86int();
|
||||
return v86.eax;
|
||||
}
|
||||
|
||||
static int
|
||||
drvread(void *buf, unsigned lba, unsigned nblk)
|
||||
{
|
||||
@ -583,7 +573,7 @@ drvread(void *buf, unsigned lba, unsigned nblk)
|
||||
v86int();
|
||||
v86.ctl = V86_FLAGS;
|
||||
if (V86_CY(v86.efl)) {
|
||||
printf("Disk error 0x%x lba 0x%x\n", v86.eax >> 8 & 0xff, lba);
|
||||
printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -31,11 +31,11 @@ ORG2= 0x2000
|
||||
# Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit.
|
||||
|
||||
# BOOT2_UFS?= UFS2_ONLY
|
||||
# BOOT2_UFS?= UFS1_AND_UFS2
|
||||
BOOT2_UFS?= UFS1_ONLY
|
||||
BOOT2_UFS?= UFS1_AND_UFS2
|
||||
# BOOT2_UFS?= UFS1_ONLY
|
||||
|
||||
CFLAGS= -elf -ffreestanding -Os -fno-builtin \
|
||||
-fno-guess-branch-probability \
|
||||
-fno-guess-branch-probability -fomit-frame-pointer\
|
||||
-mrtd \
|
||||
-D${BOOT2_UFS} \
|
||||
-I${.CURDIR}/../../common \
|
||||
@ -44,7 +44,7 @@ CFLAGS= -elf -ffreestanding -Os -fno-builtin \
|
||||
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
|
||||
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
|
||||
|
||||
LDFLAGS=-nostdlib -static -N
|
||||
LDFLAGS=-nostdlib -static -N --gc-sections
|
||||
|
||||
all: boot1 boot2
|
||||
|
||||
@ -61,7 +61,6 @@ boot1.o: boot1.s
|
||||
boot2.o: boot2.c ${.CURDIR}/../../common/ufsread.c
|
||||
${CC} ${CFLAGS} -S -o boot2.s.tmp ${.IMPSRC}
|
||||
sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
|
||||
rm -f boot2.s.tmp
|
||||
${AS} ${AFLAGS} -o boot2.o boot2.s
|
||||
|
||||
boot2.h: boot1.out
|
||||
|
@ -62,8 +62,8 @@
|
||||
#define PATH_KERNEL "/kernel"
|
||||
|
||||
#define ARGS 0x900
|
||||
#define NOPT 14
|
||||
#define NDEV 5
|
||||
#define NOPT 12
|
||||
#define NDEV 3
|
||||
#define MEM_BASE 0x12
|
||||
#define MEM_EXT 0x15
|
||||
#define V86_CY(x) ((x) & 1)
|
||||
@ -73,20 +73,18 @@
|
||||
#define DRV_MASK 0x7f
|
||||
|
||||
#define TYPE_AD 0
|
||||
#define TYPE_DA 2
|
||||
#define TYPE_DA 1
|
||||
#define TYPE_MAXHARD TYPE_DA
|
||||
#define TYPE_FD 4
|
||||
#define TYPE_FD 2
|
||||
|
||||
extern uint32_t _end;
|
||||
|
||||
static const char optstr[NOPT] = "DhaCcdgmnPprsv";
|
||||
static const char optstr[NOPT] = "DhaCgmnPprsv";
|
||||
static const unsigned char flags[NOPT] = {
|
||||
RBX_DUAL,
|
||||
RBX_SERIAL,
|
||||
RBX_ASKNAME,
|
||||
RBX_CDROM,
|
||||
RBX_CONFIG,
|
||||
RBX_KDB,
|
||||
RBX_GDB,
|
||||
RBX_MUTE,
|
||||
RBX_NOINTR,
|
||||
@ -97,8 +95,8 @@ static const unsigned char flags[NOPT] = {
|
||||
RBX_VERBOSE
|
||||
};
|
||||
|
||||
static const char *const dev_nm[NDEV] = {"ad", "wd", "da", " ", "fd"};
|
||||
static const unsigned char dev_maj[NDEV] = {30, 0, 4, 1, 2};
|
||||
static const char *const dev_nm[NDEV] = {"ad", "da", "fd"};
|
||||
static const unsigned char dev_maj[NDEV] = {30, 4, 2};
|
||||
|
||||
static struct dsk {
|
||||
unsigned drive;
|
||||
@ -116,13 +114,13 @@ static struct bootinfo bootinfo;
|
||||
static uint8_t ioctrl = IO_KEYBOARD;
|
||||
|
||||
void exit(int);
|
||||
static void load(const char *);
|
||||
static int parse(char *);
|
||||
static void load(void);
|
||||
static int parse(void);
|
||||
static int xfsread(ino_t, void *, size_t);
|
||||
static int dskread(void *, unsigned, unsigned);
|
||||
static void printf(const char *,...);
|
||||
static void putchar(int);
|
||||
static uint32_t memsize(int);
|
||||
static uint32_t memsize(void);
|
||||
static int drvread(void *, unsigned, unsigned);
|
||||
static int keyhit(unsigned);
|
||||
static int xputc(int);
|
||||
@ -150,37 +148,42 @@ xfsread(ino_t inode, void *buf, size_t nbyte)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
memsize(void)
|
||||
{
|
||||
v86.addr = MEM_EXT;
|
||||
v86.eax = 0x8800;
|
||||
v86int();
|
||||
return v86.eax;
|
||||
}
|
||||
|
||||
static inline void
|
||||
getstr(char *str, int size)
|
||||
getstr(void)
|
||||
{
|
||||
char *s;
|
||||
int c;
|
||||
|
||||
s = str;
|
||||
s = cmd;
|
||||
for (;;) {
|
||||
switch (c = xgetc(0)) {
|
||||
case 0:
|
||||
break;
|
||||
continue;
|
||||
case '\177':
|
||||
c = '\b';
|
||||
case '\b':
|
||||
if (s > str) {
|
||||
if (s > cmd) {
|
||||
s--;
|
||||
putchar('\b');
|
||||
putchar(' ');
|
||||
} else
|
||||
c = 0;
|
||||
break;
|
||||
printf("\b \b");
|
||||
}
|
||||
continue;
|
||||
case '\n':
|
||||
case '\r':
|
||||
*s = 0;
|
||||
return;
|
||||
default:
|
||||
if (s - str < size - 1)
|
||||
if (s - cmd < sizeof(cmd) - 1)
|
||||
*s++ = c;
|
||||
}
|
||||
if (c)
|
||||
putchar(c);
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,7 +211,7 @@ main(void)
|
||||
bootinfo.bi_version = BOOTINFO_VERSION;
|
||||
bootinfo.bi_size = sizeof(bootinfo);
|
||||
bootinfo.bi_basemem = 0; /* XXX will be filled by loader or kernel */
|
||||
bootinfo.bi_extmem = memsize(MEM_EXT);
|
||||
bootinfo.bi_extmem = memsize();
|
||||
bootinfo.bi_memsizes_valid++;
|
||||
|
||||
/* Process configuration file */
|
||||
@ -220,7 +223,7 @@ main(void)
|
||||
|
||||
if (*cmd) {
|
||||
printf("%s: %s", PATH_CONFIG, cmd);
|
||||
if (parse(cmd))
|
||||
if (parse())
|
||||
autoboot = 0;
|
||||
/* Do not process this command twice */
|
||||
*cmd = 0;
|
||||
@ -234,7 +237,7 @@ main(void)
|
||||
if (autoboot && !*kname) {
|
||||
memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
|
||||
if (!keyhit(3*SECOND)) {
|
||||
load(kname);
|
||||
load();
|
||||
memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
|
||||
}
|
||||
}
|
||||
@ -242,11 +245,7 @@ main(void)
|
||||
/* Present the user with the boot2 prompt. */
|
||||
|
||||
for (;;) {
|
||||
#ifdef UFS1_ONLY
|
||||
printf(" \n>> FreeBSD/i386/UFS1 BOOT\n"
|
||||
#else
|
||||
printf(" \n>> FreeBSD/i386/UFS[12] BOOT\n"
|
||||
#endif
|
||||
printf("\nFreeBSD/i386 boot\n"
|
||||
"Default: %u:%s(%u,%c)%s\n"
|
||||
"boot: ",
|
||||
dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
|
||||
@ -254,14 +253,14 @@ main(void)
|
||||
if (ioctrl & IO_SERIAL)
|
||||
sio_flush();
|
||||
if (!autoboot || keyhit(5*SECOND))
|
||||
getstr(cmd, sizeof(cmd));
|
||||
getstr();
|
||||
else
|
||||
putchar('\n');
|
||||
autoboot = 0;
|
||||
if (parse(cmd))
|
||||
if (parse())
|
||||
putchar('\a');
|
||||
else
|
||||
load(kname);
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +271,7 @@ exit(int x)
|
||||
}
|
||||
|
||||
static void
|
||||
load(const char *fname)
|
||||
load(void)
|
||||
{
|
||||
union {
|
||||
struct exec ex;
|
||||
@ -285,9 +284,9 @@ load(const char *fname)
|
||||
uint32_t addr, x;
|
||||
int fmt, i, j;
|
||||
|
||||
if (!(ino = lookup(fname))) {
|
||||
if (!(ino = lookup(kname))) {
|
||||
if (!ls)
|
||||
printf("No %s\n", fname);
|
||||
printf("No %s\n", kname);
|
||||
return;
|
||||
}
|
||||
if (xfsread(ino, &hdr, sizeof(hdr)))
|
||||
@ -359,7 +358,7 @@ load(const char *fname)
|
||||
addr = hdr.eh.e_entry & 0xffffff;
|
||||
}
|
||||
bootinfo.bi_esymtab = VTOP(p);
|
||||
bootinfo.bi_kernelname = VTOP(fname);
|
||||
bootinfo.bi_kernelname = VTOP(kname);
|
||||
bootinfo.bi_bios_dev = dsk.drive;
|
||||
__exec((caddr_t)addr, opts & RBX_MASK,
|
||||
MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part),
|
||||
@ -367,10 +366,12 @@ load(const char *fname)
|
||||
}
|
||||
|
||||
static int
|
||||
parse(char *arg)
|
||||
parse()
|
||||
{
|
||||
char *arg = cmd;
|
||||
char *p, *q;
|
||||
int drv, c, i;
|
||||
unsigned int drv;
|
||||
int c, i;
|
||||
|
||||
while ((c = *arg++)) {
|
||||
if (c == ' ' || c == '\t' || c == '\n')
|
||||
@ -401,9 +402,9 @@ parse(char *arg)
|
||||
if (*q) {
|
||||
drv = -1;
|
||||
if (arg[1] == ':') {
|
||||
if (*arg < '0' || *arg > '9')
|
||||
return -1;
|
||||
drv = *arg - '0';
|
||||
if (drv > 9)
|
||||
return (-1);
|
||||
arg += 2;
|
||||
}
|
||||
if (q - arg != 2)
|
||||
@ -414,21 +415,22 @@ parse(char *arg)
|
||||
return -1;
|
||||
dsk.type = i;
|
||||
arg += 3;
|
||||
if (arg[1] != ',' || *arg < '0' || *arg > '9')
|
||||
return -1;
|
||||
dsk.unit = *arg - '0';
|
||||
if (arg[1] != ',' || dsk.unit > 9)
|
||||
return -1;
|
||||
arg += 2;
|
||||
dsk.slice = WHOLE_DISK_SLICE;
|
||||
if (arg[1] == ',') {
|
||||
if (*arg < '0' || *arg > '0' + NDOSPART)
|
||||
dsk.slice = *arg - '0' + 1;
|
||||
if (dsk.slice > NDOSPART)
|
||||
return -1;
|
||||
if ((dsk.slice = *arg - '0'))
|
||||
dsk.slice++;
|
||||
arg += 2;
|
||||
}
|
||||
if (arg[1] != ')' || *arg < 'a' || *arg > 'p')
|
||||
if (arg[1] != ')')
|
||||
return -1;
|
||||
dsk.part = *arg - 'a';
|
||||
if (dsk.part > 7)
|
||||
return (-1);
|
||||
arg += 2;
|
||||
if (drv == -1)
|
||||
drv = dsk.unit;
|
||||
@ -512,11 +514,10 @@ dskread(void *buf, unsigned lba, unsigned nblk)
|
||||
static void
|
||||
printf(const char *fmt,...)
|
||||
{
|
||||
static const char digits[16] = "0123456789abcdef";
|
||||
va_list ap;
|
||||
char buf[10];
|
||||
char *s;
|
||||
unsigned r, u;
|
||||
unsigned u;
|
||||
int c;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@ -532,13 +533,11 @@ printf(const char *fmt,...)
|
||||
putchar(*s);
|
||||
continue;
|
||||
case 'u':
|
||||
case 'x':
|
||||
r = c == 'u' ? 10U : 16U;
|
||||
u = va_arg(ap, unsigned);
|
||||
s = buf;
|
||||
do
|
||||
*s++ = digits[u % r];
|
||||
while (u /= r);
|
||||
*s++ = '0' + u % 10U;
|
||||
while (u /= 10U);
|
||||
while (--s >= buf)
|
||||
putchar(*s);
|
||||
continue;
|
||||
@ -558,15 +557,6 @@ putchar(int c)
|
||||
xputc(c);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
memsize(int type)
|
||||
{
|
||||
v86.addr = type;
|
||||
v86.eax = 0x8800;
|
||||
v86int();
|
||||
return v86.eax;
|
||||
}
|
||||
|
||||
static int
|
||||
drvread(void *buf, unsigned lba, unsigned nblk)
|
||||
{
|
||||
@ -583,7 +573,7 @@ drvread(void *buf, unsigned lba, unsigned nblk)
|
||||
v86int();
|
||||
v86.ctl = V86_FLAGS;
|
||||
if (V86_CY(v86.efl)) {
|
||||
printf("Disk error 0x%x lba 0x%x\n", v86.eax >> 8 & 0xff, lba);
|
||||
printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user