Employ the unused bytes after the disklabel in the second sector. This makes

it possible to make UFS1_ONLY and UFS2_ONLY versions which fit inside the
traditional 16 sectors.

Remove assorted now unneeded hackery.

UFS1_AND_UFS2 still needs another 150 bytes to work, and that is probably
not within our reach, ever.
This commit is contained in:
Poul-Henning Kamp 2002-12-14 19:44:13 +00:00
parent a22c4dc517
commit a3b5a4369c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=107879
4 changed files with 22 additions and 48 deletions

View File

@ -28,25 +28,22 @@ REL1= 0x700
ORG1= 0x7c00
ORG2= 0x2000
# Setting this to anything else gives UFS1+2 support and larger
# boot2 binary.
# Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit.
# BOOT2_UFS?= UFS2_ONLY
# BOOT2_UFS?= UFS1_AND_UFS2
BOOT2_UFS?= UFS1_ONLY
CFLAGS= -elf -ffreestanding -Os -fno-builtin \
-fno-guess-branch-probability \
-mrtd \
-D${BOOT2_UFS} \
-I${.CURDIR}/../../common \
-I${.CURDIR}/../btx/lib -I. \
-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
.if ${BOOT2_UFS} == "UFS1_ONLY"
CFLAGS+= -D${BOOT2_UFS}
.else
# nothing here
.endif
LDFLAGS=-nostdlib -static -N
all: boot1 boot2
@ -77,18 +74,12 @@ boot2.h: boot1.out
boot2: boot2.ldr boot2.bin ${BTX}/btx/btx
btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
-o boot2.ld -P 1 boot2.bin
.if ${BOOT2_UFS} == "UFS1_ONLY"
@ls -l boot2.ld | awk '{ x = 7680 - $$5; \
print x " bytes available"; if (x < 0) exit 1 }'
dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
.else
@ls -l boot2.ld | awk '{ x = 9728 - $$5; \
print x " bytes available"; if (x < 0) exit 1 }'
dd if=boot2.ld of=${.TARGET} obs=9728 conv=osync 2>/dev/null
.endif
boot2.ldr:
dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
dd if=/dev/zero of=${.TARGET} bs=276 count=1 2>/dev/null
boot2.bin: boot2.out
objcopy -S -O binary boot2.out ${.TARGET}

View File

@ -19,7 +19,7 @@
.set MEM_REL,0x700 // Relocation address
.set MEM_ARG,0x900 // Arguments
.set MEM_ORG,0x7c00 // Origin
.set MEM_BUF,0x8c00 // Load area
.set MEM_BUF,0x8cec // Load area
.set MEM_BTX,0x9000 // BTX start
.set MEM_JMP,0x9010 // BTX entry point
.set MEM_USR,0xa000 // Client start
@ -37,11 +37,7 @@
.set SIZ_PAG,0x1000 // Page size
.set SIZ_SEC,0x200 // Sector size
#ifdef UFS1_ONLY
.set NSECT,0x10
#else
.set NSECT,0x14
#endif
.globl start
.globl xread
.code16
@ -175,9 +171,9 @@ main.4: xor %dx,%dx // Partition:drive
// Ok, we have a slice and drive in %dx now, so use that to locate and load
// boot2. %si references the start of the slice we are looking for, so go
// 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 the disklabel, which is 0x200 bytes long.
// we read it in, we conveniently use 0x8cec as our transfer buffer. Thus,
// boot1 ends up at 0x8cec, and boot2 starts at 0x8cec + 0x200 = 0x8eec.
// The first part of boot2 is the disklabel, which is 0x114 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
@ -192,7 +188,7 @@ main.5: mov %dx,MEM_ARG // Save args
mov 0xa(%bx),%si // Get BTX length and set
add %bx,%si // %si to start of boot2.bin
mov $MEM_USR+SIZ_PAG*2,%di // Client page 2
mov $MEM_BTX+(NSECT-2)*SIZ_SEC,%cx // Byte
mov $MEM_BTX+(NSECT-1)*SIZ_SEC,%cx // Byte
sub %si,%cx // count
rep // Relocate
movsb // client

View File

@ -19,7 +19,7 @@
.set MEM_REL,0x700 // Relocation address
.set MEM_ARG,0x900 // Arguments
.set MEM_ORG,0x7c00 // Origin
.set MEM_BUF,0x8c00 // Load area
.set MEM_BUF,0x8cec // Load area
.set MEM_BTX,0x9000 // BTX start
.set MEM_JMP,0x9010 // BTX entry point
.set MEM_USR,0xa000 // Client start
@ -37,11 +37,7 @@
.set SIZ_PAG,0x1000 // Page size
.set SIZ_SEC,0x200 // Sector size
#ifdef UFS1_ONLY
.set NSECT,0x10
#else
.set NSECT,0x14
#endif
.globl start
.globl xread
.code16
@ -175,9 +171,9 @@ main.4: xor %dx,%dx // Partition:drive
// Ok, we have a slice and drive in %dx now, so use that to locate and load
// boot2. %si references the start of the slice we are looking for, so go
// 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 the disklabel, which is 0x200 bytes long.
// we read it in, we conveniently use 0x8cec as our transfer buffer. Thus,
// boot1 ends up at 0x8cec, and boot2 starts at 0x8cec + 0x200 = 0x8eec.
// The first part of boot2 is the disklabel, which is 0x114 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
@ -192,7 +188,7 @@ main.5: mov %dx,MEM_ARG // Save args
mov 0xa(%bx),%si // Get BTX length and set
add %bx,%si // %si to start of boot2.bin
mov $MEM_USR+SIZ_PAG*2,%di // Client page 2
mov $MEM_BTX+(NSECT-2)*SIZ_SEC,%cx // Byte
mov $MEM_BTX+(NSECT-1)*SIZ_SEC,%cx // Byte
sub %si,%cx // count
rep // Relocate
movsb // client

View File

@ -28,25 +28,22 @@ REL1= 0x700
ORG1= 0x7c00
ORG2= 0x2000
# Setting this to anything else gives UFS1+2 support and larger
# boot2 binary.
# Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit.
# BOOT2_UFS?= UFS2_ONLY
# BOOT2_UFS?= UFS1_AND_UFS2
BOOT2_UFS?= UFS1_ONLY
CFLAGS= -elf -ffreestanding -Os -fno-builtin \
-fno-guess-branch-probability \
-mrtd \
-D${BOOT2_UFS} \
-I${.CURDIR}/../../common \
-I${.CURDIR}/../btx/lib -I. \
-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
.if ${BOOT2_UFS} == "UFS1_ONLY"
CFLAGS+= -D${BOOT2_UFS}
.else
# nothing here
.endif
LDFLAGS=-nostdlib -static -N
all: boot1 boot2
@ -77,18 +74,12 @@ boot2.h: boot1.out
boot2: boot2.ldr boot2.bin ${BTX}/btx/btx
btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
-o boot2.ld -P 1 boot2.bin
.if ${BOOT2_UFS} == "UFS1_ONLY"
@ls -l boot2.ld | awk '{ x = 7680 - $$5; \
print x " bytes available"; if (x < 0) exit 1 }'
dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
.else
@ls -l boot2.ld | awk '{ x = 9728 - $$5; \
print x " bytes available"; if (x < 0) exit 1 }'
dd if=boot2.ld of=${.TARGET} obs=9728 conv=osync 2>/dev/null
.endif
boot2.ldr:
dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
dd if=/dev/zero of=${.TARGET} bs=276 count=1 2>/dev/null
boot2.bin: boot2.out
objcopy -S -O binary boot2.out ${.TARGET}