Skip to content

Commit dbafe63

Browse files
authored
Merge pull request #1543 from martin-frbg/mips32
Fix MIPS32 build and add MIPS 1004K cpu (MT7621 SOC)
2 parents 88e224f + 7105125 commit dbafe63

File tree

7 files changed

+38
-41
lines changed

7 files changed

+38
-41
lines changed

Makefile.prebuild

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ ifdef CPUIDEMU
1717
EXFLAGS = -DCPUIDEMU -DVENDOR=99
1818
endif
1919

20+
ifeq ($(TARGET), 1004K)
21+
TARGET_FLAGS = -mips32r2
22+
endif
23+
2024
ifeq ($(TARGET), P5600)
2125
TARGET_FLAGS = -mips32r5
2226
endif

Makefile.system

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,14 @@ CCOMMON_OPT += -march=mips64
564564
FCOMMON_OPT += -march=mips64
565565
endif
566566

567+
ifeq ($(CORE), 1004K)
568+
CCOMMON_OPT += -mips32r2 $(MSA_FLAGS)
569+
FCOMMON_OPT += -mips32r2 $(MSA_FLAGS)
570+
endif
571+
567572
ifeq ($(CORE), P5600)
568-
CCOMMON_OPT += -mips32r5 -mnan=2008 -mtune=p5600 $(MSA_FLAGS)
569-
FCOMMON_OPT += -mips32r5 -mnan=2008 -mtune=p5600 $(MSA_FLAGS)
573+
CCOMMON_OPT += -mips32r5 -mnan=2008 -mtune=p5600 $(MSA_FLAGS)
574+
FCOMMON_OPT += -mips32r5 -mnan=2008 -mtune=p5600 $(MSA_FLAGS)
570575
endif
571576

572577
ifeq ($(CORE), I6400)

TargetList.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ CELL
5656

5757
3.MIPS CPU:
5858
P5600
59+
1004K
5960

6061
4.MIPS64 CPU:
6162
SICORTEX

cpuid_mips.c

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7272

7373
#define CPU_UNKNOWN 0
7474
#define CPU_P5600 1
75+
#define CPU_1004K 2
7576

7677
static char *cpuname[] = {
7778
"UNKOWN",
78-
"P5600"
79+
"P5600",
80+
"1004K"
7981
};
8082

8183
int detect(void){
@@ -90,7 +92,7 @@ int detect(void){
9092
if (!strncmp("cpu", buffer, 3)){
9193
p = strchr(buffer, ':') + 2;
9294
#if 0
93-
fprintf(stderr, "%s\n", p);
95+
fprintf(stderr, "%s \n", p);
9496
#endif
9597
break;
9698
}
@@ -99,43 +101,13 @@ int detect(void){
99101
fclose(infile);
100102

101103
if(p != NULL){
102-
if (strstr(p, "Loongson-3A")){
103-
return CPU_LOONGSON3A;
104-
}else if(strstr(p, "Loongson-3B")){
105-
return CPU_LOONGSON3B;
106-
}else if (strstr(p, "Loongson-3")){
107-
infile = fopen("/proc/cpuinfo", "r");
108-
p = (char *)NULL;
109-
while (fgets(buffer, sizeof(buffer), infile)){
110-
if (!strncmp("system type", buffer, 11)){
111-
p = strchr(buffer, ':') + 2;
112-
break;
113-
}
114-
}
115-
fclose(infile);
116-
if (strstr(p, "loongson3a"))
117-
return CPU_LOONGSON3A;
118-
}else{
104+
if (strstr(p, "5600")) {
105+
return CPU_P5600;
106+
} else if (strstr(p, "1004K")) {
107+
return CPU_1004K;
108+
} else
119109
return CPU_UNKNOWN;
120110
}
121-
}
122-
//Check model name for Loongson3
123-
infile = fopen("/proc/cpuinfo", "r");
124-
p = (char *)NULL;
125-
while (fgets(buffer, sizeof(buffer), infile)){
126-
if (!strncmp("model name", buffer, 10)){
127-
p = strchr(buffer, ':') + 2;
128-
break;
129-
}
130-
}
131-
fclose(infile);
132-
if(p != NULL){
133-
if (strstr(p, "Loongson-3A")){
134-
return CPU_LOONGSON3A;
135-
}else if(strstr(p, "Loongson-3B")){
136-
return CPU_LOONGSON3B;
137-
}
138-
}
139111
#endif
140112
return CPU_UNKNOWN;
141113
}
@@ -149,7 +121,7 @@ void get_architecture(void){
149121
}
150122

151123
void get_subarchitecture(void){
152-
if(detect()==CPU_P5600){
124+
if(detect()==CPU_P5600|| detect()==CPU_1004K){
153125
printf("P5600");
154126
}else{
155127
printf("UNKNOWN");
@@ -170,6 +142,14 @@ void get_cpuconfig(void){
170142
printf("#define DTB_DEFAULT_ENTRIES 64\n");
171143
printf("#define DTB_SIZE 4096\n");
172144
printf("#define L2_ASSOCIATIVE 8\n");
145+
} else if (detect()==CPU_1004K) {
146+
printf("#define MIPS1004K\n");
147+
printf("#define L1_DATA_SIZE 32768\n");
148+
printf("#define L1_DATA_LINESIZE 32\n");
149+
printf("#define L2_SIZE 26144\n");
150+
printf("#define DTB_DEFAULT_ENTRIES 8\n");
151+
printf("#define DTB_SIZE 4096\n");
152+
printf("#define L2_ASSOCIATIVE 4\n");
173153
}else{
174154
printf("#define UNKNOWN\n");
175155
}
@@ -178,6 +158,8 @@ void get_cpuconfig(void){
178158
void get_libname(void){
179159
if(detect()==CPU_P5600) {
180160
printf("p5600\n");
161+
} else if (detect()==CPU_1004K) {
162+
printf("1004K\n");
181163
}else{
182164
printf("mips\n");
183165
}

kernel/Makefile.L3

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ ifeq ($(ARCH), arm64)
2020
USE_TRMM = 1
2121
endif
2222

23+
ifeq ($(ARCH), mips)
24+
USE_TRMM = 1
25+
endif
26+
2327
ifeq ($(TARGET), LOONGSON3B)
2428
USE_TRMM = 1
2529
endif

kernel/mips/KERNEL.1004K

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include $(KERNELDIR)/KERNEL.P5600

param.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22912291
#define SYMV_P 16
22922292
#endif
22932293

2294-
#if defined(P5600) || defined(I6400) || defined(P6600) || defined(I6500)
2294+
#if defined(P5600) || defined(MIPS1004K) || defined(I6400) || defined(P6600) || defined(I6500)
22952295
#define SNUMOPT 2
22962296
#define DNUMOPT 2
22972297

0 commit comments

Comments
 (0)