Core: Set all hardware emulation constants in a single file.

This commit is contained in:
Fernando Sahmkow 2020-02-11 19:56:24 -04:00 committed by FernandoS27
parent d23d504d77
commit 1e6f8aba04
17 changed files with 88 additions and 53 deletions

View file

@ -14,6 +14,7 @@
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/gdbstub/gdbstub.h" #include "core/gdbstub/gdbstub.h"
#include "core/hardware_properties.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/scheduler.h" #include "core/hle/kernel/scheduler.h"
#include "core/hle/kernel/svc.h" #include "core/hle/kernel/svc.h"
@ -153,7 +154,7 @@ std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit(Common::PageTable& pag
config.tpidr_el0 = &cb->tpidr_el0; config.tpidr_el0 = &cb->tpidr_el0;
config.dczid_el0 = 4; config.dczid_el0 = 4;
config.ctr_el0 = 0x8444c004; config.ctr_el0 = 0x8444c004;
config.cntfrq_el0 = Timing::CNTFREQ; config.cntfrq_el0 = Hardware::CNTFREQ;
// Unpredictable instructions // Unpredictable instructions
config.define_unpredictable_behaviour = true; config.define_unpredictable_behaviour = true;

View file

@ -12,6 +12,7 @@
#include "common/assert.h" #include "common/assert.h"
#include "common/thread.h" #include "common/thread.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/hardware_properties.h"
namespace Core::Timing { namespace Core::Timing {
@ -215,7 +216,7 @@ void CoreTiming::Idle() {
} }
std::chrono::microseconds CoreTiming::GetGlobalTimeUs() const { std::chrono::microseconds CoreTiming::GetGlobalTimeUs() const {
return std::chrono::microseconds{GetTicks() * 1000000 / BASE_CLOCK_RATE}; return std::chrono::microseconds{GetTicks() * 1000000 / Hardware::BASE_CLOCK_RATE};
} }
s64 CoreTiming::GetDowncount() const { s64 CoreTiming::GetDowncount() const {

View file

@ -11,7 +11,7 @@
namespace Core::Timing { namespace Core::Timing {
constexpr u64 MAX_VALUE_TO_MULTIPLY = std::numeric_limits<s64>::max() / BASE_CLOCK_RATE; constexpr u64 MAX_VALUE_TO_MULTIPLY = std::numeric_limits<s64>::max() / Hardware::BASE_CLOCK_RATE;
s64 msToCycles(std::chrono::milliseconds ms) { s64 msToCycles(std::chrono::milliseconds ms) {
if (static_cast<u64>(ms.count() / 1000) > MAX_VALUE_TO_MULTIPLY) { if (static_cast<u64>(ms.count() / 1000) > MAX_VALUE_TO_MULTIPLY) {
@ -20,9 +20,9 @@ s64 msToCycles(std::chrono::milliseconds ms) {
} }
if (static_cast<u64>(ms.count()) > MAX_VALUE_TO_MULTIPLY) { if (static_cast<u64>(ms.count()) > MAX_VALUE_TO_MULTIPLY) {
LOG_DEBUG(Core_Timing, "Time very big, do rounding"); LOG_DEBUG(Core_Timing, "Time very big, do rounding");
return BASE_CLOCK_RATE * (ms.count() / 1000); return Hardware::BASE_CLOCK_RATE * (ms.count() / 1000);
} }
return (BASE_CLOCK_RATE * ms.count()) / 1000; return (Hardware::BASE_CLOCK_RATE * ms.count()) / 1000;
} }
s64 usToCycles(std::chrono::microseconds us) { s64 usToCycles(std::chrono::microseconds us) {
@ -32,9 +32,9 @@ s64 usToCycles(std::chrono::microseconds us) {
} }
if (static_cast<u64>(us.count()) > MAX_VALUE_TO_MULTIPLY) { if (static_cast<u64>(us.count()) > MAX_VALUE_TO_MULTIPLY) {
LOG_DEBUG(Core_Timing, "Time very big, do rounding"); LOG_DEBUG(Core_Timing, "Time very big, do rounding");
return BASE_CLOCK_RATE * (us.count() / 1000000); return Hardware::BASE_CLOCK_RATE * (us.count() / 1000000);
} }
return (BASE_CLOCK_RATE * us.count()) / 1000000; return (Hardware::BASE_CLOCK_RATE * us.count()) / 1000000;
} }
s64 nsToCycles(std::chrono::nanoseconds ns) { s64 nsToCycles(std::chrono::nanoseconds ns) {
@ -44,14 +44,14 @@ s64 nsToCycles(std::chrono::nanoseconds ns) {
} }
if (static_cast<u64>(ns.count()) > MAX_VALUE_TO_MULTIPLY) { if (static_cast<u64>(ns.count()) > MAX_VALUE_TO_MULTIPLY) {
LOG_DEBUG(Core_Timing, "Time very big, do rounding"); LOG_DEBUG(Core_Timing, "Time very big, do rounding");
return BASE_CLOCK_RATE * (ns.count() / 1000000000); return Hardware::BASE_CLOCK_RATE * (ns.count() / 1000000000);
} }
return (BASE_CLOCK_RATE * ns.count()) / 1000000000; return (Hardware::BASE_CLOCK_RATE * ns.count()) / 1000000000;
} }
u64 CpuCyclesToClockCycles(u64 ticks) { u64 CpuCyclesToClockCycles(u64 ticks) {
const u128 temporal = Common::Multiply64Into128(ticks, CNTFREQ); const u128 temporal = Common::Multiply64Into128(ticks, Hardware::CNTFREQ);
return Common::Divide128On32(temporal, static_cast<u32>(BASE_CLOCK_RATE)).first; return Common::Divide128On32(temporal, static_cast<u32>(Hardware::BASE_CLOCK_RATE)).first;
} }
} // namespace Core::Timing } // namespace Core::Timing

View file

@ -6,28 +6,24 @@
#include <chrono> #include <chrono>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hardware_properties.h"
namespace Core::Timing { namespace Core::Timing {
// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz
// The exact value used is of course unverified.
constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked
constexpr u64 CNTFREQ = 19200000; // Value from fusee.
s64 msToCycles(std::chrono::milliseconds ms); s64 msToCycles(std::chrono::milliseconds ms);
s64 usToCycles(std::chrono::microseconds us); s64 usToCycles(std::chrono::microseconds us);
s64 nsToCycles(std::chrono::nanoseconds ns); s64 nsToCycles(std::chrono::nanoseconds ns);
inline std::chrono::milliseconds CyclesToMs(s64 cycles) { inline std::chrono::milliseconds CyclesToMs(s64 cycles) {
return std::chrono::milliseconds(cycles * 1000 / BASE_CLOCK_RATE); return std::chrono::milliseconds(cycles * 1000 / Hardware::BASE_CLOCK_RATE);
} }
inline std::chrono::nanoseconds CyclesToNs(s64 cycles) { inline std::chrono::nanoseconds CyclesToNs(s64 cycles) {
return std::chrono::nanoseconds(cycles * 1000000000 / BASE_CLOCK_RATE); return std::chrono::nanoseconds(cycles * 1000000000 / Hardware::BASE_CLOCK_RATE);
} }
inline std::chrono::microseconds CyclesToUs(s64 cycles) { inline std::chrono::microseconds CyclesToUs(s64 cycles) {
return std::chrono::microseconds(cycles * 1000000 / BASE_CLOCK_RATE); return std::chrono::microseconds(cycles * 1000000 / Hardware::BASE_CLOCK_RATE);
} }
u64 CpuCyclesToClockCycles(u64 ticks); u64 CpuCyclesToClockCycles(u64 ticks);

View file

@ -6,6 +6,7 @@
#include <array> #include <array>
#include <memory> #include <memory>
#include "core/hardware_properties.h"
namespace Core { namespace Core {
@ -39,9 +40,7 @@ public:
void RunLoop(bool tight_loop); void RunLoop(bool tight_loop);
private: private:
static constexpr std::size_t NUM_CPU_CORES = 4; std::array<std::unique_ptr<CoreManager>, Hardware::NUM_CPU_CORES> core_managers;
std::array<std::unique_ptr<CoreManager>, NUM_CPU_CORES> core_managers;
std::size_t active_core{}; ///< Active core, only used in single thread mode std::size_t active_core{}; ///< Active core, only used in single thread mode
System& system; System& system;

View file

@ -0,0 +1,28 @@
// Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "common/common_types.h"
namespace Core {
union EmuThreadHandle {
u64 raw;
struct {
u32 host_handle;
u32 guest_handle;
};
};
namespace Hardware {
// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz
// The exact value used is of course unverified.
constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch cpu frequency is 1020MHz un/docked
constexpr u64 CNTFREQ = 19200000; // Switch's hardware clock speed
constexpr u32 NUM_CPU_CORES = 4; // Number of CPU Cores
} // namespace Hardware
} // namespace Core

View file

@ -124,8 +124,8 @@ bool GlobalScheduler::YieldThreadAndBalanceLoad(Thread* yielding_thread) {
"Thread yielding without being in front"); "Thread yielding without being in front");
scheduled_queue[core_id].yield(priority); scheduled_queue[core_id].yield(priority);
std::array<Thread*, NUM_CPU_CORES> current_threads; std::array<Thread*, Core::Hardware::NUM_CPU_CORES> current_threads;
for (u32 i = 0; i < NUM_CPU_CORES; i++) { for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
current_threads[i] = scheduled_queue[i].empty() ? nullptr : scheduled_queue[i].front(); current_threads[i] = scheduled_queue[i].empty() ? nullptr : scheduled_queue[i].front();
} }
@ -177,8 +177,8 @@ bool GlobalScheduler::YieldThreadAndWaitForLoadBalancing(Thread* yielding_thread
// function... // function...
if (scheduled_queue[core_id].empty()) { if (scheduled_queue[core_id].empty()) {
// Here, "current_threads" is calculated after the ""yield"", unlike yield -1 // Here, "current_threads" is calculated after the ""yield"", unlike yield -1
std::array<Thread*, NUM_CPU_CORES> current_threads; std::array<Thread*, Core::Hardware::NUM_CPU_CORES> current_threads;
for (u32 i = 0; i < NUM_CPU_CORES; i++) { for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
current_threads[i] = scheduled_queue[i].empty() ? nullptr : scheduled_queue[i].front(); current_threads[i] = scheduled_queue[i].empty() ? nullptr : scheduled_queue[i].front();
} }
for (auto& thread : suggested_queue[core_id]) { for (auto& thread : suggested_queue[core_id]) {
@ -208,7 +208,7 @@ bool GlobalScheduler::YieldThreadAndWaitForLoadBalancing(Thread* yielding_thread
} }
void GlobalScheduler::PreemptThreads() { void GlobalScheduler::PreemptThreads() {
for (std::size_t core_id = 0; core_id < NUM_CPU_CORES; core_id++) { for (std::size_t core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
const u32 priority = preemption_priorities[core_id]; const u32 priority = preemption_priorities[core_id];
if (scheduled_queue[core_id].size(priority) > 0) { if (scheduled_queue[core_id].size(priority) > 0) {
@ -349,7 +349,7 @@ bool GlobalScheduler::AskForReselectionOrMarkRedundant(Thread* current_thread,
} }
void GlobalScheduler::Shutdown() { void GlobalScheduler::Shutdown() {
for (std::size_t core = 0; core < NUM_CPU_CORES; core++) { for (std::size_t core = 0; core < Core::Hardware::NUM_CPU_CORES; core++) {
scheduled_queue[core].clear(); scheduled_queue[core].clear();
suggested_queue[core].clear(); suggested_queue[core].clear();
} }

View file

@ -10,6 +10,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/multi_level_queue.h" #include "common/multi_level_queue.h"
#include "core/hardware_properties.h"
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
namespace Core { namespace Core {
@ -23,8 +24,6 @@ class Process;
class GlobalScheduler final { class GlobalScheduler final {
public: public:
static constexpr u32 NUM_CPU_CORES = 4;
explicit GlobalScheduler(Core::System& system); explicit GlobalScheduler(Core::System& system);
~GlobalScheduler(); ~GlobalScheduler();
@ -125,7 +124,7 @@ public:
void PreemptThreads(); void PreemptThreads();
u32 CpuCoresCount() const { u32 CpuCoresCount() const {
return NUM_CPU_CORES; return Core::Hardware::NUM_CPU_CORES;
} }
void SetReselectionPending() { void SetReselectionPending() {
@ -149,13 +148,15 @@ private:
bool AskForReselectionOrMarkRedundant(Thread* current_thread, const Thread* winner); bool AskForReselectionOrMarkRedundant(Thread* current_thread, const Thread* winner);
static constexpr u32 min_regular_priority = 2; static constexpr u32 min_regular_priority = 2;
std::array<Common::MultiLevelQueue<Thread*, THREADPRIO_COUNT>, NUM_CPU_CORES> scheduled_queue; std::array<Common::MultiLevelQueue<Thread*, THREADPRIO_COUNT>, Core::Hardware::NUM_CPU_CORES>
std::array<Common::MultiLevelQueue<Thread*, THREADPRIO_COUNT>, NUM_CPU_CORES> suggested_queue; scheduled_queue;
std::array<Common::MultiLevelQueue<Thread*, THREADPRIO_COUNT>, Core::Hardware::NUM_CPU_CORES>
suggested_queue;
std::atomic<bool> is_reselection_pending{false}; std::atomic<bool> is_reselection_pending{false};
// The priority levels at which the global scheduler preempts threads every 10 ms. They are // The priority levels at which the global scheduler preempts threads every 10 ms. They are
// ordered from Core 0 to Core 3. // ordered from Core 0 to Core 3.
std::array<u32, NUM_CPU_CORES> preemption_priorities = {59, 59, 59, 62}; std::array<u32, Core::Hardware::NUM_CPU_CORES> preemption_priorities = {59, 59, 59, 62};
/// Lists all thread ids that aren't deleted/etc. /// Lists all thread ids that aren't deleted/etc.
std::vector<std::shared_ptr<Thread>> thread_list; std::vector<std::shared_ptr<Thread>> thread_list;

View file

@ -15,6 +15,7 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/hardware_properties.h"
#include "core/hle/kernel/errors.h" #include "core/hle/kernel/errors.h"
#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
@ -431,7 +432,7 @@ ResultCode Thread::SetCoreAndAffinityMask(s32 new_core, u64 new_affinity_mask) {
const s32 old_core = processor_id; const s32 old_core = processor_id;
if (processor_id >= 0 && ((affinity_mask >> processor_id) & 1) == 0) { if (processor_id >= 0 && ((affinity_mask >> processor_id) & 1) == 0) {
if (static_cast<s32>(ideal_core) < 0) { if (static_cast<s32>(ideal_core) < 0) {
processor_id = HighestSetCore(affinity_mask, GlobalScheduler::NUM_CPU_CORES); processor_id = HighestSetCore(affinity_mask, Core::Hardware::NUM_CPU_CORES);
} else { } else {
processor_id = ideal_core; processor_id = ideal_core;
} }
@ -455,7 +456,7 @@ void Thread::AdjustSchedulingOnStatus(u32 old_flags) {
scheduler.Unschedule(current_priority, static_cast<u32>(processor_id), this); scheduler.Unschedule(current_priority, static_cast<u32>(processor_id), this);
} }
for (u32 core = 0; core < GlobalScheduler::NUM_CPU_CORES; core++) { for (u32 core = 0; core < Core::Hardware::NUM_CPU_CORES; core++) {
if (core != static_cast<u32>(processor_id) && ((affinity_mask >> core) & 1) != 0) { if (core != static_cast<u32>(processor_id) && ((affinity_mask >> core) & 1) != 0) {
scheduler.Unsuggest(current_priority, core, this); scheduler.Unsuggest(current_priority, core, this);
} }
@ -466,7 +467,7 @@ void Thread::AdjustSchedulingOnStatus(u32 old_flags) {
scheduler.Schedule(current_priority, static_cast<u32>(processor_id), this); scheduler.Schedule(current_priority, static_cast<u32>(processor_id), this);
} }
for (u32 core = 0; core < GlobalScheduler::NUM_CPU_CORES; core++) { for (u32 core = 0; core < Core::Hardware::NUM_CPU_CORES; core++) {
if (core != static_cast<u32>(processor_id) && ((affinity_mask >> core) & 1) != 0) { if (core != static_cast<u32>(processor_id) && ((affinity_mask >> core) & 1) != 0) {
scheduler.Suggest(current_priority, core, this); scheduler.Suggest(current_priority, core, this);
} }
@ -485,7 +486,7 @@ void Thread::AdjustSchedulingOnPriority(u32 old_priority) {
scheduler.Unschedule(old_priority, static_cast<u32>(processor_id), this); scheduler.Unschedule(old_priority, static_cast<u32>(processor_id), this);
} }
for (u32 core = 0; core < GlobalScheduler::NUM_CPU_CORES; core++) { for (u32 core = 0; core < Core::Hardware::NUM_CPU_CORES; core++) {
if (core != static_cast<u32>(processor_id) && ((affinity_mask >> core) & 1) != 0) { if (core != static_cast<u32>(processor_id) && ((affinity_mask >> core) & 1) != 0) {
scheduler.Unsuggest(old_priority, core, this); scheduler.Unsuggest(old_priority, core, this);
} }
@ -502,7 +503,7 @@ void Thread::AdjustSchedulingOnPriority(u32 old_priority) {
} }
} }
for (u32 core = 0; core < GlobalScheduler::NUM_CPU_CORES; core++) { for (u32 core = 0; core < Core::Hardware::NUM_CPU_CORES; core++) {
if (core != static_cast<u32>(processor_id) && ((affinity_mask >> core) & 1) != 0) { if (core != static_cast<u32>(processor_id) && ((affinity_mask >> core) & 1) != 0) {
scheduler.Suggest(current_priority, core, this); scheduler.Suggest(current_priority, core, this);
} }
@ -518,7 +519,7 @@ void Thread::AdjustSchedulingOnAffinity(u64 old_affinity_mask, s32 old_core) {
return; return;
} }
for (u32 core = 0; core < GlobalScheduler::NUM_CPU_CORES; core++) { for (u32 core = 0; core < Core::Hardware::NUM_CPU_CORES; core++) {
if (((old_affinity_mask >> core) & 1) != 0) { if (((old_affinity_mask >> core) & 1) != 0) {
if (core == static_cast<u32>(old_core)) { if (core == static_cast<u32>(old_core)) {
scheduler.Unschedule(current_priority, core, this); scheduler.Unschedule(current_priority, core, this);
@ -528,7 +529,7 @@ void Thread::AdjustSchedulingOnAffinity(u64 old_affinity_mask, s32 old_core) {
} }
} }
for (u32 core = 0; core < GlobalScheduler::NUM_CPU_CORES; core++) { for (u32 core = 0; core < Core::Hardware::NUM_CPU_CORES; core++) {
if (((affinity_mask >> core) & 1) != 0) { if (((affinity_mask >> core) & 1) != 0) {
if (core == static_cast<u32>(processor_id)) { if (core == static_cast<u32>(processor_id)) {
scheduler.Schedule(current_priority, core, this); scheduler.Schedule(current_priority, core, this);

View file

@ -10,6 +10,7 @@
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/frontend/emu_window.h" #include "core/frontend/emu_window.h"
#include "core/frontend/input.h" #include "core/frontend/input.h"
#include "core/hardware_properties.h"
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/client_session.h" #include "core/hle/kernel/client_session.h"
@ -37,11 +38,11 @@ namespace Service::HID {
// Updating period for each HID device. // Updating period for each HID device.
// TODO(ogniK): Find actual polling rate of hid // TODO(ogniK): Find actual polling rate of hid
constexpr s64 pad_update_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 66); constexpr s64 pad_update_ticks = static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 66);
[[maybe_unused]] constexpr s64 accelerometer_update_ticks = [[maybe_unused]] constexpr s64 accelerometer_update_ticks =
static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 100); static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 100);
[[maybe_unused]] constexpr s64 gyroscope_update_ticks = [[maybe_unused]] constexpr s64 gyroscope_update_ticks =
static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 100); static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 100);
constexpr std::size_t SHARED_MEMORY_SIZE = 0x40000; constexpr std::size_t SHARED_MEMORY_SIZE = 0x40000;
IAppletResource::IAppletResource(Core::System& system) IAppletResource::IAppletResource(Core::System& system)

View file

@ -12,6 +12,7 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/hardware_properties.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/readable_event.h"
#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
@ -26,8 +27,8 @@
namespace Service::NVFlinger { namespace Service::NVFlinger {
constexpr s64 frame_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60); constexpr s64 frame_ticks = static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 60);
constexpr s64 frame_ticks_30fps = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 30); constexpr s64 frame_ticks_30fps = static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 30);
NVFlinger::NVFlinger(Core::System& system) : system(system) { NVFlinger::NVFlinger(Core::System& system) : system(system) {
displays.emplace_back(0, "Default", system); displays.emplace_back(0, "Default", system);
@ -222,7 +223,7 @@ void NVFlinger::Compose() {
s64 NVFlinger::GetNextTicks() const { s64 NVFlinger::GetNextTicks() const {
constexpr s64 max_hertz = 120LL; constexpr s64 max_hertz = 120LL;
return (Core::Timing::BASE_CLOCK_RATE * (1LL << swap_interval)) / max_hertz; return (Core::Hardware::BASE_CLOCK_RATE * (1LL << swap_interval)) / max_hertz;
} }
} // namespace Service::NVFlinger } // namespace Service::NVFlinger

View file

@ -5,6 +5,7 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/hardware_properties.h"
#include "core/hle/service/time/standard_steady_clock_core.h" #include "core/hle/service/time/standard_steady_clock_core.h"
namespace Service::Time::Clock { namespace Service::Time::Clock {
@ -12,7 +13,7 @@ namespace Service::Time::Clock {
TimeSpanType StandardSteadyClockCore::GetCurrentRawTimePoint(Core::System& system) { TimeSpanType StandardSteadyClockCore::GetCurrentRawTimePoint(Core::System& system) {
const TimeSpanType ticks_time_span{TimeSpanType::FromTicks( const TimeSpanType ticks_time_span{TimeSpanType::FromTicks(
Core::Timing::CpuCyclesToClockCycles(system.CoreTiming().GetTicks()), Core::Timing::CpuCyclesToClockCycles(system.CoreTiming().GetTicks()),
Core::Timing::CNTFREQ)}; Core::Hardware::CNTFREQ)};
TimeSpanType raw_time_point{setup_value.nanoseconds + ticks_time_span.nanoseconds}; TimeSpanType raw_time_point{setup_value.nanoseconds + ticks_time_span.nanoseconds};
if (raw_time_point.nanoseconds < cached_raw_time_point.nanoseconds) { if (raw_time_point.nanoseconds < cached_raw_time_point.nanoseconds) {

View file

@ -5,6 +5,7 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/hardware_properties.h"
#include "core/hle/service/time/tick_based_steady_clock_core.h" #include "core/hle/service/time/tick_based_steady_clock_core.h"
namespace Service::Time::Clock { namespace Service::Time::Clock {
@ -12,7 +13,7 @@ namespace Service::Time::Clock {
SteadyClockTimePoint TickBasedSteadyClockCore::GetTimePoint(Core::System& system) { SteadyClockTimePoint TickBasedSteadyClockCore::GetTimePoint(Core::System& system) {
const TimeSpanType ticks_time_span{TimeSpanType::FromTicks( const TimeSpanType ticks_time_span{TimeSpanType::FromTicks(
Core::Timing::CpuCyclesToClockCycles(system.CoreTiming().GetTicks()), Core::Timing::CpuCyclesToClockCycles(system.CoreTiming().GetTicks()),
Core::Timing::CNTFREQ)}; Core::Hardware::CNTFREQ)};
return {ticks_time_span.ToSeconds(), GetClockSourceId()}; return {ticks_time_span.ToSeconds(), GetClockSourceId()};
} }

View file

@ -6,6 +6,7 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/hardware_properties.h"
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/client_session.h" #include "core/hle/kernel/client_session.h"
@ -233,7 +234,7 @@ void Module::Interface::CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERe
if (current_time_point.clock_source_id == context.steady_time_point.clock_source_id) { if (current_time_point.clock_source_id == context.steady_time_point.clock_source_id) {
const auto ticks{Clock::TimeSpanType::FromTicks( const auto ticks{Clock::TimeSpanType::FromTicks(
Core::Timing::CpuCyclesToClockCycles(system.CoreTiming().GetTicks()), Core::Timing::CpuCyclesToClockCycles(system.CoreTiming().GetTicks()),
Core::Timing::CNTFREQ)}; Core::Hardware::CNTFREQ)};
const s64 base_time_point{context.offset + current_time_point.time_point - const s64 base_time_point{context.offset + current_time_point.time_point -
ticks.ToSeconds()}; ticks.ToSeconds()};
IPC::ResponseBuilder rb{ctx, (sizeof(s64) / 4) + 2}; IPC::ResponseBuilder rb{ctx, (sizeof(s64) / 4) + 2};

View file

@ -5,6 +5,7 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/hardware_properties.h"
#include "core/hle/service/time/clock_types.h" #include "core/hle/service/time/clock_types.h"
#include "core/hle/service/time/steady_clock_core.h" #include "core/hle/service/time/steady_clock_core.h"
#include "core/hle/service/time/time_sharedmemory.h" #include "core/hle/service/time/time_sharedmemory.h"
@ -31,7 +32,7 @@ void SharedMemory::SetupStandardSteadyClock(Core::System& system,
Clock::TimeSpanType current_time_point) { Clock::TimeSpanType current_time_point) {
const Clock::TimeSpanType ticks_time_span{Clock::TimeSpanType::FromTicks( const Clock::TimeSpanType ticks_time_span{Clock::TimeSpanType::FromTicks(
Core::Timing::CpuCyclesToClockCycles(system.CoreTiming().GetTicks()), Core::Timing::CpuCyclesToClockCycles(system.CoreTiming().GetTicks()),
Core::Timing::CNTFREQ)}; Core::Hardware::CNTFREQ)};
const Clock::SteadyClockContext context{ const Clock::SteadyClockContext context{
static_cast<u64>(current_time_point.nanoseconds - ticks_time_span.nanoseconds), static_cast<u64>(current_time_point.nanoseconds - ticks_time_span.nanoseconds),
clock_source_id}; clock_source_id};

View file

@ -9,6 +9,7 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/hardware_properties.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/service/hid/controllers/npad.h" #include "core/hle/service/hid/controllers/npad.h"
#include "core/hle/service/hid/hid.h" #include "core/hle/service/hid/hid.h"
@ -17,7 +18,7 @@
namespace Memory { namespace Memory {
constexpr s64 CHEAT_ENGINE_TICKS = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 12); constexpr s64 CHEAT_ENGINE_TICKS = static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 12);
constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF; constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF;
StandardVmCallbacks::StandardVmCallbacks(Core::System& system, const CheatProcessMetadata& metadata) StandardVmCallbacks::StandardVmCallbacks(Core::System& system, const CheatProcessMetadata& metadata)

View file

@ -7,13 +7,14 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/hardware_properties.h"
#include "core/memory.h" #include "core/memory.h"
#include "core/tools/freezer.h" #include "core/tools/freezer.h"
namespace Tools { namespace Tools {
namespace { namespace {
constexpr s64 MEMORY_FREEZER_TICKS = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60); constexpr s64 MEMORY_FREEZER_TICKS = static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 60);
u64 MemoryReadWidth(Memory::Memory& memory, u32 width, VAddr addr) { u64 MemoryReadWidth(Memory::Memory& memory, u32 width, VAddr addr) {
switch (width) { switch (width) {