arm_interface.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "common/common_types.h"
  7. /// Generic ARM11 CPU interface
  8. class ARM_Interface : NonCopyable {
  9. public:
  10. ARM_Interface() {
  11. m_num_instructions = 0;
  12. }
  13. ~ARM_Interface() {
  14. }
  15. /// Step CPU by one instruction
  16. void Step() {
  17. ExecuteInstruction();
  18. m_num_instructions++;
  19. }
  20. /**
  21. * Set the Program Counter to an address
  22. * @param addr Address to set PC to
  23. */
  24. virtual void SetPC(u32 addr) = 0;
  25. /*
  26. * Get the current Program Counter
  27. * @return Returns current PC
  28. */
  29. virtual u32 GetPC() const = 0;
  30. /**
  31. * Get an ARM register
  32. * @param index Register index (0-15)
  33. * @return Returns the value in the register
  34. */
  35. virtual u32 GetReg(int index) const = 0;
  36. /**
  37. * Set an ARM register
  38. * @param index Register index (0-15)
  39. * @param value Value to set register to
  40. */
  41. virtual void SetReg(int index, u32 value) = 0;
  42. /**
  43. * Get the current CPSR register
  44. * @return Returns the value of the CPSR register
  45. */
  46. virtual u32 GetCPSR() const = 0;
  47. /**
  48. * Returns the number of clock ticks since the last rese
  49. * @return Returns number of clock ticks
  50. */
  51. virtual u64 GetTicks() const = 0;
  52. /// Getter for m_num_instructions
  53. u64 GetNumInstructions() {
  54. return m_num_instructions;
  55. }
  56. protected:
  57. /// Execture next instruction
  58. virtual void ExecuteInstruction() = 0;
  59. private:
  60. u64 m_num_instructions; ///< Number of instructions executed
  61. };