Add SDMMC speed info types, and more clock rates (#480)

This commit is contained in:
TuxSH 2021-02-01 14:05:04 +00:00 committed by GitHub
parent 4fdc40228a
commit 75b4d1f563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 20 deletions

View File

@ -5,10 +5,22 @@
#pragma once
#include "svc.h"
#define SYSCLOCK_SOC (16756991)
#define SYSCLOCK_ARM9 (SYSCLOCK_SOC * 8)
#define SYSCLOCK_ARM11 (SYSCLOCK_ARM9 * 2)
#define SYSCLOCK_ARM11_NEW (SYSCLOCK_ARM11 * 3)
///< The external clock rate for the SoC.
#define SYSCLOCK_SOC (16756991u)
///< The base system clock rate (for I2C, NDMA, etc.).
#define SYSCLOCK_SYS (SYSCLOCK_SOC * 2)
///< The base clock rate for the SDMMC controller (and some other peripherals).
#define SYSCLOCK_SDMMC (SYSCLOCK_SYS * 2)
///< The clock rate for the Arm9.
#define SYSCLOCK_ARM9 (SYSCLOCK_SYS * 4)
///< The clock rate for the Arm11 in CTR mode and in \ref svcGetSystemTick.
#define SYSCLOCK_ARM11 (SYSCLOCK_ARM9 * 2)
///< The clock rate for the Arm11 in LGR1 mode.
#define SYSCLOCK_ARM11_LGR1 (SYSCLOCK_ARM11 * 2)
///< The clock rate for the Arm11 in LGR2 mode.
#define SYSCLOCK_ARM11_LGR2 (SYSCLOCK_ARM11 * 3)
///< The highest possible clock rate for the Arm11 on known New 3DS units.
#define SYSCLOCK_ARM11_NEW SYSCLOCK_ARM11_LGR2
#define CPU_TICKS_PER_MSEC (SYSCLOCK_ARM11 / 1000.0)
#define CPU_TICKS_PER_USEC (SYSCLOCK_ARM11 / 1000000.0)

View File

@ -235,6 +235,14 @@ typedef struct
const void* data; ///< Pointer to FS path data.
} FS_Path;
/// SDMC/NAND speed information
typedef struct
{
bool highSpeedModeEnabled; ///< Whether or not High Speed Mode is enabled.
bool usesHighestClockRate; ///< Whether or not a clock divider of 2 is being used.
u16 sdClkCtrl; ///< The value of the SD_CLK_CTRL register.
} FS_SdMmcSpeedInfo;
/// Filesystem archive handle, providing access to a filesystem's contents.
typedef u64 FS_Archive;
@ -467,13 +475,13 @@ Result FSUSER_GetNandCid(u8* out, u32 length);
* @brief Gets the SDMC speed info.
* @param speedInfo Pointer to output the speed info to.
*/
Result FSUSER_GetSdmcSpeedInfo(u32 *speedInfo);
Result FSUSER_GetSdmcSpeedInfo(FS_SdMmcSpeedInfo *speedInfo);
/**
* @brief Gets the NAND speed info.
* @param speedInfo Pointer to output the speed info to.
*/
Result FSUSER_GetNandSpeedInfo(u32 *speedInfo);
Result FSUSER_GetNandSpeedInfo(FS_SdMmcSpeedInfo *speedInfo);
/**
* @brief Gets the SDMC log.

View File

@ -193,7 +193,7 @@ Result FSPXI_CloseArchive(Handle serviceHandle, FSPXI_Archive archive);
/**
* @brief Unknown 0x17. Appears to be an "is archive handle valid" command?
* @param archive Archive handle to check validity of.
* @param out Pointer to output validity to.
* @param out Pointer to output validity to.
*/
Result FSPXI_Unknown0x17(Handle serviceHandle, FSPXI_Archive archive, bool* out);
@ -251,13 +251,13 @@ Result FSPXI_GetNandCid(Handle serviceHandle, void* out, u32 size);
* @brief Gets the SDMC speed info
* @param out Buffer to output the speed info to.
*/
Result FSPXI_GetSdmcSpeedInfo(Handle serviceHandle, u32* out);
Result FSPXI_GetSdmcSpeedInfo(Handle serviceHandle, FS_SdMmcSpeedInfo* out);
/**
* @brief Gets the NAND speed info
* @param out Buffer to output the speed info to.
*/
Result FSPXI_GetNandSpeedInfo(Handle serviceHandle, u32* out);
Result FSPXI_GetNandSpeedInfo(Handle serviceHandle, FS_SdMmcSpeedInfo* out);
/**
* @brief Gets the SDMC log

View File

@ -566,7 +566,7 @@ Result FSUSER_GetNandCid(u8* out, u32 length)
return cmdbuf[1];
}
Result FSUSER_GetSdmcSpeedInfo(u32 *speedInfo)
Result FSUSER_GetSdmcSpeedInfo(FS_SdMmcSpeedInfo *speedInfo)
{
u32 *cmdbuf = getThreadCommandBuffer();
@ -575,12 +575,11 @@ Result FSUSER_GetSdmcSpeedInfo(u32 *speedInfo)
Result ret = 0;
if(R_FAILED(ret = svcSendSyncRequest(fsSession()))) return ret;
if(speedInfo) *speedInfo = cmdbuf[2];
if(speedInfo) memcpy(speedInfo, &cmdbuf[2], sizeof(FS_SdMmcSpeedInfo));
return cmdbuf[1];
}
Result FSUSER_GetNandSpeedInfo(u32 *speedInfo)
Result FSUSER_GetNandSpeedInfo(FS_SdMmcSpeedInfo *speedInfo)
{
u32 *cmdbuf = getThreadCommandBuffer();
@ -589,7 +588,7 @@ Result FSUSER_GetNandSpeedInfo(u32 *speedInfo)
Result ret = 0;
if(R_FAILED(ret = svcSendSyncRequest(fsSession()))) return ret;
if(speedInfo) *speedInfo = cmdbuf[2];
if(speedInfo) memcpy(speedInfo, &cmdbuf[2], sizeof(FS_SdMmcSpeedInfo));
return cmdbuf[1];
}

View File

@ -572,7 +572,7 @@ Result FSPXI_GetNandCid(Handle serviceHandle, void* out, u32 size)
return (Result) cmdbuf[1];
}
Result FSPXI_GetSdmcSpeedInfo(Handle serviceHandle, u32* out)
Result FSPXI_GetSdmcSpeedInfo(Handle serviceHandle, FS_SdMmcSpeedInfo* out)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
@ -581,12 +581,12 @@ Result FSPXI_GetSdmcSpeedInfo(Handle serviceHandle, u32* out)
if(R_FAILED(ret = svcSendSyncRequest(serviceHandle))) return ret;
if(out) *out = cmdbuf[2];
if(out) memcpy(out, &cmdbuf[2], sizeof(FS_SdMmcSpeedInfo));
return (Result) cmdbuf[1];
}
Result FSPXI_GetNandSpeedInfo(Handle serviceHandle, u32* out)
Result FSPXI_GetNandSpeedInfo(Handle serviceHandle, FS_SdMmcSpeedInfo* out)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
@ -595,7 +595,7 @@ Result FSPXI_GetNandSpeedInfo(Handle serviceHandle, u32* out)
if(R_FAILED(ret = svcSendSyncRequest(serviceHandle))) return ret;
if(out) *out = cmdbuf[2];
if(out) memcpy(out, &cmdbuf[2], sizeof(FS_SdMmcSpeedInfo));
return (Result) cmdbuf[1];
}
@ -1084,7 +1084,7 @@ Result FSPXI_GetArchiveResource(Handle serviceHandle, FS_ArchiveResource* archiv
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x43, 1, 0); // 0x00430040
cmdbuf[1] = mediaType;
@ -1179,7 +1179,7 @@ Result FSPXI_ReadSpecialFile(Handle serviceHandle, u32* bytesRead, u64 fileOffse
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x49, 4, 2); // 0x00490102
cmdbuf[1] = 0;
cmdbuf[2] = (u32) fileOffset;