Correctly boot ELF files

This commit is contained in:
wiidev 2023-02-16 23:40:02 +00:00
parent 2d6c458083
commit 5f2414755e
2 changed files with 33 additions and 21 deletions

View File

@ -14,8 +14,6 @@
#include "iospatch.h"
#include "video.h"
extern void __exception_closeall();
struct __argv arguments;
char* m_argv[256];
@ -179,11 +177,6 @@ void LaunchApp(void)
printf("-> And we're outta here!\n");
*(vu32*)0x800000F8 = 0x0E7BE2C0; // Bus Speed
*(vu32*)0x800000FC = 0x2B73A840; // CPU Speed
//SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
__exception_closeall();
entry();
printf("--> Well.. this shouldn't happen\n");

View File

@ -5,10 +5,11 @@
#include <unistd.h>
#include <string.h>
#include <malloc.h>
#include <ogc/machine/processor.h>
#include "loader.h"
extern void __exception_setreload(int t);
extern void __exception_closeall();
static void* xfb = NULL;
static GXRModeObj* rmode = NULL;
@ -36,6 +37,16 @@ void VideoInit(void)
printf("\x1b[2;0H");
}
bool IsDollZ(const u8* buffer)
{
return (buffer[0x100] == 0x3C);
}
bool IsSpecialELF(const u8* buffer)
{
return (read32((u32)buffer) == 0x7F454C46 && buffer[0x24] == 0);
}
int main(void)
{
VideoInit();
@ -66,6 +77,8 @@ int main(void)
DCFlushRange(&execPtr[0x20], 1);
}
if (!IsDollZ(buffer) && !IsSpecialELF(buffer))
{
u32 argumentsSize = *(vu32*)0x91000000;
if (argumentsSize > 0)
{
@ -82,7 +95,13 @@ int main(void)
DCFlushRange(&ptr[2], 4);
}
}
}
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
u32 level = IRQ_Disable();
__exception_closeall();
entry();
IRQ_Restore(level);
return 0;
}