diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_scheduler.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_scheduler.hpp index c1048ef..f555f78 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_scheduler.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_scheduler.hpp @@ -70,6 +70,11 @@ NOINLINE void Initialize(KThread *idle_thread); NOINLINE void Activate(); + ALWAYS_INLINE void SetInterruptTaskRunnable() { + this->state.interrupt_task_thread_runnable = true; + this->state.needs_scheduling = true; + } + ALWAYS_INLINE void RequestScheduleOnInterrupt() { SetSchedulerUpdateNeeded(); @@ -85,13 +90,13 @@ static ALWAYS_INLINE KSchedulerPriorityQueue &GetPriorityQueue() { return s_priority_queue; } static NOINLINE u64 UpdateHighestPriorityThreadsImpl(); + + static NOINLINE void InterruptTaskThreadToRunnable(); public: /* Static public API. */ static ALWAYS_INLINE bool CanSchedule() { return GetCurrentThread().GetDisableDispatchCount() == 0; } static ALWAYS_INLINE bool IsSchedulerLockedByCurrentThread() { return s_scheduler_lock.IsLockedByCurrentThread(); } - static NOINLINE void SetInterruptTaskThreadRunnable(); - static ALWAYS_INLINE void DisableScheduling() { MESOSPHERE_ASSERT(GetCurrentThread().GetDisableDispatchCount() >= 0); GetCurrentThread().DisableDispatch(); diff --git a/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp b/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp index 37fefef..b569457 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp @@ -38,6 +38,8 @@ KProcess *cur_process = GetCurrentProcessPointer(); bool should_process_user_exception = KTargetSystem::IsUserExceptionHandlersEnabled(); + MESOSPHERE_LOG("User Exception occurred in %s\n", cur_process->GetName()); + const u64 ec = (esr >> 26) & 0x3F; switch (ec) { case 0x0: /* Unknown */ diff --git a/libraries/libmesosphere/source/kern_k_interrupt_task_manager.cpp b/libraries/libmesosphere/source/kern_k_interrupt_task_manager.cpp index 83722e1..492516a 100644 --- a/libraries/libmesosphere/source/kern_k_interrupt_task_manager.cpp +++ b/libraries/libmesosphere/source/kern_k_interrupt_task_manager.cpp @@ -91,7 +91,7 @@ /* Enqueue the task and signal the scheduler. */ this->task_queue.Enqueue(task); - Kernel::GetScheduler().SetInterruptTaskThreadRunnable(); + Kernel::GetScheduler().SetInterruptTaskRunnable(); } } diff --git a/libraries/libmesosphere/source/kern_k_scheduler.cpp b/libraries/libmesosphere/source/kern_k_scheduler.cpp index b98aa44..46bfc89 100644 --- a/libraries/libmesosphere/source/kern_k_scheduler.cpp +++ b/libraries/libmesosphere/source/kern_k_scheduler.cpp @@ -199,7 +199,7 @@ return cores_needing_scheduling; } - void KScheduler::SetInterruptTaskThreadRunnable() { + void KScheduler::InterruptTaskThreadToRunnable() { MESOSPHERE_ASSERT(GetCurrentThread().GetDisableDispatchCount() == 1); KThread *task_thread = Kernel::GetInterruptTaskManager().GetThread(); @@ -252,7 +252,7 @@ /* Switch the current process, if we're switching processes. */ if (KProcess *next_process = next_thread->GetOwnerProcess(); next_process != cur_process) { - MESOSPHERE_LOG("!!! PROCESS SWITCH !!! %s -> %s\n", cur_process != nullptr ? cur_process->GetName() : nullptr, next_process != nullptr ? next_process->GetName() : nullptr); + /* MESOSPHERE_LOG("!!! PROCESS SWITCH !!! %s -> %s\n", cur_process != nullptr ? cur_process->GetName() : nullptr, next_process != nullptr ? next_process->GetName() : nullptr); */ KProcess::Switch(cur_process, next_process); } diff --git a/libraries/libmesosphere/source/kern_panic.cpp b/libraries/libmesosphere/source/kern_panic.cpp index a60e880..fc4322e 100644 --- a/libraries/libmesosphere/source/kern_panic.cpp +++ b/libraries/libmesosphere/source/kern_panic.cpp @@ -120,6 +120,9 @@ ::std::va_list vl; va_start(vl, format); MESOSPHERE_RELEASE_LOG("Core[%d]: Kernel Panic at %s:%d\n", GetCurrentCoreId(), file, line); + if (KProcess *cur_process = GetCurrentProcessPointer(); cur_process != nullptr) { + MESOSPHERE_RELEASE_LOG("Core[%d]: Current Process: %s\n", GetCurrentCoreId(), cur_process->GetName()); + } MESOSPHERE_RELEASE_VLOG(format, vl); MESOSPHERE_RELEASE_LOG("\n"); va_end(vl); diff --git a/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s b/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s index 8d86087..64e27a6 100644 --- a/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s +++ b/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s @@ -115,10 +115,10 @@ ldrb w3, [x1, #1] cbz w3, 0f - /* If it is, we want to call KScheduler::SetInterruptTaskThreadRunnable() to note it runnable. */ + /* If it is, we want to call KScheduler::InterruptTaskThreadToRunnable() to change its state to runnable. */ stp x0, x1, [sp, #-16]! stp x30, xzr, [sp, #-16]! - bl _ZN3ams4kern10KScheduler30SetInterruptTaskThreadRunnableEv + bl _ZN3ams4kern10KScheduler29InterruptTaskThreadToRunnableEv ldp x30, xzr, [sp], 16 ldp x0, x1, [sp], 16 @@ -271,7 +271,7 @@ cbz w3, 4b /* It does, so do so. We're using the idle thread stack so no register state preserve needed. */ - bl _ZN3ams4kern10KScheduler30SetInterruptTaskThreadRunnableEv + bl _ZN3ams4kern10KScheduler29InterruptTaskThreadToRunnableEv /* Clear the interrupt task thread as runnable. */ strb wzr, [x20, #1]