diff options
| author | Yang Liu <numbksco@gmail.com> | 2024-03-05 00:49:57 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-04 17:49:57 +0100 |
| commit | cc86e94cd5636b1b83fde08a6a82842d182684d7 (patch) | |
| tree | 24b68b09adb7c9ff0be54360482bb6a3c522d099 | |
| parent | 1c10ae443dface55e243ee3ed11fcdd3b636153d (diff) | |
| download | box64-cc86e94cd5636b1b83fde08a6a82842d182684d7.tar.gz box64-cc86e94cd5636b1b83fde08a6a82842d182684d7.zip | |
[LA64] Detect the existence of LBT extension (#1325)
| -rw-r--r-- | src/main.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c index 5e14b677..fdf4edcd 100644 --- a/src/main.c +++ b/src/main.c @@ -445,11 +445,14 @@ HWCAP2_ECV if(arm64_afp) printf_log(LOG_INFO, " AFP"); #elif defined(LA64) - printf_log(LOG_INFO, "Dynarec for LoongArch"); - char *p = getenv("BOX64_DYNAREC_LA64NOEXT"); + printf_log(LOG_INFO, "Dynarec for LoongArch "); + char* p = getenv("BOX64_DYNAREC_LA64NOEXT"); if(p == NULL || p[0] == '0') { - // We don't bother to detect it, it's there. - la64_lbt = 1; + uint32_t cpucfg2 = 0, idx = 2; + // there are other extensions, but we don't care. + asm volatile("cpucfg %0, %1" : "=r"(cpucfg2) : "r"(idx)); + if (la64_lbt = (cpucfg2 >> 18) & 0b1) + printf_log(LOG_INFO, "with extension LBT_X86"); } #elif defined(RV64) void RV64_Detect_Function(); |