-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (52 loc) · 1.75 KB
/
Makefile
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
MODE?=debug
rustc_target:=aarch64-unknown-none
toolchain_prefix:=aarch64-none-elf
target_dir:=target/$(rustc_target)/$(MODE)
target_name:=rust-bao
bao_elf:=$(target_dir)/$(target_name)
bao_bin:=$(target_dir)/$(target_name).bin
bao_disasm:=$(target_dir)/$(target_name).asm
bao_elf_txt:=$(target_dir)/$(target_name).elf.txt
imgs_dir:=imgs
atf-fip:=$(imgs_dir)/flash.bin
OBJCOPY := rust-objcopy --binary-architecture=aarch64
qemu_cmd:=qemu-system-aarch64
qemu_flags:=-nographic\
-M virt,secure=on,virtualization=on,gic-version=3 \
-cpu cortex-a53 -smp 4 -m 4G\
-bios $(atf-fip)\
-device loader,file="$(bao_bin)",addr=0x50000000,force-raw=on\
-device virtio-net-device,netdev=net0\
-netdev user,id=net0,net=192.168.42.0/24,hostfwd=tcp:127.0.0.1:5555-:22\
-device virtio-serial-device -chardev pty,id=serial3 -device virtconsole,chardev=serial3
ifeq ($(MODE), release)
BUILD_CFG := --release
else
BUILD_CFG :=
endif
build: env
cargo build $(BUILD_CFG) && make dump
dump:
$(toolchain_prefix)-objdump -lS $(bao_elf) > $(bao_disasm)
$(toolchain_prefix)-readelf -a $(bao_elf) > $(bao_elf_txt)
run: $(bao_bin)
@$(qemu_cmd) $(qemu_flags)
gdb: $(bao_bin)
@$(qemu_cmd) $(qemu_flags) -s -S
monitor:
@gdb-multiarch -ex 'target remote localhost:1234' \
-ex 'file $(bao_elf)'
env:
rustup target add $(rustc_target)
rustup component add llvm-tools-preview
clean:
cargo clean
show-features:
rustc --print=target-features --target=$(rustc_target)
guest:
make -C lloader linux_image_path=../imgs/qemu-aarch64-virt/Image\
linux_dts_path=../dts/qemu-aarch64-virt/linux.dts\
output_path=../imgs/qemu-aarch64-virt/linux.bin
$(bao_bin): guest build
@$(OBJCOPY) $(bao_elf) --strip-all -O binary $@
.PHONY: env build run gdb monitor clean dump show-features