core.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/common_types.h"
  5. #include "core/core.h"
  6. #include "core/core_timing.h"
  7. #include "core/settings.h"
  8. #include "core/arm/arm_interface.h"
  9. #include "core/arm/disassembler/arm_disasm.h"
  10. #include "core/arm/dyncom/arm_dyncom.h"
  11. #include "core/hle/hle.h"
  12. #include "core/hle/kernel/thread.h"
  13. #include "core/hw/hw.h"
  14. namespace Core {
  15. ARM_Interface* g_app_core = nullptr; ///< ARM11 application core
  16. ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core
  17. /// Run the core CPU loop
  18. void RunLoop(int tight_loop) {
  19. // If the current thread is an idle thread, then don't execute instructions,
  20. // instead advance to the next event and try to yield to the next thread
  21. if (Kernel::GetCurrentThread()->IsIdle()) {
  22. LOG_TRACE(Core_ARM11, "Idling");
  23. CoreTiming::Idle();
  24. CoreTiming::Advance();
  25. HLE::Reschedule(__func__);
  26. } else {
  27. g_app_core->Run(tight_loop);
  28. }
  29. HW::Update();
  30. if (HLE::g_reschedule) {
  31. Kernel::Reschedule();
  32. }
  33. }
  34. /// Step the CPU one instruction
  35. void SingleStep() {
  36. RunLoop(1);
  37. }
  38. /// Halt the core
  39. void Halt(const char *msg) {
  40. // TODO(ShizZy): ImplementMe
  41. }
  42. /// Kill the core
  43. void Stop() {
  44. // TODO(ShizZy): ImplementMe
  45. }
  46. /// Initialize the core
  47. int Init() {
  48. g_sys_core = new ARM_DynCom(USER32MODE);
  49. g_app_core = new ARM_DynCom(USER32MODE);
  50. LOG_DEBUG(Core, "Initialized OK");
  51. return 0;
  52. }
  53. void Shutdown() {
  54. delete g_app_core;
  55. delete g_sys_core;
  56. LOG_DEBUG(Core, "Shutdown OK");
  57. }
  58. } // namespace