Set total memory size according to sdkver

This commit is contained in:
eladash 2018-11-20 23:17:53 +02:00 committed by Ani
parent c0eb4965f2
commit 2ea061b9c7
6 changed files with 38 additions and 14 deletions

View File

@ -395,8 +395,6 @@ public:
u32 v1, v2;
};
attr_t attr[500]{};
lv2_memory_container container;
atomic_t<u32> frame_num;
};

View File

@ -12,6 +12,7 @@
#include "Emu/Cell/PPUAnalyser.h"
#include "Emu/Cell/lv2/sys_prx.h"
#include "Emu/Cell/lv2/sys_memory.h"
#include <map>
#include <set>
@ -1497,6 +1498,36 @@ void ppu_load_exec(const ppu_exec_object& elf)
ppu->gpr[1] -= Emu.data.size();
}
// Initialize memory stats (according to sdk version)
// TODO: This is probably wrong with vsh.self
u32 mem_size;
if (sdk_version > 0x0021FFFF)
{
mem_size = 0xD500000;
}
else if (sdk_version > 0x00192FFF)
{
mem_size = 0xD300000;
}
else if (sdk_version > 0x0018FFFF)
{
mem_size = 0xD100000;
}
else if (sdk_version > 0x0017FFFF)
{
mem_size = 0xD000000;
}
else if (sdk_version > 0x00154FFF)
{
mem_size = 0xCC00000;
}
else
{
mem_size = 0xC800000;
}
fxm::make_always<lv2_memory_container>(mem_size);
ppu->cmd_push({ppu_cmd::initialize, 0});
// TODO: adjust for liblv2 loading option

View File

@ -37,7 +37,7 @@ error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr<u32> alloc_addr)
}
// Get "default" memory container
const auto dct = fxm::get_always<lv2_memory_container>();
const auto dct = fxm::get<lv2_memory_container>();
// Try to get "physical memory"
if (!dct->take(size))
@ -151,7 +151,7 @@ error_code sys_memory_free(u32 addr)
}
// Return "physical memory" to the default container
fxm::get_always<lv2_memory_container>()->used -= shm.second->size();
fxm::get<lv2_memory_container>()->used -= shm.second->size();
return CELL_OK;
}
@ -209,7 +209,7 @@ error_code sys_memory_get_user_memory_size(vm::ptr<sys_memory_info_t> mem_info)
sys_memory.warning("sys_memory_get_user_memory_size(mem_info=*0x%x)", mem_info);
// Get "default" memory container
const auto dct = fxm::get_always<lv2_memory_container>();
const auto dct = fxm::get<lv2_memory_container>();
mem_info->total_user_memory = dct->size;
mem_info->available_user_memory = dct->size - dct->used;
@ -235,7 +235,7 @@ error_code sys_memory_container_create(vm::ptr<u32> cid, u32 size)
return CELL_ENOMEM;
}
const auto dct = fxm::get_always<lv2_memory_container>();
const auto dct = fxm::get<lv2_memory_container>();
// Try to obtain "physical memory" from the default container
if (!dct->take(size))

View File

@ -50,14 +50,9 @@ struct lv2_memory_container
static const u32 id_step = 0x1;
static const u32 id_count = 16;
// This is purposely set lower to fake the size of the OS
// Todo: This could change with requested sdk
const u32 size = 0xEC00000; // Amount of "physical" memory in this container
const u32 size; // Amount of "physical" memory in this container
atomic_t<u32> used{}; // Amount of "physical" memory currently used
lv2_memory_container() = default;
lv2_memory_container(u32 size)
: size(size)
{

View File

@ -105,7 +105,7 @@ error_code sys_mmapper_allocate_shared_memory(u64 unk, u32 size, u64 flags, vm::
}
// Get "default" memory container
const auto dct = fxm::get_always<lv2_memory_container>();
const auto dct = fxm::get<lv2_memory_container>();
if (!dct->take(size))
{

View File

@ -63,7 +63,7 @@ void kernel_explorer::Update()
{
m_tree->clear();
const auto dct = fxm::get_always<lv2_memory_container>();
const auto dct = fxm::get<lv2_memory_container>();
if (!dct)
{