blob: 9c60dc9d0f8eca7230d573b12713213abdeb8a91 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/usr/bin/env bash
#
# scripts/boot.sh — quick direct boot in QEMU (dev loop)
#
# Builds the kernel, stages the system image, and boots directly as
# BOOTX64.EFI via QEMU's FAT driver. One image = one drive.
#
# Usage:
# ./scripts/boot.sh [--gui] [--debug] [--release] [--mem 512M] [--smp 2]
#
# Boot chain: firmware → rsnix (direct)
# Full chain: use ./scripts/boot-image.sh (firmware → rsboot → rsnix)
#
# Keybindings:
# Ctrl-A X — quit
# Ctrl-A C — QEMU monitor
#
# Environment:
# OVMF path to OVMF firmware (default: /usr/share/edk2/x64/OVMF.4m.fd)
# MEM memory size (default: 256M)
# SMP CPU count (default: 1)
# SYSTEM_IMG system image path (default: /tmp/system.img)
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$PROJECT_DIR"
# ---- config ----
OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}"
MEM="${MEM:-256M}"
SMP="${SMP:-1}"
SYSTEM_IMG="${SYSTEM_IMG:-/tmp/system.img}"
PROFILE="debug"
CARGO_FLAGS=""
GUI=""
DEBUG=""
# ---- args ----
source "$SCRIPT_DIR/lib-boot-args.sh"
handle_arg() {
case "$1" in
--release | -r)
PROFILE="release"
CARGO_FLAGS="--release"
;;
*)
echo "unknown: $1"
exit 1
;;
esac
}
parse_boot_args "$@"
OUT_DIR="target/x86_64-unknown-uefi/$PROFILE"
# ---- build ----
echo "=== Building kernel ($PROFILE) ==="
cargo build --package rsdos --target x86_64-unknown-uefi $CARGO_FLAGS
# ---- stage system image ----
echo "=== Staging system image ==="
"$SCRIPT_DIR/mksystem.sh" --force "$SYSTEM_IMG"
echo " system image: $SYSTEM_IMG"
# ---- boot ----
echo ""
echo "=== Booting (direct: firmware → rsnix) ==="
echo " ovmf: $OVMF"
echo " mem: $MEM smp: $SMP"
echo " gui: $([ -n "$GUI" ] && echo yes || echo no)"
echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)"
echo ""
exec qemu-system-x86_64 \
-bios "$OVMF" \
-drive "file=$SYSTEM_IMG,format=raw,if=none,id=disk" \
-device ide-hd,drive=disk,bus=ide.0 \
-serial stdio \
-m "$MEM" \
-machine q35 \
-cpu qemu64 \
-no-reboot \
-smp "$SMP" \
$GUI $DEBUG
|