Use g_fxo for global lv2_memory_container

This commit is contained in:
Nekotekina 2019-09-17 23:46:07 +03:00
parent 20cb19618d
commit a4951ec407
8 changed files with 19 additions and 17 deletions

View File

@ -1469,7 +1469,7 @@ void ppu_load_exec(const ppu_exec_object& elf)
mem_size += 0xC000000; mem_size += 0xC000000;
} }
fxm::make<lv2_memory_container>(mem_size); g_fxo->init<lv2_memory_container>(mem_size);
ppu->cmd_push({ppu_cmd::initialize, 0}); ppu->cmd_push({ppu_cmd::initialize, 0});

View File

@ -44,7 +44,7 @@ error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr<u32> alloc_addr)
} }
// Get "default" memory container // Get "default" memory container
const auto dct = fxm::get<lv2_memory_container>(); const auto dct = g_fxo->get<lv2_memory_container>();
// Try to get "physical memory" // Try to get "physical memory"
if (!dct->take(size)) if (!dct->take(size))
@ -179,7 +179,7 @@ error_code sys_memory_free(u32 addr)
} }
// Return "physical memory" to the default container // Return "physical memory" to the default container
fxm::get<lv2_memory_container>()->used -= shm.second->size(); g_fxo->get<lv2_memory_container>()->used -= shm.second->size();
return CELL_OK; return CELL_OK;
} }
@ -244,7 +244,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); sys_memory.warning("sys_memory_get_user_memory_size(mem_info=*0x%x)", mem_info);
// Get "default" memory container // Get "default" memory container
const auto dct = fxm::get<lv2_memory_container>(); const auto dct = g_fxo->get<lv2_memory_container>();
::reader_lock lock(s_memstats_mtx); ::reader_lock lock(s_memstats_mtx);
@ -274,7 +274,7 @@ error_code sys_memory_container_create(vm::ptr<u32> cid, u32 size)
return CELL_ENOMEM; return CELL_ENOMEM;
} }
const auto dct = fxm::get<lv2_memory_container>(); const auto dct = g_fxo->get<lv2_memory_container>();
std::lock_guard lock(s_memstats_mtx); std::lock_guard lock(s_memstats_mtx);
@ -325,7 +325,7 @@ error_code sys_memory_container_destroy(u32 cid)
} }
// Return "physical memory" to the default container // Return "physical memory" to the default container
fxm::get<lv2_memory_container>()->used -= ct->size; g_fxo->get<lv2_memory_container>()->used -= ct->size;
return CELL_OK; return CELL_OK;
} }

View File

@ -10,7 +10,7 @@
LOG_CHANNEL(sys_mmapper); LOG_CHANNEL(sys_mmapper);
lv2_memory::lv2_memory(u32 size, u32 align, u64 flags, const std::shared_ptr<lv2_memory_container>& ct) lv2_memory::lv2_memory(u32 size, u32 align, u64 flags, lv2_memory_container* ct)
: size(size) : size(size)
, align(align) , align(align)
, flags(flags) , flags(flags)
@ -113,7 +113,7 @@ error_code sys_mmapper_allocate_shared_memory(ppu_thread& ppu, u64 unk, u32 size
} }
// Get "default" memory container // Get "default" memory container
const auto dct = fxm::get<lv2_memory_container>(); const auto dct = g_fxo->get<lv2_memory_container>();
if (!dct->take(size)) if (!dct->take(size))
{ {
@ -184,7 +184,7 @@ error_code sys_mmapper_allocate_shared_memory_from_container(ppu_thread& ppu, u6
} }
// Generate a new mem ID // Generate a new mem ID
*mem_id = idm::make<lv2_obj, lv2_memory>(size, flags & SYS_MEMORY_PAGE_SIZE_64K ? 0x10000 : 0x100000, flags, ct.ptr); *mem_id = idm::make<lv2_obj, lv2_memory>(size, flags & SYS_MEMORY_PAGE_SIZE_64K ? 0x10000 : 0x100000, flags, ct.ptr.get());
return CELL_OK; return CELL_OK;
} }

