mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
sys_memory, sys_mmapper rewritten
LogBase::Fatal() removed
This commit is contained in:
parent
39629c5c7a
commit
2d37c6b5e2
20 changed files with 598 additions and 456 deletions
|
|
@ -66,10 +66,26 @@ void MemoryBase::Close()
|
|||
|
||||
bool MemoryBase::Map(const u32 addr, const u32 size)
|
||||
{
|
||||
assert(size && (size | addr) % 4096 == 0);
|
||||
if (!size || (size | addr) % 4096)
|
||||
{
|
||||
throw EXCEPTION("Invalid arguments (addr=0x%x, size=0x%x)", addr, size);
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(Memory.mutex);
|
||||
|
||||
for (auto& block : MemoryBlocks)
|
||||
{
|
||||
if (block->GetStartAddr() >= addr && block->GetStartAddr() <= addr + size - 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (addr >= block->GetStartAddr() && addr <= block->GetEndAddr())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (u32 i = addr / 4096; i < addr / 4096 + size / 4096; i++)
|
||||
{
|
||||
if (vm::check_addr(i * 4096, 4096))
|
||||
|
|
@ -78,9 +94,8 @@ bool MemoryBase::Map(const u32 addr, const u32 size)
|
|||
}
|
||||
}
|
||||
|
||||
MemoryBlocks.push_back((new MemoryBlock())->SetRange(addr, size));
|
||||
MemoryBlocks.push_back((new DynamicMemoryBlock())->SetRange(addr, size));
|
||||
|
||||
LOG_WARNING(MEMORY, "Memory mapped at 0x%x: size=0x%x", addr, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -97,9 +112,25 @@ bool MemoryBase::Unmap(const u32 addr)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
MemoryBlock* MemoryBase::Get(const u32 addr)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(Memory.mutex);
|
||||
|
||||
for (auto& block : MemoryBlocks)
|
||||
{
|
||||
if (block->GetStartAddr() == addr)
|
||||
{
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MemBlockInfo::MemBlockInfo(u32 addr, u32 size)
|
||||
: MemInfo(addr, size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ public:
|
|||
{
|
||||
DynamicMemoryBlock RAM;
|
||||
DynamicMemoryBlock Userspace;
|
||||
} PSV;
|
||||
}
|
||||
PSV;
|
||||
|
||||
struct
|
||||
{
|
||||
|
|
@ -37,7 +38,8 @@ public:
|
|||
DynamicMemoryBlock RAM;
|
||||
DynamicMemoryBlock Kernel;
|
||||
DynamicMemoryBlock Userspace;
|
||||
} PSP;
|
||||
}
|
||||
PSP;
|
||||
|
||||
bool m_inited;
|
||||
|
||||
|
|
@ -51,10 +53,6 @@ public:
|
|||
Close();
|
||||
}
|
||||
|
||||
void RegisterPages(u32 addr, u32 size);
|
||||
|
||||
void UnregisterPages(u32 addr, u32 size);
|
||||
|
||||
void Init(MemoryType type);
|
||||
|
||||
void Close();
|
||||
|
|
@ -82,6 +80,8 @@ public:
|
|||
bool Map(const u32 addr, const u32 size);
|
||||
|
||||
bool Unmap(const u32 addr);
|
||||
|
||||
MemoryBlock* Get(const u32 addr);
|
||||
};
|
||||
|
||||
extern MemoryBase Memory;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue