Пример #1
0
void mcuReboot(void)
{
    flushEntireDCache(); //Ensure that all memory transfers have completed and that the data cache has been flushed

    i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2);
    while(1);
}
Пример #2
0
void launchFirm(FirmwareType firmType, bool loadFromStorage)
{
    //Allow module injection and/or inject 3ds_injector on new NATIVE_FIRMs and LGY FIRMs
    u32 sectionNum;
    if(firmType == NATIVE_FIRM || (loadFromStorage && firmType != SAFE_FIRM && firmType != NATIVE_FIRM1X2X))
    {
        copySection0AndInjectSystemModules(firmType, loadFromStorage);
        sectionNum = 1;
    }
    else sectionNum = 0;

    //Copy FIRM sections to respective memory locations
    for(; sectionNum < 4 && firm->section[sectionNum].size != 0; sectionNum++)
        memcpy(firm->section[sectionNum].address, (u8 *)firm + firm->section[sectionNum].offset, firm->section[sectionNum].size);

    //Determine the ARM11 entry to use
    vu32 *arm11;
    if(ISFIRMLAUNCH) arm11 = (vu32 *)0x1FFFFFFC;
    else
    {
        deinitScreens();
        arm11 = (vu32 *)BRAHMA_ARM11_ENTRY;
    }

    //Set ARM11 kernel entrypoint
    *arm11 = (u32)firm->arm11Entry;

    //Ensure that all memory transfers have completed and that the caches have been flushed
    flushEntireDCache();
    flushEntireICache();

    //Final jump to ARM9 kernel
    ((void (*)())firm->arm9Entry)();
}
Пример #3
0
void mcuPowerOff(void)
{
    if(!isFirmlaunch && ARESCREENSINITIALIZED) clearScreens(false);

    //Ensure that all memory transfers have completed and that the data cache has been flushed
    flushEntireDCache();

    i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 0);
    while(true);
}
Пример #4
0
void mcuReboot(void)
{
    if(!isFirmlaunch && PDN_GPU_CNT != 1) clearScreens(true, true, false);

    //Ensure that all memory transfers have completed and that the data cache has been flushed
    flushEntireDCache();

    i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 1);
    while(true);
}
Пример #5
0
void main(void)
{
    if(f_mount(&fs, "0:", 0) == FR_OK)
    {
        FIL pathFile,
            payload;
        bool foundPayload = false;

        if(f_open(&pathFile, "luma/path.txt", FA_READ) == FR_OK)
        {
            u32 pathSize = f_size(&pathFile);

            if(pathSize > 5 && pathSize < 58)
            {
                char path[pathSize + 1];
                unsigned int read;
                f_read(&pathFile, path, pathSize, &read);
                if(path[pathSize - 1] == 0xA) pathSize--;
                if(path[pathSize - 1] == 0xD) pathSize--;

                if(pathSize > 5 && pathSize < 56 && path[0] == '/' && memcmp(&path[pathSize - 4], ".bin", 4) == 0)
                {
                    path[pathSize] = 0;
                    foundPayload = f_open(&payload, path, FA_READ) == FR_OK;
                }
            }

            f_close(&pathFile);
        }

        if(!foundPayload) foundPayload = f_open(&payload, "arm9loaderhax.bin", FA_READ) == FR_OK;

        if(foundPayload)
        {
            u32 *loaderAddress = (u32 *)0x24FFFF00;
            void *payloadAddress = (void *)0x24F00000;
            u32 payloadSize = f_size(&payload);

            memcpy(loaderAddress, loader_bin, loader_bin_size);
            loaderAddress[1] = payloadSize;

            unsigned int read;
            f_read(&payload, payloadAddress, payloadSize, &read);
            f_close(&payload);

            if((u32)read == payloadSize)
            {
                flushDCacheRange(loaderAddress, loader_bin_size);
                flushICacheRange(loaderAddress, loader_bin_size);

                ((void (*)())loaderAddress)();
            }
        }
    }

    //Ensure that all memory transfers have completed and that the data cache has been flushed
    flushEntireDCache();

    i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 0);
    while(true);
}