diff options
Diffstat (limited to 'src/arm/linux/api.h')
-rw-r--r-- | src/arm/linux/api.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/arm/linux/api.h b/src/arm/linux/api.h new file mode 100644 index 0000000..4e13e00 --- /dev/null +++ b/src/arm/linux/api.h @@ -0,0 +1,103 @@ +#pragma once + +#include <stdbool.h> +#include <stdint.h> + +#include <cpuinfo.h> + + +#define PROC_CPUINFO_ARCH_T UINT32_C(0x00000001) +#define PROC_CPUINFO_ARCH_E UINT32_C(0x00000002) +#define PROC_CPUINFO_ARCH_J UINT32_C(0x00000004) + +struct proc_cpuinfo_arch { + uint32_t version; + uint32_t flags; +}; + +struct proc_cpuinfo_cache { + uint32_t i_size; + uint32_t i_assoc; + uint32_t i_line_length; + uint32_t i_sets; + uint32_t d_size; + uint32_t d_assoc; + uint32_t d_line_length; + uint32_t d_sets; +}; + +/* arch/arm/include/uapi/asm/hwcap.h */ + +#define PROC_CPUINFO_FEATURE_SWP UINT32_C(0x00000001) +#define PROC_CPUINFO_FEATURE_HALF UINT32_C(0x00000002) +#define PROC_CPUINFO_FEATURE_THUMB UINT32_C(0x00000004) +#define PROC_CPUINFO_FEATURE_26BIT UINT32_C(0x00000008) +#define PROC_CPUINFO_FEATURE_FASTMULT UINT32_C(0x00000010) +#define PROC_CPUINFO_FEATURE_FPA UINT32_C(0x00000020) +#define PROC_CPUINFO_FEATURE_VFP UINT32_C(0x00000040) +#define PROC_CPUINFO_FEATURE_EDSP UINT32_C(0x00000080) +#define PROC_CPUINFO_FEATURE_JAVA UINT32_C(0x00000100) +#define PROC_CPUINFO_FEATURE_IWMMXT UINT32_C(0x00000200) +#define PROC_CPUINFO_FEATURE_CRUNCH UINT32_C(0x00000400) +#define PROC_CPUINFO_FEATURE_THUMBEE UINT32_C(0x00000800) +#define PROC_CPUINFO_FEATURE_NEON UINT32_C(0x00001000) +#define PROC_CPUINFO_FEATURE_VFPV3 UINT32_C(0x00002000) +#define PROC_CPUINFO_FEATURE_VFPV3D16 UINT32_C(0x00004000) /* Also set for VFPv4 with 16 double-precision registers */ +#define PROC_CPUINFO_FEATURE_TLS UINT32_C(0x00008000) +#define PROC_CPUINFO_FEATURE_VFPV4 UINT32_C(0x00010000) +#define PROC_CPUINFO_FEATURE_IDIVA UINT32_C(0x00020000) +#define PROC_CPUINFO_FEATURE_IDIVT UINT32_C(0x00040000) +#define PROC_CPUINFO_FEATURE_IDIV UINT32_C(0x00060000) +#define PROC_CPUINFO_FEATURE_VFPD32 UINT32_C(0x00080000) +#define PROC_CPUINFO_FEATURE_LPAE UINT32_C(0x00100000) +#define PROC_CPUINFO_FEATURE_EVTSTRM UINT32_C(0x00200000) + +#define PROC_CPUINFO_FEATURE2_AES UINT32_C(0x00000001) +#define PROC_CPUINFO_FEATURE2_PMULL UINT32_C(0x00000002) +#define PROC_CPUINFO_FEATURE2_SHA1 UINT32_C(0x00000004) +#define PROC_CPUINFO_FEATURE2_SHA2 UINT32_C(0x00000008) +#define PROC_CPUINFO_FEATURE2_CRC32 UINT32_C(0x00000010) + + +#define PROC_CPUINFO_VALID_ARCHITECTURE UINT32_C(0x00000001) +#define PROC_CPUINFO_VALID_IMPLEMENTER UINT32_C(0x00000002) +#define PROC_CPUINFO_VALID_VARIANT UINT32_C(0x00000004) +#define PROC_CPUINFO_VALID_PART UINT32_C(0x00000008) +#define PROC_CPUINFO_VALID_REVISION UINT32_C(0x00000010) +#define PROC_CPUINFO_VALID_FEATURES UINT32_C(0x00000020) +#define PROC_CPUINFO_VALID_ICACHE_SIZE UINT32_C(0x00000100) +#define PROC_CPUINFO_VALID_ICACHE_SETS UINT32_C(0x00000200) +#define PROC_CPUINFO_VALID_ICACHE_WAYS UINT32_C(0x00000400) +#define PROC_CPUINFO_VALID_ICACHE_LINE UINT32_C(0x00000800) +#define PROC_CPUINFO_VALID_DCACHE_SIZE UINT32_C(0x00001000) +#define PROC_CPUINFO_VALID_DCACHE_SETS UINT32_C(0x00002000) +#define PROC_CPUINFO_VALID_DCACHE_WAYS UINT32_C(0x00004000) +#define PROC_CPUINFO_VALID_DCACHE_LINE UINT32_C(0x00008000) + +#define PROC_CPUINFO_VALID_INFO UINT32_C(0x0000003F) +#define PROC_CPUINFO_VALID_ICACHE UINT32_C(0x00000F00) +#define PROC_CPUINFO_VALID_DCACHE UINT32_C(0x0000F000) +#define PROC_CPUINFO_VALID_CACHE_LINE UINT32_C(0x00008800) + +struct proc_cpuinfo { + struct proc_cpuinfo_arch architecture; + struct proc_cpuinfo_cache cache; + uint32_t features; + uint32_t features2; + uint32_t processor_number; + uint32_t cpuid; + uint32_t implementer; + uint32_t variant; + uint32_t part; + uint32_t revision; + uint32_t valid_mask; +}; + +struct proc_cpuinfo* cpuinfo_arm_linux_parse_proc_cpuinfo( + const char* filename, + uint32_t processors_count[restrict static 1]); + +void cpuinfo_arm_linux_decode_isa_from_proc_cpuinfo( + const struct proc_cpuinfo proc_cpuinfo[restrict static 1], + uint32_t proc_cpuinfo_count, + struct cpuinfo_arm_isa isa[restrict static 1]); |