Small changes in memory and RSXIOMem

Some bugs fixed, some other changes.
This commit is contained in:
Nekotekina 2014-10-04 18:43:46 +04:00
parent 6b0857dcff
commit 74007d5e5d
13 changed files with 95 additions and 92 deletions

View file

@ -578,73 +578,71 @@ bool VirtualMemoryBlock::IsMyAddress(const u64 addr)
return false;
}
u64 VirtualMemoryBlock::Map(u64 realaddr, u32 size, u64 addr)
u64 VirtualMemoryBlock::Map(u64 realaddr, u32 size)
{
if(addr)
for (u64 addr = GetStartAddr(); addr <= GetEndAddr() - GetReservedAmount() - size;)
{
if(!IsInMyRange(addr, size) && (IsMyAddress(addr) || IsMyAddress(addr + size - 1)))
return 0;
bool is_good_addr = true;
m_mapped_memory.emplace_back(addr, realaddr, size);
return addr;
}
else
{
for(u64 addr = GetStartAddr(); addr <= GetEndAddr() - GetReservedAmount() - size;)
// check if address is already mapped
for (u32 i = 0; i<m_mapped_memory.size(); ++i)
{
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))
{
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;
}
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;
if (!is_good_addr) continue;
m_mapped_memory.emplace_back(addr, realaddr, size);
return addr;
}
return 0;
}
u32 VirtualMemoryBlock::UnmapRealAddress(u64 realaddr)
bool VirtualMemoryBlock::Map(u64 realaddr, u32 size, u64 addr)
{
if(!IsInMyRange(addr, size) && (IsMyAddress(addr) || IsMyAddress(addr + size - 1)))
return false;
m_mapped_memory.emplace_back(addr, realaddr, size);
return true;
}
bool VirtualMemoryBlock::UnmapRealAddress(u64 realaddr, u32& size)
{
for(u32 i=0; i<m_mapped_memory.size(); ++i)
{
if(m_mapped_memory[i].realAddress == realaddr && IsInMyRange(m_mapped_memory[i].addr, m_mapped_memory[i].size))
{
u32 size = m_mapped_memory[i].size;
size = m_mapped_memory[i].size;
m_mapped_memory.erase(m_mapped_memory.begin() + i);
return size;
return true;
}
}
return 0;
return false;
}
u32 VirtualMemoryBlock::UnmapAddress(u64 addr)
bool VirtualMemoryBlock::UnmapAddress(u64 addr, u32& size)
{
for(u32 i=0; i<m_mapped_memory.size(); ++i)
{
if(m_mapped_memory[i].addr == addr && IsInMyRange(m_mapped_memory[i].addr, m_mapped_memory[i].size))
{
u32 size = m_mapped_memory[i].size;
size = m_mapped_memory[i].size;
m_mapped_memory.erase(m_mapped_memory.begin() + i);
return size;
return true;
}
}
return 0;
return false;
}
bool VirtualMemoryBlock::Read32(const u64 addr, u32* value)