physical_core.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 arm_interface != nullptr;
  36. }
  37. Core::ARM_Interface& ArmInterface() {
  38. return *arm_interface;
  39. }
  40. const Core::ARM_Interface& ArmInterface() const {
  41. return *arm_interface;
  42. }
  43. bool IsMainCore() const {
  44. return core_index == 0;
  45. }
  46. bool IsSystemCore() const {
  47. return core_index == 3;
  48. }
  49. std::size_t CoreIndex() const {
  50. return core_index;
  51. }
  52. Kernel::KScheduler& Scheduler() {
  53. return scheduler;
  54. }
  55. const Kernel::KScheduler& Scheduler() const {
  56. return scheduler;
  57. }
  58. private:
  59. const std::size_t core_index;
  60. Core::System& system;
  61. Kernel::KScheduler& scheduler;
  62. std::mutex guard;
  63. std::condition_variable on_interrupt;
  64. std::unique_ptr<Core::ARM_Interface> arm_interface;
  65. bool is_interrupted{};
  66. };
  67. } // namespace Kernel