Skip to content

Commit c78cbf4

Browse files
committed
Support for MIPSsim, the cycle accurate MIPS simulator.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent b288f13 commit c78cbf4

17 files changed

Lines changed: 1229 additions & 1 deletion

File tree

‎arch/mips/Kconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,17 @@ config MOMENCO_OCELOT_3
448448
The Ocelot-3 is based off Discovery III System Controller and
449449
PMC-Sierra Rm79000 core.
450450

451+
config MIPS_SIM
452+
bool 'Support for MIPS simulator (MIPSsim)'
453+
select DMA_NONCOHERENT
454+
select IRQ_CPU
455+
select SYS_SUPPORTS_32BIT_KERNEL
456+
select SYS_SUPPORTS_BIG_ENDIAN
457+
select SYS_SUPPORTS_LITTLE_ENDIAN
458+
help
459+
This option enables support for MIPS Technologies MIPSsim software
460+
emulator.
461+
451462
config MOMENCO_JAGUAR_ATX
452463
bool "Support for Momentum Jaguar board"
453464
select BOOT_ELF32

‎arch/mips/Makefile‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,13 @@ load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000
436436
core-$(CONFIG_MIPS_SEAD) += arch/mips/mips-boards/sead/
437437
load-$(CONFIG_MIPS_SEAD) += 0xffffffff80100000
438438

439+
#
440+
# MIPS SIM
441+
#
442+
core-$(CONFIG_MIPS_SIM) += arch/mips/mips-boards/sim/
443+
cflags-$(CONFIG_MIPS_SIM) += -Iinclude/asm-mips/mach-sim
444+
load-$(CONFIG_MIPS_SIM) += 0x80100000
445+
439446
#
440447
# Momentum Ocelot board
441448
#

‎arch/mips/kernel/head.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
EXPORT(stext) # used for profiling
117117
EXPORT(_stext)
118118

