@@ -30,6 +30,34 @@ $(call set-feature, BLOCK_CHAINING)
30
30
ENABLE_SYSTEM ?= 0
31
31
$(call set-feature, SYSTEM)
32
32
33
+ # Definition that bridges:
34
+ # Device Tree(initrd, memory range)
35
+ # src/io.c(memory init)
36
+ # src/riscv.c(system emulation layout init)
37
+ ifeq ($(call has, SYSTEM) , 1)
38
+ ifeq ($(call has, ELF_LOADER) , 0)
39
+ MiB = 1024*1024
40
+ MEM_START ?= 0
41
+ MEM_SIZE ?= 512 # unit in MiB
42
+ DTB_SIZE ?= 1 # unit in MiB
43
+ INITRD_SIZE ?= 8 # unit in MiB
44
+
45
+ compute_size = $(shell echo "obase=16; ibase=10; $(1 ) * $(MiB ) " | bc)
46
+ REAL_MEM_SIZE = $(call compute_size, $(MEM_SIZE ) )
47
+ REAL_DTB_SIZE = $(call compute_size, $(DTB_SIZE ) )
48
+ REAL_INITRD_SIZE = $(call compute_size, $(INITRD_SIZE ) )
49
+
50
+ CFLAGS_dt += -DMEM_START=0x$(MEM_START ) \
51
+ -DMEM_END=0x$(shell echo "obase=16; ibase=16; $(MEM_START ) +$(REAL_MEM_SIZE ) " | bc) \
52
+ -DINITRD_START=0x$(shell echo "obase=16; ibase=16; \
53
+ $(REAL_MEM_SIZE ) - $(call compute_size, ($(INITRD_SIZE ) +$(DTB_SIZE ) ) ) " | bc) \
54
+ -DINITRD_END=0x$(shell echo "obase=16; ibase=16; \
55
+ $(REAL_MEM_SIZE ) - $(call compute_size, $(DTB_SIZE ) ) - 1" | bc)
56
+
57
+ CFLAGS += -DMEM_SIZE=0x$(REAL_MEM_SIZE ) -DDTB_SIZE=0x$(REAL_DTB_SIZE ) -DINITRD_SIZE=0x$(REAL_INITRD_SIZE )
58
+ endif
59
+ endif
60
+
33
61
# Enable link-time optimization (LTO)
34
62
ENABLE_LTO ?= 1
35
63
ifeq ($(call has, LTO) , 1)
@@ -149,6 +177,14 @@ LDFLAGS += $(shell pkg-config --libs SDL2_mixer)
149
177
endif
150
178
endif
151
179
180
+ # If SYSTEM is enabled and ELF_LOADER is not, then skip FULL4G bacause guestOS
181
+ # has dedicated memory mapping range.
182
+ ifeq ($(call has, SYSTEM) , 1)
183
+ ifeq ($(call has, ELF_LOADER) , 0)
184
+ override ENABLE_FULL4G := 0
185
+ endif
186
+ endif
187
+
152
188
# Full access to a 4 GiB address space, necessitating more memory mapping
153
189
# during emulator initialization.
154
190
$(call set-feature, FULL4G)
0 commit comments