1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-23 11:13:19 +01:00

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

@ -5,6 +5,9 @@
#include "Emu/Io/KeyboardHandler.h"
#include "cellKb.h"
extern void libio_sys_config_init();
extern void libio_sys_config_end();
LOG_CHANNEL(sys_io);
template<>
@ -42,6 +45,7 @@ error_code cellKbInit(u32 max_connect)
if (max_connect == 0 || max_connect > CELL_KB_MAX_KEYBOARDS)
return CELL_KB_ERROR_INVALID_PARAMETER;
libio_sys_config_init();
handler->Init(std::min(max_connect, 7u));
return CELL_OK;
@ -59,6 +63,7 @@ error_code cellKbEnd()
return CELL_KB_ERROR_UNINITIALIZED;
// TODO
libio_sys_config_end();
return CELL_OK;
}

View File

@ -6,6 +6,9 @@
#include "cellMouse.h"
extern void libio_sys_config_init();
extern void libio_sys_config_end();
LOG_CHANNEL(sys_io);
template<>
@ -45,6 +48,7 @@ error_code cellMouseInit(u32 max_connect)
return CELL_MOUSE_ERROR_INVALID_PARAMETER;
}
libio_sys_config_init();
handler->Init(std::min(max_connect, 7u));
return CELL_OK;
@ -99,6 +103,7 @@ error_code cellMouseEnd()
return CELL_MOUSE_ERROR_UNINITIALIZED;
// TODO
libio_sys_config_end();
return CELL_OK;
}

View File

@ -8,6 +8,9 @@
#include "Input/product_info.h"
#include "cellPad.h"
extern void libio_sys_config_init();
extern void libio_sys_config_end();
LOG_CHANNEL(sys_io);
template<>
@ -61,6 +64,7 @@ error_code cellPadInit(u32 max_connect)
if (max_connect == 0 || max_connect > CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;
libio_sys_config_init();
config->max_connect = std::min<u32>(max_connect, CELL_PAD_MAX_PORT_NUM);
config->port_setting.fill(CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF);
return CELL_OK;
@ -77,6 +81,7 @@ error_code cellPadEnd()
if (!config->max_connect.exchange(0))
return CELL_PAD_ERROR_UNINITIALIZED;
libio_sys_config_end();
return CELL_OK;
}

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;
}