boot: separate BIOS from UEFI
boot/bios/ now holds the MBR, the El Torito stub and the real-mode stage 2; boot/uefi/ is empty and documented. Separate directories rather than #ifdefs, because the two share almost nothing. A BIOS loader lives in 16-bit real mode, reaches the firmware through software interrupts, and walks itself up into long mode. A UEFI loader is a 64-bit PE that the firmware has already placed in long mode with paging on, calling services through a table of function pointers. What they do share is the hand-off contract, which boot/README.md now writes down: ELF segments placed, long mode, a 24-byte-entry memory map at E820_MAP_ADDR, framebuffer geometry at VBE_INFO_ADDR. That contract is the point of documenting it now. UEFI's GetMemoryMap returns EFI_MEMORY_DESCRIPTORs, and the right move is to translate them into the entries kernel/arch/x86_64/e820.c already parses rather than teach the kernel a second format. Build output paths under $(BUILD)/boot are unchanged; only sources moved.
This commit is contained in:
parent
8a4ac03ea9
commit
08a1a9033a
19 changed files with 125 additions and 33 deletions
22
Makefile
22
Makefile
|
|
@ -383,10 +383,10 @@ qemu-iso: schos.iso
|
|||
# splash, and loads the kernel — not size-constrained the same way, just
|
||||
# padded out to a fixed STAGE2_SECTORS*512 bytes so the kernel's starting
|
||||
# sector on disk is predictable (kept in sync with STAGE2_SECTORS in
|
||||
# boot/bootasm.S and boot/stage2main.c).
|
||||
# boot/bios/bootasm.S and boot/bios/stage2main.c).
|
||||
# -----------------------------------------------------------------------
|
||||
# STAGE2_SECTORS used to be written out three times -- here, in boot/bootasm.S
|
||||
# and in boot/stage2main.c -- and docs/layout.md carried a warning about keeping
|
||||
# STAGE2_SECTORS used to be written out three times -- here, in boot/bios/bootasm.S
|
||||
# and in boot/bios/stage2main.c -- and docs/layout.md carried a warning about keeping
|
||||
# them in step. They are now all fed from this one variable via -D, so the
|
||||
# warning describes a problem that can no longer happen. Both C/asm files keep
|
||||
# an #ifndef fallback purely so they still read sensibly on their own.
|
||||
|
|
@ -405,9 +405,9 @@ STAGE2_DEF = -DSTAGE2_SECTORS=$(STAGE2_SECTORS)
|
|||
# that make carried on and padstage2.pl received nonsense.
|
||||
STAGE2_BYTES = $$(( $(STAGE2_SECTORS) * 512 ))
|
||||
|
||||
$(BUILD)/boot/bootblock: boot/bootasm.S
|
||||
$(BUILD)/boot/bootblock: boot/bios/bootasm.S
|
||||
@mkdir -p $(BUILD)/boot
|
||||
$(CC32) $(STAGE2_DEF) -fno-builtin -fno-pic -nostdinc -I./include -c boot/bootasm.S -o $(BUILD)/boot/bootasm.o
|
||||
$(CC32) $(STAGE2_DEF) -fno-builtin -fno-pic -nostdinc -I./include -c boot/bios/bootasm.S -o $(BUILD)/boot/bootasm.o
|
||||
$(LD) -m elf_i386 -nostdlib $(LD_LOWBASE) -n -N -e start -Ttext 0x7C00 \
|
||||
-o $(BUILD)/boot/bootblocktmp.o $(BUILD)/boot/bootasm.o
|
||||
$(OBJCOPY) -S -O binary -j .text $(BUILD)/boot/bootblocktmp.o $(BUILD)/boot/bootblock
|
||||
|
|
@ -415,19 +415,19 @@ $(BUILD)/boot/bootblock: boot/bootasm.S
|
|||
|
||||
# Stage 1 for optical media. Same job as bootblock, far less of it: El Torito
|
||||
# has already loaded stage2 alongside this sector by the time it runs, so it
|
||||
# only records that we came from a CD and jumps. See boot/cdboot.S.
|
||||
$(BUILD)/boot/cdboot: boot/cdboot.S
|
||||
# only records that we came from a CD and jumps. See boot/bios/cdboot.S.
|
||||
$(BUILD)/boot/cdboot: boot/bios/cdboot.S
|
||||
@mkdir -p $(BUILD)/boot
|
||||
$(CC32) -fno-builtin -fno-pic -nostdinc -I./include -c boot/cdboot.S -o $(BUILD)/boot/cdbootasm.o
|
||||
$(CC32) -fno-builtin -fno-pic -nostdinc -I./include -c boot/bios/cdboot.S -o $(BUILD)/boot/cdbootasm.o
|
||||
$(LD) -m elf_i386 -nostdlib $(LD_LOWBASE) -n -N -e start -Ttext 0x7C00 \
|
||||
-o $(BUILD)/boot/cdboottmp.o $(BUILD)/boot/cdbootasm.o
|
||||
$(OBJCOPY) -S -O binary -j .text $(BUILD)/boot/cdboottmp.o $@
|
||||
./tools/sign.pl $@
|
||||
|
||||
$(BUILD)/boot/stage2: boot/stage2.S boot/stage2main.c include/logo.h
|
||||
$(BUILD)/boot/stage2: boot/bios/stage2.S boot/bios/stage2main.c include/logo.h
|
||||
@mkdir -p $(BUILD)/boot
|
||||
$(CC32) $(STAGE2_DEF) -fno-builtin -fno-pic -nostdinc -I./include -c boot/stage2.S -o $(BUILD)/boot/stage2asm.o
|
||||
$(CC32) $(STAGE2_DEF) -fno-builtin -fno-pic -O -nostdinc -I./include -c boot/stage2main.c -o $(BUILD)/boot/stage2main.o
|
||||
$(CC32) $(STAGE2_DEF) -fno-builtin -fno-pic -nostdinc -I./include -c boot/bios/stage2.S -o $(BUILD)/boot/stage2asm.o
|
||||
$(CC32) $(STAGE2_DEF) -fno-builtin -fno-pic -O -nostdinc -I./include -c boot/bios/stage2main.c -o $(BUILD)/boot/stage2main.o
|
||||
$(LD) -m elf_i386 -nostdlib $(LD_LOWBASE) -n -N -e stage2start -Ttext 0x7E00 \
|
||||
-o $(BUILD)/boot/stage2tmp.o $(BUILD)/boot/stage2asm.o $(BUILD)/boot/stage2main.o
|
||||
$(OBJCOPY) -S -O binary -j .text -j .rodata -j .data $(BUILD)/boot/stage2tmp.o $(BUILD)/boot/stage2
|
||||
|
|
|
|||
Loading…
Reference in a new issue