diff --git a/fusee/fusee-secondary/src/main.c b/fusee/fusee-secondary/src/main.c index 6344fdb62..8b6d18916 100644 --- a/fusee/fusee-secondary/src/main.c +++ b/fusee/fusee-secondary/src/main.c @@ -2,8 +2,12 @@ #include "hwinit.h" #include "loader.h" +#include "stage2.h" -int main(void) { +/* Allow for main(int argc, void **argv) signature. */ +#pragma GCC diagnostic ignored "-Wmain" + +int main(int argc, void **argv) { entrypoint_t entrypoint; /* TODO: What other hardware init should we do here? */ diff --git a/fusee/fusee-secondary/src/stage2.h b/fusee/fusee-secondary/src/stage2.h new file mode 100644 index 000000000..e7ddb1a87 --- /dev/null +++ b/fusee/fusee-secondary/src/stage2.h @@ -0,0 +1,12 @@ +#ifndef FUSEE_STAGE2_H +#define FUSEE_STAGE2_H + +#include "utils.h" + +/* TODO: Is there a more concise way to do this? */ +#define STAGE2_ARGV_VERSION 0 +#define STAGE2_ARGV_CONFIG 1 +#define STAGE2_ARGV_LFB 2 +#define STAGE2_ARGC 3 + +#endif \ No newline at end of file diff --git a/fusee/fusee-secondary/src/start.s b/fusee/fusee-secondary/src/start.s index 961542f45..3686a2a27 100644 --- a/fusee/fusee-secondary/src/start.s +++ b/fusee/fusee-secondary/src/start.s @@ -15,17 +15,17 @@ _start: msr cpsr_cxsf, #0xDF /* Relocate ourselves if necessary */ - ldr r0, =__start__ - adr r1, _start - cmp r0, r1 + ldr r2, =__start__ + adr r3, _start + cmp r2, r3 bne _relocation_loop_end - ldr r2, =__bss_start__ - sub r2, r2, r0 /* size >= 32, obviously */ + ldr r4, =__bss_start__ + sub r4, r4, r2 /* size >= 32, obviously */ _relocation_loop: - ldmia r1!, {r3-r10} - stmia r0!, {r3-r10} - subs r2, #0x20 + ldmia r3!, {r5-r12} + stmia r2!, {r5-r12} + subs r4, #0x20 bne _relocation_loop ldr r12, =_relocation_loop_end @@ -35,6 +35,7 @@ _start: /* Set the stack pointer */ ldr sp, =0x40008000 mov fp, #0 + stmfd sp!, {r0, r1} /* Clear .bss */ ldr r0, =__bss_start__ @@ -50,5 +51,6 @@ _start: .rept 13 CLEAR_GPR_REG_ITER .endr + ldmfd sp!, {r0, r1} bl main b .