@@ -70,68 +70,33 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7070/* or implied, of The University of Texas at Austin. */
7171/*********************************************************************/
7272
73- #define CPU_UNKNOWN 0
74- #define CPU_SICORTEX 1
75- #define CPU_LOONGSON3A 2
76- #define CPU_LOONGSON3B 3
77- #define CPU_I6400 4
78- #define CPU_P6600 5
79- #define CPU_I6500 6
73+ #define CPU_UNKNOWN 0
74+ #define CPU_SICORTEX 1
75+ #define CPU_LOONGSON3R3 2
76+ #define CPU_LOONGSON3R4 3
77+ #define CPU_I6400 4
78+ #define CPU_P6600 5
79+ #define CPU_I6500 6
8080
8181static char * cpuname [] = {
8282 "UNKNOWN" ,
8383 "SICORTEX" ,
84- "LOONGSON3A " ,
85- "LOONGSON3B " ,
84+ "LOONGSON3R3 " ,
85+ "LOONGSON3R4 " ,
8686 "I6400" ,
8787 "P6600" ,
8888 "I6500"
8989};
9090
9191int detect (void ){
9292
93- #ifdef __linux
93+ #ifdef linux
9494 FILE * infile ;
9595 char buffer [512 ], * p ;
9696
9797 p = (char * )NULL ;
98- infile = fopen ("/proc/cpuinfo" , "r" );
99- while (fgets (buffer , sizeof (buffer ), infile )){
100- if (!strncmp ("cpu" , buffer , 3 )){
101- p = strchr (buffer , ':' ) + 2 ;
102- #if 0
103- fprintf (stderr , "%s\n" , p );
104- #endif
105- break ;
106- }
107- }
108-
109- fclose (infile );
110-
111- if (p != NULL ){
112- if (strstr (p , "Loongson-3A" )){
113- return CPU_LOONGSON3A ;
114- }else if (strstr (p , "Loongson-3B" )){
115- return CPU_LOONGSON3B ;
116- }else if (strstr (p , "Loongson-3" )){
117- infile = fopen ("/proc/cpuinfo" , "r" );
118- p = (char * )NULL ;
119- while (fgets (buffer , sizeof (buffer ), infile )){
120- if (!strncmp ("system type" , buffer , 11 )){
121- p = strchr (buffer , ':' ) + 2 ;
122- break ;
123- }
124- }
125- fclose (infile );
126- if (strstr (p , "loongson3a" ))
127- return CPU_LOONGSON3A ;
128- }else {
129- return CPU_SICORTEX ;
130- }
131- }
13298 //Check model name for Loongson3
13399 infile = fopen ("/proc/cpuinfo" , "r" );
134- p = (char * )NULL ;
135100 while (fgets (buffer , sizeof (buffer ), infile )){
136101 if (!strncmp ("model name" , buffer , 10 )){
137102 p = strchr (buffer , ':' ) + 2 ;
@@ -140,14 +105,16 @@ int detect(void){
140105 }
141106 fclose (infile );
142107 if (p != NULL ){
143- if (strstr (p , "Loongson-3A" )){
144- return CPU_LOONGSON3A ;
145- }else if (strstr (p , "Loongson-3B" )){
146- return CPU_LOONGSON3B ;
147- }
108+ if (strstr (p , "Loongson-3A3000" ) || strstr (p , "Loongson-3B3000" )){
109+ return CPU_LOONGSON3R3 ;
110+ }else if (strstr (p , "Loongson-3A4000" ) || strstr (p , "Loongson-3B4000" )){
111+ return CPU_LOONGSON3R4 ;
112+ } else {
113+ return CPU_SICORTEX ;
148114 }
149115#endif
150116 return CPU_UNKNOWN ;
117+ }
151118}
152119
153120char * get_corename (void ){
@@ -159,10 +126,10 @@ void get_architecture(void){
159126}
160127
161128void get_subarchitecture (void ){
162- if (detect ()== CPU_LOONGSON3A ) {
163- printf ("LOONGSON3A " );
164- }else if (detect ()== CPU_LOONGSON3B ){
165- printf ("LOONGSON3B " );
129+ if (detect ()== CPU_LOONGSON3R3 ) {
130+ printf ("LOONGSON3R3 " );
131+ }else if (detect ()== CPU_LOONGSON3R4 ){
132+ printf ("LOONGSON3R4 " );
166133 }else if (detect ()== CPU_I6400 ){
167134 printf ("I6400" );
168135 }else if (detect ()== CPU_P6600 ){
@@ -179,17 +146,17 @@ void get_subdirname(void){
179146}
180147
181148void get_cpuconfig (void ){
182- if (detect ()== CPU_LOONGSON3A ) {
183- printf ("#define LOONGSON3A \n" );
149+ if (detect ()== CPU_LOONGSON3R3 ) {
150+ printf ("#define LOONGSON3R3 \n" );
184151 printf ("#define L1_DATA_SIZE 65536\n" );
185152 printf ("#define L1_DATA_LINESIZE 32\n" );
186153 printf ("#define L2_SIZE 512488\n" );
187154 printf ("#define L2_LINESIZE 32\n" );
188155 printf ("#define DTB_DEFAULT_ENTRIES 64\n" );
189156 printf ("#define DTB_SIZE 4096\n" );
190157 printf ("#define L2_ASSOCIATIVE 4\n" );
191- }else if (detect ()== CPU_LOONGSON3B ){
192- printf ("#define LOONGSON3B \n" );
158+ }else if (detect ()== CPU_LOONGSON3R4 ){
159+ printf ("#define LOONGSON3R4 \n" );
193160 printf ("#define L1_DATA_SIZE 65536\n" );
194161 printf ("#define L1_DATA_LINESIZE 32\n" );
195162 printf ("#define L2_SIZE 512488\n" );
@@ -237,10 +204,10 @@ void get_cpuconfig(void){
237204}
238205
239206void get_libname (void ){
240- if (detect ()== CPU_LOONGSON3A ) {
241- printf ("loongson3a \n" );
242- }else if (detect ()== CPU_LOONGSON3B ) {
243- printf ("loongson3b \n" );
207+ if (detect ()== CPU_LOONGSON3R3 ) {
208+ printf ("loongson3r3 \n" );
209+ }else if (detect ()== CPU_LOONGSON3R4 ) {
210+ printf ("loongson3r4 \n" );
244211 }else if (detect ()== CPU_I6400 ) {
245212 printf ("i6400\n" );
246213 }else if (detect ()== CPU_P6600 ) {
0 commit comments