static void system_booted_action(void)
{
	int key_config;
	static int booted = 0;

	if (booted) {
		return;
	}
	
	key_config = sceKernelApplicationType();

	if (key_config == PSP_INIT_KEYCONFIG_GAME ||
			key_config == PSP_INIT_KEYCONFIG_POPS
	   ) {
		SetSpeed(conf.umdisocpuspeed, conf.umdisobusspeed);
	} else if (conf.vshcpuspeed != 0) {
		SetSpeed(conf.vshcpuspeed, conf.vshbusspeed);
	}

	if(need_msstor_speed()) {
		msstor_init();
		printk("%s: msstor cache enabled\n", __func__);
	}

	booted = 1;
	sync_cache();
}
static int need_msstor_speed(void)
{
	int key_config;

	if(conf.msspeed == MSSPEED_NONE)
		return 0;

	if(conf.msspeed == MSSPEED_ALWAYS) {
		return 1;
	}

	key_config = sceKernelApplicationType();

	if(key_config == PSP_INIT_KEYCONFIG_GAME) {
		if(conf.msspeed == MSSPEED_GAME || conf.msspeed == MSSPEED_POP_GAME) {
			return 1;
		}
	} else if(key_config == PSP_INIT_KEYCONFIG_POPS) {
		if(conf.msspeed == MSSPEED_POP || conf.msspeed == MSSPEED_POP_GAME) {
			return 1;
		}
	} else if(key_config == PSP_INIT_KEYCONFIG_VSH) {
		if(conf.msspeed == MSSPEED_VSH || conf.msspeed == MSSPEED_GAME_VSH) {
			return 1;
		}
	}

	return 0;
}
예제 #3
0
파일: init.c 프로젝트: Kaegell/uofw
static u32 sub_05F0(void)
{   
    s32 pspModel;
    s32 apiType;
    s32 intrState;
    
    invoke_init_callback(3);
    patchGames();   
    sceKernelSetDNAS(0);
    
    intrState = sceKernelCpuSuspendIntr();
    
    pspModel = sceKernelGetModel();
    if (pspModel >= PSP_4000) {
        apiType = sceKernelApplicationType();
        switch (apiType) {
        case SCE_INIT_APPLICATION_VSH: 
        case SCE_INIT_APPLICATION_UPDATER: 
        case SCE_INIT_APPLICATION_POPS:
            UtilsForKernel_39FFB756(81);
            break;
        default:
            UtilsForKernel_39FFB756(0);
            break;
        }
    }
    sceKernelCpuResumeIntr(intrState);
    PowerUnlock();
    return SCE_ERROR_OK;
}
예제 #4
0
//prevent umd-cache in homebrew, so we can drain the cache partition.
void patch_umdcache(u32 text_addr)
{
	int ret;

	ret = sceKernelApplicationType();

	if (ret != PSP_INIT_KEYCONFIG_GAME)
		return;

	ret = sctrlKernelBootFrom();

	if (ret != 0x40 && ret != 0x50)
		return;
	
	//kill module start
	MAKE_DUMMY_FUNCTION_RETURN_1(text_addr + g_offs->umdcache_patch.module_start);
}
예제 #5
0
int load_plugins(void)
{
	unsigned int key = sceKernelApplicationType();
	int apitype;

	apitype = sceKernelInitApitype();

	if(rebootex_conf.recovery_mode) {
		return 0;
	}

	if(conf.plugvsh && key == PSP_INIT_KEYCONFIG_VSH && is_vsh_plugins_enabled()) {
		if(psp_model == PSP_GO) {
			load_plugin("ef0:/seplugins/vsh.txt", WAIT_MEMORY_STICK_TIMEOUT);
		}

		// pspgo has smaller wait time
		load_plugin("ms0:/seplugins/vsh.txt", psp_model == PSP_GO ? WAIT_MEMORY_STICK_TIMEOUT / 10 : WAIT_MEMORY_STICK_TIMEOUT);
	} //game mode
	else if(conf.pluggame && ( key == PSP_INIT_KEYCONFIG_GAME || apitype == 0x123) ) {
		if(psp_model == PSP_GO && sctrlKernelBootFrom() == 0x50) {
			load_plugin("ef0:/seplugins/game.txt", WAIT_MEMORY_STICK_TIMEOUT);
		} else {
			load_plugin("ms0:/seplugins/game.txt", WAIT_MEMORY_STICK_TIMEOUT);
		}
	} //ps1 mode
	else if(conf.plugpop && key == PSP_INIT_KEYCONFIG_POPS) {
		if(psp_model == PSP_GO && sctrlKernelBootFrom() == 0x50) {
			load_plugin("ef0:/seplugins/pops.txt", WAIT_MEMORY_STICK_TIMEOUT);
		} else {
			load_plugin("ms0:/seplugins/pops.txt", WAIT_MEMORY_STICK_TIMEOUT);
		}
	}
	
	//return success
	return 0;
}
// 0x00000340
int module_start(SceSize args, void* argp)
{
	SceModule2 *pMod;
	int fd, key_config;
	SEConfig config;
   
	psp_model = sceKernelGetModel();
	psp_fw_version = sceKernelDevkitVersion();
	setup_patch_offset_table(psp_fw_version);

	printk_init("ms0:/LOG_GALAXY.TXT");
	printk("PROGalaxyController started: 0x%08X\n", (uint)psp_fw_version);

	key_config = sceKernelApplicationType();
	sctrlSEGetConfig(&config);
	
	if(config.iso_cache && psp_model != PSP_1000 && key_config == PSP_INIT_KEYCONFIG_GAME) {
		int bufsize;

		bufsize = config.iso_cache_total_size * 1024 * 1024 / config.iso_cache_num;
		
		if((bufsize % 512) != 0) {
			bufsize &= ~(512-1);
		}

		if(bufsize == 0) {
			bufsize = 512;
		}

		infernoCacheSetPolicy(config.iso_cache_policy);
		infernoCacheInit(bufsize, config.iso_cache_num);
	}
	
	g_iso_fn = sctrlSEGetUmdFile();
	pMod = (SceModule2*)sceKernelFindModuleByName("sceThreadManager");

	if(pMod != NULL) {
		// sceKernelCreateThread export
		_sw((u32)&myKernelCreateThread, pMod->text_addr + g_offs->sceKernelCreateThread); 

		// sceKernelStartThread export
		_sw((u32)&myKernelStartThread, pMod->text_addr + g_offs->sceKernelStartThread); 
	} else {
		printk("sceThreadManager cannot be found?!\n");
	}

	clear_cache();

	while( 1 ) {
		fd = sceIoOpen(g_iso_fn, PSP_O_RDONLY, 0);

		if(fd >= 0) {
			break;
		}

		sceKernelDelayThread(10000);
	}

	sceIoClose(fd);
	printk("%s: finished\n", __func__);

	return 0;
}
static int syspatch_module_chain(SceModule2 *mod)
{
	int apitype;

	apitype = sceKernelInitApitype();
	
#ifdef DEBUG
	printk("Starting %s Apitype: 0x%X\n", mod->modname, apitype);
	hook_import_bynid((SceModule*)mod, "KDebugForKernel", 0x84F370BC, printk, 0);
#endif

	if (is_system_booted()) {
		if(0 == strcmp(mod->modname, "sceNpSignupPlugin_Module")) {
			patch_npsignup(mod->text_addr);
			sync_cache();
			goto exit;
		}

		if(0 == strcmp(mod->modname, "sceVshNpSignin_Module")) {
			patch_npsignin(mod->text_addr);
			sync_cache();
			goto exit;
		}

		if(0 == strcmp(mod->modname, "sceNp")) {
			patch_np(mod->text_addr, 9, 90);
			sync_cache();
			goto exit;
		}

		if(conf.usbversion && 0 == strcmp(mod->modname, "sceUSB_Stor_Ms_Driver")) {
			patch_sceUSB_Stor_Ms_Driver((SceModule*)mod);
			goto exit;
		}

		system_booted_action();
		patch_module_for_version_spoof((SceModule*)mod);
		goto exit;
	}

	if(0 == strcmp(mod->modname, "sceLoadExec")) {
		u32 key_config;

		key_config = sceKernelApplicationType();
		
		if (key_config == PSP_INIT_KEYCONFIG_GAME) {
			if(PSP_1000 != psp_model) {
				prepatch_partitions();
				sync_cache();
			}
		}

		goto exit;
	}

	if(0 == strcmp(mod->modname, "sceSYSCON_Driver")) {
		resolve_syscon_driver((SceModule*)mod);
		goto exit;
	}

	// load after lflash
	if(0 == strcmp(mod->modname, "sceDisplay_Service")) {
		load_config();
		patch_sceLoadExec();
		sync_cache();
		goto exit;
	}

	if(0 == strcmp(mod->modname, "sceMediaSync")) {
		patch_sceMediaSync(mod->text_addr);
		sync_cache();
		goto exit;
	}

	if(0 == strcmp(mod->modname, "sceUmdMan_driver")) {
		patch_sceUmdMan_driver((SceModule*)mod);
		sync_cache();
		goto exit;
	}

	if(0 == strcmp(mod->modname, "sceUmdCache_driver")) {
		patch_umdcache(mod->text_addr);
		sync_cache();
		goto exit;
	}

	if(0 == strcmp(mod->modname, "sceWlan_Driver")) {
		patch_sceWlan_Driver(mod->text_addr);
		sync_cache();
		goto exit;
	}

	if(0 == strcmp(mod->modname, "scePower_Service")) {
		patch_scePower_Service(mod->text_addr);
		sync_cache();
		goto exit;
	}

	if(0 == strcmp(mod->modname, "sceMesgLed")) {
		patch_mesgled((SceModule*)mod);
		sync_cache();
		goto exit;
	}

	if (0 == strcmp(mod->modname, "sceImpose_Driver")) {
		patch_sceChkreg();
		disable_PauseGame(mod->text_addr);
		usb_charge();
		sync_cache();
		goto exit;
	} 

	if(psp_model == PSP_GO && 0 == strcmp(mod->modname, "pspMarch33_Driver")) {
		patch_pspMarch33_Driver(mod->text_addr);
		sync_cache();
		goto exit;
	}

#ifdef DEBUG
	if(0 == strcmp(mod->modname, "sceKernelLibrary")) {
		printk_sync();
		printk("printk synchronized\n");
		goto exit;
	}
#endif

exit:
	if (previous)
		return (*previous)(mod);

	return 0;
}
예제 #8
0
파일: init.c 프로젝트: Kaegell/uofw
static u32 sub_0DD0(SceLoadCoreBootInfo *bootInfo)
{
    if (sceKernelIsDevelopmentToolMode() == SCE_FALSE || bootInfo->unk24 != 0)
        return 0;
    return (sceKernelApplicationType() == SCE_INIT_APPLICATION_GAME);
}