physical_core.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <condition_variable>
  5. #include <cstddef>
  6. #include <memory>
  7. #include <mutex>
  8. #include "core/arm/arm_interface.h"
  9. namespace Kernel {
  10. class KScheduler;
  11. } // namespace Kernel
  12. namespace Core {
  13. class ExclusiveMonitor;
  14. class System;
  15. } // namespace Core
  16. namespace Kernel {
  17. class PhysicalCore {
  18. public:
  19. PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_);
  20. ~PhysicalCore();
  21. YUZU_NON_COPYABLE(PhysicalCore);
  22. YUZU_NON_MOVEABLE(PhysicalCore);
  23. /// Initialize the core for the specified parameters.
  24. void Initialize(bool is_64_bit);
  25. /// Execute current jit state
  26. void Run();
  27. void Idle();
  28. /// Interrupt this physical core.
  29. void Interrupt();
  30. /// Clear this core's interrupt
  31. void ClearInterrupt();
  32. /// Check if this core is interrupted
  33. bool IsInterrupted() const;
  34. bool IsInitialized() const {
  35. return m_arm_interface != nullptr;
  36. }
  37. Core::ARM_Interface& ArmInterface() {
  38. return *m_arm_interface;
  39. }
  40. const Core::ARM_Interface& ArmInterface() const {
  41. return *m_arm_interface;
  42. }
  43. std::size_t CoreIndex() const {
  44. return m_core_index;
  45. }
  46. Kernel::KScheduler& Scheduler() {
  47. return m_scheduler;
  48. }
  49. const Kernel::KScheduler& Scheduler() const {
  50. return m_scheduler;
  51. }
  52. private:
  53. const std::size_t m_core_index;
  54. Core::System& m_system;
  55. Kernel::KScheduler& m_scheduler;
  56. std::mutex m_guard;
  57. std::condition_variable m_on_interrupt;
  58. std::unique_ptr<Core::ARM_Interface> m_arm_interface;
  59. bool m_is_interrupted{};
  60. };
  61. } // namespace Kernel