summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2000-07-07 21:12:34 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2000-07-07 21:12:34 +0000
commit568fd2f6bb3e5ac855109f9379a95db58e442377 (patch)
tree8d000e79a0dfd6018ea1535a32fc32616631a5f1
parent69e33ecb3a7006afdd7695ca163eca0fbe24ffe7 (diff)
Notes
-rw-r--r--sys/boot/README2
-rw-r--r--sys/boot/forth/loader.conf2
-rw-r--r--sys/boot/i386/boot0/boot0.m476
-rw-r--r--sys/boot/i386/boot2/Makefile2
-rw-r--r--sys/boot/i386/boot2/boot1.m466
-rw-r--r--sys/boot/i386/boot2/boot1.s49
-rw-r--r--sys/boot/i386/boot2/boot2.c221
-rw-r--r--sys/boot/i386/btx/btx/btx.m459
-rw-r--r--sys/boot/i386/btx/btx/btx.s21
-rw-r--r--sys/boot/i386/cdldr/Makefile3
-rw-r--r--sys/boot/i386/libi386/biosdisk.c110
-rw-r--r--sys/boot/i386/mbr/mbr.m451
-rw-r--r--sys/boot/i386/mbr/mbr.s47
-rw-r--r--sys/boot/pc98/btx/btx/btx.m459
14 files changed, 271 insertions, 497 deletions
diff --git a/sys/boot/README b/sys/boot/README
index 89851da3a502..7502788324ec 100644
--- a/sys/boot/README
+++ b/sys/boot/README
@@ -1,3 +1,5 @@
+$FreeBSD$
+
README file, for the boot config file setup. This is meant
to explain how to manage the loader configuration process.
The boot and loading process is either defined, or being
diff --git a/sys/boot/forth/loader.conf b/sys/boot/forth/loader.conf
index 26773515b4cb..ffdbdaf715a8 100644
--- a/sys/boot/forth/loader.conf
+++ b/sys/boot/forth/loader.conf
@@ -154,7 +154,7 @@ if_tl_load="NO" # Texas Instruments TNETE100 ("ThunderLAN")
if_vr_load="NO" # VIA Rhine I and Rhine II
if_wb_load="NO" # Winbond W89C840F
if_wi_load="NO" # WaveLAN/IEEE 802.11 wireless NICs
-if_wx_load="NO" # Intel Gigabit Ethernet Card (``Wiseman'')
+if_wx_load="NO" # Intel Gigabit Ethernet
if_xl_load="NO" # 3Com Etherlink XL (3c900, 3c905, 3c905B)
##############################################################
diff --git a/sys/boot/i386/boot0/boot0.m4 b/sys/boot/i386/boot0/boot0.m4
deleted file mode 100644
index d318d2a07e87..000000000000
--- a/sys/boot/i386/boot0/boot0.m4
+++ /dev/null
@@ -1,76 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-define(_al,0x0)dnl
-define(_cl,0x1)dnl
-define(_dl,0x2)dnl
-define(_bl,0x3)dnl
-define(_ah,0x4)dnl
-define(_ch,0x5)dnl
-define(_dh,0x6)dnl
-define(_bh,0x7)dnl
-
-define(_ax,0x0)dnl
-define(_cx,0x1)dnl
-define(_dx,0x2)dnl
-define(_bx,0x3)dnl
-define(_sp,0x4)dnl
-define(_bp,0x5)dnl
-define(_si,0x6)dnl
-define(_di,0x7)dnl
-
-define(_es,0x0)dnl
-define(_cs,0x1)dnl
-define(_ss,0x2)dnl
-define(_ds,0x3)dnl
-define(_fs,0x4)dnl
-define(_gs,0x5)dnl
-
-define(_bx_si,0x0)dnl
-define(_bx_di,0x1)dnl
-define(_bp_si,0x2)dnl
-define(_bp_di,0x3)dnl
-define(_si_,0x4)dnl
-define(_di_,0x5)dnl
-define(_bp_,0x6)dnl
-define(_bx_,0x7)dnl
-
-define(o16,`.byte 0x66')dnl
-
-define(addw1r,`.byte 0x3; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(addwia,`.byte 0x5; .word $1')dnl
-define(btwr1,`.word 0xa30f; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(btswr1,`.word 0xab0f; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(cmpbmr,`.byte 0x3a; .byte 0x6 | ($2 << 0x3); .word $1')dnl
-define(cmpw1r,`.byte 0x3b; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(cmpwi2,`.byte 0x81; .byte 0xb8 | $3; .word $2; .word $1')dnl
-define(addwir,`.byte 0x83; .byte 0xc0 | $2; .byte $1')dnl
-define(movbr0,`.byte 0x88; .byte ($1 << 0x3) | $2')dnl
-define(movbr1,`.byte 0x88; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(movwr1,`.byte 0x89; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(movb0r,`.byte 0x8a; .byte ($2 << 0x3) | $1')dnl
-define(addb0r,`.byte 0x2; .byte ($2 << 0x3) | $1')dnl
-define(movb1r,`.byte 0x8a; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movw1r,`.byte 0x8b; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movws1,`.byte 0x8c; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(movwir,`.byte 0xb8 | $2; .word $1')dnl
-define(movbi0,`.byte 0xc6; .byte $2; .byte $1')dnl
-define(callwi,`.byte 0xe8; .word $1 - . - 0x2')dnl
-define(jmpnwi,`.byte 0xe9; .word $1 - . - 0x2')dnl
-define(tstbi1,`.byte 0xf6; .byte 0x40 | $3; .byte $2; .byte $1')dnl
-define(incb1,`.byte 0xfe; .byte 0x40 | $2; .byte $1')dnl
-define(pushw1,`.byte 0xff; .byte 0x70 | $2; .byte $1')dnl
diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
index 0ccf65d0a0b3..35e7d89caeb1 100644
--- a/sys/boot/i386/boot2/Makefile
+++ b/sys/boot/i386/boot2/Makefile
@@ -10,7 +10,7 @@ CLEANFILES+= boot1 boot1.out boot1.o \
sio.o
# A value of 0x80 enables LBA support.
-B1FLAGS= 0
+B1FLAGS= 0x80
BOOT_COMCONSOLE_PORT?= 0x3f8
BOOT_COMCONSOLE_SPEED?= 9600
diff --git a/sys/boot/i386/boot2/boot1.m4 b/sys/boot/i386/boot2/boot1.m4
deleted file mode 100644
index 94dd13bd18b9..000000000000
--- a/sys/boot/i386/boot2/boot1.m4
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-define(_al,0x0)dnl
-define(_cl,0x1)dnl
-define(_dl,0x2)dnl
-define(_bl,0x3)dnl
-define(_ah,0x4)dnl
-define(_ch,0x5)dnl
-define(_dh,0x6)dnl
-define(_bh,0x7)dnl
-
-define(_ax,0x0)dnl
-define(_cx,0x1)dnl
-define(_dx,0x2)dnl
-define(_bx,0x3)dnl
-define(_sp,0x4)dnl
-define(_bp,0x5)dnl
-define(_si,0x6)dnl
-define(_di,0x7)dnl
-
-define(_bx_si,0x0)dnl
-define(_bx_di,0x1)dnl
-define(_bp_si,0x2)dnl
-define(_bp_di,0x3)dnl
-define(_si_,0x4)dnl
-define(_di_,0x5)dnl
-define(_bp_,0x6)dnl
-define(_bx_,0x7)dnl
-
-define(cs_,`.byte 0x2e')dnl
-define(o16,`.byte 0x66')dnl
-
-define(addbr1,`.byte 0x0; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(addwr1,`.byte 0x1; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(subbr1,`.byte 0x28; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(cmpbi1,`.byte 0x80; .byte 0x78 | $3; .byte $2; .byte $1')dnl
-define(cmpwir,`.byte 0x81; .byte 0xf8 | $2; .word $1')dnl
-define(movbr1,`.byte 0x88; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(movwr1,`.byte 0x89; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(movwrm,`.byte 0x89; .byte 0x6 | ($1 << 0x3); .word $2')dnl
-define(movb1r,`.byte 0x8a; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movw1r,`.byte 0x8b; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(leaw1r,`.byte 0x8d; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movwir,`.byte 0xb8 | $2; .word $1')dnl
-define(lesw1r,`.byte 0xc4; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movbi1,`.byte 0xc6; .byte 0x40 | $3; .byte $2; .byte $1')dnl
-define(callwi,`.byte 0xe8; .word $1 - . - 0x2')dnl
-define(jmpnwi,`.byte 0xe9; .word $1 - . - 0x2')dnl
-define(tstbi0,`.byte 0xf6; .byte $2; .byte $1')dnl
-define(tstbim,`.byte 0xf6; .byte 0x6; .word $2; .byte $1')dnl
-define(incw1,`.byte 0xff; .byte 0x40 | $2; .byte $1')dnl
diff --git a/sys/boot/i386/boot2/boot1.s b/sys/boot/i386/boot2/boot1.s
index da238b114f61..3b34041efd1a 100644
--- a/sys/boot/i386/boot2/boot1.s
+++ b/sys/boot/i386/boot2/boot1.s
@@ -23,6 +23,7 @@
.set MEM_BTX,0x9000 # BTX start
.set MEM_JMP,0x9010 # BTX entry point
.set MEM_USR,0xa000 # Client start
+ .set BDA_BOOT,0x472 # Boot howto flag
# Partition Constants
.set PRT_OFF,0x1be # Partition offset
@@ -138,13 +139,13 @@ main.4: xor %dx,%dx # Partition:drive
# ahead and load up the first 16 sectors (boot1 + boot2) from that. When
# we read it in, we conveniently use 0x8c00 as our transfer buffer. Thus,
# boot1 ends up at 0x8c00, and boot2 starts at 0x8c00 + 0x200 = 0x8e00.
-# The first part of boot2 is boot2.ldr, which is 0x200 bytes of zeros.
+# The first part of boot2 is the disklabel, which is 0x200 bytes long.
# The second part is BTX, which is thus loaded into 0x9000, which is where
# it also runs from. The boot2.bin binary starts right after the end of
# BTX, so we have to figure out where the start of it is and then move the
# binary to 0xb000. Normally, BTX clients start at MEM_USR, or 0xa000, but
# when we use btxld create boot2, we use an entry point of 0x1000. That
-# entry point is relative, to MEM_USR, thus boot2.bin starts at 0xb000.
+# entry point is relative to MEM_USR; thus boot2.bin starts at 0xb000.
#
main.5: mov %dx,MEM_ARG # Save args
movb $0x10,%dh # Sector count
@@ -200,7 +201,8 @@ error: callw putstr # Display message
callw putstr # prompt
xorb %ah,%ah # BIOS: Get
int $0x16 # keypress
- int $0x19 # BIOS: Reboot
+ movw $0x1234, BDA_BOOT # Do a warm boot
+ ljmp $0xffff,$0x0 # reboot the machine
#
# Display a null-terminated string using the BIOS output.
#
@@ -228,25 +230,8 @@ return: retw # To caller
#
# %dl - byte - drive number
# stack - 10 bytes - EDD Packet
-#
-read: testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled?
- jz read.1 # No
- mov $0x55aa,%bx # Magic
- push %dx # Save
- movb $0x41,%ah # BIOS: Check
- int $0x13 # extensions present
- pop %dx # Restore
- jc read.1 # If error
- cmp $0xaa55,%bx # Magic?
- jne read.1 # No
- testb $0x1,%cl # Packet interface?
- jz read.1 # No
- mov %bp,%si # Disk packet
- movb $0x42,%ah # BIOS: Extended
- int $0x13 # read
- retw # To caller
-
-read.1: push %dx # Save
+#
+read: push %dx # Save
movb $0x8,%ah # BIOS: Get drive
int $0x13 # parameters
movb %dh,%ch # Max head number
@@ -269,7 +254,7 @@ read.1: push %dx # Save
pop %dx # Restore
cmpl $0x3ff,%eax # Cylinder number supportable?
sti # Enable interrupts
- ja ereturn # No
+ ja read.7 # No, try EDD
xchgb %al,%ah # Set up cylinder
rorb $0x2,%al # number
orb %ch,%al # Merge
@@ -301,8 +286,24 @@ read.4: movzbw %bl,%ax # Sectors read
read.5: shlb %bl # buffer
add %bl,0x5(%bp) # pointer,
sub %al,0x2(%bp) # block count
- ja read.1 # If not done
+ ja read # If not done
read.6: retw # To caller
+read.7: testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled?
+ jz ereturn # No, so return an error
+ mov $0x55aa,%bx # Magic
+ push %dx # Save
+ movb $0x41,%ah # BIOS: Check
+ int $0x13 # extensions present
+ pop %dx # Restore
+ jc return # If error, return an error
+ cmp $0xaa55,%bx # Magic?
+ jne ereturn # No, so return an error
+ testb $0x1,%cl # Packet interface?
+ jz ereturn # No, so return an error
+ mov %bp,%si # Disk packet
+ movb $0x42,%ah # BIOS: Extended
+ int $0x13 # read
+ retw # To caller
# Messages
diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c
index 551238165231..67b906463fac 100644
--- a/sys/boot/i386/boot2/boot2.c
+++ b/sys/boot/i386/boot2/boot2.c
@@ -113,28 +113,127 @@ static uint8_t ioctrl = 0x1;
void exit(int);
static void load(const char *);
static int parse(char *);
-static void readfile(const char *, void *, size_t);
static ino_t lookup(const char *);
-static int fsfind(const char *, ino_t *);
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 void getstr(char *, int);
static int putchar(int);
-static int getchar(void);
static void *memcpy(void *, const void *, size_t);
-static int strcmp(const char *, const char *);
static void *malloc(size_t);
static uint32_t memsize(int);
-static uint32_t drvinfo(int);
static int drvread(void *, unsigned, unsigned);
static int keyhit(unsigned);
static int xputc(int);
static int xgetc(int);
-static void putc(int);
static int getc(int);
+static inline void
+readfile(const char *fname, void *buf, size_t size)
+{
+ ino_t ino;
+
+ if ((ino = lookup(fname)))
+ fsread(ino, buf, size);
+}
+
+static inline int
+strcmp(const char *s1, const char *s2)
+{
+ for (; *s1 == *s2 && *s1; s1++, s2++);
+ return (u_char)*s1 - (u_char)*s2;
+}
+
+static inline int
+fsfind(const char *name, ino_t * ino)
+{
+ char buf[DEV_BSIZE];
+ struct dirent *d;
+ char *s;
+ ssize_t n;
+
+ fs_off = 0;
+ while ((n = fsread(*ino, buf, DEV_BSIZE)) > 0)
+ for (s = buf; s < buf + DEV_BSIZE;) {
+ d = (void *)s;
+ if (ls)
+ printf("%s ", d->d_name);
+ else if (!strcmp(name, d->d_name)) {
+ *ino = d->d_fileno;
+ return d->d_type;
+ }
+ s += d->d_reclen;
+ }
+ if (n != -1 && ls)
+ putchar('\n');
+ return 0;
+}
+
+static inline int
+getchar(void)
+{
+ int c;
+
+ c = xgetc(0);
+ if (c == '\r')
+ c = '\n';
+ return c;
+}
+
+static inline void
+getstr(char *str, int size)
+{
+ char *s;
+ int c;
+
+ s = str;
+ do {
+ switch (c = getchar()) {
+ case 0:
+ break;
+ case '\b':
+ case '\177':
+ if (s > str) {
+ s--;
+ putchar('\b');
+ putchar(' ');
+ } else
+ c = 0;
+ break;
+ case '\n':
+ *s = 0;
+ break;
+ default:
+ if (s - str < size - 1)
+ *s++ = c;
+ }
+ if (c)
+ putchar(c);
+ } while (c != '\n');
+}
+
+static inline uint32_t
+drvinfo(int drive)
+{
+ v86.addr = 0x13;
+ v86.eax = 0x800;
+ v86.edx = DRV_HARD + drive;
+ v86int();
+ if (V86_CY(v86.efl))
+ return 0x4f010f;
+ return ((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) |
+ (v86.edx & 0xff00) | (v86.ecx & 0x3f);
+}
+
+static inline void
+putc(int c)
+{
+ v86.addr = 0x10;
+ v86.eax = 0xe00 | (c & 0xff);
+ v86.ebx = 0x7;
+ v86int();
+}
+
int
main(void)
{
@@ -191,6 +290,7 @@ main(void)
}
}
+/* XXX - Needed for btxld to link the boot2 binary; do not remove. */
void
exit(int x)
{
@@ -374,15 +474,6 @@ parse(char *arg)
return 0;
}
-static void
-readfile(const char *fname, void *buf, size_t size)
-{
- ino_t ino;
-
- if ((ino = lookup(fname)))
- fsread(ino, buf, size);
-}
-
static ino_t
lookup(const char *path)
{
@@ -411,32 +502,6 @@ lookup(const char *path)
}
return dt == DT_REG ? ino : 0;
}
-
-static int
-fsfind(const char *name, ino_t * ino)
-{
- char buf[DEV_BSIZE];
- struct dirent *d;
- char *s;
- ssize_t n;
-
- fs_off = 0;
- while ((n = fsread(*ino, buf, DEV_BSIZE)) > 0)
- for (s = buf; s < buf + DEV_BSIZE;) {
- d = (void *)s;
- if (ls)
- printf("%s ", d->d_name);
- else if (!strcmp(name, d->d_name)) {
- *ino = d->d_fileno;
- return d->d_type;
- }
- s += d->d_reclen;
- }
- if (n != -1 && ls)
- putchar('\n');
- return 0;
-}
-
static int
xfsread(ino_t inode, void *buf, size_t nbyte)
{
@@ -626,38 +691,6 @@ printf(const char *fmt,...)
return 0;
}
-static void
-getstr(char *str, int size)
-{
- char *s;
- int c;
-
- s = str;
- do {
- switch (c = getchar()) {
- case 0:
- break;
- case '\b':
- case '\177':
- if (s > str) {
- s--;
- putchar('\b');
- putchar(' ');
- } else
- c = 0;
- break;
- case '\n':
- *s = 0;
- break;
- default:
- if (s - str < size - 1)
- *s++ = c;
- }
- if (c)
- putchar(c);
- } while (c != '\n');
-}
-
static int
putchar(int c)
{
@@ -666,17 +699,6 @@ putchar(int c)
return xputc(c);
}
-static int
-getchar(void)
-{
- int c;
-
- c = xgetc(0);
- if (c == '\r')
- c = '\n';
- return c;
-}
-
static void *
memcpy(void *dst, const void *src, size_t size)
{
@@ -688,13 +710,6 @@ memcpy(void *dst, const void *src, size_t size)
return dst;
}
-static int
-strcmp(const char *s1, const char *s2)
-{
- for (; *s1 == *s2 && *s1; s1++, s2++);
- return (u_char)*s1 - (u_char)*s2;
-}
-
static void *
malloc(size_t size)
{
@@ -717,19 +732,6 @@ memsize(int type)
return v86.eax;
}
-static uint32_t
-drvinfo(int drive)
-{
- v86.addr = 0x13;
- v86.eax = 0x800;
- v86.edx = DRV_HARD + drive;
- v86int();
- if (V86_CY(v86.efl))
- return 0x4f010f;
- return ((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) |
- (v86.edx & 0xff00) | (v86.ecx & 0x3f);
-}
-
static int
drvread(void *buf, unsigned lba, unsigned nblk)
{
@@ -793,15 +795,6 @@ xgetc(int fn)
}
}
-static void
-putc(int c)
-{
- v86.addr = 0x10;
- v86.eax = 0xe00 | (c & 0xff);
- v86.ebx = 0x7;
- v86int();
-}
-
static int
getc(int fn)
{
diff --git a/sys/boot/i386/btx/btx/btx.m4 b/sys/boot/i386/btx/btx/btx.m4
deleted file mode 100644
index 70649bbb6c91..000000000000
--- a/sys/boot/i386/btx/btx/btx.m4
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-define(_al,0x0)dnl
-define(_cl,0x1)dnl
-define(_dl,0x2)dnl
-define(_bl,0x3)dnl
-define(_ah,0x4)dnl
-define(_ch,0x5)dnl
-define(_dh,0x6)dnl
-define(_bh,0x7)dnl
-
-define(_ax,0x0)dnl
-define(_cx,0x1)dnl
-define(_dx,0x2)dnl
-define(_bx,0x3)dnl
-define(_sp,0x4)dnl
-define(_bp,0x5)dnl
-define(_si,0x6)dnl
-define(_di,0x7)dnl
-
-define(_bx_si,0x0)dnl
-define(_bx_di,0x1)dnl
-define(_bp_si,0x2)dnl
-define(_bp_di,0x3)dnl
-define(_si_,0x4)dnl
-define(_di_,0x5)dnl
-define(_bp_,0x6)dnl
-define(_bx_,0x7)dnl
-
-define(o16,`.byte 0x66')dnl
-
-define(addwia,`.byte 0x5; .word $1')dnl
-define(lgdtwm,`.byte 0xf; .byte 0x1; .byte 0x16; .word $1')dnl
-define(lidtwm,`.byte 0xf; .byte 0x1; .byte 0x1e; .word $1')dnl
-define(cmpwmr,`.byte 0x3b; .byte ($2 << 0x3) | 0x6; .word $1')dnl
-define(cmpwir,`.byte 0x81; .byte 0xf8 | $2; .word $1')dnl
-define(movbr1,`.byte 0x88; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(movwr0,`.byte 0x89; .byte ($1 << 0x3) | $2')dnl
-define(leaw1r,`.byte 0x8d; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movwir,`.byte 0xb8 | $2; .word $1')dnl
-define(movbi1,`.byte 0xc6; .byte 0x40 | $3; .byte $2; .byte $1')dnl
-define(callwi,`.byte 0xe8; .word $1 - . - 0x2')dnl
-define(jmpfwi,`.byte 0xea; .word $2; .word $1')dnl
-define(tstbim,`.byte 0xf6; .byte 0x6; .word $2; .byte $1')dnl
diff --git a/sys/boot/i386/btx/btx/btx.s b/sys/boot/i386/btx/btx/btx.s
index 827a444d190b..48729cf9c62d 100644
--- a/sys/boot/i386/btx/btx/btx.s
+++ b/sys/boot/i386/btx/btx/btx.s
@@ -480,6 +480,8 @@ v86mon.2: cmpb $0xf4,%al # HLT?
jmp intrtn # Return to user mode
v86mon.3: cmpb $0xf,%al # Prefixed instruction?
jne v86mon.4 # No
+ cmpb $0x09,(%esi) # Is it a WBINVD?
+ je v86wbinvd # Yes
cmpb $0x30,(%esi) # Is it a WRMSR?
je v86wrmsr # Yes
cmpb $0x32,(%esi) # Is it a RDMSR?
@@ -522,18 +524,26 @@ v86mon.7: subl %edi,%esi # From linear
#
v86mov: movl %cr0,%eax # CR0 to
movl %eax,0x1c(%ebp) # saved EAX
- incl %esi # Adjust
- incl %esi # IP
+ incl %esi # Adjust IP
+#
+# Return from emulating a 0x0f prefixed instruction
+#
+v86preret: incl %esi # Adjust IP
jmp v86mon.7 # Finish up
#
+# Emulate WBINVD
+#
+v86wbinvd: wbinvd # Write back and invalidate
+ # cache
+ jmp v86preret # Finish up
+#
# Emulate WRMSR
#
v86wrmsr: movl 0x18(%ebp),%ecx # Get user's %ecx (MSR to write)
movl 0x14(%ebp),%edx # Load the value
movl 0x1c(%ebp),%eax # to write
wrmsr # Write MSR
- incl %esi # Adjust IP
- jmp v86mon.7 # Finish up
+ jmp v86preret # Finish up
#
# Emulate RDMSR
#
@@ -541,8 +551,7 @@ v86rdmsr: movl 0x18(%ebp),%ecx # MSR to read
rdmsr # Read the MSR
movl %eax,0x1c(%ebp) # Return the value of
movl %edx,0x14(%ebp) # the MSR to the user
- incl %esi # Adjust IP
- jmp v86mon.7
+ jmp v86preret # Finish up
#
# Emulate CLI.
#
diff --git a/sys/boot/i386/cdldr/Makefile b/sys/boot/i386/cdldr/Makefile
index a67f2a741198..f42e1ef043ba 100644
--- a/sys/boot/i386/cdldr/Makefile
+++ b/sys/boot/i386/cdldr/Makefile
@@ -32,9 +32,6 @@ ${LDR}: ${LDR}.o
objcopy -S -O binary ${LDR}.out ${.TARGET}
.endif
-${LDR}.o: ${.CURDIR}/${LDR}.s
- ${AS} ${AFLAGS} -o ${.TARGET} ${.CURDIR}/${LDR}.s
-
CLEANFILES+= ${LDR} ${LDR}.out ${LDR}.o ${BOOT}.tmp
.include <bsd.prog.mk>
diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c
index bee8a529db9a..36fd10a52fd0 100644
--- a/sys/boot/i386/libi386/biosdisk.c
+++ b/sys/boot/i386/libi386/biosdisk.c
@@ -48,6 +48,7 @@
#include <btxv86.h>
#include "libi386.h"
+#define BIOS_NUMDRIVES 0x475
#define BIOSDISK_SECSIZE 512
#define BUFSIZE (1 * BIOSDISK_SECSIZE)
#define MAXBDDEV MAXDEV
@@ -75,7 +76,7 @@ struct open_disk {
#define BD_MODEINT13 0x0000
#define BD_MODEEDD1 0x0001
#define BD_MODEEDD3 0x0002
-#define BD_MODEMASK 0x0003
+#define BD_MODEMASK 0x0003
#define BD_FLOPPY 0x0004
#define BD_LABELOK 0x0008
#define BD_PARTTABOK 0x0010
@@ -158,22 +159,23 @@ bd_unit2bios(int unit)
/*
* Quiz the BIOS for disk devices, save a little info about them.
- *
- * XXX should we be consulting the BIOS equipment list, specifically
- * the value at 0x475?
*/
static int
bd_init(void)
{
- int base, unit;
+ int base, unit, nfd = 0;
/* sequence 0, 0x80 */
for (base = 0; base <= 0x80; base += 0x80) {
for (unit = base; (nbdinfo < MAXBDDEV); unit++) {
+ /* check the BIOS equipment list for number of fixed disks */
+ if((base == 0x80) &&
+ (nfd >= *(unsigned short *)PTOV(BIOS_NUMDRIVES)))
+ break;
+
bdinfo[nbdinfo].bd_unit = unit;
bdinfo[nbdinfo].bd_flags = (unit < 0x80) ? BD_FLOPPY : 0;
- /* XXX add EDD probes */
if (!bd_int13probe(&bdinfo[nbdinfo]))
break;
@@ -181,6 +183,8 @@ bd_init(void)
printf("BIOS drive %c: is disk%d\n",
(unit < 0x80) ? ('A' + unit) : ('C' + unit - 0x80), nbdinfo);
nbdinfo++;
+ if (base == 0x80)
+ nfd++;
}
}
return(0);
@@ -189,11 +193,9 @@ bd_init(void)
/*
* Try to detect a device supported by the legacy int13 BIOS
*/
-
static int
bd_int13probe(struct bdinfo *bd)
{
-
v86.ctl = V86_FLAGS;
v86.addr = 0x13;
v86.eax = 0x800;
@@ -204,6 +206,19 @@ bd_int13probe(struct bdinfo *bd)
((v86.edx & 0xff) > (bd->bd_unit & 0x7f))) { /* unit # OK */
bd->bd_flags |= BD_MODEINT13;
bd->bd_type = v86.ebx & 0xff;
+
+ /* Determine if we can use EDD with this device. */
+ v86.eax = 0x4100;
+ v86.edx = bd->bd_unit;
+ v86.ebx = 0x55aa;
+ v86int();
+ if (!(v86.efl & 0x1) && /* carry clear */
+ ((v86.ebx & 0xffff) == 0xaa55) && /* signature */
+ (v86.ecx & 0x1)) { /* packets mode ok */
+ bd->bd_flags |= BD_MODEEDD1;
+ if(v86.eax & 0xff00 > 0x300)
+ bd->bd_flags |= BD_MODEEDD3;
+ }
return(1);
}
return(0);
@@ -285,19 +300,28 @@ bd_printslice(struct open_disk *od, struct dos_partition *dp, char *prefix)
case DOSPTYP_EXT:
return;
case 0x01:
- sprintf(line, "%s: FAT-12\n", prefix);
+ sprintf(line, "%s: FAT-12 %.6dMB (%d - %d)\n", prefix,
+ dp->dp_size / 2048, /* 512-byte sector assumption */
+ dp->dp_start, dp->dp_start + dp->dp_size);
break;
case 0x04:
case 0x06:
case 0x0e:
- sprintf(line, "%s: FAT-16\n", prefix);
+ sprintf(line, "%s: FAT-16 %.6dMB (%d - %d)\n", prefix,
+ dp->dp_size / 2048, /* 512-byte sector assumption */
+ dp->dp_start, dp->dp_start + dp->dp_size);
break;
case 0x0b:
case 0x0c:
- sprintf(line, "%s: FAT-32\n", prefix);
+ sprintf(line, "%s: FAT-32 %.6dMB (%d - %d)\n", prefix,
+ dp->dp_size / 2048, /* 512-byte sector assumption */
+ dp->dp_start, dp->dp_start + dp->dp_size);
break;
default:
- sprintf(line, "%s: Unknown fs: 0x%x\n", prefix, dp->dp_typ);
+ sprintf(line, "%s: Unknown fs: 0x%x %.6dMB (%d - %d)\n",
+ prefix, dp->dp_typ,
+ dp->dp_size / 2048, /* 512-byte sector assumption */
+ dp->dp_start, dp->dp_start + dp->dp_size);
}
pager_output(line);
}
@@ -315,18 +339,21 @@ bd_printbsdslice(struct open_disk *od, int offset, char *prefix)
return;
lp =(struct disklabel *)(&buf[0]);
if (lp->d_magic != DISKMAGIC) {
- sprintf(line, "bad disklabel\n");
+ sprintf(line, "%s: FFS bad disklabel\n", prefix);
pager_output(line);
return;
}
/* Print partitions */
for (i = 0; i < lp->d_npartitions; i++) {
- if ((lp->d_partitions[i].p_fstype == FS_BSDFFS) || (lp->d_partitions[i].p_fstype == FS_SWAP) ||
+ if ((lp->d_partitions[i].p_fstype == FS_BSDFFS) ||
+ (lp->d_partitions[i].p_fstype == FS_SWAP) ||
+ (lp->d_partitions[i].p_fstype == FS_VINUM) ||
((lp->d_partitions[i].p_fstype == FS_UNUSED) &&
(od->od_flags & BD_FLOPPY) && (i == 0))) { /* Floppies often have bogus fstype, print 'a' */
sprintf(line, " %s%c: %s %.6dMB (%d - %d)\n", prefix, 'a' + i,
- (lp->d_partitions[i].p_fstype == FS_SWAP) ? "swap" : "FFS",
+ (lp->d_partitions[i].p_fstype == FS_SWAP) ? "swap" :
+ (lp->d_partitions[i].p_fstype == FS_VINUM) ? "vinum" : "FFS",
lp->d_partitions[i].p_size / 2048, /* 512-byte sector assumption */
lp->d_partitions[i].p_offset, lp->d_partitions[i].p_offset + lp->d_partitions[i].p_size);
pager_output(line);
@@ -799,18 +826,47 @@ bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
v86int();
}
- /* build request XXX support EDD requests too */
- v86.ctl = V86_FLAGS;
- v86.addr = 0x13;
- v86.eax = 0x200 | x;
- v86.ecx = ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec;
- v86.edx = (hd << 8) | od->od_unit;
- v86.es = VTOPSEG(xp);
- v86.ebx = VTOPOFF(xp);
- v86int();
- result = (v86.efl & 0x1);
- if (result == 0)
- break;
+ if(cyl > 1023) {
+ /* use EDD if the disk supports it, otherwise, return error */
+ if(od->od_flags & BD_MODEEDD1) {
+ static unsigned short packet[8];
+
+ packet[0] = 0x10;
+ packet[1] = x;
+ packet[2] = VTOPOFF(xp);
+ packet[3] = VTOPSEG(xp);
+ packet[4] = dblk & 0xffff;
+ packet[5] = dblk >> 16;
+ packet[6] = 0;
+ packet[7] = 0;
+ v86.ctl = V86_FLAGS;
+ v86.addr = 0x13;
+ v86.eax = 0x4200;
+ v86.edx = od->od_unit;
+ v86.ds = VTOPSEG(packet);
+ v86.esi = VTOPOFF(packet);
+ v86int();
+ result = (v86.efl & 0x1);
+ if(result == 0)
+ break;
+ } else {
+ result = 1;
+ break;
+ }
+ } else {
+ /* Use normal CHS addressing */
+ v86.ctl = V86_FLAGS;
+ v86.addr = 0x13;
+ v86.eax = 0x200 | x;
+ v86.ecx = ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec;
+ v86.edx = (hd << 8) | od->od_unit;
+ v86.es = VTOPSEG(xp);
+ v86.ebx = VTOPOFF(xp);
+ v86int();
+ result = (v86.efl & 0x1);
+ if (result == 0)
+ break;
+ }
}
DEBUG("%d sectors from %d/%d/%d to %p (0x%x) %s", x, cyl, hd, sec - 1, p, VTOP(p), result ? "failed" : "ok");
diff --git a/sys/boot/i386/mbr/mbr.m4 b/sys/boot/i386/mbr/mbr.m4
deleted file mode 100644
index c8783b92059e..000000000000
--- a/sys/boot/i386/mbr/mbr.m4
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Copyright (c) 1999 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-define(_al,0x0)dnl
-define(_cl,0x1)dnl
-define(_dl,0x2)dnl
-define(_bl,0x3)dnl
-define(_ah,0x4)dnl
-define(_ch,0x5)dnl
-define(_dh,0x6)dnl
-define(_bh,0x7)dnl
-
-define(_ax,0x0)dnl
-define(_cx,0x1)dnl
-define(_dx,0x2)dnl
-define(_bx,0x3)dnl
-define(_sp,0x4)dnl
-define(_bp,0x5)dnl
-define(_si,0x6)dnl
-define(_di,0x7)dnl
-
-define(_bx_si,0x0)dnl
-define(_bx_di,0x1)dnl
-define(_bp_si,0x2)dnl
-define(_bp_di,0x3)dnl
-define(_si_,0x4)dnl
-define(_di_,0x5)dnl
-define(_bp_,0x6)dnl
-define(_bx_,0x7)dnl
-
-define(cmpbr0,`.byte 0x38; .byte ($1 << 0x3) | $2')dnl
-define(cmpwi2,`.byte 0x81; .byte 0xb8 | $3; .word $2; .word $1')dnl
-define(movb0r,`.byte 0x8a; .byte ($2 << 0x3) | $1')dnl
-define(movb1r,`.byte 0x8a; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movw1r,`.byte 0x8b; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movwir,`.byte 0xb8 | $2; .word $1')dnl
-define(jmpnwi,`.byte 0xe9; .word $1 - . - 0x2')dnl
diff --git a/sys/boot/i386/mbr/mbr.s b/sys/boot/i386/mbr/mbr.s
index c8a55b6f5ce6..9cd39d295ddf 100644
--- a/sys/boot/i386/mbr/mbr.s
+++ b/sys/boot/i386/mbr/mbr.s
@@ -22,7 +22,7 @@
.set PT_OFF,0x1be # Partition table
.set MAGIC,0xaa55 # Magic: bootable
- .set NDRIVE,0x8 # Drives to support
+ .set NHRDRV,0x475 # Number of hard drives
.globl start # Entry point
.code16
@@ -34,10 +34,8 @@ start: cld # String ops inc
xorw %ax,%ax # Zero
movw %ax,%es # Address
movw %ax,%ds # data
- cli # Disable interrupts
movw %ax,%ss # Set up
movw $LOAD,%sp # stack
- sti # Enable interrupts
#
# Relocate ourself to a lower address so that we are out of the way when
# we load in the bootstrap from the partition to boot.
@@ -73,23 +71,52 @@ main.2: addb $0x10,%bl # Till
int $0x18 # BIOS: Diskless boot
#
# Ok, we've found a possible active partition. Check to see that the drive
-# is a valid hard drive number. XXX - We assume that there are up to 8 valid
-# hard drives, regardless of how many are actually installed. Yuck.
+# is a valid hard drive number.
#
main.3: cmpb $0x80,%dl # Drive valid?
jb main.4 # No
- cmpb $0x80+NDRIVE,%dl # Within range?
+ movb NHRDRV,%dh # Calculate the highest
+ addb $0x80,%dh # drive number available
+ cmpb %dh,%dl # Within range?
jb main.5 # Yes
+main.4: movb (%si),%dl # Load drive
#
# Ok, now that we have a valid drive and partition entry, load the CHS from
# the partition entry and read the sector from the disk.
#
-main.4: movb (%si),%dl # Load drive
-main.5: movb 0x1(%si),%dh # Load head
+main.5: movw %sp,%di # Save stack pointer
+ movb 0x1(%si),%dh # Load head
movw 0x2(%si),%cx # Load cylinder:sector
movw $LOAD,%bx # Transfer buffer
- movw $0x201,%ax # BIOS: Read from
- int $0x13 # disk
+ cmpb $0xff,%dh # Might we need to use LBA?
+ jnz main.7 # No.
+ cmpw $0xffff,%cx # Do we need to use LBA?
+ jnz main.7 # No.
+ pushw %cx # Save %cx
+ pushw %bx # Save %bx
+ movw $0x55aa,%bx # Magic
+ movb $0x41,%ah # BIOS: EDD extensions
+ int $0x13 # present?
+ jc main.6 # No.
+ cmpw $0xaa55,%bx # Magic ok?
+ jne main.6 # No.
+ testb $0x1,%cl # Packet mode present?
+ jz main.6 # No.
+ popw %bx # Restore %bx
+ pushl $0x0 # Set the LBA
+ pushl 0x8(%si) # address
+ pushw %es # Set the address of
+ pushw %bx # the transfer buffer
+ pushw $0x1 # Read 1 sector
+ pushw $0x10 # Packet length
+ movw %sp,%si # Packer pointer
+ movw $0x4200,%ax # BIOS: LBA Read from disk
+ jmp main.8 # Skip the CHS setup
+main.6: popw %bx # Restore %bx
+ popw %cx # Restore %cx
+main.7: movw $0x201,%ax # BIOS: Read from disk
+main.8: int $0x13 # Call the BIOS
+ movw %di,%sp # Restore stack
jc err_rd # If error
#
# Now that we've loaded the bootstrap, check for the 0xaa55 signature. If it
diff --git a/sys/boot/pc98/btx/btx/btx.m4 b/sys/boot/pc98/btx/btx/btx.m4
deleted file mode 100644
index 70649bbb6c91..000000000000
--- a/sys/boot/pc98/btx/btx/btx.m4
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-define(_al,0x0)dnl
-define(_cl,0x1)dnl
-define(_dl,0x2)dnl
-define(_bl,0x3)dnl
-define(_ah,0x4)dnl
-define(_ch,0x5)dnl
-define(_dh,0x6)dnl
-define(_bh,0x7)dnl
-
-define(_ax,0x0)dnl
-define(_cx,0x1)dnl
-define(_dx,0x2)dnl
-define(_bx,0x3)dnl
-define(_sp,0x4)dnl
-define(_bp,0x5)dnl
-define(_si,0x6)dnl
-define(_di,0x7)dnl
-
-define(_bx_si,0x0)dnl
-define(_bx_di,0x1)dnl
-define(_bp_si,0x2)dnl
-define(_bp_di,0x3)dnl
-define(_si_,0x4)dnl
-define(_di_,0x5)dnl
-define(_bp_,0x6)dnl
-define(_bx_,0x7)dnl
-
-define(o16,`.byte 0x66')dnl
-
-define(addwia,`.byte 0x5; .word $1')dnl
-define(lgdtwm,`.byte 0xf; .byte 0x1; .byte 0x16; .word $1')dnl
-define(lidtwm,`.byte 0xf; .byte 0x1; .byte 0x1e; .word $1')dnl
-define(cmpwmr,`.byte 0x3b; .byte ($2 << 0x3) | 0x6; .word $1')dnl
-define(cmpwir,`.byte 0x81; .byte 0xf8 | $2; .word $1')dnl
-define(movbr1,`.byte 0x88; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(movwr0,`.byte 0x89; .byte ($1 << 0x3) | $2')dnl
-define(leaw1r,`.byte 0x8d; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movwir,`.byte 0xb8 | $2; .word $1')dnl
-define(movbi1,`.byte 0xc6; .byte 0x40 | $3; .byte $2; .byte $1')dnl
-define(callwi,`.byte 0xe8; .word $1 - . - 0x2')dnl
-define(jmpfwi,`.byte 0xea; .word $2; .word $1')dnl
-define(tstbim,`.byte 0xf6; .byte 0x6; .word $2; .byte $1')dnl