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

View file

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