Merge pull request #425 from lioncash/namespace
core_timing: Namespace all functions and constants in core_timing's header
This commit is contained in:
commit
f362cf46ee
|
@ -23,6 +23,8 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
|
||||||
|
namespace CoreTiming {
|
||||||
|
|
||||||
// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz
|
// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz
|
||||||
// The exact value used is of course unverified.
|
// The exact value used is of course unverified.
|
||||||
constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked
|
constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked
|
||||||
|
@ -117,8 +119,6 @@ inline u64 cyclesToMs(s64 cycles) {
|
||||||
return cycles * 1000 / BASE_CLOCK_RATE;
|
return cycles * 1000 / BASE_CLOCK_RATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CoreTiming {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CoreTiming begins at the boundary of timing slice -1. An initial call to Advance() is
|
* CoreTiming begins at the boundary of timing slice -1. An initial call to Advance() is
|
||||||
* required to end slice -1 and start slice 0 before the first cycle of code is executed.
|
* required to end slice -1 and start slice 0 before the first cycle of code is executed.
|
||||||
|
|
|
@ -146,7 +146,8 @@ void Thread::WakeAfterDelay(s64 nanoseconds) {
|
||||||
if (nanoseconds == -1)
|
if (nanoseconds == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CoreTiming::ScheduleEvent(nsToCycles(nanoseconds), ThreadWakeupEventType, callback_handle);
|
CoreTiming::ScheduleEvent(CoreTiming::nsToCycles(nanoseconds), ThreadWakeupEventType,
|
||||||
|
callback_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::CancelWakeupTimer() {
|
void Thread::CancelWakeupTimer() {
|
||||||
|
|
|
@ -57,7 +57,8 @@ void Timer::Set(s64 initial, s64 interval) {
|
||||||
// Immediately invoke the callback
|
// Immediately invoke the callback
|
||||||
Signal(0);
|
Signal(0);
|
||||||
} else {
|
} else {
|
||||||
CoreTiming::ScheduleEvent(nsToCycles(initial), timer_callback_event_type, callback_handle);
|
CoreTiming::ScheduleEvent(CoreTiming::nsToCycles(initial), timer_callback_event_type,
|
||||||
|
callback_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ void Timer::Signal(int cycles_late) {
|
||||||
|
|
||||||
if (interval_delay != 0) {
|
if (interval_delay != 0) {
|
||||||
// Reschedule the timer with the interval delay
|
// Reschedule the timer with the interval delay
|
||||||
CoreTiming::ScheduleEvent(nsToCycles(interval_delay) - cycles_late,
|
CoreTiming::ScheduleEvent(CoreTiming::nsToCycles(interval_delay) - cycles_late,
|
||||||
timer_callback_event_type, callback_handle);
|
timer_callback_event_type, callback_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ constexpr u32 sample_rate{48000};
|
||||||
/// to more audio channels (probably when Docked I guess)
|
/// to more audio channels (probably when Docked I guess)
|
||||||
constexpr u32 audio_channels{2};
|
constexpr u32 audio_channels{2};
|
||||||
/// TODO(st4rk): find a proper value for the audio_ticks
|
/// TODO(st4rk): find a proper value for the audio_ticks
|
||||||
constexpr u64 audio_ticks{static_cast<u64>(BASE_CLOCK_RATE / 500)};
|
constexpr u64 audio_ticks{static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / 500)};
|
||||||
|
|
||||||
class IAudioOut final : public ServiceFramework<IAudioOut> {
|
class IAudioOut final : public ServiceFramework<IAudioOut> {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
namespace Service::Audio {
|
namespace Service::Audio {
|
||||||
|
|
||||||
/// TODO(bunnei): Find a proper value for the audio_ticks
|
/// TODO(bunnei): Find a proper value for the audio_ticks
|
||||||
constexpr u64 audio_ticks{static_cast<u64>(BASE_CLOCK_RATE / 200)};
|
constexpr u64 audio_ticks{static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / 200)};
|
||||||
|
|
||||||
class IAudioRenderer final : public ServiceFramework<IAudioRenderer> {
|
class IAudioRenderer final : public ServiceFramework<IAudioRenderer> {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -18,9 +18,9 @@ namespace Service::HID {
|
||||||
|
|
||||||
// Updating period for each HID device.
|
// Updating period for each HID device.
|
||||||
// TODO(shinyquagsire23): These need better values.
|
// TODO(shinyquagsire23): These need better values.
|
||||||
constexpr u64 pad_update_ticks = BASE_CLOCK_RATE / 10000;
|
constexpr u64 pad_update_ticks = CoreTiming::BASE_CLOCK_RATE / 10000;
|
||||||
constexpr u64 accelerometer_update_ticks = BASE_CLOCK_RATE / 10000;
|
constexpr u64 accelerometer_update_ticks = CoreTiming::BASE_CLOCK_RATE / 10000;
|
||||||
constexpr u64 gyroscope_update_ticks = BASE_CLOCK_RATE / 10000;
|
constexpr u64 gyroscope_update_ticks = CoreTiming::BASE_CLOCK_RATE / 10000;
|
||||||
|
|
||||||
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
namespace Service::NVFlinger {
|
namespace Service::NVFlinger {
|
||||||
|
|
||||||
constexpr size_t SCREEN_REFRESH_RATE = 60;
|
constexpr size_t SCREEN_REFRESH_RATE = 60;
|
||||||
constexpr u64 frame_ticks = static_cast<u64>(BASE_CLOCK_RATE / SCREEN_REFRESH_RATE);
|
constexpr u64 frame_ticks = static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / SCREEN_REFRESH_RATE);
|
||||||
|
|
||||||
NVFlinger::NVFlinger() {
|
NVFlinger::NVFlinger() {
|
||||||
// Add the different displays to the list of displays.
|
// Add the different displays to the list of displays.
|
||||||
|
|
|
@ -59,7 +59,8 @@ public:
|
||||||
private:
|
private:
|
||||||
void GetCurrentTimePoint(Kernel::HLERequestContext& ctx) {
|
void GetCurrentTimePoint(Kernel::HLERequestContext& ctx) {
|
||||||
NGLOG_DEBUG(Service_Time, "called");
|
NGLOG_DEBUG(Service_Time, "called");
|
||||||
SteadyClockTimePoint steady_clock_time_point{cyclesToMs(CoreTiming::GetTicks()) / 1000};
|
SteadyClockTimePoint steady_clock_time_point{
|
||||||
|
CoreTiming::cyclesToMs(CoreTiming::GetTicks()) / 1000};
|
||||||
IPC::ResponseBuilder rb{ctx, (sizeof(SteadyClockTimePoint) / 4) + 2};
|
IPC::ResponseBuilder rb{ctx, (sizeof(SteadyClockTimePoint) / 4) + 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushRaw(steady_clock_time_point);
|
rb.PushRaw(steady_clock_time_point);
|
||||||
|
|
|
@ -56,13 +56,14 @@ static void UpdateTimeCallback(u64 userdata, int cycles_late) {
|
||||||
|
|
||||||
date_time.date_time = GetSystemTime();
|
date_time.date_time = GetSystemTime();
|
||||||
date_time.update_tick = CoreTiming::GetTicks();
|
date_time.update_tick = CoreTiming::GetTicks();
|
||||||
date_time.tick_to_second_coefficient = BASE_CLOCK_RATE;
|
date_time.tick_to_second_coefficient = CoreTiming::BASE_CLOCK_RATE;
|
||||||
date_time.tick_offset = 0;
|
date_time.tick_offset = 0;
|
||||||
|
|
||||||
++shared_page.date_time_counter;
|
++shared_page.date_time_counter;
|
||||||
|
|
||||||
// system time is updated hourly
|
// system time is updated hourly
|
||||||
CoreTiming::ScheduleEvent(msToCycles(60 * 60 * 1000) - cycles_late, update_time_event);
|
CoreTiming::ScheduleEvent(CoreTiming::msToCycles(60 * 60 * 1000) - cycles_late,
|
||||||
|
update_time_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init() {
|
void Init() {
|
||||||
|
|
Loading…
Reference in New Issue