source: rtems/cpukit/score/cpu/m68k/cpu.c @ 3dc9afb6

4.115
Last change on this file since 3dc9afb6 was 3dc9afb6, checked in by Joel Sherrill <joel.sherrill@…>, on 07/24/11 at 22:51:36

2011-07-24 Joel Sherrill <joel.sherrill@…>

  • cpu.c, cpu_asm.S: Remove /*PAGE markers which were interpreted by a long dead print script.
  • 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/*
53 *  _CPU_ISR_Get_level
54 */
55
56uint32_t   _CPU_ISR_Get_level( void )
57{
58  uint32_t   level;
59
60  m68k_get_interrupt_level( level );
61
62  return level;
63}
64
65/*
66 *  _CPU_ISR_install_raw_handler
67 */
68
69void _CPU_ISR_install_raw_handler(
70  uint32_t    vector,
71  proc_ptr    new_handler,
72  proc_ptr   *old_handler
73)
74{
75  proc_ptr *interrupt_table = NULL;
76
77#if (M68K_HAS_FPSP_PACKAGE == 1)
78  /*
79   *  If this vector being installed is one related to FP, then the
80   *  FPSP will install the handler itself and handle it completely
81   *  with no intervention from RTEMS.
82   */
83
84  if (*_FPSP_install_raw_handler &&
85      (*_FPSP_install_raw_handler)(vector, new_handler, *old_handler))
86        return;
87#endif
88
89
90  /*
91   *  On CPU models without a VBR, it is necessary for there to be some
92   *  header code for each ISR which saves a register, loads the vector
93   *  number, and jumps to _ISR_Handler.
94   */
95
96  m68k_get_vbr( interrupt_table );
97#if ( M68K_HAS_VBR == 1 )
98  *old_handler = interrupt_table[ vector ];
99  interrupt_table[ vector ] = new_handler;
100#else
101
102  /*
103   *  Install handler into RTEMS jump table and if VBR table is in
104   *  RAM, install the pointer to the appropriate jump table slot.
105   *  If the VBR table is in ROM, it is the BSP's responsibility to
106   *  load it appropriately to vector to the RTEMS jump table.
107   */
108
109  *old_handler = (proc_ptr) _CPU_ISR_jump_table[vector].isr_handler;
110  _CPU_ISR_jump_table[vector].isr_handler = (uint32_t) new_handler;
111  if ( (uint32_t) interrupt_table != 0xFFFFFFFF )
112    interrupt_table[ vector ] = (proc_ptr) &_CPU_ISR_jump_table[vector];
113#endif /* M68K_HAS_VBR */
114}
115
116/*
117 *  _CPU_ISR_install_vector
118 *
119 *  This kernel routine installs the RTEMS handler for the
120 *  specified vector.
121 *
122 *  Input parameters:
123 *    vector      - interrupt vector number
124 *    new_handler - replacement ISR for this vector number
125 *    old_handler - former ISR for this vector number
126 *
127 *  Output parameters:  NONE
128 */
129
130void _CPU_ISR_install_vector(
131  uint32_t    vector,
132  proc_ptr    new_handler,
133  proc_ptr   *old_handler
134)
135{
136  proc_ptr ignored = 0;  /* to avoid warning */
137
138  *old_handler = _ISR_Vector_table[ vector ];
139
140  _CPU_ISR_install_raw_handler( vector, _ISR_Handler, &ignored );
141
142  _ISR_Vector_table[ vector ] = new_handler;
143}
144
145
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/*
184 *  The following code context switches the software FPU emulation
185 *  code provided with GCC.
186 */
187
188#if (CPU_SOFTWARE_FP == TRUE)
189extern Context_Control_fp _fpCCR;
190
191void _CPU_Context_save_fp (Context_Control_fp **fp_context_ptr)
192{
193  Context_Control_fp *fp;
194
195  fp = *fp_context_ptr;
196
197  *fp = _fpCCR;
198}
199
200void _CPU_Context_restore_fp (Context_Control_fp **fp_context_ptr)
201{
202  Context_Control_fp *fp;
203
204  fp = *fp_context_ptr;
205
206  _fpCCR = *fp;
207}
208#endif
Note: See TracBrowser for help on using the repository browser.