source: rtems/cpukit/score/cpu/c4x/rtems/score/c4x.h @ 10f8664

4.104.114.84.95
Last change on this file since 10f8664 was 10f8664, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/02/04 at 07:39:05

2004-10-02 Ralf Corsepius <ralf_corsepius@…>

  • rtems/score/c4x.h: Add doxygen preamble.
  • rtems/score/cpu.h: Add doxygen preamble.
  • rtems/score/cpu_asm.h: Add doxygen preamble.
  • rtems/score/types.h: Add doxygen preamble.
  • Property mode set to 100644
File size: 8.3 KB
Line 
1/**
2 * @file rtems/score/c4x.h
3 */
4
5/*
6 *  This file is an example (i.e. "no CPU") of the file which is
7 *  created for each CPU family port of RTEMS.
8 *
9 *
10 *  COPYRIGHT (c) 1989-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 *
19 */
20
21#ifndef _INCLUDE_C4X_h
22#define _INCLUDE_C4X_h
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/*
29 *  This file contains the information required to build
30 *  RTEMS for a particular member of the "no cpu"
31 *  family when executing in protected mode.  It does
32 *  this by setting variables to indicate which implementation
33 *  dependent features are present in a particular member
34 *  of the family.
35 */
36 
37#if defined(_C30)
38#define CPU_MODEL_NAME  "C30"
39
40#elif defined(_C31)
41#define CPU_MODEL_NAME  "C31"
42 
43#elif defined(_C32)
44#define CPU_MODEL_NAME  "C32"
45 
46#elif defined(_C33)
47#define CPU_MODEL_NAME  "C33"
48 
49#elif defined(_C40)
50#define CPU_MODEL_NAME  "C40"
51 
52#elif defined(_C44)
53#define CPU_MODEL_NAME  "C44"
54 
55#else
56 
57#error "Unsupported CPU Model"
58 
59#endif
60
61/*
62 *  Define the name of the CPU family.
63 */
64
65#define CPU_NAME "Texas Instruments C3x/C4x"
66
67/*
68 *  This port is a little unusual in that even though there are "floating
69 *  point registers", the notion of floating point is very inherent to
70 *  applications.  In addition, the calling conventions require that
71 *  only a few extended registers be preserved across subroutine calls.
72 *  The overhead of including these few registers in the basic
73 *  context is small compared to the overhead of managing the notion
74 *  of separate floating point contexts.  So we decided to pretend that
75 *  there is no FPU on the C3x or C4x.
76 */
77
78#define C4X_HAS_FPU  0
79
80/*
81 *  Routines to manipulate the bits in the Status Word (ST).
82 */
83
84#define C4X_ST_C      0x0001
85#define C4X_ST_V      0x0002
86#define C4X_ST_Z      0x0004
87#define C4X_ST_N      0x0008
88#define C4X_ST_UF     0x0010
89#define C4X_ST_LV     0x0020
90#define C4X_ST_LUF    0x0040
91#define C4X_ST_OVM    0x0080
92#define C4X_ST_RM     0x0100
93#define C4X_ST_CF     0x0400
94#define C4X_ST_CE     0x0800
95#define C4X_ST_CC     0x1000
96#define C4X_ST_GIE    0x2000
97
98#ifndef _TMS320C40
99#define C3X_IE_INTERRUPT_MASK_BITS     0xffff
100#define C3x_IE_INTERRUPTS_ALL_ENABLED  0x0000
101#define C3x_IE_INTERRUPTS_ALL_DISABLED 0xffff
102#endif
103
104#ifndef ASM
105
106/*
107 *  A nop macro.
108 */
109
110#define c4x_nop() \
111  __asm__("nop");
112
113/*
114 *  Routines to set and clear individual bits in the ST (status word).
115 *
116 *  cpu_st_bit_clear  - clear bit in ST
117 *  cpu_st_bit_set    - set bit in ST
118 *  cpu_st_get        - obtain entire ST
119 */
120
121#ifdef _TMS320C40
122#define c4x_gie_nop()
123#else
124#define c4x_gie_nop() { c4x_nop(); c4x_nop(); }
125#endif
126
127#define cpu_st_bit_clear(_st_bit) \
128  do { \
129    __asm__("andn %0,st" : : "g" (_st_bit) : "cc"); \
130    c4x_gie_nop(); \
131  } while (0)
132
133#define cpu_st_bit_set(_st_bit) \
134  do { \
135    __asm__("or %0,st" : : "g" (_st_bit) : "cc"); \
136    c4x_gie_nop(); \
137  } while (0)
138
139static inline unsigned int cpu_st_get(void)
140{
141  register unsigned int st_value;
142  __asm__("ldi st, %0" : "=r" (st_value));
143  return st_value;
144}
145
146/*
147 *  Routines to manipulate the Global Interrupt Enable (GIE) bit in
148 *  the Status Word (ST).
149 *
150 *  c4x_global_interrupts_get      - returns current GIE setting
151 *  c4x_global_interrupts_disable  - disables global interrupts
152 *  c4x_global_interrupts_enable   - enables global interrupts
153 *  c4x_global_interrupts_restore  - restores GIE to pre-disable state
154 *  c4x_global_interrupts_flash    - temporarily enable global interrupts
155 */
156
157#define c4x_global_interrupts_get() \
158  (cpu_st_get() & C4X_ST_GIE)
159 
160#define c4x_global_interrupts_disable() \
161  cpu_st_bit_clear(C4X_ST_GIE)
162
163#define c4x_global_interrupts_enable() \
164  cpu_st_bit_set(C4X_ST_GIE)
165
166#define c4x_global_interrupts_restore(_old_level) \
167  cpu_st_bit_set(_old_level)
168
169#define c4x_global_interrupts_flash(_old_level) \
170  do { \
171    cpu_st_bit_set(_old_level); \
172    cpu_st_bit_clear(C4X_ST_GIE); \
173  } while (0)
174
175#ifndef _TMS320C40
176
177/*
178 *  Routines to set and get the IF register
179 *
180 *  c3x_get_if     - obtains IF register
181 *  c3x_set_if     - sets IF register
182 */
183
184static inline unsigned int c3x_get_if(void)
185{
186  register unsigned int _if_value;
187
188  __asm__( "ldi if, %0" : "=r" (_if_value) );
189  return _if_value;
190}
191
192static inline void c3x_set_if(unsigned int _if_value)
193{
194  __asm__( "ldi %0, if" : : "g" (_if_value) : "if", "cc");
195}
196
197/*
198 *  Routines to set and get the IE register
199 *
200 *  c3x_get_ie     - obtains IE register
201 *  c3x_set_ie     - sets IE register
202 */
203
204static inline unsigned int c3x_get_ie(void)
205{
206  register unsigned int _ie_value;
207
208  __asm__ volatile ( "ldi ie, %0" : "=r" (_ie_value) );
209  return _ie_value;
210}
211
212static inline void c3x_set_ie(unsigned int _ie_value)
213{
214  __asm__ volatile ( "ldi %0, ie" : : "g" (_ie_value) : "ie", "cc");
215}
216
217/*
218 *  Routines to manipulates the mask portion of the IE register.
219 *
220 *  c3x_ie_mask_all     - returns previous IE mask
221 *  c3x_ie_mask_restore - restores previous IE mask
222 *  c3x_ie_mask_flash   - temporarily restores previous IE mask
223 *  c3x_ie_mask_set     - sets a specific set of the IE mask
224 */
225 
226#define c3x_ie_mask_all( _isr_cookie ) \
227  do { \
228    __asm__("ldi  ie,%0\n" \
229            "\tandn 0ffffh, ie" \
230          : "=r" (_isr_cookie): : "ie", "cc" ); \
231  } while (0)
232
233#define c3x_ie_mask_restore( _isr_cookie )  \
234  do { \
235    __asm__("or %0, ie" \
236          : : "g" (_isr_cookie) : "ie", "cc" ); \
237  } while (0)
238
239#define c3x_ie_mask_flash( _isr_cookie ) \
240  do { \
241    __asm__("or %0, ie\n" \
242           "\tandn 0ffffh, ie" \
243          : : "g" (_isr_cookie) : "ie", "cc" ); \
244  } while (0)
245
246#define c3x_ie_mask_set( _new_mask ) \
247  do { unsigned int _ie_mask; \
248    unsigned int _ie_value; \
249    \
250    if ( _new_mask == 0 ) _ie_mask = 0; \
251    else                  _ie_mask = 0xffff; \
252    _ie_value = c3x_get_ie(); \
253    _ie_value &= C4X_IE_INTERRUPT_MASK_BITS; \
254    _ie_value |= _ie_mask; \
255    c3x_set_ie(_ie_value); \
256  } while (0)
257#endif
258/* end of C3x specific interrupt flag routines */
259
260/*
261 *  This is a section of C4x specific interrupt flag management routines.
262 */
263
264#ifdef _TMS320C40
265
266/*
267 *  Routines to set and get the IIF register
268 *
269 *  c4x_get_iif     - obtains IIF register
270 *  c4x_set_iif     - sets IIF register
271 */
272
273static inline unsigned int c4x_get_iif(void)
274{
275  register unsigned int _iif_value;
276
277  __asm__( "ldi iif, %0" : "=r" (_iif_value) );
278  return _iif_value;
279}
280
281static inline void c4x_set_iif(unsigned int _iif_value)
282{
283  __asm__( "ldi %0, iif" : : "g" (_iif_value) : "iif", "cc");
284}
285
286/*
287 *  Routines to set and get the IIE register
288 *
289 *  c4x_get_iie     - obtains IIE register
290 *  c4x_set_iie     - sets IIE register
291 */
292
293static inline unsigned int c4x_get_iie(void)
294{
295  register unsigned int _iie_value;
296
297  __asm__( "ldi iie, %0" : "=r" (_iie_value) );
298  return _iie_value;
299}
300
301static inline void c4x_set_iie(unsigned int _iie_value)
302{
303  __asm__( "ldi %0, iie" : : "g" (_iie_value) : "iie", "cc");
304}
305
306/*
307 *  Routines to manipulates the mask portion of the IIE register.
308 *
309 *  c4x_ie_mask_all     - returns previous IIE mask
310 *  c4x_ie_mask_restore - restores previous IIE mask
311 *  c4x_ie_mask_flash   - temporarily restores previous IIE mask
312 *  c4x_ie_mask_set     - sets a specific set of the IIE mask
313 */
314
315#if 0
316#warning "C4x IIE masking routines not implemented."
317#define c4x_iie_mask_all( _isr_cookie )
318#define c4x_iie_mask_restore( _isr_cookie )
319#define c4x_iie_mask_flash( _isr_cookie )
320#define c4x_iie_mask_set( _new_mask )
321#endif
322
323#endif
324/* end of C4x specific interrupt flag routines */
325
326/*
327 *  Routines to access the Interrupt Trap Table Pointer
328 *
329 *  c4x_get_ittp    - get ITTP
330 *  c4x_set_ittp    - set ITTP
331 */
332
333static inline void * c4x_get_ittp(void)
334{
335  register unsigned int _if_value;
336 
337  __asm__( "ldi if, %0" : "=r" (_if_value) );
338  return (void *)((_if_value & 0xffff0000) >> 8);
339
340
341static inline void c4x_set_ittp(void *_ittp_value)
342
343  unsigned int _if_value;
344  unsigned int _ittp_field;
345
346#ifdef _TMS320C40
347  _if_value = c4x_get_iif();
348#else
349  _if_value = c3x_get_if();
350#endif
351  _if_value &= 0xffff;
352  _ittp_field = (((unsigned int) _ittp_value) >> 8);
353  _if_value |= _ittp_field << 16 ;
354#ifdef _TMS320C40
355  c4x_set_iif( _if_value );
356#else
357  c3x_set_if( _if_value );
358#endif
359
360
361#endif /* ifndef ASM */
362
363#ifdef __cplusplus
364}
365#endif
366
367#endif /* ! _INCLUDE_C4X_h */
368/* end of include file */
Note: See TracBrowser for help on using the repository browser.