blob: b158d3b8ab2777b4feebc4b70a97d3383e0802b7 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001LOCAL_DIR := $(GET_LOCAL_DIR)
2
3MODULE := $(LOCAL_DIR)
4
5WITH_KERNEL_VM=1
6
7GLOBAL_DEFINES += \
8 MEMBASE=0x00200000U \
9 KERNEL_ASPACE_BASE=0x00200000U \
10 KERNEL_ASPACE_SIZE=0x7fe00000U \
11 X86_WITH_FPU=1 \
12 SMP_MAX_CPUS=1
13
14
15KERNEL_BASE ?= 0x00200000
16KERNEL_LOAD_OFFSET ?= 0x0
17
18MODULE_SRCS += \
19 $(LOCAL_DIR)/crt0.S \
20 $(LOCAL_DIR)/arch.c \
21 $(LOCAL_DIR)/asm.S \
22 $(LOCAL_DIR)/cache.c \
23 $(LOCAL_DIR)/cache-ops.S \
24 $(LOCAL_DIR)/ops.S \
25 $(LOCAL_DIR)/thread.c \
26 $(LOCAL_DIR)/mmu.c \
27 $(LOCAL_DIR)/faults.c \
28 $(LOCAL_DIR)/descriptor.c \
29 $(LOCAL_DIR)/fpu.c
30
31# set the default toolchain to x86 elf and set a #define
32ifndef TOOLCHAIN_PREFIX
33TOOLCHAIN_PREFIX := i386-elf-
34endif
35
36
37cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`"; \
38 then echo "$(2)"; else echo "$(3)"; fi ;)
39
40# disable SSP if the compiler supports it; it will break stuff
41GLOBAL_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
42
43GLOBAL_COMPILEFLAGS += -fasynchronous-unwind-tables
44GLOBAL_COMPILEFLAGS += -gdwarf-2
45
46ARCH_OPTFLAGS := -O2
47
48# potentially generated files that should be cleaned out with clean make rule
49GENERATED += \
50 $(BUILDDIR)/kernel.ld
51
52# rules for generating the linker scripts
53$(BUILDDIR)/kernel.ld: $(LOCAL_DIR)/kernel.ld $(wildcard arch/*.ld)
54 @echo generating $@
55 @$(MKDIR)
56 $(NOECHO)cp $< $@
57
58include make/module.mk