core.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 "common/logging/log.h"
  6. #include "core/core.h"
  7. #include "core/core_timing.h"
  8. #include "core/settings.h"
  9. #include "core/arm/arm_interface.h"
  10. #include "core/arm/disassembler/arm_disasm.h"
  11. #include "core/arm/dyncom/arm_dyncom.h"
  12. #include "core/hle/hle.h"
  13. #include "core/hle/kernel/thread.h"
  14. #include "core/hw/hw.h"
  15. namespace Core {
  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. // If we don't have a currently active thread then don't execute instructions,
  21. // instead advance to the next event and try to yield to the next thread
  22. if (Kernel::GetCurrentThread() == nullptr) {
  23. LOG_TRACE(Core_ARM11, "Idling");
  24. CoreTiming::Idle();
  25. CoreTiming::Advance();
  26. HLE::Reschedule(__func__);
  27. } else {
  28. g_app_core->Run(tight_loop);
  29. }
  30. HW::Update();
  31. if (HLE::g_reschedule) {
  32. Kernel::Reschedule();
  33. }
  34. }
  35. /// Step the CPU one instruction
  36. void SingleStep() {
  37. RunLoop(1);
  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. g_sys_core = new ARM_DynCom(USER32MODE);
  50. g_app_core = new ARM_DynCom(USER32MODE);
  51. LOG_DEBUG(Core, "Initialized OK");
  52. return 0;
  53. }
  54. void Shutdown() {
  55. delete g_app_core;
  56. delete g_sys_core;
  57. LOG_DEBUG(Core, "Shutdown OK");
  58. }
  59. } // namespace