k_interrupt_manager.cpp 992 B

1234567891011121314151617181920212223242526272829303132
  1. // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "core/hle/kernel/k_interrupt_manager.h"
  4. #include "core/hle/kernel/k_process.h"
  5. #include "core/hle/kernel/k_scheduler.h"
  6. #include "core/hle/kernel/k_thread.h"
  7. #include "core/hle/kernel/kernel.h"
  8. namespace Kernel::KInterruptManager {
  9. void HandleInterrupt(KernelCore& kernel, s32 core_id) {
  10. auto* process = kernel.CurrentProcess();
  11. if (!process) {
  12. return;
  13. }
  14. auto& current_thread = GetCurrentThread(kernel);
  15. // If the user disable count is set, we may need to pin the current thread.
  16. if (current_thread.GetUserDisableCount() && !process->GetPinnedThread(core_id)) {
  17. KScopedSchedulerLock sl{kernel};
  18. // Pin the current thread.
  19. process->PinCurrentThread(core_id);
  20. // Set the interrupt flag for the thread.
  21. GetCurrentThread(kernel).SetInterruptFlag();
  22. }
  23. }
  24. } // namespace Kernel::KInterruptManager