(Wii) forward arguments to loaded DOL files, fixes paths

This commit is contained in:
Toad King 2012-08-06 13:35:14 -04:00
parent fe5a11b051
commit cc52ee9754
4 changed files with 39 additions and 22 deletions

View File

@ -5,6 +5,7 @@
#include <string.h>
#include <gccore.h>
#include <gctypes.h>
#include <ogcsys.h>
#include "../../retroarch_logger.h"
@ -22,7 +23,9 @@ typedef struct _dolheader
uint32_t entry_point;
} dolheader;
uint32_t load_dol_image (void *dolstart)
static char dol_argv_commandline[1024];
uint32_t *load_dol_image (void *dolstart)
{
uint32_t i;
dolheader *dolfile;
@ -35,7 +38,7 @@ uint32_t load_dol_image (void *dolstart)
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100))
continue;
RARCH_LOG("loading text section %u @ 0x%08x (0x%08x bytes)\n",
RARCH_LOG("loading text section %u @ 0x%08x (0x%08x bytes)\n",
i, dolfile->text_start[i], dolfile->text_size[i]);
ICInvalidateRange ((void *) dolfile->text_start[i],
@ -50,13 +53,13 @@ uint32_t load_dol_image (void *dolstart)
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100))
continue;
RARCH_LOG("loading data section %u @ 0x%08x (0x%08x bytes)\n", i,
RARCH_LOG("loading data section %u @ 0x%08x (0x%08x bytes)\n", i,
dolfile->data_start[i], dolfile->data_size[i]);
memmove ((void*) dolfile->data_start[i], dolstart+dolfile->data_pos[i],
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]);
DCFlushRangeNoSync ((void *) dolfile->data_start[i], dolfile->data_size[i]);
}
RARCH_LOG("clearing bss\n");
@ -64,9 +67,20 @@ uint32_t load_dol_image (void *dolstart)
memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
return dolfile->entry_point;
return (uint32_t *) dolfile->entry_point;
}
return 0;
return NULL;
}
// NOTE: this does not update the path to point to the new loading .dol file.
// we only ues it for keeping the current path anyway.
void dol_copy_argv(struct __argv *argv)
{
memcpy(dol_argv_commandline, __system_argv->commandLine, __system_argv->length);
DCFlushRange((void *) dol_argv_commandline, sizeof(dol_argv_commandline));
argv->argvMagic = ARGV_MAGIC;
argv->commandLine = dol_argv_commandline;
argv->length = __system_argv->length;
DCFlushRange((void *) argv, sizeof(struct __argv));
}

View File

@ -24,10 +24,8 @@
#include <gctypes.h>
uint32_t load_dol_image (void *dolstart);
extern void __exception_closeall(void);
extern int32_t __IOS_ShutdownSubSystems(void);
uint32_t *load_dol_image (void *dolstart);
void dol_copy_argv(struct __argv *argv);
#endif

View File

@ -29,6 +29,7 @@
#include <fat.h>
#include <ogc/lwp_threads.h>
#include <ogc/system.h>
#include <gctypes.h>
#include "exec/dol.h"
#endif
@ -87,12 +88,16 @@ void rarch_console_exec(const char *path)
#endif
fatUnmount("carda:");
fatUnmount("cardb:");
void (*ep)() = (void(*)())load_dol_image(mem);
RARCH_LOG("jumping to 0x%08X\n", (uint32_t)ep);
uint32_t *ep = load_dol_image(mem);
if (ep[1] == ARGV_MAGIC)
dol_copy_argv((struct __argv *) &ep[2]);
RARCH_LOG("jumping to 0x%08X\n", (uint32_t) ep);
SYS_ResetSystem(SYS_SHUTDOWN,0,0);
__lwp_thread_stopmultitasking(ep);
__lwp_thread_stopmultitasking((void(*)()) ep);
#else
RARCH_WARN("External loading of executables is not supported for this platform.\n");
#endif

View File

@ -48,11 +48,11 @@ static void find_and_set_first_file(void)
//Last fallback - we'll need to start the first executable file
// we can find in the RetroArch cores directory
char first_file[512];
char first_file[512] = {0};
rarch_manage_libretro_set_first_file(first_file, sizeof(first_file),
LIBRETRO_DIR_PATH, "dol");
if(first_file)
if(first_file[0])
strlcpy(libretro_path, first_file, sizeof(libretro_path));
else
RARCH_ERR("Failed last fallback - RetroArch Salamander will exit.\n");
@ -89,8 +89,8 @@ static void init_settings(void)
if(config_file_exists)
{
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
snprintf(libretro_path, sizeof(libretro_path), tmp_str);
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
snprintf(libretro_path, sizeof(libretro_path), tmp_str);
}
if(!config_file_exists || !strcmp(libretro_path, ""))
@ -111,14 +111,14 @@ static void get_environment_settings(void)
int main(int argc, char *argv[])
{
#ifdef HAVE_LOGGER
logger_init();
#endif
#ifdef HW_RVL
L2Enhance();
#endif
#ifdef HAVE_LOGGER
logger_init();
#endif
fatInitDefault();
getcwd(app_dir, sizeof(app_dir));