summaryrefslogtreecommitdiffstats
path: root/sys/boot/i386
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2002-06-21 06:18:05 +0000
committermckusick <mckusick@FreeBSD.org>2002-06-21 06:18:05 +0000
commit88d85c15ef183c06524d6ca695f62c0c0672b00c (patch)
treef1364dbfb9835934a3879b5904f7ff9a1495744c /sys/boot/i386
parenteacb69b0197a8553d5004aa99532cabad8778e36 (diff)
downloadFreeBSD-src-88d85c15ef183c06524d6ca695f62c0c0672b00c.zip
FreeBSD-src-88d85c15ef183c06524d6ca695f62c0c0672b00c.tar.gz
This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit block pointers. It also adds a file-creation time field, an ability to use jumbo blocks per inode to allow extent like pointer density, and space for extended attributes (up to twice the filesystem block size worth of attributes, e.g., on a 16K filesystem, there is space for 32K of attributes). UFS2 fully supports and runs existing UFS1 filesystems. New filesystems built using newfs can be built in either UFS1 or UFS2 format using the -O option. In this commit UFS1 is the default format, so if you want to build UFS2 format filesystems, you must specify -O 2. This default will be changed to UFS2 when UFS2 proves itself to be stable. In this commit the boot code for reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c) as there is insufficient space in the boot block. Once the size of the boot block is increased, this code can be defined. Things to note: the definition of SBSIZE has changed to SBLOCKSIZE. The header file <ufs/ufs/dinode.h> must be included before <ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and ufs_lbn_t. Still TODO: Verify that the first level bootstraps work for all the architectures. Convert the utility ffsinfo to understand UFS2 and test growfs. Add support for the extended attribute storage. Update soft updates to ensure integrity of extended attribute storage. Switch the current extended attribute interfaces to use the extended attribute storage. Add the extent like functionality (framework is there, but is currently never used). Sponsored by: DARPA & NAI Labs. Reviewed by: Poul-Henning Kamp <phk@freebsd.org>
Diffstat (limited to 'sys/boot/i386')
-rw-r--r--sys/boot/i386/Makefile2
-rw-r--r--sys/boot/i386/boot2/Makefile2
-rw-r--r--sys/boot/i386/boot2/boot2.c84
-rw-r--r--sys/boot/i386/gptboot/Makefile2
-rw-r--r--sys/boot/i386/gptboot/gptboot.c84
-rw-r--r--sys/boot/i386/libi386/Makefile11
-rw-r--r--sys/boot/i386/loader/Makefile2
7 files changed, 89 insertions, 98 deletions
diff --git a/sys/boot/i386/Makefile b/sys/boot/i386/Makefile
index 4fd9447..3fbdc45 100644
--- a/sys/boot/i386/Makefile
+++ b/sys/boot/i386/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-SUBDIR= mbr boot0 btx boot2 cdboot kgzldr libi386 loader
+SUBDIR= libi386 mbr boot0 btx boot2 cdboot kgzldr loader
# special boot programs, 'self-extracting boot2+loader'
SUBDIR+= pxeldr
diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
index 2883b93..75e4fe3 100644
--- a/sys/boot/i386/boot2/Makefile
+++ b/sys/boot/i386/boot2/Makefile
@@ -75,7 +75,7 @@ boot2.bin: boot2.out
boot2.out: boot2.o sio.o
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
- ${BTX}/lib/crt0.o boot2.o sio.o
+ ${BTX}/lib/crt0.o boot2.o sio.o ../libi386/libi386.a
boot2.o: boot2.h
diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c
index fa82999..e506c29 100644
--- a/sys/boot/i386/boot2/boot2.c
+++ b/sys/boot/i386/boot2/boot2.c
@@ -73,9 +73,10 @@
#define TYPE_AD 0
#define TYPE_WD 1
-#define TYPE_WFD 2
-#define TYPE_FD 3
-#define TYPE_DA 4
+#define TYPE_DA 2
+#define TYPE_MAXHARD TYPE_DA
+#define TYPE_WFD 3
+#define TYPE_FD 4
extern uint32_t _end;
@@ -97,8 +98,8 @@ static const unsigned char flags[NOPT] = {
RBX_VERBOSE
};
-static const char *const dev_nm[] = {"ad", "wd", " ", "fd", "da"};
-static const unsigned dev_maj[] = {30, 0, 1, 2, 4};
+static const char *const dev_nm[NDEV] = {"ad", "wd", "da", " ", "fd"};
+static const unsigned char dev_maj[NDEV] = {30, 0, 4, 1, 2};
static struct dsk {
unsigned drive;
@@ -111,16 +112,14 @@ static struct dsk {
} dsk;
static char cmd[512];
static char kname[1024];
-static uint32_t opts;
+static uint32_t opts = RB_BOOTINFO;
static struct bootinfo bootinfo;
static uint8_t ioctrl = IO_KEYBOARD;
void exit(int);
static void load(const char *);
static int parse(char *);
-static ino_t lookup(const char *);
static int xfsread(ino_t, void *, size_t);
-static ssize_t fsread(ino_t, void *, size_t);
static int dskread(void *, unsigned, unsigned);
static int printf(const char *,...);
static int putchar(int);
@@ -131,16 +130,17 @@ static int xputc(int);
static int xgetc(int);
static int getc(int);
+#if 1
#define memcpy __builtin_memcpy
-
-static inline void
-readfile(const char *fname, void *buf, size_t size)
+#else
+static void memcpy(char *, const char *, int);
+static void
+memcpy(char *dst, const char *src, int len)
{
- ino_t ino;
-
- if ((ino = lookup(fname)))
- fsread(ino, buf, size);
+ while (len--)
+ *dst++ = *src++;
}
+#endif
static inline int
strcmp(const char *s1, const char *s2)
@@ -151,15 +151,14 @@ strcmp(const char *s1, const char *s2)
#include "ufsread.c"
-static inline int
-getchar(void)
+static int
+xfsread(ino_t inode, void *buf, size_t nbyte)
{
- int c;
-
- c = xgetc(0);
- if (c == '\r')
- c = '\n';
- return c;
+ if (fsread(inode, buf, nbyte) != nbyte) {
+ printf("Invalid %s\n", "format");
+ return -1;
+ }
+ return 0;
}
static inline void
@@ -169,12 +168,13 @@ getstr(char *str, int size)
int c;
s = str;
- do {
- switch (c = getchar()) {
+ for (;;) {
+ switch (c = xgetc(0)) {
case 0:
break;
- case '\b':
case '\177':
+ c = '\b';
+ case '\b':
if (s > str) {
s--;
putchar('\b');
@@ -183,15 +183,16 @@ getstr(char *str, int size)
c = 0;
break;
case '\n':
+ case '\r':
*s = 0;
- break;
+ return;
default:
if (s - str < size - 1)
*s++ = c;
}
if (c)
putchar(c);
- } while (c != '\n');
+ }
}
static inline uint32_t
@@ -220,6 +221,7 @@ int
main(void)
{
int autoboot, i;
+ ino_t ino;
dmadat = (void *)(roundup2(__base + _end, 0x10000) - __base);
v86.ctl = V86_FLAGS;
@@ -238,7 +240,10 @@ main(void)
/* Process configuration file */
autoboot = 1;
- readfile(PATH_CONFIG, cmd, sizeof(cmd));
+
+ if ((ino = lookup(PATH_CONFIG)))
+ fsread(ino, cmd, sizeof(cmd));
+
if (*cmd) {
printf("%s: %s", PATH_CONFIG, cmd);
if (parse(cmd))
@@ -328,7 +333,7 @@ load(const char *fname)
return;
p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE);
bootinfo.bi_symtab = VTOP(p);
- memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms));
+ memcpy(p, (char *)&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))
@@ -365,7 +370,7 @@ load(const char *fname)
if (xfsread(ino, &es, sizeof(es)))
return;
for (i = 0; i < 2; i++) {
- memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size));
+ memcpy(p, (char *)&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))
@@ -378,7 +383,7 @@ load(const char *fname)
bootinfo.bi_esymtab = VTOP(p);
bootinfo.bi_kernelname = VTOP(fname);
bootinfo.bi_bios_dev = dsk.drive;
- __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
+ __exec((caddr_t)addr, opts & RBX_MASK,
MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part),
0, 0, 0, VTOP(&bootinfo));
}
@@ -449,9 +454,8 @@ parse(char *arg)
arg += 2;
if (drv == -1)
drv = dsk.unit;
- dsk.drive = (dsk.type == TYPE_WD ||
- dsk.type == TYPE_AD ||
- dsk.type == TYPE_DA ? DRV_HARD : 0) + drv;
+ dsk.drive = (dsk.type <= TYPE_MAXHARD
+ ? DRV_HARD : 0) + drv;
dsk_meta = 0;
fsread(0, NULL, 0);
}
@@ -467,16 +471,6 @@ parse(char *arg)
}
static int
-xfsread(ino_t inode, void *buf, size_t nbyte)
-{
- if (fsread(inode, buf, nbyte) != nbyte) {
- printf("Invalid %s\n", "format");
- return -1;
- }
- return 0;
-}
-
-static int
dskread(void *buf, unsigned lba, unsigned nblk)
{
struct dos_partition *dp;
diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile
index 2883b93..75e4fe3 100644
--- a/sys/boot/i386/gptboot/Makefile
+++ b/sys/boot/i386/gptboot/Makefile
@@ -75,7 +75,7 @@ boot2.bin: boot2.out
boot2.out: boot2.o sio.o
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
- ${BTX}/lib/crt0.o boot2.o sio.o
+ ${BTX}/lib/crt0.o boot2.o sio.o ../libi386/libi386.a
boot2.o: boot2.h
diff --git a/sys/boot/i386/gptboot/gptboot.c b/sys/boot/i386/gptboot/gptboot.c
index fa82999..e506c29 100644
--- a/sys/boot/i386/gptboot/gptboot.c
+++ b/sys/boot/i386/gptboot/gptboot.c
@@ -73,9 +73,10 @@
#define TYPE_AD 0
#define TYPE_WD 1
-#define TYPE_WFD 2
-#define TYPE_FD 3
-#define TYPE_DA 4
+#define TYPE_DA 2
+#define TYPE_MAXHARD TYPE_DA
+#define TYPE_WFD 3
+#define TYPE_FD 4
extern uint32_t _end;
@@ -97,8 +98,8 @@ static const unsigned char flags[NOPT] = {
RBX_VERBOSE
};
-static const char *const dev_nm[] = {"ad", "wd", " ", "fd", "da"};
-static const unsigned dev_maj[] = {30, 0, 1, 2, 4};
+static const char *const dev_nm[NDEV] = {"ad", "wd", "da", " ", "fd"};
+static const unsigned char dev_maj[NDEV] = {30, 0, 4, 1, 2};
static struct dsk {
unsigned drive;
@@ -111,16 +112,14 @@ static struct dsk {
} dsk;
static char cmd[512];
static char kname[1024];
-static uint32_t opts;
+static uint32_t opts = RB_BOOTINFO;
static struct bootinfo bootinfo;
static uint8_t ioctrl = IO_KEYBOARD;
void exit(int);
static void load(const char *);
static int parse(char *);
-static ino_t lookup(const char *);
static int xfsread(ino_t, void *, size_t);
-static ssize_t fsread(ino_t, void *, size_t);
static int dskread(void *, unsigned, unsigned);
static int printf(const char *,...);
static int putchar(int);
@@ -131,16 +130,17 @@ static int xputc(int);
static int xgetc(int);
static int getc(int);
+#if 1
#define memcpy __builtin_memcpy
-
-static inline void
-readfile(const char *fname, void *buf, size_t size)
+#else
+static void memcpy(char *, const char *, int);
+static void
+memcpy(char *dst, const char *src, int len)
{
- ino_t ino;
-
- if ((ino = lookup(fname)))
- fsread(ino, buf, size);
+ while (len--)
+ *dst++ = *src++;
}
+#endif
static inline int
strcmp(const char *s1, const char *s2)
@@ -151,15 +151,14 @@ strcmp(const char *s1, const char *s2)
#include "ufsread.c"
-static inline int
-getchar(void)
+static int
+xfsread(ino_t inode, void *buf, size_t nbyte)
{
- int c;
-
- c = xgetc(0);
- if (c == '\r')
- c = '\n';
- return c;
+ if (fsread(inode, buf, nbyte) != nbyte) {
+ printf("Invalid %s\n", "format");
+ return -1;
+ }
+ return 0;
}
static inline void
@@ -169,12 +168,13 @@ getstr(char *str, int size)
int c;
s = str;
- do {
- switch (c = getchar()) {
+ for (;;) {
+ switch (c = xgetc(0)) {
case 0:
break;
- case '\b':
case '\177':
+ c = '\b';
+ case '\b':
if (s > str) {
s--;
putchar('\b');
@@ -183,15 +183,16 @@ getstr(char *str, int size)
c = 0;
break;
case '\n':
+ case '\r':
*s = 0;
- break;
+ return;
default:
if (s - str < size - 1)
*s++ = c;
}
if (c)
putchar(c);
- } while (c != '\n');
+ }
}
static inline uint32_t
@@ -220,6 +221,7 @@ int
main(void)
{
int autoboot, i;
+ ino_t ino;
dmadat = (void *)(roundup2(__base + _end, 0x10000) - __base);
v86.ctl = V86_FLAGS;
@@ -238,7 +240,10 @@ main(void)
/* Process configuration file */
autoboot = 1;
- readfile(PATH_CONFIG, cmd, sizeof(cmd));
+
+ if ((ino = lookup(PATH_CONFIG)))
+ fsread(ino, cmd, sizeof(cmd));
+
if (*cmd) {
printf("%s: %s", PATH_CONFIG, cmd);
if (parse(cmd))
@@ -328,7 +333,7 @@ load(const char *fname)
return;
p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE);
bootinfo.bi_symtab = VTOP(p);
- memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms));
+ memcpy(p, (char *)&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))
@@ -365,7 +370,7 @@ load(const char *fname)
if (xfsread(ino, &es, sizeof(es)))
return;
for (i = 0; i < 2; i++) {
- memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size));
+ memcpy(p, (char *)&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))
@@ -378,7 +383,7 @@ load(const char *fname)
bootinfo.bi_esymtab = VTOP(p);
bootinfo.bi_kernelname = VTOP(fname);
bootinfo.bi_bios_dev = dsk.drive;
- __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
+ __exec((caddr_t)addr, opts & RBX_MASK,
MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part),
0, 0, 0, VTOP(&bootinfo));
}
@@ -449,9 +454,8 @@ parse(char *arg)
arg += 2;
if (drv == -1)
drv = dsk.unit;
- dsk.drive = (dsk.type == TYPE_WD ||
- dsk.type == TYPE_AD ||
- dsk.type == TYPE_DA ? DRV_HARD : 0) + drv;
+ dsk.drive = (dsk.type <= TYPE_MAXHARD
+ ? DRV_HARD : 0) + drv;
dsk_meta = 0;
fsread(0, NULL, 0);
}
@@ -467,16 +471,6 @@ parse(char *arg)
}
static int
-xfsread(ino_t inode, void *buf, size_t nbyte)
-{
- if (fsread(inode, buf, nbyte) != nbyte) {
- printf("Invalid %s\n", "format");
- return -1;
- }
- return 0;
-}
-
-static int
dskread(void *buf, unsigned lba, unsigned nblk)
{
struct dos_partition *dp;
diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile
index 1268e02..5c5292b 100644
--- a/sys/boot/i386/libi386/Makefile
+++ b/sys/boot/i386/libi386/Makefile
@@ -4,9 +4,9 @@ LIB= i386
INTERNALLIB= true
SRCS= aout_freebsd.c biosacpi.c bioscd.c biosdisk.c biosmem.c biospnp.c \
- biospci.c bootinfo.c comconsole.c devicename.c elf_freebsd.c gatea20.c \
- i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.s \
- time.c vidconsole.c
+ biospci.c bootinfo.c comconsole.c devicename.c divdi3.c elf_freebsd.c \
+ gatea20.c i386_copy.c i386_module.c moddi3.c nullconsole.c pxe.c \
+ pxetramp.s qdivrem.c time.c vidconsole.c
CFLAGS+= -ffreestanding
BOOT_COMCONSOLE_PORT?= 0x3f8
@@ -39,9 +39,12 @@ beforedepend ${OBJS}: machine
machine:
ln -sf ${.CURDIR}/../../../i386/include machine
+ ln -sf ${.CURDIR}/../../../../lib/libc/quad/divdi3.c divdi3.c
+ ln -sf ${.CURDIR}/../../../../lib/libc/quad/moddi3.c moddi3.c
+ ln -sf ${.CURDIR}/../../../../lib/libc/quad/qdivrem.c qdivrem.c
.endif
-CLEANFILES+= machine
+CLEANFILES+= machine divdi3.c moddi3.c qdivrem.c
.include <bsd.lib.mk>
diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile
index 0ad1276..8ff4779 100644
--- a/sys/boot/i386/loader/Makefile
+++ b/sys/boot/i386/loader/Makefile
@@ -119,7 +119,7 @@ FILES+= loader.rc
${BASE}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBFICL} vers.o
${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
- ${LIBFICL} ${LIBI386} ${LIBSTAND}
+ ${LIBFICL} ${LIBI386} ${LIBSTAND} ${LIBI386}
# If it's not there, don't consider it a target
.if exists(${.CURDIR}/../../../i386/include)
OpenPOWER on IntegriCloud