diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a5a633f826..d93eb39a43 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -43,6 +43,7 @@ set(SRCS hle/kernel/server_port.cpp hle/kernel/server_session.cpp hle/kernel/shared_memory.cpp + hle/kernel/svc.cpp hle/kernel/thread.cpp hle/kernel/timer.cpp hle/kernel/vm_manager.cpp @@ -63,7 +64,6 @@ set(SRCS hle/service/sm/controller.cpp hle/service/sm/sm.cpp hle/shared_page.cpp - hle/svc.cpp hw/aes/arithmetic128.cpp hw/aes/ccm.cpp hw/aes/key.cpp @@ -116,7 +116,6 @@ set(HEADERS frontend/input.h gdbstub/gdbstub.h hle/config_mem.h - hle/function_wrappers.h hle/ipc.h hle/ipc_helpers.h hle/kernel/address_arbiter.h @@ -139,6 +138,8 @@ set(HEADERS hle/kernel/session.h hle/kernel/shared_memory.h hle/kernel/sync_object.h + hle/kernel/svc.h + hle/kernel/svc_wrap.h hle/kernel/thread.h hle/kernel/timer.h hle/kernel/vm_manager.h @@ -160,7 +161,6 @@ set(HEADERS hle/service/sm/controller.h hle/service/sm/sm.h hle/shared_page.h - hle/svc.h hw/aes/arithmetic128.h hw/aes/ccm.h hw/aes/key.h diff --git a/src/core/hle/svc.cpp b/src/core/hle/kernel/svc.cpp similarity index 74% rename from src/core/hle/svc.cpp rename to src/core/hle/kernel/svc.cpp index 6ec151d946..3dae8b38b1 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -5,7 +5,6 @@ #include "common/logging/log.h" #include "common/microprofile.h" #include "core/core_timing.h" -#include "core/hle/function_wrappers.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" #include "core/hle/kernel/handle_table.h" @@ -13,27 +12,22 @@ #include "core/hle/kernel/object_address_table.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/resource_limit.h" +#include "core/hle/kernel/svc.h" +#include "core/hle/kernel/svc_wrap.h" #include "core/hle/kernel/sync_object.h" #include "core/hle/kernel/thread.h" #include "core/hle/lock.h" #include "core/hle/result.h" #include "core/hle/service/service.h" -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Namespace SVC - -using Kernel::ERR_INVALID_HANDLE; -using Kernel::Handle; -using Kernel::SharedPtr; - -namespace SVC { +namespace Kernel { /// Set the process heap to a given Size. It can both extend and shrink the heap. static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { LOG_TRACE(Kernel_SVC, "called, heap_size=0x%llx", heap_size); - auto& process = *Kernel::g_current_process; + auto& process = *g_current_process; CASCADE_RESULT(*heap_addr, process.HeapAllocate(Memory::HEAP_VADDR, heap_size, - Kernel::VMAPermission::ReadWrite)); + VMAPermission::ReadWrite)); return RESULT_SUCCESS; } @@ -41,48 +35,48 @@ static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { LOG_TRACE(Kernel_SVC, "called, dst_addr=0x%llx, src_addr=0x%llx, size=0x%llx", dst_addr, src_addr, size); - return Kernel::g_current_process->MirrorMemory(dst_addr, src_addr, size); + return g_current_process->MirrorMemory(dst_addr, src_addr, size); } /// Unmaps a region that was previously mapped with svcMapMemory static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { LOG_TRACE(Kernel_SVC, "called, dst_addr=0x%llx, src_addr=0x%llx, size=0x%llx", dst_addr, src_addr, size); - return Kernel::g_current_process->UnmapMemory(dst_addr, src_addr, size); + return g_current_process->UnmapMemory(dst_addr, src_addr, size); } /// Connect to an OS service given the port name, returns the handle to the port to out -static ResultCode ConnectToPort(Kernel::Handle* out_handle, VAddr port_name_address) { +static ResultCode ConnectToPort(Handle* out_handle, VAddr port_name_address) { if (!Memory::IsValidVirtualAddress(port_name_address)) - return Kernel::ERR_NOT_FOUND; + return ERR_NOT_FOUND; static constexpr std::size_t PortNameMaxLength = 11; // Read 1 char beyond the max allowed port name to detect names that are too long. std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); if (port_name.size() > PortNameMaxLength) - return Kernel::ERR_PORT_NAME_TOO_LONG; + return ERR_PORT_NAME_TOO_LONG; LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name.c_str()); auto it = Service::g_kernel_named_ports.find(port_name); if (it == Service::g_kernel_named_ports.end()) { LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name.c_str()); - return Kernel::ERR_NOT_FOUND; + return ERR_NOT_FOUND; } auto client_port = it->second; - SharedPtr client_session; + SharedPtr client_session; CASCADE_RESULT(client_session, client_port->Connect()); // Return the client session - CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(client_session)); + CASCADE_RESULT(*out_handle, g_handle_table.Create(client_session)); return RESULT_SUCCESS; } /// Makes a blocking IPC call to an OS service. -static ResultCode SendSyncRequest(Kernel::Handle handle) { - SharedPtr session = Kernel::g_handle_table.Get(handle); +static ResultCode SendSyncRequest(Handle handle) { + SharedPtr session = g_handle_table.Get(handle); if (!session) { LOG_ERROR(Kernel_SVC, "called with invalid handle=0x%08X", handle); return ERR_INVALID_HANDLE; @@ -94,15 +88,15 @@ static ResultCode SendSyncRequest(Kernel::Handle handle) { // TODO(Subv): svcSendSyncRequest should put the caller thread to sleep while the server // responds and cause a reschedule. - return session->SendSyncRequest(Kernel::GetCurrentThread()); + return session->SendSyncRequest(GetCurrentThread()); } /// Get the ID for the specified thread. -static ResultCode GetThreadId(u32* thread_id, Kernel::Handle thread_handle) { +static ResultCode GetThreadId(u32* thread_id, Handle thread_handle) { LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); - const SharedPtr thread = - Kernel::g_handle_table.Get(thread_handle); + const SharedPtr thread = + g_handle_table.Get(thread_handle); if (!thread) { return ERR_INVALID_HANDLE; } @@ -112,11 +106,11 @@ static ResultCode GetThreadId(u32* thread_id, Kernel::Handle thread_handle) { } /// Get the ID of the specified process -static ResultCode GetProcessId(u32* process_id, Kernel::Handle process_handle) { +static ResultCode GetProcessId(u32* process_id, Handle process_handle) { LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); - const SharedPtr process = - Kernel::g_handle_table.Get(process_handle); + const SharedPtr process = + g_handle_table.Get(process_handle); if (!process) { return ERR_INVALID_HANDLE; } @@ -141,18 +135,18 @@ static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr, "requesting_current_thread_handle=0x%08X", holding_thread_handle, mutex_addr, requesting_thread_handle); - SharedPtr holding_thread = - Kernel::g_handle_table.Get(holding_thread_handle); - SharedPtr requesting_thread = - Kernel::g_handle_table.Get(requesting_thread_handle); + SharedPtr holding_thread = + g_handle_table.Get(holding_thread_handle); + SharedPtr requesting_thread = + g_handle_table.Get(requesting_thread_handle); ASSERT(holding_thread); ASSERT(requesting_thread); - SharedPtr mutex = Kernel::g_object_address_table.Get(mutex_addr); + SharedPtr mutex = g_object_address_table.Get(mutex_addr); if (!mutex) { // Create a new mutex for the specified address if one does not already exist - mutex = Kernel::Mutex::Create(holding_thread, mutex_addr); + mutex = Mutex::Create(holding_thread, mutex_addr); mutex->name = Common::StringFromFormat("mutex-%llx", mutex_addr); } @@ -175,10 +169,10 @@ static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr, static ResultCode UnlockMutex(VAddr mutex_addr) { LOG_TRACE(Kernel_SVC, "called mutex_addr=0x%llx", mutex_addr); - SharedPtr mutex = Kernel::g_object_address_table.Get(mutex_addr); + SharedPtr mutex = g_object_address_table.Get(mutex_addr); ASSERT(mutex); - return mutex->Release(Kernel::GetCurrentThread()); + return mutex->Release(GetCurrentThread()); } /// Break program execution @@ -199,7 +193,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) LOG_TRACE(Kernel_SVC, "called info_id=0x%X, info_sub_id=0x%X, handle=0x%08X", info_id, info_sub_id, handle); - auto& vm_manager = Kernel::g_current_process->vm_manager; + auto& vm_manager = g_current_process->vm_manager; switch (static_cast(info_id)) { case GetInfoType::TotalMemoryUsage: *result = vm_manager.GetTotalMemoryUsage(); @@ -231,7 +225,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) /// Gets the priority for the specified thread static ResultCode GetThreadPriority(u32* priority, Handle handle) { - const SharedPtr thread = Kernel::g_handle_table.Get(handle); + const SharedPtr thread = g_handle_table.Get(handle); if (!thread) return ERR_INVALID_HANDLE; @@ -242,18 +236,18 @@ static ResultCode GetThreadPriority(u32* priority, Handle handle) { /// Sets the priority for the specified thread static ResultCode SetThreadPriority(Handle handle, u32 priority) { if (priority > THREADPRIO_LOWEST) { - return Kernel::ERR_OUT_OF_RANGE; + return ERR_OUT_OF_RANGE; } - SharedPtr thread = Kernel::g_handle_table.Get(handle); + SharedPtr thread = g_handle_table.Get(handle); if (!thread) - return Kernel::ERR_INVALID_HANDLE; + return ERR_INVALID_HANDLE; // Note: The kernel uses the current process's resource limit instead of // the one from the thread owner's resource limit. - SharedPtr& resource_limit = Kernel::g_current_process->resource_limit; - if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) { - return Kernel::ERR_NOT_AUTHORIZED; + SharedPtr& resource_limit = g_current_process->resource_limit; + if (resource_limit->GetMaxResourceValue(ResourceTypes::PRIORITY) > priority) { + return ERR_NOT_AUTHORIZED; } thread->SetPriority(priority); @@ -275,19 +269,18 @@ static u32 GetCurrentProcessorNumber() { /// Query process memory static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_info*/, - Kernel::Handle process_handle, u64 addr) { - using Kernel::Process; - Kernel::SharedPtr process = Kernel::g_handle_table.Get(process_handle); + Handle process_handle, u64 addr) { + SharedPtr process = g_handle_table.Get(process_handle); if (!process) { return ERR_INVALID_HANDLE; } auto vma = process->vm_manager.FindVMA(addr); memory_info->attributes = 0; - if (vma == Kernel::g_current_process->vm_manager.vma_map.end()) { + if (vma == g_current_process->vm_manager.vma_map.end()) { memory_info->base_address = 0; - memory_info->permission = static_cast(Kernel::VMAPermission::None); + memory_info->permission = static_cast(VMAPermission::None); memory_info->size = 0; - memory_info->type = static_cast(Kernel::MemoryState::Free); + memory_info->type = static_cast(MemoryState::Free); } else { memory_info->base_address = vma->second.base; memory_info->permission = static_cast(vma->second.permissions); @@ -302,25 +295,25 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_i /// Query memory static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, VAddr addr) { LOG_TRACE(Kernel_SVC, "called, addr=%llx", addr); - return QueryProcessMemory(memory_info, page_info, Kernel::CurrentProcess, addr); + return QueryProcessMemory(memory_info, page_info, CurrentProcess, addr); } /// Exits the current process static void ExitProcess() { - LOG_INFO(Kernel_SVC, "Process %u exiting", Kernel::g_current_process->process_id); + LOG_INFO(Kernel_SVC, "Process %u exiting", g_current_process->process_id); - ASSERT_MSG(Kernel::g_current_process->status == Kernel::ProcessStatus::Running, + ASSERT_MSG(g_current_process->status == ProcessStatus::Running, "Process has already exited"); - Kernel::g_current_process->status = Kernel::ProcessStatus::Exited; + g_current_process->status = ProcessStatus::Exited; // Stop all the process threads that are currently waiting for objects. - auto& thread_list = Kernel::GetThreadList(); + auto& thread_list = GetThreadList(); for (auto& thread : thread_list) { - if (thread->owner_process != Kernel::g_current_process) + if (thread->owner_process != g_current_process) continue; - if (thread == Kernel::GetCurrentThread()) + if (thread == GetCurrentThread()) continue; // TODO(Subv): When are the other running/ready threads terminated? @@ -332,7 +325,7 @@ static void ExitProcess() { } // Kill the current thread - Kernel::GetCurrentThread()->Stop(); + GetCurrentThread()->Stop(); Core::System::GetInstance().PrepareReschedule(); } @@ -343,17 +336,17 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V std::string name = Common::StringFromFormat("unknown-%llx", entry_point); if (priority > THREADPRIO_LOWEST) { - return Kernel::ERR_OUT_OF_RANGE; + return ERR_OUT_OF_RANGE; } - SharedPtr& resource_limit = Kernel::g_current_process->resource_limit; - if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) { - return Kernel::ERR_NOT_AUTHORIZED; + SharedPtr& resource_limit = g_current_process->resource_limit; + if (resource_limit->GetMaxResourceValue(ResourceTypes::PRIORITY) > priority) { + return ERR_NOT_AUTHORIZED; } if (processor_id == THREADPROCESSORID_DEFAULT) { // Set the target CPU to the one specified in the process' exheader. - processor_id = Kernel::g_current_process->ideal_processor; + processor_id = g_current_process->ideal_processor; ASSERT(processor_id != THREADPROCESSORID_DEFAULT); } @@ -374,14 +367,14 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V break; } - CASCADE_RESULT(SharedPtr thread, - Kernel::Thread::Create(name, entry_point, priority, arg, processor_id, stack_top, - Kernel::g_current_process)); + CASCADE_RESULT(SharedPtr thread, + Thread::Create(name, entry_point, priority, arg, processor_id, stack_top, + g_current_process)); thread->context.fpscr = FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | FPSCR_ROUND_TOZERO; // 0x03C00000 - CASCADE_RESULT(thread->guest_handle, Kernel::g_handle_table.Create(thread)); + CASCADE_RESULT(thread->guest_handle, g_handle_table.Create(thread)); *out_handle = thread->guest_handle; Core::System::GetInstance().PrepareReschedule(); @@ -398,8 +391,8 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V static ResultCode StartThread(Handle thread_handle) { LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); - const SharedPtr thread = - Kernel::g_handle_table.Get(thread_handle); + const SharedPtr thread = + g_handle_table.Get(thread_handle); if (!thread) { return ERR_INVALID_HANDLE; } @@ -413,7 +406,7 @@ static ResultCode StartThread(Handle thread_handle) { static void ExitThread() { LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::CPU().GetPC()); - Kernel::ExitCurrentThread(); + ExitCurrentThread(); Core::System::GetInstance().PrepareReschedule(); } @@ -423,14 +416,14 @@ static void SleepThread(s64 nanoseconds) { // Don't attempt to yield execution if there are no available threads to run, // this way we avoid a useless reschedule to the idle thread. - if (nanoseconds == 0 && !Kernel::HaveReadyThreads()) + if (nanoseconds == 0 && !HaveReadyThreads()) return; // Sleep current thread and check for next thread to schedule - Kernel::WaitCurrentThread_Sleep(); + WaitCurrentThread_Sleep(); // Create an event to wake the thread up after the specified nanosecond delay has passed - Kernel::GetCurrentThread()->WakeAfterDelay(nanoseconds); + GetCurrentThread()->WakeAfterDelay(nanoseconds); Core::System::GetInstance().PrepareReschedule(); } @@ -442,9 +435,9 @@ static ResultCode SignalProcessWideKey(VAddr addr, u32 target) { } /// Close a handle -static ResultCode CloseHandle(Kernel::Handle handle) { +static ResultCode CloseHandle(Handle handle) { LOG_TRACE(Kernel_SVC, "Closing handle 0x%08X", handle); - return Kernel::g_handle_table.Close(handle); + return g_handle_table.Close(handle); } namespace { @@ -459,47 +452,47 @@ struct FunctionDef { static const FunctionDef SVC_Table[] = { {0x00, nullptr, "Unknown"}, - {0x01, HLE::Wrap, "svcSetHeapSize"}, + {0x01, SvcWrap, "svcSetHeapSize"}, {0x02, nullptr, "svcSetMemoryPermission"}, {0x03, nullptr, "svcSetMemoryAttribute"}, - {0x04, HLE::Wrap, "svcMapMemory"}, - {0x05, HLE::Wrap, "svcUnmapMemory"}, - {0x06, HLE::Wrap, "svcQueryMemory"}, - {0x07, HLE::Wrap, "svcExitProcess"}, - {0x08, HLE::Wrap, "svcCreateThread"}, - {0x09, HLE::Wrap, "svcStartThread"}, - {0x0A, HLE::Wrap, "svcExitThread"}, - {0x0B, HLE::Wrap, "svcSleepThread"}, - {0x0C, HLE::Wrap, "svcGetThreadPriority"}, - {0x0D, HLE::Wrap, "svcSetThreadPriority"}, + {0x04, SvcWrap, "svcMapMemory"}, + {0x05, SvcWrap, "svcUnmapMemory"}, + {0x06, SvcWrap, "svcQueryMemory"}, + {0x07, SvcWrap, "svcExitProcess"}, + {0x08, SvcWrap, "svcCreateThread"}, + {0x09, SvcWrap, "svcStartThread"}, + {0x0A, SvcWrap, "svcExitThread"}, + {0x0B, SvcWrap, "svcSleepThread"}, + {0x0C, SvcWrap, "svcGetThreadPriority"}, + {0x0D, SvcWrap, "svcSetThreadPriority"}, {0x0E, nullptr, "svcGetThreadCoreMask"}, {0x0F, nullptr, "svcSetThreadCoreMask"}, - {0x10, HLE::Wrap, "svcGetCurrentProcessorNumber"}, + {0x10, SvcWrap, "svcGetCurrentProcessorNumber"}, {0x11, nullptr, "svcSignalEvent"}, {0x12, nullptr, "svcClearEvent"}, {0x13, nullptr, "svcMapSharedMemory"}, {0x14, nullptr, "svcUnmapSharedMemory"}, {0x15, nullptr, "svcCreateTransferMemory"}, - {0x16, HLE::Wrap, "svcCloseHandle"}, + {0x16, SvcWrap, "svcCloseHandle"}, {0x17, nullptr, "svcResetSignal"}, - {0x18, HLE::Wrap, "svcWaitSynchronization"}, + {0x18, SvcWrap, "svcWaitSynchronization"}, {0x19, nullptr, "svcCancelSynchronization"}, - {0x1A, HLE::Wrap, "svcLockMutex"}, - {0x1B, HLE::Wrap, "svcUnlockMutex"}, + {0x1A, SvcWrap, "svcLockMutex"}, + {0x1B, SvcWrap, "svcUnlockMutex"}, {0x1C, nullptr, "svcWaitProcessWideKeyAtomic"}, - {0x1D, HLE::Wrap, "svcSignalProcessWideKey"}, + {0x1D, SvcWrap, "svcSignalProcessWideKey"}, {0x1E, nullptr, "svcGetSystemTick"}, - {0x1F, HLE::Wrap, "svcConnectToPort"}, + {0x1F, SvcWrap, "svcConnectToPort"}, {0x20, nullptr, "svcSendSyncRequestLight"}, - {0x21, HLE::Wrap, "svcSendSyncRequest"}, + {0x21, SvcWrap, "svcSendSyncRequest"}, {0x22, nullptr, "svcSendSyncRequestWithUserBuffer"}, {0x23, nullptr, "svcSendAsyncRequestWithUserBuffer"}, - {0x24, HLE::Wrap, "svcGetProcessId"}, - {0x25, HLE::Wrap, "svcGetThreadId"}, - {0x26, HLE::Wrap, "svcBreak"}, - {0x27, HLE::Wrap, "svcOutputDebugString"}, + {0x24, SvcWrap, "svcGetProcessId"}, + {0x25, SvcWrap, "svcGetThreadId"}, + {0x26, SvcWrap, "svcBreak"}, + {0x27, SvcWrap, "svcOutputDebugString"}, {0x28, nullptr, "svcReturnFromException"}, - {0x29, HLE::Wrap, "svcGetInfo"}, + {0x29, SvcWrap, "svcGetInfo"}, {0x2A, nullptr, "svcFlushEntireDataCache"}, {0x2B, nullptr, "svcFlushDataCache"}, {0x2C, nullptr, "svcMapPhysicalMemory"}, @@ -616,4 +609,4 @@ void CallSVC(u32 immediate) { } } -} // namespace SVC +} // namespace Kernel diff --git a/src/core/hle/svc.h b/src/core/hle/kernel/svc.h similarity index 66% rename from src/core/hle/svc.h rename to src/core/hle/kernel/svc.h index fd001a38ea..b0265b6c84 100644 --- a/src/core/hle/svc.h +++ b/src/core/hle/kernel/svc.h @@ -1,4 +1,4 @@ -// Copyright 2014 Citra Emulator Project +// Copyright 2018 Citra Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -6,8 +6,7 @@ #include "common/common_types.h" -//////////////////////////////////////////////////////////////////////////////////////////////////// -// SVC types +namespace Kernel { struct MemoryInfo { u64 base_address; @@ -21,11 +20,6 @@ struct PageInfo { u64 flags; }; -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Namespace SVC - -namespace SVC { - /// Values accepted by svcGetInfo enum class GetInfoType : u64 { // 1.0.0+ @@ -41,4 +35,4 @@ enum class GetInfoType : u64 { void CallSVC(u32 immediate); -} // namespace SVC +} // namespace Kernel diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/kernel/svc_wrap.h similarity index 88% rename from src/core/hle/function_wrappers.h rename to src/core/hle/kernel/svc_wrap.h index df2c3e843c..65b64cb3c2 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/kernel/svc_wrap.h @@ -1,4 +1,4 @@ -// Copyright 2017 Citra Emulator Project +// Copyright 2018 Citra Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -7,11 +7,11 @@ #include "common/common_types.h" #include "core/arm/arm_interface.h" #include "core/core.h" +#include "core/hle/kernel/svc.h" #include "core/hle/result.h" -#include "core/hle/svc.h" #include "core/memory.h" -namespace HLE { +namespace Kernel { #define PARAM(n) Core::CPU().GetReg(n) @@ -27,22 +27,22 @@ static inline void FuncReturn(u64 res) { // Function wrappers that return type ResultCode template -void Wrap() { +void SvcWrap() { FuncReturn(func(PARAM(0)).raw); } template -void Wrap() { +void SvcWrap() { FuncReturn(func((u32)PARAM(0)).raw); } template -void Wrap() { +void SvcWrap() { FuncReturn(func((u32)PARAM(0), (u32)PARAM(1)).raw); } template -void Wrap() { +void SvcWrap() { u32 param_1 = 0; u32 retval = func(¶m_1, (u32)PARAM(1)).raw; Core::CPU().SetReg(1, param_1); @@ -50,7 +50,7 @@ void Wrap() { } template -void Wrap() { +void SvcWrap() { u32 param_1 = 0; u32 retval = func(¶m_1, PARAM(1)).raw; Core::CPU().SetReg(1, param_1); @@ -58,12 +58,12 @@ void Wrap() { } template -void Wrap() { +void SvcWrap() { FuncReturn(func(PARAM(0), (u32)PARAM(1)).raw); } template -void Wrap() { +void SvcWrap() { u64 param_1 = 0; u32 retval = func(¶m_1, PARAM(1)).raw; Core::CPU().SetReg(1, param_1); @@ -71,22 +71,22 @@ void Wrap() { } template -void Wrap() { +void SvcWrap() { FuncReturn(func((u32)PARAM(0), PARAM(1), (u32)PARAM(2)).raw); } template -void Wrap() { +void SvcWrap() { FuncReturn(func(PARAM(0), PARAM(1), PARAM(2)).raw); } template -void Wrap() { +void SvcWrap() { FuncReturn(func(PARAM(1), PARAM(2), (s64)PARAM(3)).raw); } template -void Wrap() { +void SvcWrap() { u64 param_1 = 0; u32 retval = func(¶m_1, PARAM(1), PARAM(2), PARAM(3)).raw; Core::CPU().SetReg(1, param_1); @@ -94,7 +94,7 @@ void Wrap() { } template -void Wrap() { +void SvcWrap() { u32 param_1 = 0; u32 retval = func(¶m_1, PARAM(1), PARAM(2), PARAM(3), (u32)PARAM(4), (s32)(PARAM(5) & 0xFFFFFFFF)) @@ -104,7 +104,7 @@ void Wrap() { } template -void Wrap() { +void SvcWrap() { MemoryInfo memory_info = {}; PageInfo page_info = {}; u32 retval = func(&memory_info, &page_info, PARAM(2)).raw; @@ -122,7 +122,7 @@ void Wrap() { // Function wrappers that return type u32 template -void Wrap() { +void SvcWrap() { FuncReturn(func()); } @@ -130,26 +130,26 @@ void Wrap() { /// Function wrappers that return type void template -void Wrap() { +void SvcWrap() { func(); } template -void Wrap() { +void SvcWrap() { func((s64)PARAM(0)); } template -void Wrap() { +void SvcWrap() { func(PARAM(0), (s32)(PARAM(1) & 0xFFFFFFFF)); } template -void Wrap() { +void SvcWrap() { func(PARAM(0), PARAM(1), PARAM(2)); } #undef PARAM #undef FuncReturn -} // namespace HLE +} // namespace Kernel