Forwarder changes:

*Fixed Codedumps from Preload
*Fixed USB not working
*Changed back to old LoadMii dolloader (which is working with preloader too now)
This commit is contained in:
dimok321 2009-06-15 23:11:36 +00:00
parent 02d53a5e09
commit 124c3f05ed
4 changed files with 108 additions and 119 deletions

View File

@ -8,7 +8,7 @@
#include "cfg.h" #include "cfg.h"
char update_path[150]=""; char update_path[150];
static char *cfg_name, *cfg_val; static char *cfg_name, *cfg_val;

View File

@ -1,74 +1,54 @@
// this code was contributed by shagkur of the devkitpro team, thx! #include <malloc.h>
#include <stdio.h>
#include <stdio.h> #include <stdlib.h>
#include <string.h> #include <ogc/machine/processor.h>
#include <gccore.h>
#include <gccore.h> #include <dirent.h>
#include <ogcsys.h> #include <string.h>
typedef struct _dolheader { #include "dolloader.h"
u32 text_pos[7];
u32 data_pos[11]; typedef struct _dolheader {
u32 text_start[7]; u32 text_pos[7];
u32 data_start[11]; u32 data_pos[11];
u32 text_size[7]; u32 text_start[7];
u32 data_size[11]; u32 data_start[11];
u32 bss_start; u32 text_size[7];
u32 bss_size; u32 data_size[11];
u32 entry_point; u32 bss_start;
} dolheader; u32 bss_size;
u32 entry_point;
u32 load_dol_image (void *dolstart) { } dolheader;
u32 i;
dolheader *dolfile; u32 load_dol_image (void *dolstart, struct __argv *argv) {
u32 i;
if (dolstart) { dolheader *dolfile;
dolfile = (dolheader *) dolstart;
for (i = 0; i < 7; i++) { if (dolstart) {
if ((!dolfile->text_size[i]) || dolfile = (dolheader *) dolstart;
(dolfile->text_start[i] < 0x100)) for (i = 0; i < 7; i++) {
continue; if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue;
VIDEO_WaitVSync();
/*printf ("loading text section %u @ 0x%08x " ICInvalidateRange ((void *) dolfile->text_start[i],dolfile->text_size[i]);
"(0x%08x bytes)\n", memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[i]);
i, dolfile->text_start[i], }
dolfile->text_size[i]);*/
VIDEO_WaitVSync(); for(i = 0; i < 11; i++) {
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue;
ICInvalidateRange ((void *) dolfile->text_start[i], VIDEO_WaitVSync();
dolfile->text_size[i]); memmove ((void *) dolfile->data_start[i],dolstart+dolfile->data_pos[i],dolfile->data_size[i]);
memmove ((void *) dolfile->text_start[i], DCFlushRangeNoSync ((void *) dolfile->data_start[i],dolfile->data_size[i]);
dolstart+dolfile->text_pos[i], }
dolfile->text_size[i]);
} memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
for(i = 0; i < 11; i++) {
if ((!dolfile->data_size[i]) || if (argv && argv->argvMagic == ARGV_MAGIC) {
(dolfile->data_start[i] < 0x100)) void *new_argv = (void *)(dolfile->entry_point + 8);
continue; memmove(new_argv, argv, sizeof(*argv));
DCFlushRange(new_argv, sizeof(*argv));
/*printf ("loading data section %u @ 0x%08x " }
"(0x%08x bytes)\n", return dolfile->entry_point;
i, dolfile->data_start[i], }
dolfile->data_size[i]);*/ return 0;
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);
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
return dolfile->entry_point;
}
return 0;
}

View File

@ -1,8 +1,6 @@
#ifndef _DOLLOADER_H_ #ifndef _DOLLOADER_H_
#define _DOLLOADER_H_ #define _DOLLOADER_H_
#include <wiiuse/wpad.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
@ -12,23 +10,9 @@ extern "C"
#define EXECUTABLE_MEM_ADDR 0x92000000 #define EXECUTABLE_MEM_ADDR 0x92000000
/* dol header */ /* dol header */
extern void __exception_closeall(); extern void __exception_closeall();
typedef void (*entrypoint) (void); typedef void (*entrypoint) (void);
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, struct __argv *argv); u32 load_dol_image (void *dolstart, struct __argv *argv);

View File

@ -25,13 +25,10 @@
*/ */
#include <gccore.h> #include <gccore.h>
#include <wiiuse/wpad.h>
#include <fat.h>
#include <sdcard/wiisd_io.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <ogc/machine/processor.h> #include <ogc/machine/processor.h>
#include "pngu/pngu.h" #include "pngu/pngu.h"
@ -43,8 +40,8 @@
#include "fatmounter.h" #include "fatmounter.h"
PNGUPROP imgProp; static PNGUPROP imgProp;
IMGCTX ctx; static IMGCTX ctx;
u8 * GetImageData(void) { u8 * GetImageData(void) {
@ -108,49 +105,65 @@ int main(int argc, char **argv)
/* check devices */ /* check devices */
SDCard_Init(); SDCard_Init();
USBDevice_Init(); USBDevice_Init();
char cfgpath[256]; char cfgpath[256];
bool result = false;
sprintf(cfgpath, "SD:/config/GXGlobal.cfg"); sprintf(cfgpath, "SD:/config/GXGlobal.cfg");
if(!cfg_parsefile(cfgpath, &cfg_set)) //no cfg-File on SD: try USB: result = cfg_parsefile(cfgpath, &cfg_set);
if(!result) //no cfg-File on SD: try USB:
{ {
sprintf(cfgpath, "USB:/config/GXGlobal.cfg"); sprintf(cfgpath, "USB:/config/GXGlobal.cfg");
cfg_parsefile(cfgpath, &cfg_set); result = cfg_parsefile(cfgpath, &cfg_set);
} }
if(update_path[0] == '\0') // non cfg-File loaded or update_path not set
if(result)
{
sprintf(cfgpath, "%sboot.dol", update_path);
/* Open dol File and check exist */
exeFile = fopen (cfgpath, "rb");
if (exeFile==NULL)
{
sprintf(cfgpath, "%sboot.elf", update_path);
exeFile = fopen (cfgpath,"rb");
}
if (exeFile==NULL)
result = false;
else
result = true;
}
if(!result) // non cfg-File loaded or update_path not set
{ {
/* Open dol File and check exist */ /* Open dol File and check exist */
strcpy(cfgpath, "SD:/apps/usbloader_gx/boot.dol"); sprintf(cfgpath, "SD:/apps/usbloader_gx/boot.dol");
exeFile = fopen (cfgpath ,"rb"); exeFile = fopen (cfgpath ,"rb");
if (exeFile==NULL) if (exeFile==NULL)
{ {
strcpy(cfgpath, "SD:/apps/usbloader_gx/boot.elf"); sprintf(cfgpath, "SD:/apps/usbloader_gx/boot.elf");
exeFile = fopen (cfgpath ,"rb"); exeFile = fopen (cfgpath ,"rb");
} }
if (exeFile==NULL) if (exeFile==NULL)
{ {
strcpy(cfgpath, "USB:/apps/usbloader_gx/boot.dol"); sprintf(cfgpath, "USB:/apps/usbloader_gx/boot.dol");
exeFile = fopen (cfgpath ,"rb"); exeFile = fopen (cfgpath ,"rb");
} }
if (exeFile==NULL) if (exeFile==NULL)
{ {
strcpy(cfgpath, "USB:/apps/usbloader_gx/boot.elf"); sprintf(cfgpath, "USB:/apps/usbloader_gx/boot.elf");
exeFile = fopen (cfgpath ,"rb"); exeFile = fopen (cfgpath ,"rb");
} }
if (exeFile==NULL) // if nothing found exiting
if (exeFile==NULL) {
printf("\n\n\t\tCan't find DOL File...\n");
Menu_Render();
sleep(3);
fclose (exeFile);
SDCard_deInit();
USBDevice_deInit();
StopGX();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
else
{
sprintf(cfgpath, "%sboot.dol", update_path);
/* Open dol File and check exist */
exeFile = fopen (cfgpath, "rb");
if (exeFile==NULL)
{
sprintf(cfgpath, "%sboot.elf", update_path);
exeFile = fopen (cfgpath,"rb");
} }
if (exeFile==NULL)
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
fseek (exeFile, 0, SEEK_END); fseek (exeFile, 0, SEEK_END);
@ -159,7 +172,13 @@ int main(int argc, char **argv)
if(fread (exeBuffer, 1, exeSize, exeFile) != (unsigned int) exeSize) if(fread (exeBuffer, 1, exeSize, exeFile) != (unsigned int) exeSize)
{ {
printf("Can't open DOL File...\n"); printf("\n\n\t\tCan't open DOL File...\n");
Menu_Render();
fclose (exeFile);
sleep(3);
SDCard_deInit();
USBDevice_deInit();
StopGX();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
fclose (exeFile); fclose (exeFile);
@ -172,7 +191,7 @@ int main(int argc, char **argv)
args.commandLine = (char*)malloc(args.length); args.commandLine = (char*)malloc(args.length);
if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
strcpy(args.commandLine, cfgpath); strcpy(args.commandLine, cfgpath);
args.commandLine[args.length - 1] = '\x00'; args.commandLine[args.length - 1] = '\0';
args.argc = 1; args.argc = 1;
args.argv = &args.commandLine; args.argv = &args.commandLine;
args.endARGV = args.argv + 1; args.endARGV = args.argv + 1;
@ -195,6 +214,12 @@ int main(int argc, char **argv)
StopGX(); StopGX();
if (exeEntryPointAddress == 0) { if (exeEntryPointAddress == 0) {
printf("EntryPointAddress failed...\n"); printf("EntryPointAddress failed...\n");
Menu_Render();
sleep(3);
fclose (exeFile);
SDCard_deInit();
USBDevice_deInit();
StopGX();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);; SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);;
} }
exeEntryPoint = (entrypoint) exeEntryPointAddress; exeEntryPoint = (entrypoint) exeEntryPointAddress;