mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-19 10:53:58 +00:00
Conditionalize the number of sectors loaded by boot1.s on UFS1/UFS12.
Conditionalize the "XX bytes left" checks reference on UFS1/UFS12. Conditionally build the necessary 64bit math for boot2 if UFS12. Sponsored by: DARPA & NAI Labs.
This commit is contained in:
parent
5b0f380cdd
commit
15cfc1833c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=104635
@ -7,7 +7,7 @@ BINDIR?= /boot
|
||||
BINMODE= 444
|
||||
CLEANFILES+= boot1 boot1.out boot1.o \
|
||||
boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \
|
||||
boot2.s sio.o
|
||||
boot2.s sio.o divdi3.o moddi3.o qdivrem.o
|
||||
|
||||
NM?= nm
|
||||
|
||||
@ -27,6 +27,10 @@ BTX= ${.CURDIR}/../btx
|
||||
ORG1= 0x7c00
|
||||
ORG2= 0x1000
|
||||
|
||||
# Setting this to anything else gives UFS1+2 support and larger
|
||||
# boot2 binary.
|
||||
BOOT2_UFS?= UFS1_ONLY
|
||||
|
||||
CFLAGS= -elf -ffreestanding -Os -fno-builtin \
|
||||
-fno-guess-branch-probability \
|
||||
-mrtd \
|
||||
@ -36,7 +40,11 @@ CFLAGS= -elf -ffreestanding -Os -fno-builtin \
|
||||
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
|
||||
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
|
||||
|
||||
CFLAGS+= -DUFS1_ONLY
|
||||
.if ${BOOT2_UFS} == "UFS1_ONLY"
|
||||
CFLAGS+= -D${BOOT2_UFS}
|
||||
.else
|
||||
|
||||
.endif
|
||||
|
||||
LDFLAGS=-nostdlib -static -N
|
||||
|
||||
@ -66,9 +74,15 @@ 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
|
||||
@ -76,9 +90,13 @@ boot2.ldr:
|
||||
boot2.bin: boot2.out
|
||||
objcopy -S -O binary boot2.out ${.TARGET}
|
||||
|
||||
.if ${BOOT2_UFS} == "UFS1_ONLY"
|
||||
boot2.out: boot2.o sio.o
|
||||
.else
|
||||
boot2.out: boot2.o sio.o divdi3.o moddi3.o qdivrem.o
|
||||
.endif
|
||||
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
|
||||
${BTX}/lib/crt0.o boot2.o sio.o
|
||||
${BTX}/lib/crt0.o ${.ALLSRC}
|
||||
|
||||
boot2.o: boot2.h
|
||||
|
||||
@ -88,6 +106,15 @@ sio.o: sio.s
|
||||
--defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \
|
||||
${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
moddi3.o: ${.CURDIR}/../../../libkern/moddi3.c
|
||||
${CC} ${CFLAGS} -I${.CURDIR}/../../../ -c ${.IMPSRC}
|
||||
|
||||
divdi3.o: ${.CURDIR}/../../../libkern/divdi3.c
|
||||
${CC} ${CFLAGS} -I${.CURDIR}/../../../ -c ${.IMPSRC}
|
||||
|
||||
qdivrem.o: ${.CURDIR}/../../../libkern/qdivrem.c
|
||||
${CC} ${CFLAGS} -I${.CURDIR}/../../../ -c ${.IMPSRC}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
|
||||
boot1 ${DESTDIR}${BINDIR}/boot1
|
||||
|
@ -37,6 +37,11 @@
|
||||
.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
|
||||
@ -181,13 +186,13 @@ main.4: xor %dx,%dx // Partition:drive
|
||||
// entry point is relative to MEM_USR; thus boot2.bin starts at 0xb000.
|
||||
//
|
||||
main.5: mov %dx,MEM_ARG // Save args
|
||||
movb $0x14,%dh // Sector count
|
||||
movb $NSECT,%dh // Sector count
|
||||
callw nread // Read disk
|
||||
mov $MEM_BTX,%bx // BTX
|
||||
mov 0xa(%bx),%si // Get BTX length and set
|
||||
add %bx,%si // %si to start of boot2.bin
|
||||
mov $MEM_USR+SIZ_PAG,%di // Client page 1
|
||||
mov $MEM_BTX+0x12*SIZ_SEC,%cx // Byte
|
||||
mov $MEM_BTX+(NSECT-2)*SIZ_SEC,%cx // Byte
|
||||
sub %si,%cx // count
|
||||
rep // Relocate
|
||||
movsb // client
|
||||
|
@ -37,6 +37,11 @@
|
||||
.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
|
||||
@ -181,13 +186,13 @@ main.4: xor %dx,%dx // Partition:drive
|
||||
// entry point is relative to MEM_USR; thus boot2.bin starts at 0xb000.
|
||||
//
|
||||
main.5: mov %dx,MEM_ARG // Save args
|
||||
movb $0x14,%dh // Sector count
|
||||
movb $NSECT,%dh // Sector count
|
||||
callw nread // Read disk
|
||||
mov $MEM_BTX,%bx // BTX
|
||||
mov 0xa(%bx),%si // Get BTX length and set
|
||||
add %bx,%si // %si to start of boot2.bin
|
||||
mov $MEM_USR+SIZ_PAG,%di // Client page 1
|
||||
mov $MEM_BTX+0x12*SIZ_SEC,%cx // Byte
|
||||
mov $MEM_BTX+(NSECT-2)*SIZ_SEC,%cx // Byte
|
||||
sub %si,%cx // count
|
||||
rep // Relocate
|
||||
movsb // client
|
||||
|
@ -269,7 +269,11 @@ main(void)
|
||||
/* Present the user with the boot2 prompt. */
|
||||
|
||||
for (;;) {
|
||||
printf(" \n>> FreeBSD/i386 BOOT\n"
|
||||
#ifdef UFS1_ONLY
|
||||
printf(" \n>> FreeBSD/i386/UFS1 BOOT\n"
|
||||
#else
|
||||
printf(" \n>> FreeBSD/i386/UFS[12] BOOT\n"
|
||||
#endif
|
||||
"Default: %u:%s(%u,%c)%s\n"
|
||||
"boot: ",
|
||||
dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
|
||||
|
@ -7,7 +7,7 @@ BINDIR?= /boot
|
||||
BINMODE= 444
|
||||
CLEANFILES+= boot1 boot1.out boot1.o \
|
||||
boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \
|
||||
boot2.s sio.o
|
||||
boot2.s sio.o divdi3.o moddi3.o qdivrem.o
|
||||
|
||||
NM?= nm
|
||||
|
||||
@ -27,6 +27,10 @@ BTX= ${.CURDIR}/../btx
|
||||
ORG1= 0x7c00
|
||||
ORG2= 0x1000
|
||||
|
||||
# Setting this to anything else gives UFS1+2 support and larger
|
||||
# boot2 binary.
|
||||
BOOT2_UFS?= UFS1_ONLY
|
||||
|
||||
CFLAGS= -elf -ffreestanding -Os -fno-builtin \
|
||||
-fno-guess-branch-probability \
|
||||
-mrtd \
|
||||
@ -36,7 +40,11 @@ CFLAGS= -elf -ffreestanding -Os -fno-builtin \
|
||||
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
|
||||
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
|
||||
|
||||
CFLAGS+= -DUFS1_ONLY
|
||||
.if ${BOOT2_UFS} == "UFS1_ONLY"
|
||||
CFLAGS+= -D${BOOT2_UFS}
|
||||
.else
|
||||
|
||||
.endif
|
||||
|
||||
LDFLAGS=-nostdlib -static -N
|
||||
|
||||
@ -66,9 +74,15 @@ 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
|
||||
@ -76,9 +90,13 @@ boot2.ldr:
|
||||
boot2.bin: boot2.out
|
||||
objcopy -S -O binary boot2.out ${.TARGET}
|
||||
|
||||
.if ${BOOT2_UFS} == "UFS1_ONLY"
|
||||
boot2.out: boot2.o sio.o
|
||||
.else
|
||||
boot2.out: boot2.o sio.o divdi3.o moddi3.o qdivrem.o
|
||||
.endif
|
||||
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
|
||||
${BTX}/lib/crt0.o boot2.o sio.o
|
||||
${BTX}/lib/crt0.o ${.ALLSRC}
|
||||
|
||||
boot2.o: boot2.h
|
||||
|
||||
@ -88,6 +106,15 @@ sio.o: sio.s
|
||||
--defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \
|
||||
${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
moddi3.o: ${.CURDIR}/../../../libkern/moddi3.c
|
||||
${CC} ${CFLAGS} -I${.CURDIR}/../../../ -c ${.IMPSRC}
|
||||
|
||||
divdi3.o: ${.CURDIR}/../../../libkern/divdi3.c
|
||||
${CC} ${CFLAGS} -I${.CURDIR}/../../../ -c ${.IMPSRC}
|
||||
|
||||
qdivrem.o: ${.CURDIR}/../../../libkern/qdivrem.c
|
||||
${CC} ${CFLAGS} -I${.CURDIR}/../../../ -c ${.IMPSRC}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
|
||||
boot1 ${DESTDIR}${BINDIR}/boot1
|
||||
|
@ -269,7 +269,11 @@ main(void)
|
||||
/* Present the user with the boot2 prompt. */
|
||||
|
||||
for (;;) {
|
||||
printf(" \n>> FreeBSD/i386 BOOT\n"
|
||||
#ifdef UFS1_ONLY
|
||||
printf(" \n>> FreeBSD/i386/UFS1 BOOT\n"
|
||||
#else
|
||||
printf(" \n>> FreeBSD/i386/UFS[12] BOOT\n"
|
||||
#endif
|
||||
"Default: %u:%s(%u,%c)%s\n"
|
||||
"boot: ",
|
||||
dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
|
||||
|
Loading…
Reference in New Issue
Block a user