-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.mk
134 lines (96 loc) · 3.19 KB
/
config.mk
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
include $(CROOT)/cc_config.mk
ARMV_MAJOR = 8
ARMV_MINOR = 0
ARM_PROFILE = a
ifeq ($(ARMV_MINOR),0)
MARCH=armv$(ARMV_MAJOR)-$(ARM_PROFILE)
else
MARCH=armv$(ARMV_MAJOR).$(ARMV_MINOR)-$(ARM_PROFILE)
endif
UPROG = test
TARGET = aarch64-none-elf
CROSS_COMPILE = $(TARGET)-
NEWLIBLOC ?= /opt/cross/${TARGET}/lib
CC = $(CROSS_COMPILE)gcc
AS = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
AR = $(CROSS_COMPILE)ar
STRIP = $(CROSS_COMPILE)strip
SH_FLAGS += -march=$(MARCH)+fp+simd+nosve
SH_FLAGS += -DARMV_MAJOR=$(ARMV_MAJOR)
SH_FLAGS += -DARMV_MINOR=$(ARMV_MINOR)
SH_FLAGS += -DARM_PROFILE=$(ARM_PROFILE)
SH_FLAGS += -include config.h
# float-cast-overflow, pointer-overflow
#UBSAN_SAN = alignment,bool,builtin,bounds,enum,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound
CFLAGS += -I$(CROOT)/src/include -I$(CROOT)/src/arch/$(ARCH)
CFLAGS += -MMD
# TODO: Should fix the remaining warnings
CFLAGS += -Wall -Wextra -Werror -Wno-unused-function -Wno-unused-parameter -Wno-unused-but-set-variable
ifdef DEBUG_BUILD
CFLAGS += -g
CFLAGS += -O1
else
CFLAGS += -O2
endif
ifdef CONFIG_UBSAN
include $(CROOT)/ubsan.mk
endif
ifdef CONFIG_KASAN
include $(CROOT)/kasan.mk
endif
ifdef CONFIG_KCOV
include $(CROOT)/kcov.mk
endif
ASFLAGS += -I$(CROOT)/src/include
ifneq ("$(wildcard $(CROOT)/userconfig.mk)","")
include $(CROOT)/userconfig.mk
endif
# Place these last so that userconfig.mk can put data into SH_FLAGS
CFLAGS += $(SH_FLAGS)
ASFLAGS += $(SH_FLAGS)
QEMU_FLAGS += -machine virt
# Test older:
# - cortex-a57
QEMU_FLAGS += -cpu cortex-a72
QEMU_FLAGS += -nographic
# https://fadeevab.com/how-to-setup-qemu-output-to-console-and-automate-using-shell-script/
#QEMU_FLAGS += -serial pipe:/tmp/guest
QEMU_FLAGS += -smp 1
# TODO: There are some assumptions on the amount of memory in the code
QEMU_FLAGS += -m 128M
QEMU_FLAGS += -d unimp,guest_errors
# Variables which should be defined in userconfig.mk
ifdef USERARGS
KERNEL_APPEND += userargs=$(USERARGS)
endif
ifdef KERNEL_APPEND
QEMU_FLAGS += -append "$(KERNEL_APPEND)"
endif
ifeq ($(USE_DISK),1)
QEMU_FLAGS += -device virtio-blk-device,drive=hd0 -drive file=rootfs.tar,id=hd0,if=none,format=raw
endif
#QEMU_FLAGS += -device vhost-vsock-device,guest-cid=3
#QEMU_FLAGS += -chardev socket,host=127.0.0.1,port=8181,id=foo -device virtio-serial-device -device virtserialport,chardev=foo,id=test0,nr=1
# RNG device
QEMU_FLAGS += -object rng-random,filename=/dev/random,id=rng0
QEMU_FLAGS += -device virtio-rng-device,rng=rng0
# Useful for debugging
ifeq ($(QEMU_TRACE),1)
QEMU_FLAGS += -trace events=events
endif
# Networking
# tap device (requires admin)
# -netdev type=tap,id=net0 -device virtio-net-device,netdev=net0
NET_SHARED = net=192.168.1.0/24,dhcpstart=192.168.1.10
# Standard user
QEMU_FLAGS += -netdev user,id=net0,$(NET_SHARED)
# tap with root
#QEMU_FLAGS += -netdev type=tap,id=net0,$(NET_SHARED)
# tap w/o root
#QEMU_FLAGS += -netdev user,type=tap,ifname=tap0,id=net0,script=no,downscript=no
#QEMU_FLAGS += -netdev user,type=tap,ifname=tap0,id=net0
# Config of interface in guest
QEMU_FLAGS += -device virtio-net-device,netdev=net0
QEMU_FLAGS += -kernel Image
QEMU_FLAGS += -initrd apps/$(UPROG)