source: rtems/cpukit/score/cpu/m68k/cpu.c @ da42259

4.104.115
Last change on this file since da42259 was 3b7e9bc, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 05/15/09 at 07:20:38

cpu.c, cpu_asm.S, rtems/score/cpu.h: Cleanup of the floating point context initialization, save and restore code.

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/*
2 *  Motorola MC68xxx Dependent Source
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#include <rtems/system.h>
15#include <rtems/score/isr.h>
16
17#if defined( __mcoldfire__ ) && ( M68K_HAS_FPU == 1 )
18  uint32_t _CPU_cacr_shadow;
19#endif
20
21/*  _CPU_Initialize
22 *
23 *  This routine performs processor dependent initialization.
24 *
25 *  INPUT PARAMETERS: NONE
26 *
27 *  OUTPUT PARAMETERS: NONE
28 */
29
30void _CPU_Initialize(void)
31{
32#if ( M68K_HAS_VBR == 0 )
33  /* fill the isr redirect table with the code to place the format/id
34     onto the stack */
35
36  uint32_t   slot;
37
38  for (slot = 0; slot < CPU_INTERRUPT_NUMBER_OF_VECTORS; slot++)
39  {
40    _CPU_ISR_jump_table[slot].move_a7 = M68K_MOVE_A7;
41    _CPU_ISR_jump_table[slot].format_id = slot << 2;
42    _CPU_ISR_jump_table[slot].jmp = M68K_JMP;
43    _CPU_ISR_jump_table[slot].isr_handler = (uint32_t) 0xDEADDEAD;
44  }
45#endif /* M68K_HAS_VBR */
46}
47
48/*PAGE
49 *
50 *  _CPU_ISR_Get_level
51 */
52 
53uint32_t   _CPU_ISR_Get_level( void )
54{
55  uint32_t   level;
56
57  m68k_get_interrupt_level( level );
58
59  return level;
60}
61
62/*PAGE
63 *
64 *  _CPU_ISR_install_raw_handler
65 */
66 
67void _CPU_ISR_install_raw_handler(
68  uint32_t    vector,
69  proc_ptr    new_handler,
70  proc_ptr   *old_handler
71)
72{
73  proc_ptr *interrupt_table = NULL;
74
75#if (M68K_HAS_FPSP_PACKAGE == 1)
76  /*
77   *  If this vector being installed is one related to FP, then the
78   *  FPSP will install the handler itself and handle it completely
79   *  with no intervention from RTEMS.
80   */
81
82  if (*_FPSP_install_raw_handler &&
83      (*_FPSP_install_raw_handler)(vector, new_handler, *old_handler))
84        return;
85#endif
86
87
88  /*
89   *  On CPU models without a VBR, it is necessary for there to be some
90   *  header code for each ISR which saves a register, loads the vector
91   *  number, and jumps to _ISR_Handler.
92   */
93
94  m68k_get_vbr( interrupt_table );
95#if ( M68K_HAS_VBR == 1 )
96  *old_handler = interrupt_table[ vector ];
97  interrupt_table[ vector ] = new_handler;
98#else
99
100  /*
101   *  Install handler into RTEMS jump table and if VBR table is in
102   *  RAM, install the pointer to the appropriate jump table slot.
103   *  If the VBR table is in ROM, it is the BSP's responsibility to
104   *  load it appropriately to vector to the RTEMS jump table.
105   */
106
107  *old_handler = (proc_ptr) _CPU_ISR_jump_table[vector].isr_handler;
108  _CPU_ISR_jump_table[vector].isr_handler = (uint32_t) new_handler;
109  if ( (uint32_t) interrupt_table != 0xFFFFFFFF )
110    interrupt_table[ vector ] = (proc_ptr) &_CPU_ISR_jump_table[vector];
111#endif /* M68K_HAS_VBR */
112}
113
114/*PAGE
115 *
116 *  _CPU_ISR_install_vector
117 *
118 *  This kernel routine installs the RTEMS handler for the
119 *  specified vector.
120 *
121 *  Input parameters:
122 *    vector      - interrupt vector number
123 *    new_handler - replacement ISR for this vector number
124 *    old_handler - former ISR for this vector number
125 *
126 *  Output parameters:  NONE
127 */
128
129void _CPU_ISR_install_vector(
130  uint32_t    vector,
131  proc_ptr    new_handler,
132  proc_ptr   *old_handler
133)
134{
135  proc_ptr ignored = 0;  /* to avoid warning */
136
137  *old_handler = _ISR_Vector_table[ vector ];
138
139  _CPU_ISR_install_raw_handler( vector, _ISR_Handler, &ignored );
140
141  _ISR_Vector_table[ vector ] = new_handler;
142}
143
144
145/*PAGE
146 *
147 *  _CPU_Install_interrupt_stack
148 */
149
150void _CPU_Install_interrupt_stack( void )
151{
152#if ( M68K_HAS_SEPARATE_STACKS == 1 )
153  void *isp = _CPU_Interrupt_stack_high;
154
155  asm volatile ( "movec %0,%%isp" : "=r" (isp) : "0" (isp) );
156#endif
157}
158
159#if ( M68K_HAS_BFFFO != 1 )
160/*
161 * Returns table for duplication of the BFFFO instruction (16 bits only)
162 */
163const unsigned char _CPU_m68k_BFFFO_table[256] = {
164    8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
165    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
166    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
167    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
168    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
169    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
170    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
171    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
172    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
173    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
174    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
175    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
176    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
177    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
178    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
179    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
180};
181#endif
182
183/*PAGE
184 *
185 *  The following code context switches the software FPU emulation
186 *  code provided with GCC.
187 */
188
189#if (CPU_SOFTWARE_FP == TRUE)
190extern Context_Control_fp _fpCCR;
191
192void _CPU_Context_save_fp (Context_Control_fp **fp_context_ptr)
193{
194  Context_Control_fp *fp;
195
196  fp = *fp_context_ptr;
197
198  *fp = _fpCCR;
199}
200
201void _CPU_Context_restore_fp (Context_Control_fp **fp_context_ptr)
202{
203  Context_Control_fp *fp;
204
205  fp = *fp_context_ptr;
206
207  _fpCCR = *fp;
208}
209#endif
Note: See TracBrowser for help on using the repository browser.