Beispiel #1
0
DSTATUS disk_initialize (
    BYTE pdrv               /* Physical drive nmuber (0..) */
)
{
    sdmmc_sdcard_init();
    return RES_OK;
}
Beispiel #2
0
//---------------------------------------------------------------------------------
void sdmmcValueHandler(u32 value, void* user_data) {
//---------------------------------------------------------------------------------
	int result;
	
	switch(value) {

	case SDMMC_HAVE_SD:
		result = sdmmc_read16(REG_SDSTATUS0);
		fifoSendValue32(FIFO_SDMMC, result);
		break;

	case SDMMC_SD_START:
		if (sdmmc_read16(REG_SDSTATUS0) == 0) {
			result = 1;
		} else {
			sdmmc_controller_init();
			result = sdmmc_sdcard_init();
		}
		fifoSendValue32(FIFO_SDMMC, result);
		break;

	case SDMMC_SD_IS_INSERTED:
		result = sdmmc_cardinserted();
		fifoSendValue32(FIFO_SDMMC, result);
		break;

	case SDMMC_SD_STOP:
		break;

	}
}
Beispiel #3
0
int main()
{
	// Initialize sdcard and nand
	*(u32*)0x10000020 = 0;
    *(u32*)0x10000020 = 0x340;
	sdmmc_sdcard_init();
	sdmmc_nand_readsectors(0x5C000, 0x20, (u8*)0x08006000);
	
	// Jump to secondary payload
	((void (*)())0x08006000)();
    return 0;
}
void main(void)
{
    initScreens();
    sdmmc_sdcard_init();

    //Determine if booting with A9LH
    u32 a9lhBoot = !PDN_SPI_CNT;
    //Detect the console being used
    console = PDN_MPCORE_CFG == 7;

    drawString(TITLE, 10, 10, COLOR_TITLE);
    posY = drawString("Thanks to delebile, #cakey and StandardBus", 10, 40, COLOR_WHITE);
    posY = drawString(a9lhBoot ? "Press SELECT to update ShadowNAND" : "Press SELECT for a full install", 10, posY + SPACING_Y, COLOR_WHITE);
    posY = drawString("Press any other button to shutdown", 10, posY, COLOR_WHITE);

    u32 pressed = waitInput();
    if(pressed == BUTTON_SELECT) installer(a9lhBoot);

    shutdown(0, NULL);
}
Beispiel #5
0
int mount() {
    uint8_t i;
    uint32_t temp;
    int8_t partition;

    sdmmc_controller_init();
    temp = sdmmc_sdcard_init() ;
    if (sdmmc_sdcard_readsectors(0,1,(void*)&sect)) return FAT_ERR_SDREAD; // Error reading MBR
    else {
        temp=sect[510] + (sect[511]<<8);
        if(temp!=0xAA55) return FAT_ERR_MBR; // Check failed
        else {
            partition=-1;
            for(i=0; i<4; i++) { // Max four partition to check
                switch (sect[450+i*16]) { // Partition type
                case 0x06:  // FAT 16 CHS
                    temp=sect[447+i*16]*63+sect[448+i*16]-1;
                    if ((partition==-1) && temp) {
                        partition=i;
                        fat.LBA_Begin=temp;
                        fat.FAT_RecordLen=16;
                    }
                    break;
                case 0x0B: // FAT 32 CHS
                    temp=sect[447+i*16]*63+sect[448+i*16]-1;
                    if ((partition==-1) && temp) {
                        partition=i;
                        fat.LBA_Begin=temp;
                        fat.FAT_RecordLen=32;
                    }
                    break;
                case 0x0C: //FAT 32 LBA
                    temp=sect[454+i*16]+(sect[455+i*16]<<8)+(sect[456+i*16]<<16)+(sect[457+i*16]<<24);
                    if ((partition==-1) && temp) {
                        partition=i;
                        fat.LBA_Begin=temp;
                        fat.FAT_RecordLen=32;
                    }
                    break;
                case 0x0E: // FAT 16 LBA
                    temp=sect[454+i*16]+(sect[455+i*16]<<8)+(sect[456+i*16]<<16)+(sect[457+i*16]<<24);
                    if ((partition==-1) && temp) {
                        partition=i;
                        fat.LBA_Begin=temp;
                        fat.FAT_RecordLen=16;
                    }
                    break;
                default:
                    break;
                }
                if (partition==-1) return FAT_ERR_PARTITION; // No valid partition found
                else {
                    if (sdmmc_sdcard_readsectors(fat.LBA_Begin,1,(void*)&sect)) return FAT_ERR_SDREAD; // Error reading FAT ID
                    else {
                        temp=sect[510]+(sect[511]<<8);
                        if(temp!=0xAA55) return FAT_ERR_FATID; // Check failed
                        else {
                            fat.BPB_BytsPerSec=sect[11]+(sect[12]<<8);
                            fat.BPB_SecPerClus=sect[13];
                            fat.BPB_RsvdSecCnt=sect[14]+(sect[15]<<8);
                            fat.BPB_NumFATs=sect[16];
                            fat.BPB_RootDirEnt=sect[17] + (sect[18]<<8);
                            if (fat.FAT_RecordLen==16) {
                                fat.BPB_RootDirEnt=sect[17] + (sect[18]<<8);
                                fat.BPB_FATS=sect[22]+(sect[23]<<8);
                                fat.BPB_RootClus=2;
                            } else {
                                fat.BPB_RootDirEnt=0;
                                fat.BPB_FATS=sect[36]+(sect[37]<<8)+(sect[38]<<16)+(sect[39]<<24);
                                fat.BPB_RootClus=sect[44]+(sect[45]<<8)+(sect[46]<<16)+(sect[47]<<24);
                            }
                            curfatsect=fat_begin_lba(fat);
                            if (sdmmc_sdcard_readsectors(curfatsect,1,(void*)&fatsect)) return -1;
                            rootdirsect = lba_addr(fat.BPB_RootClus);
                            return changedir("\\");
                        }
                    }
                }
            }
        }
    }
}