mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 23:28:57 +00:00
Add in a hack to support IBM "El Torito" CD-ROM booting BIOS's which expect
the first sector of the emulated floppy to contain a valid MS-DOS BPB that it can modify. Since boot1 is the first sector of boot.flp, this resulted in the BIOS overwriting part of boot1: specifically the function used to read in sectors from the disk. Submitted by: Mark Peek <mark@whistle.com> Submitted by: Doug Ambrisko <ambrisko@ambrisko.com> PR: i386/26382 Obtained from: NetBSD, OpenBSD (the example BPB) MFC after: 1 month
This commit is contained in:
parent
a079a625af
commit
b0606ca15f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=80751
@ -6,9 +6,11 @@ STRIP=
|
||||
BINDIR?= /boot
|
||||
BINMODE= 444
|
||||
CLEANFILES+= boot1 boot1.out boot1.o \
|
||||
boot2.ldr boot2.bin boot2.ld boot2.out boot2.o \
|
||||
boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \
|
||||
sio.o
|
||||
|
||||
NM?= nm
|
||||
|
||||
# A value of 0x80 enables LBA support.
|
||||
B1FLAGS= 0x80
|
||||
|
||||
@ -46,6 +48,11 @@ boot1.out: boot1.o
|
||||
boot1.o: boot1.s
|
||||
${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} ${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
boot2.h: boot1.out
|
||||
${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
|
||||
{ x = $$1 - ORG1; printf("#define XREADORG 0x7%x\n", x) }' \
|
||||
ORG1=`printf "%d" ${ORG1}` > boot2.h
|
||||
|
||||
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
|
||||
@ -63,6 +70,8 @@ boot2.out: boot2.o sio.o
|
||||
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
|
||||
${BTX}/lib/crt0.o boot2.o sio.o
|
||||
|
||||
boot2.o: boot2.h
|
||||
|
||||
sio.o: sio.s
|
||||
${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \
|
||||
--defsym SIOFMT=${B2SIOFMT} \
|
||||
|
@ -43,7 +43,40 @@
|
||||
|
||||
start: jmp main # Start recognizably
|
||||
|
||||
.org 0x4,0x90
|
||||
# This is the start of a standard BIOS Parameter Block (BPB). Most bootable
|
||||
# FAT disks have this at the start of their MBR. While normal BIOS's will
|
||||
# work fine without this section, IBM's El Torito emulation "fixes" up the
|
||||
# BPB by writing into the memory copy of the MBR. Rather than have data
|
||||
# written into our xread routine, we'll define a BPB to work around it.
|
||||
# The data marked with (T) indicates a field required for a ThinkPad to
|
||||
# recognize the disk and (W) indicates fields written from IBM BIOS code.
|
||||
# The use of the BPB is based on what OpenBSD and NetBSD implemented in
|
||||
# their boot code but the required fields were determined by trial and error.
|
||||
#
|
||||
# Note: If additional space is needed in boot1, one solution would be to
|
||||
# move the "prompt" message data (below) to replace the OEM ID.
|
||||
|
||||
.org 0x03, 0x00
|
||||
oemid: .space 0x08, 0x00 # OEM ID
|
||||
|
||||
.org 0x0b, 0x00
|
||||
bpb: .word 512 # sector size (T)
|
||||
.byte 0 # sectors/clustor
|
||||
.word 0 # reserved sectors
|
||||
.byte 0 # number of FATs
|
||||
.word 0 # root entries
|
||||
.word 0 # small sectors
|
||||
.byte 0 # media type (W)
|
||||
.word 0 # sectors/fat
|
||||
.word 18 # sectors per track (T)
|
||||
.word 2 # number of heads (T)
|
||||
.long 0 # hidden sectors (W)
|
||||
.long 0 # large sectors
|
||||
|
||||
.org 0x24, 0x00
|
||||
ebpb: .byte 0 # BIOS physical drive number (W)
|
||||
|
||||
.org 0x25,0x90
|
||||
#
|
||||
# Trampoline used by boot2 to call read to read data from the disk via
|
||||
# the BIOS. Call with:
|
||||
|
@ -43,7 +43,40 @@
|
||||
|
||||
start: jmp main # Start recognizably
|
||||
|
||||
.org 0x4,0x90
|
||||
# This is the start of a standard BIOS Parameter Block (BPB). Most bootable
|
||||
# FAT disks have this at the start of their MBR. While normal BIOS's will
|
||||
# work fine without this section, IBM's El Torito emulation "fixes" up the
|
||||
# BPB by writing into the memory copy of the MBR. Rather than have data
|
||||
# written into our xread routine, we'll define a BPB to work around it.
|
||||
# The data marked with (T) indicates a field required for a ThinkPad to
|
||||
# recognize the disk and (W) indicates fields written from IBM BIOS code.
|
||||
# The use of the BPB is based on what OpenBSD and NetBSD implemented in
|
||||
# their boot code but the required fields were determined by trial and error.
|
||||
#
|
||||
# Note: If additional space is needed in boot1, one solution would be to
|
||||
# move the "prompt" message data (below) to replace the OEM ID.
|
||||
|
||||
.org 0x03, 0x00
|
||||
oemid: .space 0x08, 0x00 # OEM ID
|
||||
|
||||
.org 0x0b, 0x00
|
||||
bpb: .word 512 # sector size (T)
|
||||
.byte 0 # sectors/clustor
|
||||
.word 0 # reserved sectors
|
||||
.byte 0 # number of FATs
|
||||
.word 0 # root entries
|
||||
.word 0 # small sectors
|
||||
.byte 0 # media type (W)
|
||||
.word 0 # sectors/fat
|
||||
.word 18 # sectors per track (T)
|
||||
.word 2 # number of heads (T)
|
||||
.long 0 # hidden sectors (W)
|
||||
.long 0 # large sectors
|
||||
|
||||
.org 0x24, 0x00
|
||||
ebpb: .byte 0 # BIOS physical drive number (W)
|
||||
|
||||
.org 0x25,0x90
|
||||
#
|
||||
# Trampoline used by boot2 to call read to read data from the disk via
|
||||
# the BIOS. Call with:
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include <btxv86.h>
|
||||
|
||||
#include "boot2.h"
|
||||
#include "lib.h"
|
||||
|
||||
#define RBX_ASKNAME 0x0 /* -a */
|
||||
@ -739,7 +740,7 @@ drvread(void *buf, unsigned lba, unsigned nblk)
|
||||
|
||||
printf("%c\b", c = c << 8 | c >> 24);
|
||||
v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
|
||||
v86.addr = 0x704; /* call to xread in boot1 */
|
||||
v86.addr = XREADORG; /* call to xread in boot1 */
|
||||
v86.es = VTOPSEG(buf);
|
||||
v86.eax = lba;
|
||||
v86.ebx = VTOPOFF(buf);
|
||||
|
@ -6,9 +6,11 @@ STRIP=
|
||||
BINDIR?= /boot
|
||||
BINMODE= 444
|
||||
CLEANFILES+= boot1 boot1.out boot1.o \
|
||||
boot2.ldr boot2.bin boot2.ld boot2.out boot2.o \
|
||||
boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \
|
||||
sio.o
|
||||
|
||||
NM?= nm
|
||||
|
||||
# A value of 0x80 enables LBA support.
|
||||
B1FLAGS= 0x80
|
||||
|
||||
@ -46,6 +48,11 @@ boot1.out: boot1.o
|
||||
boot1.o: boot1.s
|
||||
${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} ${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
boot2.h: boot1.out
|
||||
${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
|
||||
{ x = $$1 - ORG1; printf("#define XREADORG 0x7%x\n", x) }' \
|
||||
ORG1=`printf "%d" ${ORG1}` > boot2.h
|
||||
|
||||
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
|
||||
@ -63,6 +70,8 @@ boot2.out: boot2.o sio.o
|
||||
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
|
||||
${BTX}/lib/crt0.o boot2.o sio.o
|
||||
|
||||
boot2.o: boot2.h
|
||||
|
||||
sio.o: sio.s
|
||||
${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \
|
||||
--defsym SIOFMT=${B2SIOFMT} \
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include <btxv86.h>
|
||||
|
||||
#include "boot2.h"
|
||||
#include "lib.h"
|
||||
|
||||
#define RBX_ASKNAME 0x0 /* -a */
|
||||
@ -739,7 +740,7 @@ drvread(void *buf, unsigned lba, unsigned nblk)
|
||||
|
||||
printf("%c\b", c = c << 8 | c >> 24);
|
||||
v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
|
||||
v86.addr = 0x704; /* call to xread in boot1 */
|
||||
v86.addr = XREADORG; /* call to xread in boot1 */
|
||||
v86.es = VTOPSEG(buf);
|
||||
v86.eax = lba;
|
||||
v86.ebx = VTOPOFF(buf);
|
||||
|
Loading…
Reference in New Issue
Block a user