diff --git a/libn3ds/include/drivers/mmc/sdmmc.h b/libn3ds/include/drivers/mmc/sdmmc.h index 2101158..d4eaf22 100644 --- a/libn3ds/include/drivers/mmc/sdmmc.h +++ b/libn3ds/include/drivers/mmc/sdmmc.h @@ -51,7 +51,7 @@ enum // SD/MMC device numbers. enum { - SDMMC_DEV_SLOT = 0, // SD card/MMC slot. + SDMMC_DEV_CARD = 0, // SD card/MMC. SDMMC_DEV_eMMC = 1 // Builtin eMMC. }; diff --git a/libn3ds/include/drivers/toshsd_config.h b/libn3ds/include/drivers/toshsd_config.h index ad334c9..8aea6bc 100644 --- a/libn3ds/include/drivers/toshsd_config.h +++ b/libn3ds/include/drivers/toshsd_config.h @@ -29,19 +29,19 @@ // Port 0 is port 0 on controller 1, port 3 is port 1 on controller 2. #ifdef _3DS // This define determines whenever the SD slot is accessible on -// ARM9 or ARM11 when TOSHSD_SLOT_PORT for ARM9 is set to 2. +// ARM9 or ARM11 when TOSHSD_CARD_PORT for ARM9 is set to 2. #define TOSHSD_C2_MAP (0u) // Controller 2 (physical 3) memory mapping. 0=ARM9 0x10007000 or 1=ARM11 0x10100000. #ifdef ARM9 -#define TOSHSD_SLOT_PORT (2u) // Can be on port 0 or 2. 0 always on ARM9. +#define TOSHSD_CARD_PORT (2u) // Can be on port 0 or 2. 0 always on ARM9. #define TOSHSD_eMMC_PORT (1u) // Port 1 only. Do not change. #elif ARM11 -#define TOSHSD_SLOT_PORT (2u) // Port 2 only. Do not change. +#define TOSHSD_CARD_PORT (2u) // Port 2 only. Do not change. #define TOSHSD_eMMC_PORT (3u) // Placeholder. Do not change. Not connected/accessible. #endif // #ifdef ARM9 #elif TWL -#define TOSHSD_SLOT_PORT (0u) +#define TOSHSD_CARD_PORT (0u) #define TOSHSD_eMMC_PORT (1u) #endif // #ifdef _3DS diff --git a/libn3ds/source/drivers/mmc/sdmmc.c b/libn3ds/source/drivers/mmc/sdmmc.c index 296b1c6..49298ea 100644 --- a/libn3ds/source/drivers/mmc/sdmmc.c +++ b/libn3ds/source/drivers/mmc/sdmmc.c @@ -413,7 +413,7 @@ static u32 initTranState(SdmmcDev *const dev, const u8 cardType, const u32 rca) static inline u8 dev2portNum(u8 devNum) { - return (devNum == SDMMC_DEV_eMMC ? TOSHSD_eMMC_PORT : TOSHSD_SLOT_PORT); + return (devNum == SDMMC_DEV_eMMC ? TOSHSD_eMMC_PORT : TOSHSD_CARD_PORT); } // TODO: In many places we also want to check the card's response. diff --git a/libn3ds/source/drivers/toshsd.c b/libn3ds/source/drivers/toshsd.c index 7756eb9..0ac490b 100644 --- a/libn3ds/source/drivers/toshsd.c +++ b/libn3ds/source/drivers/toshsd.c @@ -34,7 +34,7 @@ static void toshsdIsr(UNUSED u32 id) { - Toshsd *const regs = getToshsdRegs(TOSHSD_SLOT_PORT / 2u); + Toshsd *const regs = getToshsdRegs(TOSHSD_CARD_PORT / 2u); regs->sd_status = ~(STATUS_INSERT | STATUS_REMOVE); // TODO: Some kind of event to notify the main loop. } @@ -44,7 +44,7 @@ void TOSHSD_init(void) #if (_3DS && ARM9) // Note: The power bits don't affect regular card detect. Port remapping does. // TODO: Can we switch controllers/ports glitch-free? - const u32 slotPort = (TOSHSD_SLOT_PORT == 2u ? SDMMCCTL_SLOT_TOSHSD3_SEL : SDMMCCTL_SLOT_TOSHSD1_SEL); + const u32 slotPort = (TOSHSD_CARD_PORT == 2u ? SDMMCCTL_SLOT_TOSHSD3_SEL : SDMMCCTL_SLOT_TOSHSD1_SEL); const u32 c2Map = (TOSHSD_C2_MAP == 1u ? SDMMCCTL_TOSHSD3_MAP11 : SDMMCCTL_TOSHSD3_MAP9); getCfg9Regs()->sdmmcctl = slotPort | c2Map | SDMMCCTL_UNK_BIT6; #endif // #if (_3DS && ARM9) @@ -134,12 +134,12 @@ static void setPort(Toshsd *const regs, const ToshsdPort *const port) bool TOSHSD_cardDetected(void) { - return getToshsdRegs(TOSHSD_SLOT_PORT / 2u)->sd_status & STATUS_DETECT; + return getToshsdRegs(TOSHSD_CARD_PORT / 2u)->sd_status & STATUS_DETECT; } bool TOSHSD_cardSliderUnlocked(void) { - return getToshsdRegs(TOSHSD_SLOT_PORT / 2u)->sd_status & STATUS_NO_WRPROT; + return getToshsdRegs(TOSHSD_CARD_PORT / 2u)->sd_status & STATUS_NO_WRPROT; } // TODO: Clock in Hz? diff --git a/libn3ds/thirdparty/fatfs/diskio.c b/libn3ds/thirdparty/fatfs/diskio.c index 2a2ee32..0c8611e 100644 --- a/libn3ds/thirdparty/fatfs/diskio.c +++ b/libn3ds/thirdparty/fatfs/diskio.c @@ -43,7 +43,7 @@ DSTATUS disk_initialize ( { (void)pdrv; - return (SDMMC_init(SDMMC_DEV_SLOT) == RES_OK ? 0u : STA_NOINIT); + return (SDMMC_init(SDMMC_DEV_CARD) == RES_OK ? 0u : STA_NOINIT); } @@ -79,7 +79,7 @@ DRESULT disk_read ( ndmaCh->cnt = NDMA_EN | NDMA_START_TOSHSD3 | NDMA_TCNT_MODE | // TODO: IRQ enable missing? NDMA_BURST(64u / 4) | NDMA_SAD_FIX | NDMA_DAD_INC; - if(SDMMC_readSectors(SDMMC_DEV_SLOT, sector, NULL, blockCount)) + if(SDMMC_readSectors(SDMMC_DEV_CARD, sector, NULL, blockCount)) { ndmaCh->cnt = 0; // Stop DMA on error. return RES_ERROR; @@ -132,7 +132,7 @@ DRESULT disk_write ( ndmaCh->cnt = NDMA_EN | NDMA_START_TOSHSD3 | NDMA_TCNT_MODE | // TODO: IRQ enable missing? NDMA_BURST(64u / 4) | NDMA_SAD_INC | NDMA_DAD_FIX; - if(SDMMC_writeSectors(SDMMC_DEV_SLOT, sector, NULL, blockCount)) + if(SDMMC_writeSectors(SDMMC_DEV_CARD, sector, NULL, blockCount)) { ndmaCh->cnt = 0; // Stop DMA on error. return RES_ERROR; @@ -170,7 +170,7 @@ DRESULT disk_ioctl ( switch(cmd) { case GET_SECTOR_COUNT: - *(DWORD*)buff = SDMMC_getSectors(SDMMC_DEV_SLOT); + *(DWORD*)buff = SDMMC_getSectors(SDMMC_DEV_CARD); break; case GET_SECTOR_SIZE: *(WORD*)buff = 512u;