core.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. class ARM_Interface;
  7. ////////////////////////////////////////////////////////////////////////////////////////////////////
  8. namespace Core {
  9. enum CPUCore {
  10. CPU_Interpreter,
  11. CPU_OldInterpreter,
  12. };
  13. struct ThreadContext {
  14. u32 cpu_registers[13];
  15. u32 sp;
  16. u32 lr;
  17. u32 pc;
  18. u32 cpsr;
  19. u32 fpu_registers[32];
  20. u32 fpscr;
  21. u32 fpexc;
  22. // These are not part of native ThreadContext, but needed by emu
  23. u32 reg_15;
  24. u32 mode;
  25. };
  26. extern ARM_Interface* g_app_core; ///< ARM11 application core
  27. extern ARM_Interface* g_sys_core; ///< ARM11 system (OS) core
  28. ////////////////////////////////////////////////////////////////////////////////////////////////////
  29. /// Start the core
  30. void Start();
  31. /**
  32. * Run the core CPU loop
  33. * This function runs the core for the specified number of CPU instructions before trying to update
  34. * hardware. This is much faster than SingleStep (and should be equivalent), as the CPU is not
  35. * required to do a full dispatch with each instruction. NOTE: the number of instructions requested
  36. * is not guaranteed to run, as this will be interrupted preemptively if a hardware update is
  37. * requested (e.g. on a thread switch).
  38. */
  39. void RunLoop(int tight_loop=1000);
  40. /// Step the CPU one instruction
  41. void SingleStep();
  42. /// Halt the core
  43. void Halt(const char *msg);
  44. /// Kill the core
  45. void Stop();
  46. /// Initialize the core
  47. int Init();
  48. /// Shutdown the core
  49. void Shutdown();
  50. } // namespace