core.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/logging/log.h"
  5. #include "core/core.h"
  6. #include "core/core_timing.h"
  7. #include "core/arm/arm_interface.h"
  8. #include "core/arm/dyncom/arm_dyncom.h"
  9. #include "core/hle/hle.h"
  10. #include "core/hle/kernel/thread.h"
  11. #include "core/hw/hw.h"
  12. namespace Core {
  13. ARM_Interface* g_app_core = nullptr; ///< ARM11 application core
  14. ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core
  15. /// Run the core CPU loop
  16. void RunLoop(int tight_loop) {
  17. // If we don't have a currently active thread then don't execute instructions,
  18. // instead advance to the next event and try to yield to the next thread
  19. if (Kernel::GetCurrentThread() == nullptr) {
  20. LOG_TRACE(Core_ARM11, "Idling");
  21. CoreTiming::Idle();
  22. CoreTiming::Advance();
  23. HLE::Reschedule(__func__);
  24. } else {
  25. g_app_core->Run(tight_loop);
  26. }
  27. HW::Update();
  28. if (HLE::g_reschedule) {
  29. Kernel::Reschedule();
  30. }
  31. }
  32. /// Step the CPU one instruction
  33. void SingleStep() {
  34. RunLoop(1);
  35. }
  36. /// Halt the core
  37. void Halt(const char *msg) {
  38. // TODO(ShizZy): ImplementMe
  39. }
  40. /// Kill the core
  41. void Stop() {
  42. // TODO(ShizZy): ImplementMe
  43. }
  44. /// Initialize the core
  45. int Init() {
  46. g_sys_core = new ARM_DynCom(USER32MODE);
  47. g_app_core = new ARM_DynCom(USER32MODE);
  48. LOG_DEBUG(Core, "Initialized OK");
  49. return 0;
  50. }
  51. void Shutdown() {
  52. delete g_app_core;
  53. delete g_sys_core;
  54. LOG_DEBUG(Core, "Shutdown OK");
  55. }
  56. } // namespace