119-
#ifdef CONFIG_QEMU
119+
#if defined(CONFIG_QEMU) || defined(CONFIG_MIPS_SIM)
120120
/*
121121
* Give us a fighting chance of running if execution beings at the
122122
* kernel load address. This is needed because this platform does

‎arch/mips/mips-boards/sim/Makefile‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
3+
#
4+
# This program is free software; you can distribute it and/or modify it
5+
# under the terms of the GNU General Public License (Version 2) as
6+
# published by the Free Software Foundation.
7+
#
8+
# This program is distributed in the hope it will be useful, but WITHOUT
9+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11+
# for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License along
14+
# with this program; if not, write to the Free Software Foundation, Inc.,
15+
# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16+
#
17+
18+
obj-y := sim_setup.o sim_mem.o sim_time.o sim_printf.o sim_int.o sim_irq.o \
19+
sim_cmdline.o
20+
obj-$(CONFIG_SMP) += sim_smp.o
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Carsten Langgaard, carstenl@mips.com
3+
* Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4+
*
5+
* This program is free software; you can distribute it and/or modify it
6+
* under the terms of the GNU General Public License (Version 2) as
7+
* published by the Free Software Foundation.
8+
*
9+
* This program is distributed in the hope it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along
15+
* with this program; if not, write to the Free Software Foundation, Inc.,
16+
* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17+
*
18+
* Kernel command line creation using the prom monitor (YAMON) argc/argv.
19+
*/
20+
#include <linux/init.h>
21+
#include <linux/string.h>
22+
23+
#include <asm/bootinfo.h>
24+
25+
extern int prom_argc;
26+
extern int *_prom_argv;
27+
28+
/*
29+
* YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer.
30+
* This macro take care of sign extension.
31+
*/
32+
#define prom_argv(index) ((char *)(((int *)(int)_prom_argv)[(index)]))
33+
34+
char arcs_cmdline[CL_SIZE];
35+
36+
char * __init prom_getcmdline(void)
37+
{
38+
return &(arcs_cmdline[0]);
39+
}
40+
41+
42+
void __init prom_init_cmdline(void)
43+
{
44+
char *cp;
45+
int actr;
46+
47+
actr = 1; /* Always ignore argv[0] */
48+
49+
cp = &(arcs_cmdline[0]);
50+
while(actr < prom_argc) {
51+
strcpy(cp, prom_argv(actr));
52+
cp += strlen(prom_argv(actr));
53+
*cp++ = ' ';
54+
actr++;
55+
}
56+
if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
57+
--cp;
58+
*cp = '\0';
59+
}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/*
2+
* Carsten Langgaard, carstenl@mips.com
3+
* Copyright (C) 1999, 2000 MIPS Technologies, Inc. All rights reserved.
4+
*
5+
* This program is free software; you can distribute it and/or modify it
6+
* under the terms of the GNU General Public License (Version 2) as
7+
* published by the Free Software Foundation.
8+
*
9+
* This program is distributed in the hope it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along
15+
* with this program; if not, write to the Free Software Foundation, Inc.,
16+
* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17+
*
18+
* Interrupt exception dispatch code.
19+
*/
20+
#include <linux/config.h>
21+
22+
#include <asm/asm.h>
23+
#include <asm/mipsregs.h>
24+
#include <asm/regdef.h>
25+
#include <asm/stackframe.h>
26+
27+
/* A lot of complication here is taken away because:
28+
*
29+
* 1) We handle one interrupt and return, sitting in a loop and moving across
30+
* all the pending IRQ bits in the cause register is _NOT_ the answer, the
31+
* common case is one pending IRQ so optimize in that direction.
32+
*
33+
* 2) We need not check against bits in the status register IRQ mask, that
34+
* would make this routine slow as hell.
35+
*
36+
* 3) Linux only thinks in terms of all IRQs on or all IRQs off, nothing in
37+
* between like BSD spl() brain-damage.
38+
*
39+
* Furthermore, the IRQs on the MIPS board look basically (barring software
40+
* IRQs which we don't use at all and all external interrupt sources are
41+
* combined together on hardware interrupt 0 (MIPS IRQ 2)) like:
42+
*
43+
* MIPS IRQ Source
44+
* -------- ------
45+
* 0 Software (ignored)
46+
* 1 Software (ignored)
47+
* 2 Combined hardware interrupt (hw0)
48+
* 3 Hardware (ignored)
49+
* 4 Hardware (ignored)
50+
* 5 Hardware (ignored)
51+
* 6 Hardware (ignored)
52+
* 7 R4k timer (what we use)
53+
*
54+
* Note: On the SEAD board thing are a little bit different.
55+
* Here IRQ 2 (hw0) is wired to the UART0 and IRQ 3 (hw1) is wired
56+
* wired to UART1.
57+
*
58+
* We handle the IRQ according to _our_ priority which is:
59+
*
60+
* Highest ---- R4k Timer
61+
* Lowest ---- Combined hardware interrupt
62+
*
63+
* then we just return, if multiple IRQs are pending then we will just take
64+
* another exception, big deal.
65+
*/
66+
67+
.text
68+
.set noreorder
69+
.set noat
70+
.align 5
71+
NESTED(mipsIRQ, PT_SIZE, sp)
72+
SAVE_ALL
73+
CLI
74+
.set at
75+
76+
mfc0 s0, CP0_CAUSE # get irq bits
77+
mfc0 s1, CP0_STATUS # get irq mask
78+
and s0, s1
79+
80+
/* First we check for r4k counter/timer IRQ. */
81+
andi a0, s0, CAUSEF_IP7
82+
beq a0, zero, 1f
83+
andi a0, s0, CAUSEF_IP2 # delay slot, check hw0 interrupt
84+
85+
/* Wheee, a timer interrupt. */
86+
move a0, sp
87+
jal mips_timer_interrupt
88+
nop
89+
90+
j ret_from_irq
91+
nop
92+
93+
1:
94+
#if defined(CONFIG_MIPS_SEAD)
95+
beq a0, zero, 1f
96+
andi a0, s0, CAUSEF_IP3 # delay slot, check hw1 interrupt
97+
#else
98+
beq a0, zero, 1f # delay slot, check hw3 interrupt
99+
andi a0, s0, CAUSEF_IP5
100+
#endif
101+
102+
/* Wheee, combined hardware level zero interrupt. */
103+
#if defined(CONFIG_MIPS_ATLAS)
104+
jal atlas_hw0_irqdispatch
105+
#elif defined(CONFIG_MIPS_MALTA)
106+
jal malta_hw0_irqdispatch
107+
#elif defined(CONFIG_MIPS_SEAD)
108+
jal sead_hw0_irqdispatch
109+
#else
110+
#error "MIPS board not supported\n"
111+
#endif
112+
move a0, sp # delay slot
113+
114+
j ret_from_irq
115+
nop # delay slot
116+
117+
1:
118+
#if defined(CONFIG_MIPS_SEAD)
119+
beq a0, zero, 1f
120+
andi a0, s0, CAUSEF_IP5 # delay slot, check hw3 interrupt
121+
jal sead_hw1_irqdispatch
122+
move a0, sp # delay slot
123+
j ret_from_irq
124+
nop # delay slot
125+
1:
126+
#endif
127+
#if defined(CONFIG_MIPS_MALTA)
128+
beq a0, zero, 1f # check hw3 (coreHI) interrupt
129+
nop
130+
jal corehi_irqdispatch
131+
move a0, sp
132+
j ret_from_irq
133+
nop
134+
1:
135+
#endif
136+
/*
137+
* Here by mistake? This is possible, what can happen is that by the
138+
* time we take the exception the IRQ pin goes low, so just leave if
139+
* this is the case.
140+
*/
141+
move a1,s0
142+
PRINT("Got interrupt: c0_cause = %08x\n")
143+
mfc0 a1, CP0_EPC
144+
PRINT("c0_epc = %08x\n")
145+
146+
j ret_from_irq
147+
nop
148+
END(mipsIRQ)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
3+
*
4+
* This program is free software; you can distribute it and/or modify it
5+
* under the terms of the GNU General Public License (Version 2) as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope it will be useful, but WITHOUT
9+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11+
* for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License along
14+
* with this program; if not, write to the Free Software Foundation, Inc.,
15+
* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16+
*
17+
*/
18+
#include <linux/init.h>
19+
#include <linux/string.h>
20+
#include <asm/bootinfo.h>
21+
22+
extern char arcs_cmdline[];
23+
24+
char * __init prom_getcmdline(void)
25+
{
26+
return arcs_cmdline;
27+
}
28+
29+
30+
void __init prom_init_cmdline(void)
31+
{
32+
/* nothing to do */
33+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (C) 1999, 2005 MIPS Technologies, Inc. All rights reserved.
3+
*
4+
* This program is free software; you can distribute it and/or modify it
5+
* under the terms of the GNU General Public License (Version 2) as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope it will be useful, but WITHOUT
9+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11+
* for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License along
14+
* with this program; if not, write to the Free Software Foundation, Inc.,
15+
* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16+
*
17+
*/
18+
#include <linux/init.h>
19+
#include <linux/sched.h>
20+
#include <linux/slab.h>
21+
#include <linux/interrupt.h>
22+
#include <linux/kernel_stat.h>
23+
#include <asm/mips-boards/simint.h>
24+
25+
26+
extern void mips_cpu_irq_init(int);
27+
28+
extern asmlinkage void simIRQ(void);
29+
30+
asmlinkage void sim_hw0_irqdispatch(struct pt_regs *regs)
31+
{
32+
do_IRQ(2, regs);
33+
}
34+
35+
void __init arch_init_irq(void)
36+
{
37+
/* Now safe to set the exception vector. */
38+
set_except_vector(0, simIRQ);
39+
40+
mips_cpu_irq_init(MIPSCPU_INT_BASE);
41+
}

0 commit comments

Comments
 (0)