forked from rivosinc/salus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
129 lines (105 loc) · 3.38 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Path variables:
#
# RV64_PREFIX: Path prefix for riscv64 toolchain. Default: use toolchain in $PATH.
# QEMU: Path to compiled QEMU tree. Default: use QEMU in $PATH.
# LINUX: Path to compiled Linux kernel tree.
# DEBIAN: Path to a pre-baked Debian image.
RV64_PREFIX ?= riscv64-unknown-elf-
OBJCOPY := $(RV64_PREFIX)objcopy
QEMU ?=
ifneq ($(QEMU),)
QEMU_PATH := $(QEMU)/build/riscv64-softmmu/
else
QEMU_PATH :=
endif
QEMU_BIN := $(QEMU_PATH)qemu-system-riscv64
LINUX ?=
LINUX_BIN := $(LINUX)/arch/riscv/boot/Image
DEBIAN ?=
ROOTFS_IMAGE := $(DEBIAN)/image.qcow2
INITRD_IMAGE := $(DEBIAN)/initrd
RELEASE_BINS := target/riscv64gc-unknown-none-elf/release/
DEBUG_BINS := target/riscv64gc-unknown-none-elf/debug/
KERNEL_ADDR := 0xc0200000
INITRD_ADDR := 0xc2200000
BOOTARGS := console=hvc0 earlycon=sbi
# QEMU options:
#
# NCPU: Number of CPUs to boot with. Default: 1
# MEM_SIZE: RAM size for the emulated system. Default: 4GB
# EXTRA_QEMU_ARGS: Any extra flags to pass to QEMU (e.g. other devices).
NCPU ?= 1
MEM_SIZE ?= 4096
EXTRA_QEMU_ARGS ?=
MACH_ARGS := -M virt,aia=aplic-imsic,aia-guests=4 -cpu rv64,x-aia=true
MACH_ARGS += -smp $(NCPU) -m $(MEM_SIZE) -nographic
HOST_TRIPLET := $(shell cargo -Vv | grep '^host:' | awk ' { print $$2; } ')
all: salus tellus guestvm
.PHONY: check
check:
cargo test \
--target $(HOST_TRIPLET) \
--workspace \
--exclude test_workloads \
--lib
.PHONY: salus
salus:
cargo build --release --bin salus
.PHONY: salus_debug
salus_debug:
cargo build --bin salus
tellus_bin: tellus
${OBJCOPY} -O binary $(RELEASE_BINS)tellus tellus_raw
${OBJCOPY} -O binary $(RELEASE_BINS)guestvm guestvm_raw
./create_guest_image.sh tellus_raw guestvm_raw tellus_guestvm
guestvm:
RUSTFLAGS='-Clink-arg=-Tlds/guest.lds' cargo build --package test_workloads --release --bin guestvm
.PHONY: tellus
tellus: guestvm
cargo build --package test_workloads --bin tellus --release
# Runnable targets:
#
# run_tellus_gdb: Run Tellus as the host VM with GDB debugging enabled.
# run_tellus: Run Tellus as the host VM.
# run_linux: Run a bare Linux kernel as the host VM.
# run_debian: Run a Linux kernel as the host VM with a Debian rootfs.
run_tellus_gdb: tellus_bin salus_debug
$(QEMU_BIN) \
-s -S $(MACH_ARGS) \
-kernel $(DEBUG_BINS)salus \
-device guest-loader,kernel=tellus_guestvm,addr=$(KERNEL_ADDR) \
$(EXTRA_QEMU_ARGS)
run_tellus: tellus_bin salus
$(QEMU_BIN) \
$(MACH_ARGS) \
-kernel $(RELEASE_BINS)salus \
-device guest-loader,kernel=tellus_guestvm,addr=$(KERNEL_ADDR) \
$(EXTRA_QEMU_ARGS)
run_linux: salus
$(QEMU_BIN) \
$(MACH_ARGS) \
-kernel $(RELEASE_BINS)salus \
-device guest-loader,kernel=$(LINUX_BIN),addr=$(KERNEL_ADDR) \
-append "$(BOOTARGS)" \
$(EXTRA_QEMU_ARGS)
run_debian: salus
$(QEMU_BIN) \
$(MACH_ARGS) \
-kernel $(RELEASE_BINS)salus \
-device guest-loader,kernel=$(LINUX_BIN),addr=$(KERNEL_ADDR) \
-append "$(BOOTARGS) root=LABEL=rootfs" \
-device guest-loader,initrd=$(INITRD_IMAGE),addr=$(INITRD_ADDR) \
-device x-riscv-iommu-pci \
-drive file=$(ROOTFS_IMAGE),if=none,id=hd \
-device nvme,serial=deadbeef,drive=hd \
-netdev user,id=usernet,hostfwd=tcp:127.0.0.1:7722-0.0.0.0:22 \
-device e1000e,netdev=usernet \
$(EXTRA_QEMU_ARGS)
.PHONY: lint
lint:
cargo clippy -- -D warnings -Wmissing-docs
.PHONY: format
format:
cargo fmt -- --check --config format_code_in_doc_comments=true
.PHONY: ci
ci: salus guestvm tellus lint format check