summaryrefslogtreecommitdiff
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-01-11 13:53:11 -0200
committerGravatar Yuri Kunde Schlesner2015-01-30 11:47:05 -0200
commitd9b19be1d9c1baa5e8b92c1960c14e435e6b532f (patch)
treeda083beea826952f0a9c07ab392992ef6ca84c5c /src/core/hle/svc.cpp
parentKernel: Convert SharedMemory to not use Handles (diff)
downloadyuzu-d9b19be1d9c1baa5e8b92c1960c14e435e6b532f.tar.gz
yuzu-d9b19be1d9c1baa5e8b92c1960c14e435e6b532f.tar.xz
yuzu-d9b19be1d9c1baa5e8b92c1960c14e435e6b532f.zip
Kernel: Convert Semaphore to not use Handles
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 165da0402..6cbe38bc3 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -374,17 +374,38 @@ static Result GetThreadId(u32* thread_id, Handle handle) {
374 374
375/// Creates a semaphore 375/// Creates a semaphore
376static Result CreateSemaphore(Handle* semaphore, s32 initial_count, s32 max_count) { 376static Result CreateSemaphore(Handle* semaphore, s32 initial_count, s32 max_count) {
377 ResultCode res = Kernel::CreateSemaphore(semaphore, initial_count, max_count); 377 using Kernel::Semaphore;
378
379 ResultVal<SharedPtr<Semaphore>> semaphore_res = Semaphore::Create(initial_count, max_count);
380 if (semaphore_res.Failed())
381 return semaphore_res.Code().raw;
382
383 ResultVal<Handle> handle_res = Kernel::g_handle_table.Create(*semaphore_res);
384 if (handle_res.Failed())
385 return handle_res.Code().raw;
386
387 *semaphore = *handle_res;
378 LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X", 388 LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X",
379 initial_count, max_count, *semaphore); 389 initial_count, max_count, *semaphore);
380 return res.raw; 390 return RESULT_SUCCESS.raw;
381} 391}
382 392
383/// Releases a certain number of slots in a semaphore 393/// Releases a certain number of slots in a semaphore
384static Result ReleaseSemaphore(s32* count, Handle semaphore, s32 release_count) { 394static Result ReleaseSemaphore(s32* count, Handle handle, s32 release_count) {
385 LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, semaphore); 395 using Kernel::Semaphore;
386 ResultCode res = Kernel::ReleaseSemaphore(count, semaphore, release_count); 396
387 return res.raw; 397 LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, handle);
398
399 SharedPtr<Semaphore> semaphore = Kernel::g_handle_table.Get<Semaphore>(handle);
400 if (semaphore == nullptr)
401 return InvalidHandle(ErrorModule::Kernel).raw;
402
403 ResultVal<s32> release_res = semaphore->Release(release_count);
404 if (release_res.Failed())
405 return release_res.Code().raw;
406
407 *count = *release_res;
408 return RESULT_SUCCESS.raw;
388} 409}
389 410
390/// Query memory 411/// Query memory