diff options
author | Gentoo <installgentoo@endianness.com> | 2021-03-27 10:36:05 +1100 |
---|---|---|
committer | Gentoo <installgentoo@endianness.com> | 2021-03-27 10:36:05 +1100 |
commit | 0349c6d6572f59770898d3f40287ebdcd2f8ed30 (patch) | |
tree | 4f55d594e5343a7d4f4e6d4dea34d9c35caa0b99 /source/load_elf.c | |
download | YetAnotherModLoader-0349c6d6572f59770898d3f40287ebdcd2f8ed30.tar.gz YetAnotherModLoader-0349c6d6572f59770898d3f40287ebdcd2f8ed30.tar.bz2 YetAnotherModLoader-0349c6d6572f59770898d3f40287ebdcd2f8ed30.zip |
Diffstat (limited to 'source/load_elf.c')
-rw-r--r-- | source/load_elf.c | 55 |
1 files changed, 55 insertions, 0 deletions
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 <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ogcsys.h> +#include <gccore.h> +#include <ogc/machine/processor.h> + +#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); +} |