mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-16 07:10:40 +00:00
Forgotten memory check + PSV stuff fixed
This commit is contained in:
parent
582825934c
commit
7370c49ff3
@ -21,8 +21,8 @@ public:
|
||||
virtual u8 DecodeMemory(const u64 address)
|
||||
{
|
||||
using namespace ARMv7_opcodes;
|
||||
const u16 code0 = Memory.Read16(address);
|
||||
const u16 code1 = Memory.Read16(address + 2);
|
||||
const u16 code0 = Memory.PSV.Read16(address);
|
||||
const u16 code1 = Memory.PSV.Read16(address + 2);
|
||||
|
||||
switch(code0 >> 12) //15 - 12
|
||||
{
|
||||
|
@ -275,7 +275,7 @@ protected:
|
||||
if(regs_list & mask)
|
||||
{
|
||||
CPU.SP -= 4;
|
||||
Memory.Write32(CPU.SP, CPU.read_gpr(i));
|
||||
Memory.PSV.Write32(CPU.SP, CPU.read_gpr(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -286,7 +286,7 @@ protected:
|
||||
{
|
||||
if(regs_list & mask)
|
||||
{
|
||||
CPU.write_gpr(i, Memory.Read32(CPU.SP));
|
||||
CPU.write_gpr(i, Memory.PSV.Read32(CPU.SP));
|
||||
CPU.SP += 4;
|
||||
}
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ void MemoryBase::Write8(u64 addr, const u8 data)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
*(u8*)((u64)GetBaseAddr() + addr) = data;
|
||||
*(u8*)((u8*)GetBaseAddr() + addr) = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -382,7 +382,7 @@ void MemoryBase::Write16(u64 addr, const u16 data)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
*(u16*)((u64)GetBaseAddr() + addr) = re16(data);
|
||||
*(u16*)((u8*)GetBaseAddr() + addr) = re16(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -397,7 +397,7 @@ void MemoryBase::Write32(u64 addr, const u32 data)
|
||||
{
|
||||
if (addr < RAW_SPU_BASE_ADDR || (addr % RAW_SPU_OFFSET) < RAW_SPU_PROB_OFFSET || !RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET])
|
||||
{
|
||||
*(u32*)((u64)GetBaseAddr() + addr) = re32(data);
|
||||
*(u32*)((u8*)GetBaseAddr() + addr) = re32(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -415,7 +415,7 @@ void MemoryBase::Write64(u64 addr, const u64 data)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
*(u64*)((u64)GetBaseAddr() + addr) = re64(data);
|
||||
*(u64*)((u8*)GetBaseAddr() + addr) = re64(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -428,7 +428,7 @@ void MemoryBase::Write128(u64 addr, const u128 data)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
*(u128*)((u64)GetBaseAddr() + addr) = re128(data);
|
||||
*(u128*)((u8*)GetBaseAddr() + addr) = re128(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -476,7 +476,7 @@ u8 MemoryBase::Read8(u64 addr)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
return *(u8*)((u64)GetBaseAddr() + addr);
|
||||
return *(u8*)((u8*)GetBaseAddr() + addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -490,7 +490,7 @@ u16 MemoryBase::Read16(u64 addr)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
return re16(*(u16*)((u64)GetBaseAddr() + addr));
|
||||
return re16(*(u16*)((u8*)GetBaseAddr() + addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -506,7 +506,7 @@ u32 MemoryBase::Read32(u64 addr)
|
||||
{
|
||||
if (addr < RAW_SPU_BASE_ADDR || (addr % RAW_SPU_OFFSET) < RAW_SPU_PROB_OFFSET || !RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET])
|
||||
{
|
||||
return re32(*(u32*)((u64)GetBaseAddr() + addr));
|
||||
return re32(*(u32*)((u8*)GetBaseAddr() + addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -527,7 +527,7 @@ u64 MemoryBase::Read64(u64 addr)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
return re64(*(u64*)((u64)GetBaseAddr() + addr));
|
||||
return re64(*(u64*)((u8*)GetBaseAddr() + addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -541,7 +541,7 @@ u128 MemoryBase::Read128(u64 addr)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
return re128(*(u128*)((u64)GetBaseAddr() + addr));
|
||||
return re128(*(u128*)((u8*)GetBaseAddr() + addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -56,20 +56,43 @@ public:
|
||||
MemoryBlock* RawSPUMem[(0x100000000 - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET];
|
||||
VirtualMemoryBlock RSXIOMem;
|
||||
|
||||
struct
|
||||
struct Reader32LE
|
||||
{
|
||||
private:
|
||||
void* m_base_addr;
|
||||
|
||||
public:
|
||||
Reader32LE() : m_base_addr(nullptr) {}
|
||||
|
||||
void Write8(const u32 addr, const u8 data) { *(u8*)((u64)m_base_addr + addr) = data; }
|
||||
void Write16(const u32 addr, const u16 data) { *(u16*)((u64)m_base_addr + addr) = data; }
|
||||
void Write32(const u32 addr, const u32 data) { *(u32*)((u64)m_base_addr + addr) = data; }
|
||||
void Write64(const u32 addr, const u64 data) { *(u64*)((u64)m_base_addr + addr) = data; }
|
||||
void Write128(const u32 addr, const u128 data) { *(u128*)((u64)m_base_addr + addr) = data; }
|
||||
|
||||
u8 Read8(const u32 addr) { return *(u8*)((u64)m_base_addr + addr); }
|
||||
u16 Read16(const u32 addr) { return *(u16*)((u64)m_base_addr + addr); }
|
||||
u32 Read32(const u32 addr) { return *(u32*)((u64)m_base_addr + addr); }
|
||||
u64 Read64(const u32 addr) { return *(u64*)((u64)m_base_addr + addr); }
|
||||
u128 Read128(const u32 addr) { return *(u128*)((u64)m_base_addr + addr); }
|
||||
|
||||
void Init(void* real_addr) { m_base_addr = real_addr; }
|
||||
};
|
||||
|
||||
struct : Reader32LE
|
||||
{
|
||||
DynamicMemoryBlockLE RAM;
|
||||
DynamicMemoryBlockLE Userspace;
|
||||
} PSVMemory;
|
||||
} PSV;
|
||||
|
||||
struct
|
||||
struct : Reader32LE
|
||||
{
|
||||
DynamicMemoryBlockLE Scratchpad;
|
||||
DynamicMemoryBlockLE VRAM;
|
||||
DynamicMemoryBlockLE RAM;
|
||||
DynamicMemoryBlockLE Kernel;
|
||||
DynamicMemoryBlockLE Userspace;
|
||||
} PSPMemory;
|
||||
} PSP;
|
||||
|
||||
bool m_inited;
|
||||
|
||||
@ -150,17 +173,26 @@ public:
|
||||
return (T)ReverseData<sizeof(T)>(val);
|
||||
};
|
||||
|
||||
u8* GetMemFromAddr(const u64 addr)
|
||||
template<typename T> u8* GetMemFromAddr(const T addr)
|
||||
{
|
||||
return (u8*)GetBaseAddr() + addr;
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
return (u8*)GetBaseAddr() + addr;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR(MEMORY, "%s(): invalid address (0x%llx)", __FUNCTION__, addr);
|
||||
assert(0);
|
||||
return (u8*)GetBaseAddr();
|
||||
}
|
||||
}
|
||||
|
||||
void* VirtualToRealAddr(const u64 vaddr)
|
||||
template<typename T> void* VirtualToRealAddr(const T vaddr)
|
||||
{
|
||||
return GetMemFromAddr(vaddr);
|
||||
return GetMemFromAddr<T>(vaddr);
|
||||
}
|
||||
|
||||
u64 RealToVirtualAddr(const void* addr)
|
||||
u32 RealToVirtualAddr(const void* addr)
|
||||
{
|
||||
const u64 res = (u64)addr - (u64)GetBaseAddr();
|
||||
|
||||
@ -237,16 +269,18 @@ public:
|
||||
break;
|
||||
|
||||
case Memory_PSV:
|
||||
MemoryBlocks.push_back(PSVMemory.RAM.SetRange(0x81000000, 0x10000000));
|
||||
MemoryBlocks.push_back(UserMemory = PSVMemory.Userspace.SetRange(0x91000000, 0x10000000));
|
||||
MemoryBlocks.push_back(PSV.RAM.SetRange(0x81000000, 0x10000000));
|
||||
MemoryBlocks.push_back(UserMemory = PSV.Userspace.SetRange(0x91000000, 0x10000000));
|
||||
PSV.Init(GetBaseAddr());
|
||||
break;
|
||||
|
||||
case Memory_PSP:
|
||||
MemoryBlocks.push_back(PSPMemory.Scratchpad.SetRange(0x00010000, 0x00004000));
|
||||
MemoryBlocks.push_back(PSPMemory.VRAM.SetRange(0x04000000, 0x00200000));
|
||||
MemoryBlocks.push_back(PSPMemory.RAM.SetRange(0x08000000, 0x02000000));
|
||||
MemoryBlocks.push_back(PSPMemory.Kernel.SetRange(0x88000000, 0x00800000));
|
||||
MemoryBlocks.push_back(UserMemory = PSPMemory.Userspace.SetRange(0x08800000, 0x01800000));
|
||||
MemoryBlocks.push_back(PSP.Scratchpad.SetRange(0x00010000, 0x00004000));
|
||||
MemoryBlocks.push_back(PSP.VRAM.SetRange(0x04000000, 0x00200000));
|
||||
MemoryBlocks.push_back(PSP.RAM.SetRange(0x08000000, 0x02000000));
|
||||
MemoryBlocks.push_back(PSP.Kernel.SetRange(0x88000000, 0x00800000));
|
||||
MemoryBlocks.push_back(UserMemory = PSP.Userspace.SetRange(0x08800000, 0x01800000));
|
||||
PSP.Init(GetBaseAddr());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -473,13 +507,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
u8* operator + (const u64 vaddr)
|
||||
template<typename T> u8* operator + (const T vaddr)
|
||||
{
|
||||
u8* ret = GetMemFromAddr(vaddr);
|
||||
u8* ret = GetMemFromAddr<T>(vaddr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
u8& operator[] (const u64 vaddr)
|
||||
template<typename T> u8& operator[] (const T vaddr)
|
||||
{
|
||||
return *(*this + vaddr);
|
||||
}
|
||||
|
@ -237,8 +237,8 @@ bool ELF32Loader::LoadPhdrData(u64 _offset)
|
||||
switch(machine)
|
||||
{
|
||||
case MACHINE_SPU: break;
|
||||
case MACHINE_MIPS: Memory.PSPMemory.RAM.AllocFixed(phdr_arr[i].p_vaddr + offset, phdr_arr[i].p_memsz); break;
|
||||
case MACHINE_ARM: Memory.PSVMemory.RAM.AllocFixed(phdr_arr[i].p_vaddr + offset, phdr_arr[i].p_memsz); break;
|
||||
case MACHINE_MIPS: Memory.PSP.RAM.AllocFixed(phdr_arr[i].p_vaddr + offset, phdr_arr[i].p_memsz); break;
|
||||
case MACHINE_ARM: Memory.PSV.RAM.AllocFixed(phdr_arr[i].p_vaddr + offset, phdr_arr[i].p_memsz); break;
|
||||
|
||||
default:
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user