core.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #include "common/common_types.h"
  5. #include "core/core.h"
  6. #include "core/settings.h"
  7. #include "core/arm/disassembler/arm_disasm.h"
  8. #include "core/arm/interpreter/arm_interpreter.h"
  9. #include "core/arm/dyncom/arm_dyncom.h"
  10. #include "core/hle/hle.h"
  11. #include "core/hle/kernel/thread.h"
  12. #include "core/hw/hw.h"
  13. namespace Core {
  14. u64 g_last_ticks = 0; ///< Last CPU ticks
  15. ARM_Disasm* g_disasm = nullptr; ///< ARM disassembler
  16. ARM_Interface* g_app_core = nullptr; ///< ARM11 application core
  17. ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core
  18. /// Run the core CPU loop
  19. void RunLoop(int tight_loop) {
  20. g_app_core->Run(tight_loop);
  21. HW::Update();
  22. if (HLE::g_reschedule) {
  23. Kernel::Reschedule();
  24. }
  25. }
  26. /// Step the CPU one instruction
  27. void SingleStep() {
  28. RunLoop(1);
  29. }
  30. /// Halt the core
  31. void Halt(const char *msg) {
  32. // TODO(ShizZy): ImplementMe
  33. }
  34. /// Kill the core
  35. void Stop() {
  36. // TODO(ShizZy): ImplementMe
  37. }
  38. /// Initialize the core
  39. int Init() {
  40. NOTICE_LOG(MASTER_LOG, "initialized OK");
  41. g_disasm = new ARM_Disasm();
  42. g_sys_core = new ARM_Interpreter();
  43. switch (Settings::values.cpu_core) {
  44. case CPU_FastInterpreter:
  45. g_app_core = new ARM_DynCom();
  46. break;
  47. case CPU_Interpreter:
  48. default:
  49. g_app_core = new ARM_Interpreter();
  50. break;
  51. }
  52. g_last_ticks = Core::g_app_core->GetTicks();
  53. return 0;
  54. }
  55. void Shutdown() {
  56. delete g_disasm;
  57. delete g_app_core;
  58. delete g_sys_core;
  59. NOTICE_LOG(MASTER_LOG, "shutdown OK");
  60. }
  61. } // namespace