core.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 "common/log.h"
  6. #include "common/symbols.h"
  7. #include "core/core.h"
  8. #include "core/mem_map.h"
  9. #include "core/hw/hw.h"
  10. #include "core/hw/gpu.h"
  11. #include "core/arm/disassembler/arm_disasm.h"
  12. #include "core/arm/interpreter/arm_interpreter.h"
  13. #include "core/hle/hle.h"
  14. #include "core/hle/kernel/thread.h"
  15. namespace Core {
  16. u64 g_last_ticks = 0; ///< Last CPU ticks
  17. ARM_Disasm* g_disasm = nullptr; ///< ARM disassembler
  18. ARM_Interface* g_app_core = nullptr; ///< ARM11 application core
  19. ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core
  20. /// Run the core CPU loop
  21. void RunLoop() {
  22. for (;;){
  23. g_app_core->Run(GPU::kFrameTicks);
  24. HW::Update();
  25. Kernel::Reschedule();
  26. }
  27. }
  28. /// Step the CPU one instruction
  29. void SingleStep() {
  30. g_app_core->Step();
  31. // Update and reschedule after approx. 1 frame
  32. u64 current_ticks = Core::g_app_core->GetTicks();
  33. if ((current_ticks - g_last_ticks) >= GPU::kFrameTicks || HLE::g_reschedule) {
  34. g_last_ticks = current_ticks;
  35. HW::Update();
  36. Kernel::Reschedule();
  37. }
  38. }
  39. /// Halt the core
  40. void Halt(const char *msg) {
  41. // TODO(ShizZy): ImplementMe
  42. }
  43. /// Kill the core
  44. void Stop() {
  45. // TODO(ShizZy): ImplementMe
  46. }
  47. /// Initialize the core
  48. int Init() {
  49. NOTICE_LOG(MASTER_LOG, "initialized OK");
  50. g_disasm = new ARM_Disasm();
  51. g_app_core = new ARM_Interpreter();
  52. g_sys_core = new ARM_Interpreter();
  53. g_last_ticks = Core::g_app_core->GetTicks();
  54. return 0;
  55. }
  56. void Shutdown() {
  57. delete g_disasm;
  58. delete g_app_core;
  59. delete g_sys_core;
  60. NOTICE_LOG(MASTER_LOG, "shutdown OK");
  61. }
  62. } // namespace