mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-14 14:00:42 +02:00
Centralizes all the nasty behaviour that will end up breaking when WINE eventually turns on userspace syscall dispatch. Pushes all of the logic in to the UnixLib. Support both paths until everyone is migrated to supporting the UnixLib, then we can delete the bit of code duplication between the PE side and UnixLib side. Helpful that everything that gets punched through the UnixLib is optional, so worst case some optional bits can break for a while.
45 lines
1.6 KiB
C++
45 lines
1.6 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#pragma once
|
|
|
|
#include <FEXCore/Core/Context.h>
|
|
#include <FEXCore/Config/Config.h>
|
|
#include <FEXCore/Utils/ArchHelpers/Arm64.h>
|
|
|
|
#include "Windows/Common/FEXUnixLib.h"
|
|
|
|
namespace FEX::Windows {
|
|
class TSOHandlerConfig final {
|
|
public:
|
|
TSOHandlerConfig(FEXCore::Context::Context& CTX) {
|
|
if (HalfBarrierTSOEnabled()) {
|
|
UnalignedHandlerType = FEXCore::ArchHelpers::Arm64::UnalignedHandlerType::HalfBarrier;
|
|
} else {
|
|
UnalignedHandlerType = FEXCore::ArchHelpers::Arm64::UnalignedHandlerType::NonAtomic;
|
|
}
|
|
|
|
if (TSOEnabled() && FEX::Windows::UnixLib::TryEnableHardwareTSO()) {
|
|
CTX.SetHardwareTSOSupport(true);
|
|
}
|
|
|
|
uint64_t Flags = (StrictInProcessSplitLocks() ? FEX_UNALIGN_ATOMIC_STRICT_SPLIT_LOCKS : 0) |
|
|
(KernelUnalignedAtomicBackpatching() ? FEX_UNALIGN_ATOMIC_BACKPATCH : 0) | FEX_UNALIGN_ATOMIC_EMULATE;
|
|
|
|
if (UnixLib::SetKernelUnalignedAtomicControl(Flags)) {
|
|
LogMan::Msg::IFmt("FEX: Kernel unaligned atomics enabled!");
|
|
}
|
|
}
|
|
|
|
FEXCore::ArchHelpers::Arm64::UnalignedHandlerType GetUnalignedHandlerType() const {
|
|
return UnalignedHandlerType;
|
|
}
|
|
|
|
private:
|
|
FEX_CONFIG_OPT(TSOEnabled, TSOENABLED);
|
|
FEX_CONFIG_OPT(HalfBarrierTSOEnabled, HALFBARRIERTSOENABLED);
|
|
FEX_CONFIG_OPT(StrictInProcessSplitLocks, STRICTINPROCESSSPLITLOCKS);
|
|
FEX_CONFIG_OPT(KernelUnalignedAtomicBackpatching, KERNELUNALIGNEDATOMICBACKPATCHING);
|
|
|
|
FEXCore::ArchHelpers::Arm64::UnalignedHandlerType UnalignedHandlerType {FEXCore::ArchHelpers::Arm64::UnalignedHandlerType::HalfBarrier};
|
|
};
|
|
} // namespace FEX::Windows
|