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

4.9
Last change on this file since d0279f6e was edb1810e, checked in by Joel Sherrill <joel.sherrill@…>, on 09/08/08 at 15:19:14

2008-09-08 Joel Sherrill <joel.sherrill@…>

  • cpu.c, rtems/score/cpu.h: Remove extraneous spaces.
  • 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/*  _CPU_Initialize
18 *
19 *  This routine performs processor dependent initialization.
20 *
21 *  INPUT PARAMETERS:
22 *    thread_dispatch - entry pointer to thread dispatcher
23 *
24 *  OUTPUT PARAMETERS: NONE
25 */
26
27void _CPU_Initialize(
28  void      (*thread_dispatch)      /* ignored on this CPU */
29)
30{
31#if ( M68K_HAS_VBR == 0 )
32  /* fill the isr redirect table with the code to place the format/id
33     onto the stack */
34
35  uint32_t   slot;
36
37  for (slot = 0; slot < CPU_INTERRUPT_NUMBER_OF_VECTORS; slot++)
38  {
39    _CPU_ISR_jump_table[slot].move_a7 = M68K_MOVE_A7;
40    _CPU_ISR_jump_table[slot].format_id = slot << 2;
41    _CPU_ISR_jump_table[slot].jmp = M68K_JMP;
42    _CPU_ISR_jump_table[slot].isr_handler = (uint32_t) 0xDEADDEAD;
43  }
44#endif /* M68K_HAS_VBR */
45}
46
47/*PAGE
48 *
49 *  _CPU_ISR_Get_level
50 */
51 
52uint32_t   _CPU_ISR_Get_level( void )
53{
54  uint32_t   level;
55
56  m68k_get_interrupt_level( level );
57
58  return level;
59}
60
61/*PAGE
62 *
63 *  _CPU_ISR_install_raw_handler
64 */
65 
66void _CPU_ISR_install_raw_handler(
67  uint32_t    vector,
68  proc_ptr    new_handler,
69  proc_ptr   *old_handler
70)
71{
72  proc_ptr *interrupt_table = NULL;
73
74#if (M68K_HAS_FPSP_PACKAGE == 1)
75  /*
76   *  If this vector being installed is one related to FP, then the
77   *  FPSP will install the handler itself and handle it completely
78   *  with no intervention from RTEMS.
79   */
80
81  if (*_FPSP_install_raw_handler &&
82      (*_FPSP_install_raw_handler)(vector, new_handler, *old_handler))
83        return;
84#endif
85
86
87  /*
88   *  On CPU models without a VBR, it is necessary for there to be some
89   *  header code for each ISR which saves a register, loads the vector
90   *  number, and jumps to _ISR_Handler.
91   */
92
93  m68k_get_vbr( interrupt_table );
94#if ( M68K_HAS_VBR == 1 )
95  *old_handler = interrupt_table[ vector ];
96  interrupt_table[ vector ] = new_handler;
97#else
98
99  /*
100   *  Install handler into RTEMS jump table and if VBR table is in
101   *  RAM, install the pointer to the appropriate jump table slot.
102   *  If the VBR table is in ROM, it is the BSP's responsibility to
103   *  load it appropriately to vector to the RTEMS jump table.
104   */
105
106  *old_handler = (proc_ptr) _CPU_ISR_jump_table[vector].isr_handler;
107  _CPU_ISR_jump_table[vector].isr_handler = (uint32_t) new_handler;
108  if ( (uint32_t) interrupt_table != 0xFFFFFFFF )
109    interrupt_table[ vector ] = (proc_ptr) &_CPU_ISR_jump_table[vector];
110#endif /* M68K_HAS_VBR */
111}
112
113/*PAGE
114 *
115 *  _CPU_ISR_install_vector
116 *
117 *  This kernel routine installs the RTEMS handler for the
118 *  specified vector.
119 *
120 *  Input parameters:
121 *    vector      - interrupt vector number
122 *    new_handler - replacement ISR for this vector number
123 *    old_handler - former ISR for this vector number
124 *
125 *  Output parameters:  NONE
126 */
127
128void _CPU_ISR_install_vector(
129  uint32_t    vector,
130  proc_ptr    new_handler,
131  proc_ptr   *old_handler
132)
133{
134  proc_ptr ignored = 0;  /* to avoid warning */
135
136  *old_handler = _ISR_Vector_table[ vector ];
137
138  _CPU_ISR_install_raw_handler( vector, _ISR_Handler, &ignored );
139
140  _ISR_Vector_table[ vector ] = new_handler;
141}
142
143
144/*PAGE
145 *
146 *  _CPU_Install_interrupt_stack
147 */
148
149void _CPU_Install_interrupt_stack( void )
150{
151#if ( M68K_HAS_SEPARATE_STACKS == 1 )
152  void *isp = _CPU_Interrupt_stack_high;
153
154  asm volatile ( "movec %0,%%isp" : "=r" (isp) : "0" (isp) );
155#endif
156}
157
158#if ( M68K_HAS_BFFFO != 1 )
159/*
160 * Returns table for duplication of the BFFFO instruction (16 bits only)
161 */
162const unsigned char _CPU_m68k_BFFFO_table[256] = {
163    8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
164    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
165    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
166    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
167    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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};
180#endif
181
182/*PAGE
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.