[ac7d5ef0] | 1 | /* |
---|
[38ffa0c] | 2 | * Motorola MC68xxx Dependent Source |
---|
[ac7d5ef0] | 3 | * |
---|
[08311cc3] | 4 | * COPYRIGHT (c) 1989-1999. |
---|
[ac7d5ef0] | 5 | * On-Line Applications Research Corporation (OAR). |
---|
| 6 | * |
---|
[98e4ebf5] | 7 | * The license and distribution terms for this file may be |
---|
| 8 | * found in the file LICENSE in this distribution or at |
---|
[05a98b7] | 9 | * http://www.rtems.com/license/LICENSE. |
---|
[ac7d5ef0] | 10 | * |
---|
| 11 | * $Id$ |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | #include <rtems/system.h> |
---|
[5e9b32b] | 15 | #include <rtems/score/isr.h> |
---|
[ac7d5ef0] | 16 | |
---|
[3b7e9bc] | 17 | #if defined( __mcoldfire__ ) && ( M68K_HAS_FPU == 1 ) |
---|
| 18 | uint32_t _CPU_cacr_shadow; |
---|
| 19 | #endif |
---|
| 20 | |
---|
[ac7d5ef0] | 21 | /* _CPU_Initialize |
---|
| 22 | * |
---|
| 23 | * This routine performs processor dependent initialization. |
---|
| 24 | * |
---|
[c03e2bc] | 25 | * INPUT PARAMETERS: NONE |
---|
[ac7d5ef0] | 26 | * |
---|
| 27 | * OUTPUT PARAMETERS: NONE |
---|
| 28 | */ |
---|
| 29 | |
---|
[c03e2bc] | 30 | void _CPU_Initialize(void) |
---|
[ac7d5ef0] | 31 | { |
---|
[f4b7e297] | 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 | |
---|
[d86bae8] | 36 | uint32_t slot; |
---|
[f4b7e297] | 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; |
---|
[edb1810e] | 43 | _CPU_ISR_jump_table[slot].isr_handler = (uint32_t) 0xDEADDEAD; |
---|
[f4b7e297] | 44 | } |
---|
| 45 | #endif /* M68K_HAS_VBR */ |
---|
[ac7d5ef0] | 46 | } |
---|
| 47 | |
---|
[3a4ae6c] | 48 | /*PAGE |
---|
| 49 | * |
---|
| 50 | * _CPU_ISR_Get_level |
---|
| 51 | */ |
---|
| 52 | |
---|
[d86bae8] | 53 | uint32_t _CPU_ISR_Get_level( void ) |
---|
[3a4ae6c] | 54 | { |
---|
[d86bae8] | 55 | uint32_t level; |
---|
[3a4ae6c] | 56 | |
---|
| 57 | m68k_get_interrupt_level( level ); |
---|
| 58 | |
---|
| 59 | return level; |
---|
| 60 | } |
---|
| 61 | |
---|
[637df35] | 62 | /*PAGE |
---|
| 63 | * |
---|
| 64 | * _CPU_ISR_install_raw_handler |
---|
| 65 | */ |
---|
| 66 | |
---|
| 67 | void _CPU_ISR_install_raw_handler( |
---|
[d86bae8] | 68 | uint32_t vector, |
---|
[637df35] | 69 | proc_ptr new_handler, |
---|
| 70 | proc_ptr *old_handler |
---|
| 71 | ) |
---|
| 72 | { |
---|
| 73 | proc_ptr *interrupt_table = NULL; |
---|
| 74 | |
---|
[5bf6ffb] | 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 |
---|
[637df35] | 86 | |
---|
[f4b7e297] | 87 | |
---|
[5bf6ffb] | 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 ); |
---|
[f4b7e297] | 95 | #if ( M68K_HAS_VBR == 1 ) |
---|
[c533372] | 96 | *old_handler = interrupt_table[ vector ]; |
---|
[637df35] | 97 | interrupt_table[ vector ] = new_handler; |
---|
[38ffa0c] | 98 | #else |
---|
[5ede9706] | 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 | |
---|
[86e1c26] | 107 | *old_handler = (proc_ptr) _CPU_ISR_jump_table[vector].isr_handler; |
---|
[edb1810e] | 108 | _CPU_ISR_jump_table[vector].isr_handler = (uint32_t) new_handler; |
---|
| 109 | if ( (uint32_t) interrupt_table != 0xFFFFFFFF ) |
---|
[5ede9706] | 110 | interrupt_table[ vector ] = (proc_ptr) &_CPU_ISR_jump_table[vector]; |
---|
[38ffa0c] | 111 | #endif /* M68K_HAS_VBR */ |
---|
[637df35] | 112 | } |
---|
| 113 | |
---|
| 114 | /*PAGE |
---|
| 115 | * |
---|
| 116 | * _CPU_ISR_install_vector |
---|
[ac7d5ef0] | 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 | |
---|
| 129 | void _CPU_ISR_install_vector( |
---|
[d86bae8] | 130 | uint32_t vector, |
---|
[ac7d5ef0] | 131 | proc_ptr new_handler, |
---|
| 132 | proc_ptr *old_handler |
---|
| 133 | ) |
---|
| 134 | { |
---|
[926a05e] | 135 | proc_ptr ignored = 0; /* to avoid warning */ |
---|
[ac7d5ef0] | 136 | |
---|
| 137 | *old_handler = _ISR_Vector_table[ vector ]; |
---|
| 138 | |
---|
[637df35] | 139 | _CPU_ISR_install_raw_handler( vector, _ISR_Handler, &ignored ); |
---|
| 140 | |
---|
[ac7d5ef0] | 141 | _ISR_Vector_table[ vector ] = new_handler; |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | /*PAGE |
---|
| 146 | * |
---|
| 147 | * _CPU_Install_interrupt_stack |
---|
| 148 | */ |
---|
| 149 | |
---|
| 150 | void _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 | |
---|
[9e86dd7d] | 159 | #if ( M68K_HAS_BFFFO != 1 ) |
---|
| 160 | /* |
---|
[38ffa0c] | 161 | * Returns table for duplication of the BFFFO instruction (16 bits only) |
---|
[9e86dd7d] | 162 | */ |
---|
[60a3fa0c] | 163 | const unsigned char _CPU_m68k_BFFFO_table[256] = { |
---|
[38ffa0c] | 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 |
---|
[9e86dd7d] | 180 | }; |
---|
| 181 | #endif |
---|
[00d2a828] | 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) |
---|
| 190 | extern Context_Control_fp _fpCCR; |
---|
| 191 | |
---|
[3b7e9bc] | 192 | void _CPU_Context_save_fp (Context_Control_fp **fp_context_ptr) |
---|
[00d2a828] | 193 | { |
---|
| 194 | Context_Control_fp *fp; |
---|
| 195 | |
---|
[14865ec7] | 196 | fp = *fp_context_ptr; |
---|
[00d2a828] | 197 | |
---|
| 198 | *fp = _fpCCR; |
---|
| 199 | } |
---|
| 200 | |
---|
[3b7e9bc] | 201 | void _CPU_Context_restore_fp (Context_Control_fp **fp_context_ptr) |
---|
[00d2a828] | 202 | { |
---|
| 203 | Context_Control_fp *fp; |
---|
| 204 | |
---|
[14865ec7] | 205 | fp = *fp_context_ptr; |
---|
[00d2a828] | 206 | |
---|
| 207 | _fpCCR = *fp; |
---|
| 208 | } |
---|
| 209 | #endif |
---|