about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2025-06-17 15:54:58 +0800
committerGitHub <noreply@github.com>2025-06-17 09:54:58 +0200
commit71220b7fef4466f98cc78b1d013755aca8e217c6 (patch)
tree22e553abee39ed636e04a59d1b0e782a83cf739d /src
parentae0c91dce0671c176321fc72bfa69f1731d4aa2e (diff)
downloadbox64-71220b7fef4466f98cc78b1d013755aca8e217c6.tar.gz
box64-71220b7fef4466f98cc78b1d013755aca8e217c6.zip
[WOW64] Finished host extension detection (#2755)
Diffstat (limited to 'src')
-rw-r--r--src/os/hostext_wine.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/os/hostext_wine.c b/src/os/hostext_wine.c
index 3b6d5663..3dd9551b 100644
--- a/src/os/hostext_wine.c
+++ b/src/os/hostext_wine.c
@@ -1,4 +1,5 @@
 #include <winternl.h>
+#include <stdio.h>
 
 #include "debug.h"
 #include "wine/compiler.h"
@@ -14,7 +15,33 @@ int DetectHostCpuFeatures(void)
     if (IsProcessorFeaturePresent(PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE))
         cpuext.atomics = 1;
 
-    // TODO
-    cpuext.uscat = cpuext.flagm = cpuext.flagm2 = cpuext.frintts = cpuext.afp = cpuext.rndr = 0;
+    // Read from the registry to get the rest, consider as a success even if it fails
+    HKEY key;
+    ULONGLONG value;
+    DWORD size = sizeof(value);
+    if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, KEY_READ, &key))
+        return 1;
+
+    if (RegQueryValueExA(key, "CP 4030" /* ID_AA64ISAR0_EL1 */, NULL, NULL, (LPBYTE)&value, &size) == ERROR_SUCCESS) {
+        // TS, bits[55:52]
+        cpuext.flagm = !!((value >> 52) & 0x1);
+        cpuext.flagm2 = !!((value >> 53) & 0x1);
+        // PRINTTS, bits[35:32]
+        cpuext.frintts = !!((value >> 32) & 0x1);
+        // RND, bits[63:60]
+        cpuext.rndr = !!((value >> 60) & 0x1);
+    }
+    size = sizeof(value);
+    if (RegQueryValueExA(key, "CP 4039" /* ID_AA64MMFR1_EL1 */, NULL, NULL, (LPBYTE)&value, &size) == ERROR_SUCCESS) {
+        // AFP, bits[47:44]
+        cpuext.afp = !!((value >> 44) & 0x1);
+    }
+    size = sizeof(value);
+    if (RegQueryValueExA(key, "CP 403A" /* ID_AA64MMFR2_EL1 */, NULL, NULL, (LPBYTE)&value, &size) == ERROR_SUCCESS) {
+        // AT, bits[35:32]
+        cpuext.uscat = !!((value >> 32) & 0x1);
+    }
+
+    RegCloseKey(key);
     return 1;
 }