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
22# building head blobs
23.PRECIOUS: $(CRT_OBJS)
24
25%.o: $(CRT_PATH)/%.S
26	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -c $< -o $@
27
28# Build and link the tests
29%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
30	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
31
32memory: CFLAGS+=-DCHECK_UNALIGNED=1
33
34# Running
35QEMU_BASE_MACHINE=-M virt -cpu max -display none
36QEMU_OPTS+=$(QEMU_BASE_MACHINE) -semihosting-config enable=on,target=native,chardev=output -kernel
37
38# console test is manual only
39QEMU_SEMIHOST=-chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -mon chardev=stdio0,mode=readline
40run-semiconsole: QEMU_OPTS=$(QEMU_BASE_MACHINE) $(QEMU_SEMIHOST)  -kernel
41run-semiconsole: semiconsole
42	$(call skip-test, $<, "MANUAL ONLY")
43run-plugin-semiconsole-with-%: semiconsole
44	$(call skip-test, $<, "MANUAL ONLY")
45
46# Simple Record/Replay Test
47.PHONY: memory-record
48run-memory-record: memory-record memory
49	$(call run-test, $<, \
50	  $(QEMU) -monitor none -display none \
51		  -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
52		  -icount shift=5$(COMMA)rr=record$(COMMA)rrfile=record.bin \
53	   	  $(QEMU_OPTS) memory, \
54	  "$< on $(TARGET_NAME)")
55
56.PHONY: memory-replay
57run-memory-replay: memory-replay run-memory-record
58	$(call run-test, $<, \
59	  $(QEMU) -monitor none -display none \
60		  -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
61		  -icount shift=5$(COMMA)rr=replay$(COMMA)rrfile=record.bin \
62	   	  $(QEMU_OPTS) memory, \
63	  "$< on $(TARGET_NAME)")
64
65EXTRA_RUNS+=run-memory-replay
66
67ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_3),)
68pauth-3: CFLAGS += -march=armv8.3-a
69else
70pauth-3:
71	$(call skip-test, "BUILD of $@", "missing compiler support")
72run-pauth-3:
73	$(call skip-test, "RUN of pauth-3", "not built")
74run-plugin-pauth-3-with-%:
75	$(call skip-test, "RUN of pauth-3 ($*)", "not built")
76endif
77