mirror of
https://github.com/modmii/YAWM-ModMii-Edition.git
synced 2024-11-21 15:49:19 +01:00
Correctly boot ELF files
This commit is contained in:
parent
2d6c458083
commit
5f2414755e
@ -14,8 +14,6 @@
|
||||
#include "iospatch.h"
|
||||
#include "video.h"
|
||||
|
||||
extern void __exception_closeall();
|
||||
|
||||
struct __argv arguments;
|
||||
char* m_argv[256];
|
||||
|
||||
@ -178,12 +176,7 @@ 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");
|
||||
|
@ -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;
|
||||
|
||||
@ -24,18 +25,28 @@ void VideoInit(void)
|
||||
VIDEO_Init();
|
||||
rmode = VIDEO_GetPreferredMode(NULL);
|
||||
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_SetNextFramebuffer(xfb);
|
||||
VIDEO_SetBlack(FALSE);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
if(rmode->viTVMode&VI_NON_INTERLACE)
|
||||
if (rmode->viTVMode & VI_NON_INTERLACE)
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
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,23 +77,31 @@ int main(void)
|
||||
DCFlushRange(&execPtr[0x20], 1);
|
||||
}
|
||||
|
||||
u32 argumentsSize = *(vu32*)0x91000000;
|
||||
if (argumentsSize > 0)
|
||||
if (!IsDollZ(buffer) && !IsSpecialELF(buffer))
|
||||
{
|
||||
u32* ptr = (u32*)entry;
|
||||
|
||||
if (ptr[1] == 0x5F617267)
|
||||
u32 argumentsSize = *(vu32*)0x91000000;
|
||||
if (argumentsSize > 0)
|
||||
{
|
||||
struct Arguments* argv = (struct Arguments*)&ptr[2];
|
||||
u32* ptr = (u32*)entry;
|
||||
|
||||
argv->magic = 0x5F617267;
|
||||
argv->cmdLine = (char*)0x91000020;
|
||||
argv->length = argumentsSize;
|
||||
if (ptr[1] == 0x5F617267)
|
||||
{
|
||||
struct Arguments* argv = (struct Arguments*)&ptr[2];
|
||||
|
||||
DCFlushRange(&ptr[2], 4);
|
||||
argv->magic = 0x5F617267;
|
||||
argv->cmdLine = (char*)0x91000020;
|
||||
argv->length = argumentsSize;
|
||||
|
||||
DCFlushRange(&ptr[2], 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
|
||||
u32 level = IRQ_Disable();
|
||||
__exception_closeall();
|
||||
entry();
|
||||
IRQ_Restore(level);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user