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

4.104.115
Last change on this file since febaa8a was febaa8a, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/10 at 15:03:09

2010-03-27 Joel Sherrill <joel.sherrill@…>

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