diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-01-11 06:43:29 +0100 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-01-30 14:47:04 +0100 |
commit | 4bb33dfc30768c536d3f0ffb980464b1ab2d25d9 (patch) | |
tree | 09f772e5283ef1302f1b29d30f3f0150dd690bf0 /src/core/hle/svc.cpp | |
parent | Common: Fix SCOPE_EXIT to actually create unique identifiers. (diff) | |
download | yuzu-4bb33dfc30768c536d3f0ffb980464b1ab2d25d9.tar yuzu-4bb33dfc30768c536d3f0ffb980464b1ab2d25d9.tar.gz yuzu-4bb33dfc30768c536d3f0ffb980464b1ab2d25d9.tar.bz2 yuzu-4bb33dfc30768c536d3f0ffb980464b1ab2d25d9.tar.lz yuzu-4bb33dfc30768c536d3f0ffb980464b1ab2d25d9.tar.xz yuzu-4bb33dfc30768c536d3f0ffb980464b1ab2d25d9.tar.zst yuzu-4bb33dfc30768c536d3f0ffb980464b1ab2d25d9.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/svc.cpp | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 3d743f125..165da0402 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -63,21 +63,28 @@ static Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, /// Maps a memory block to specified address static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { + using Kernel::SharedMemory; + using Kernel::MemoryPermission; + LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", handle, addr, permissions, other_permissions); - Kernel::MemoryPermission permissions_type = static_cast<Kernel::MemoryPermission>(permissions); + SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle); + if (shared_memory == nullptr) + return InvalidHandle(ErrorModule::Kernel).raw; + + MemoryPermission permissions_type = static_cast<MemoryPermission>(permissions); switch (permissions_type) { - case Kernel::MemoryPermission::Read: - case Kernel::MemoryPermission::Write: - case Kernel::MemoryPermission::ReadWrite: - case Kernel::MemoryPermission::Execute: - case Kernel::MemoryPermission::ReadExecute: - case Kernel::MemoryPermission::WriteExecute: - case Kernel::MemoryPermission::ReadWriteExecute: - case Kernel::MemoryPermission::DontCare: - Kernel::MapSharedMemory(handle, addr, permissions_type, - static_cast<Kernel::MemoryPermission>(other_permissions)); + case MemoryPermission::Read: + case MemoryPermission::Write: + case MemoryPermission::ReadWrite: + case MemoryPermission::Execute: + case MemoryPermission::ReadExecute: + case MemoryPermission::WriteExecute: + case MemoryPermission::ReadWriteExecute: + case MemoryPermission::DontCare: + shared_memory->Map(addr, permissions_type, + static_cast<MemoryPermission>(other_permissions)); break; default: LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions); @@ -463,12 +470,19 @@ static s64 GetSystemTick() { /// Creates a memory block at the specified address with the specified permissions and size static Result CreateMemoryBlock(Handle* memblock, u32 addr, u32 size, u32 my_permission, - u32 other_permission) { - + u32 other_permission) { + using Kernel::SharedMemory; // TODO(Subv): Implement this function - Handle shared_memory = Kernel::CreateSharedMemory(); - *memblock = shared_memory; + ResultVal<SharedPtr<SharedMemory>> shared_memory_res = SharedMemory::Create(); + if (shared_memory_res.Failed()) + return shared_memory_res.Code().raw; + + ResultVal<Handle> handle_res = Kernel::g_handle_table.Create(*shared_memory_res); + if (handle_res.Failed()) + return handle_res.Code().raw; + + *memblock = *handle_res; LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x%08X", addr); return 0; } |