mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-16 16:14:25 -04:00
kern: implement more of KInterruptManager
This commit is contained in:
parent
62de3322ff
commit
5f857cb079
17 changed files with 579 additions and 39 deletions
|
@ -19,12 +19,31 @@ namespace ams::kern {
|
|||
|
||||
namespace {
|
||||
|
||||
class KSchedulerInterruptTask : public KInterruptTask {
|
||||
public:
|
||||
constexpr KSchedulerInterruptTask() : KInterruptTask() { /* ... */ }
|
||||
|
||||
virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override {
|
||||
return GetDummyInterruptTask();
|
||||
}
|
||||
|
||||
virtual void DoTask() override {
|
||||
MESOSPHERE_PANIC("KSchedulerInterruptTask::DoTask was called!");
|
||||
}
|
||||
};
|
||||
|
||||
ALWAYS_INLINE void IncrementScheduledCount(KThread *thread) {
|
||||
if (KProcess *parent = thread->GetOwnerProcess(); parent != nullptr) {
|
||||
/* TODO: parent->IncrementScheduledCount(); */
|
||||
}
|
||||
}
|
||||
|
||||
KSchedulerInterruptTask g_scheduler_interrupt_task;
|
||||
|
||||
ALWAYS_INLINE auto *GetSchedulerInterruptTask() {
|
||||
return std::addressof(g_scheduler_interrupt_task);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void KScheduler::Initialize(KThread *idle_thread) {
|
||||
|
@ -40,7 +59,8 @@ namespace ams::kern {
|
|||
SetSchedulerUpdateNeeded();
|
||||
}
|
||||
|
||||
/* TODO: Bind interrupt handler. */
|
||||
/* Bind interrupt handler. */
|
||||
Kernel::GetInterruptManager().BindHandler(GetSchedulerInterruptTask(), KInterruptName_Scheduler, this->core_id, KInterruptController::PriorityLevel_Scheduler, false, false);
|
||||
}
|
||||
|
||||
void KScheduler::Activate() {
|
||||
|
@ -51,6 +71,13 @@ namespace ams::kern {
|
|||
RescheduleCurrentCore();
|
||||
}
|
||||
|
||||
void KScheduler::RescheduleOtherCores(u64 cores_needing_scheduling) {
|
||||
if (const u64 core_mask = cores_needing_scheduling & ~(1ul << this->core_id); core_mask != 0) {
|
||||
cpu::DataSynchronizationBarrier();
|
||||
Kernel::GetInterruptManager().SendInterProcessorInterrupt(KInterruptName_Scheduler, core_mask);
|
||||
}
|
||||
}
|
||||
|
||||
u64 KScheduler::UpdateHighestPriorityThread(KThread *highest_thread) {
|
||||
if (KThread *prev_highest_thread = this->state.highest_priority_thread; AMS_LIKELY(prev_highest_thread != highest_thread)) {
|
||||
if (AMS_LIKELY(prev_highest_thread != nullptr)) {
|
||||
|
@ -171,7 +198,7 @@ namespace ams::kern {
|
|||
void KScheduler::SetInterruptTaskThreadRunnable() {
|
||||
MESOSPHERE_ASSERT(GetCurrentThread().GetDisableDispatchCount() == 1);
|
||||
|
||||
KThread *task_thread = nullptr /* TODO: GetInterruptTaskManager().GetThread() */;
|
||||
KThread *task_thread = Kernel::GetInterruptTaskManager().GetThread();
|
||||
{
|
||||
KScopedSchedulerLock sl;
|
||||
if (AMS_LIKELY(task_thread->GetThreadState() == KThread::ThreadState_Waiting)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue