*********** * WARNING * *********** Highly evil, UNTESTED hack follows. It compiles. It just *might* actually work if I haven't screwed up too many things. Index: common/ufsread.c =================================================================== RCS file: /home/ncvs/src/sys/boot/common/ufsread.c,v retrieving revision 1.9 diff -u -r1.9 ufsread.c --- common/ufsread.c 14 Dec 2002 19:39:44 -0000 1.9 +++ common/ufsread.c 15 Dec 2002 00:45:28 -0000 @@ -43,9 +43,6 @@ (fsbtodb(fs, cgimin(fs, ino_to_cg(fs, x))) + \ (((x) % (fs)->fs_ipg) / (ipervblk) * DBPERVBLK)) #define INO_TO_VBO(ipervblk, x) ((x) % ipervblk) -#define FS_TO_VBA(fs, fsb, off) (fsbtodb(fs, fsb) + \ - ((off) / VBLKSIZE) * DBPERVBLK) -#define FS_TO_VBO(fs, fsb, off) ((off) & VBLKMASK) /* Buffers that must not span a 64k boundary. */ struct dmadat { @@ -73,7 +70,7 @@ fs_off = 0; while ((n = fsread(*ino, buf, DEV_BSIZE)) > 0) for (s = buf; s < buf + DEV_BSIZE;) { - d = (void *)s; + d = (struct dirent *)s; if (ls) printf("%s ", d->d_name); else if (!strcmp(name, d->d_name)) { @@ -112,7 +109,7 @@ memcpy(name, path, n); name[n] = 0; if (dt != DT_DIR) { - printf("%s: not a directory.\n", name); + printf("%s: not directory\n", name); return (0); } if ((dt = fsfind(name, &ino)) <= 0) Index: i386/boot2/Makefile =================================================================== RCS file: /home/ncvs/src/sys/boot/i386/boot2/Makefile,v retrieving revision 1.41 diff -u -r1.41 Makefile --- i386/boot2/Makefile 14 Dec 2002 19:44:13 -0000 1.41 +++ i386/boot2/Makefile 15 Dec 2002 00:45:28 -0000 @@ -31,10 +31,10 @@ # 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 \ +CFLAGS= -elf -ffreestanding -Os -fno-builtin -fomit-frame-pointer \ -fno-guess-branch-probability \ -mrtd \ -D${BOOT2_UFS} \ @@ -44,7 +44,7 @@ -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 Index: i386/boot2/boot2.c =================================================================== RCS file: /home/ncvs/src/sys/boot/i386/boot2/boot2.c,v retrieving revision 1.56 diff -u -r1.56 boot2.c --- i386/boot2/boot2.c 14 Dec 2002 19:40:35 -0000 1.56 +++ i386/boot2/boot2.c 15 Dec 2002 00:45:28 -0000 @@ -43,8 +43,6 @@ #define RBX_ASKNAME 0x0 /* -a */ #define RBX_SINGLE 0x1 /* -s */ #define RBX_DFLTROOT 0x5 /* -r */ -#define RBX_KDB 0x6 /* -d */ -#define RBX_CONFIG 0xa /* -c */ #define RBX_VERBOSE 0xb /* -v */ #define RBX_SERIAL 0xc /* -h */ #define RBX_CDROM 0xd /* -C */ @@ -62,7 +60,7 @@ #define PATH_KERNEL "/kernel" #define ARGS 0x900 -#define NOPT 14 +#define NOPT 12 #define NDEV 5 #define MEM_BASE 0x12 #define MEM_EXT 0x15 @@ -79,14 +77,12 @@ extern uint32_t _end; -static const char optstr[NOPT] = "DhaCcdgmnPprsv"; -static const unsigned char flags[NOPT] = { +static const char optstr[NOPT] = "DhaCgmnPprsv"; +static const char flags[NOPT] = { RBX_DUAL, RBX_SERIAL, RBX_ASKNAME, RBX_CDROM, - RBX_CONFIG, - RBX_KDB, RBX_GDB, RBX_MUTE, RBX_NOINTR, @@ -115,7 +111,6 @@ static struct bootinfo bootinfo; static uint8_t ioctrl = IO_KEYBOARD; -void exit(int); static void load(const char *); static int parse(char *); static int xfsread(ino_t, void *, size_t); @@ -135,7 +130,7 @@ strcmp(const char *s1, const char *s2) { for (; *s1 == *s2 && *s1; s1++, s2++); - return (u_char)*s1 - (u_char)*s2; + return *s1 - *s2; } #include "ufsread.c" @@ -162,14 +157,11 @@ case 0: break; case '\177': - c = '\b'; case '\b': if (s > str) { s--; - putchar('\b'); - putchar(' '); - } else - c = 0; + printf("\b \b"); + } break; case '\n': case '\r': @@ -178,9 +170,8 @@ default: if (s - str < size - 1) *s++ = c; - } - if (c) putchar(c); + } } } @@ -242,11 +233,7 @@ /* 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, @@ -265,12 +252,6 @@ } } -/* XXX - Needed for btxld to link the boot2 binary; do not remove. */ -void -exit(int x) -{ -} - static void load(const char *fname) { @@ -311,7 +292,7 @@ return; p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE); bootinfo.bi_symtab = VTOP(p); - memcpy(p, (char *)&hdr.ex.a_syms, sizeof(hdr.ex.a_syms)); + memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms)); p += sizeof(hdr.ex.a_syms); if (hdr.ex.a_syms) { if (xfsread(ino, p, hdr.ex.a_syms)) @@ -348,7 +329,7 @@ if (xfsread(ino, &es, sizeof(es))) return; for (i = 0; i < 2; i++) { - memcpy(p, (char *)&es[i].sh_size, sizeof(es[i].sh_size)); + memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size)); p += sizeof(es[i].sh_size); fs_off = es[i].sh_offset; if (xfsread(ino, p, es[i].sh_size)) @@ -370,7 +351,8 @@ parse(char *arg) { char *p, *q; - int drv, c, i; + int c, i, u; + unsigned int drv; while ((c = *arg++)) { if (c == ' ' || c == '\t' || c == '\n') @@ -401,9 +383,9 @@ 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 +396,22 @@ 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 +495,10 @@ 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 +514,11 @@ 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++ = u % 10; + while (u /= 10); while (--s >= buf) putchar(*s); continue; @@ -583,7 +563,7 @@ 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; Index: i386/btx/lib/Makefile =================================================================== RCS file: /home/ncvs/src/sys/boot/i386/btx/lib/Makefile,v retrieving revision 1.10 diff -u -r1.10 Makefile --- i386/btx/lib/Makefile 17 Sep 2002 01:48:55 -0000 1.10 +++ i386/btx/lib/Makefile 15 Dec 2002 00:45:28 -0000 @@ -1,5 +1,6 @@ # $FreeBSD: src/sys/boot/i386/btx/lib/Makefile,v 1.10 2002/09/17 01:48:55 peter Exp $ +# btxsys.o must follow btxcsu.o due to a fallthrough OBJS= btxcsu.o btxsys.o btxv86.o CLEANFILES+= crt0.o ${OBJS} Index: i386/btx/lib/btxcsu.s =================================================================== RCS file: /home/ncvs/src/sys/boot/i386/btx/lib/btxcsu.s,v retrieving revision 1.3 diff -u -r1.3 btxcsu.s --- i386/btx/lib/btxcsu.s 28 Aug 1999 00:40:07 -0000 1.3 +++ i386/btx/lib/btxcsu.s 15 Dec 2002 00:45:28 -0000 @@ -35,9 +35,11 @@ addl $ARGADJ,%eax # argument movl %eax,__args # pointer call main # Invoke client main() - call exit # Invoke client exit() + # The code for __exit follows immediately, fallthrough # # Data. # - .comm __base,4 # Client base address - .comm __args,4 # Client arguments + .bss + .globl __base, __args +__base: .space 4 # Client base address +__args: .space 4 # Client arguments Index: i386/btx/lib/btxv86.s =================================================================== RCS file: /home/ncvs/src/sys/boot/i386/btx/lib/btxv86.s,v retrieving revision 1.3 diff -u -r1.3 btxv86.s --- i386/btx/lib/btxv86.s 28 Aug 1999 00:40:08 -0000 1.3 +++ i386/btx/lib/btxv86.s 15 Dec 2002 00:45:28 -0000 @@ -81,5 +81,7 @@ # # V86 interface structure. # - .comm __v86,SIZ_V86 - .comm __v86ret,4 + .bss + .globl __v86, __v86ret +__v86: .space SIZ_V86 +__v86ret: .space 4