From 2ea061b9c7d7f6ef76af237d4944f09678643277 Mon Sep 17 00:00:00 2001 From: eladash Date: Tue, 20 Nov 2018 23:17:53 +0200 Subject: [PATCH] Set total memory size according to sdkver --- rpcs3/Emu/Cell/Modules/cellCamera.h | 2 -- rpcs3/Emu/Cell/PPUModule.cpp | 31 +++++++++++++++++++++++++++++ rpcs3/Emu/Cell/lv2/sys_memory.cpp | 8 ++++---- rpcs3/Emu/Cell/lv2/sys_memory.h | 7 +------ rpcs3/Emu/Cell/lv2/sys_mmapper.cpp | 2 +- rpcs3/rpcs3qt/kernel_explorer.cpp | 2 +- 6 files changed, 38 insertions(+), 14 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellCamera.h b/rpcs3/Emu/Cell/Modules/cellCamera.h index 5008dd279d..7bb78a118c 100644 --- a/rpcs3/Emu/Cell/Modules/cellCamera.h +++ b/rpcs3/Emu/Cell/Modules/cellCamera.h @@ -395,8 +395,6 @@ public: u32 v1, v2; }; attr_t attr[500]{}; - - lv2_memory_container container; atomic_t frame_num; }; diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index f26fadc49e..80553ce5fc 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -12,6 +12,7 @@ #include "Emu/Cell/PPUAnalyser.h" #include "Emu/Cell/lv2/sys_prx.h" +#include "Emu/Cell/lv2/sys_memory.h" #include #include @@ -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(mem_size); + ppu->cmd_push({ppu_cmd::initialize, 0}); // TODO: adjust for liblv2 loading option diff --git a/rpcs3/Emu/Cell/lv2/sys_memory.cpp b/rpcs3/Emu/Cell/lv2/sys_memory.cpp index f1e9ae5509..eb21fc873d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_memory.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_memory.cpp @@ -37,7 +37,7 @@ error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr alloc_addr) } // Get "default" memory container - const auto dct = fxm::get_always(); + const auto dct = fxm::get(); // 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()->used -= shm.second->size(); + fxm::get()->used -= shm.second->size(); return CELL_OK; } @@ -209,7 +209,7 @@ error_code sys_memory_get_user_memory_size(vm::ptr 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(); + const auto dct = fxm::get(); 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 cid, u32 size) return CELL_ENOMEM; } - const auto dct = fxm::get_always(); + const auto dct = fxm::get(); // Try to obtain "physical memory" from the default container if (!dct->take(size)) diff --git a/rpcs3/Emu/Cell/lv2/sys_memory.h b/rpcs3/Emu/Cell/lv2/sys_memory.h index 0a61db2599..804e98476d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_memory.h +++ b/rpcs3/Emu/Cell/lv2/sys_memory.h @@ -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 used{}; // Amount of "physical" memory currently used - lv2_memory_container() = default; - lv2_memory_container(u32 size) : size(size) { diff --git a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp index 633d6ae43b..ba02cb2a22 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp @@ -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(); + const auto dct = fxm::get(); if (!dct->take(size)) { diff --git a/rpcs3/rpcs3qt/kernel_explorer.cpp b/rpcs3/rpcs3qt/kernel_explorer.cpp index 28d83812af..5cae91a1f4 100644 --- a/rpcs3/rpcs3qt/kernel_explorer.cpp +++ b/rpcs3/rpcs3qt/kernel_explorer.cpp @@ -63,7 +63,7 @@ void kernel_explorer::Update() { m_tree->clear(); - const auto dct = fxm::get_always(); + const auto dct = fxm::get(); if (!dct) {