mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-16 00:15:08 +01:00
*Made forwarder Preloader compatible thanks to SpaceJump (only for DOLs though)
This commit is contained in:
parent
6c7e7a2a03
commit
70d8b4f4a4
2
Makefile
2
Makefile
@ -31,8 +31,8 @@ CXXFLAGS = $(CFLAGS)
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# move loader to another location - THANKS CREDIAR - 0x81330000 for HBC
|
# move loader to another location - THANKS CREDIAR - 0x81330000 for HBC
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--section-start,.init=0x81230000
|
||||||
#LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
#LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
||||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--section-start,.init=0x81000000
|
|
||||||
#LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--section-start,.init=0x80003f00
|
#LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--section-start,.init=0x80003f00
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
@ -1,42 +1,74 @@
|
|||||||
#include <malloc.h>
|
// this code was contributed by shagkur of the devkitpro team, thx!
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ogc/machine/processor.h>
|
|
||||||
#include <gccore.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "dolloader.h"
|
#include <gccore.h>
|
||||||
|
#include <ogcsys.h>
|
||||||
|
|
||||||
u32 load_dol_image (void *dolstart, struct __argv *argv) {
|
typedef struct _dolheader {
|
||||||
|
u32 text_pos[7];
|
||||||
|
u32 data_pos[11];
|
||||||
|
u32 text_start[7];
|
||||||
|
u32 data_start[11];
|
||||||
|
u32 text_size[7];
|
||||||
|
u32 data_size[11];
|
||||||
|
u32 bss_start;
|
||||||
|
u32 bss_size;
|
||||||
|
u32 entry_point;
|
||||||
|
} dolheader;
|
||||||
|
|
||||||
|
u32 load_dol_image (void *dolstart) {
|
||||||
u32 i;
|
u32 i;
|
||||||
dolheader *dolfile;
|
dolheader *dolfile;
|
||||||
|
|
||||||
if (dolstart) {
|
if (dolstart) {
|
||||||
dolfile = (dolheader *) dolstart;
|
dolfile = (dolheader *) dolstart;
|
||||||
for (i = 0; i < 7; i++) {
|
for (i = 0; i < 7; i++) {
|
||||||
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue;
|
if ((!dolfile->text_size[i]) ||
|
||||||
VIDEO_WaitVSync();
|
(dolfile->text_start[i] < 0x100))
|
||||||
ICInvalidateRange ((void *) dolfile->text_start[i],dolfile->text_size[i]);
|
continue;
|
||||||
memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[i]);
|
|
||||||
|
/*printf ("loading text section %u @ 0x%08x "
|
||||||
|
"(0x%08x bytes)\n",
|
||||||
|
i, dolfile->text_start[i],
|
||||||
|
dolfile->text_size[i]);*/
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
|
ICInvalidateRange ((void *) dolfile->text_start[i],
|
||||||
|
dolfile->text_size[i]);
|
||||||
|
memmove ((void *) dolfile->text_start[i],
|
||||||
|
dolstart+dolfile->text_pos[i],
|
||||||
|
dolfile->text_size[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < 11; i++) {
|
for(i = 0; i < 11; i++) {
|
||||||
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue;
|
if ((!dolfile->data_size[i]) ||
|
||||||
VIDEO_WaitVSync();
|
(dolfile->data_start[i] < 0x100))
|
||||||
memmove ((void *) dolfile->data_start[i],dolstart+dolfile->data_pos[i],dolfile->data_size[i]);
|
continue;
|
||||||
DCFlushRangeNoSync ((void *) dolfile->data_start[i],dolfile->data_size[i]);
|
|
||||||
|
/*printf ("loading data section %u @ 0x%08x "
|
||||||
|
"(0x%08x bytes)\n",
|
||||||
|
i, dolfile->data_start[i],
|
||||||
|
dolfile->data_size[i]);*/
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
|
memmove ((void*) dolfile->data_start[i],
|
||||||
|
dolstart+dolfile->data_pos[i],
|
||||||
|
dolfile->data_size[i]);
|
||||||
|
DCFlushRangeNoSync ((void *) dolfile->data_start[i],
|
||||||
|
dolfile->data_size[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf ("clearing bss\n");
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
|
memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
|
||||||
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
|
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
|
||||||
|
|
||||||
if (argv && argv->argvMagic == ARGV_MAGIC) {
|
return dolfile->entry_point;
|
||||||
void *new_argv = (void *)(dolfile->entry_point + 8);
|
|
||||||
memmove(new_argv, argv, sizeof(*argv));
|
|
||||||
DCFlushRange(new_argv, sizeof(*argv));
|
|
||||||
}
|
|
||||||
return dolfile->entry_point;
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user