summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar bunnei2016-12-16 00:37:38 -0500
committerGravatar bunnei2016-12-21 23:48:13 -0500
commit4fc8b8229ed1d9ea9d20faee7059c898265db6cf (patch)
tree45095e416393473fe9721c60edd9a220b2e44dd4 /src/core/hle
parentcore: Consolidate core and system state, remove system module & cleanups. (diff)
downloadyuzu-4fc8b8229ed1d9ea9d20faee7059c898265db6cf.tar.gz
yuzu-4fc8b8229ed1d9ea9d20faee7059c898265db6cf.tar.xz
yuzu-4fc8b8229ed1d9ea9d20faee7059c898265db6cf.zip
core: Remove HLE module, consolidate code & various cleanups.
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/function_wrappers.h16
-rw-r--r--src/core/hle/hle.h23
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp1
-rw-r--r--src/core/hle/kernel/kernel.h3
-rw-r--r--src/core/hle/kernel/thread.cpp5
-rw-r--r--src/core/hle/kernel/thread.h1
-rw-r--r--src/core/hle/service/csnd_snd.cpp1
-rw-r--r--src/core/hle/service/fs/archive.cpp5
-rw-r--r--src/core/hle/service/fs/archive.h4
-rw-r--r--src/core/hle/service/ir/ir.cpp3
-rw-r--r--src/core/hle/service/mic_u.cpp3
-rw-r--r--src/core/hle/svc.cpp70
12 files changed, 53 insertions, 82 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h
index 0f2a04e30..cafc7fe62 100644
--- a/src/core/hle/function_wrappers.h
+++ b/src/core/hle/function_wrappers.h
@@ -7,7 +7,7 @@
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "core/arm/arm_interface.h" 8#include "core/arm/arm_interface.h"
9#include "core/core.h" 9#include "core/core.h"
10#include "core/hle/hle.h" 10#include "core/hle/kernel/kernel.h"
11#include "core/hle/result.h" 11#include "core/hle/result.h"
12#include "core/hle/svc.h" 12#include "core/hle/svc.h"
13#include "core/memory.h" 13#include "core/memory.h"
@@ -64,7 +64,7 @@ void Wrap() {
64template <ResultCode func(s32*, u32*, s32, bool, s64)> 64template <ResultCode func(s32*, u32*, s32, bool, s64)>
65void Wrap() { 65void Wrap() {
66 s32 param_1 = 0; 66 s32 param_1 = 0;
67 s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2), 67 s32 retval = func(&param_1, (Kernel::Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
68 (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))) 68 (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0)))
69 .raw; 69 .raw;
70 70
@@ -110,7 +110,7 @@ void Wrap() {
110 FuncReturn(retval); 110 FuncReturn(retval);
111} 111}
112 112
113template <ResultCode func(MemoryInfo*, PageInfo*, Handle, u32)> 113template <ResultCode func(MemoryInfo*, PageInfo*, Kernel::Handle, u32)>
114void Wrap() { 114void Wrap() {
115 MemoryInfo memory_info = {}; 115 MemoryInfo memory_info = {};
116 PageInfo page_info = {}; 116 PageInfo page_info = {};
@@ -205,7 +205,7 @@ void Wrap() {
205 FuncReturn(func(PARAM(0), param1, param2).raw); 205 FuncReturn(func(PARAM(0), param1, param2).raw);
206} 206}
207 207
208template <ResultCode func(s64*, Handle, u32)> 208template <ResultCode func(s64*, Kernel::Handle, u32)>
209void Wrap() { 209void Wrap() {
210 s64 param_1 = 0; 210 s64 param_1 = 0;
211 u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw; 211 u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
@@ -214,15 +214,15 @@ void Wrap() {
214 FuncReturn(retval); 214 FuncReturn(retval);
215} 215}
216 216
217template <ResultCode func(Handle, u32)> 217template <ResultCode func(Kernel::Handle, u32)>
218void Wrap() { 218void Wrap() {
219 FuncReturn(func(PARAM(0), PARAM(1)).raw); 219 FuncReturn(func(PARAM(0), PARAM(1)).raw);
220} 220}
221 221
222template <ResultCode func(Handle*, Handle*, const char*, u32)> 222template <ResultCode func(Kernel::Handle*, Kernel::Handle*, const char*, u32)>
223void Wrap() { 223void Wrap() {
224 Handle param_1 = 0; 224 Kernel::Handle param_1 = 0;
225 Handle param_2 = 0; 225 Kernel::Handle param_2 = 0;
226 u32 retval = func(&param_1, &param_2, 226 u32 retval = func(&param_1, &param_2,
227 reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3)) 227 reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3))
228 .raw; 228 .raw;
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h
deleted file mode 100644
index 23859e129..000000000
--- a/src/core/hle/hle.h
+++ /dev/null
@@ -1,23 +0,0 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8
9typedef u32 Handle;
10typedef s32 Result;
11
12const Handle INVALID_HANDLE = 0;
13
14namespace HLE {
15
16void Reschedule(const char* reason);
17bool IsReschedulePending();
18void DoneRescheduling();
19
20void Init();
21void Shutdown();
22
23} // namespace
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index b5a0cc3a3..01fab123e 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -4,7 +4,6 @@
4 4
5#include "common/common_types.h" 5#include "common/common_types.h"
6#include "common/logging/log.h" 6#include "common/logging/log.h"
7#include "core/hle/hle.h"
8#include "core/hle/kernel/address_arbiter.h" 7#include "core/hle/kernel/address_arbiter.h"
9#include "core/hle/kernel/thread.h" 8#include "core/hle/kernel/thread.h"
10#include "core/memory.h" 9#include "core/memory.h"
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 1adcf6c71..9503e7d04 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -11,11 +11,12 @@
11#include <vector> 11#include <vector>
12#include <boost/smart_ptr/intrusive_ptr.hpp> 12#include <boost/smart_ptr/intrusive_ptr.hpp>
13#include "common/common_types.h" 13#include "common/common_types.h"
14#include "core/hle/hle.h"
15#include "core/hle/result.h" 14#include "core/hle/result.h"
16 15
17namespace Kernel { 16namespace Kernel {
18 17
18using Handle = u32;
19
19class Thread; 20class Thread;
20 21
21// TODO: Verify code 22// TODO: Verify code
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 91c05fc42..c964b35d4 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -14,7 +14,6 @@
14#include "core/arm/skyeye_common/armstate.h" 14#include "core/arm/skyeye_common/armstate.h"
15#include "core/core.h" 15#include "core/core.h"
16#include "core/core_timing.h" 16#include "core/core_timing.h"
17#include "core/hle/hle.h"
18#include "core/hle/kernel/kernel.h" 17#include "core/hle/kernel/kernel.h"
19#include "core/hle/kernel/memory.h" 18#include "core/hle/kernel/memory.h"
20#include "core/hle/kernel/mutex.h" 19#include "core/hle/kernel/mutex.h"
@@ -330,7 +329,7 @@ void Thread::ResumeFromWait() {
330 329
331 ready_queue.push_back(current_priority, this); 330 ready_queue.push_back(current_priority, this);
332 status = THREADSTATUS_READY; 331 status = THREADSTATUS_READY;
333 HLE::Reschedule(__func__); 332 Core::System::GetInstance().PrepareReschedule();
334} 333}
335 334
336/** 335/**
@@ -545,8 +544,6 @@ void Reschedule() {
545 Thread* cur = GetCurrentThread(); 544 Thread* cur = GetCurrentThread();
546 Thread* next = PopNextReadyThread(); 545 Thread* next = PopNextReadyThread();
547 546
548 HLE::DoneRescheduling();
549
550 if (cur && next) { 547 if (cur && next) {
551 LOG_TRACE(Kernel, "context switch %u -> %u", cur->GetObjectId(), next->GetObjectId()); 548 LOG_TRACE(Kernel, "context switch %u -> %u", cur->GetObjectId(), next->GetObjectId());
552 } else if (cur) { 549 } else if (cur) {
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index d4fefc573..89acc12c1 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -11,7 +11,6 @@
11#include <boost/container/flat_set.hpp> 11#include <boost/container/flat_set.hpp>
12#include "common/common_types.h" 12#include "common/common_types.h"
13#include "core/core.h" 13#include "core/core.h"
14#include "core/hle/hle.h"
15#include "core/hle/kernel/kernel.h" 14#include "core/hle/kernel/kernel.h"
16#include "core/hle/result.h" 15#include "core/hle/result.h"
17 16
diff --git a/src/core/hle/service/csnd_snd.cpp b/src/core/hle/service/csnd_snd.cpp
index 6544e89a2..25392f3cf 100644
--- a/src/core/hle/service/csnd_snd.cpp
+++ b/src/core/hle/service/csnd_snd.cpp
@@ -4,7 +4,6 @@
4 4
5#include <cstring> 5#include <cstring>
6#include "common/alignment.h" 6#include "common/alignment.h"
7#include "core/hle/hle.h"
8#include "core/hle/kernel/mutex.h" 7#include "core/hle/kernel/mutex.h"
9#include "core/hle/kernel/shared_memory.h" 8#include "core/hle/kernel/shared_memory.h"
10#include "core/hle/service/csnd_snd.h" 9#include "core/hle/service/csnd_snd.h"
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index 09205e4b2..6cddc1fdb 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -23,7 +23,6 @@
23#include "core/file_sys/archive_systemsavedata.h" 23#include "core/file_sys/archive_systemsavedata.h"
24#include "core/file_sys/directory_backend.h" 24#include "core/file_sys/directory_backend.h"
25#include "core/file_sys/file_backend.h" 25#include "core/file_sys/file_backend.h"
26#include "core/hle/hle.h"
27#include "core/hle/kernel/client_session.h" 26#include "core/hle/kernel/client_session.h"
28#include "core/hle/result.h" 27#include "core/hle/result.h"
29#include "core/hle/service/fs/archive.h" 28#include "core/hle/service/fs/archive.h"
@@ -46,9 +45,7 @@ struct hash<Service::FS::ArchiveIdCode> {
46}; 45};
47} 46}
48 47
49/// TODO(Subv): Confirm length of these strings 48static constexpr Kernel::Handle INVALID_HANDLE{};
50const std::string SYSTEM_ID = "00000000000000000000000000000000";
51const std::string SDCARD_ID = "00000000000000000000000000000000";
52 49
53namespace Service { 50namespace Service {
54namespace FS { 51namespace FS {
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h
index 7ba62ede0..0aa373f40 100644
--- a/src/core/hle/service/fs/archive.h
+++ b/src/core/hle/service/fs/archive.h
@@ -17,9 +17,9 @@ class FileBackend;
17} 17}
18 18
19/// The unique system identifier hash, also known as ID0 19/// The unique system identifier hash, also known as ID0
20extern const std::string SYSTEM_ID; 20static constexpr char SYSTEM_ID[]{ "00000000000000000000000000000000" };
21/// The scrambled SD card CID, also known as ID1 21/// The scrambled SD card CID, also known as ID1
22extern const std::string SDCARD_ID; 22static constexpr char SDCARD_ID[]{ "00000000000000000000000000000000" };
23 23
24namespace Service { 24namespace Service {
25namespace FS { 25namespace FS {
diff --git a/src/core/hle/service/ir/ir.cpp b/src/core/hle/service/ir/ir.cpp
index 4d6639ded..7f1731a50 100644
--- a/src/core/hle/service/ir/ir.cpp
+++ b/src/core/hle/service/ir/ir.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "core/hle/kernel/event.h" 5#include "core/hle/kernel/event.h"
6#include "core/hle/kernel/kernel.h"
6#include "core/hle/kernel/shared_memory.h" 7#include "core/hle/kernel/shared_memory.h"
7#include "core/hle/service/ir/ir.h" 8#include "core/hle/service/ir/ir.h"
8#include "core/hle/service/ir/ir_rst.h" 9#include "core/hle/service/ir/ir_rst.h"
@@ -36,7 +37,7 @@ void InitializeIrNopShared(Interface* self) {
36 u32 send_buff_size = cmd_buff[4]; 37 u32 send_buff_size = cmd_buff[4];
37 u32 unk2 = cmd_buff[5]; 38 u32 unk2 = cmd_buff[5];
38 u8 baud_rate = cmd_buff[6] & 0xFF; 39 u8 baud_rate = cmd_buff[6] & 0xFF;
39 Handle handle = cmd_buff[8]; 40 Kernel::Handle handle = cmd_buff[8];
40 41
41 if (Kernel::g_handle_table.IsValid(handle)) { 42 if (Kernel::g_handle_table.IsValid(handle)) {
42 transfer_shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle); 43 transfer_shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle);
diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp
index 7ced36439..4f1dd2fce 100644
--- a/src/core/hle/service/mic_u.cpp
+++ b/src/core/hle/service/mic_u.cpp
@@ -4,6 +4,7 @@
4 4
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6#include "core/hle/kernel/event.h" 6#include "core/hle/kernel/event.h"
7#include "core/hle/kernel/kernel.h"
7#include "core/hle/kernel/shared_memory.h" 8#include "core/hle/kernel/shared_memory.h"
8#include "core/hle/service/mic_u.h" 9#include "core/hle/service/mic_u.h"
9 10
@@ -50,7 +51,7 @@ static bool audio_buffer_loop;
50static void MapSharedMem(Interface* self) { 51static void MapSharedMem(Interface* self) {
51 u32* cmd_buff = Kernel::GetCommandBuffer(); 52 u32* cmd_buff = Kernel::GetCommandBuffer();
52 u32 size = cmd_buff[1]; 53 u32 size = cmd_buff[1];
53 Handle mem_handle = cmd_buff[3]; 54 Kernel::Handle mem_handle = cmd_buff[3];
54 shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(mem_handle); 55 shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(mem_handle);
55 if (shared_memory) { 56 if (shared_memory) {
56 shared_memory->name = "MIC_U:shared_memory"; 57 shared_memory->name = "MIC_U:shared_memory";
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index b20f2aaa4..5a52525c6 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -166,7 +166,7 @@ static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 add
166} 166}
167 167
168/// Maps a memory block to specified address 168/// Maps a memory block to specified address
169static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { 169static ResultCode MapMemoryBlock(Kernel::Handle handle, u32 addr, u32 permissions, u32 other_permissions) {
170 using Kernel::SharedMemory; 170 using Kernel::SharedMemory;
171 using Kernel::MemoryPermission; 171 using Kernel::MemoryPermission;
172 172
@@ -198,7 +198,7 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o
198 ErrorSummary::InvalidArgument, ErrorLevel::Usage); 198 ErrorSummary::InvalidArgument, ErrorLevel::Usage);
199} 199}
200 200
201static ResultCode UnmapMemoryBlock(Handle handle, u32 addr) { 201static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) {
202 using Kernel::SharedMemory; 202 using Kernel::SharedMemory;
203 203
204 LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X", handle, addr); 204 LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X", handle, addr);
@@ -213,7 +213,7 @@ static ResultCode UnmapMemoryBlock(Handle handle, u32 addr) {
213} 213}
214 214
215/// Connect to an OS service given the port name, returns the handle to the port to out 215/// Connect to an OS service given the port name, returns the handle to the port to out
216static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) { 216static ResultCode ConnectToPort(Kernel::Handle* out_handle, const char* port_name) {
217 if (port_name == nullptr) 217 if (port_name == nullptr)
218 return ERR_NOT_FOUND; 218 return ERR_NOT_FOUND;
219 if (std::strlen(port_name) > 11) 219 if (std::strlen(port_name) > 11)
@@ -238,7 +238,7 @@ static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) {
238} 238}
239 239
240/// Makes a blocking IPC call to an OS service. 240/// Makes a blocking IPC call to an OS service.
241static ResultCode SendSyncRequest(Handle handle) { 241static ResultCode SendSyncRequest(Kernel::Handle handle) {
242 SharedPtr<Kernel::ClientSession> session = 242 SharedPtr<Kernel::ClientSession> session =
243 Kernel::g_handle_table.Get<Kernel::ClientSession>(handle); 243 Kernel::g_handle_table.Get<Kernel::ClientSession>(handle);
244 if (session == nullptr) { 244 if (session == nullptr) {
@@ -253,13 +253,13 @@ static ResultCode SendSyncRequest(Handle handle) {
253} 253}
254 254
255/// Close a handle 255/// Close a handle
256static ResultCode CloseHandle(Handle handle) { 256static ResultCode CloseHandle(Kernel::Handle handle) {
257 LOG_TRACE(Kernel_SVC, "Closing handle 0x%08X", handle); 257 LOG_TRACE(Kernel_SVC, "Closing handle 0x%08X", handle);
258 return Kernel::g_handle_table.Close(handle); 258 return Kernel::g_handle_table.Close(handle);
259} 259}
260 260
261/// Wait for a handle to synchronize, timeout after the specified nanoseconds 261/// Wait for a handle to synchronize, timeout after the specified nanoseconds
262static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) { 262static ResultCode WaitSynchronization1(Kernel::Handle handle, s64 nano_seconds) {
263 auto object = Kernel::g_handle_table.GetWaitObject(handle); 263 auto object = Kernel::g_handle_table.GetWaitObject(handle);
264 Kernel::Thread* thread = Kernel::GetCurrentThread(); 264 Kernel::Thread* thread = Kernel::GetCurrentThread();
265 265
@@ -295,7 +295,7 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
295} 295}
296 296
297/// Wait for the given handles to synchronize, timeout after the specified nanoseconds 297/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
298static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wait_all, 298static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 handle_count, bool wait_all,
299 s64 nano_seconds) { 299 s64 nano_seconds) {
300 Kernel::Thread* thread = Kernel::GetCurrentThread(); 300 Kernel::Thread* thread = Kernel::GetCurrentThread();
301 301
@@ -423,7 +423,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
423} 423}
424 424
425/// Create an address arbiter (to allocate access to shared resources) 425/// Create an address arbiter (to allocate access to shared resources)
426static ResultCode CreateAddressArbiter(Handle* out_handle) { 426static ResultCode CreateAddressArbiter(Kernel::Handle* out_handle) {
427 using Kernel::AddressArbiter; 427 using Kernel::AddressArbiter;
428 428
429 SharedPtr<AddressArbiter> arbiter = AddressArbiter::Create(); 429 SharedPtr<AddressArbiter> arbiter = AddressArbiter::Create();
@@ -433,7 +433,7 @@ static ResultCode CreateAddressArbiter(Handle* out_handle) {
433} 433}
434 434
435/// Arbitrate address 435/// Arbitrate address
436static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value, 436static ResultCode ArbitrateAddress(Kernel::Handle handle, u32 address, u32 type, u32 value,
437 s64 nanoseconds) { 437 s64 nanoseconds) {
438 using Kernel::AddressArbiter; 438 using Kernel::AddressArbiter;
439 439
@@ -476,7 +476,7 @@ static void OutputDebugString(const char* string) {
476} 476}
477 477
478/// Get resource limit 478/// Get resource limit
479static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle) { 479static ResultCode GetResourceLimit(Kernel::Handle* resource_limit, Kernel::Handle process_handle) {
480 LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); 480 LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle);
481 481
482 SharedPtr<Kernel::Process> process = 482 SharedPtr<Kernel::Process> process =
@@ -490,7 +490,7 @@ static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle
490} 490}
491 491
492/// Get resource limit current values 492/// Get resource limit current values
493static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_limit_handle, 493static ResultCode GetResourceLimitCurrentValues(s64* values, Kernel::Handle resource_limit_handle,
494 u32* names, u32 name_count) { 494 u32* names, u32 name_count) {
495 LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d", 495 LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d",
496 resource_limit_handle, names, name_count); 496 resource_limit_handle, names, name_count);
@@ -507,7 +507,7 @@ static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_lim
507} 507}
508 508
509/// Get resource limit max values 509/// Get resource limit max values
510static ResultCode GetResourceLimitLimitValues(s64* values, Handle resource_limit_handle, u32* names, 510static ResultCode GetResourceLimitLimitValues(s64* values, Kernel::Handle resource_limit_handle, u32* names,
511 u32 name_count) { 511 u32 name_count) {
512 LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d", 512 LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d",
513 resource_limit_handle, names, name_count); 513 resource_limit_handle, names, name_count);
@@ -524,7 +524,7 @@ static ResultCode GetResourceLimitLimitValues(s64* values, Handle resource_limit
524} 524}
525 525
526/// Creates a new thread 526/// Creates a new thread
527static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point, u32 arg, 527static ResultCode CreateThread(Kernel::Handle* out_handle, s32 priority, u32 entry_point, u32 arg,
528 u32 stack_top, s32 processor_id) { 528 u32 stack_top, s32 processor_id) {
529 using Kernel::Thread; 529 using Kernel::Thread;
530 530
@@ -588,7 +588,7 @@ static void ExitThread() {
588} 588}
589 589
590/// Gets the priority for the specified thread 590/// Gets the priority for the specified thread
591static ResultCode GetThreadPriority(s32* priority, Handle handle) { 591static ResultCode GetThreadPriority(s32* priority, Kernel::Handle handle) {
592 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); 592 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
593 if (thread == nullptr) 593 if (thread == nullptr)
594 return ERR_INVALID_HANDLE; 594 return ERR_INVALID_HANDLE;
@@ -598,7 +598,7 @@ static ResultCode GetThreadPriority(s32* priority, Handle handle) {
598} 598}
599 599
600/// Sets the priority for the specified thread 600/// Sets the priority for the specified thread
601static ResultCode SetThreadPriority(Handle handle, s32 priority) { 601static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) {
602 SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); 602 SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
603 if (thread == nullptr) 603 if (thread == nullptr)
604 return ERR_INVALID_HANDLE; 604 return ERR_INVALID_HANDLE;
@@ -608,7 +608,7 @@ static ResultCode SetThreadPriority(Handle handle, s32 priority) {
608} 608}
609 609
610/// Create a mutex 610/// Create a mutex
611static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) { 611static ResultCode CreateMutex(Kernel::Handle* out_handle, u32 initial_locked) {
612 using Kernel::Mutex; 612 using Kernel::Mutex;
613 613
614 SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0); 614 SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0);
@@ -622,7 +622,7 @@ static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) {
622} 622}
623 623
624/// Release a mutex 624/// Release a mutex
625static ResultCode ReleaseMutex(Handle handle) { 625static ResultCode ReleaseMutex(Kernel::Handle handle) {
626 using Kernel::Mutex; 626 using Kernel::Mutex;
627 627
628 LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle); 628 LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle);
@@ -637,7 +637,7 @@ static ResultCode ReleaseMutex(Handle handle) {
637} 637}
638 638
639/// Get the ID of the specified process 639/// Get the ID of the specified process
640static ResultCode GetProcessId(u32* process_id, Handle process_handle) { 640static ResultCode GetProcessId(u32* process_id, Kernel::Handle process_handle) {
641 LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); 641 LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle);
642 642
643 const SharedPtr<Kernel::Process> process = 643 const SharedPtr<Kernel::Process> process =
@@ -650,7 +650,7 @@ static ResultCode GetProcessId(u32* process_id, Handle process_handle) {
650} 650}
651 651
652/// Get the ID of the process that owns the specified thread 652/// Get the ID of the process that owns the specified thread
653static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) { 653static ResultCode GetProcessIdOfThread(u32* process_id, Kernel::Handle thread_handle) {
654 LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); 654 LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle);
655 655
656 const SharedPtr<Kernel::Thread> thread = 656 const SharedPtr<Kernel::Thread> thread =
@@ -667,7 +667,7 @@ static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) {
667} 667}
668 668
669/// Get the ID for the specified thread. 669/// Get the ID for the specified thread.
670static ResultCode GetThreadId(u32* thread_id, Handle handle) { 670static ResultCode GetThreadId(u32* thread_id, Kernel::Handle handle) {
671 LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); 671 LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle);
672 672
673 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); 673 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
@@ -679,7 +679,7 @@ static ResultCode GetThreadId(u32* thread_id, Handle handle) {
679} 679}
680 680
681/// Creates a semaphore 681/// Creates a semaphore
682static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max_count) { 682static ResultCode CreateSemaphore(Kernel::Handle* out_handle, s32 initial_count, s32 max_count) {
683 using Kernel::Semaphore; 683 using Kernel::Semaphore;
684 684
685 CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count)); 685 CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count));
@@ -692,7 +692,7 @@ static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max
692} 692}
693 693
694/// Releases a certain number of slots in a semaphore 694/// Releases a certain number of slots in a semaphore
695static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) { 695static ResultCode ReleaseSemaphore(s32* count, Kernel::Handle handle, s32 release_count) {
696 using Kernel::Semaphore; 696 using Kernel::Semaphore;
697 697
698 LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, handle); 698 LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, handle);
@@ -708,7 +708,7 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count)
708 708
709/// Query process memory 709/// Query process memory
710static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, 710static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info,
711 Handle process_handle, u32 addr) { 711 Kernel::Handle process_handle, u32 addr) {
712 using Kernel::Process; 712 using Kernel::Process;
713 Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle); 713 Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle);
714 if (process == nullptr) 714 if (process == nullptr)
@@ -736,7 +736,7 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32
736} 736}
737 737
738/// Create an event 738/// Create an event
739static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) { 739static ResultCode CreateEvent(Kernel::Handle* out_handle, u32 reset_type) {
740 using Kernel::Event; 740 using Kernel::Event;
741 741
742 SharedPtr<Event> evt = Event::Create(static_cast<Kernel::ResetType>(reset_type)); 742 SharedPtr<Event> evt = Event::Create(static_cast<Kernel::ResetType>(reset_type));
@@ -749,14 +749,14 @@ static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
749} 749}
750 750
751/// Duplicates a kernel handle 751/// Duplicates a kernel handle
752static ResultCode DuplicateHandle(Handle* out, Handle handle) { 752static ResultCode DuplicateHandle(Kernel::Handle* out, Kernel::Handle handle) {
753 CASCADE_RESULT(*out, Kernel::g_handle_table.Duplicate(handle)); 753 CASCADE_RESULT(*out, Kernel::g_handle_table.Duplicate(handle));
754 LOG_TRACE(Kernel_SVC, "duplicated 0x%08X to 0x%08X", handle, *out); 754 LOG_TRACE(Kernel_SVC, "duplicated 0x%08X to 0x%08X", handle, *out);
755 return RESULT_SUCCESS; 755 return RESULT_SUCCESS;
756} 756}
757 757
758/// Signals an event 758/// Signals an event
759static ResultCode SignalEvent(Handle handle) { 759static ResultCode SignalEvent(Kernel::Handle handle) {
760 using Kernel::Event; 760 using Kernel::Event;
761 LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle); 761 LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle);
762 762
@@ -770,7 +770,7 @@ static ResultCode SignalEvent(Handle handle) {
770} 770}
771 771
772/// Clears an event 772/// Clears an event
773static ResultCode ClearEvent(Handle handle) { 773static ResultCode ClearEvent(Kernel::Handle handle) {
774 using Kernel::Event; 774 using Kernel::Event;
775 LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle); 775 LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle);
776 776
@@ -783,7 +783,7 @@ static ResultCode ClearEvent(Handle handle) {
783} 783}
784 784
785/// Creates a timer 785/// Creates a timer
786static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) { 786static ResultCode CreateTimer(Kernel::Handle* out_handle, u32 reset_type) {
787 using Kernel::Timer; 787 using Kernel::Timer;
788 788
789 SharedPtr<Timer> timer = Timer::Create(static_cast<Kernel::ResetType>(reset_type)); 789 SharedPtr<Timer> timer = Timer::Create(static_cast<Kernel::ResetType>(reset_type));
@@ -796,7 +796,7 @@ static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) {
796} 796}
797 797
798/// Clears a timer 798/// Clears a timer
799static ResultCode ClearTimer(Handle handle) { 799static ResultCode ClearTimer(Kernel::Handle handle) {
800 using Kernel::Timer; 800 using Kernel::Timer;
801 801
802 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); 802 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
@@ -810,7 +810,7 @@ static ResultCode ClearTimer(Handle handle) {
810} 810}
811 811
812/// Starts a timer 812/// Starts a timer
813static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) { 813static ResultCode SetTimer(Kernel::Handle handle, s64 initial, s64 interval) {
814 using Kernel::Timer; 814 using Kernel::Timer;
815 815
816 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); 816 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
@@ -825,7 +825,7 @@ static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) {
825} 825}
826 826
827/// Cancels a timer 827/// Cancels a timer
828static ResultCode CancelTimer(Handle handle) { 828static ResultCode CancelTimer(Kernel::Handle handle) {
829 using Kernel::Timer; 829 using Kernel::Timer;
830 830
831 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); 831 LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
@@ -860,7 +860,7 @@ static s64 GetSystemTick() {
860} 860}
861 861
862/// Creates a memory block at the specified address with the specified permissions and size 862/// Creates a memory block at the specified address with the specified permissions and size
863static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission, 863static ResultCode CreateMemoryBlock(Kernel::Handle* out_handle, u32 addr, u32 size, u32 my_permission,
864 u32 other_permission) { 864 u32 other_permission) {
865 using Kernel::SharedMemory; 865 using Kernel::SharedMemory;
866 866
@@ -912,7 +912,7 @@ static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32
912 return RESULT_SUCCESS; 912 return RESULT_SUCCESS;
913} 913}
914 914
915static ResultCode CreatePort(Handle* server_port, Handle* client_port, const char* name, 915static ResultCode CreatePort(Kernel::Handle* server_port, Kernel::Handle* client_port, const char* name,
916 u32 max_sessions) { 916 u32 max_sessions) {
917 // TODO(Subv): Implement named ports. 917 // TODO(Subv): Implement named ports.
918 ASSERT_MSG(name == nullptr, "Named ports are currently unimplemented"); 918 ASSERT_MSG(name == nullptr, "Named ports are currently unimplemented");
@@ -978,7 +978,7 @@ static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) {
978 return RESULT_SUCCESS; 978 return RESULT_SUCCESS;
979} 979}
980 980
981static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) { 981static ResultCode GetProcessInfo(s64* out, Kernel::Handle process_handle, u32 type) {
982 LOG_TRACE(Kernel_SVC, "called process=0x%08X type=%u", process_handle, type); 982 LOG_TRACE(Kernel_SVC, "called process=0x%08X type=%u", process_handle, type);
983 983
984 using Kernel::Process; 984 using Kernel::Process;
@@ -1185,7 +1185,7 @@ void CallSVC(u32 immediate) {
1185 if (info->func) { 1185 if (info->func) {
1186 info->func(); 1186 info->func();
1187 // TODO(Subv): Not all service functions should cause a reschedule in all cases. 1187 // TODO(Subv): Not all service functions should cause a reschedule in all cases.
1188 HLE::Reschedule(__func__); 1188 Core::System::GetInstance().PrepareReschedule();
1189 } else { 1189 } else {
1190 LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name); 1190 LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name);
1191 } 1191 }