hle.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/assert.h"
  5. #include "common/logging/log.h"
  6. #include "core/arm/arm_interface.h"
  7. #include "core/core.h"
  8. #include "core/hle/hle.h"
  9. #include "core/hle/config_mem.h"
  10. #include "core/hle/shared_page.h"
  11. #include "core/hle/service/service.h"
  12. ////////////////////////////////////////////////////////////////////////////////////////////////////
  13. namespace HLE {
  14. bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread
  15. void Reschedule(const char *reason) {
  16. DEBUG_ASSERT_MSG(reason != nullptr && strlen(reason) < 256, "Reschedule: Invalid or too long reason.");
  17. // TODO(bunnei): It seems that games depend on some CPU execution time elapsing during HLE
  18. // routines. This simulates that time by artificially advancing the number of CPU "ticks".
  19. // The value was chosen empirically, it seems to work well enough for everything tested, but
  20. // is likely not ideal. We should find a more accurate way to simulate timing with HLE.
  21. Core::g_app_core->AddTicks(4000);
  22. Core::g_app_core->PrepareReschedule();
  23. g_reschedule = true;
  24. }
  25. void Init() {
  26. Service::Init();
  27. g_reschedule = false;
  28. LOG_DEBUG(Kernel, "initialized OK");
  29. }
  30. void Shutdown() {
  31. Service::Shutdown();
  32. LOG_DEBUG(Kernel, "shutdown OK");
  33. }
  34. } // namespace