summaryrefslogtreecommitdiff
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-01-23 02:19:33 -0200
committerGravatar Yuri Kunde Schlesner2015-01-30 11:47:07 -0200
commitad80ff1e322430634e04ffcb39ffef268411ea6b (patch)
treed9f7c1db67286a11812ffcc1e26f1abb5c02a033 /src/core/hle/svc.cpp
parentKernel: Convert Mutex to not use Handles (diff)
downloadyuzu-ad80ff1e322430634e04ffcb39ffef268411ea6b.tar.gz
yuzu-ad80ff1e322430634e04ffcb39ffef268411ea6b.tar.xz
yuzu-ad80ff1e322430634e04ffcb39ffef268411ea6b.zip
Kernel: Convert Timer to (mostly) not use Handles
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 76ce59b29..95403644b 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -479,28 +479,61 @@ static Result ClearEvent(Handle evt) {
479 479
480/// Creates a timer 480/// Creates a timer
481static Result CreateTimer(Handle* handle, u32 reset_type) { 481static Result CreateTimer(Handle* handle, u32 reset_type) {
482 ResultCode res = Kernel::CreateTimer(handle, static_cast<ResetType>(reset_type)); 482 using Kernel::Timer;
483 LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", 483
484 reset_type, *handle); 484 auto timer_res = Timer::Create(static_cast<ResetType>(reset_type));
485 return res.raw; 485 if (timer_res.Failed())
486 return timer_res.Code().raw;
487
488 auto handle_res = Kernel::g_handle_table.Create(timer_res.MoveFrom());
489 if (handle_res.Failed())
490 return handle_res.Code().raw;
491 *handle = handle_res.MoveFrom();
492
493 LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, *handle);
494 return RESULT_SUCCESS.raw;
486} 495}
487 496
488/// Clears a timer 497/// Clears a timer
489static Result ClearTimer(Handle handle) { 498static Result ClearTimer(Handle handle) {
499 using Kernel::Timer;
500
490 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); 501 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
491 return Kernel::ClearTimer(handle).raw; 502
503 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
504 if (timer == nullptr)
505 return InvalidHandle(ErrorModule::Kernel).raw;
506
507 timer->Clear();
508 return RESULT_SUCCESS.raw;
492} 509}
493 510
494/// Starts a timer 511/// Starts a timer
495static Result SetTimer(Handle handle, s64 initial, s64 interval) { 512static Result SetTimer(Handle handle, s64 initial, s64 interval) {
513 using Kernel::Timer;
514
496 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); 515 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
497 return Kernel::SetTimer(handle, initial, interval).raw; 516
517 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
518 if (timer == nullptr)
519 return InvalidHandle(ErrorModule::Kernel).raw;
520
521 timer->Set(initial, interval);
522 return RESULT_SUCCESS.raw;
498} 523}
499 524
500/// Cancels a timer 525/// Cancels a timer
501static Result CancelTimer(Handle handle) { 526static Result CancelTimer(Handle handle) {
527 using Kernel::Timer;
528
502 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); 529 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
503 return Kernel::CancelTimer(handle).raw; 530
531 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
532 if (timer == nullptr)
533 return InvalidHandle(ErrorModule::Kernel).raw;
534
535 timer->Cancel();
536 return RESULT_SUCCESS.raw;
504} 537}
505 538
506/// Sleep the current thread 539/// Sleep the current thread