blob: ab6ac75fa99da05979d6b7fdd9ac5cff0be11721 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001LOCAL_DIR := $(GET_LOCAL_DIR)
2
3MODULE := $(LOCAL_DIR)
4
5GLOBAL_DEFINES += \
6 ARM64_CPU_$(ARM_CPU)=1 \
7 ARM_ISA_ARMV8=1 \
8 IS_64BIT=1
9
10MODULE_SRCS += \
11 $(LOCAL_DIR)/arch.c \
12 $(LOCAL_DIR)/asm.S \
13 $(LOCAL_DIR)/exceptions.S \
14 $(LOCAL_DIR)/exceptions_el2_el3.S \
15 $(LOCAL_DIR)/exceptions_c.c \
16 $(LOCAL_DIR)/fpu.c \
17 $(LOCAL_DIR)/thread.c \
18 $(LOCAL_DIR)/spinlock.S \
19 $(LOCAL_DIR)/start.S \
20 $(LOCAL_DIR)/cache-ops.S \
21
22# $(LOCAL_DIR)/arm/start.S \
23 $(LOCAL_DIR)/arm/cache.c \
24 $(LOCAL_DIR)/arm/ops.S \
25 $(LOCAL_DIR)/arm/faults.c \
26 $(LOCAL_DIR)/arm/dcc.S
27
28GLOBAL_DEFINES += \
29 ARCH_DEFAULT_STACK_SIZE=8192
30
31# if its requested we build with SMP, arm generically supports 4 cpus
32ifeq ($(WITH_SMP),1)
33SMP_MAX_CPUS ?= 4
34SMP_CPU_CLUSTER_SHIFT ?= 8
35SMP_CPU_ID_BITS ?= 24 # Ignore aff3 bits for now since they are not next to aff2
36
37GLOBAL_DEFINES += \
38 WITH_SMP=1 \
39 SMP_MAX_CPUS=$(SMP_MAX_CPUS) \
40 SMP_CPU_CLUSTER_SHIFT=$(SMP_CPU_CLUSTER_SHIFT) \
41 SMP_CPU_ID_BITS=$(SMP_CPU_ID_BITS)
42
43MODULE_SRCS += \
44 $(LOCAL_DIR)/mp.c
45else
46GLOBAL_DEFINES += \
47 SMP_MAX_CPUS=1
48endif
49
50ARCH_OPTFLAGS := -O2
51
52# we have a mmu and want the vmm/pmm
53WITH_KERNEL_VM ?= 1
54
55ifeq ($(WITH_KERNEL_VM),1)
56
57MODULE_SRCS += \
58 $(LOCAL_DIR)/mmu.c
59
60KERNEL_ASPACE_BASE ?= 0xffff000000000000
61KERNEL_ASPACE_SIZE ?= 0x0001000000000000
62USER_ASPACE_BASE ?= 0x0000000001000000
63USER_ASPACE_SIZE ?= 0x0000fffffe000000
64
65GLOBAL_DEFINES += \
66 KERNEL_ASPACE_BASE=$(KERNEL_ASPACE_BASE) \
67 KERNEL_ASPACE_SIZE=$(KERNEL_ASPACE_SIZE) \
68 USER_ASPACE_BASE=$(USER_ASPACE_BASE) \
69 USER_ASPACE_SIZE=$(USER_ASPACE_SIZE)
70
71KERNEL_BASE ?= $(KERNEL_ASPACE_BASE)
72KERNEL_LOAD_OFFSET ?= 0
73
74GLOBAL_DEFINES += \
75 KERNEL_BASE=$(KERNEL_BASE) \
76 KERNEL_LOAD_OFFSET=$(KERNEL_LOAD_OFFSET)
77
78else
79
80KERNEL_BASE ?= $(MEMBASE)
81KERNEL_LOAD_OFFSET ?= 0
82
83endif
84
85GLOBAL_DEFINES += \
86 MEMBASE=$(MEMBASE) \
87 MEMSIZE=$(MEMSIZE)
88
89# try to find the toolchain
90include $(LOCAL_DIR)/toolchain.mk
91TOOLCHAIN_PREFIX := $(ARCH_$(ARCH)_TOOLCHAIN_PREFIX)
92$(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX))
93
94ARCH_COMPILEFLAGS += $(ARCH_$(ARCH)_COMPILEFLAGS)
95
96GLOBAL_LDFLAGS += -z max-page-size=4096
97
98
99# make sure some bits were set up
100MEMVARS_SET := 0
101ifneq ($(MEMBASE),)
102MEMVARS_SET := 1
103endif
104ifneq ($(MEMSIZE),)
105MEMVARS_SET := 1
106endif
107ifeq ($(MEMVARS_SET),0)
108$(error missing MEMBASE or MEMSIZE variable, please set in target rules.mk)
109endif
110
111# potentially generated files that should be cleaned out with clean make rule
112GENERATED += \
113 $(BUILDDIR)/system-onesegment.ld
114
115# rules for generating the linker script
116$(BUILDDIR)/system-onesegment.ld: $(LOCAL_DIR)/system-onesegment.ld $(wildcard arch/*.ld) linkerscript.phony
117 @echo generating $@
118 @$(MKDIR)
119 $(NOECHO)sed "s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/;s/%KERNEL_BASE%/$(KERNEL_BASE)/;s/%KERNEL_LOAD_OFFSET%/$(KERNEL_LOAD_OFFSET)/" < $< > $@.tmp
120 @$(call TESTANDREPLACEFILE,$@.tmp,$@)
121
122linkerscript.phony:
123.PHONY: linkerscript.phony
124
125include make/module.mk