summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-11-09 23:02:50 +0100
committerZach Hilman <zachhilman@gmail.com>2018-11-18 16:53:47 +0100
commit7901de2b75bf527790c3c24e6667b275e2ebeb2b (patch)
treef12da044a1763a561de7b0c9c3117765eae36da1 /src
parentMerge pull request #1722 from MysticExile/enable-applictation-crash-report (diff)
downloadyuzu-7901de2b75bf527790c3c24e6667b275e2ebeb2b.tar
yuzu-7901de2b75bf527790c3c24e6667b275e2ebeb2b.tar.gz
yuzu-7901de2b75bf527790c3c24e6667b275e2ebeb2b.tar.bz2
yuzu-7901de2b75bf527790c3c24e6667b275e2ebeb2b.tar.lz
yuzu-7901de2b75bf527790c3c24e6667b275e2ebeb2b.tar.xz
yuzu-7901de2b75bf527790c3c24e6667b275e2ebeb2b.tar.zst
yuzu-7901de2b75bf527790c3c24e6667b275e2ebeb2b.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/svc.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 2e7c9d094..20af65ee7 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -1194,9 +1194,39 @@ static ResultCode ResetSignal(Handle handle) {
/// Creates a TransferMemory object
static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 permissions) {
- LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x{:X}, size=0x{:X}, perms=0x{:08X}", addr, size,
- permissions);
- *handle = 0;
+ LOG_DEBUG(Kernel_SVC, "called addr=0x{:X}, size=0x{:X}, perms=0x{:08X}", addr, size,
+ permissions);
+
+ if (!Common::Is4KBAligned(addr)) {
+ LOG_ERROR(Kernel_SVC, "Address ({:016X}) is not page aligned!", addr);
+ return ERR_INVALID_ADDRESS;
+ }
+
+ if (!Common::Is4KBAligned(size) || size == 0) {
+ LOG_ERROR(Kernel_SVC, "Size ({:016X}) is not page aligned or equal to zero!", size);
+ return ERR_INVALID_ADDRESS;
+ }
+
+ if (addr + size <= addr) {
+ LOG_ERROR(Kernel_SVC, "Address and size cause overflow! (address={:016X}, size={:016X})",
+ addr, size);
+ return ERR_INVALID_ADDRESS_STATE;
+ }
+
+ if (permissions > static_cast<u32>(MemoryPermission::ReadWrite) ||
+ permissions == static_cast<u32>(MemoryPermission::Write)) {
+ LOG_ERROR(Kernel_SVC, "Invalid memory permissions for transfer memory! (perms={:08X})",
+ permissions);
+ return ERR_INVALID_MEMORY_PERMISSIONS;
+ }
+
+ auto& kernel = Core::System::GetInstance().Kernel();
+ auto& handle_table = Core::CurrentProcess()->GetHandleTable();
+ const auto perms = static_cast<MemoryPermission>(permissions);
+ const auto shared_mem_handle = SharedMemory::Create(
+ kernel, handle_table.Get<Process>(CurrentProcess), size, perms, perms, addr);
+
+ CASCADE_RESULT(*handle, handle_table.Create(shared_mem_handle));
return RESULT_SUCCESS;
}