From 0349c6d6572f59770898d3f40287ebdcd2f8ed30 Mon Sep 17 00:00:00 2001 From: Gentoo Date: Sat, 27 Mar 2021 10:36:05 +1100 Subject: initial commit --- source/load_elf.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 source/load_elf.c (limited to 'source/load_elf.c') diff --git a/source/load_elf.c b/source/load_elf.c new file mode 100644 index 0000000..1519db8 --- /dev/null +++ b/source/load_elf.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#include + +#include "elf-loader.h" +#include "sync.h" +#include "gecko.h" + +extern void __exception_closeall(void); + +//taken from https://github.com/Fullmetal5/WiiNetworkLoader +//Note: There isn't any point for printf() messages, since you can't read them fast enough anyway +void boot_elf(void *payload, size_t size) +{ + + gprintf("Shutting down IOS Subsystems... "); + + __IOS_ShutdownSubsystems(); + + gprintf("OK"); + gprintf("Shutting down CPU ISR... "); + + uint32_t level; + _CPU_ISR_Disable(level); + + gprintf("OK"); + gprintf("Shutting down exception vectors... "); + + __exception_closeall(); + + gprintf("OK"); + gprintf("Copying ELF loading stub... "); + + + memcpy((void*)0x81330000, loader_bin, loader_bin_len); + sync_before_exec((void*)0x81330000, loader_bin_len); + + + gprintf("OK"); + gprintf("Jumping to entry point!"); + + + void (*entry)(void*, uint32_t) = (void*)0x81330000; + entry(payload, size); + + printf("If you can see this then something has gone very wrong!\n"); + + gprintf("ELF failed to load somehow!"); + + fflush(stdout); + while(1); +} -- cgit v1.2.3