-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
104 lines (74 loc) · 2.13 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
#
# Copyright 2023, Colias Group, LLC
#
# SPDX-License-Identifier: BSD-2-Clause
#
BUILD ?= build
BOARD ?= qemu_virt_aarch64
build_dir := $(BUILD)/$(BOARD)
.PHONY: none
none:
.PHONY: clean
clean:
rm -rf $(BUILD)
$(build_dir):
mkdir -p $@
microkit_board := $(BOARD)
microkit_config := debug
microkit_sdk_config_dir := $(MICROKIT_SDK)/board/$(microkit_board)/$(microkit_config)
sel4_include_dirs := $(microkit_sdk_config_dir)/include
### Protection domains
crate = $(build_dir)/$(1).elf
define build_crate
$(crate): $(crate).intermediate
.INTERMDIATE: $(crate).intermediate
$(crate).intermediate:
SEL4_INCLUDE_DIRS=$(abspath $(sel4_include_dirs)) \
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-microkit-minimal \
--release \
-p $(1) \
$(extra-flags-$(1))
endef
crate_names := \
banscii-artist \
banscii-assistant \
banscii-serial-driver
extra-flags-banscii-serial-driver := --features board-$(microkit_board)
crates := $(foreach crate_name,$(crate_names),$(call crate,$(crate_name)))
$(eval $(foreach crate_name,$(crate_names),$(call build_crate,$(crate_name))))
### Loader
system_description_template := banscii.system.template
system_description := $(build_dir)/banscii.system
$(system_description): generate_system_description.py $(system_description_template) | $(build_dir)
python3 $< --template $(system_description_template) --board $(BOARD) -o $@
loader := $(build_dir)/loader.img
$(loader): $(system_description) $(crates)
$(MICROKIT_SDK)/bin/microkit \
$< \
--search-path $(build_dir) \
--board $(microkit_board) \
--config $(microkit_config) \
-r $(build_dir)/report.txt \
-o $@
.PHONY: build
build: $(loader)
### Run
ifeq ($(BOARD),qemu_virt_aarch64)
qemu_cmd := \
qemu-system-aarch64 \
-machine virt,virtualization=on -cpu cortex-a53 -m size=2G \
-serial mon:stdio \
-nographic \
-device loader,file=$(loader),addr=0x70000000,cpu-num=0
.PHONY: run
run: $(loader)
$(qemu_cmd)
.PHONY: test
test: test.py $(loader)
python3 $< $(qemu_cmd)
endif