mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
kern: update GetInfo logic for tick count InfoTypes
This commit is contained in:
parent
6cbfaaf835
commit
6407786059
2 changed files with 23 additions and 22 deletions
|
@ -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,28 +226,27 @@ 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. */
|
||||||
|
KScopedDisableDispatch dd;
|
||||||
|
|
||||||
|
/* Determine the tick count. */
|
||||||
s64 tick_count;
|
s64 tick_count;
|
||||||
{
|
if (info_subtype == static_cast<u64>(-1ul)) {
|
||||||
KScopedInterruptDisable di;
|
tick_count = thread->GetCpuTime();
|
||||||
|
if (GetCurrentThreadPointer() == thread.GetPointerUnsafe()) {
|
||||||
|
const s64 cur_tick = KHardwareTimer::GetTick();
|
||||||
|
const s64 prev_switch = Kernel::GetScheduler().GetLastContextSwitchTime();
|
||||||
|
tick_count += (cur_tick - prev_switch);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const s32 phys_core = cpu::VirtualToPhysicalCoreMap[info_subtype];
|
||||||
|
MESOSPHERE_ABORT_UNLESS(phys_core < static_cast<s32>(cpu::NumCores));
|
||||||
|
|
||||||
if (info_subtype == static_cast<u64>(-1ul)) {
|
tick_count = thread->GetCpuTime(phys_core);
|
||||||
tick_count = thread->GetCpuTime();
|
if (GetCurrentThreadPointer() == thread.GetPointerUnsafe() && phys_core == GetCurrentCoreId()) {
|
||||||
if (GetCurrentThreadPointer() == thread.GetPointerUnsafe()) {
|
const s64 cur_tick = KHardwareTimer::GetTick();
|
||||||
const s64 cur_tick = KHardwareTimer::GetTick();
|
const s64 prev_switch = Kernel::GetScheduler().GetLastContextSwitchTime();
|
||||||
const s64 prev_switch = Kernel::GetScheduler().GetLastContextSwitchTime();
|
tick_count += (cur_tick - prev_switch);
|
||||||
tick_count += (cur_tick - prev_switch);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const s32 phys_core = cpu::VirtualToPhysicalCoreMap[info_subtype];
|
|
||||||
MESOSPHERE_ABORT_UNLESS(phys_core < static_cast<s32>(cpu::NumCores));
|
|
||||||
|
|
||||||
tick_count = thread->GetCpuTime(phys_core);
|
|
||||||
if (GetCurrentThreadPointer() == thread.GetPointerUnsafe() && phys_core == GetCurrentCoreId()) {
|
|
||||||
const s64 cur_tick = KHardwareTimer::GetTick();
|
|
||||||
const s64 prev_switch = Kernel::GetScheduler().GetLastContextSwitchTime();
|
|
||||||
tick_count += (cur_tick - prev_switch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue