Beispiel #1
0
void app_booter_main(void)
{
	void *exeBuffer = (void *) EXECUTABLE_MEM_ADDR;
	u32 exeEntryPointAddress = 0;
	entrypoint exeEntryPoint;

	if (valid_elf_image(exeBuffer) == 1)
		exeEntryPointAddress = load_elf_image(exeBuffer);
	else
		exeEntryPointAddress = load_dol_image(exeBuffer);

	exeEntryPoint = (entrypoint) exeEntryPointAddress;

	if (!exeEntryPoint)
		return;

	if (SYSTEM_ARGV->argvMagic == ARGV_MAGIC)
	{
		void *new_argv = (void *) (exeEntryPointAddress + 8);
		memcpy(new_argv, SYSTEM_ARGV, sizeof(struct __argv));
		sync_before_exec(new_argv, sizeof(struct __argv));
	}

	exeEntryPoint ();
}
Beispiel #2
0
void Reload (void)
{
    if (!GetFileToBoot ())
    {
        // run sm, priiloader on the nand is required
        *(vu32*)0x8132FFFB = 0x50756E65;
        DCFlushRange((void*)0x8132FFFB,4);
        SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
    }

    struct __argv arg;
    memset (&arg, 0, sizeof(struct __argv));

    memmove(ARGS_ADDR, &arg, sizeof(arg));
    DCFlushRange(ARGS_ADDR, sizeof(arg) + arg.length);

    memcpy(BOOTER_ADDR, booter_dol, booter_dol_size);
    DCFlushRange(BOOTER_ADDR, booter_dol_size);

    entrypoint exeEntryPoint;
    exeEntryPoint = (entrypoint) BOOTER_ADDR;

    /* cleaning up and load dol */
    SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
    _CPU_ISR_Disable (cookie);
    __exception_closeall ();
    exeEntryPoint ();
    _CPU_ISR_Restore (cookie);

    exit (0);
}
Beispiel #3
0
int main(int argc, char **argv)
{
	u32 cookie;
	FILE *exeFile = NULL;
	void *exeBuffer          = (void *)EXECUTABLE_MEM_ADDR;
	int exeSize              = 0;
	u32 exeEntryPointAddress = 0;
	entrypoint exeEntryPoint;
	
	/* int videomod */
	InitVideo();
	/* get imagedata */
	u8 * imgdata = GetImageData();
	/* fadein of image */
	for(int i = 0; i < 255; i = i+10)
	{
		if(i>255) i = 255;
		Background_Show(0, 0, 0, imgdata, 0, 1, 1, i);
		Menu_Render();
	}
	
	/* check devices */
	SDCard_Init();
	USBDevice_Init();
	
	char cfgpath[256];
	
	/* Open dol File and check exist */
	sprintf(cfgpath, PATH1);
	exeFile = fopen (cfgpath ,"rb");
	if (exeFile==NULL)
	{
		sprintf(cfgpath, PATH2);
		exeFile = fopen (cfgpath ,"rb");
	}
	if (exeFile==NULL)
	{
		sprintf(cfgpath, PATH3);
		exeFile = fopen (cfgpath ,"rb");
	}
	if (exeFile==NULL)
	{
		sprintf(cfgpath, PATH4);
		exeFile = fopen (cfgpath ,"rb");
	}
	
	if (PACK2)
	{
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH5);
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH6);
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH7);
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH8);
			exeFile = fopen (cfgpath ,"rb");
		}
	}
	
	if (PACK3)
	{
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH9);
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH10);
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH11);
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH12);
			exeFile = fopen (cfgpath ,"rb");
		}
	}
	
	if (PACK4)
	{
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH13);
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH14);
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH15);
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, PATH16);
			exeFile = fopen (cfgpath ,"rb");
		}
	}
	
	// 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);
	}

	fseek (exeFile, 0, SEEK_END);
	exeSize = ftell(exeFile);
	fseek (exeFile, 0, SEEK_SET);

	if(fread (exeBuffer, 1, exeSize, exeFile) != (unsigned int) exeSize)
	{
		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);
	}
	fclose (exeFile);

	/* load entry point */
	struct __argv args;
	bzero(&args, sizeof(args));
	args.argvMagic = ARGV_MAGIC;
	args.length = strlen(cfgpath) + 2;
	args.commandLine = (char*)malloc(args.length);
	if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
	strcpy(args.commandLine, cfgpath);
	args.commandLine[args.length - 1] = '\0';
	args.argc = 1;
	args.argv = &args.commandLine;
	args.endARGV = args.argv + 1;

	int ret = valid_elf_image(exeBuffer);
	if (ret == 1)
		exeEntryPointAddress = load_elf_image(exeBuffer);
	else
		exeEntryPointAddress = load_dol_image(exeBuffer, &args);

	/* fadeout of image */
	for(int i = 255; i > 1; i = i-7)
	{
		if(i < 0) i = 0;
		Background_Show(0, 0, 0, imgdata, 0, 1, 1, i);
		Menu_Render();
	}
	SDCard_deInit();
	USBDevice_deInit();
	StopGX();
	if (exeEntryPointAddress == 0) {
		printf("EntryPointAddress  failed...\n");
        Menu_Render();
        sleep(3);
        fclose (exeFile);
        SDCard_deInit();
        USBDevice_deInit();
        StopGX();
		SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);;
	}
	exeEntryPoint = (entrypoint) exeEntryPointAddress;
	/* cleaning up and load dol */
	SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
	_CPU_ISR_Disable (cookie);
	__exception_closeall ();
	exeEntryPoint ();
	_CPU_ISR_Restore (cookie);
	return 0;
}
Beispiel #4
0
int main(int argc, char **argv)
{
	u32 cookie;
	FILE *exeFile = NULL;
	void *exeBuffer = (void *)EXECUTABLE_MEM_ADDR;
	u32 exeSize = 0;
	u32 exeEntryPointAddress = 0;
	entrypoint exeEntryPoint;
	__exception_setreload(0);

	IOS_ReloadIOS(58);

	/* int videomod */
	InitVideo();
	/* get imagedata */
	u8 * imgdata = GetImageData();
	fadein(imgdata);
	/* check devices */
	SDCard_Init();
	USBDevice_Init();

	char cfgpath[256];
	bool result = false;

	sprintf(cfgpath, "sd:/config/SaveGame_Manager_GX/SaveGame_Manager_GX.cfg");
	result = cfg_parsefile(cfgpath, &cfg_set);
	if(!result) //no cfg-File on SD: try USB:
	{
		sprintf(cfgpath, "usb:config/SaveGame_Manager_GX/SaveGame_Manager_GX.cfg");
		result = cfg_parsefile(cfgpath, &cfg_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 */
		sprintf(cfgpath, "sd:/apps/SaveGame_Manager_GX/boot.dol");
		exeFile = fopen (cfgpath ,"rb");
		if (exeFile==NULL)
		{
			sprintf(cfgpath, "sd:/apps/SaveGame_Manager_GX/boot.elf");
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, "usb:/apps/SaveGame_Manager_GX/boot.dol");
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, "usb:/apps/SaveGame_Manager_GX/boot.elf");
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, "sd:/apps/SaveGameManagerGX/boot.dol");
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, "sd:/apps/SaveGameManagerGX/boot.elf");
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, "usb:/apps/SaveGameManagerGX/boot.dol");
			exeFile = fopen (cfgpath ,"rb");
		}
		if (exeFile==NULL)
		{
			sprintf(cfgpath, "usb:/apps/SaveGameManagerGX/boot.elf");
			exeFile = fopen (cfgpath ,"rb");
		}
		// if nothing found exiting
		if (exeFile==NULL)
		{
            fadeout(imgdata);
            fclose (exeFile);
            SDCard_deInit();
            USBDevice_deInit();
            StopGX();
            free(imgdata);
			SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
		}
	}

	fseek (exeFile, 0, SEEK_END);
	exeSize = ftell(exeFile);
	rewind (exeFile);

	if(fread (exeBuffer, 1, exeSize, exeFile) != exeSize)
	{
		fadeout(imgdata);
        fclose (exeFile);
        SDCard_deInit();
        USBDevice_deInit();
        StopGX();
        free(imgdata);
		SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
	}
	fclose (exeFile);

	/* load entry point */
	struct __argv args;
	bzero(&args, sizeof(args));
	args.argvMagic = ARGV_MAGIC;
	args.length = strlen(cfgpath) + 2;
	args.commandLine = (char*)malloc(args.length);
	if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
	strcpy(args.commandLine, cfgpath);
	args.commandLine[args.length - 1] = '\0';
	args.argc = 1;
	args.argv = &args.commandLine;
	args.endARGV = args.argv + 1;

	u8 * appboot_buff = (u8 *) malloc(app_booter_dol_size);
	if(!appboot_buff)
	{
		fadeout(imgdata);
        SDCard_deInit();
        USBDevice_deInit();
        StopGX();
        free(imgdata);
		SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
	}

    memcpy(appboot_buff, app_booter_dol, app_booter_dol_size);

	exeEntryPointAddress = load_dol_image(appboot_buff, &args);

    if(appboot_buff)
        free(appboot_buff);

	fadeout(imgdata);
	SDCard_deInit();
	USBDevice_deInit();
	StopGX();
	free(imgdata);

	if (exeEntryPointAddress == 0)
	{
		SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
	}

	exeEntryPoint = (entrypoint) exeEntryPointAddress;
	/* cleaning up and load dol */
	SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
	_CPU_ISR_Disable (cookie);
	__exception_closeall ();
	exeEntryPoint ();
	_CPU_ISR_Restore (cookie);
	return 0;
}