-
Notifications
You must be signed in to change notification settings - Fork 1
/
justfile
61 lines (56 loc) · 2.2 KB
/
justfile
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
default: iso
clean:
rm -rf target/x86_64-boss-uefi
rm -rf .build
rm -rf apps/.build
# Base image
bosbaima:
mkdir -p .build/bosbaima
date > .build/bosbaima/date
just apps/ build base
cp apps/.build/base/base.bop .build/bosbaima/
tar cf .build/BOSBAIMA.TAR -C .build/bosbaima base.bop date
profile := "release" # "dev" or "release"
profile_dir := "release" # "debug" or "release"
features := ","
cargo_flags := "--profile " + profile + " --features " + features
magic_section_offset := "0x141000000"
reloc_section_offset := "0x141001000"
# EFI executable
emulator:
cargo build {{cargo_flags}}
cargo clippy {{cargo_flags}}
# magic! (read mem_manager::reloc::relocate_pe for an explanation)
mkdir -p .build
dd if=/dev/random of=.build/rand bs=1 count=1024 2> /dev/null
dd if=/dev/zero of=.build/zero bs=1 count=1 2> /dev/null
cat .build/rand .build/rand > .build/reloc-magic
objdump -hj.data target/x86_64-boss-uefi/{{profile_dir}}/boss.efi | tail -n+6 | head -n1 >> .build/reloc-magic
cat .build/zero >> .build/reloc-magic
objcopy target/x86_64-boss-uefi/{{profile_dir}}/boss.efi \
--add-section .reloc-magic=.build/reloc-magic \
--change-section-address .reloc-magic={{magic_section_offset}} \
--change-section-address .reloc={{reloc_section_offset}} \
.build/BOOTX64.EFI
image_size := "65536" # sectors
image_size_mb := "32"
# Bootable image
iso: emulator bosbaima
dd if=/dev/zero of=.build/boss.iso bs=1M count={{image_size_mb}} 2> /dev/null
mformat -i .build/boss.iso -T {{image_size}}
mmd -i .build/boss.iso ::/EFI
mmd -i .build/boss.iso ::/EFI/BOOT
mmd -i .build/boss.iso ::/BOSS
mcopy -i .build/boss.iso .build/BOOTX64.EFI ::/EFI/BOOT
mcopy -i .build/boss.iso .build/BOSBAIMA.TAR ::/BOSS/BOSBAIMA.TAR
# Boot
qemu: iso
qemu-system-x86_64 -enable-kvm \
-drive if=pflash,format=raw,readonly=on,file=/usr/share/ovmf/x64/OVMF.fd \
-device ahci,id=ahci \
-device ide-hd,drive=disk,bus=ahci.0 \
-drive if=none,id=disk,format=raw,file=.build/boss.iso \
-m 128 \
-smp 1,sockets=1,cores=1,threads=1 \
-boot menu=off,splash-time=0 \
-serial stdio