1 #include <string.h>
2 
3 #include <arm/api.h>
4 #include <arm/linux/api.h>
5 #include <arm/android/api.h>
6 
7 
cpuinfo_arm_android_parse_chipset_properties(const char proc_cpuinfo_hardware[CPUINFO_HARDWARE_VALUE_MAX],const char ro_product_board[CPUINFO_BUILD_PROP_VALUE_MAX],const char ro_board_platform[CPUINFO_BUILD_PROP_VALUE_MAX],const char ro_mediatek_platform[CPUINFO_BUILD_PROP_VALUE_MAX],const char ro_arch[CPUINFO_BUILD_PROP_VALUE_MAX],const char ro_chipname[CPUINFO_BUILD_PROP_VALUE_MAX],uint32_t cores,uint32_t max_cpu_freq_max,char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])8 void cpuinfo_arm_android_parse_chipset_properties(
9 	const char proc_cpuinfo_hardware[CPUINFO_HARDWARE_VALUE_MAX],
10 	const char ro_product_board[CPUINFO_BUILD_PROP_VALUE_MAX],
11 	const char ro_board_platform[CPUINFO_BUILD_PROP_VALUE_MAX],
12 	const char ro_mediatek_platform[CPUINFO_BUILD_PROP_VALUE_MAX],
13 	const char ro_arch[CPUINFO_BUILD_PROP_VALUE_MAX],
14 	const char ro_chipname[CPUINFO_BUILD_PROP_VALUE_MAX],
15 	uint32_t cores,
16 	uint32_t max_cpu_freq_max,
17 	char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])
18 {
19 	struct cpuinfo_android_properties properties;
20 	strncpy(properties.proc_cpuinfo_hardware, proc_cpuinfo_hardware, CPUINFO_HARDWARE_VALUE_MAX);
21 	strncpy(properties.ro_product_board, ro_product_board, CPUINFO_BUILD_PROP_VALUE_MAX);
22 	strncpy(properties.ro_board_platform, ro_board_platform, CPUINFO_BUILD_PROP_VALUE_MAX);
23 	strncpy(properties.ro_mediatek_platform, ro_mediatek_platform, CPUINFO_BUILD_PROP_VALUE_MAX);
24 	strncpy(properties.ro_arch, ro_arch, CPUINFO_BUILD_PROP_VALUE_MAX);
25 	strncpy(properties.ro_chipname, ro_chipname, CPUINFO_BUILD_PROP_VALUE_MAX);
26 
27 	struct cpuinfo_arm_chipset chipset =
28 		cpuinfo_arm_android_decode_chipset(&properties, cores, max_cpu_freq_max);
29 	if (chipset.series == cpuinfo_arm_chipset_series_unknown) {
30 		chipset_name[0] = 0;
31 	} else {
32 		cpuinfo_arm_chipset_to_string(&chipset, chipset_name);
33 	}
34 }
35 
cpuinfo_arm_android_parse_proc_cpuinfo_hardware(const char hardware[CPUINFO_HARDWARE_VALUE_MAX],uint32_t cores,uint32_t max_cpu_freq_max,bool is_tegra,char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])36 void cpuinfo_arm_android_parse_proc_cpuinfo_hardware(
37 	const char hardware[CPUINFO_HARDWARE_VALUE_MAX], uint32_t cores, uint32_t max_cpu_freq_max, bool is_tegra,
38 	char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])
39 {
40 	struct cpuinfo_arm_chipset chipset =
41 		cpuinfo_arm_linux_decode_chipset_from_proc_cpuinfo_hardware(hardware, cores, max_cpu_freq_max, is_tegra);
42 	if (chipset.series == cpuinfo_arm_chipset_series_unknown) {
43 		chipset_name[0] = 0;
44 	} else {
45 		cpuinfo_arm_fixup_chipset(&chipset, cores, max_cpu_freq_max);
46 		cpuinfo_arm_chipset_to_string(&chipset, chipset_name);
47 	}
48 }
49 
cpuinfo_arm_android_parse_ro_product_board(const char board[CPUINFO_BUILD_PROP_VALUE_MAX],uint32_t cores,uint32_t max_cpu_freq_max,char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])50 void cpuinfo_arm_android_parse_ro_product_board(
51 	const char board[CPUINFO_BUILD_PROP_VALUE_MAX], uint32_t cores, uint32_t max_cpu_freq_max,
52 	char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])
53 {
54 	struct cpuinfo_arm_chipset chipset =
55 		cpuinfo_arm_android_decode_chipset_from_ro_product_board(board, cores, max_cpu_freq_max);
56 	if (chipset.series == cpuinfo_arm_chipset_series_unknown) {
57 		chipset_name[0] = 0;
58 	} else {
59 		cpuinfo_arm_fixup_chipset(&chipset, cores, max_cpu_freq_max);
60 		cpuinfo_arm_chipset_to_string(&chipset, chipset_name);
61 	}
62 }
63 
cpuinfo_arm_android_parse_ro_board_platform(const char platform[CPUINFO_BUILD_PROP_VALUE_MAX],uint32_t cores,uint32_t max_cpu_freq_max,char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])64 void cpuinfo_arm_android_parse_ro_board_platform(
65 	const char platform[CPUINFO_BUILD_PROP_VALUE_MAX], uint32_t cores, uint32_t max_cpu_freq_max,
66 	char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])
67 {
68 	struct cpuinfo_arm_chipset chipset =
69 		cpuinfo_arm_android_decode_chipset_from_ro_board_platform(platform, cores, max_cpu_freq_max);
70 	if (chipset.series == cpuinfo_arm_chipset_series_unknown) {
71 		chipset_name[0] = 0;
72 	} else {
73 		cpuinfo_arm_fixup_chipset(&chipset, cores, max_cpu_freq_max);
74 		cpuinfo_arm_chipset_to_string(&chipset, chipset_name);
75 	}
76 }
77 
cpuinfo_arm_android_parse_ro_mediatek_platform(const char platform[CPUINFO_BUILD_PROP_VALUE_MAX],uint32_t cores,uint32_t max_cpu_freq_max,char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])78 void cpuinfo_arm_android_parse_ro_mediatek_platform(
79 	const char platform[CPUINFO_BUILD_PROP_VALUE_MAX], uint32_t cores, uint32_t max_cpu_freq_max,
80 	char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])
81 {
82 	struct cpuinfo_arm_chipset chipset = cpuinfo_arm_android_decode_chipset_from_ro_mediatek_platform(platform);
83 	if (chipset.series == cpuinfo_arm_chipset_series_unknown) {
84 		chipset_name[0] = 0;
85 	} else {
86 		cpuinfo_arm_fixup_chipset(&chipset, cores, max_cpu_freq_max);
87 		cpuinfo_arm_chipset_to_string(&chipset, chipset_name);
88 	}
89 }
90 
cpuinfo_arm_android_parse_ro_arch(const char arch[CPUINFO_BUILD_PROP_VALUE_MAX],uint32_t cores,uint32_t max_cpu_freq_max,char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])91 void cpuinfo_arm_android_parse_ro_arch(
92 	const char arch[CPUINFO_BUILD_PROP_VALUE_MAX], uint32_t cores, uint32_t max_cpu_freq_max,
93 	char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])
94 {
95 	struct cpuinfo_arm_chipset chipset = cpuinfo_arm_android_decode_chipset_from_ro_arch(arch);
96 	if (chipset.series == cpuinfo_arm_chipset_series_unknown) {
97 		chipset_name[0] = 0;
98 	} else {
99 		cpuinfo_arm_fixup_chipset(&chipset, cores, max_cpu_freq_max);
100 		cpuinfo_arm_chipset_to_string(&chipset, chipset_name);
101 	}
102 }
103 
cpuinfo_arm_android_parse_ro_chipname(const char chipname[CPUINFO_BUILD_PROP_VALUE_MAX],uint32_t cores,uint32_t max_cpu_freq_max,char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])104 void cpuinfo_arm_android_parse_ro_chipname(
105 	const char chipname[CPUINFO_BUILD_PROP_VALUE_MAX], uint32_t cores, uint32_t max_cpu_freq_max,
106 	char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX])
107 {
108 	struct cpuinfo_arm_chipset chipset = cpuinfo_arm_android_decode_chipset_from_ro_chipname(chipname);
109 	if (chipset.series == cpuinfo_arm_chipset_series_unknown) {
110 		chipset_name[0] = 0;
111 	} else {
112 		cpuinfo_arm_fixup_chipset(&chipset, cores, max_cpu_freq_max);
113 		cpuinfo_arm_chipset_to_string(&chipset, chipset_name);
114 	}
115 }
116