summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-07-03 00:26:45 -0400
committerGravatar GitHub2018-07-03 00:26:45 -0400
commit15e68cdbaac38bbf13cd4eb0d70d1e34b2fd4256 (patch)
tree9d072a572c0037a44e1e35aeffc242d3772a383c /src/core/hle/kernel/svc.cpp
parentMerge pull request #612 from bunnei/fix-cull (diff)
parentFix build and address review feedback (diff)
downloadyuzu-15e68cdbaac38bbf13cd4eb0d70d1e34b2fd4256.tar.gz
yuzu-15e68cdbaac38bbf13cd4eb0d70d1e34b2fd4256.tar.xz
yuzu-15e68cdbaac38bbf13cd4eb0d70d1e34b2fd4256.zip
Merge pull request #607 from jroweboy/logging
Logging - Customizable backends
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp139
1 files changed, 68 insertions, 71 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 1a36e0d02..5ad923fe7 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -32,7 +32,7 @@ namespace Kernel {
32 32
33/// Set the process heap to a given Size. It can both extend and shrink the heap. 33/// Set the process heap to a given Size. It can both extend and shrink the heap.
34static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { 34static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) {
35 NGLOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size); 35 LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size);
36 auto& process = *Core::CurrentProcess(); 36 auto& process = *Core::CurrentProcess();
37 CASCADE_RESULT(*heap_addr, 37 CASCADE_RESULT(*heap_addr,
38 process.HeapAllocate(Memory::HEAP_VADDR, heap_size, VMAPermission::ReadWrite)); 38 process.HeapAllocate(Memory::HEAP_VADDR, heap_size, VMAPermission::ReadWrite));
@@ -40,21 +40,21 @@ static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) {
40} 40}
41 41
42static ResultCode SetMemoryAttribute(VAddr addr, u64 size, u32 state0, u32 state1) { 42static ResultCode SetMemoryAttribute(VAddr addr, u64 size, u32 state0, u32 state1) {
43 NGLOG_WARNING(Kernel_SVC, "(STUBBED) called, addr=0x{:X}", addr); 43 LOG_WARNING(Kernel_SVC, "(STUBBED) called, addr=0x{:X}", addr);
44 return RESULT_SUCCESS; 44 return RESULT_SUCCESS;
45} 45}
46 46
47/// Maps a memory range into a different range. 47/// Maps a memory range into a different range.
48static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { 48static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) {
49 NGLOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 49 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
50 src_addr, size); 50 src_addr, size);
51 return Core::CurrentProcess()->MirrorMemory(dst_addr, src_addr, size); 51 return Core::CurrentProcess()->MirrorMemory(dst_addr, src_addr, size);
52} 52}
53 53
54/// Unmaps a region that was previously mapped with svcMapMemory 54/// Unmaps a region that was previously mapped with svcMapMemory
55static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { 55static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) {
56 NGLOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 56 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
57 src_addr, size); 57 src_addr, size);
58 return Core::CurrentProcess()->UnmapMemory(dst_addr, src_addr, size); 58 return Core::CurrentProcess()->UnmapMemory(dst_addr, src_addr, size);
59} 59}
60 60
@@ -69,11 +69,11 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address
69 if (port_name.size() > PortNameMaxLength) 69 if (port_name.size() > PortNameMaxLength)
70 return ERR_PORT_NAME_TOO_LONG; 70 return ERR_PORT_NAME_TOO_LONG;
71 71
72 NGLOG_TRACE(Kernel_SVC, "called port_name={}", port_name); 72 LOG_TRACE(Kernel_SVC, "called port_name={}", port_name);
73 73
74 auto it = Service::g_kernel_named_ports.find(port_name); 74 auto it = Service::g_kernel_named_ports.find(port_name);
75 if (it == Service::g_kernel_named_ports.end()) { 75 if (it == Service::g_kernel_named_ports.end()) {
76 NGLOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name); 76 LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name);
77 return ERR_NOT_FOUND; 77 return ERR_NOT_FOUND;
78 } 78 }
79 79
@@ -91,11 +91,11 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address
91static ResultCode SendSyncRequest(Handle handle) { 91static ResultCode SendSyncRequest(Handle handle) {
92 SharedPtr<ClientSession> session = g_handle_table.Get<ClientSession>(handle); 92 SharedPtr<ClientSession> session = g_handle_table.Get<ClientSession>(handle);
93 if (!session) { 93 if (!session) {
94 NGLOG_ERROR(Kernel_SVC, "called with invalid handle=0x{:08X}", handle); 94 LOG_ERROR(Kernel_SVC, "called with invalid handle=0x{:08X}", handle);
95 return ERR_INVALID_HANDLE; 95 return ERR_INVALID_HANDLE;
96 } 96 }
97 97
98 NGLOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName()); 98 LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName());
99 99
100 Core::System::GetInstance().PrepareReschedule(); 100 Core::System::GetInstance().PrepareReschedule();
101 101
@@ -106,7 +106,7 @@ static ResultCode SendSyncRequest(Handle handle) {
106 106
107/// Get the ID for the specified thread. 107/// Get the ID for the specified thread.
108static ResultCode GetThreadId(u32* thread_id, Handle thread_handle) { 108static ResultCode GetThreadId(u32* thread_id, Handle thread_handle) {
109 NGLOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); 109 LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle);
110 110
111 const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); 111 const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle);
112 if (!thread) { 112 if (!thread) {
@@ -119,7 +119,7 @@ static ResultCode GetThreadId(u32* thread_id, Handle thread_handle) {
119 119
120/// Get the ID of the specified process 120/// Get the ID of the specified process
121static ResultCode GetProcessId(u32* process_id, Handle process_handle) { 121static ResultCode GetProcessId(u32* process_id, Handle process_handle) {
122 NGLOG_TRACE(Kernel_SVC, "called process=0x{:08X}", process_handle); 122 LOG_TRACE(Kernel_SVC, "called process=0x{:08X}", process_handle);
123 123
124 const SharedPtr<Process> process = g_handle_table.Get<Process>(process_handle); 124 const SharedPtr<Process> process = g_handle_table.Get<Process>(process_handle);
125 if (!process) { 125 if (!process) {
@@ -149,8 +149,8 @@ static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thr
149/// Wait for the given handles to synchronize, timeout after the specified nanoseconds 149/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
150static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 handle_count, 150static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 handle_count,
151 s64 nano_seconds) { 151 s64 nano_seconds) {
152 NGLOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, handle_count={}, nano_seconds={}", 152 LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, handle_count={}, nano_seconds={}",
153 handles_address, handle_count, nano_seconds); 153 handles_address, handle_count, nano_seconds);
154 154
155 if (!Memory::IsValidVirtualAddress(handles_address)) 155 if (!Memory::IsValidVirtualAddress(handles_address))
156 return ERR_INVALID_POINTER; 156 return ERR_INVALID_POINTER;
@@ -210,7 +210,7 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64
210 210
211/// Resumes a thread waiting on WaitSynchronization 211/// Resumes a thread waiting on WaitSynchronization
212static ResultCode CancelSynchronization(Handle thread_handle) { 212static ResultCode CancelSynchronization(Handle thread_handle) {
213 NGLOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle); 213 LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle);
214 214
215 const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); 215 const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle);
216 if (!thread) { 216 if (!thread) {
@@ -227,24 +227,24 @@ static ResultCode CancelSynchronization(Handle thread_handle) {
227/// Attempts to locks a mutex, creating it if it does not already exist 227/// Attempts to locks a mutex, creating it if it does not already exist
228static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr, 228static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr,
229 Handle requesting_thread_handle) { 229 Handle requesting_thread_handle) {
230 NGLOG_TRACE(Kernel_SVC, 230 LOG_TRACE(Kernel_SVC,
231 "called holding_thread_handle=0x{:08X}, mutex_addr=0x{:X}, " 231 "called holding_thread_handle=0x{:08X}, mutex_addr=0x{:X}, "
232 "requesting_current_thread_handle=0x{:08X}", 232 "requesting_current_thread_handle=0x{:08X}",
233 holding_thread_handle, mutex_addr, requesting_thread_handle); 233 holding_thread_handle, mutex_addr, requesting_thread_handle);
234 234
235 return Mutex::TryAcquire(mutex_addr, holding_thread_handle, requesting_thread_handle); 235 return Mutex::TryAcquire(mutex_addr, holding_thread_handle, requesting_thread_handle);
236} 236}
237 237
238/// Unlock a mutex 238/// Unlock a mutex
239static ResultCode ArbitrateUnlock(VAddr mutex_addr) { 239static ResultCode ArbitrateUnlock(VAddr mutex_addr) {
240 NGLOG_TRACE(Kernel_SVC, "called mutex_addr=0x{:X}", mutex_addr); 240 LOG_TRACE(Kernel_SVC, "called mutex_addr=0x{:X}", mutex_addr);
241 241
242 return Mutex::Release(mutex_addr); 242 return Mutex::Release(mutex_addr);
243} 243}
244 244
245/// Break program execution 245/// Break program execution
246static void Break(u64 unk_0, u64 unk_1, u64 unk_2) { 246static void Break(u64 unk_0, u64 unk_1, u64 unk_2) {
247 NGLOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!"); 247 LOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!");
248 ASSERT(false); 248 ASSERT(false);
249} 249}
250 250
@@ -252,13 +252,13 @@ static void Break(u64 unk_0, u64 unk_1, u64 unk_2) {
252static void OutputDebugString(VAddr address, s32 len) { 252static void OutputDebugString(VAddr address, s32 len) {
253 std::string str(len, '\0'); 253 std::string str(len, '\0');
254 Memory::ReadBlock(address, str.data(), str.size()); 254 Memory::ReadBlock(address, str.data(), str.size());
255 NGLOG_DEBUG(Debug_Emulated, "{}", str); 255 LOG_DEBUG(Debug_Emulated, "{}", str);
256} 256}
257 257
258/// Gets system/memory information for the current process 258/// Gets system/memory information for the current process
259static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) { 259static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) {
260 NGLOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, 260 LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
261 info_sub_id, handle); 261 info_sub_id, handle);
262 262
263 auto& vm_manager = Core::CurrentProcess()->vm_manager; 263 auto& vm_manager = Core::CurrentProcess()->vm_manager;
264 264
@@ -309,17 +309,17 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
309 *result = Core::CurrentProcess()->is_virtual_address_memory_enabled; 309 *result = Core::CurrentProcess()->is_virtual_address_memory_enabled;
310 break; 310 break;
311 case GetInfoType::TitleId: 311 case GetInfoType::TitleId:
312 NGLOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query titleid, returned 0"); 312 LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query titleid, returned 0");
313 *result = 0; 313 *result = 0;
314 break; 314 break;
315 case GetInfoType::PrivilegedProcessId: 315 case GetInfoType::PrivilegedProcessId:
316 NGLOG_WARNING(Kernel_SVC, 316 LOG_WARNING(Kernel_SVC,
317 "(STUBBED) Attempted to query privileged process id bounds, returned 0"); 317 "(STUBBED) Attempted to query privileged process id bounds, returned 0");
318 *result = 0; 318 *result = 0;
319 break; 319 break;
320 case GetInfoType::UserExceptionContextAddr: 320 case GetInfoType::UserExceptionContextAddr:
321 NGLOG_WARNING(Kernel_SVC, 321 LOG_WARNING(Kernel_SVC,
322 "(STUBBED) Attempted to query user exception context address, returned 0"); 322 "(STUBBED) Attempted to query user exception context address, returned 0");
323 *result = 0; 323 *result = 0;
324 break; 324 break;
325 default: 325 default:
@@ -331,14 +331,13 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
331 331
332/// Sets the thread activity 332/// Sets the thread activity
333static ResultCode SetThreadActivity(Handle handle, u32 unknown) { 333static ResultCode SetThreadActivity(Handle handle, u32 unknown) {
334 NGLOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, unknown=0x{:08X}", handle, 334 LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, unknown=0x{:08X}", handle, unknown);
335 unknown);
336 return RESULT_SUCCESS; 335 return RESULT_SUCCESS;
337} 336}
338 337
339/// Gets the thread context 338/// Gets the thread context
340static ResultCode GetThreadContext(Handle handle, VAddr addr) { 339static ResultCode GetThreadContext(Handle handle, VAddr addr) {
341 NGLOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, addr=0x{:X}", handle, addr); 340 LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, addr=0x{:X}", handle, addr);
342 return RESULT_SUCCESS; 341 return RESULT_SUCCESS;
343} 342}
344 343
@@ -377,16 +376,15 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) {
377 376
378/// Get which CPU core is executing the current thread 377/// Get which CPU core is executing the current thread
379static u32 GetCurrentProcessorNumber() { 378static u32 GetCurrentProcessorNumber() {
380 NGLOG_TRACE(Kernel_SVC, "called"); 379 LOG_TRACE(Kernel_SVC, "called");
381 return GetCurrentThread()->processor_id; 380 return GetCurrentThread()->processor_id;
382} 381}
383 382
384static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size, 383static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size,
385 u32 permissions) { 384 u32 permissions) {
386 NGLOG_TRACE( 385 LOG_TRACE(Kernel_SVC,
387 Kernel_SVC, 386 "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}",
388 "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", 387 shared_memory_handle, addr, size, permissions);
389 shared_memory_handle, addr, size, permissions);
390 388
391 SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle); 389 SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle);
392 if (!shared_memory) { 390 if (!shared_memory) {
@@ -406,15 +404,15 @@ static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 s
406 return shared_memory->Map(Core::CurrentProcess().get(), addr, permissions_type, 404 return shared_memory->Map(Core::CurrentProcess().get(), addr, permissions_type,
407 MemoryPermission::DontCare); 405 MemoryPermission::DontCare);
408 default: 406 default:
409 NGLOG_ERROR(Kernel_SVC, "unknown permissions=0x{:08X}", permissions); 407 LOG_ERROR(Kernel_SVC, "unknown permissions=0x{:08X}", permissions);
410 } 408 }
411 409
412 return RESULT_SUCCESS; 410 return RESULT_SUCCESS;
413} 411}
414 412
415static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size) { 413static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size) {
416 NGLOG_WARNING(Kernel_SVC, "called, shared_memory_handle=0x{:08X}, addr=0x{:X}, size=0x{:X}", 414 LOG_WARNING(Kernel_SVC, "called, shared_memory_handle=0x{:08X}, addr=0x{:X}, size=0x{:X}",
417 shared_memory_handle, addr, size); 415 shared_memory_handle, addr, size);
418 416
419 SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle); 417 SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle);
420 418
@@ -442,19 +440,19 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_i
442 memory_info->type = static_cast<u32>(vma->second.meminfo_state); 440 memory_info->type = static_cast<u32>(vma->second.meminfo_state);
443 } 441 }
444 442
445 NGLOG_TRACE(Kernel_SVC, "called process=0x{:08X} addr={:X}", process_handle, addr); 443 LOG_TRACE(Kernel_SVC, "called process=0x{:08X} addr={:X}", process_handle, addr);
446 return RESULT_SUCCESS; 444 return RESULT_SUCCESS;
447} 445}
448 446
449/// Query memory 447/// Query memory
450static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, VAddr addr) { 448static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, VAddr addr) {
451 NGLOG_TRACE(Kernel_SVC, "called, addr={:X}", addr); 449 LOG_TRACE(Kernel_SVC, "called, addr={:X}", addr);
452 return QueryProcessMemory(memory_info, page_info, CurrentProcess, addr); 450 return QueryProcessMemory(memory_info, page_info, CurrentProcess, addr);
453} 451}
454 452
455/// Exits the current process 453/// Exits the current process
456static void ExitProcess() { 454static void ExitProcess() {
457 NGLOG_INFO(Kernel_SVC, "Process {} exiting", Core::CurrentProcess()->process_id); 455 LOG_INFO(Kernel_SVC, "Process {} exiting", Core::CurrentProcess()->process_id);
458 456
459 ASSERT_MSG(Core::CurrentProcess()->status == ProcessStatus::Running, 457 ASSERT_MSG(Core::CurrentProcess()->status == ProcessStatus::Running,
460 "Process has already exited"); 458 "Process has already exited");
@@ -530,17 +528,17 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V
530 Core::System::GetInstance().PrepareReschedule(); 528 Core::System::GetInstance().PrepareReschedule();
531 Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule(); 529 Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule();
532 530
533 NGLOG_TRACE(Kernel_SVC, 531 LOG_TRACE(Kernel_SVC,
534 "called entrypoint=0x{:08X} ({}), arg=0x{:08X}, stacktop=0x{:08X}, " 532 "called entrypoint=0x{:08X} ({}), arg=0x{:08X}, stacktop=0x{:08X}, "
535 "threadpriority=0x{:08X}, processorid=0x{:08X} : created handle=0x{:08X}", 533 "threadpriority=0x{:08X}, processorid=0x{:08X} : created handle=0x{:08X}",
536 entry_point, name, arg, stack_top, priority, processor_id, *out_handle); 534 entry_point, name, arg, stack_top, priority, processor_id, *out_handle);
537 535
538 return RESULT_SUCCESS; 536 return RESULT_SUCCESS;
539} 537}
540 538
541/// Starts the thread for the provided handle 539/// Starts the thread for the provided handle
542static ResultCode StartThread(Handle thread_handle) { 540static ResultCode StartThread(Handle thread_handle) {
543 NGLOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); 541 LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle);
544 542
545 const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); 543 const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle);
546 if (!thread) { 544 if (!thread) {
@@ -557,7 +555,7 @@ static ResultCode StartThread(Handle thread_handle) {
557 555
558/// Called when a thread exits 556/// Called when a thread exits
559static void ExitThread() { 557static void ExitThread() {
560 NGLOG_TRACE(Kernel_SVC, "called, pc=0x{:08X}", Core::CurrentArmInterface().GetPC()); 558 LOG_TRACE(Kernel_SVC, "called, pc=0x{:08X}", Core::CurrentArmInterface().GetPC());
561 559
562 ExitCurrentThread(); 560 ExitCurrentThread();
563 Core::System::GetInstance().PrepareReschedule(); 561 Core::System::GetInstance().PrepareReschedule();
@@ -565,7 +563,7 @@ static void ExitThread() {
565 563
566/// Sleep the current thread 564/// Sleep the current thread
567static void SleepThread(s64 nanoseconds) { 565static void SleepThread(s64 nanoseconds) {
568 NGLOG_TRACE(Kernel_SVC, "called nanoseconds={}", nanoseconds); 566 LOG_TRACE(Kernel_SVC, "called nanoseconds={}", nanoseconds);
569 567
570 // Don't attempt to yield execution if there are no available threads to run, 568 // Don't attempt to yield execution if there are no available threads to run,
571 // this way we avoid a useless reschedule to the idle thread. 569 // this way we avoid a useless reschedule to the idle thread.
@@ -584,7 +582,7 @@ static void SleepThread(s64 nanoseconds) {
584/// Wait process wide key atomic 582/// Wait process wide key atomic
585static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_variable_addr, 583static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_variable_addr,
586 Handle thread_handle, s64 nano_seconds) { 584 Handle thread_handle, s64 nano_seconds) {
587 NGLOG_TRACE( 585 LOG_TRACE(
588 Kernel_SVC, 586 Kernel_SVC,
589 "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}", 587 "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}",
590 mutex_addr, condition_variable_addr, thread_handle, nano_seconds); 588 mutex_addr, condition_variable_addr, thread_handle, nano_seconds);
@@ -611,8 +609,8 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var
611 609
612/// Signal process wide key 610/// Signal process wide key
613static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target) { 611static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target) {
614 NGLOG_TRACE(Kernel_SVC, "called, condition_variable_addr=0x{:X}, target=0x{:08X}", 612 LOG_TRACE(Kernel_SVC, "called, condition_variable_addr=0x{:X}, target=0x{:08X}",
615 condition_variable_addr, target); 613 condition_variable_addr, target);
616 614
617 auto RetrieveWaitingThreads = 615 auto RetrieveWaitingThreads =
618 [](size_t core_index, std::vector<SharedPtr<Thread>>& waiting_threads, VAddr condvar_addr) { 616 [](size_t core_index, std::vector<SharedPtr<Thread>>& waiting_threads, VAddr condvar_addr) {
@@ -692,8 +690,8 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target
692 690
693// Wait for an address (via Address Arbiter) 691// Wait for an address (via Address Arbiter)
694static ResultCode WaitForAddress(VAddr address, u32 type, s32 value, s64 timeout) { 692static ResultCode WaitForAddress(VAddr address, u32 type, s32 value, s64 timeout) {
695 NGLOG_WARNING(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, timeout={}", 693 LOG_WARNING(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, timeout={}",
696 address, type, value, timeout); 694 address, type, value, timeout);
697 // If the passed address is a kernel virtual address, return invalid memory state. 695 // If the passed address is a kernel virtual address, return invalid memory state.
698 if (Memory::IsKernelVirtualAddress(address)) { 696 if (Memory::IsKernelVirtualAddress(address)) {
699 return ERR_INVALID_ADDRESS_STATE; 697 return ERR_INVALID_ADDRESS_STATE;
@@ -717,9 +715,8 @@ static ResultCode WaitForAddress(VAddr address, u32 type, s32 value, s64 timeout
717 715
718// Signals to an address (via Address Arbiter) 716// Signals to an address (via Address Arbiter)
719static ResultCode SignalToAddress(VAddr address, u32 type, s32 value, s32 num_to_wake) { 717static ResultCode SignalToAddress(VAddr address, u32 type, s32 value, s32 num_to_wake) {
720 NGLOG_WARNING(Kernel_SVC, 718 LOG_WARNING(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, num_to_wake=0x{:X}",
721 "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, num_to_wake=0x{:X}", address, 719 address, type, value, num_to_wake);
722 type, value, num_to_wake);
723 // If the passed address is a kernel virtual address, return invalid memory state. 720 // If the passed address is a kernel virtual address, return invalid memory state.
724 if (Memory::IsKernelVirtualAddress(address)) { 721 if (Memory::IsKernelVirtualAddress(address)) {
725 return ERR_INVALID_ADDRESS_STATE; 722 return ERR_INVALID_ADDRESS_STATE;
@@ -754,13 +751,13 @@ static u64 GetSystemTick() {
754 751
755/// Close a handle 752/// Close a handle
756static ResultCode CloseHandle(Handle handle) { 753static ResultCode CloseHandle(Handle handle) {
757 NGLOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); 754 LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle);
758 return g_handle_table.Close(handle); 755 return g_handle_table.Close(handle);
759} 756}
760 757
761/// Reset an event 758/// Reset an event
762static ResultCode ResetSignal(Handle handle) { 759static ResultCode ResetSignal(Handle handle) {
763 NGLOG_WARNING(Kernel_SVC, "(STUBBED) called handle 0x{:08X}", handle); 760 LOG_WARNING(Kernel_SVC, "(STUBBED) called handle 0x{:08X}", handle);
764 auto event = g_handle_table.Get<Event>(handle); 761 auto event = g_handle_table.Get<Event>(handle);
765 ASSERT(event != nullptr); 762 ASSERT(event != nullptr);
766 event->Clear(); 763 event->Clear();
@@ -769,14 +766,14 @@ static ResultCode ResetSignal(Handle handle) {
769 766
770/// Creates a TransferMemory object 767/// Creates a TransferMemory object
771static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 permissions) { 768static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 permissions) {
772 NGLOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x{:X}, size=0x{:X}, perms=0x{:08X}", addr, 769 LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x{:X}, size=0x{:X}, perms=0x{:08X}", addr, size,
773 size, permissions); 770 permissions);
774 *handle = 0; 771 *handle = 0;
775 return RESULT_SUCCESS; 772 return RESULT_SUCCESS;
776} 773}
777 774
778static ResultCode GetThreadCoreMask(Handle thread_handle, u32* core, u64* mask) { 775static ResultCode GetThreadCoreMask(Handle thread_handle, u32* core, u64* mask) {
779 NGLOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); 776 LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle);
780 777
781 const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); 778 const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle);
782 if (!thread) { 779 if (!thread) {
@@ -790,8 +787,8 @@ static ResultCode GetThreadCoreMask(Handle thread_handle, u32* core, u64* mask)
790} 787}
791 788
792static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { 789static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) {
793 NGLOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, mask=0x{:16X}, core=0x{:X}", thread_handle, 790 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, mask=0x{:16X}, core=0x{:X}", thread_handle,
794 mask, core); 791 mask, core);
795 792
796 const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); 793 const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle);
797 if (!thread) { 794 if (!thread) {
@@ -830,8 +827,8 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) {
830 827
831static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permissions, 828static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permissions,
832 u32 remote_permissions) { 829 u32 remote_permissions) {
833 NGLOG_TRACE(Kernel_SVC, "called, size=0x{:X}, localPerms=0x{:08X}, remotePerms=0x{:08X}", size, 830 LOG_TRACE(Kernel_SVC, "called, size=0x{:X}, localPerms=0x{:08X}, remotePerms=0x{:08X}", size,
834 local_permissions, remote_permissions); 831 local_permissions, remote_permissions);
835 auto sharedMemHandle = 832 auto sharedMemHandle =
836 SharedMemory::Create(g_handle_table.Get<Process>(KernelHandle::CurrentProcess), size, 833 SharedMemory::Create(g_handle_table.Get<Process>(KernelHandle::CurrentProcess), size,
837 static_cast<MemoryPermission>(local_permissions), 834 static_cast<MemoryPermission>(local_permissions),
@@ -842,7 +839,7 @@ static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permiss
842} 839}
843 840
844static ResultCode ClearEvent(Handle handle) { 841static ResultCode ClearEvent(Handle handle) {
845 NGLOG_TRACE(Kernel_SVC, "called, event=0x{:08X}", handle); 842 LOG_TRACE(Kernel_SVC, "called, event=0x{:08X}", handle);
846 843
847 SharedPtr<Event> evt = g_handle_table.Get<Event>(handle); 844 SharedPtr<Event> evt = g_handle_table.Get<Event>(handle);
848 if (evt == nullptr) 845 if (evt == nullptr)
@@ -994,7 +991,7 @@ static const FunctionDef SVC_Table[] = {
994 991
995static const FunctionDef* GetSVCInfo(u32 func_num) { 992static const FunctionDef* GetSVCInfo(u32 func_num) {
996 if (func_num >= std::size(SVC_Table)) { 993 if (func_num >= std::size(SVC_Table)) {
997 NGLOG_ERROR(Kernel_SVC, "Unknown svc=0x{:02X}", func_num); 994 LOG_ERROR(Kernel_SVC, "Unknown svc=0x{:02X}", func_num);
998 return nullptr; 995 return nullptr;
999 } 996 }
1000 return &SVC_Table[func_num]; 997 return &SVC_Table[func_num];
@@ -1013,10 +1010,10 @@ void CallSVC(u32 immediate) {
1013 if (info->func) { 1010 if (info->func) {
1014 info->func(); 1011 info->func();
1015 } else { 1012 } else {
1016 NGLOG_CRITICAL(Kernel_SVC, "Unimplemented SVC function {}(..)", info->name); 1013 LOG_CRITICAL(Kernel_SVC, "Unimplemented SVC function {}(..)", info->name);
1017 } 1014 }
1018 } else { 1015 } else {
1019 NGLOG_CRITICAL(Kernel_SVC, "Unknown SVC function 0x{:X}", immediate); 1016 LOG_CRITICAL(Kernel_SVC, "Unknown SVC function 0x{:X}", immediate);
1020 } 1017 }
1021} 1018}
1022 1019