aboutsummaryrefslogtreecommitdiff
path: root/src/arm/linux/api.h
blob: 4e13e00b7c20470ae2ea80a37f0544d71a24f024 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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]);