3030#define CPU_UNKNOWN 0
3131#define CPU_ARMV6 1
3232#define CPU_ARMV7 2
33- #define CPU_CORTEXA15 3
33+ #define CPU_CORTEXA9 3
34+ #define CPU_CORTEXA15 4
3435
3536static char * cpuname [] = {
3637 "UNKOWN" ,
3738 "ARMV6" ,
3839 "ARMV7" ,
40+ "CORTEXA9" ,
3941 "CORTEXA15"
4042};
4143
4244
45+ static char * cpuname_lower [] = {
46+ "unknown" ,
47+ "armv6" ,
48+ "armv7" ,
49+ "cortexa9" ,
50+ "cortexa15"
51+ };
52+
53+
4354int get_feature (char * search )
4455{
4556
@@ -85,6 +96,29 @@ int detect(void)
8596 char buffer [512 ], * p ;
8697 p = (char * ) NULL ;
8798
99+ infile = fopen ("/proc/cpuinfo" , "r" );
100+ while (fgets (buffer , sizeof (buffer ), infile ))
101+ {
102+
103+ if (!strncmp ("CPU part" , buffer , 8 ))
104+ {
105+ p = strchr (buffer , ':' ) + 2 ;
106+ break ;
107+ }
108+ }
109+
110+ fclose (infile );
111+ if (p != NULL ) {
112+ if (strstr (p , "0xc09" )) {
113+ return CPU_CORTEXA9 ;
114+ }
115+ if (strstr (p , "0xc15" )) {
116+ return CPU_CORTEXA15 ;
117+ }
118+
119+ }
120+
121+ p = (char * ) NULL ;
88122 infile = fopen ("/proc/cpuinfo" , "r" );
89123
90124 while (fgets (buffer , sizeof (buffer ), infile ))
@@ -142,21 +176,7 @@ void get_architecture(void)
142176void get_subarchitecture (void )
143177{
144178 int d = detect ();
145- switch (d )
146- {
147-
148- case CPU_ARMV7 :
149- printf ("ARMV7" );
150- break ;
151-
152- case CPU_ARMV6 :
153- printf ("ARMV6" );
154- break ;
155-
156- default :
157- printf ("UNKNOWN" );
158- break ;
159- }
179+ printf ("%s" , cpuname [d ]);
160180}
161181
162182void get_subdirname (void )
@@ -170,6 +190,36 @@ void get_cpuconfig(void)
170190 int d = detect ();
171191 switch (d )
172192 {
193+ case CPU_CORTEXA9 :
194+ printf ("#define CORTEXA9\n" );
195+ printf ("#define HAVE_VFP\n" );
196+ printf ("#define HAVE_VFPV3\n" );
197+ if ( get_feature ("neon" )) printf ("#define HAVE_NEON\n" );
198+ if ( get_feature ("vfpv4" )) printf ("#define HAVE_VFPV4\n" );
199+ printf ("#define L1_DATA_SIZE 32768\n" );
200+ printf ("#define L1_DATA_LINESIZE 32\n" );
201+ printf ("#define L2_SIZE 1048576\n" );
202+ printf ("#define L2_LINESIZE 32\n" );
203+ printf ("#define DTB_DEFAULT_ENTRIES 128\n" );
204+ printf ("#define DTB_SIZE 4096\n" );
205+ printf ("#define L2_ASSOCIATIVE 4\n" );
206+ break ;
207+
208+ case CPU_CORTEXA15 :
209+ printf ("#define CORTEXA15\n" );
210+ printf ("#define HAVE_VFP\n" );
211+ printf ("#define HAVE_VFPV3\n" );
212+ if ( get_feature ("neon" )) printf ("#define HAVE_NEON\n" );
213+ if ( get_feature ("vfpv4" )) printf ("#define HAVE_VFPV4\n" );
214+ printf ("#define L1_DATA_SIZE 32768\n" );
215+ printf ("#define L1_DATA_LINESIZE 32\n" );
216+ printf ("#define L2_SIZE 1048576\n" );
217+ printf ("#define L2_LINESIZE 32\n" );
218+ printf ("#define DTB_DEFAULT_ENTRIES 128\n" );
219+ printf ("#define DTB_SIZE 4096\n" );
220+ printf ("#define L2_ASSOCIATIVE 4\n" );
221+ break ;
222+
173223
174224 case CPU_ARMV7 :
175225 printf ("#define ARMV7\n" );
@@ -206,18 +256,7 @@ void get_libname(void)
206256{
207257
208258 int d = detect ();
209- switch (d )
210- {
211-
212- case CPU_ARMV7 :
213- printf ("armv7\n" );
214- break ;
215-
216- case CPU_ARMV6 :
217- printf ("armv6\n" );
218- break ;
219-
220- }
259+ printf ("%s" , cpuname_lower [d ]);
221260}
222261
223262
0 commit comments