diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index beff0c31a..fbf1c338c 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -18,6 +18,7 @@ class CodeSet; class Process; class Thread; class Semaphore; +class Timer; enum class ResetType { OneShot, @@ -84,6 +85,14 @@ public: */ ResultVal> CreateSemaphore(s32 initial_count, s32 max_count, std::string name = "Unknown"); + + /** + * Creates a timer + * @param reset_type ResetType describing how to create the timer + * @param name Optional name of timer + * @return The created Timer + */ + SharedPtr CreateTimer(ResetType reset_type, std::string name = "Unknown"); }; } // namespace Kernel diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 228e12ee8..99df081b2 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -986,8 +986,8 @@ static ResultCode ClearEvent(Handle handle) { /// Creates a timer static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) { - SharedPtr timer = Timer::Create(static_cast(reset_type), - fmt ::format("timer-{:08x}", Core::CPU().GetReg(14))); + SharedPtr timer = Core::System::GetInstance().Kernel().CreateTimer( + static_cast(reset_type), fmt ::format("timer-{:08x}", Core::CPU().GetReg(14))); CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(timer))); LOG_TRACE(Kernel_SVC, "called reset_type=0x{:08X} : created handle=0x{:08X}", reset_type, diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index f1965365c..b229a94af 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -19,11 +19,11 @@ static CoreTiming::EventType* timer_callback_event_type = nullptr; // us to simply use a pool index or similar. static Kernel::HandleTable timer_callback_handle_table; -Timer::Timer() {} +Timer::Timer(KernelSystem& kernel) {} Timer::~Timer() {} -SharedPtr Timer::Create(ResetType reset_type, std::string name) { - SharedPtr timer(new Timer); +SharedPtr KernelSystem::CreateTimer(ResetType reset_type, std::string name) { + SharedPtr timer(new Timer(*this)); timer->reset_type = reset_type; timer->signaled = false; diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h index 6607f6058..c039bb4f1 100644 --- a/src/core/hle/kernel/timer.h +++ b/src/core/hle/kernel/timer.h @@ -12,14 +12,6 @@ namespace Kernel { class Timer final : public WaitObject { public: - /** - * Creates a timer - * @param reset_type ResetType describing how to create the timer - * @param name Optional name of timer - * @return The created Timer - */ - static SharedPtr Create(ResetType reset_type, std::string name = "Unknown"); - std::string GetTypeName() const override { return "Timer"; } @@ -68,7 +60,7 @@ public: void Signal(s64 cycles_late); private: - Timer(); + explicit Timer(KernelSystem& kernel); ~Timer() override; ResetType reset_type; ///< The ResetType of this timer @@ -81,6 +73,8 @@ private: /// Handle used as userdata to reference this object when inserting into the CoreTiming queue. Handle callback_handle; + + friend class KernelSystem; }; /// Initializes the required variables for timers