1#
2# Aarch64 system tests
3#
4
5AARCH64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/aarch64/system
6VPATH+=$(AARCH64_SYSTEM_SRC)
7
8# These objects provide the basic boot code and helper functions for all tests
9CRT_OBJS=boot.o
10
11AARCH64_TEST_SRCS=$(wildcard $(AARCH64_SYSTEM_SRC)/*.c)
12AARCH64_TESTS = $(patsubst $(AARCH64_SYSTEM_SRC)/%.c, %, $(AARCH64_TEST_SRCS))
13
14CRT_PATH=$(AARCH64_SYSTEM_SRC)
15LINK_SCRIPT=$(AARCH64_SYSTEM_SRC)/kernel.ld
16LDFLAGS=-Wl,-T$(LINK_SCRIPT)
17TESTS+=$(AARCH64_TESTS) $(MULTIARCH_TESTS)
18EXTRA_RUNS+=$(MULTIARCH_RUNS)
19CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
20LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
21
22config-cc.mak: Makefile
23	$(quiet-@)( \
24	    $(call cc-option,-march=armv8.3-a, CROSS_CC_HAS_ARMV8_3)) 3> config-cc.mak
25-include config-cc.mak
26
27# building head blobs
28.PRECIOUS: $(CRT_OBJS)
29
30%.o: $(CRT_PATH)/%.S
31	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -c $< -o $@
32
33# Build and link the tests
34%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
35	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
36
37memory: CFLAGS+=-DCHECK_UNALIGNED=1
38
39memory-sve: memory.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
40	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
41
42memory-sve: CFLAGS+=-DCHECK_UNALIGNED=1 -march=armv8.1-a+sve -O3
43
44TESTS+=memory-sve
45
46# Running
47QEMU_BASE_MACHINE=-M virt -cpu max -display none
48QEMU_BASE_ARGS=-semihosting-config enable=on,target=native,chardev=output
49QEMU_OPTS+=$(QEMU_BASE_MACHINE) $(QEMU_BASE_ARGS) -kernel
50
51# console test is manual only
52QEMU_SEMIHOST=-serial none -chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -mon chardev=stdio0,mode=readline
53run-semiconsole: QEMU_OPTS=$(QEMU_BASE_MACHINE) $(QEMU_SEMIHOST) -kernel
54run-semiconsole: semiconsole
55	$(call skip-test, $<, "MANUAL ONLY")
56	$(if $(V),@printf "  %-7s %s %s\n" "TO RUN" $(notdir $(QEMU)) "$(QEMU_OPTS) $<")
57run-plugin-semiconsole-with-%: semiconsole
58	$(call skip-test, $<, "MANUAL ONLY")
59
60# vtimer test needs EL2
61QEMU_EL2_MACHINE=-machine virt,virtualization=on,gic-version=2 -cpu cortex-a57 -smp 4
62run-vtimer: QEMU_OPTS=$(QEMU_EL2_MACHINE) $(QEMU_BASE_ARGS) -kernel
63
64# Simple Record/Replay Test
65.PHONY: memory-record
66run-memory-record: memory-record memory
67	$(call run-test, $<, \
68	  $(QEMU) -monitor none -display none \
69		  -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
70		  -icount shift=5$(COMMA)rr=record$(COMMA)rrfile=record.bin \
71		  $(QEMU_OPTS) memory)
72
73.PHONY: memory-replay
74run-memory-replay: memory-replay run-memory-record
75	$(call run-test, $<, \
76	  $(QEMU) -monitor none -display none \
77		  -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
78		  -icount shift=5$(COMMA)rr=replay$(COMMA)rrfile=record.bin \
79		  $(QEMU_OPTS) memory)
80
81EXTRA_RUNS+=run-memory-replay
82
83ifneq ($(CROSS_CC_HAS_ARMV8_3),)
84pauth-3: CFLAGS += $(CROSS_CC_HAS_ARMV8_3)
85else
86pauth-3:
87	$(call skip-test, "BUILD of $@", "missing compiler support")
88run-pauth-3:
89	$(call skip-test, "RUN of pauth-3", "not built")
90endif
91