@@ -171,10 +171,11 @@ int MemoryManager::PoolReserve(void** out_addr, VAddr virtual_addr, size_t size,
171
171
172
172
// Fixed mapping means the virtual address must exactly match the provided one.
173
173
if (True (flags & MemoryMapFlags::Fixed)) {
174
- const auto & vma = FindVMA (mapped_addr)->second ;
174
+ auto & vma = FindVMA (mapped_addr)->second ;
175
175
// If the VMA is mapped, unmap the region first.
176
176
if (vma.IsMapped ()) {
177
177
UnmapMemoryImpl (mapped_addr, size);
178
+ vma = FindVMA (mapped_addr)->second ;
178
179
}
179
180
const size_t remaining_size = vma.base + vma.size - mapped_addr;
180
181
ASSERT_MSG (vma.type == VMAType::Free && remaining_size >= size);
@@ -208,10 +209,11 @@ int MemoryManager::Reserve(void** out_addr, VAddr virtual_addr, size_t size, Mem
208
209
209
210
// Fixed mapping means the virtual address must exactly match the provided one.
210
211
if (True (flags & MemoryMapFlags::Fixed)) {
211
- const auto & vma = FindVMA (mapped_addr)->second ;
212
+ auto & vma = FindVMA (mapped_addr)->second ;
212
213
// If the VMA is mapped, unmap the region first.
213
214
if (vma.IsMapped ()) {
214
215
UnmapMemoryImpl (mapped_addr, size);
216
+ vma = FindVMA (mapped_addr)->second ;
215
217
}
216
218
const size_t remaining_size = vma.base + vma.size - mapped_addr;
217
219
ASSERT_MSG (vma.type == VMAType::Free && remaining_size >= size);
@@ -393,14 +395,18 @@ s32 MemoryManager::UnmapMemoryImpl(VAddr virtual_addr, size_t size) {
393
395
ASSERT_MSG (vma_base.Contains (virtual_addr, size),
394
396
" Existing mapping does not contain requested unmap range" );
395
397
398
+ const auto type = vma_base.type ;
399
+ if (type == VMAType::Free) {
400
+ return ORBIS_OK;
401
+ }
402
+
396
403
const auto vma_base_addr = vma_base.base ;
397
404
const auto vma_base_size = vma_base.size ;
398
405
const auto phys_base = vma_base.phys_base ;
399
406
const bool is_exec = vma_base.is_exec ;
400
407
const auto start_in_vma = virtual_addr - vma_base_addr;
401
- const auto type = vma_base.type ;
402
408
const bool has_backing = type == VMAType::Direct || type == VMAType::File;
403
- if (type == VMAType::Direct) {
409
+ if (type == VMAType::Direct || type == VMAType::Pooled ) {
404
410
rasterizer->UnmapMemory (virtual_addr, size);
405
411
}
406
412
if (type == VMAType::Flexible) {
@@ -418,10 +424,12 @@ s32 MemoryManager::UnmapMemoryImpl(VAddr virtual_addr, size_t size) {
418
424
MergeAdjacent (vma_map, new_it);
419
425
bool readonly_file = vma.prot == MemoryProt::CpuRead && type == VMAType::File;
420
426
421
- // Unmap the memory region.
422
- impl.Unmap (vma_base_addr, vma_base_size, start_in_vma, start_in_vma + size, phys_base, is_exec,
423
- has_backing, readonly_file);
424
- TRACK_FREE (virtual_addr, " VMEM" );
427
+ if (type != VMAType::Reserved && type != VMAType::PoolReserved) {
428
+ // Unmap the memory region.
429
+ impl.Unmap (vma_base_addr, vma_base_size, start_in_vma, start_in_vma + size, phys_base,
430
+ is_exec, has_backing, readonly_file);
431
+ TRACK_FREE (virtual_addr, " VMEM" );
432
+ }
425
433
426
434
return ORBIS_OK;
427
435
}
0 commit comments