8#include <botan/internal/cpuid.h>
10#include <botan/internal/os_utils.h>
14#if defined(BOTAN_TARGET_CPU_IS_PPC_FAMILY)
16uint32_t CPUID::CPUID_Data::detect_cpu_features(uint32_t allowed) {
20 enum class PPC_hwcap_bit : uint64_t {
21 ALTIVEC_bit = (1 << 28),
22 CRYPTO_bit = (1 << 25),
28 feat |= if_set(hwcap_altivec, PPC_hwcap_bit::ALTIVEC_bit, CPUID::CPUID_ALTIVEC_BIT, allowed);
30 #if defined(BOTAN_TARGET_ARCH_IS_PPC64)
31 if(feat & CPUID::CPUID_ALTIVEC_BIT) {
33 feat |= if_set(hwcap_crypto, PPC_hwcap_bit::CRYPTO_bit, CPUID::CPUID_POWER_CRYPTO_BIT, allowed);
34 feat |= if_set(hwcap_crypto, PPC_hwcap_bit::DARN_bit, CPUID::CPUID_DARN_BIT, allowed);
41 #if defined(BOTAN_USE_GCC_INLINE_ASM)
42 auto vmx_probe = []()
noexcept ->
int {
47 if(allowed & CPUID::CPUID_ALTIVEC_BIT) {
49 feat |= CPUID::CPUID_ALTIVEC_BIT;
52 #if defined(BOTAN_TARGET_CPU_IS_PPC64)
53 auto vcipher_probe = []()
noexcept ->
int {
54 asm(
"vcipher 0, 0, 0");
58 auto darn_probe = []()
noexcept ->
int {
60 asm volatile(
"darn %0, 1" :
"=r"(output));
61 return (~output) != 0;
64 if(feat & CPUID::CPUID_ALTIVEC_BIT) {
66 feat |= CPUID::CPUID_POWER_CRYPTO_BIT & allowed;
70 feat |= CPUID::CPUID_DARN_BIT & allowed;
unsigned long auxval_hwcap()
int BOTAN_TEST_API run_cpu_instruction_probe(const std::function< int()> &probe_fn)
unsigned long get_auxval(unsigned long id)
unsigned long auxval_hwcap2()