summaryrefslogtreecommitdiff
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index bec9837a4..46fca51c7 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -26,6 +26,7 @@
26// Namespace SVC 26// Namespace SVC
27 27
28using Kernel::SharedPtr; 28using Kernel::SharedPtr;
29using Kernel::ERR_INVALID_HANDLE;
29 30
30namespace SVC { 31namespace SVC {
31 32
@@ -71,7 +72,7 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o
71 72
72 SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle); 73 SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle);
73 if (shared_memory == nullptr) 74 if (shared_memory == nullptr)
74 return InvalidHandle(ErrorModule::Kernel); 75 return ERR_INVALID_HANDLE;
75 76
76 MemoryPermission permissions_type = static_cast<MemoryPermission>(permissions); 77 MemoryPermission permissions_type = static_cast<MemoryPermission>(permissions);
77 switch (permissions_type) { 78 switch (permissions_type) {
@@ -108,7 +109,7 @@ static ResultCode ConnectToPort(Handle* out, const char* port_name) {
108static ResultCode SendSyncRequest(Handle handle) { 109static ResultCode SendSyncRequest(Handle handle) {
109 SharedPtr<Kernel::Session> session = Kernel::g_handle_table.Get<Kernel::Session>(handle); 110 SharedPtr<Kernel::Session> session = Kernel::g_handle_table.Get<Kernel::Session>(handle);
110 if (session == nullptr) { 111 if (session == nullptr) {
111 return InvalidHandle(ErrorModule::Kernel); 112 return ERR_INVALID_HANDLE;
112 } 113 }
113 114
114 LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, session->GetName().c_str()); 115 LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, session->GetName().c_str());
@@ -127,7 +128,7 @@ static ResultCode CloseHandle(Handle handle) {
127static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) { 128static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
128 auto object = Kernel::g_handle_table.GetWaitObject(handle); 129 auto object = Kernel::g_handle_table.GetWaitObject(handle);
129 if (object == nullptr) 130 if (object == nullptr)
130 return InvalidHandle(ErrorModule::Kernel); 131 return ERR_INVALID_HANDLE;
131 132
132 LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, 133 LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle,
133 object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds); 134 object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds);
@@ -176,7 +177,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
176 for (int i = 0; i < handle_count; ++i) { 177 for (int i = 0; i < handle_count; ++i) {
177 auto object = Kernel::g_handle_table.GetWaitObject(handles[i]); 178 auto object = Kernel::g_handle_table.GetWaitObject(handles[i]);
178 if (object == nullptr) 179 if (object == nullptr)
179 return InvalidHandle(ErrorModule::Kernel); 180 return ERR_INVALID_HANDLE;
180 181
181 // Check if the current thread should wait on this object... 182 // Check if the current thread should wait on this object...
182 if (object->ShouldWait()) { 183 if (object->ShouldWait()) {
@@ -272,7 +273,7 @@ static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 val
272 273
273 SharedPtr<AddressArbiter> arbiter = Kernel::g_handle_table.Get<AddressArbiter>(handle); 274 SharedPtr<AddressArbiter> arbiter = Kernel::g_handle_table.Get<AddressArbiter>(handle);
274 if (arbiter == nullptr) 275 if (arbiter == nullptr)
275 return InvalidHandle(ErrorModule::Kernel); 276 return ERR_INVALID_HANDLE;
276 277
277 return arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type), 278 return arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type),
278 address, value, nanoseconds); 279 address, value, nanoseconds);
@@ -347,7 +348,7 @@ static void ExitThread() {
347static ResultCode GetThreadPriority(s32* priority, Handle handle) { 348static ResultCode GetThreadPriority(s32* priority, Handle handle) {
348 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); 349 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
349 if (thread == nullptr) 350 if (thread == nullptr)
350 return InvalidHandle(ErrorModule::Kernel); 351 return ERR_INVALID_HANDLE;
351 352
352 *priority = thread->GetPriority(); 353 *priority = thread->GetPriority();
353 return RESULT_SUCCESS; 354 return RESULT_SUCCESS;
@@ -357,7 +358,7 @@ static ResultCode GetThreadPriority(s32* priority, Handle handle) {
357static ResultCode SetThreadPriority(Handle handle, s32 priority) { 358static ResultCode SetThreadPriority(Handle handle, s32 priority) {
358 SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); 359 SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
359 if (thread == nullptr) 360 if (thread == nullptr)
360 return InvalidHandle(ErrorModule::Kernel); 361 return ERR_INVALID_HANDLE;
361 362
362 thread->SetPriority(priority); 363 thread->SetPriority(priority);
363 return RESULT_SUCCESS; 364 return RESULT_SUCCESS;
@@ -386,7 +387,7 @@ static ResultCode ReleaseMutex(Handle handle) {
386 387
387 SharedPtr<Mutex> mutex = Kernel::g_handle_table.Get<Mutex>(handle); 388 SharedPtr<Mutex> mutex = Kernel::g_handle_table.Get<Mutex>(handle);
388 if (mutex == nullptr) 389 if (mutex == nullptr)
389 return InvalidHandle(ErrorModule::Kernel); 390 return ERR_INVALID_HANDLE;
390 391
391 mutex->Release(); 392 mutex->Release();
392 return RESULT_SUCCESS; 393 return RESULT_SUCCESS;
@@ -398,7 +399,7 @@ static ResultCode GetThreadId(u32* thread_id, Handle handle) {
398 399
399 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); 400 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
400 if (thread == nullptr) 401 if (thread == nullptr)
401 return InvalidHandle(ErrorModule::Kernel); 402 return ERR_INVALID_HANDLE;
402 403
403 *thread_id = thread->GetThreadId(); 404 *thread_id = thread->GetThreadId();
404 return RESULT_SUCCESS; 405 return RESULT_SUCCESS;
@@ -430,7 +431,7 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count)
430 431
431 SharedPtr<Semaphore> semaphore = Kernel::g_handle_table.Get<Semaphore>(handle); 432 SharedPtr<Semaphore> semaphore = Kernel::g_handle_table.Get<Semaphore>(handle);
432 if (semaphore == nullptr) 433 if (semaphore == nullptr)
433 return InvalidHandle(ErrorModule::Kernel); 434 return ERR_INVALID_HANDLE;
434 435
435 ResultVal<s32> release_res = semaphore->Release(release_count); 436 ResultVal<s32> release_res = semaphore->Release(release_count);
436 if (release_res.Failed()) 437 if (release_res.Failed())
@@ -476,7 +477,7 @@ static ResultCode SignalEvent(Handle handle) {
476 477
477 auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle); 478 auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle);
478 if (evt == nullptr) 479 if (evt == nullptr)
479 return InvalidHandle(ErrorModule::Kernel); 480 return ERR_INVALID_HANDLE;
480 481
481 evt->Signal(); 482 evt->Signal();
482 HLE::Reschedule(__func__); 483 HLE::Reschedule(__func__);
@@ -489,7 +490,7 @@ static ResultCode ClearEvent(Handle handle) {
489 490
490 auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle); 491 auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle);
491 if (evt == nullptr) 492 if (evt == nullptr)
492 return InvalidHandle(ErrorModule::Kernel); 493 return ERR_INVALID_HANDLE;
493 494
494 evt->Clear(); 495 evt->Clear();
495 return RESULT_SUCCESS; 496 return RESULT_SUCCESS;
@@ -520,7 +521,7 @@ static ResultCode ClearTimer(Handle handle) {
520 521
521 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); 522 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
522 if (timer == nullptr) 523 if (timer == nullptr)
523 return InvalidHandle(ErrorModule::Kernel); 524 return ERR_INVALID_HANDLE;
524 525
525 timer->Clear(); 526 timer->Clear();
526 return RESULT_SUCCESS; 527 return RESULT_SUCCESS;
@@ -534,7 +535,7 @@ static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) {
534 535
535 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); 536 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
536 if (timer == nullptr) 537 if (timer == nullptr)
537 return InvalidHandle(ErrorModule::Kernel); 538 return ERR_INVALID_HANDLE;
538 539
539 timer->Set(initial, interval); 540 timer->Set(initial, interval);
540 return RESULT_SUCCESS; 541 return RESULT_SUCCESS;
@@ -548,7 +549,7 @@ static ResultCode CancelTimer(Handle handle) {
548 549
549 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); 550 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
550 if (timer == nullptr) 551 if (timer == nullptr)
551 return InvalidHandle(ErrorModule::Kernel); 552 return ERR_INVALID_HANDLE;
552 553
553 timer->Cancel(); 554 timer->Cancel();
554 return RESULT_SUCCESS; 555 return RESULT_SUCCESS;