summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar B3n302017-11-25 14:56:57 +0100
committerGravatar bunnei2018-01-08 19:10:25 -0500
commit82151d407d8021fa8865cf8dd51c4d5cf0a4b702 (patch)
tree739df280fddbecb50e1a2fa690abe8749486ea2d /src/core/hle
parentIPC: Make DuplicateSession return the Domain instead of the Session if the re... (diff)
downloadyuzu-82151d407d8021fa8865cf8dd51c4d5cf0a4b702.tar.gz
yuzu-82151d407d8021fa8865cf8dd51c4d5cf0a4b702.tar.xz
yuzu-82151d407d8021fa8865cf8dd51c4d5cf0a4b702.zip
CoreTiming: Reworked CoreTiming (cherry-picked from Citra #3119)
* CoreTiming: New CoreTiming; Add Test for CoreTiming
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/kernel/thread.cpp5
-rw-r--r--src/core/hle/kernel/timer.cpp9
-rw-r--r--src/core/hle/shared_page.cpp4
3 files changed, 7 insertions, 11 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 9132d1d77..f9d821a80 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -26,7 +26,7 @@
26namespace Kernel { 26namespace Kernel {
27 27
28/// Event type for the thread wake up event 28/// Event type for the thread wake up event
29static int ThreadWakeupEventType; 29static CoreTiming::EventType* ThreadWakeupEventType = nullptr;
30 30
31bool Thread::ShouldWait(Thread* thread) const { 31bool Thread::ShouldWait(Thread* thread) const {
32 return status != THREADSTATUS_DEAD; 32 return status != THREADSTATUS_DEAD;
@@ -265,8 +265,7 @@ void Thread::WakeAfterDelay(s64 nanoseconds) {
265 if (nanoseconds == -1) 265 if (nanoseconds == -1)
266 return; 266 return;
267 267
268 u64 microseconds = nanoseconds / 1000; 268 CoreTiming::ScheduleEvent(nsToCycles(nanoseconds), ThreadWakeupEventType, callback_handle);
269 CoreTiming::ScheduleEvent(usToCycles(microseconds), ThreadWakeupEventType, callback_handle);
270} 269}
271 270
272void Thread::ResumeFromWait() { 271void Thread::ResumeFromWait() {
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp
index d7ec93672..a93a6c87a 100644
--- a/src/core/hle/kernel/timer.cpp
+++ b/src/core/hle/kernel/timer.cpp
@@ -14,7 +14,7 @@
14namespace Kernel { 14namespace Kernel {
15 15
16/// The event type of the generic timer callback event 16/// The event type of the generic timer callback event
17static int timer_callback_event_type; 17static CoreTiming::EventType* timer_callback_event_type = nullptr;
18// TODO(yuriks): This can be removed if Timer objects are explicitly pooled in the future, allowing 18// TODO(yuriks): This can be removed if Timer objects are explicitly pooled in the future, allowing
19// us to simply use a pool index or similar. 19// us to simply use a pool index or similar.
20static Kernel::HandleTable timer_callback_handle_table; 20static Kernel::HandleTable timer_callback_handle_table;
@@ -57,9 +57,7 @@ void Timer::Set(s64 initial, s64 interval) {
57 // Immediately invoke the callback 57 // Immediately invoke the callback
58 Signal(0); 58 Signal(0);
59 } else { 59 } else {
60 u64 initial_microseconds = initial / 1000; 60 CoreTiming::ScheduleEvent(nsToCycles(initial), timer_callback_event_type, callback_handle);
61 CoreTiming::ScheduleEvent(usToCycles(initial_microseconds), timer_callback_event_type,
62 callback_handle);
63 } 61 }
64} 62}
65 63
@@ -88,8 +86,7 @@ void Timer::Signal(int cycles_late) {
88 86
89 if (interval_delay != 0) { 87 if (interval_delay != 0) {
90 // Reschedule the timer with the interval delay 88 // Reschedule the timer with the interval delay
91 u64 interval_microseconds = interval_delay / 1000; 89 CoreTiming::ScheduleEvent(nsToCycles(interval_delay) - cycles_late,
92 CoreTiming::ScheduleEvent(usToCycles(interval_microseconds) - cycles_late,
93 timer_callback_event_type, callback_handle); 90 timer_callback_event_type, callback_handle);
94 } 91 }
95} 92}
diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp
index 833dc5ec9..9ce8af961 100644
--- a/src/core/hle/shared_page.cpp
+++ b/src/core/hle/shared_page.cpp
@@ -14,7 +14,7 @@ namespace SharedPage {
14 14
15SharedPageDef shared_page; 15SharedPageDef shared_page;
16 16
17static int update_time_event; 17static CoreTiming::EventType* update_time_event;
18 18
19/// Gets system time in 3DS format. The epoch is Jan 1900, and the unit is millisecond. 19/// Gets system time in 3DS format. The epoch is Jan 1900, and the unit is millisecond.
20static u64 GetSystemTime() { 20static u64 GetSystemTime() {
@@ -56,7 +56,7 @@ static void UpdateTimeCallback(u64 userdata, int cycles_late) {
56 56
57 date_time.date_time = GetSystemTime(); 57 date_time.date_time = GetSystemTime();
58 date_time.update_tick = CoreTiming::GetTicks(); 58 date_time.update_tick = CoreTiming::GetTicks();
59 date_time.tick_to_second_coefficient = g_clock_rate_arm11; 59 date_time.tick_to_second_coefficient = BASE_CLOCK_RATE;
60 date_time.tick_offset = 0; 60 date_time.tick_offset = 0;
61 61
62 ++shared_page.date_time_counter; 62 ++shared_page.date_time_counter;