Handle arguments in a better way

This commit is contained in:
TuxSH 2017-05-23 16:11:39 +02:00
parent dd21a3930d
commit a9a8edeaf4
3 changed files with 27 additions and 32 deletions

View File

@ -160,7 +160,7 @@ fname: .ascii "FILE"
mov r0, #2 ; argc
ldr r1, =argv_addr ; argv
ldr r2, =0xBEEF ; magic word
ldr r2, =0xBABE ; magic word
ldr r5, =arm11_entrypoint_addr
ldr r6, [r4, #0x08]

View File

@ -43,7 +43,7 @@ bool isFirmlaunch = false,
isSdMode;
u16 launchedPath[41];
void main(int argc, char **argv)
void main(int argc, char **argv, u32 magicWord)
{
bool isSafeMode = false,
isNoForceFlagSet = false;
@ -52,9 +52,7 @@ void main(int argc, char **argv)
FirmwareType firmType;
FirmwareSource nandType;
switch(argc)
{
case 1: //Normal boot
if(magicWord == 0xBEEF && argc >= 1) //Normal boot
{
u32 i;
for(i = 0; i < 40 && argv[0][i] != 0; i++) //Copy and convert the path to UTF-16
@ -62,8 +60,7 @@ void main(int argc, char **argv)
launchedPath[i] = 0;
break;
}
case 2: //Firmlaunch
else if(magicWord == 0xBABE && argc == 2) //Firmlaunch
{
u32 i;
u16 *p = (u16 *)argv[0];
@ -74,9 +71,9 @@ void main(int argc, char **argv)
isFirmlaunch = true;
break;
}
default:
sprintf(errbuf, "Unsupported launcher (argc = %d).", argc);
else
{
sprintf(errbuf, "Unsupported launcher or entrypoint (magic = 0x%08x, argc = %d).", magicWord, argc);
error(errbuf);
break;
}

View File

@ -29,12 +29,9 @@ _start:
orr r4, #0x1C0
msr cpsr_cx, r4
ldr r4, =0xBEEF
cmp r2, r4
movne r0, #0 @ check magic word
mov r9, r0
mov r10, r1
mov r11, r2
@ Change the stack pointer
mov sp, #0x08100000
@ -95,4 +92,5 @@ _start:
mov r0, r9
mov r1, r10
mov r2, r11
b main