diff options
author | bunnei <bunneidev@gmail.com> | 2018-01-14 23:15:31 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-01-14 23:20:55 +0100 |
commit | 974362bc12c146e255bf7eb77dd9939ed649a483 (patch) | |
tree | 7abcab89739682ab74193253b0389758a3c2fd64 /src/core/hle/kernel | |
parent | kernel: Increase default stack size to 64K. (diff) | |
download | yuzu-974362bc12c146e255bf7eb77dd9939ed649a483.tar yuzu-974362bc12c146e255bf7eb77dd9939ed649a483.tar.gz yuzu-974362bc12c146e255bf7eb77dd9939ed649a483.tar.bz2 yuzu-974362bc12c146e255bf7eb77dd9939ed649a483.tar.lz yuzu-974362bc12c146e255bf7eb77dd9939ed649a483.tar.xz yuzu-974362bc12c146e255bf7eb77dd9939ed649a483.tar.zst yuzu-974362bc12c146e255bf7eb77dd9939ed649a483.zip |
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 34 | ||||
-rw-r--r-- | src/core/hle/kernel/svc_wrap.h | 5 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index eb02dbde3..9c60576c1 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -17,6 +17,7 @@ #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/shared_memory.h" #include "core/hle/kernel/svc.h" #include "core/hle/kernel/svc_wrap.h" #include "core/hle/kernel/sync_object.h" @@ -384,6 +385,37 @@ static u32 GetCurrentProcessorNumber() { return 0; } +static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size, + u32 permissions) { + LOG_TRACE(Kernel_SVC, + "called, shared_memory_handle=0x%08X, addr=0x%llx, size=0x%llx, permissions=0x%08X", + shared_memory_handle, addr, size, permissions); + + SharedPtr<SharedMemory> shared_memory = + Kernel::g_handle_table.Get<SharedMemory>(shared_memory_handle); + if (!shared_memory) { + return ERR_INVALID_HANDLE; + } + + MemoryPermission permissions_type = static_cast<MemoryPermission>(permissions); + switch (permissions_type) { + case MemoryPermission::Read: + case MemoryPermission::Write: + case MemoryPermission::ReadWrite: + case MemoryPermission::Execute: + case MemoryPermission::ReadExecute: + case MemoryPermission::WriteExecute: + case MemoryPermission::ReadWriteExecute: + case MemoryPermission::DontCare: + return shared_memory->Map(Kernel::g_current_process.get(), addr, permissions_type, + MemoryPermission::DontCare); + default: + LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions); + } + + return RESULT_SUCCESS; +} + /// Query process memory static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_info*/, Handle process_handle, u64 addr) { @@ -707,7 +739,7 @@ static const FunctionDef SVC_Table[] = { {0x10, SvcWrap<GetCurrentProcessorNumber>, "GetCurrentProcessorNumber"}, {0x11, nullptr, "SignalEvent"}, {0x12, nullptr, "ClearEvent"}, - {0x13, nullptr, "MapSharedMemory"}, + {0x13, SvcWrap<MapSharedMemory>, "MapSharedMemory"}, {0x14, nullptr, "UnmapSharedMemory"}, {0x15, SvcWrap<CreateTransferMemory>, "CreateTransferMemory"}, {0x16, SvcWrap<CloseHandle>, "CloseHandle"}, diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index e66911fa5..fd7054bbd 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h @@ -86,6 +86,11 @@ void SvcWrap() { FuncReturn(func(PARAM(0), PARAM(1), PARAM(2)).raw); } +template <ResultCode func(u32, u64, u64, u32)> +void SvcWrap() { + FuncReturn(func((u32)PARAM(0), PARAM(1), PARAM(2), (u32)PARAM(3)).raw); +} + template <ResultCode func(u32*, u64, u64, s64)> void SvcWrap() { u32 param_1 = 0; |