RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
cpukit
score
cpu
mips
include
rtems
score
mips.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
15
16
/*
17
* COPYRIGHT (c) 1989-2001.
18
* On-Line Applications Research Corporation (OAR).
19
*
20
* Redistribution and use in source and binary forms, with or without
21
* modification, are permitted provided that the following conditions
22
* are met:
23
* 1. Redistributions of source code must retain the above copyright
24
* notice, this list of conditions and the following disclaimer.
25
* 2. Redistributions in binary form must reproduce the above copyright
26
* notice, this list of conditions and the following disclaimer in the
27
* documentation and/or other materials provided with the distribution.
28
*
29
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
33
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39
* POSSIBILITY OF SUCH DAMAGE.
40
*/
41
42
#ifndef _RTEMS_SCORE_MIPS_H
43
#define _RTEMS_SCORE_MIPS_H
44
52
53
#ifdef __cplusplus
54
extern
"C"
{
55
#endif
56
57
#ifndef ASM
58
#include <
rtems/mips/idtcpu.h
>
59
#endif
60
61
/*
62
* SR bits that enable/disable interrupts
63
*
64
* NOTE: XXX what about SR_ERL?
65
*/
66
67
#if (__mips == 3) || (__mips == 32)
68
#ifdef ASM
69
#define SR_INTERRUPT_ENABLE_BITS 0x01
70
#else
71
#define SR_INTERRUPT_ENABLE_BITS SR_IE
72
#endif
73
74
#elif __mips == 1
75
#define SR_INTERRUPT_ENABLE_BITS SR_IEC
76
77
#else
78
#error "mips interrupt enable bits: unknown architecture level!"
79
#endif
80
81
/*
82
* This file contains the information required to build
83
* RTEMS for a particular member of the "no cpu"
84
* family when executing in protected mode. It does
85
* this by setting variables to indicate which implementation
86
* dependent features are present in a particular member
87
* of the family.
88
*/
89
90
#if defined(__mips_soft_float)
91
#define MIPS_HAS_FPU 0
92
#else
93
#define MIPS_HAS_FPU 1
94
#endif
95
96
97
#if (__mips == 1)
98
#define CPU_MODEL_NAME "ISA Level 1 or 2"
99
#elif (__mips == 3) || (__mips == 32)
100
#if defined(__mips64)
101
#define CPU_MODEL_NAME "ISA Level 4"
102
#else
103
#define CPU_MODEL_NAME "ISA Level 3"
104
#endif
105
#else
106
#error "Unknown MIPS ISA level"
107
#endif
108
109
/*
110
* Define the name of the CPU family.
111
*/
112
113
#define CPU_NAME "MIPS"
114
115
/*
116
* RTEMS Vector numbers for exception conditions. This is a direct
117
* map to the causes.
118
*/
119
120
#define MIPS_EXCEPTION_BASE 0
121
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
137
/* FPE only on mips2 and higher */
138
#define MIPS_EXCEPTION_FPE MIPS_EXCEPTION_BASE+15
139
#define MIPS_EXCEPTION_C2E MIPS_EXCEPTION_BASE+16
140
/* 17-22 reserved */
141
#define MIPS_EXCEPTION_WATCH MIPS_EXCEPTION_BASE+23
142
/* 24-30 reserved */
143
#define MIPS_EXCEPTION_VCED MIPS_EXCEPTION_BASE+31
144
145
#define MIPS_INTERRUPT_BASE MIPS_EXCEPTION_BASE+32
146
147
/*
148
* Some macros to access registers
149
*/
150
151
#define mips_get_sr( _x ) \
152
do { \
153
__asm__ volatile( "mfc0 %0, $12; nop" : "=r" (_x) : ); \
154
} while (0)
155
156
#define mips_set_sr( _x ) \
157
do { \
158
unsigned int __x = (_x); \
159
__asm__ volatile( "mtc0 %0, $12; nop" : : "r" (__x) ); \
160
} while (0)
161
162
163
/*
164
* Access the Cause register
165
*/
166
167
#define mips_get_cause( _x ) \
168
do { \
169
__asm__ volatile( "mfc0 %0, $13; nop" : "=r" (_x) : ); \
170
} while (0)
171
172
173
#define mips_set_cause( _x ) \
174
do { \
175
unsigned int __x = (_x); \
176
__asm__ volatile( "mtc0 %0, $13; nop" : : "r" (__x) ); \
177
} while (0)
178
179
180
181
182
/*
183
* Access the Debug Cache Invalidate Control register
184
*/
185
186
#define mips_get_dcic( _x ) \
187
do { \
188
__asm__ volatile( "mfc0 %0, $7; nop" : "=r" (_x) : ); \
189
} while (0)
190
191
192
#define mips_set_dcic( _x ) \
193
do { \
194
unsigned int __x = (_x); \
195
__asm__ volatile( "mtc0 %0, $7; nop" : : "r" (__x) ); \
196
} while (0)
197
198
199
200
201
/*
202
* Access the Breakpoint Program Counter & Mask registers
203
* (_x for BPC, _y for mask)
204
*/
205
206
#define mips_get_bpcrm( _x, _y ) \
207
do { \
208
__asm__ volatile( "mfc0 %0, $3; nop" : "=r" (_x) : ); \
209
__asm__ volatile( "mfc0 %0, $11; nop" : "=r" (_y) : ); \
210
} while (0)
211
212
213
#define mips_set_bpcrm( _x, _y ) \
214
do { \
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) ); \
219
} while (0)
220
221
222
223
224
225
226
/*
227
* Access the Breakpoint Data Address & Mask registers
228
* (_x for BDA, _y for mask)
229
*/
230
231
#define mips_get_bdarm( _x, _y ) \
232
do { \
233
__asm__ volatile( "mfc0 %0, $5; nop" : "=r" (_x) : ); \
234
__asm__ volatile( "mfc0 %0, $9; nop" : "=r" (_y) : ); \
235
} while (0)
236
237
238
#define mips_set_bdarm( _x, _y ) \
239
do { \
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) ); \
244
} while (0)
245
246
247
248
249
250
251
252
/*
253
* Access FCR31
254
*/
255
256
#if ( MIPS_HAS_FPU == 1 )
257
258
#define mips_get_fcr31( _x ) \
259
do { \
260
__asm__ volatile( "cfc1 %0, $31; nop" : "=r" (_x) : ); \
261
} while(0)
262
263
264
#define mips_set_fcr31( _x ) \
265
do { \
266
unsigned int __x = (_x); \
267
__asm__ volatile( "ctc1 %0, $31; nop" : : "r" (__x) ); \
268
} while(0)
269
270
#else
271
272
#define mips_get_fcr31( _x )
273
#define mips_set_fcr31( _x )
274
275
#endif
276
277
/*
278
* Manipulate interrupt mask
279
*
280
* mips_unmask_interrupt( _mask)
281
* enables interrupts - mask is positioned so it only needs to be or'ed
282
* into the status reg. This also does some other things !!!! Caution
283
* should be used if invoking this while in the middle of a debugging
284
* session where the client may have nested interrupts.
285
*
286
* mips_mask_interrupt( _mask )
287
* disable the interrupt - mask is the complement of the bits to be
288
* cleared - i.e. to clear ext int 5 the mask would be - 0xffff7fff
289
*
290
*
291
* NOTE: mips_mask_interrupt() used to be disable_int().
292
* mips_unmask_interrupt() used to be enable_int().
293
*
294
*/
295
296
#define mips_enable_in_interrupt_mask( _mask ) \
297
do { \
298
unsigned int _sr; \
299
mips_get_sr( _sr ); \
300
_sr |= (_mask); \
301
mips_set_sr( _sr ); \
302
} while (0)
303
304
#define mips_disable_in_interrupt_mask( _mask ) \
305
do { \
306
unsigned int _sr; \
307
mips_get_sr( _sr ); \
308
_sr &= ~(_mask); \
309
mips_set_sr( _sr ); \
310
} while (0)
311
312
#ifdef __cplusplus
313
}
314
#endif
315
317
#endif
/* _RTEMS_SCORE_MIPS_H */
318
/* end of include file */
idtcpu.h
CPU Related Definitions.
Generated by
1.18.0