Memory: Implement Unmap in ControlMemory

Also do a sanity check to make sure the memory region is free for linear allocations
This commit is contained in:
PSI-Rockin 2024-05-09 20:05:19 -04:00
parent c65b91e6f1
commit ba25ae7eba
2 changed files with 10 additions and 0 deletions

View file

@ -426,6 +426,9 @@ bool Memory::allocMemoryLinear(u32& outVaddr, u32 inVaddr, s32 pages, FcramRegio
u32 paddr = memList.begin()->paddr;
u32 vaddr = getLinearHeapVaddr() + paddr;
auto res = testMemoryState(vaddr, pages, MemoryState::Free);
if (res.isFailure()) Helpers::panic("Unable to map linear allocation (vaddr:%08X pages:%08X)", vaddr, pages);
Operation op{ .newState = MemoryState::Continuous, .r = r, .w = w, .x = x, .changeState = true, .changePerms = true };
changeMemoryState(vaddr, pages, op);
mapPhysicalMemory(vaddr, paddr, pages, r, w, x);