From 7988a26accf14738580e7a9566718c4b7ea59885 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Wed, 13 Jul 2016 22:22:23 +0200 Subject: [PATCH] Automatically copy GM9 payload on newly formatted SDs A9LH only feature --- a9lh.ld | 3 ++- gateway.ld | 3 ++- source/abstraction/a9-start.s | 12 ++++++++++++ source/abstraction/gw-start.s | 12 ++++++++++++ source/godmode.c | 6 ++++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/a9lh.ld b/a9lh.ld index 95dbe9e..6602263 100644 --- a/a9lh.ld +++ b/a9lh.ld @@ -5,7 +5,8 @@ SECTIONS .text.start : { *(.text.start) } .text : { *(.text) } .data : { *(.data) } - .bss : { *(.bss COMMON) } + .bss : { __bss_start = .; *(.bss COMMON) } + __bss_end = .; .rodata : { *(.rodata) } . = ALIGN(4); __end__ = ABSOLUTE(.); diff --git a/gateway.ld b/gateway.ld index ae2478b..48952fc 100644 --- a/gateway.ld +++ b/gateway.ld @@ -5,7 +5,8 @@ SECTIONS .text.start : { *(.text.start) } .text : { *(.text) } .data : { *(.data) } - .bss : { *(.bss COMMON) } + .bss : { __bss_start = .; *(.bss COMMON) } + __bss_end = .; .rodata : { *(.rodata) } . = ALIGN(4); __end__ = ABSOLUTE(.); diff --git a/source/abstraction/a9-start.s b/source/abstraction/a9-start.s index b303472..d4b276e 100644 --- a/source/abstraction/a9-start.s +++ b/source/abstraction/a9-start.s @@ -14,6 +14,18 @@ _start: bic r4, #(1<<0) @ - mpu disable mcr p15, 0, r4, c1, c0, 0 @ write control register + @ Clear bss + ldr r0, =__bss_start + ldr r1, =__bss_end + mov r2, #0 + + .bss_clr: + cmp r0, r1 + beq .bss_clr_done + str r2, [r0], #4 + b .bss_clr + .bss_clr_done: + @ Give read/write access to all the memory regions ldr r5, =0x33333333 mcr p15, 0, r5, c5, c0, 2 @ write data access diff --git a/source/abstraction/gw-start.s b/source/abstraction/gw-start.s index 1f1a8e4..d3f611a 100644 --- a/source/abstraction/gw-start.s +++ b/source/abstraction/gw-start.s @@ -44,6 +44,18 @@ _start: bic r4, #(1<<0) @ - mpu disable mcr p15, 0, r4, c1, c0, 0 @ write control register + @ Clear bss + ldr r0, =__bss_start + ldr r1, =__bss_end + mov r2, #0 + + .bss_clr: + cmp r0, r1 + beq .bss_clr_done + str r2, [r0], #4 + b .bss_clr + .bss_clr_done: + @ Give read/write access to all the memory regions ldr r5, =0x33333333 mcr p15, 0, r5, c5, c0, 2 @ write data access diff --git a/source/godmode.c b/source/godmode.c index a14e5a3..48a70c7 100644 --- a/source/godmode.c +++ b/source/godmode.c @@ -193,6 +193,12 @@ u32 SdFormatMenu(void) { return 1; } + if (*(vu32*) 0x101401C0 == 0) { + InitSDCardFS(); // on A9LH: copy the payload from mem to SD root + FileSetData("0:/arm9loaderhax.bin", (u8*) 0x23F00000, 0x40000, 0, true); + DeinitSDCardFS(); + } + return 0; }