Skip to content

Commit

Permalink
PPU LLVM: Allow to abort OVL analysis in the middle
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jul 14, 2023
1 parent c441469 commit 3570595
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rpcs3/Emu/Cell/PPUModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2682,8 +2682,16 @@ std::pair<std::shared_ptr<lv2_overlay>, CellError> ppu_load_overlay(const ppu_ex

ovlm->entry = static_cast<u32>(elf.header.e_entry);

const auto cpu = cpu_thread::get_current();

// Analyse executable (TODO)
ovlm->analyse(0, ovlm->entry, end, applied);
if (!ovlm->analyse(0, ovlm->entry, end, applied, !cpu ? std::function<bool()>() : [cpu, is_being_used_in_emulation = (vm::base(ovlm->segs[0].addr) == ovlm->segs[0].ptr)]()
{
return is_being_used_in_emulation && cpu->state & cpu_flag::exit;
}))
{
return {nullptr, CellError{CELL_CANCEL + 0u}};
}

// Validate analyser results (not required)
ovlm->validate(0);
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/Emu/Cell/PPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3479,6 +3479,12 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_

if (error)
{
if (error == CELL_CANCEL + 0u)
{
// Emulation stopped
break;
}

// Abort
ovl_err = elf_error::header_type;
break;
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/Emu/Cell/lv2/sys_overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ static error_code overlay_load_module(vm::ptr<u32> ovlmid, const std::string& vp

if (error)
{
if (error == CELL_CANCEL + 0u)
{
// Emulation stopped
return {};
}

return error;
}

Expand Down

0 comments on commit 3570595

Please sign in to comment.