1 #ifndef __UDEV__
2 #define __UDEV__
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <stdint.h>
7 #include <string.h>
8 #include <stdbool.h>
9 #include <unistd.h>
10 #include <fcntl.h>
11 #include <errno.h>
12 
13 #include "cpu.h"
14 
15 #define _PATH_SYS_SYSTEM        "/sys/devices/system"
16 #define _PATH_SYS_CPU           "/cpu"
17 #define _PATH_FREQUENCY         "/cpufreq"
18 #define _PATH_FREQUENCY_MAX     "/cpuinfo_max_freq"
19 #define _PATH_FREQUENCY_MIN     "/cpuinfo_min_freq"
20 #define _PATH_CACHE_L1D         "/cache/index0"
21 #define _PATH_CACHE_L1I         "/cache/index1"
22 #define _PATH_CACHE_L2          "/cache/index2"
23 #define _PATH_CACHE_L3          "/cache/index3"
24 #define _PATH_CACHE_SIZE        "/size"
25 #define _PATH_CACHE_SHARED_MAP  "/shared_cpu_map"
26 
27 #define _PATH_FREQUENCY_MAX_LEN 100
28 #define _PATH_CACHE_MAX_LEN     200
29 #define DEFAULT_FILE_SIZE       4096
30 
31 char* read_file(char* path, int* len);
32 long get_max_freq_from_file(uint32_t core);
33 long get_min_freq_from_file(uint32_t core);
34 long get_l1i_cache_size(uint32_t core);
35 long get_l1d_cache_size(uint32_t core);
36 long get_l2_cache_size(uint32_t core);
37 long get_l3_cache_size(uint32_t core);
38 int get_num_caches_by_level(struct cpuInfo* cpu, uint32_t level);
39 
40 #endif
41