summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/shared_memory.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-08-03 05:37:44 +0200
committerLioncash <mathew1800@gmail.com>2018-08-03 17:22:47 +0200
commit26de4bb521b1ace7af76eff4f6956cb23ac0d58c (patch)
tree904a93d00abf5bde2742499fb3d60a3aa1521820 /src/core/hle/kernel/shared_memory.cpp
parentMerge pull request #892 from lioncash/global (diff)
downloadyuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar.gz
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar.bz2
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar.lz
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar.xz
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar.zst
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/shared_memory.cpp63
1 files changed, 14 insertions, 49 deletions
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index a5b11bd87..b3ddebb3d 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -8,7 +8,6 @@
#include "common/logging/log.h"
#include "core/core.h"
#include "core/hle/kernel/errors.h"
-#include "core/hle/kernel/memory.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/memory.h"
@@ -29,51 +28,22 @@ SharedPtr<SharedMemory> SharedMemory::Create(SharedPtr<Process> owner_process, u
shared_memory->permissions = permissions;
shared_memory->other_permissions = other_permissions;
- if (address == 0) {
- // We need to allocate a block from the Linear Heap ourselves.
- // We'll manually allocate some memory from the linear heap in the specified region.
- MemoryRegionInfo* memory_region = GetMemoryRegion(region);
- auto& linheap_memory = memory_region->linear_heap_memory;
-
- ASSERT_MSG(linheap_memory->size() + size <= memory_region->size,
- "Not enough space in region to allocate shared memory!");
-
- shared_memory->backing_block = linheap_memory;
- shared_memory->backing_block_offset = linheap_memory->size();
- // Allocate some memory from the end of the linear heap for this region.
- linheap_memory->insert(linheap_memory->end(), size, 0);
- memory_region->used += size;
-
- shared_memory->linear_heap_phys_address =
- Memory::FCRAM_PADDR + memory_region->base +
- static_cast<PAddr>(shared_memory->backing_block_offset);
-
- // Increase the amount of used linear heap memory for the owner process.
- if (shared_memory->owner_process != nullptr) {
- shared_memory->owner_process->linear_heap_used += size;
- }
-
- // Refresh the address mappings for the current process.
- if (Core::CurrentProcess() != nullptr) {
- Core::CurrentProcess()->vm_manager.RefreshMemoryBlockMappings(linheap_memory.get());
- }
- } else {
- auto& vm_manager = shared_memory->owner_process->vm_manager;
- // The memory is already available and mapped in the owner process.
- auto vma = vm_manager.FindVMA(address);
- ASSERT_MSG(vma != vm_manager.vma_map.end(), "Invalid memory address");
- ASSERT_MSG(vma->second.backing_block, "Backing block doesn't exist for address");
-
- // The returned VMA might be a bigger one encompassing the desired address.
- auto vma_offset = address - vma->first;
- ASSERT_MSG(vma_offset + size <= vma->second.size,
- "Shared memory exceeds bounds of mapped block");
-
- shared_memory->backing_block = vma->second.backing_block;
- shared_memory->backing_block_offset = vma->second.offset + vma_offset;
- }
+ auto& vm_manager = shared_memory->owner_process->vm_manager;
+
+ // The memory is already available and mapped in the owner process.
+ auto vma = vm_manager.FindVMA(address);
+ ASSERT_MSG(vma != vm_manager.vma_map.end(), "Invalid memory address");
+ ASSERT_MSG(vma->second.backing_block, "Backing block doesn't exist for address");
+
+ // The returned VMA might be a bigger one encompassing the desired address.
+ auto vma_offset = address - vma->first;
+ ASSERT_MSG(vma_offset + size <= vma->second.size,
+ "Shared memory exceeds bounds of mapped block");
+ shared_memory->backing_block = vma->second.backing_block;
+ shared_memory->backing_block_offset = vma->second.offset + vma_offset;
shared_memory->base_address = address;
+
return shared_memory;
}
@@ -124,11 +94,6 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
VAddr target_address = address;
- if (base_address == 0 && target_address == 0) {
- // Calculate the address at which to map the memory block.
- target_address = Memory::PhysicalToVirtualAddress(linear_heap_phys_address).value();
- }
-
// Map the memory block into the target process
auto result = target_process->vm_manager.MapMemoryBlock(
target_address, backing_block, backing_block_offset, size, MemoryState::Shared);