aboutsummaryrefslogtreecommitdiff
path: root/include/odp/api/spec/system_info.h
blob: 5d4e3cb87126ad1e82a6c541ad167692bf7b03d3 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/* Copyright (c) 2013-2018, Linaro Limited
 * Copyright (c) 2020, Nokia
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

/**
 * @file
 *
 * ODP system information
 */

#ifndef ODP_API_SPEC_SYSTEM_INFO_H_
#define ODP_API_SPEC_SYSTEM_INFO_H_
#include <odp/visibility_begin.h>

#ifdef __cplusplus
extern "C" {
#endif

/** @defgroup odp_system ODP SYSTEM
 *  System information.
 *  @{
 */

/**
 * CPU instruction set architecture (ISA) families
 */
typedef enum odp_cpu_arch_t {
	/** Unknown CPU architecture */
	ODP_CPU_ARCH_UNKNOWN = 0,

	/** ARM */
	ODP_CPU_ARCH_ARM,

	/** MIPS */
	ODP_CPU_ARCH_MIPS,

	/** PowerPC */
	ODP_CPU_ARCH_PPC,

	/** RISC-V */
	ODP_CPU_ARCH_RISCV,

	/** x86 */
	ODP_CPU_ARCH_X86

} odp_cpu_arch_t;

/**
 * ARM ISA versions
 *
 * ISA versions are defined in ascending order.
 */
typedef enum odp_cpu_arch_arm_t {
	/** Unknown ARM ISA version */
	ODP_CPU_ARCH_ARM_UNKNOWN = 0,

	/** ARMv6 ISA */
	ODP_CPU_ARCH_ARMV6,

	/** ARMv7-A ISA */
	ODP_CPU_ARCH_ARMV7,

	/** ARMv8.0-A ISA */
	ODP_CPU_ARCH_ARMV8_0,

	/** ARMv8.1-A ISA */
	ODP_CPU_ARCH_ARMV8_1,

	/** ARMv8.2-A ISA */
	ODP_CPU_ARCH_ARMV8_2,

	/** ARMv8.3-A ISA */
	ODP_CPU_ARCH_ARMV8_3,

	/** ARMv8.4-A ISA */
	ODP_CPU_ARCH_ARMV8_4,

	/** ARMv8.5-A ISA */
	ODP_CPU_ARCH_ARMV8_5,

	/** ARMv8.6-A ISA */
	ODP_CPU_ARCH_ARMV8_6,

} odp_cpu_arch_arm_t;

/**
 * MIPS ISA versions
 */
typedef enum odp_cpu_arch_mips_t {
	/** Unknown MIPS ISA version */
	ODP_CPU_ARCH_MIPS_UNKNOWN = 0

} odp_cpu_arch_mips_t;

/**
 * PowerPC ISA versions
 */
typedef enum odp_cpu_arch_ppc_t {
	/** Unknown PPC ISA version */
	ODP_CPU_ARCH_PPC_UNKNOWN = 0

} odp_cpu_arch_ppc_t;

/**
 * RISC-V ISA versions
 */
typedef enum odp_cpu_arch_riscv_t {
	/** Unknown RISC-V ISA version */
	ODP_CPU_ARCH_RISCV_UNKNOWN = 0

} odp_cpu_arch_riscv_t;

/**
 * x86 ISA versions
 */
typedef enum odp_cpu_arch_x86_t {
	/** Unknown x86 ISA version */
	ODP_CPU_ARCH_X86_UNKNOWN = 0,

	/** x86 32bit ISA */
	ODP_CPU_ARCH_X86_I686,

	/** x86 64bit ISA */
	ODP_CPU_ARCH_X86_64

} odp_cpu_arch_x86_t;

/**
 * CPU ISA versions
 */
typedef union odp_cpu_arch_isa_t {
	/** ARM ISA versions */
	odp_cpu_arch_arm_t arm;

	/** MIPS ISA versions */
	odp_cpu_arch_mips_t mips;

	/** PowerPC ISA versions */
	odp_cpu_arch_ppc_t ppc;

	/** RISC-V ISA versions */
	odp_cpu_arch_riscv_t riscv;

	/** x86 ISA versions */
	odp_cpu_arch_x86_t x86;

} odp_cpu_arch_isa_t;

/**
 * System info
 */
typedef struct odp_system_info_t {
	/**
	 * CPU architecture
	 *
	 * Defines CPU ISA family: ARM, MIPS, PPC, RISC-V, x86 or unknown
	 */
	odp_cpu_arch_t cpu_arch;

	/**
	 * ISA version of ODP software
	 *
	 * Defines the ISA version that was used to build the ODP library. Depending on compiler
	 * target architecture setting, the value may be lower than the ISA version supported by
	 * the CPU hardware.
	 */
	odp_cpu_arch_isa_t cpu_isa_sw;

	/**
	 * ISA version of CPU hardware
	 *
	 * Defines the ISA version supported by the CPU hardware. The value is set to
	 * ODP_CPU_ARCH_<arch>_UNKNOWN, when the ISA version cannot be determined.
	 */
	odp_cpu_arch_isa_t cpu_isa_hw;

} odp_system_info_t;

/**
 * Retrieve system information
 *
 * Fills in system information structure on success. The call is not intended
 * for fast path use.
 *
 * @param[out] info    Pointer to system info struct for output
 *
 * @retval  0 on success
 * @retval <0 on failure
 */
int odp_system_info(odp_system_info_t *info);

/**
 * Default system huge page size in bytes
 *
 * @return Default huge page size in bytes
 * @retval 0 on no huge pages
 */
uint64_t odp_sys_huge_page_size(void);

/**
 * System huge page sizes in bytes
 *
 * Returns the number of huge page sizes supported by the system. Outputs up to
 * 'num' sizes when the 'size' array pointer is not NULL. If return value is
 * larger than 'num', there are more supported sizes than the function was
 * allowed to output. If return value (N) is less than 'num', only sizes
 * [0 ... N-1] have been written. Returned values are ordered from smallest to
 * largest.
 *
 * @param[out] size     Points to an array of huge page sizes for output
 * @param      num      Maximum number of huge page sizes to output
 *
 * @return Number of supported huge page sizes
 * @retval <0 on failure
 */
int odp_sys_huge_page_size_all(uint64_t size[], int num);

/**
 * Page size in bytes
 *
 * @return Page size in bytes
 */
uint64_t odp_sys_page_size(void);

/**
 * Cache line size in bytes
 *
 * @return CPU cache line size in bytes
 */
int odp_sys_cache_line_size(void);

/**
 * Print system info
 *
 * Print out implementation defined information about the system. This
 * information is intended for debugging purposes and may contain e.g.
 * information about CPUs, memory and other HW configuration.
 */
void odp_sys_info_print(void);

/**
 * Print configuration
 *
 * Print out implementation defined information about selected configuration options. This
 * information is intended for debugging purposes and may contain e.g. content of various
 * configuration files, environment variables and configuration options of ODP API.
 */
void odp_sys_config_print(void);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#include <odp/visibility_end.h>
#endif