Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split GM9 across two sections in memory. #837

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,25 @@ $(VRAM_TAR): $(SPLASH) $(OVERRIDE_FONT) $(VRAM_DATA) $(VRAM_SCRIPTS)

arm9/arm9.elf: $(VRAM_TAR)

firm: $(ELF)
$(OUTDIR)/AHBWRAM_LO.elf: $(ELF)
@$(OBJCOPY) arm9/arm9.elf -j AHBWRAM_LO $@

$(OUTDIR)/AHBWRAM_HI.elf: $(ELF)
@$(OBJCOPY) arm9/arm9.elf -j AHBWRAM_HI $@
Comment on lines +94 to +98
Copy link
Author

@DarkRTA DarkRTA Jan 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objcopy is now throwing a warning and it does not provide any option to silence it.
Since this doesn't break the build, do you have any suggestions on how I can silence its output, or if we can even do so?


BINS := $(OUTDIR)/AHBWRAM_LO.elf $(OUTDIR)/AHBWRAM_HI.elf

firm: $(ELF) $(BINS)
@mkdir -p $(call dirname,"$(FIRM)") $(call dirname,"$(FIRMD)")
@echo "[FLAVOR] $(FLAVOR)"
@echo "[VERSION] $(VERSION)"
@echo "[BUILD] $(DBUILTL)"
@echo "[FIRM] $(FIRM)"
@$(PY3) -m firmtool build $(FIRM) $(FTFLAGS) -g -D $(ELF) -C NDMA XDMA
@$(PY3) -m firmtool build $(FIRM) $(FTFLAGS) -g -D $(BINS) arm11/arm11.elf \
-C NDMA NDMA XDMA
@echo "[FIRM] $(FIRMD)"
@$(PY3) -m firmtool build $(FIRMD) $(FTDFLAGS) -g -D $(ELF) -C NDMA XDMA
@$(PY3) -m firmtool build $(FIRMD) $(FTDFLAGS) -g -D $(BINS) arm11/arm11.elf \
-C NDMA NDMA XDMA

vram0: $(VRAM_TAR) .FORCE # legacy target name

Expand Down
5 changes: 3 additions & 2 deletions arm9/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ INCDIRS := source source/common source/filesys source/crypto source/fatfs source
INCLUDE := $(foreach dir,$(INCDIRS),-I"$(shell pwd)/$(dir)")

ASFLAGS += $(SUBARCH) $(INCLUDE)
CFLAGS += $(SUBARCH) $(INCLUDE) -fno-builtin-memcpy -flto
Wolfvak marked this conversation as resolved.
Show resolved Hide resolved
LDFLAGS += $(SUBARCH) -Wl,--use-blx,-Map,$(TARGET).map -flto
CFLAGS += $(SUBARCH) $(INCLUDE) -fno-builtin-memcpy
LDFLAGS += $(SUBARCH) -Wl,--use-blx,-Map,$(TARGET).map \
-Xlinker --no-warn-rwx-segments

include ../Makefile.common
include ../Makefile.build
50 changes: 29 additions & 21 deletions arm9/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,52 @@ ENTRY(_start)

MEMORY
{
VECTORS (RX) : ORIGIN = 0x08000000, LENGTH = 64
AHBWRAM (RWX) : ORIGIN = 0x08000040, LENGTH = 512K - 64
AHBWRAM_LO (RWX) : ORIGIN = 0x08000040, LENGTH = 512K - 64
AHBWRAM_HI (RWX) : ORIGIN = 0x080a0000, LENGTH = 386K
}

SECTIONS
{
.vectors : ALIGN(4) {
__vectors_lma = LOADADDR(.vectors);
__vectors_vma = ABSOLUTE(.);
/* this must come *first* so it picks up lua */
AHBWRAM_HI : ALIGN(4) {
*build/lua*(.text*);
libm*(.text*);
*(.rodata.vram_data);

} >AHBWRAM_HI


__vectors_vma = 0x08000000;
AHBWRAM_LO : ALIGN(4) {
/* this needs to be absolute otherwise GM9 won't boot */
__vectors_lma = ABSOLUTE(.);
KEEP(*(.vectors));
. = ALIGN(4);
__vectors_len = ABSOLUTE(.) - __vectors_vma;
} >VECTORS AT>AHBWRAM
__vectors_len = . - __vectors_lma;

.text : ALIGN(4) {
__text_s = ABSOLUTE(.);
. = ALIGN(4);
*(.text.start);
*(.text*);

/* .ARM.exidx (needed for lua) */
. = ALIGN(4);
__text_e = ABSOLUTE(.);
} >AHBWRAM
__exidx_start = .;
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
__exidx_end = .;

.rodata : ALIGN(4) {
*(.rodata*);
. = ALIGN(4);
} >AHBWRAM
*(.rodata*);

.data : ALIGN(4) {
*(.data*);
/* .data */
. = ALIGN(4);
} >AHBWRAM
*(.data*);

.bss : ALIGN(4) {
. = ALIGN(4);
__bss_start = .;
*(.bss*);
. = ALIGN(4);
__bss_end = .;
} >AHBWRAM

__end__ = ABSOLUTE(.);
__end__ = .;
} >AHBWRAM_LO

}
2 changes: 1 addition & 1 deletion arm9/source/start.s
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ _start:
@ Install exception handlers
ldr r0, =__vectors_lma
ldr r1, =__vectors_len
ldr r2, =XRQ_Start
ldr r2, =__vectors_vma
add r1, r0, r1
.LXRQ_Install:
cmp r0, r1
Expand Down
3 changes: 1 addition & 2 deletions arm9/source/system/xrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#define PC_DUMPRAD (0x10)
#define SP_DUMPLEN (0x80)
extern u32 __text_s, __text_e;

static bool sp_dumpable(u32 sp, u32 *sp_lower, u32 *sp_upper)
{
Expand All @@ -31,7 +30,7 @@ static bool sp_dumpable(u32 sp, u32 *sp_lower, u32 *sp_upper)

static bool pc_dumpable(u32 pc, u32 *pc_lower, u32 *pc_upper)
{
u32 code_start = (u32)(&__text_s), code_end = (u32)(&__text_e);
u32 code_start = __A9RAM0_ADDR, code_end = __A9RAM0_ADDR + __A9RAM0_LEN;

if ((pc >= code_end) || (pc < code_start))
return false;
Expand Down
Loading