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 "iospatch.h"
#include "video.h" #include "video.h"
extern void __exception_closeall();
struct __argv arguments; struct __argv arguments;
char* m_argv[256]; char* m_argv[256];
@ -179,11 +177,6 @@ void LaunchApp(void)
printf("-> And we're outta here!\n"); 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(); entry();
printf("--> Well.. this shouldn't happen\n"); printf("--> Well.. this shouldn't happen\n");

View File

@ -5,10 +5,11 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <malloc.h> #include <malloc.h>
#include <ogc/machine/processor.h>
#include "loader.h" #include "loader.h"
extern void __exception_setreload(int t); extern void __exception_closeall();
static void* xfb = NULL; static void* xfb = NULL;
static GXRModeObj* rmode = NULL; static GXRModeObj* rmode = NULL;
@ -24,18 +25,28 @@ void VideoInit(void)
VIDEO_Init(); VIDEO_Init();
rmode = VIDEO_GetPreferredMode(NULL); rmode = VIDEO_GetPreferredMode(NULL);
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
VIDEO_Configure(rmode); VIDEO_Configure(rmode);
VIDEO_SetNextFramebuffer(xfb); VIDEO_SetNextFramebuffer(xfb);
VIDEO_SetBlack(FALSE); VIDEO_SetBlack(FALSE);
VIDEO_Flush(); VIDEO_Flush();
VIDEO_WaitVSync(); VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) if (rmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync(); VIDEO_WaitVSync();
printf("\x1b[2;0H"); 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) int main(void)
{ {
VideoInit(); VideoInit();
@ -66,6 +77,8 @@ int main(void)
DCFlushRange(&execPtr[0x20], 1); DCFlushRange(&execPtr[0x20], 1);
} }
if (!IsDollZ(buffer) && !IsSpecialELF(buffer))
{
u32 argumentsSize = *(vu32*)0x91000000; u32 argumentsSize = *(vu32*)0x91000000;
if (argumentsSize > 0) if (argumentsSize > 0)
{ {
@ -82,7 +95,13 @@ int main(void)
DCFlushRange(&ptr[2], 4); DCFlushRange(&ptr[2], 4);
} }
} }
}
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
u32 level = IRQ_Disable();
__exception_closeall();
entry(); entry();
IRQ_Restore(level);
return 0; return 0;
} }