2 # This builds either into a library that's linked with the TLK kernel
3 # (when MONITOR_MODULE = false, in the case of MODULE_ARCH = arm).
5 # Or, generates a separate mon.bin binary with its own address space
6 # (when MONITOR_MODULE = true, in the case of MODULE_ARCH = arm64).
8 LOCAL_DIR := $(GET_LOCAL_DIR)
10 MODULE := $(LOCAL_DIR)
12 MONARCH := $(MONITOR_ARCH)
13 MODULE_ARCH := $(MONARCH)
16 -I$(LOCAL_DIR)/include \
17 -I$(LOCAL_DIR)/$(MONARCH)/include
20 $(error arm32 standalone monitor binary not supported)
24 $(LOCAL_DIR)/common/debug.c \
25 $(LOCAL_DIR)/common/printf.c
27 ifeq ($(MONARCH),arm64)
29 $(LOCAL_DIR)/arm64/monitor_start.S \
30 $(LOCAL_DIR)/arm64/monitor_vector.S \
31 $(LOCAL_DIR)/arm64/monitor_cpu.S \
32 $(LOCAL_DIR)/arm64/monitor_fastcall.S \
33 $(LOCAL_DIR)/arm64/monitor_lib.S \
34 $(LOCAL_DIR)/arm64/monitor_mmu.S
36 MODULE_CC := $(TOOLCHAIN_PREFIX64)gcc
37 MODULE_LD := $(TOOLCHAIN_PREFIX64)ld
38 MON_OBJCOPY := $(TOOLCHAIN_PREFIX64)objcopy
41 # generating separate $(MONARCH) mon.bin
42 ifeq ($(MONITOR_BIN),true)
49 MONITOR_MODULE := true
50 MON_LD := $(MODULE_LD)
51 MON_LINKER_SCRIPT += \
52 $(BUILDDIR)/monitor-onesegment.ld
54 MONELF := $(BUILDDIR)/mon.elf
55 MONBIN := $(BUILDDIR)/mon.bin
58 $(error missing MONBASE variable, please set in target rules.mk)
61 $(error missing MONBITS variable, please set in target rules.mk)
64 $(error missing MONCPUS variable, please set in target rules.mk)
67 $(BUILDDIR)/monitor-onesegment.ld: $(LOCAL_DIR)/$(MONARCH)/monitor-onesegment.ld $(CONFIGHEADER)
70 $(NOECHO)sed "s/%MEMBASE%/$(MONBASE)/" < $< > $@
73 include make/module.mk