interface: allow clear of previously-signaled halt

This commit is contained in:
Liam 2022-06-25 14:51:19 -04:00 committed by merry
parent ff47d0de72
commit 02c8b434c7
5 changed files with 36 additions and 2 deletions

View file

@ -101,6 +101,10 @@ struct Jit::Impl {
Atomic::Or(&jit_state.halt_reason, static_cast<u32>(hr));
}
void ClearHalt(HaltReason hr) {
Atomic::And(&jit_state.halt_reason, ~static_cast<u32>(hr));
}
void ClearExclusiveState() {
jit_state.exclusive_state = 0;
}
@ -232,6 +236,10 @@ void Jit::HaltExecution(HaltReason hr) {
impl->HaltExecution(hr);
}
void Jit::ClearHalt(HaltReason hr) {
impl->ClearHalt(hr);
}
void Jit::ClearExclusiveState() {
impl->ClearExclusiveState();
}

View file

@ -134,6 +134,10 @@ public:
Atomic::Or(&jit_state.halt_reason, static_cast<u32>(hr));
}
void ClearHalt(HaltReason hr) {
Atomic::And(&jit_state.halt_reason, ~static_cast<u32>(hr));
}
u64 GetSP() const {
return jit_state.sp;
}
@ -351,6 +355,10 @@ void Jit::HaltExecution(HaltReason hr) {
impl->HaltExecution(hr);
}
void Jit::ClearHalt(HaltReason hr) {
impl->ClearHalt(hr);
}
u64 Jit::GetSP() const {
return impl->GetSP();
}

View file

@ -17,4 +17,12 @@ inline void Or(volatile u32* ptr, u32 value) {
#endif
}
inline void And(volatile u32* ptr, u32 value) {
#ifdef _MSC_VER
_InterlockedAnd(reinterpret_cast<volatile long*>(ptr), value);
#else
__atomic_and_fetch(ptr, value, __ATOMIC_SEQ_CST);
#endif
}
} // namespace Dynarmic::Atomic

View file

@ -57,10 +57,15 @@ public:
/**
* Stops execution in Jit::Run.
* Can only be called from a callback.
*/
void HaltExecution(HaltReason hr = HaltReason::UserDefined1);
/**
* Clears a halt reason from flags.
* Warning: Only use this if you're sure this won't introduce races.
*/
void ClearHalt(HaltReason hr = HaltReason::UserDefined1);
/// View and modify registers.
std::array<std::uint32_t, 16>& Regs();
const std::array<std::uint32_t, 16>& Regs() const;

View file

@ -58,10 +58,15 @@ public:
/**
* Stops execution in Jit::Run.
* Can only be called from a callback.
*/
void HaltExecution(HaltReason hr = HaltReason::UserDefined1);
/**
* Clears a halt reason from flags.
* Warning: Only use this if you're sure this won't introduce races.
*/
void ClearHalt(HaltReason hr = HaltReason::UserDefined1);
/// Read Stack Pointer
std::uint64_t GetSP() const;
/// Modify Stack Pointer