rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | LOCAL_DIR := $(GET_LOCAL_DIR) |
| 2 | |
| 3 | MODULE := $(LOCAL_DIR) |
| 4 | |
| 5 | GLOBAL_DEFINES += \ |
| 6 | ARM64_CPU_$(ARM_CPU)=1 \ |
| 7 | ARM_ISA_ARMV8=1 \ |
| 8 | IS_64BIT=1 |
| 9 | |
| 10 | MODULE_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 | |
| 28 | GLOBAL_DEFINES += \ |
| 29 | ARCH_DEFAULT_STACK_SIZE=8192 |
| 30 | |
| 31 | # if its requested we build with SMP, arm generically supports 4 cpus |
| 32 | ifeq ($(WITH_SMP),1) |
| 33 | SMP_MAX_CPUS ?= 4 |
| 34 | SMP_CPU_CLUSTER_SHIFT ?= 8 |
| 35 | SMP_CPU_ID_BITS ?= 24 # Ignore aff3 bits for now since they are not next to aff2 |
| 36 | |
| 37 | GLOBAL_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 | |
| 43 | MODULE_SRCS += \ |
| 44 | $(LOCAL_DIR)/mp.c |
| 45 | else |
| 46 | GLOBAL_DEFINES += \ |
| 47 | SMP_MAX_CPUS=1 |
| 48 | endif |
| 49 | |
| 50 | ARCH_OPTFLAGS := -O2 |
| 51 | |
| 52 | # we have a mmu and want the vmm/pmm |
| 53 | WITH_KERNEL_VM ?= 1 |
| 54 | |
| 55 | ifeq ($(WITH_KERNEL_VM),1) |
| 56 | |
| 57 | MODULE_SRCS += \ |
| 58 | $(LOCAL_DIR)/mmu.c |
| 59 | |
| 60 | KERNEL_ASPACE_BASE ?= 0xffff000000000000 |
| 61 | KERNEL_ASPACE_SIZE ?= 0x0001000000000000 |
| 62 | USER_ASPACE_BASE ?= 0x0000000001000000 |
| 63 | USER_ASPACE_SIZE ?= 0x0000fffffe000000 |
| 64 | |
| 65 | GLOBAL_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 | |
| 71 | KERNEL_BASE ?= $(KERNEL_ASPACE_BASE) |
| 72 | KERNEL_LOAD_OFFSET ?= 0 |
| 73 | |
| 74 | GLOBAL_DEFINES += \ |
| 75 | KERNEL_BASE=$(KERNEL_BASE) \ |
| 76 | KERNEL_LOAD_OFFSET=$(KERNEL_LOAD_OFFSET) |
| 77 | |
| 78 | else |
| 79 | |
| 80 | KERNEL_BASE ?= $(MEMBASE) |
| 81 | KERNEL_LOAD_OFFSET ?= 0 |
| 82 | |
| 83 | endif |
| 84 | |
| 85 | GLOBAL_DEFINES += \ |
| 86 | MEMBASE=$(MEMBASE) \ |
| 87 | MEMSIZE=$(MEMSIZE) |
| 88 | |
| 89 | # try to find the toolchain |
| 90 | include $(LOCAL_DIR)/toolchain.mk |
| 91 | TOOLCHAIN_PREFIX := $(ARCH_$(ARCH)_TOOLCHAIN_PREFIX) |
| 92 | $(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX)) |
| 93 | |
| 94 | ARCH_COMPILEFLAGS += $(ARCH_$(ARCH)_COMPILEFLAGS) |
| 95 | |
| 96 | GLOBAL_LDFLAGS += -z max-page-size=4096 |
| 97 | |
| 98 | |
| 99 | # make sure some bits were set up |
| 100 | MEMVARS_SET := 0 |
| 101 | ifneq ($(MEMBASE),) |
| 102 | MEMVARS_SET := 1 |
| 103 | endif |
| 104 | ifneq ($(MEMSIZE),) |
| 105 | MEMVARS_SET := 1 |
| 106 | endif |
| 107 | ifeq ($(MEMVARS_SET),0) |
| 108 | $(error missing MEMBASE or MEMSIZE variable, please set in target rules.mk) |
| 109 | endif |
| 110 | |
| 111 | # potentially generated files that should be cleaned out with clean make rule |
| 112 | GENERATED += \ |
| 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 | |
| 122 | linkerscript.phony: |
| 123 | .PHONY: linkerscript.phony |
| 124 | |
| 125 | include make/module.mk |