Savestates Support For PS3 Emulation (#10478)

This commit is contained in:
Elad Ashkenazi 2022-07-04 16:02:17 +03:00 committed by GitHub
parent 969b9eb89d
commit fcd297ffb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
154 changed files with 4948 additions and 635 deletions

View file

@ -9,6 +9,27 @@
LOG_CHANNEL(sys_mutex);
lv2_mutex::lv2_mutex(utils::serial& ar)
: protocol(ar)
, recursive(ar)
, adaptive(ar)
, key(ar)
, name(ar)
{
ar(lock_count, owner);
}
std::shared_ptr<void> lv2_mutex::load(utils::serial& ar)
{
auto mtx = std::make_shared<lv2_mutex>(ar);
return lv2_obj::load(mtx->key, mtx);
}
void lv2_mutex::save(utils::serial& ar)
{
ar(protocol, recursive, adaptive, key, name, lock_count, owner & -2);
}
error_code sys_mutex_create(ppu_thread& ppu, vm::ptr<u32> mutex_id, vm::ptr<sys_mutex_attribute_t> attr)
{
ppu.state += cpu_flag::wait;
@ -154,11 +175,24 @@ error_code sys_mutex_lock(ppu_thread& ppu, u32 mutex_id, u64 timeout)
while (auto state = ppu.state.fetch_sub(cpu_flag::signal))
{
if (is_stopped(state) || state & cpu_flag::signal)
if (state & cpu_flag::signal)
{
break;
}
if (is_stopped(state))
{
std::lock_guard lock(mutex->mutex);
if (std::find(mutex->sq.begin(), mutex->sq.end(), &ppu) == mutex->sq.end())
{
break;
}
ppu.state += cpu_flag::again;
return {};
}
if (timeout)
{
if (lv2_obj::wait_timeout(timeout, &ppu))
@ -166,7 +200,7 @@ error_code sys_mutex_lock(ppu_thread& ppu, u32 mutex_id, u64 timeout)
// Wait for rescheduling
if (ppu.check_state())
{
return {};
continue;
}
std::lock_guard lock(mutex->mutex);