boot6.sh (3117B)
1 #!/bin/sh 2 ## boot6.sh — build the seed-kernel ELF/Image with boot4's tcc3. 3 ## 4 ## Drives tcc3 to compile + link the seed kernel directly: no `ld -T 5 ## kernel.lds`, no objcopy. aarch64 emits the flat Image QEMU expects; 6 ## amd64/riscv64 emit the ELF consumed by QEMU's -kernel path. 7 ## 8 ## ─── Inputs (sources, from canonical tree) ─────────────────────────── 9 ## build/$ARCH/src/src/kernel/arch/$ARCH/{kernel.S, mmu.c, arch.h} 10 ## build/$ARCH/src/src/kernel/kernel.c 11 ## build/$ARCH/src/src/tcc-cc/mem.c 12 ## 13 ## ─── Inputs (binaries from prior stages) ────────────────────────────── 14 ## build/$ARCH/$DRIVER/boot4/tcc3 15 ## build/$ARCH/$DRIVER/boot2/scheme1 16 ## 17 ## ─── Tools ──────────────────────────────────────────────────────────── 18 ## scheme1 evaluates a host-generated run.scm (from boot6-gen-runscm.sh) 19 ## against the flat staging root. 20 ## 21 ## ─── Outputs ───────────────────────────────────────────────────────── 22 ## build/$ARCH/$DRIVER/boot6/$KERNEL_NAME 23 ## aarch64: Image — flat boot Image, byte-format identical to the gcc 24 ## Makefile's `objcopy -O binary` output. QEMU's `-kernel` 25 ## detects `ARM\x64` magic at file offset 0x38 and follows 26 ## the arm64 boot protocol, putting DTB phys in x0 before 27 ## jumping to _start. 28 ## amd64/riscv64: kernel.elf — ELF consumed via QEMU's -kernel path. 29 ## 30 ## Usage: scripts/boot6.sh <arch> 31 ## <arch> ∈ {aarch64, amd64, riscv64} for either DRIVER (default podman). 32 33 set -eu 34 35 . scripts/lib-arch.sh 36 bootlib_init boot6 "${1:-}" 37 driver_init empty 38 require_src 39 40 BOOT2=build/$ARCH/$DRIVER/boot2 41 BOOT4=build/$ARCH/$DRIVER/boot4 42 SRC=build/$ARCH/src 43 44 # ── prerequisites ───────────────────────────────────────────────────── 45 require_prev "$BOOT4" tcc3 46 require_prev "$BOOT2" scheme1 47 for f in kernel/arch/$ARCH/kernel.S kernel/arch/$ARCH/mmu.c kernel/arch/$ARCH/arch.h kernel/kernel.c tcc-cc/mem.c; do 48 require_file "$SRC/src/$f" 49 done 50 51 # ── stage inputs and run scheme1 + run.scm under $DRIVER ────────────── 52 . scripts/lib-runscm.sh 53 runscm_init "$STAGE" "$OUT" 54 runscm_gen scripts/boot6-gen-runscm.sh "$ARCH" 55 56 runscm_scheme1 "$BOOT2/scheme1" 57 runscm_prelude "$SRC/src/scheme1/prelude.scm" 58 59 runscm_input tcc3 "$BOOT4/tcc3" 60 runscm_input_from_src "kernel/arch/$ARCH/kernel.S" 61 runscm_input_from_src kernel/kernel.c 62 runscm_input_from_src "kernel/arch/$ARCH/arch.h" 63 runscm_input_from_src "kernel/arch/$ARCH/mmu.c" 64 runscm_input_from_src tcc-cc/mem.c 65 66 runscm_export "$KERNEL_NAME" 67 runscm_run "${BOOT6_TIMEOUT:-1200}" 68 69 echo "[$BOOT_TAG] OK -> $OUT/$KERNEL_NAME ($(wc -c <"$OUT/$KERNEL_NAME") bytes)"