Implement HLE sys_config stack allocation

This commit is contained in:
Eladash 2020-09-26 10:08:12 +03:00 committed by Ivan
parent 8ad36e2526
commit 83d71519e0
4 changed files with 58 additions and 0 deletions

View file

@ -1,4 +1,6 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
LOG_CHANNEL(sys_io);
@ -7,10 +9,51 @@ extern void cellPad_init();
extern void cellKb_init();
extern void cellMouse_init();
struct libio_sys_config
{
shared_mutex mtx;
s32 init_ctr = 0;
u32 stack_addr = 0;
~libio_sys_config() noexcept
{
if (stack_addr)
{
vm::dealloc_verbose_nothrow(stack_addr, vm::stack);
}
}
};
// Only exists internally (has no name)
extern void libio_sys_config_init()
{
auto cfg = g_fxo->get<libio_sys_config>();
std::lock_guard lock(cfg->mtx);
if (cfg->init_ctr++ == 0)
{
// Belongs to "_cfg_evt_hndlr" thread (8k stack)
cfg->stack_addr = verify(HERE, vm::alloc(0x2000, vm::stack, 4096));
}
}
extern void libio_sys_config_end()
{
auto cfg = g_fxo->get<libio_sys_config>();
std::lock_guard lock(cfg->mtx);
if (cfg->init_ctr-- == 1)
{
verify(HERE), vm::dealloc(std::exchange(cfg->stack_addr, 0), vm::stack);
}
}
error_code sys_config_start()
{
sys_io.todo("sys_config_start()");
return CELL_OK;
}