diff options
Diffstat (limited to 'src/core/hle/svc.cpp')
| -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, | |||
| 63 | 63 | ||
| 64 | /// Maps a memory block to specified address | 64 | /// Maps a memory block to specified address |
| 65 | static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { | 65 | static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { |
| 66 | using Kernel::SharedMemory; | ||
| 67 | using Kernel::MemoryPermission; | ||
| 68 | |||
| 66 | LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", | 69 | LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", |
| 67 | handle, addr, permissions, other_permissions); | 70 | handle, addr, permissions, other_permissions); |
| 68 | 71 | ||
| 69 | Kernel::MemoryPermission permissions_type = static_cast<Kernel::MemoryPermission>(permissions); | 72 | SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle); |
| 73 | if (shared_memory == nullptr) | ||
| 74 | return InvalidHandle(ErrorModule::Kernel).raw; | ||
| 75 | |||
| 76 | MemoryPermission permissions_type = static_cast<MemoryPermission>(permissions); | ||
| 70 | switch (permissions_type) { | 77 | switch (permissions_type) { |
| 71 | case Kernel::MemoryPermission::Read: | 78 | case MemoryPermission::Read: |
| 72 | case Kernel::MemoryPermission::Write: | 79 | case MemoryPermission::Write: |
| 73 | case Kernel::MemoryPermission::ReadWrite: | 80 | case MemoryPermission::ReadWrite: |
| 74 | case Kernel::MemoryPermission::Execute: | 81 | case MemoryPermission::Execute: |
| 75 | case Kernel::MemoryPermission::ReadExecute: | 82 | case MemoryPermission::ReadExecute: |
| 76 | case Kernel::MemoryPermission::WriteExecute: | 83 | case MemoryPermission::WriteExecute: |
| 77 | case Kernel::MemoryPermission::ReadWriteExecute: | 84 | case MemoryPermission::ReadWriteExecute: |
| 78 | case Kernel::MemoryPermission::DontCare: | 85 | case MemoryPermission::DontCare: |
| 79 | Kernel::MapSharedMemory(handle, addr, permissions_type, | 86 | shared_memory->Map(addr, permissions_type, |
| 80 | static_cast<Kernel::MemoryPermission>(other_permissions)); | 87 | static_cast<MemoryPermission>(other_permissions)); |
| 81 | break; | 88 | break; |
| 82 | default: | 89 | default: |
| 83 | LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions); | 90 | LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions); |
| @@ -463,12 +470,19 @@ static s64 GetSystemTick() { | |||
| 463 | 470 | ||
| 464 | /// Creates a memory block at the specified address with the specified permissions and size | 471 | /// Creates a memory block at the specified address with the specified permissions and size |
| 465 | static Result CreateMemoryBlock(Handle* memblock, u32 addr, u32 size, u32 my_permission, | 472 | static Result CreateMemoryBlock(Handle* memblock, u32 addr, u32 size, u32 my_permission, |
| 466 | u32 other_permission) { | 473 | u32 other_permission) { |
| 467 | 474 | using Kernel::SharedMemory; | |
| 468 | // TODO(Subv): Implement this function | 475 | // TODO(Subv): Implement this function |
| 469 | 476 | ||
| 470 | Handle shared_memory = Kernel::CreateSharedMemory(); | 477 | ResultVal<SharedPtr<SharedMemory>> shared_memory_res = SharedMemory::Create(); |
| 471 | *memblock = shared_memory; | 478 | if (shared_memory_res.Failed()) |
| 479 | return shared_memory_res.Code().raw; | ||
| 480 | |||
| 481 | ResultVal<Handle> handle_res = Kernel::g_handle_table.Create(*shared_memory_res); | ||
| 482 | if (handle_res.Failed()) | ||
| 483 | return handle_res.Code().raw; | ||
| 484 | |||
| 485 | *memblock = *handle_res; | ||
| 472 | LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x%08X", addr); | 486 | LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x%08X", addr); |
| 473 | return 0; | 487 | return 0; |
| 474 | } | 488 | } |