示例#1
0
文件: loader.c 项目: Rolen47/prxpatch
int load_quest_index() {
    mib_table = NULL;
    mib_elems = 0;
    k1 = pspSdkSetK1(0);
    model_go = sceKernelGetModel() == 4 ? 1 : 0;
    strcpy(filename, "xxx:/mhp3rd/quest/mib_id.dat");
    SET_DEVICENAME(filename, model_go);
    kprintf("trying to open %s\n", filename);
    SceUID fd = sceIoOpen(filename, PSP_O_RDONLY, 0777);
    if(fd < 0) {
        kprintf("Cannot find mib_id.dat\n");
        pspSdkSetK1(k1);
        return fd;
    }
    SceSize size = (SceSize)sceIoLseek(fd, 0, PSP_SEEK_END);
    sceIoLseek(fd, 0, PSP_SEEK_SET);
    index_id = sceKernelAllocPartitionMemory(PSP_MEMORY_PARTITION_KERNEL, "mhp3mib", PSP_SMEM_High, size, NULL);
    if(index_id >= 0) {
        mib_table = sceKernelGetBlockHeadAddr(index_id);
        sceIoRead(fd, mib_table, size);
        mib_elems = size / (sizeof(u32) * 2);
        quest_number = mib_table + mib_elems;
        kprintf("index size: %i bytes, entries: %i\n", size, index_elems);
    } else {
        kprintf("failed to allocate memory for table\n");
    }
    sceIoClose(fd);
    pspSdkSetK1(k1);
    return 0;
}
示例#2
0
文件: memoryop.c 项目: Kaegell/uofw
void MemoryProtectInit(u32 size, u32 extSize)
{
    if (sceKernelGetModel() == 0 && sceKernelDipsw(10) == 0 && sceKernelDipsw(12) == 0) // A4B8
        HW(0xBC100040) = (HW(0xBC100040) & 0xFFFFFFFC) | 0x1;
    else {
        // A2E8
        HW(0xBC100040) = (HW(0xBC100040) & 0xFFFFFFFC) | 0x2;
    }
    // A2F8
    if (size > 0x800000)
        size = 0x800000;
    vs32 *ptr = (s32*)0xBC000000;
    // A334
    while (size > 0x001FFFFF) {
        size -= 0x200000;
        *(ptr++) = 0xCCCCCCCC;
    }
    // A348
    if (size != 0) {
        u32 flag = 0xCCCCCCCC;
        // A36C
        s32 i;
        for (i = (size >> 18) * 4; i < 32; i += 4)
            flag |= (0xF << i);

        // A380
        *(ptr++) = flag;
    }
示例#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
void saveSettingsConfig() {
  // Save settings config file
  writeConfig("ux0:VitaShell/settings.txt", settings_entries, sizeof(settings_entries) / sizeof(ConfigEntry));

  if (sceKernelGetModel() == SCE_KERNEL_MODEL_VITATV) {
    vitashell_config.select_button = SELECT_BUTTON_MODE_FTP;
  }
}
示例#5
0
int initPatches( void )
{
	getDevkitVersion = ( void * )findProc( "sceSystemMemoryManager", "SysMemUserForUser", 0x3FC9AE6A );
	fw_version = getDevkitVersion();
	model = sceKernelGetModel();
	//Disable slim specific patches
	model = PSP_MODEL_STANDARD;
	return fw_version;
}
示例#6
0
int main_thread(SceSize args, void *argp)
{
	int exit = 0, init_key = 0, model = 0, light = 0;
	SceCtrlData pad;
	sceCtrlPeekBufferPositive(&pad, 1);

	if(pad.Buttons & PSP_CTRL_LTRIGGER)
	{
		exit = 1;
	}
	else if(pad.Buttons & PSP_CTRL_RTRIGGER)
	{
		light = 1;
	}

	if(!exit)
	{
		init_key = sceKernelInitKeyConfig();

		if(init_key == PSP_INIT_KEYCONFIG_VSH) // VSH MODE SPOTTED
		{
			loadStartModuleWithArgs("ms0:/seplugins/cfe/cfe_vsh.prx", 1, 0, NULL);
		}
		else
		{
			model = sceKernelGetModel();

			if(model == PSP_MODEL_SLIM_AND_LITE) // PSP SLIM SPOTTED
			{
				if(sceKernelInitApitype() == PSP_INIT_APITYPE_DISC) 
				{
					if(!light) loadStartModuleWithArgs("ms0:/seplugins/cfe/cfe_game.prx", 8, 0, NULL);
						else loadStartModuleWithArgs("ms0:/seplugins/cfe/cfe_light.prx", 1, 0, NULL);
				}
				else
				{
					loadStartModuleWithArgs("ms0:/seplugins/cfe/cfe_light.prx", 1, 0, NULL);
				}
			}
			else // PSP FAT SPOTTED
			{
				loadStartModuleWithArgs("ms0:/seplugins/cfe/cfe_light.prx", 1, 0, NULL);
			}
		}
	}

	sceKernelStopUnloadSelfModule(0, NULL, NULL, NULL);
	return 0;
}
示例#7
0
int _choose_alloc(int size)
{
	int free_kernel=sceKernelPartitionMaxFreeMemSize(1),free_user=sceKernelPartitionMaxFreeMemSize(6);
	
 	if(free_kernel>size+10*1024){
		if(free_user>size){
			if(usbinit || free_kernel>size+300*1024) return (free_kernel>free_user ? 6 : 1);
			else return 6;
		}
		else return 1;
	}
	if(free_user>size) return 6;
	else if(sceKernelGetModel() && sceKernelPartitionMaxFreeMemSize(8)>size) return 8;
	else return 0;
}
示例#8
0
int module_start(SceSize args, void* argp)
{
	char keypath[128];
	int ret;
	SceIoStat stat;

	psp_fw_version = sceKernelDevkitVersion();
	setup_patch_offset_table(psp_fw_version);
	psp_model = sceKernelGetModel();
	memset(&conf, 0, sizeof(conf));
	sctrlSEGetConfig(&conf);
	printk_init("ms0:/popcorn.txt");
	printk("Popcorn: init_file = %s psp_fw_version = 0x%08X psp_model = %d\n", sceKernelInitFileName(), (uint)psp_fw_version, (int)psp_model);

	get_keypath(keypath, sizeof(keypath));
	ret = sceIoGetstat(keypath, &stat);
	g_keys_bin_found = 0;

	if(ret == 0) {
		ret = load_key(keypath, g_keys, sizeof(g_keys));

		if(ret == 0) {
			g_keys_bin_found = 1;
			printk("keys.bin found\n");
		}
	}

	g_is_custom_ps1 = is_custom_ps1();
	g_icon0_status = get_icon0_status();

	if(g_is_custom_ps1) {
		setup_psx_fw_version(psp_fw_version);
	}

	g_previous = sctrlHENSetStartModuleHandler(&popcorn_patch_chain);
	patch_scePops_Manager();
	sync_cache();
	
	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;
}
示例#10
0
int getHardwareModel()
{
    return sceKernelGetModel();
}
示例#11
0
文件: led.c 项目: esxgx/uofw
int sceLedInit(void)
{    
    int i;
    memset(&leds, 0, 0xF0);
    g_00000F40 = 2;
    leds[LED_TYPE_MS].gpioPort = 6;
    leds[LED_TYPE_MS].unk2 = 0;
    leds[LED_TYPE_WLAN].gpioPort = 7;
    leds[LED_TYPE_WLAN].unk2 = 1;
    
    int model = sceKernelGetModel();
    if((model - 1 < 2) || model == 4)
    {
        leds[LED_TYPE_WLAN].unk1 = 1;
    }
    if(((model - 4) < 2) || model == 7 || model == 9)
    {
        //loc_0000022C
        leds[LED_TYPE_BT].gpioPort = 24;
        leds[LED_TYPE_BT].unk2 = 3;
        if(model == 4)
            leds[LED_TYPE_BT].unk1 = 1;
        g_00000F40 = 3;
    }

    if(g_00000F40 >= 0)
    {
        for(i = 0; i < g_00000F40; i++)
        {
            //loc_000000D4
            if(sceGpioGetPortMode(leds[i].gpioPort) == 2)
            {
                //loc_00000210
                sceGpioSetPortMode(leds[i].gpioPort, 0);
                if(leds[i].unk1 == 0)
                {
                    //loc_000001AC
                    sceGpioPortClear(1 << leds[i].gpioPort);
                    continue;
                }
            }
            else if(i == LED_TYPE_BT)
            {
                //loc_000001BC
                int gpioPort = sceGpioPortRead();
                int btStatus = sceSysconGetBtPowerStatus();
                
                if(((btStatus == 0) ? 0 : (((gpioPort >> leds[i].gpioPort) & 1) ^ leds[i].unk1)) != 0)
                {
                    //loc_000001FC
                    sceLedSetMode(2, 1, 0);
                    continue;
                }
                else
                {
                    if(leds[i].unk1 == 0)
                    {
                        //loc_000001AC
                         sceGpioPortClear(1 << leds[i].gpioPort); //since i is 2 then this is 160, but I wanted it to be uniform
                         continue;
                    }
                }
            }
            else
            {
                if(leds[i].unk1 == 0)