Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys_game: Made the LV2 Watchdog restarts the game forcefully #13074

Merged
merged 2 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions rpcs3/Emu/Cell/Modules/cellSysutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Emu/Cell/PPUModule.h"
#include "Emu/Cell/Modules/cellGame.h"

#include "Emu/Cell/lv2/sys_game.h"
#include "Emu/Cell/lv2/sys_process.h"
#include "cellSysutil.h"

Expand Down Expand Up @@ -126,6 +127,10 @@ extern s32 sysutil_send_system_cmd(u64 status, u64 param)
return -1;
}
}
else if (status == CELL_SYSUTIL_REQUEST_EXITGAME)
{
abort_lv2_watchdog();
}

for (sysutil_cb_manager::registered_cb cb : cbm->callbacks)
{
Expand Down
11 changes: 10 additions & 1 deletion rpcs3/Emu/Cell/lv2/sys_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct watchdog_t

Emu.CallFromMainThread([]()
{
Emu.Restart();
Emu.Restart(false);
});

return;
Expand All @@ -82,6 +82,15 @@ struct watchdog_t
static constexpr auto thread_name = "LV2 Watchdog Thread"sv;
};

void abort_lv2_watchdog()
{
if (auto thr = g_fxo->try_get<named_thread<watchdog_t>>())
{
sys_game.notice("Aborting %s...", thr->thread_name);
*thr = thread_state::aborting;
}
}

error_code _sys_game_watchdog_start(u32 timeout)
{
sys_game.trace("sys_game_watchdog_start(timeout=%d)", timeout);
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/Cell/lv2/sys_game.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

void abort_lv2_watchdog();

error_code _sys_game_watchdog_start(u32 timeout);
error_code _sys_game_watchdog_stop();
error_code _sys_game_watchdog_clear();
Expand Down
7 changes: 5 additions & 2 deletions rpcs3/Emu/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2823,13 +2823,16 @@ std::shared_ptr<utils::serial> Emulator::Kill(bool allow_autoexit, bool savestat
return to_ar;
}

game_boot_result Emulator::Restart()
game_boot_result Emulator::Restart(bool graceful)
{
if (!IsStopped())
{
auto save_args = std::make_tuple(argv, envp, data, disc, klic, hdd1, m_config_mode, m_config_mode);

GracefulShutdown(false, false);
if (graceful)
GracefulShutdown(false, false);
else
Kill(false);

std::tie(argv, envp, data, disc, klic, hdd1, m_config_mode, m_config_mode) = std::move(save_args);
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class Emulator final
void Resume();
void GracefulShutdown(bool allow_autoexit = true, bool async_op = false, bool savestate = false);
std::shared_ptr<utils::serial> Kill(bool allow_autoexit = true, bool savestate = false);
game_boot_result Restart();
game_boot_result Restart(bool graceful = true);
bool Quit(bool force_quit);
static void CleanUp();

Expand Down