mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 03:25:16 +00:00
Memory fixes
This commit is contained in:
parent
ce97a7e7a6
commit
4a6779469c
7 changed files with 32 additions and 43 deletions
|
@ -128,7 +128,6 @@ void MemoryBase::Init(MemoryType type)
|
|||
MemoryBlocks.push_back(MainMem.SetRange(0x00010000, 0x2FFF0000));
|
||||
MemoryBlocks.push_back(UserMemory = PRXMem.SetRange(0x30000000, 0x10000000));
|
||||
MemoryBlocks.push_back(RSXCMDMem.SetRange(0x40000000, 0x10000000));
|
||||
MemoryBlocks.push_back(MmaperMem.SetRange(0xB0000000, 0x10000000));
|
||||
MemoryBlocks.push_back(RSXFBMem.SetRange(0xC0000000, 0x10000000));
|
||||
MemoryBlocks.push_back(StackMem.SetRange(0xD0000000, 0x10000000));
|
||||
break;
|
||||
|
@ -218,7 +217,7 @@ bool MemoryBase::Map(const u64 addr, const u32 size)
|
|||
}
|
||||
|
||||
MemoryBlocks.push_back((new MemoryBlock())->SetRange(addr, size));
|
||||
LOG_WARNING(MEMORY, "MemoryBase::Map(0x%llx, 0x%x)", addr, size);
|
||||
LOG_WARNING(MEMORY, "Memory mapped at 0x%llx: size=0x%x", addr, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ public:
|
|||
DynamicMemoryBlock MainMem;
|
||||
DynamicMemoryBlock PRXMem;
|
||||
DynamicMemoryBlock RSXCMDMem;
|
||||
DynamicMemoryBlock MmaperMem;
|
||||
DynamicMemoryBlock RSXFBMem;
|
||||
DynamicMemoryBlock StackMem;
|
||||
MemoryBlock* RawSPUMem[(0x100000000 - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET];
|
||||
|
|
|
@ -366,7 +366,7 @@ namespace vm
|
|||
//BE pointer to LE data
|
||||
template<typename T, int lvl = 1, typename AT = u32> struct bptrl : public _ptr_base<T, lvl, typename to_be_t<AT>::type>
|
||||
{
|
||||
static bptrl make(AT addr)
|
||||
static bptrl make(typename to_be_t<AT>::type addr)
|
||||
{
|
||||
return (bptrl&)addr;
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ namespace vm
|
|||
//BE pointer to BE data
|
||||
template<typename T, int lvl = 1, typename AT = u32> struct bptrb : public _ptr_base<typename to_be_t<T>::type, lvl, typename to_be_t<AT>::type>
|
||||
{
|
||||
static bptrb make(AT addr)
|
||||
static bptrb make(typename to_be_t<AT>::type addr)
|
||||
{
|
||||
return (bptrb&)addr;
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ namespace vm
|
|||
//default pointer for HLE structures (BE ptrerence to BE data)
|
||||
template<typename T, int lvl = 1, typename AT = u32> struct bptr : public bptrb<T, lvl, AT>
|
||||
{
|
||||
static bptr make(AT addr)
|
||||
static bptr make(typename to_be_t<AT>::type addr)
|
||||
{
|
||||
return (bptr&)addr;
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ void getSaveDataStat(SaveDataEntry entry, vm::ptr<CellSaveDataStatGet> statGet)
|
|||
strcpy_trunc(statGet->getParam.listParam, entry.listParam);
|
||||
|
||||
statGet->fileNum = 0;
|
||||
statGet->fileList = vm::bptr<CellSaveDataFileStat>::make(0);
|
||||
statGet->fileList.set(be_t<u32>::make(0));
|
||||
statGet->fileListNum = 0;
|
||||
std::string saveDir = "/dev_hdd0/home/00000001/savedata/" + entry.dirName; // TODO: Get the path of the current user
|
||||
vfsDir dir(saveDir);
|
||||
|
|
|
@ -1337,7 +1337,7 @@ s64 cellSpursGetWorkloadFlag(vm::ptr<CellSpurs> spurs, vm::ptr<vm::bptr<CellSpur
|
|||
return CELL_SPURS_POLICY_MODULE_ERROR_ALIGN;
|
||||
}
|
||||
|
||||
*flag = vm::bptr<CellSpursWorkloadFlag>::make(Memory.RealToVirtualAddr(&spurs->m.wklFlag));
|
||||
flag->set(be_t<u32>::make(Memory.RealToVirtualAddr(&spurs->m.wklFlag)));
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -271,20 +271,20 @@ struct CellSpurs
|
|||
// real data
|
||||
struct
|
||||
{
|
||||
atomic_t<u8> wklReadyCount[0x20];
|
||||
u8 wklA[0x10]; // 0x20
|
||||
u8 wklB[0x10]; // 0x30
|
||||
u8 wklMinCnt[0x10]; // 0x40
|
||||
atomic_t<u8> wklMaxCnt[0x10]; // 0x50
|
||||
atomic_t<u8> wklReadyCount[0x20]; // 0x0 (index = wid)
|
||||
u8 wklA[0x10]; // 0x20 (packed 4-bit data, index = wid % 16, internal index = wid / 16)
|
||||
u8 wklB[0x10]; // 0x30 (packed 4-bit data, index = wid % 16, internal index = wid / 16)
|
||||
u8 wklMinCnt[0x10]; // 0x40 (seems only for first 0..15 wids)
|
||||
atomic_t<u8> wklMaxCnt[0x10]; // 0x50 (packed 4-bit data, index = wid % 16, internal index = wid / 16)
|
||||
CellSpursWorkloadFlag wklFlag; // 0x60
|
||||
atomic_t<u16> wklSet1; // 0x70
|
||||
atomic_t<u16> wklSet1; // 0x70 (bitset for 0..15 wids)
|
||||
atomic_t<u8> x72; // 0x72
|
||||
u8 x73; // 0x73
|
||||
u8 flags1; // 0x74
|
||||
u8 x75; // 0x75
|
||||
u8 nSpus; // 0x76
|
||||
atomic_t<u8> flagRecv; // 0x77
|
||||
atomic_t<u16> wklSet2; // 0x78
|
||||
atomic_t<u16> wklSet2; // 0x78 (bitset for 16..32 wids)
|
||||
u8 x7A[6]; // 0x7A
|
||||
atomic_t<u8> wklStat1[0x10]; // 0x80
|
||||
u8 wklD1[0x10]; // 0x90
|
||||
|
@ -314,7 +314,7 @@ struct CellSpurs
|
|||
be_t<u32> unk12; // 0x98C
|
||||
be_t<u64> unk13; // 0x990
|
||||
u8 unknown4[0xB00 - 0x998];
|
||||
_sub_str3 wklG1[0x10];// 0xB00
|
||||
_sub_str3 wklG1[0x10]; // 0xB00
|
||||
be_t<u64> unk7; // 0xD00
|
||||
be_t<u64> unk8; // 0xD08
|
||||
be_t<u32> unk9; // 0xD10
|
||||
|
@ -334,8 +334,8 @@ struct CellSpurs
|
|||
be_t<u32> exception; // 0xD6C
|
||||
sys_spu_image spuImg; // 0xD70
|
||||
be_t<u32> flags; // 0xD80
|
||||
be_t<s32> spuPriority;// 0xD84
|
||||
be_t<u32> ppuPriority;// 0xD88
|
||||
be_t<s32> spuPriority; // 0xD84
|
||||
be_t<u32> ppuPriority; // 0xD88
|
||||
char prefix[0x0f]; // 0xD8C
|
||||
u8 prefixSize; // 0xD9B
|
||||
be_t<u32> unk5; // 0xD9C
|
||||
|
@ -345,12 +345,12 @@ struct CellSpurs
|
|||
sys_lwmutex_t mutex; // 0xDB0
|
||||
sys_lwcond_t cond; // 0xDC8
|
||||
u8 unknown9[0xE00 - 0xDD0];
|
||||
_sub_str4 wklH1[0x10];// 0xE00
|
||||
_sub_str4 wklH1[0x10]; // 0xE00
|
||||
_sub_str2 sub3; // 0xF00
|
||||
u8 unknown6[0x1000 - 0xF80];
|
||||
_sub_str3 wklG2[0x10];// 0x1000
|
||||
_sub_str1 wklF2[0x10];// 0x1200
|
||||
_sub_str4 wklH2[0x10];// 0x1A00
|
||||
_sub_str3 wklG2[0x10]; // 0x1000
|
||||
_sub_str1 wklF2[0x10]; // 0x1200
|
||||
_sub_str4 wklH2[0x10]; // 0x1A00
|
||||
} m;
|
||||
|
||||
// alternative implementation
|
||||
|
|
|
@ -11,7 +11,7 @@ MemoryContainerInfo* current_ct;
|
|||
|
||||
s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 addr)
|
||||
{
|
||||
sys_vm.Todo("sys_vm_memory_map(vsize=0x%x,psize=0x%x,cidr=0x%x,flags=0x%llx,policy=0x%llx,addr=0x%x)",
|
||||
sys_vm.Error("sys_vm_memory_map(vsize=0x%x, psize=0x%x, cidr=0x%x, flags=0x%llx, policy=0x%llx, addr_addr=0x%x)",
|
||||
vsize, psize, cid, flag, policy, addr);
|
||||
|
||||
// Check virtual size.
|
||||
|
@ -26,25 +26,12 @@ s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 a
|
|||
return CELL_ENOMEM;
|
||||
}
|
||||
|
||||
// Use fixed address (TODO: search and use some free address instead)
|
||||
u32 new_addr = Memory.IsGoodAddr(0x60000000) ? 0x70000000 : 0x60000000;
|
||||
|
||||
// If container ID is SYS_MEMORY_CONTAINER_ID_INVALID, allocate directly.
|
||||
if(cid == SYS_MEMORY_CONTAINER_ID_INVALID)
|
||||
{
|
||||
u32 new_addr;
|
||||
switch(flag)
|
||||
{
|
||||
case SYS_MEMORY_PAGE_SIZE_1M:
|
||||
new_addr = (u32)Memory.Alloc(psize, 0x100000);
|
||||
break;
|
||||
|
||||
case SYS_MEMORY_PAGE_SIZE_64K:
|
||||
new_addr = (u32)Memory.Alloc(psize, 0x10000);
|
||||
break;
|
||||
|
||||
default: return CELL_EINVAL;
|
||||
}
|
||||
|
||||
if(!new_addr) return CELL_ENOMEM;
|
||||
|
||||
// Create a new MemoryContainerInfo to act as default container with vsize.
|
||||
current_ct = new MemoryContainerInfo(new_addr, vsize);
|
||||
}
|
||||
|
@ -57,18 +44,22 @@ s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 a
|
|||
current_ct = ct;
|
||||
}
|
||||
|
||||
// Allocate actual memory using virtual size (physical size is ignored)
|
||||
assert(Memory.Map(new_addr, vsize));
|
||||
|
||||
// Write a pointer for the allocated memory.
|
||||
vm::write32(addr, current_ct->addr);
|
||||
vm::write32(addr, new_addr);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 sys_vm_unmap(u32 addr)
|
||||
{
|
||||
sys_vm.Todo("sys_vm_unmap(addr=0x%x)", addr);
|
||||
sys_vm.Error("sys_vm_unmap(addr=0x%x)", addr);
|
||||
|
||||
// Simply free the memory to unmap.
|
||||
if(!Memory.Free(addr)) return CELL_EINVAL;
|
||||
// Unmap memory.
|
||||
assert(addr == 0x60000000 || addr == 0x70000000);
|
||||
if(!Memory.Unmap(addr)) return CELL_EINVAL;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue