Handle arguments in a better way
This commit is contained in:
parent
dd21a3930d
commit
a9a8edeaf4
@ -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]
|
||||
|
@ -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,33 +52,30 @@ void main(int argc, char **argv)
|
||||
FirmwareType firmType;
|
||||
FirmwareSource nandType;
|
||||
|
||||
switch(argc)
|
||||
if(magicWord == 0xBEEF && argc >= 1) //Normal boot
|
||||
{
|
||||
case 1: //Normal boot
|
||||
{
|
||||
u32 i;
|
||||
for(i = 0; i < 40 && argv[0][i] != 0; i++) //Copy and convert the path to UTF-16
|
||||
launchedPath[i] = argv[0][i];
|
||||
launchedPath[i] = 0;
|
||||
break;
|
||||
}
|
||||
u32 i;
|
||||
for(i = 0; i < 40 && argv[0][i] != 0; i++) //Copy and convert the path to UTF-16
|
||||
launchedPath[i] = argv[0][i];
|
||||
launchedPath[i] = 0;
|
||||
break;
|
||||
}
|
||||
else if(magicWord == 0xBABE && argc == 2) //Firmlaunch
|
||||
{
|
||||
u32 i;
|
||||
u16 *p = (u16 *)argv[0];
|
||||
for(i = 0; i < 40 && p[i] != 0; i++)
|
||||
launchedPath[i] = p[i];
|
||||
launchedPath[i] = 0;
|
||||
|
||||
case 2: //Firmlaunch
|
||||
{
|
||||
u32 i;
|
||||
u16 *p = (u16 *)argv[0];
|
||||
for(i = 0; i < 40 && p[i] != 0; i++)
|
||||
launchedPath[i] = p[i];
|
||||
launchedPath[i] = 0;
|
||||
|
||||
isFirmlaunch = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
sprintf(errbuf, "Unsupported launcher (argc = %d).", argc);
|
||||
error(errbuf);
|
||||
break;
|
||||
isFirmlaunch = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(errbuf, "Unsupported launcher or entrypoint (magic = 0x%08x, argc = %d).", magicWord, argc);
|
||||
error(errbuf);
|
||||
break;
|
||||
}
|
||||
|
||||
if(memcmp(launchedPath, u"sdmc", 8) == 0)
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user