mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 06:26:49 +00:00
allow deallocations to unmap rsx mapped memory
This commit is contained in:
parent
ce98c962f8
commit
23b380eb41
7 changed files with 84 additions and 64 deletions
|
|
@ -13,35 +13,7 @@ VirtualMemoryBlock* VirtualMemoryBlock::SetRange(const u32 start, const u32 size
|
|||
|
||||
bool VirtualMemoryBlock::IsInMyRange(const u32 addr, const u32 size)
|
||||
{
|
||||
return addr >= m_range_start && addr + size - 1 <= m_range_start + m_range_size - 1 - GetReservedAmount();
|
||||
}
|
||||
|
||||
u32 VirtualMemoryBlock::Map(u32 realaddr, u32 size)
|
||||
{
|
||||
for (u32 addr = m_range_start; addr <= m_range_start + m_range_size - 1 - GetReservedAmount() - size;)
|
||||
{
|
||||
bool is_good_addr = true;
|
||||
|
||||
// check if address is already mapped
|
||||
for (u32 i = 0; i<m_mapped_memory.size(); ++i)
|
||||
{
|
||||
if ((addr >= m_mapped_memory[i].addr && addr < m_mapped_memory[i].addr + m_mapped_memory[i].size) ||
|
||||
(m_mapped_memory[i].addr >= addr && m_mapped_memory[i].addr < addr + size))
|
||||
{
|
||||
is_good_addr = false;
|
||||
addr = m_mapped_memory[i].addr + m_mapped_memory[i].size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_good_addr) continue;
|
||||
|
||||
m_mapped_memory.emplace_back(addr, realaddr, size);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return addr >= m_range_start && addr + size <= m_range_start + m_range_size - GetReservedAmount();
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Map(u32 realaddr, u32 size, u32 addr)
|
||||
|
|
@ -117,7 +89,7 @@ bool VirtualMemoryBlock::getRealAddr(u32 addr, u32& result)
|
|||
return false;
|
||||
}
|
||||
|
||||
u32 VirtualMemoryBlock::getMappedAddress(u32 realAddress)
|
||||
s32 VirtualMemoryBlock::getMappedAddress(u32 realAddress)
|
||||
{
|
||||
for (u32 i = 0; i<m_mapped_memory.size(); ++i)
|
||||
{
|
||||
|
|
@ -127,7 +99,7 @@ u32 VirtualMemoryBlock::getMappedAddress(u32 realAddress)
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Reserve(u32 size)
|
||||
|
|
@ -152,3 +124,13 @@ u32 VirtualMemoryBlock::GetReservedAmount()
|
|||
{
|
||||
return m_reserve_size;
|
||||
}
|
||||
|
||||
u32 VirtualMemoryBlock::GetRangeStart()
|
||||
{
|
||||
return m_range_start;
|
||||
}
|
||||
|
||||
u32 VirtualMemoryBlock::GetRangeEnd()
|
||||
{
|
||||
return m_range_start + m_range_size - GetReservedAmount();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,10 +51,8 @@ public:
|
|||
u32 GetSize() const { return m_range_size; }
|
||||
bool IsInMyRange(const u32 addr, const u32 size);
|
||||
|
||||
// maps real address to virtual address space, returns the mapped address or 0 on failure (if no address is specified the
|
||||
// first mappable space is used)
|
||||
// maps real address to virtual address space
|
||||
bool Map(u32 realaddr, u32 size, u32 addr);
|
||||
u32 Map(u32 realaddr, u32 size);
|
||||
|
||||
// Unmap real address (please specify only starting point, no midway memory will be unmapped), returns the size of the unmapped area
|
||||
bool UnmapRealAddress(u32 realaddr, u32& size);
|
||||
|
|
@ -71,6 +69,12 @@ public:
|
|||
// Return the total amount of reserved memory
|
||||
u32 GetReservedAmount();
|
||||
|
||||
// Return the start of the mapped space
|
||||
u32 GetRangeStart();
|
||||
|
||||
// Return the end of the mapped space
|
||||
u32 GetRangeEnd();
|
||||
|
||||
bool Read32(const u32 addr, u32* value);
|
||||
|
||||
bool Write32(const u32 addr, const u32 value);
|
||||
|
|
@ -92,6 +96,6 @@ public:
|
|||
return realAddr;
|
||||
}
|
||||
|
||||
// return the mapped address given a real address, if not mapped return 0
|
||||
u32 getMappedAddress(u32 realAddress);
|
||||
// return the mapped address given a real address, if not mapped return minus one
|
||||
s32 getMappedAddress(u32 realAddress);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue