Esempio n. 1
0
loadExecReboot(int r0, int r1, int r2, uint32_t hiId, uint32_t loId)
{
	const size_t pathLen = 64;
	wchar_t path[pathLen];
	size_t read;
	P9File f;

	p9FileInit(f);
	swprintf(path, pathLen, L"sdmc:/" FIRM_PATH_FMT, hiId, loId);
	p9Open(f, path, 1);
	p9Read(f, &read, (void *)FIRM_ADDR, FIRM_SIZE);
	p9Close(f);

	p9FileInit(f);
	swprintf(path, pathLen, L"sdmc:/" FIRM_PATCH_PATH_FMT, hiId, loId);
	p9Open(f, path, 1);
	p9Read(f, &read, (void *)PATCH_ADDR, PATCH_SIZE);
	p9Close(f);

	while (p9RecvPxi() != 0x44846);
	svcKernelSetState(SVC_KERNEL_STATE_INIT, hiId, loId,
		SVC_KERNEL_STATE_TITLE_COMPAT);

	if (loId != TID_CTR_NATIVE_FIRM && loId != TID_KTR_NATIVE_FIRM)
		nandSector = 0;

	svcBackdoor((void *)execReboot);
	__builtin_unreachable();
}
Esempio n. 2
0
Result miniSocInit()
{
    if(AtomicPostIncrement(&miniSocRefCount))
        return 0;

    u32 tmp = 0;
    Result ret = 0;
    bool isSocURegistered;

    ret = srvIsServiceRegistered(&isSocURegistered, "soc:U");
    if(ret != 0) goto cleanup;
    if(!isSocURegistered)
    {
        ret = -1;
        goto cleanup;
    }

    ret = srvGetServiceHandle(&SOCU_handle, "soc:U");
    if(ret != 0) goto cleanup;

    ret = svcControlMemory(&tmp, socContextAddr, 0, socContextSize, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE);
    if(ret != 0) goto cleanup;

    socContextAddr = tmp;

    ret = svcCreateMemoryBlock(&socMemhandle, (u32)socContextAddr, socContextSize, 0, 3);
    if(ret != 0) goto cleanup;



    ret = SOCU_Initialize(socMemhandle, socContextSize);
    if(ret != 0) goto cleanup;

    svcKernelSetState(0x10000, 2);
    miniSocEnabled = true;
    return 0;

cleanup:
    AtomicDecrement(&miniSocRefCount);

    if(socMemhandle != 0)
    {
        svcCloseHandle(socMemhandle);
        socMemhandle = 0;
    }

    if(SOCU_handle != 0)
    {
        SOCU_Shutdown();
        svcCloseHandle(SOCU_handle);
        SOCU_handle = 0;
    }

    if(tmp != 0)
        svcControlMemory(&tmp, socContextAddr, socContextAddr, socContextSize, MEMOP_FREE, MEMPERM_DONTCARE);

    return ret;
}
Esempio n. 3
0
Result miniSocExit(void)
{
    if(AtomicDecrement(&miniSocRefCount))
        return 0;

    Result ret = 0;
    u32 tmp;

    svcCloseHandle(socMemhandle);
    socMemhandle = 0;

    ret = SOCU_Shutdown();

    svcCloseHandle(SOCU_handle);
    SOCU_handle = 0;

    svcControlMemory(&tmp, socContextAddr, socContextAddr, socContextSize, MEMOP_FREE, MEMPERM_DONTCARE);
    if(ret == 0)
    {
        svcKernelSetState(0x10000, 2);
        miniSocEnabled = false;
    }
    return ret;
}