diff options
| author | 2015-12-31 09:46:32 -0500 | |
|---|---|---|
| committer | 2016-01-14 11:29:19 -0500 | |
| commit | d90d5a0ee6b9c08baacd56cb88159d20bbfdb2f0 (patch) | |
| tree | 7d0c54fee5790a5c5071d8441ec7cb6d88e0e527 /src/core/hle/svc.cpp | |
| parent | Merge pull request #1309 from lioncash/render (diff) | |
| download | yuzu-d90d5a0ee6b9c08baacd56cb88159d20bbfdb2f0.tar.gz yuzu-d90d5a0ee6b9c08baacd56cb88159d20bbfdb2f0.tar.xz yuzu-d90d5a0ee6b9c08baacd56cb88159d20bbfdb2f0.zip | |
HLE/SVC: Implement UnmapMemoryBlock.
This implementation will need to be (almost completely) changed when we implement multiprocess support.
Diffstat (limited to 'src/core/hle/svc.cpp')
| -rw-r--r-- | src/core/hle/svc.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index e39edcc16..ba21e06d5 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -161,6 +161,8 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o | |||
| 161 | LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", | 161 | LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", |
| 162 | handle, addr, permissions, other_permissions); | 162 | handle, addr, permissions, other_permissions); |
| 163 | 163 | ||
| 164 | // TODO(Subv): The same process that created a SharedMemory object can not map it in its own address space | ||
| 165 | |||
| 164 | SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle); | 166 | SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle); |
| 165 | if (shared_memory == nullptr) | 167 | if (shared_memory == nullptr) |
| 166 | return ERR_INVALID_HANDLE; | 168 | return ERR_INVALID_HANDLE; |
| @@ -175,13 +177,27 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o | |||
| 175 | case MemoryPermission::WriteExecute: | 177 | case MemoryPermission::WriteExecute: |
| 176 | case MemoryPermission::ReadWriteExecute: | 178 | case MemoryPermission::ReadWriteExecute: |
| 177 | case MemoryPermission::DontCare: | 179 | case MemoryPermission::DontCare: |
| 178 | shared_memory->Map(addr, permissions_type, | 180 | return shared_memory->Map(addr, permissions_type, |
| 179 | static_cast<MemoryPermission>(other_permissions)); | 181 | static_cast<MemoryPermission>(other_permissions)); |
| 180 | break; | ||
| 181 | default: | 182 | default: |
| 182 | LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions); | 183 | LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions); |
| 183 | } | 184 | } |
| 184 | return RESULT_SUCCESS; | 185 | |
| 186 | return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 187 | } | ||
| 188 | |||
| 189 | static ResultCode UnmapMemoryBlock(Handle handle, u32 addr) { | ||
| 190 | using Kernel::SharedMemory; | ||
| 191 | |||
| 192 | LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X", handle, addr); | ||
| 193 | |||
| 194 | // TODO(Subv): Return E0A01BF5 if the address is not in the application's heap | ||
| 195 | |||
| 196 | SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle); | ||
| 197 | if (shared_memory == nullptr) | ||
| 198 | return ERR_INVALID_HANDLE; | ||
| 199 | |||
| 200 | return shared_memory->Unmap(addr); | ||
| 185 | } | 201 | } |
| 186 | 202 | ||
| 187 | /// Connect to an OS service given the port name, returns the handle to the port to out | 203 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| @@ -765,7 +781,13 @@ static s64 GetSystemTick() { | |||
| 765 | static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission, | 781 | static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission, |
| 766 | u32 other_permission) { | 782 | u32 other_permission) { |
| 767 | using Kernel::SharedMemory; | 783 | using Kernel::SharedMemory; |
| 768 | // TODO(Subv): Implement this function | 784 | |
| 785 | if (size % Memory::PAGE_SIZE != 0) | ||
| 786 | return ResultCode(ErrorDescription::MisalignedSize, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 787 | |||
| 788 | // TODO(Subv): Return E0A01BF5 if the address is not in the application's heap | ||
| 789 | |||
| 790 | // TODO(Subv): Implement this function properly | ||
| 769 | 791 | ||
| 770 | using Kernel::MemoryPermission; | 792 | using Kernel::MemoryPermission; |
| 771 | SharedPtr<SharedMemory> shared_memory = SharedMemory::Create(size, | 793 | SharedPtr<SharedMemory> shared_memory = SharedMemory::Create(size, |
| @@ -912,7 +934,7 @@ static const FunctionDef SVC_Table[] = { | |||
| 912 | {0x1D, HLE::Wrap<ClearTimer>, "ClearTimer"}, | 934 | {0x1D, HLE::Wrap<ClearTimer>, "ClearTimer"}, |
| 913 | {0x1E, HLE::Wrap<CreateMemoryBlock>, "CreateMemoryBlock"}, | 935 | {0x1E, HLE::Wrap<CreateMemoryBlock>, "CreateMemoryBlock"}, |
| 914 | {0x1F, HLE::Wrap<MapMemoryBlock>, "MapMemoryBlock"}, | 936 | {0x1F, HLE::Wrap<MapMemoryBlock>, "MapMemoryBlock"}, |
| 915 | {0x20, nullptr, "UnmapMemoryBlock"}, | 937 | {0x20, HLE::Wrap<UnmapMemoryBlock>, "UnmapMemoryBlock"}, |
| 916 | {0x21, HLE::Wrap<CreateAddressArbiter>, "CreateAddressArbiter"}, | 938 | {0x21, HLE::Wrap<CreateAddressArbiter>, "CreateAddressArbiter"}, |
| 917 | {0x22, HLE::Wrap<ArbitrateAddress>, "ArbitrateAddress"}, | 939 | {0x22, HLE::Wrap<ArbitrateAddress>, "ArbitrateAddress"}, |
| 918 | {0x23, HLE::Wrap<CloseHandle>, "CloseHandle"}, | 940 | {0x23, HLE::Wrap<CloseHandle>, "CloseHandle"}, |