42#ifndef _RTEMS_SCORE_MIPS_H
43#define _RTEMS_SCORE_MIPS_H
67#if (__mips == 3) || (__mips == 32)
69#define SR_INTERRUPT_ENABLE_BITS 0x01
71#define SR_INTERRUPT_ENABLE_BITS SR_IE
75#define SR_INTERRUPT_ENABLE_BITS SR_IEC
78#error "mips interrupt enable bits: unknown architecture level!"
90#if defined(__mips_soft_float)
98#define CPU_MODEL_NAME "ISA Level 1 or 2"
99#elif (__mips == 3) || (__mips == 32)
101#define CPU_MODEL_NAME "ISA Level 4"
103#define CPU_MODEL_NAME "ISA Level 3"
106#error "Unknown MIPS ISA level"
113#define CPU_NAME "MIPS"
120#define MIPS_EXCEPTION_BASE 0
122#define MIPS_EXCEPTION_INT MIPS_EXCEPTION_BASE+0
123#define MIPS_EXCEPTION_MOD MIPS_EXCEPTION_BASE+1
124#define MIPS_EXCEPTION_TLBL MIPS_EXCEPTION_BASE+2
125#define MIPS_EXCEPTION_TLBS MIPS_EXCEPTION_BASE+3
126#define MIPS_EXCEPTION_ADEL MIPS_EXCEPTION_BASE+4
127#define MIPS_EXCEPTION_ADES MIPS_EXCEPTION_BASE+5
128#define MIPS_EXCEPTION_IBE MIPS_EXCEPTION_BASE+6
129#define MIPS_EXCEPTION_DBE MIPS_EXCEPTION_BASE+7
130#define MIPS_EXCEPTION_SYSCALL MIPS_EXCEPTION_BASE+8
131#define MIPS_EXCEPTION_BREAK MIPS_EXCEPTION_BASE+9
132#define MIPS_EXCEPTION_RI MIPS_EXCEPTION_BASE+10
133#define MIPS_EXCEPTION_CPU MIPS_EXCEPTION_BASE+11
134#define MIPS_EXCEPTION_OVERFLOW MIPS_EXCEPTION_BASE+12
135#define MIPS_EXCEPTION_TRAP MIPS_EXCEPTION_BASE+13
136#define MIPS_EXCEPTION_VCEI MIPS_EXCEPTION_BASE+14
138#define MIPS_EXCEPTION_FPE MIPS_EXCEPTION_BASE+15
139#define MIPS_EXCEPTION_C2E MIPS_EXCEPTION_BASE+16
141#define MIPS_EXCEPTION_WATCH MIPS_EXCEPTION_BASE+23
143#define MIPS_EXCEPTION_VCED MIPS_EXCEPTION_BASE+31
145#define MIPS_INTERRUPT_BASE MIPS_EXCEPTION_BASE+32
151#define mips_get_sr( _x ) \
153 __asm__ volatile( "mfc0 %0, $12; nop" : "=r" (_x) : ); \
156#define mips_set_sr( _x ) \
158 unsigned int __x = (_x); \
159 __asm__ volatile( "mtc0 %0, $12; nop" : : "r" (__x) ); \
167#define mips_get_cause( _x ) \
169 __asm__ volatile( "mfc0 %0, $13; nop" : "=r" (_x) : ); \
173#define mips_set_cause( _x ) \
175 unsigned int __x = (_x); \
176 __asm__ volatile( "mtc0 %0, $13; nop" : : "r" (__x) ); \
186#define mips_get_dcic( _x ) \
188 __asm__ volatile( "mfc0 %0, $7; nop" : "=r" (_x) : ); \
192#define mips_set_dcic( _x ) \
194 unsigned int __x = (_x); \
195 __asm__ volatile( "mtc0 %0, $7; nop" : : "r" (__x) ); \
206#define mips_get_bpcrm( _x, _y ) \
208 __asm__ volatile( "mfc0 %0, $3; nop" : "=r" (_x) : ); \
209 __asm__ volatile( "mfc0 %0, $11; nop" : "=r" (_y) : ); \
213#define mips_set_bpcrm( _x, _y ) \
215 unsigned int __x = (_x); \
216 unsigned int __y = (_y); \
217 __asm__ volatile( "mtc0 %0, $11; nop" : : "r" (__y) ); \
218 __asm__ volatile( "mtc0 %0, $3; nop" : : "r" (__x) ); \
231#define mips_get_bdarm( _x, _y ) \
233 __asm__ volatile( "mfc0 %0, $5; nop" : "=r" (_x) : ); \
234 __asm__ volatile( "mfc0 %0, $9; nop" : "=r" (_y) : ); \
238#define mips_set_bdarm( _x, _y ) \
240 unsigned int __x = (_x); \
241 unsigned int __y = (_y); \
242 __asm__ volatile( "mtc0 %0, $9; nop" : : "r" (__y) ); \
243 __asm__ volatile( "mtc0 %0, $5; nop" : : "r" (__x) ); \
256#if ( MIPS_HAS_FPU == 1 )
258#define mips_get_fcr31( _x ) \
260 __asm__ volatile( "cfc1 %0, $31; nop" : "=r" (_x) : ); \
264#define mips_set_fcr31( _x ) \
266 unsigned int __x = (_x); \
267 __asm__ volatile( "ctc1 %0, $31; nop" : : "r" (__x) ); \
272#define mips_get_fcr31( _x )
273#define mips_set_fcr31( _x )
296#define mips_enable_in_interrupt_mask( _mask ) \
299 mips_get_sr( _sr ); \
301 mips_set_sr( _sr ); \
304#define mips_disable_in_interrupt_mask( _mask ) \
307 mips_get_sr( _sr ); \
309 mips_set_sr( _sr ); \