• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #pragma once
2 
3 #include <stdbool.h>
4 #include <stdint.h>
5 #include <stddef.h>
6 
7 #include <cpuinfo.h>
8 #include <cpuinfo/common.h>
9 
10 
11 #define CPUINFO_LINUX_FLAG_PRESENT            UINT32_C(0x00000001)
12 #define CPUINFO_LINUX_FLAG_POSSIBLE           UINT32_C(0x00000002)
13 #define CPUINFO_LINUX_FLAG_MAX_FREQUENCY      UINT32_C(0x00000004)
14 #define CPUINFO_LINUX_FLAG_MIN_FREQUENCY      UINT32_C(0x00000008)
15 #define CPUINFO_LINUX_FLAG_SMT_ID             UINT32_C(0x00000010)
16 #define CPUINFO_LINUX_FLAG_CORE_ID            UINT32_C(0x00000020)
17 #define CPUINFO_LINUX_FLAG_PACKAGE_ID         UINT32_C(0x00000040)
18 #define CPUINFO_LINUX_FLAG_APIC_ID            UINT32_C(0x00000080)
19 #define CPUINFO_LINUX_FLAG_SMT_CLUSTER        UINT32_C(0x00000100)
20 #define CPUINFO_LINUX_FLAG_CORE_CLUSTER       UINT32_C(0x00000200)
21 #define CPUINFO_LINUX_FLAG_PACKAGE_CLUSTER    UINT32_C(0x00000400)
22 #define CPUINFO_LINUX_FLAG_PROC_CPUINFO       UINT32_C(0x00000800)
23 #define CPUINFO_LINUX_FLAG_VALID              UINT32_C(0x00001000)
24 
25 
26 typedef bool (*cpuinfo_cpulist_callback)(uint32_t, uint32_t, void*);
27 CPUINFO_INTERNAL bool cpuinfo_linux_parse_cpulist(const char* filename, cpuinfo_cpulist_callback callback, void* context);
28 typedef bool (*cpuinfo_smallfile_callback)(const char*, const char*, void*);
29 CPUINFO_INTERNAL bool cpuinfo_linux_parse_small_file(const char* filename, size_t buffer_size, cpuinfo_smallfile_callback, void* context);
30 typedef bool (*cpuinfo_line_callback)(const char*, const char*, void*, uint64_t);
31 CPUINFO_INTERNAL bool cpuinfo_linux_parse_multiline_file(const char* filename, size_t buffer_size, cpuinfo_line_callback, void* context);
32 
33 CPUINFO_INTERNAL uint32_t cpuinfo_linux_get_max_processors_count(void);
34 CPUINFO_INTERNAL uint32_t cpuinfo_linux_get_max_possible_processor(uint32_t max_processors_count);
35 CPUINFO_INTERNAL uint32_t cpuinfo_linux_get_max_present_processor(uint32_t max_processors_count);
36 CPUINFO_INTERNAL uint32_t cpuinfo_linux_get_processor_min_frequency(uint32_t processor);
37 CPUINFO_INTERNAL uint32_t cpuinfo_linux_get_processor_max_frequency(uint32_t processor);
38 CPUINFO_INTERNAL bool cpuinfo_linux_get_processor_package_id(uint32_t processor, uint32_t package_id[restrict static 1]);
39 CPUINFO_INTERNAL bool cpuinfo_linux_get_processor_core_id(uint32_t processor, uint32_t core_id[restrict static 1]);
40 
41 CPUINFO_INTERNAL bool cpuinfo_linux_detect_possible_processors(uint32_t max_processors_count,
42 	uint32_t* processor0_flags, uint32_t processor_struct_size, uint32_t possible_flag);
43 CPUINFO_INTERNAL bool cpuinfo_linux_detect_present_processors(uint32_t max_processors_count,
44 	uint32_t* processor0_flags, uint32_t processor_struct_size, uint32_t present_flag);
45 
46 typedef bool (*cpuinfo_siblings_callback)(uint32_t, uint32_t, uint32_t, void*);
47 CPUINFO_INTERNAL bool cpuinfo_linux_detect_core_siblings(
48 	uint32_t max_processors_count,
49 	uint32_t processor,
50 	cpuinfo_siblings_callback callback,
51 	void* context);
52 CPUINFO_INTERNAL bool cpuinfo_linux_detect_thread_siblings(
53 	uint32_t max_processors_count,
54 	uint32_t processor,
55 	cpuinfo_siblings_callback callback,
56 	void* context);
57 
58 extern CPUINFO_INTERNAL const struct cpuinfo_processor** cpuinfo_linux_cpu_to_processor_map;
59 extern CPUINFO_INTERNAL const struct cpuinfo_core** cpuinfo_linux_cpu_to_core_map;
60