1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-18 01:46:47 +00:00

kern: update GetInfo logic for tick count InfoTypes

This commit is contained in:
Michael Scire 2021-09-17 14:57:08 -07:00 committed by SciresM
parent 6cbfaaf835
commit 6407786059
2 changed files with 23 additions and 22 deletions

View file

@ -181,6 +181,9 @@ namespace ams::kern::svc {
/* Verify the input handle is invalid. */ /* Verify the input handle is invalid. */
R_UNLESS(handle == ams::svc::InvalidHandle, svc::ResultInvalidHandle()); R_UNLESS(handle == ams::svc::InvalidHandle, svc::ResultInvalidHandle());
/* Disable dispatch while we get the tick count. */
KScopedDisableDispatch dd;
/* Verify the requested core is valid. */ /* Verify the requested core is valid. */
const bool core_valid = (info_subtype == static_cast<u64>(-1ul)) || (info_subtype == static_cast<u64>(GetCurrentCoreId())); const bool core_valid = (info_subtype == static_cast<u64>(-1ul)) || (info_subtype == static_cast<u64>(GetCurrentCoreId()));
R_UNLESS(core_valid, svc::ResultInvalidCombination()); R_UNLESS(core_valid, svc::ResultInvalidCombination());
@ -223,11 +226,11 @@ namespace ams::kern::svc {
KScopedAutoObject thread = GetCurrentProcess().GetHandleTable().GetObject<KThread>(handle); KScopedAutoObject thread = GetCurrentProcess().GetHandleTable().GetObject<KThread>(handle);
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle()); R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
/* Disable interrupts while we get the tick count. */ /* Disable dispatch while we get the tick count. */
s64 tick_count; KScopedDisableDispatch dd;
{
KScopedInterruptDisable di;
/* Determine the tick count. */
s64 tick_count;
if (info_subtype == static_cast<u64>(-1ul)) { if (info_subtype == static_cast<u64>(-1ul)) {
tick_count = thread->GetCpuTime(); tick_count = thread->GetCpuTime();
if (GetCurrentThreadPointer() == thread.GetPointerUnsafe()) { if (GetCurrentThreadPointer() == thread.GetPointerUnsafe()) {
@ -246,7 +249,6 @@ namespace ams::kern::svc {
tick_count += (cur_tick - prev_switch); tick_count += (cur_tick - prev_switch);
} }
} }
}
/* Set the output. */ /* Set the output. */
*out = tick_count; *out = tick_count;

View file

@ -157,11 +157,10 @@ namespace ams::svc {
InfoType_UsedNonSystemMemorySize = 22, InfoType_UsedNonSystemMemorySize = 22,
InfoType_IsApplication = 23, InfoType_IsApplication = 23,
InfoType_FreeThreadCount = 24, InfoType_FreeThreadCount = 24,
InfoType_ThreadTickCount = 25,
InfoType_MesosphereMeta = 65000, InfoType_MesosphereMeta = 65000,
InfoType_MesosphereCurrentProcess = 65001, InfoType_MesosphereCurrentProcess = 65001,
InfoType_ThreadTickCount = 0xF0000002,
}; };
enum TickCountInfo : u64 { enum TickCountInfo : u64 {