forked from seL4/rust-root-task-demo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
108 lines (93 loc) · 3.08 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
#
# Copyright 2023, Colias Group, LLC
#
# SPDX-License-Identifier: BSD-2-Clause
#
BUILD ?= build
OS := sel4
build_dir := $(BUILD)
.PHONY: none
none:
.PHONY: clean
clean:
rm -rf $(build_dir)
sel4_prefix := $(SEL4_INSTALL_DIR)
ifeq ($(OS), rel4)
export sel4_prefix = /opt/reL4
endif
# Kernel loader binary artifacts provided by Docker container:
# - `sel4-kernel-loader`: The loader binary, which expects to have a payload appended later via
# binary patch.
# - `sel4-kernel-loader-add-payload`: CLI which appends a payload to the loader.
loader_artifacts_dir := $(sel4_prefix)/bin
loader := $(loader_artifacts_dir)/sel4-kernel-loader
loader_cli := $(loader_artifacts_dir)/sel4-kernel-loader-add-payload
app_crate := example
app := $(build_dir)/$(app_crate).elf
$(app): $(app).intermediate
# SEL4_TARGET_PREFIX is used by build.rs scripts of various rust-sel4 crates to locate seL4
# configuration and libsel4 headers.
.INTERMDIATE: $(app).intermediate
# $(app).intermediate:
# SEL4_PREFIX=$(sel4_prefix) \
# cargo build \
# -Z build-std=core,alloc,compiler_builtins \
# -Z build-std-features=compiler-builtins-mem \
# --target-dir $(build_dir)/target \
# --out-dir $(build_dir) \
# --target aarch64-sel4 \
# -p $(app_crate)
$(app).intermediate:
SEL4_PREFIX=/opt/seL4 \
cargo build \
-Z build-std=core,alloc,compiler_builtins \
-Z build-std-features=compiler-builtins-mem \
--target-dir $(build_dir)/target \
--out-dir $(build_dir) \
--target riscv64imac-sel4 \
-p $(app_crate)
image := $(build_dir)/image.elf
# Append the payload to the loader using the loader CLI
$(image): $(app) $(loader) $(loader_cli)
$(loader_cli) \
--loader $(loader) \
--sel4-prefix $(sel4_prefix) \
--app $(app) \
-o $@
# qemu_cmd := \
# qemu-system-aarch64 \
# -machine virt,virtualization=on -cpu cortex-a57 -m size=1G \
# -serial mon:stdio \
# -nographic \
# -kernel $(image)
qemu_cmd := \
qemu-system-riscv64 \
-machine virt -m size=4G \
-serial mon:stdio \
-nographic \
-kernel $(image) \
-D qemu.log -d in_asm,int,pcall,cpu_reset,guest_errors
.PHONY: run
run: $(image)
$(qemu_cmd)
.PHONY: test
test: test.py $(image)
python3 $< $(qemu_cmd)
install:
cd kernel/rel4_kernel && make run
cd kernel/seL4_c_impl && cmake \
-DCROSS_COMPILER_PREFIX=riscv64-linux-gnu- \
-DCMAKE_INSTALL_PREFIX=/opt/reL4 \
-DKernelPlatform=spike \
-C ../kernel-settings.cmake \
-G Ninja \
-S . \
-B build && \
ninja -C build clean && ninja -C build all && sudo ninja -C build install
# sudo cp /opt/reL4/libsel4/include/interfaces/sel4-arch.xml /opt/reL4/libsel4/include/interfaces/object-api-arch.xml
# sudo cp /opt/reL4/libsel4/include/interfaces/sel4.xml /opt/reL4/libsel4/include/interfaces/object-api.xml
# sudo cp /opt/reL4/libsel4/include/interfaces/sel4-sel4arch.xml /opt/reL4/libsel4/include/interfaces/object-api-sel4-arch.xml
sudo cp /opt/seL4/libsel4/include/interfaces/*.xml /opt/reL4/libsel4/include/interfaces/
sudo cp /opt/seL4/bin/sel4-kernel-loader /opt/reL4/bin/
sudo cp /opt/seL4/bin/sel4-kernel-loader-add-payload /opt/reL4/bin/
.PHONY: install