diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-08-28 15:18:07 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-08-28 15:18:07 +0200 |
| commit | 5f31e0e093f87e91dc71de7866450f0036deb91b (patch) | |
| tree | cda95683dd5fda76c052f277404ef6aac7b51cb2 /src | |
| parent | 39f2b508f8e12e12505630d5db78adfbeeb9e7f9 (diff) | |
| download | box64-5f31e0e093f87e91dc71de7866450f0036deb91b.tar.gz box64-5f31e0e093f87e91dc71de7866450f0036deb91b.zip | |
[DYNAREC] Added detection of available CPU Extensions
Diffstat (limited to 'src')
| -rwxr-xr-x | src/include/debug.h | 6 | ||||
| -rwxr-xr-x | src/main.c | 48 |
2 files changed, 54 insertions, 0 deletions
diff --git a/src/include/debug.h b/src/include/debug.h index 26bbb8d7..31f84bde 100755 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -13,6 +13,12 @@ extern int box64_dynarec_dump; extern int box64_dynarec_trace; extern int box64_dynarec_forced; extern uintptr_t box64_nodynarec_start, box64_nodynarec_end; +#ifdef ARM64 +extern int arm64_asimd; +extern int arm64_aes; +extern int arm64_pmull; +extern int arm64_crc32; +#endif #endif extern int dlsym_error; // log dlsym error #ifdef HAVE_TRACE diff --git a/src/main.c b/src/main.c index 68e63fc1..b00618d7 100755 --- a/src/main.c +++ b/src/main.c @@ -9,6 +9,12 @@ #include <signal.h> #include <sys/syscall.h> #include <sys/mman.h> +#ifdef DYNAREC +#ifdef ARM64 +#include <linux/auxvec.h> +#include <asm/hwcap.h> +#endif +#endif #include "build_info.h" #include "debug.h" @@ -38,6 +44,12 @@ int box64_dynarec_dump = 0; int box64_dynarec_forced = 0; uintptr_t box64_nodynarec_start = 0; uintptr_t box64_nodynarec_end = 0; +#ifdef ARM64 +int arm64_asimd = 0; +int arm64_aes = 0; +int arm64_pmull = 0; +int arm64_crc32 = 0; +#endif #else //DYNAREC int box64_dynarec = 0; #endif @@ -116,6 +128,39 @@ void my_child_fork() } } +#ifdef DYNAREC +void GatherDynarecExtensions() +{ + if(box64_dynarec==0) // no need to check if no dynarec + return; +#ifdef ARM64 + unsigned long hwcap = real_getauxval(AT_HWCAP); + if(!hwcap) // no HWCap: provide a default... + hwcap = HWCAP_ASIMD; + // first, check all needed extensions, lif half, edsp and fastmult + if((hwcap&HWCAP_ASIMD) == 0) { + printf_log(LOG_INFO, "Missing ASMID cpu support, disabling Dynarec\n"); + box64_dynarec=0; + return; + } + if(hwcap&HWCAP_CRC32) + arm64_crc32 = 1; + if(hwcap&HWCAP_PMULL) + arm64_pmull = 1; + if(hwcap&HWCAP_AES) + arm64_aes = 1; + printf_log(LOG_INFO, "Dynarec for ARM64, with extension: ASIMD"); + if(arm64_aes) + printf_log(LOG_INFO, " AES"); + if(arm64_crc32) + printf_log(LOG_INFO, " CRC32"); + if(arm64_pmull) + printf_log(LOG_INFO, " PMULL"); + printf_log(LOG_INFO, " PageSize:%d\n", box64_pagesize); +#endif +} +#endif + EXPORTDYN void LoadLogEnv() @@ -355,6 +400,9 @@ void LoadLogEnv() box64_pagesize = sysconf(_SC_PAGESIZE); if(!box64_pagesize) box64_pagesize = 4096; +#ifdef DYNAREC + GatherDynarecExtensions(); +#endif } EXPORTDYN |