summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Subv2015-12-31 09:46:32 -0500
committerGravatar Subv2016-01-14 11:29:19 -0500
commitd90d5a0ee6b9c08baacd56cb88159d20bbfdb2f0 (patch)
tree7d0c54fee5790a5c5071d8441ec7cb6d88e0e527 /src/core/hle/kernel
parentMerge pull request #1309 from lioncash/render (diff)
downloadyuzu-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/kernel')
-rw-r--r--src/core/hle/kernel/shared_memory.cpp21
-rw-r--r--src/core/hle/kernel/shared_memory.h7
2 files changed, 28 insertions, 0 deletions
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index 1f477664b..d90f0f00f 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -39,6 +39,12 @@ ResultCode SharedMemory::Map(VAddr address, MemoryPermission permissions,
39 ErrorSummary::InvalidArgument, ErrorLevel::Permanent); 39 ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
40 } 40 }
41 41
42 // TODO(Subv): Return E0E01BEE when permissions and other_permissions don't
43 // match what was specified when the memory block was created.
44
45 // TODO(Subv): Return E0E01BEE when address should be 0.
46 // Note: Find out when that's the case.
47
42 if (fixed_address != 0) { 48 if (fixed_address != 0) {
43 if (address != 0 && address != fixed_address) { 49 if (address != 0 && address != fixed_address) {
44 LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s: fixed_addres is 0x%08X!", 50 LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s: fixed_addres is 0x%08X!",
@@ -74,6 +80,21 @@ ResultCode SharedMemory::Map(VAddr address, MemoryPermission permissions,
74 return RESULT_SUCCESS; 80 return RESULT_SUCCESS;
75} 81}
76 82
83ResultCode SharedMemory::Unmap(VAddr address) {
84 if (base_address == 0) {
85 // TODO(Subv): Verify what actually happens when you want to unmap a memory block that
86 // was originally mapped with address = 0
87 return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
88 }
89
90 if (base_address != address)
91 return ResultCode(ErrorDescription::WrongAddress, ErrorModule::OS, ErrorSummary::InvalidState, ErrorLevel::Usage);
92
93 base_address = 0;
94
95 return RESULT_SUCCESS;
96}
97
77u8* SharedMemory::GetPointer(u32 offset) { 98u8* SharedMemory::GetPointer(u32 offset) {
78 if (base_address != 0) 99 if (base_address != 0)
79 return Memory::GetPointer(base_address + offset); 100 return Memory::GetPointer(base_address + offset);
diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h
index 35b550d12..b51049ad0 100644
--- a/src/core/hle/kernel/shared_memory.h
+++ b/src/core/hle/kernel/shared_memory.h
@@ -53,6 +53,13 @@ public:
53 ResultCode Map(VAddr address, MemoryPermission permissions, MemoryPermission other_permissions); 53 ResultCode Map(VAddr address, MemoryPermission permissions, MemoryPermission other_permissions);
54 54
55 /** 55 /**
56 * Unmaps a shared memory block from the specified address in system memory
57 * @param address Address in system memory where the shared memory block is mapped
58 * @return Result code of the unmap operation
59 */
60 ResultCode Unmap(VAddr address);
61
62 /**
56 * Gets a pointer to the shared memory block 63 * Gets a pointer to the shared memory block
57 * @param offset Offset from the start of the shared memory block to get pointer 64 * @param offset Offset from the start of the shared memory block to get pointer
58 * @return Pointer to the shared memory block from the specified offset 65 * @return Pointer to the shared memory block from the specified offset