2929
3030#define CPU_UNKNOWN 0
3131#define CPU_ARMV8 1
32+ #define CPU_CORTEXA57 2
3233
3334static char * cpuname [] = {
34- "UNKOWN" ,
35- "ARMV8"
35+ "UNKNOWN" ,
36+ "ARMV8" ,
37+ "CORTEXA57"
3638};
3739
40+ static char * cpuname_lower [] = {
41+ "unknown" ,
42+ "armv8" ,
43+ "cortexa57"
44+ };
3845
3946int get_feature (char * search )
4047{
@@ -53,13 +60,13 @@ int get_feature(char *search)
5360 {
5461 p = strchr (buffer , ':' ) + 2 ;
5562 break ;
56- }
57- }
63+ }
64+ }
5865
59- fclose (infile );
66+ fclose (infile );
6067
6168
62- if ( p == NULL ) return ;
69+ if ( p == NULL ) return 0 ;
6370
6471 t = strtok (p ," " );
6572 while ( t = strtok (NULL ," " ))
@@ -82,11 +89,30 @@ int detect(void)
8289 p = (char * ) NULL ;
8390
8491 infile = fopen ("/proc/cpuinfo" , "r" );
92+ while (fgets (buffer , sizeof (buffer ), infile ))
93+ {
8594
95+ if (!strncmp ("CPU part" , buffer , 8 ))
96+ {
97+ p = strchr (buffer , ':' ) + 2 ;
98+ break ;
99+ }
100+ }
101+
102+ fclose (infile );
103+ if (p != NULL ) {
104+ if (strstr (p , "0xd07" )) {
105+ return CPU_CORTEXA57 ;
106+ }
107+ }
108+
109+ p = (char * ) NULL ;
110+ infile = fopen ("/proc/cpuinfo" , "r" );
86111 while (fgets (buffer , sizeof (buffer ), infile ))
87112 {
88113
89- if ((!strncmp ("model name" , buffer , 10 )) || (!strncmp ("Processor" , buffer , 9 )))
114+ if ((!strncmp ("model name" , buffer , 10 )) || (!strncmp ("Processor" , buffer , 9 )) ||
115+ (!strncmp ("CPU architecture" , buffer , 16 )))
90116 {
91117 p = strchr (buffer , ':' ) + 2 ;
92118 break ;
@@ -100,7 +126,7 @@ int detect(void)
100126
101127 if (strstr (p , "AArch64" ))
102128 {
103- return CPU_ARMV8 ;
129+ return CPU_ARMV8 ;
104130
105131 }
106132
@@ -118,23 +144,13 @@ char *get_corename(void)
118144
119145void get_architecture (void )
120146{
121- printf ("ARM " );
147+ printf ("ARM64 " );
122148}
123149
124150void get_subarchitecture (void )
125151{
126152 int d = detect ();
127- switch (d )
128- {
129-
130- case CPU_ARMV8 :
131- printf ("ARMV8" );
132- break ;
133-
134- default :
135- printf ("UNKNOWN" );
136- break ;
137- }
153+ printf ("%s" , cpuname [d ]);
138154}
139155
140156void get_subdirname (void )
@@ -160,26 +176,32 @@ void get_cpuconfig(void)
160176 printf ("#define L2_ASSOCIATIVE 4\n" );
161177 break ;
162178
163-
179+ case CPU_CORTEXA57 :
180+ printf ("#define CORTEXA57\n" );
181+ printf ("#define HAVE_VFP\n" );
182+ printf ("#define HAVE_VFPV3\n" );
183+ printf ("#define HAVE_NEON\n" );
184+ printf ("#define HAVE_VFPV4\n" );
185+ printf ("#define L1_CODE_SIZE 49152\n" );
186+ printf ("#define L1_CODE_LINESIZE 64\n" );
187+ printf ("#define L1_CODE_ASSOCIATIVE 3\n" );
188+ printf ("#define L1_DATA_SIZE 32768\n" );
189+ printf ("#define L1_DATA_LINESIZE 64\n" );
190+ printf ("#define L1_DATA_ASSOCIATIVE 2\n" );
191+ printf ("#define L2_SIZE 2097152\n" );
192+ printf ("#define L2_LINESIZE 64\n" );
193+ printf ("#define L2_ASSOCIATIVE 16\n" );
194+ break ;
164195 }
165196}
166197
167198
168199void get_libname (void )
169200{
170-
171201 int d = detect ();
172- switch (d )
173- {
174-
175- case CPU_ARMV8 :
176- printf ("armv8\n" );
177- break ;
178-
179- }
202+ printf ("%s" , cpuname_lower [d ]);
180203}
181204
182-
183205void get_features (void )
184206{
185207
0 commit comments