mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-27 17:15:29 +03:00
Make GetTimeTicks return the time in guest ticks as opposed to host
This is required by audren.
This commit is contained in:
parent
d5a15faab7
commit
7d573db80b
@ -49,25 +49,27 @@ namespace skyline::util {
|
|||||||
|
|
||||||
inline const u64 ClockFrequency{detail::InitFrequency()}; //!< The system counter clock frequency in Hz
|
inline const u64 ClockFrequency{detail::InitFrequency()}; //!< The system counter clock frequency in Hz
|
||||||
|
|
||||||
|
template<i64 TargetFrequency>
|
||||||
|
inline i64 GetTimeScaled() {
|
||||||
|
u64 frequency{ClockFrequency};
|
||||||
|
u64 ticks;
|
||||||
|
asm volatile("MRS %0, CNTVCT_EL0" : "=r"(ticks));
|
||||||
|
return static_cast<i64>(((ticks / frequency) * TargetFrequency) + (((ticks % frequency) * TargetFrequency + (frequency / 2)) / frequency));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Returns the current time in nanoseconds
|
* @brief Returns the current time in nanoseconds
|
||||||
* @return The current time in nanoseconds
|
* @return The current time in nanoseconds
|
||||||
*/
|
*/
|
||||||
inline i64 GetTimeNs() {
|
inline i64 GetTimeNs() {
|
||||||
u64 frequency{ClockFrequency};
|
return GetTimeScaled<constant::NsInSecond>();
|
||||||
u64 ticks;
|
|
||||||
asm volatile("MRS %0, CNTVCT_EL0" : "=r"(ticks));
|
|
||||||
return static_cast<i64>(((ticks / frequency) * constant::NsInSecond) + (((ticks % frequency) * constant::NsInSecond + (frequency / 2)) / frequency));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the current time in arbitrary ticks
|
* @return The current time in guest ticks
|
||||||
* @return The current time in ticks
|
|
||||||
*/
|
*/
|
||||||
inline u64 GetTimeTicks() {
|
inline u64 GetTimeTicks() {
|
||||||
u64 ticks;
|
constexpr i64 TegraX1ClockFrequency{19200000}; // The clock frequency of the Tegra X1 (19.2 MHz)
|
||||||
asm volatile("MRS %0, CNTVCT_EL0" : "=r"(ticks));
|
return static_cast<u64>(GetTimeScaled<TegraX1ClockFrequency>());
|
||||||
return ticks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user