iso: boot both firmwares, from a disc with a real hierarchy
The disc carried one file -- boot/schos.bin -- with 8.3 uppercase names, one El Torito entry, and no way to boot a UEFI machine. Now: /boot/schos.bin BIOS entry, unchanged: no-emulation, 1+STAGE2_SECTORS /boot/efiboot.img UEFI entry: a FAT image built with mtools /EFI/BOOT/BOOTX64.EFI the loader, also visible as a file /bin /etc /usr ... the staged sysroot as an ordinary tree Rock Ridge and Joliet restore real names, permissions and symlinks; -cache-inodes matters more than it looks, because the sysroot is a toybox multicall binary with a couple of hundred hard links to it and without inode caching each link becomes its own copy. -isohybrid-gpt-basdat adds a GPT so the .iso can be dd'd to a stick and booted by UEFI. That is UEFI only and deliberately so: the BIOS isohybrid trick needs syslinux's isohdpfx.bin, and even with it this loader reads the kernel back over ATAPI, which a stick presented as a hard disk cannot serve. usbstick.img is what that is for. The FAT image carries the kernel as well as the loader, because BOOTX64.EFI opens \schos\kernel on the volume it was loaded from, and for a UEFI boot that is the FAT image rather than the ISO 9660 tree. Without it the loader halted with EFI_NOT_FOUND. Also fixes `make iso` and `make ramroot`, which were already broken: fs-ram.img was still built by the v1 mkfs while the kernel accepts only SchFS as root, so the ramdisk was a format it could not mount and it panicked with "schfs root: no SchFS volume on the root device". It is a mkschfs image now, which needed --exclude in mkschfs -- dropping the exclude list was not an option, because the ramdisk is linked into the kernel binary and what goes in it is a licensing question. RAMDISK_NINODES is gone with the v1 image: SchFS has no preallocated inode table. Verified: BIOS ISO boots to a shell and runs commands over serial (241 files in /bin, /etc/motd reads back). UEFI ISO boots to a prompt. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
e4df779048
commit
61b35a1f71
3 changed files with 188 additions and 14 deletions
27
Makefile
27
Makefile
|
|
@ -291,11 +291,9 @@ CFLAGS_SYS = $(CFLAGS) -I./kernel/sys
|
|||
# -----------------------------------------------------------------------
|
||||
RAMDISK_BLOCKS ?= 6000
|
||||
|
||||
# Inodes for the ramdisk root. The inode table is preallocated, so mkfs's
|
||||
# default of 12000 cost 1501 of those 6000 blocks -- a quarter of the image, to
|
||||
# describe about 260 files. 2000 is still an order of magnitude of headroom and
|
||||
# costs 251 blocks.
|
||||
RAMDISK_NINODES ?= 2000
|
||||
# RAMDISK_NINODES used to live here, sizing mkfs's preallocated inode table.
|
||||
# The ramdisk is a SchFS image now (see $(BUILD)/fs-ram.img) and SchFS allocates
|
||||
# object ids as it goes, so there is no table to size and nothing to tune.
|
||||
|
||||
# Kept out of the ramdisk root.
|
||||
#
|
||||
|
|
@ -444,8 +442,12 @@ iso:
|
|||
rm -rf $(BUILD)/kernel $(BUILD)/lib $(BUILD)/cmd
|
||||
$(MAKE) RAMROOT=1 schos.iso
|
||||
|
||||
schos.iso: $(BUILD)/boot/cdboot $(BUILD)/boot/stage2 $(BUILD)/kernel/kernel
|
||||
STAGE2_SECTORS=$(STAGE2_SECTORS) sh tools/posix/mkiso.sh $@
|
||||
# The UEFI loader is a dependency now: the disc carries a second El Torito
|
||||
# entry pointing at a FAT image that holds it, so one disc boots both firmwares.
|
||||
# sysroot-install because the disc also carries the tree as a real hierarchy.
|
||||
schos.iso: $(BUILD)/boot/cdboot $(BUILD)/boot/stage2 $(BUILD)/kernel/kernel \
|
||||
$(BUILD)/uefi/BOOTX64.EFI sysroot-install
|
||||
STAGE2_SECTORS=$(STAGE2_SECTORS) SYSROOT=$(SYSROOT) sh tools/posix/mkiso.sh $@
|
||||
|
||||
# Boot the ISO the way a machine booting off a disc would: no hard disk at
|
||||
# all, so a kernel that still secretly depends on one fails here rather than
|
||||
|
|
@ -525,10 +527,17 @@ $(BUILD)/kernel/kernel: $(KERNOBJS) $(BUILD)/kernel/initcode_obj $(BUILD)/kernel
|
|||
# The ramdisk root image, and the object wrapping it for the linker. Built from
|
||||
# the same staged sysroot as the main image, just capped at RAMDISK_BLOCKS --
|
||||
# mkfs's content dedup means the whole userland still fits in a few MB.
|
||||
$(BUILD)/fs-ram.img: $(MKFS) $(BUILD)/sysroot.stamp
|
||||
# Built with mkschfs, not mkfs.
|
||||
#
|
||||
# SchFS is the only root the kernel will mount -- it panics in forkret() when
|
||||
# handed anything else -- so a v1 image here produced "schfs root: no SchFS
|
||||
# volume on the root device" and made `make iso` and `make ramroot` unbootable.
|
||||
# RAMDISK_NINODES is gone with it: SchFS has no preallocated inode table, which
|
||||
# is what that knob existed to size.
|
||||
$(BUILD)/fs-ram.img: $(MKSCHFS) $(BUILD)/sysroot.stamp
|
||||
@mkdir -p $(BUILD)
|
||||
@rm -f $@
|
||||
$(MKFS) $@ --size $(RAMDISK_BLOCKS) --ninodes $(RAMDISK_NINODES) \
|
||||
$(MKSCHFS) $@ --size $(RAMDISK_BLOCKS) --label schos \
|
||||
$(RAMDISK_EXCLUDE_ARGS) --sysroot $(SYSROOT)
|
||||
|
||||
$(BUILD)/kernel/ramdisk_obj: $(BUILD)/fs-ram.img
|
||||
|
|
|
|||
Loading…
Reference in a new issue