physical_core.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2020 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <cstddef>
  6. #include <memory>
  7. namespace Common {
  8. class SpinLock;
  9. }
  10. namespace Kernel {
  11. class Scheduler;
  12. } // namespace Kernel
  13. namespace Core {
  14. class ARM_Interface;
  15. class CPUInterruptHandler;
  16. class ExclusiveMonitor;
  17. class System;
  18. } // namespace Core
  19. namespace Kernel {
  20. class PhysicalCore {
  21. public:
  22. PhysicalCore(Core::System& system, std::size_t id, Kernel::Scheduler& scheduler,
  23. Core::CPUInterruptHandler& interrupt_handler);
  24. ~PhysicalCore();
  25. PhysicalCore(const PhysicalCore&) = delete;
  26. PhysicalCore& operator=(const PhysicalCore&) = delete;
  27. PhysicalCore(PhysicalCore&&) = default;
  28. PhysicalCore& operator=(PhysicalCore&&) = default;
  29. void Idle();
  30. /// Interrupt this physical core.
  31. void Interrupt();
  32. /// Clear this core's interrupt
  33. void ClearInterrupt();
  34. /// Check if this core is interrupted
  35. bool IsInterrupted() const;
  36. // Shutdown this physical core.
  37. void Shutdown();
  38. bool IsMainCore() const {
  39. return core_index == 0;
  40. }
  41. bool IsSystemCore() const {
  42. return core_index == 3;
  43. }
  44. std::size_t CoreIndex() const {
  45. return core_index;
  46. }
  47. Kernel::Scheduler& Scheduler() {
  48. return scheduler;
  49. }
  50. const Kernel::Scheduler& Scheduler() const {
  51. return scheduler;
  52. }
  53. private:
  54. Core::CPUInterruptHandler& interrupt_handler;
  55. std::size_t core_index;
  56. Kernel::Scheduler& scheduler;
  57. std::unique_ptr<Common::SpinLock> guard;
  58. };
  59. } // namespace Kernel