View File

@ -15,12 +15,12 @@ struct lv2_memory : lv2_obj
const u32 size; // Memory size const u32 size; // Memory size
const u32 align; // Alignment required const u32 align; // Alignment required
const u64 flags; const u64 flags;
const std::shared_ptr<lv2_memory_container> ct; // Associated memory container lv2_memory_container* const ct; // Associated memory container
const std::shared_ptr<utils::shm> shm; const std::shared_ptr<utils::shm> shm;
atomic_t<u32> counter{0}; atomic_t<u32> counter{0};
lv2_memory(u32 size, u32 align, u64 flags, const std::shared_ptr<lv2_memory_container>& ct); lv2_memory(u32 size, u32 align, u64 flags, lv2_memory_container* ct);
}; };
enum : u64 enum : u64

View File

@ -3,7 +3,7 @@
#include "Emu/Cell/PPUThread.h" #include "Emu/Cell/PPUThread.h"
#include "Emu/Memory/vm_locking.h" #include "Emu/Memory/vm_locking.h"
sys_vm_t::sys_vm_t(u32 _addr, u32 vsize, const std::shared_ptr<lv2_memory_container>& ct, u32 psize) sys_vm_t::sys_vm_t(u32 _addr, u32 vsize, lv2_memory_container* ct, u32 psize)
: ct(ct) : ct(ct)
, psize(psize) , psize(psize)
, addr(_addr) , addr(_addr)
@ -38,7 +38,9 @@ error_code sys_vm_memory_map(ppu_thread& ppu, u32 vsize, u32 psize, u32 cid, u64
return CELL_EINVAL; return CELL_EINVAL;
} }
auto ct = cid == SYS_MEMORY_CONTAINER_ID_INVALID ? fxm::get<lv2_memory_container>() : idm::get<lv2_memory_container>(cid); const auto idm_ct = idm::get<lv2_memory_container>(cid);
const auto ct = cid == SYS_MEMORY_CONTAINER_ID_INVALID ? g_fxo->get<lv2_memory_container>() : idm_ct.get();
if (!ct) if (!ct)
{ {

View File

@ -35,13 +35,13 @@ struct sys_vm_t
static const u32 id_step = 0x1; static const u32 id_step = 0x1;
static const u32 id_count = 16; static const u32 id_count = 16;
const std::shared_ptr<lv2_memory_container> ct; lv2_memory_container* const ct;
const u32 addr; const u32 addr;
const u32 size; const u32 size;
u32 psize; u32 psize;
shared_mutex mutex; shared_mutex mutex;
sys_vm_t(u32 addr, u32 vsize, const std::shared_ptr<lv2_memory_container>& ct, u32 psize); sys_vm_t(u32 addr, u32 vsize, lv2_memory_container* ct, u32 psize);
~sys_vm_t(); ~sys_vm_t();
static std::array<atomic_t<u32>, id_count> g_ids; static std::array<atomic_t<u32>, id_count> g_ids;

View File

@ -28,7 +28,7 @@ namespace rsx
// User memory + fifo size // User memory + fifo size
buffer_size = ::align<u32>(buffer_size, 0x100000) + 0x10000000; buffer_size = ::align<u32>(buffer_size, 0x100000) + 0x10000000;
// We are not allowed to drain all memory so add a little // We are not allowed to drain all memory so add a little
fxm::make<lv2_memory_container>(buffer_size + 0x1000000); g_fxo->init<lv2_memory_container>(buffer_size + 0x1000000);
const u32 contextAddr = vm::alloc(sizeof(rsx_context), vm::main); const u32 contextAddr = vm::alloc(sizeof(rsx_context), vm::main);
if (contextAddr == 0) if (contextAddr == 0)

View File

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