1c4293333SXiaojuan Yang#
2c4293333SXiaojuan Yang# Loongarch64 system tests
3c4293333SXiaojuan Yang#
4c4293333SXiaojuan Yang
5c4293333SXiaojuan YangLOONGARCH64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/loongarch64/system
6c4293333SXiaojuan YangVPATH+=$(LOONGARCH64_SYSTEM_SRC)
7c4293333SXiaojuan Yang
8c4293333SXiaojuan Yang# These objects provide the basic boot code and helper functions for all tests
9c4293333SXiaojuan YangCRT_OBJS=boot.o
10c4293333SXiaojuan Yang
11c4293333SXiaojuan YangLOONGARCH64_TEST_SRCS=$(wildcard $(LOONGARCH64_SYSTEM_SRC)/*.c)
12c4293333SXiaojuan YangLOONGARCH64_TESTS = $(patsubst $(LOONGARCH64_SYSTEM_SRC)/%.c, %, $(LOONGARCH64_TEST_SRCS))
13c4293333SXiaojuan Yang
14c4293333SXiaojuan YangCRT_PATH=$(LOONGARCH64_SYSTEM_SRC)
15c4293333SXiaojuan YangLINK_SCRIPT=$(LOONGARCH64_SYSTEM_SRC)/kernel.ld
16c4293333SXiaojuan YangLDFLAGS=-Wl,-T$(LINK_SCRIPT)
17c4293333SXiaojuan YangTESTS+=$(LOONGARCH64_TESTS) $(MULTIARCH_TESTS)
18c4293333SXiaojuan YangCFLAGS+=-nostdlib -g -O1 -march=loongarch64 -mabi=lp64d $(MINILIB_INC)
19*4e4b6851SRichard HendersonLDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc -Wl,--no-warn-rwx-segments
20c4293333SXiaojuan Yang
21c4293333SXiaojuan Yang# building head blobs
22c4293333SXiaojuan Yang.PRECIOUS: $(CRT_OBJS)
23c4293333SXiaojuan Yang
24c4293333SXiaojuan Yang%.o: $(CRT_PATH)/%.S
256c180490SRichard Henderson	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -Wa,--noexecstack -c $< -o $@
26c4293333SXiaojuan Yang
27c4293333SXiaojuan Yang# Build and link the tests
28c4293333SXiaojuan Yang%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
29c4293333SXiaojuan Yang	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
30c4293333SXiaojuan Yang
31c4293333SXiaojuan Yangmemory: CFLAGS+=-DCHECK_UNALIGNED=0
32c4293333SXiaojuan Yang# Running
33c4293333SXiaojuan YangQEMU_OPTS+=-serial chardev:output -kernel
34