hle.cpp 1.5 KB

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