summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-04-30 03:24:27 -0400
committerGravatar Lioncash2018-04-30 03:32:59 -0400
commit0197e28cc95e96e651eab555f512d0bb292e9215 (patch)
treeed7367dd74a937809d9501b2d848e8e981b538ba /src
parentMerge pull request #424 from lioncash/string (diff)
downloadyuzu-0197e28cc95e96e651eab555f512d0bb292e9215.tar.gz
yuzu-0197e28cc95e96e651eab555f512d0bb292e9215.tar.xz
yuzu-0197e28cc95e96e651eab555f512d0bb292e9215.zip
core_timing: Namespace all functions and constants in core_timing's header
All of these variables and functions are related to timings and should be within the namespace.
Diffstat (limited to 'src')
-rw-r--r--src/core/core_timing.h4
-rw-r--r--src/core/hle/kernel/thread.cpp3
-rw-r--r--src/core/hle/kernel/timer.cpp5
-rw-r--r--src/core/hle/service/audio/audout_u.cpp2
-rw-r--r--src/core/hle/service/audio/audren_u.cpp2
-rw-r--r--src/core/hle/service/hid/hid.cpp6
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp2
-rw-r--r--src/core/hle/service/time/time.cpp3
-rw-r--r--src/core/hle/shared_page.cpp5
9 files changed, 18 insertions, 14 deletions
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index 26e4b1134..9d3c1d05c 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -23,6 +23,8 @@
23#include "common/common_types.h" 23#include "common/common_types.h"
24#include "common/logging/log.h" 24#include "common/logging/log.h"
25 25
26namespace CoreTiming {
27
26// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz 28// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz
27// The exact value used is of course unverified. 29// The exact value used is of course unverified.
28constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked 30constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked
@@ -117,8 +119,6 @@ inline u64 cyclesToMs(s64 cycles) {
117 return cycles * 1000 / BASE_CLOCK_RATE; 119 return cycles * 1000 / BASE_CLOCK_RATE;
118} 120}
119 121
120namespace CoreTiming {
121
122/** 122/**
123 * CoreTiming begins at the boundary of timing slice -1. An initial call to Advance() is 123 * CoreTiming begins at the boundary of timing slice -1. An initial call to Advance() is
124 * required to end slice -1 and start slice 0 before the first cycle of code is executed. 124 * required to end slice -1 and start slice 0 before the first cycle of code is executed.
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 63790ea00..1bd5d9ebf 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -146,7 +146,8 @@ void Thread::WakeAfterDelay(s64 nanoseconds) {
146 if (nanoseconds == -1) 146 if (nanoseconds == -1)
147 return; 147 return;
148 148
149 CoreTiming::ScheduleEvent(nsToCycles(nanoseconds), ThreadWakeupEventType, callback_handle); 149 CoreTiming::ScheduleEvent(CoreTiming::nsToCycles(nanoseconds), ThreadWakeupEventType,
150 callback_handle);
150} 151}
151 152
152void Thread::CancelWakeupTimer() { 153void Thread::CancelWakeupTimer() {
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp
index ad58bf043..661356a97 100644
--- a/src/core/hle/kernel/timer.cpp
+++ b/src/core/hle/kernel/timer.cpp
@@ -57,7 +57,8 @@ 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 CoreTiming::ScheduleEvent(nsToCycles(initial), timer_callback_event_type, callback_handle); 60 CoreTiming::ScheduleEvent(CoreTiming::nsToCycles(initial), timer_callback_event_type,
61 callback_handle);
61 } 62 }
62} 63}
63 64
@@ -86,7 +87,7 @@ void Timer::Signal(int cycles_late) {
86 87
87 if (interval_delay != 0) { 88 if (interval_delay != 0) {
88 // Reschedule the timer with the interval delay 89 // Reschedule the timer with the interval delay
89 CoreTiming::ScheduleEvent(nsToCycles(interval_delay) - cycles_late, 90 CoreTiming::ScheduleEvent(CoreTiming::nsToCycles(interval_delay) - cycles_late,
90 timer_callback_event_type, callback_handle); 91 timer_callback_event_type, callback_handle);
91 } 92 }
92} 93}
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index 6297dc450..fa3728672 100644
--- a/src/core/hle/service/audio/audout_u.cpp
+++ b/src/core/hle/service/audio/audout_u.cpp
@@ -18,7 +18,7 @@ constexpr u32 sample_rate{48000};
18/// to more audio channels (probably when Docked I guess) 18/// to more audio channels (probably when Docked I guess)
19constexpr u32 audio_channels{2}; 19constexpr u32 audio_channels{2};
20/// TODO(st4rk): find a proper value for the audio_ticks 20/// TODO(st4rk): find a proper value for the audio_ticks
21constexpr u64 audio_ticks{static_cast<u64>(BASE_CLOCK_RATE / 500)}; 21constexpr u64 audio_ticks{static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / 500)};
22 22
23class IAudioOut final : public ServiceFramework<IAudioOut> { 23class IAudioOut final : public ServiceFramework<IAudioOut> {
24public: 24public:
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index 291885db8..0d6eb1d51 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -12,7 +12,7 @@
12namespace Service::Audio { 12namespace Service::Audio {
13 13
14/// TODO(bunnei): Find a proper value for the audio_ticks 14/// TODO(bunnei): Find a proper value for the audio_ticks
15constexpr u64 audio_ticks{static_cast<u64>(BASE_CLOCK_RATE / 200)}; 15constexpr u64 audio_ticks{static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / 200)};
16 16
17class IAudioRenderer final : public ServiceFramework<IAudioRenderer> { 17class IAudioRenderer final : public ServiceFramework<IAudioRenderer> {
18public: 18public:
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 736180b63..dc7ff5c31 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -18,9 +18,9 @@ namespace Service::HID {
18 18
19// Updating period for each HID device. 19// Updating period for each HID device.
20// TODO(shinyquagsire23): These need better values. 20// TODO(shinyquagsire23): These need better values.
21constexpr u64 pad_update_ticks = BASE_CLOCK_RATE / 10000; 21constexpr u64 pad_update_ticks = CoreTiming::BASE_CLOCK_RATE / 10000;
22constexpr u64 accelerometer_update_ticks = BASE_CLOCK_RATE / 10000; 22constexpr u64 accelerometer_update_ticks = CoreTiming::BASE_CLOCK_RATE / 10000;
23constexpr u64 gyroscope_update_ticks = BASE_CLOCK_RATE / 10000; 23constexpr u64 gyroscope_update_ticks = CoreTiming::BASE_CLOCK_RATE / 10000;
24 24
25class IAppletResource final : public ServiceFramework<IAppletResource> { 25class IAppletResource final : public ServiceFramework<IAppletResource> {
26public: 26public:
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index 3481e48d0..5c50ed601 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -19,7 +19,7 @@
19namespace Service::NVFlinger { 19namespace Service::NVFlinger {
20 20
21constexpr size_t SCREEN_REFRESH_RATE = 60; 21constexpr size_t SCREEN_REFRESH_RATE = 60;
22constexpr u64 frame_ticks = static_cast<u64>(BASE_CLOCK_RATE / SCREEN_REFRESH_RATE); 22constexpr u64 frame_ticks = static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / SCREEN_REFRESH_RATE);
23 23
24NVFlinger::NVFlinger() { 24NVFlinger::NVFlinger() {
25 // Add the different displays to the list of displays. 25 // Add the different displays to the list of displays.
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 278465358..e50680356 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -59,7 +59,8 @@ public:
59private: 59private:
60 void GetCurrentTimePoint(Kernel::HLERequestContext& ctx) { 60 void GetCurrentTimePoint(Kernel::HLERequestContext& ctx) {
61 NGLOG_DEBUG(Service_Time, "called"); 61 NGLOG_DEBUG(Service_Time, "called");
62 SteadyClockTimePoint steady_clock_time_point{cyclesToMs(CoreTiming::GetTicks()) / 1000}; 62 SteadyClockTimePoint steady_clock_time_point{
63 CoreTiming::cyclesToMs(CoreTiming::GetTicks()) / 1000};
63 IPC::ResponseBuilder rb{ctx, (sizeof(SteadyClockTimePoint) / 4) + 2}; 64 IPC::ResponseBuilder rb{ctx, (sizeof(SteadyClockTimePoint) / 4) + 2};
64 rb.Push(RESULT_SUCCESS); 65 rb.Push(RESULT_SUCCESS);
65 rb.PushRaw(steady_clock_time_point); 66 rb.PushRaw(steady_clock_time_point);
diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp
index bba4a0715..9ed8ab249 100644
--- a/src/core/hle/shared_page.cpp
+++ b/src/core/hle/shared_page.cpp
@@ -56,13 +56,14 @@ 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 = BASE_CLOCK_RATE; 59 date_time.tick_to_second_coefficient = CoreTiming::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;
63 63
64 // system time is updated hourly 64 // system time is updated hourly
65 CoreTiming::ScheduleEvent(msToCycles(60 * 60 * 1000) - cycles_late, update_time_event); 65 CoreTiming::ScheduleEvent(CoreTiming::msToCycles(60 * 60 * 1000) - cycles_late,
66 update_time_event);
66} 67}
67 68
68void Init() { 69void Init() {