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