mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-30 11:02:39 -06: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 Process;
|
||||||
class Thread;
|
class Thread;
|
||||||
class Semaphore;
|
class Semaphore;
|
||||||
|
class Timer;
|
||||||
|
|
||||||
enum class ResetType {
|
enum class ResetType {
|
||||||
OneShot,
|
OneShot,
|
||||||
|
@ -84,6 +85,14 @@ public:
|
||||||
*/
|
*/
|
||||||
ResultVal<SharedPtr<Semaphore>> CreateSemaphore(s32 initial_count, s32 max_count,
|
ResultVal<SharedPtr<Semaphore>> CreateSemaphore(s32 initial_count, s32 max_count,
|
||||||
std::string name = "Unknown");
|
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
|
} // namespace Kernel
|
||||||
|
|
|
@ -986,8 +986,8 @@ static ResultCode ClearEvent(Handle handle) {
|
||||||
|
|
||||||
/// Creates a timer
|
/// Creates a timer
|
||||||
static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) {
|
static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) {
|
||||||
SharedPtr<Timer> timer = Timer::Create(static_cast<ResetType>(reset_type),
|
SharedPtr<Timer> timer = Core::System::GetInstance().Kernel().CreateTimer(
|
||||||
fmt ::format("timer-{:08x}", Core::CPU().GetReg(14)));
|
static_cast<ResetType>(reset_type), fmt ::format("timer-{:08x}", Core::CPU().GetReg(14)));
|
||||||
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(timer)));
|
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,
|
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.
|
// us to simply use a pool index or similar.
|
||||||
static Kernel::HandleTable timer_callback_handle_table;
|
static Kernel::HandleTable timer_callback_handle_table;
|
||||||
|
|
||||||
Timer::Timer() {}
|
Timer::Timer(KernelSystem& kernel) {}
|
||||||
Timer::~Timer() {}
|
Timer::~Timer() {}
|
||||||
|
|
||||||
SharedPtr<Timer> Timer::Create(ResetType reset_type, std::string name) {
|
SharedPtr<Timer> KernelSystem::CreateTimer(ResetType reset_type, std::string name) {
|
||||||
SharedPtr<Timer> timer(new Timer);
|
SharedPtr<Timer> timer(new Timer(*this));
|
||||||
|
|
||||||
timer->reset_type = reset_type;
|
timer->reset_type = reset_type;
|
||||||
timer->signaled = false;
|
timer->signaled = false;
|
||||||
|
|
|
@ -12,14 +12,6 @@ namespace Kernel {
|
||||||
|
|
||||||
class Timer final : public WaitObject {
|
class Timer final : public WaitObject {
|
||||||
public:
|
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 {
|
std::string GetTypeName() const override {
|
||||||
return "Timer";
|
return "Timer";
|
||||||
}
|
}
|
||||||
|
@ -68,7 +60,7 @@ public:
|
||||||
void Signal(s64 cycles_late);
|
void Signal(s64 cycles_late);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Timer();
|
explicit Timer(KernelSystem& kernel);
|
||||||
~Timer() override;
|
~Timer() override;
|
||||||
|
|
||||||
ResetType reset_type; ///< The ResetType of this timer
|
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 used as userdata to reference this object when inserting into the CoreTiming queue.
|
||||||
Handle callback_handle;
|
Handle callback_handle;
|
||||||
|
|
||||||
|
friend class KernelSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Initializes the required variables for timers
|
/// Initializes the required variables for timers
|
||||||
|
|
Loading…
Reference in a new issue