source: rtems/c/src/exec/score/cpu/mips/rtems/score/mips.h @ 8264d23

4.104.114.84.95
Last change on this file since 8264d23 was 8264d23, checked in by Joel Sherrill <joel.sherrill@…>, on 03/08/02 at 16:24:48

2002-03-05 Greg Menke <gregory.menke@…>

  • cpu_asm.S: Added support for the debug exception vector, cleaned up the exception processing & exception return stuff. Re-added EPC in the task context structure so the gdb stub will know where a thread is executing. Should've left it there in the first place...
  • idtcpu.h: Added support for the debug exception vector.
  • cpu.c: Added _exceptionTaskStack to hold a pointer to the stack frame in an interrupt so context switch code can get the userspace EPC when scheduling.
  • rtems/score/cpu.h: Re-added EPC to the task context.
  • Property mode set to 100644
File size: 6.2 KB
Line 
1/*  mips.h
2 *
3 *  COPYRIGHT (c) 1989-2001.
4 *  On-Line Applications Research Corporation (OAR).
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.OARcorp.com/rtems/license.html.
9 *
10 *  $Id$
11 */
12/* @(#)mips64orion.h       08/29/96     1.3 */
13
14#ifndef _INCLUDE_MIPS_h
15#define _INCLUDE_MIPS_h
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#ifndef ASM
22#include <idtcpu.h>
23#endif
24
25/*
26 *  SR bits that enable/disable interrupts
27 *
28 *  NOTE: XXX what about SR_ERL?
29 */
30
31#if __mips == 3
32#ifdef ASM
33#define SR_INTERRUPT_ENABLE_BITS 0x01
34#else
35#define SR_INTERRUPT_ENABLE_BITS SR_IE
36#endif
37
38#elif __mips == 1
39#define SR_INTERRUPT_ENABLE_BITS SR_IEC
40
41#else
42#error "mips interrupt enable bits: unknown architecture level!"
43#endif
44
45/*
46 *  This file contains the information required to build
47 *  RTEMS for a particular member of the "no cpu"
48 *  family when executing in protected mode.  It does
49 *  this by setting variables to indicate which implementation
50 *  dependent features are present in a particular member
51 *  of the family.
52 */
53 
54#if defined(__mips_soft_float)
55#define MIPS_HAS_FPU 0
56#else
57#define MIPS_HAS_FPU 1
58#endif
59
60#if (__mips == 1)
61#define CPU_MODEL_NAME  "ISA Level 1 or 2"
62#elif (__mips == 3)
63#if defined(__mips64)
64#define CPU_MODEL_NAME  "ISA Level 4"
65#else
66#define CPU_MODEL_NAME  "ISA Level 3"
67#endif
68#else
69#error "Unknown MIPS ISA level"
70#endif
71
72/*
73 *  Define the name of the CPU family.
74 */
75
76#define CPU_NAME "MIPS"
77
78/*
79 *  RTEMS Vector numbers for exception conditions.  This is a direct
80 *  map to the causes.
81 */
82
83#define MIPS_EXCEPTION_BASE 0
84
85#define MIPS_EXCEPTION_INT              MIPS_EXCEPTION_BASE+0
86#define MIPS_EXCEPTION_MOD              MIPS_EXCEPTION_BASE+1
87#define MIPS_EXCEPTION_TLBL             MIPS_EXCEPTION_BASE+2
88#define MIPS_EXCEPTION_TLBS             MIPS_EXCEPTION_BASE+3
89#define MIPS_EXCEPTION_ADEL             MIPS_EXCEPTION_BASE+4
90#define MIPS_EXCEPTION_ADES             MIPS_EXCEPTION_BASE+5
91#define MIPS_EXCEPTION_IBE              MIPS_EXCEPTION_BASE+6
92#define MIPS_EXCEPTION_DBE              MIPS_EXCEPTION_BASE+7
93#define MIPS_EXCEPTION_SYSCALL          MIPS_EXCEPTION_BASE+8
94#define MIPS_EXCEPTION_BREAK            MIPS_EXCEPTION_BASE+9
95#define MIPS_EXCEPTION_RI               MIPS_EXCEPTION_BASE+10
96#define MIPS_EXCEPTION_CPU              MIPS_EXCEPTION_BASE+11
97#define MIPS_EXCEPTION_OVERFLOW         MIPS_EXCEPTION_BASE+12
98#define MIPS_EXCEPTION_TRAP             MIPS_EXCEPTION_BASE+13
99#define MIPS_EXCEPTION_VCEI             MIPS_EXCEPTION_BASE+14
100/* FPE only on mips2 and higher */
101#define MIPS_EXCEPTION_FPE              MIPS_EXCEPTION_BASE+15
102#define MIPS_EXCEPTION_C2E              MIPS_EXCEPTION_BASE+16
103/* 17-22 reserved */
104#define MIPS_EXCEPTION_WATCH            MIPS_EXCEPTION_BASE+23
105/* 24-30 reserved */
106#define MIPS_EXCEPTION_VCED             MIPS_EXCEPTION_BASE+31
107
108#define MIPS_INTERRUPT_BASE             MIPS_EXCEPTION_BASE+32
109
110/*
111 *  Some macros to access registers
112 */
113
114#define mips_get_sr( _x ) \
115  do { \
116    asm volatile( "mfc0 %0, $12; nop" : "=r" (_x) : ); \
117  } while (0)
118
119#define mips_set_sr( _x ) \
120  do { \
121    register unsigned int __x = (_x); \
122    asm volatile( "mtc0 %0, $12; nop" : : "r" (__x) ); \
123  } while (0)
124
125
126/*
127 *  Access the Cause register
128 */
129
130#define mips_get_cause( _x ) \
131  do { \
132    asm volatile( "mfc0 %0, $13; nop" : "=r" (_x) : ); \
133  } while (0)
134
135
136#define mips_set_cause( _x ) \
137  do { \
138    register unsigned int __x = (_x); \
139    asm volatile( "mtc0 %0, $13; nop" : : "r" (__x) ); \
140  } while (0)
141
142
143
144
145/*
146 *  Access the Debug Cache Invalidate Control register
147 */
148
149#define mips_get_dcic( _x ) \
150  do { \
151    asm volatile( "mfc0 %0, $7; nop" : "=r" (_x) : ); \
152  } while (0)
153
154
155#define mips_set_dcic( _x ) \
156  do { \
157    register unsigned int __x = (_x); \
158    asm volatile( "mtc0 %0, $7; nop" : : "r" (__x) ); \
159  } while (0)
160
161
162
163
164/*
165 *  Access the Breakpoint Program Counter & Mask registers
166 *  (_x for BPC, _y for mask)
167 */
168
169#define mips_get_bpcrm( _x, _y ) \
170  do { \
171    asm volatile( "mfc0 %0, $3; nop" : "=r" (_x) : ); \
172    asm volatile( "mfc0 %0, $11; nop" : "=r" (_y) : ); \
173  } while (0)
174
175
176#define mips_set_bpcrm( _x, _y ) \
177  do { \
178    register unsigned int __x = (_x); \
179    register unsigned int __y = (_y); \
180    asm volatile( "mtc0 %0, $11; nop" : : "r" (__y) ); \
181    asm volatile( "mtc0 %0, $3; nop" : : "r" (__x) ); \
182  } while (0)
183
184
185
186
187
188
189/*
190 *  Access the Breakpoint Data Address & Mask registers
191 *  (_x for BDA, _y for mask)
192 */
193
194#define mips_get_bdarm( _x, _y ) \
195  do { \
196    asm volatile( "mfc0 %0, $5; nop" : "=r" (_x) : ); \
197    asm volatile( "mfc0 %0, $9; nop" : "=r" (_y) : ); \
198  } while (0)
199
200
201#define mips_set_bdarm( _x, _y ) \
202  do { \
203    register unsigned int __x = (_x); \
204    register unsigned int __y = (_y); \
205    asm volatile( "mtc0 %0, $9; nop" : : "r" (__y) ); \
206    asm volatile( "mtc0 %0, $5; nop" : : "r" (__x) ); \
207  } while (0)
208
209
210
211
212
213
214
215/*
216 *  Access FCR31
217 */
218
219#define mips_get_fcr31( _x ) \
220  do { \
221    asm volatile( "cfc1 %0, $31; nop" : "=r" (_x) : ); \
222  } while(0)
223
224
225#define mips_set_fcr31( _x ) \
226  do { \
227    register unsigned int __x = (_x); \
228    asm volatile( "ctc1 %0, $31; nop" : : "r" (__x) ); \
229  } while(0)
230
231
232/*
233 *  Manipulate interrupt mask
234 *
235 *  mips_unmask_interrupt( _mask)
236 *    enables interrupts - mask is positioned so it only needs to be or'ed
237 *    into the status reg. This also does some other things !!!! Caution
238 *    should be used if invoking this while in the middle of a debugging
239 *    session where the client may have nested interrupts.
240 *
241 *  mips_mask_interrupt( _mask )
242 *    disable the interrupt - mask is the complement of the bits to be
243 *    cleared - i.e. to clear ext int 5 the mask would be - 0xffff7fff
244 *
245 *
246 *  NOTE: mips_mask_interrupt() used to be disable_int().
247 *        mips_unmask_interrupt() used to be enable_int().
248 *
249 */
250
251#define mips_enable_in_interrupt_mask( _mask ) \
252  do { \
253    unsigned int _sr; \
254    mips_get_sr( _sr ); \
255    _sr |= (_mask); \
256    mips_set_sr( _sr ); \
257  } while (0)
258
259#define mips_disable_in_interrupt_mask( _mask ) \
260  do { \
261    unsigned int _sr; \
262    mips_get_sr( _sr ); \
263    _sr &= ~(_mask); \
264    mips_set_sr( _sr ); \
265  } while (0)
266
267#ifdef __cplusplus
268}
269#endif
270
271#endif /* ! _INCLUDE_MIPS_h */
272/* end of include file */
Note: See TracBrowser for help on using the repository browser.