setup initial value of MSR on ppc context

Fixed PrefetchW feature check
Added prefetchw check to startup AVX check, there should be no CPUs that support AVX but not PrefetchW.
Init VRSAVE to all ones.
Removed unused disable_global_lock flag.
This commit is contained in:
chss95cs@gmail.com
2023-04-01 14:48:56 -04:00
parent 8678becda6
commit 6ccdc4d0df
6 changed files with 42 additions and 23 deletions

View File

@@ -14,20 +14,32 @@
// Includes Windows headers, so it goes after platform_win.h.
#include "third_party/xbyak/xbyak/xbyak_util.h"
class StartupAvxCheck {
class StartupCpuFeatureCheck {
public:
StartupAvxCheck() {
StartupCpuFeatureCheck() {
Xbyak::util::Cpu cpu;
if (cpu.has(Xbyak::util::Cpu::tAVX)) {
return;
const char* error_message = nullptr;
if (!cpu.has(Xbyak::util::Cpu::tAVX)) {
error_message =
"Your CPU does not support AVX, which is required by Xenia. See "
"the "
"FAQ for system requirements at https://xenia.jp";
}
unsigned int data[4];
Xbyak::util::Cpu::getCpuid(0x80000001, data);
if (!(data[2] & (1U << 8))) {
error_message =
"Your cpu does not support PrefetchW, which Xenia Canary "
"requires.";
}
if (error_message == nullptr) {
return;
} else {
// TODO(gibbed): detect app type and printf instead, if needed?
MessageBoxA(nullptr, error_message, "Xenia Error",
MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
ExitProcess(static_cast<uint32_t>(-1));
}
// TODO(gibbed): detect app type and printf instead, if needed?
MessageBoxA(
nullptr,
"Your CPU does not support AVX, which is required by Xenia. See the "
"FAQ for system requirements at https://xenia.jp",
"Xenia Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
ExitProcess(static_cast<uint32_t>(-1));
}
};
@@ -38,4 +50,4 @@ class StartupAvxCheck {
// https://docs.microsoft.com/en-us/cpp/preprocessor/init-seg
#pragma warning(suppress : 4073)
#pragma init_seg(lib)
static StartupAvxCheck gStartupAvxCheck;
static StartupCpuFeatureCheck gStartupAvxCheck;

View File

@@ -71,6 +71,13 @@ void InitFeatureFlags() {
unsigned int data[4];
Xbyak::util::Cpu::getCpuid(0x80000001, data);
unsigned amd_flags = data[2];
// chrispy: do prefetchw manually, prefetchw is one of the features xbyak
// ignores if you have an amd cpu.
if (amd_flags & (1U << 8)) {
// no mask for prefetchw
feature_flags_ |= kX64EmitPrefetchW;
}
if (amd_flags & (1U << 5)) {
if ((cvars::x64_extension_mask & kX64EmitLZCNT) == kX64EmitLZCNT) {
feature_flags_ |= kX64EmitLZCNT;