arm_dynarmic_32.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright 2020 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <memory>
  6. #include <unordered_map>
  7. #include <dynarmic/A32/a32.h>
  8. #include <dynarmic/A64/a64.h>
  9. #include <dynarmic/exclusive_monitor.h>
  10. #include "common/common_types.h"
  11. #include "common/hash.h"
  12. #include "core/arm/arm_interface.h"
  13. #include "core/arm/exclusive_monitor.h"
  14. namespace Core::Memory {
  15. class Memory;
  16. }
  17. namespace Core {
  18. class CPUInterruptHandler;
  19. class DynarmicCallbacks32;
  20. class DynarmicCP15;
  21. class DynarmicExclusiveMonitor;
  22. class System;
  23. class ARM_Dynarmic_32 final : public ARM_Interface {
  24. public:
  25. ARM_Dynarmic_32(System& system_, CPUInterrupts& interrupt_handlers_, bool uses_wall_clock_,
  26. ExclusiveMonitor& exclusive_monitor_, std::size_t core_index_);
  27. ~ARM_Dynarmic_32() override;
  28. void SetPC(u64 pc) override;
  29. u64 GetPC() const override;
  30. u64 GetReg(int index) const override;
  31. void SetReg(int index, u64 value) override;
  32. u128 GetVectorReg(int index) const override;
  33. void SetVectorReg(int index, u128 value) override;
  34. u32 GetPSTATE() const override;
  35. void SetPSTATE(u32 pstate) override;
  36. void Run() override;
  37. void ExceptionalExit() override;
  38. void Step() override;
  39. VAddr GetTlsAddress() const override;
  40. void SetTlsAddress(VAddr address) override;
  41. void SetTPIDR_EL0(u64 value) override;
  42. u64 GetTPIDR_EL0() const override;
  43. void ChangeProcessorID(std::size_t new_core_id) override;
  44. bool IsInThumbMode() const {
  45. return (GetPSTATE() & 0x20) != 0;
  46. }
  47. void SaveContext(ThreadContext32& ctx) override;
  48. void SaveContext(ThreadContext64& ctx) override {}
  49. void LoadContext(const ThreadContext32& ctx) override;
  50. void LoadContext(const ThreadContext64& ctx) override {}
  51. void PrepareReschedule() override;
  52. void ClearExclusiveState() override;
  53. void ClearInstructionCache() override;
  54. void InvalidateCacheRange(VAddr addr, std::size_t size) override;
  55. void PageTableChanged(Common::PageTable& new_page_table,
  56. std::size_t new_address_space_size_in_bits) override;
  57. private:
  58. std::shared_ptr<Dynarmic::A32::Jit> MakeJit(Common::PageTable* page_table) const;
  59. using JitCacheKey = std::pair<Common::PageTable*, std::size_t>;
  60. using JitCacheType =
  61. std::unordered_map<JitCacheKey, std::shared_ptr<Dynarmic::A32::Jit>, Common::PairHash>;
  62. friend class DynarmicCallbacks32;
  63. friend class DynarmicCP15;
  64. std::unique_ptr<DynarmicCallbacks32> cb;
  65. JitCacheType jit_cache;
  66. std::shared_ptr<DynarmicCP15> cp15;
  67. std::size_t core_index;
  68. DynarmicExclusiveMonitor& exclusive_monitor;
  69. std::shared_ptr<Dynarmic::A32::Jit> jit;
  70. };
  71. } // namespace Core