mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-12 01:18:01 +01:00
Squashed 'externals/biscuit/' content from commit 1d53c9e6
git-subtree-dir: externals/biscuit git-subtree-split: 1d53c9e6cfe56544982200a5bac15a5de064936b
This commit is contained in:
commit
e4a733d5b2
55 changed files with 40248 additions and 0 deletions
39
src/cpuinfo.cpp
Normal file
39
src/cpuinfo.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c), 2022, KNS Group LLC (YADRO)
|
||||
//
|
||||
// Use of this source code is governed by an MIT-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
#include <biscuit/cpuinfo.hpp>
|
||||
|
||||
namespace biscuit {
|
||||
|
||||
bool CPUInfo::Has(RISCVExtension extension) const {
|
||||
#if defined(__linux__) && defined(__riscv)
|
||||
const static uint64_t features = getauxval(AT_HWCAP) & (
|
||||
COMPAT_HWCAP_ISA_I |
|
||||
COMPAT_HWCAP_ISA_M |
|
||||
COMPAT_HWCAP_ISA_A |
|
||||
COMPAT_HWCAP_ISA_F |
|
||||
COMPAT_HWCAP_ISA_D |
|
||||
COMPAT_HWCAP_ISA_C |
|
||||
COMPAT_HWCAP_ISA_V
|
||||
);
|
||||
#else
|
||||
const static uint64_t features = 0;
|
||||
#endif
|
||||
|
||||
return (features & static_cast<uint64_t>(extension)) != 0;
|
||||
}
|
||||
|
||||
uint32_t CPUInfo::GetVlenb() const {
|
||||
if(Has(RISCVExtension::V)) {
|
||||
static CSRReader<CSR::VLenb> csrReader;
|
||||
const static auto getVLEN = csrReader.GetCode<uint32_t (*)()>();
|
||||
return getVLEN();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace biscuit
|
||||
Loading…
Add table
Add a link
Reference in a new issue