mirror of
https://github.com/PabloMK7/citra
synced 2024-11-15 05:08:23 +00:00
Kernel: pass ref to timer
This commit is contained in:
parent
247249d5d3
commit
c141657d83
4 changed files with 17 additions and 14 deletions
|
@ -18,6 +18,7 @@ class CodeSet;
|
|||
class Process;
|
||||
class Thread;
|
||||
class Semaphore;
|
||||
class Timer;
|
||||
|
||||
enum class ResetType {
|
||||
OneShot,
|
||||
|
@ -84,6 +85,14 @@ public:
|
|||
*/
|
||||
ResultVal<SharedPtr<Semaphore>> 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<Timer> CreateTimer(ResetType reset_type, std::string name = "Unknown");
|
||||
};
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -986,8 +986,8 @@ static ResultCode ClearEvent(Handle handle) {
|
|||
|
||||
/// Creates a timer
|
||||
static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) {
|
||||
SharedPtr<Timer> timer = Timer::Create(static_cast<ResetType>(reset_type),
|
||||
fmt ::format("timer-{:08x}", Core::CPU().GetReg(14)));
|
||||
SharedPtr<Timer> timer = Core::System::GetInstance().Kernel().CreateTimer(
|
||||
static_cast<ResetType>(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,
|
||||
|
|
|
@ -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> Timer::Create(ResetType reset_type, std::string name) {
|
||||
SharedPtr<Timer> timer(new Timer);
|
||||
SharedPtr<Timer> KernelSystem::CreateTimer(ResetType reset_type, std::string name) {
|
||||
SharedPtr<Timer> timer(new Timer(*this));
|
||||
|
||||
timer->reset_type = reset_type;
|
||||
timer->signaled = false;
|
||||
|
|
|
@ -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<Timer> 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
|
||||
|
|
Loading…
Reference in a new issue