Fix start.s in stage2 of Fusee for argc/argv

This commit is contained in:
Michael Scire 2018-04-08 05:06:04 -06:00
parent 353019a269
commit c758b1188a
3 changed files with 27 additions and 9 deletions

View File

@ -2,8 +2,12 @@
#include "hwinit.h" #include "hwinit.h"
#include "loader.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; entrypoint_t entrypoint;
/* TODO: What other hardware init should we do here? */ /* TODO: What other hardware init should we do here? */

View File

@ -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

View File

@ -15,17 +15,17 @@ _start:
msr cpsr_cxsf, #0xDF msr cpsr_cxsf, #0xDF
/* Relocate ourselves if necessary */ /* Relocate ourselves if necessary */
ldr r0, =__start__ ldr r2, =__start__
adr r1, _start adr r3, _start
cmp r0, r1 cmp r2, r3
bne _relocation_loop_end bne _relocation_loop_end
ldr r2, =__bss_start__ ldr r4, =__bss_start__
sub r2, r2, r0 /* size >= 32, obviously */ sub r4, r4, r2 /* size >= 32, obviously */
_relocation_loop: _relocation_loop:
ldmia r1!, {r3-r10} ldmia r3!, {r5-r12}
stmia r0!, {r3-r10} stmia r2!, {r5-r12}
subs r2, #0x20 subs r4, #0x20
bne _relocation_loop bne _relocation_loop
ldr r12, =_relocation_loop_end ldr r12, =_relocation_loop_end
@ -35,6 +35,7 @@ _start:
/* Set the stack pointer */ /* Set the stack pointer */
ldr sp, =0x40008000 ldr sp, =0x40008000
mov fp, #0 mov fp, #0
stmfd sp!, {r0, r1}
/* Clear .bss */ /* Clear .bss */
ldr r0, =__bss_start__ ldr r0, =__bss_start__
@ -50,5 +51,6 @@ _start:
.rept 13 .rept 13
CLEAR_GPR_REG_ITER CLEAR_GPR_REG_ITER
.endr .endr
ldmfd sp!, {r0, r1}
bl main bl main
b . b .