mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 06:26:49 +00:00
Savestates Support For PS3 Emulation (#10478)
This commit is contained in:
parent
969b9eb89d
commit
fcd297ffb2
154 changed files with 4948 additions and 635 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include "Emu/Cell/ErrorCodes.h"
|
||||
#include "Emu/Cell/PPUThread.h"
|
||||
#include "Emu/Cell/timers.hpp"
|
||||
#include "Emu/System.h"
|
||||
#include "sys_event.h"
|
||||
#include "sys_process.h"
|
||||
|
||||
|
|
@ -23,6 +24,24 @@ struct lv2_timer_thread
|
|||
static constexpr auto thread_name = "Timer Thread"sv;
|
||||
};
|
||||
|
||||
lv2_timer::lv2_timer(utils::serial& ar)
|
||||
: lv2_obj{1}
|
||||
, state(ar)
|
||||
, port(lv2_event_queue::load_ptr(ar, port))
|
||||
, source(ar)
|
||||
, data1(ar)
|
||||
, data2(ar)
|
||||
, expire(ar)
|
||||
, period(ar)
|
||||
{
|
||||
}
|
||||
|
||||
void lv2_timer::save(utils::serial& ar)
|
||||
{
|
||||
USING_SERIALIZATION_VERSION(lv2_sync);
|
||||
ar(state), lv2_event_queue::save_ptr(ar, port.get()), ar(source, data1, data2, expire, period);
|
||||
}
|
||||
|
||||
u64 lv2_timer::check()
|
||||
{
|
||||
while (thread_ctrl::state() != thread_state::aborting)
|
||||
|
|
@ -34,6 +53,7 @@ u64 lv2_timer::check()
|
|||
const u64 _now = get_guest_system_time();
|
||||
u64 next = expire;
|
||||
|
||||
// If aborting, perform the last accurate check for event
|
||||
if (_now >= next)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
|
@ -73,7 +93,19 @@ u64 lv2_timer::check()
|
|||
|
||||
void lv2_timer_thread::operator()()
|
||||
{
|
||||
u64 sleep_time = umax;
|
||||
{
|
||||
decltype(timers) vec;
|
||||
|
||||
idm::select<lv2_obj, lv2_timer>([&vec](u32 id, lv2_timer&)
|
||||
{
|
||||
vec.emplace_back(idm::get_unlocked<lv2_obj, lv2_timer>(id));
|
||||
});
|
||||
|
||||
std::lock_guard lock(mutex);
|
||||
timers = std::move(vec);
|
||||
}
|
||||
|
||||
u64 sleep_time = 0;
|
||||
|
||||
while (thread_ctrl::state() != thread_state::aborting)
|
||||
{
|
||||
|
|
@ -87,6 +119,12 @@ void lv2_timer_thread::operator()()
|
|||
|
||||
sleep_time = umax;
|
||||
|
||||
if (Emu.IsPaused())
|
||||
{
|
||||
sleep_time = 10000;
|
||||
continue;
|
||||
}
|
||||
|
||||
reader_lock lock(mutex);
|
||||
|
||||
for (const auto& timer : timers)
|
||||
|
|
@ -115,6 +153,7 @@ error_code sys_timer_create(ppu_thread& ppu, vm::ptr<u32> timer_id)
|
|||
auto& thread = g_fxo->get<named_thread<lv2_timer_thread>>();
|
||||
{
|
||||
std::lock_guard lock(thread.mutex);
|
||||
lv2_obj::unqueue(thread.timers, ptr);
|
||||
thread.timers.emplace_back(std::move(ptr));
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +383,7 @@ error_code sys_timer_sleep(ppu_thread& ppu, u32 sleep_time)
|
|||
{
|
||||
ppu.state += cpu_flag::wait;
|
||||
|
||||
sys_timer.trace("sys_timer_sleep(sleep_time=%d) -> sys_timer_usleep()", sleep_time);
|
||||
sys_timer.warning("sys_timer_sleep(sleep_time=%d)", sleep_time);
|
||||
|
||||
return sys_timer_usleep(ppu, sleep_time * u64{1000000});
|
||||
}
|
||||
|
|
@ -359,7 +398,10 @@ error_code sys_timer_usleep(ppu_thread& ppu, u64 sleep_time)
|
|||
{
|
||||
lv2_obj::sleep(ppu, sleep_time);
|
||||
|
||||
lv2_obj::wait_timeout<true>(sleep_time);
|
||||
if (!lv2_obj::wait_timeout<true>(sleep_time))
|
||||
{
|
||||
ppu.state += cpu_flag::again;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue