arm_interpreter.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common.h"
  6. #include "core/arm/arm_interface.h"
  7. #include "core/arm/interpreter/armdefs.h"
  8. #include "core/arm/interpreter/armemu.h"
  9. class ARM_Interpreter : virtual public ARM_Interface {
  10. public:
  11. ARM_Interpreter();
  12. ~ARM_Interpreter();
  13. /**
  14. * Set the Program Counter to an address
  15. * @param addr Address to set PC to
  16. */
  17. void SetPC(u32 pc);
  18. /*
  19. * Get the current Program Counter
  20. * @return Returns current PC
  21. */
  22. u32 GetPC() const;
  23. /**
  24. * Get an ARM register
  25. * @param index Register index (0-15)
  26. * @return Returns the value in the register
  27. */
  28. u32 GetReg(int index) const;
  29. /**
  30. * Set an ARM register
  31. * @param index Register index (0-15)
  32. * @param value Value to set register to
  33. */
  34. void SetReg(int index, u32 value);
  35. /**
  36. * Get the current CPSR register
  37. * @return Returns the value of the CPSR register
  38. */
  39. u32 GetCPSR() const;
  40. /**
  41. * Set the current CPSR register
  42. * @param cpsr Value to set CPSR to
  43. */
  44. void SetCPSR(u32 cpsr);
  45. /**
  46. * Returns the number of clock ticks since the last reset
  47. * @return Returns number of clock ticks
  48. */
  49. u64 GetTicks() const;
  50. /**
  51. * Saves the current CPU context
  52. * @param ctx Thread context to save
  53. */
  54. void SaveContext(ThreadContext& ctx);
  55. /**
  56. * Loads a CPU context
  57. * @param ctx Thread context to load
  58. */
  59. void LoadContext(const ThreadContext& ctx);
  60. /// Prepare core for thread reschedule (if needed to correctly handle state)
  61. void PrepareReschedule();
  62. protected:
  63. /**
  64. * Executes the given number of instructions
  65. * @param num_instructions Number of instructions to executes
  66. */
  67. void ExecuteInstructions(int num_instructions);
  68. private:
  69. ARMul_State* state;
  70. };