Changeset a385489 in rtems
- Timestamp:
- Aug 18, 2011, 9:00:14 AM (9 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 74ac113
- Parents:
- b7ee9ab
- Location:
- cpukit/score/cpu/nios2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/score/cpu/nios2/ChangeLog
rb7ee9ab ra385489 1 2011-08-18 Chris Johns <chrisj@rtems.org> 2 3 * cpu.c: Fix the ISR get level for the IIC. Make 4 _CPU_Context_Initialize a function rather than inlined. 5 * cpu_asm.S: Do not enable interrupt on return, rather resume the 6 state on entry to the ISR. 7 * irq.c, nios2/nios2-iic-low-level.S: Change the ISR handler so 8 the ipending decoding is in C and within the interrupt 9 context. This is usable with the Altera HAL directly. 10 * rtems/score/cpu.h: Add ienable and ipending interfaces. Add some 11 comments. Remove _CPU_Context_Initialize. 12 1 13 2011-08-14 Chris Johns <chrisj@rtems.org> 2 14 -
cpukit/score/cpu/nios2/cpu.c
rb7ee9ab ra385489 19 19 #include <rtems/score/isr.h> 20 20 #include <rtems/score/wkspace.h> 21 22 #include <rtems/score/nios2.h> 21 23 22 24 /* _CPU_Initialize … … 45 47 /* 46 48 * _CPU_ISR_Get_level 47 *48 * NO_CPU Specific Information:49 *50 * XXX document implementation including references if appropriate51 49 */ 52 50 53 51 uint32_t _CPU_ISR_Get_level( void ) 54 52 { 55 /* 56 * This routine returns the current interrupt level. 57 */ 53 /* @todo Add EIC support. */ 54 uint32_t status = __builtin_rdctl(0); 55 return status & 1 ? 0 : 1; 56 } 58 57 59 return 0; 58 /* 59 * FIXME: Evaluate interrupt level. 60 */ 61 void _CPU_Context_Initialize( 62 Context_Control *the_context, 63 uint32_t *stack_base, 64 uint32_t size, 65 uint32_t new_level, 66 void *entry_point, 67 bool is_fp 68 ) 69 { 70 uint32_t stack = (uint32_t)stack_base + size - 4; 71 the_context->fp = stack; 72 the_context->sp = stack; 73 the_context->ra = (intptr_t) entry_point; 74 /* @todo Add EIC support. */ 75 the_context->status = new_level ? 0 : 1; 60 76 } 61 77 -
cpukit/score/cpu/nios2/cpu_asm.S
rb7ee9ab ra385489 71 71 ldw ea, 40(r5) 72 72 ldw at, 44(r5) 73 /* FIXME: Always have interrupts enabled when we return from Context_switch */74 ori at, at, 175 73 wrctl estatus, at 76 74 -
cpukit/score/cpu/nios2/irq.c
rb7ee9ab ra385489 35 35 register unsigned long *stack_ptr __asm__ ("sp"); 36 36 37 RTEMS_INLINE_ROUTINE void38 __Dipatch_interrupt_vector(uint32_t vector, proc_ptr pp)39 {40 if ( _ISR_Vector_table[ vector] )41 {42 (*_ISR_Vector_table[ vector ])(vector, pp);43 };44 }45 46 #if (RTEMS_NIOS_USE_ALT_HAL == TRUE)47 48 #include <bsp/alt/nios2.h>49 50 37 RTEMS_INLINE_ROUTINE void __IIC_Handler(void) 51 38 { … … 57 44 * Obtain from the interrupt controller a bit list of pending interrupts, 58 45 * and then process the highest priority interrupt. This process loops, 59 * loading the active interrupt list on each pass until alt_irq_pending()46 * loading the active interrupt list on each pass until ipending 60 47 * return zero. 61 48 * … … 67 54 */ 68 55 69 NIOS2_READ_IPENDING(active);56 _CPU_read_ipending (active); 70 57 71 58 while (active) … … 76 63 /* 77 64 * Test each bit in turn looking for an active interrupt. Once one is 78 * found, the interrupt handler asigned by a call to alt_irq_register() is 79 * called to clear the interrupt condition. 65 * found call it to clear the interrupt condition. 80 66 */ 81 67 … … 84 70 if (active & mask) 85 71 { 86 __Dipatch_interrupt_vector(vector, NULL); 72 if ( _ISR_Vector_table[ vector] ) 73 (*_ISR_Vector_table[ vector ])(vector, NULL); 87 74 active &= ~mask; 88 75 } … … 91 78 }; 92 79 93 NIOS2_READ_IPENDING(active);80 _CPU_read_ipending (active); 94 81 } 95 82 96 83 } 97 #endif98 84 99 #if (RTEMS_NIOS_USE_ALT_HAL == TRUE)100 85 void __ISR_Handler(void) 101 #else102 void __ISR_Handler(uint32_t vector, CPU_Interrupt_frame *ifr)103 #endif104 86 { 105 register uint32_t 87 register uint32_t level; 106 88 107 89 /* Interrupts are disabled upon entry to this Handler */ … … 119 101 _Thread_Dispatch_increment_disable_level(); 120 102 121 #if (RTEMS_NIOS_USE_ALT_HAL == TRUE)122 103 __IIC_Handler(); 123 #else124 __Dipatch_interrupt_vector(vector, ifr);125 #endif126 104 127 105 /* Make sure that interrupts are disabled again */ -
cpukit/score/cpu/nios2/nios2-iic-low-level.S
rb7ee9ab ra385489 232 232 stw ea, 72(sp) 233 233 234 #if REMOVED_BY_CCJ 234 235 /* 235 236 * Obtain a bitlist of the pending interrupts. … … 267 268 268 269 mov r5, sp 269 270 #endif 271 270 272 .extern __ISR_Handler 271 273 call __ISR_Handler -
cpukit/score/cpu/nios2/rtems/score/cpu.h
rb7ee9ab ra385489 190 190 #endif 191 191 192 /** 193 * @brief Read the ienable register. 194 */ 195 #define _CPU_read_ienable( value ) \ 196 do { value = __builtin_rdctl(3); } while (0) 197 198 /** 199 * @brief Write the ienable register. 200 */ 201 #define _CPU_write_ienable( value ) \ 202 do { __builtin_wrctl(3, value); } while (0) 203 204 /** 205 * @brief Read the ipending register. 206 */ 207 #define _CPU_read_ipending( value ) \ 208 do { value = __builtin_rdctl(4); } while (0) 209 210 /** 211 * Disable all interrupts for a critical section. The previous 212 * level is returned in _level. 213 */ 192 214 #define _CPU_ISR_Disable( _isr_cookie ) \ 193 215 do { \ … … 196 218 } while ( 0 ) 197 219 220 /** 221 * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). 222 * This indicates the end of a critical section. The parameter 223 * _level is not modified. 224 */ 198 225 #define _CPU_ISR_Enable( _isr_cookie ) \ 199 226 do { \ … … 201 228 } while ( 0 ) 202 229 230 /** 231 * This temporarily restores the interrupt to _level before immediately 232 * disabling them again. This is used to divide long critical 233 * sections into two or more parts. The parameter _level is not 234 * modified. 235 */ 203 236 #define _CPU_ISR_Flash( _isr_cookie ) \ 204 237 do { \ … … 207 240 } while ( 0 ) 208 241 209 #define _CPU_ISR_Set_level( new_level ) \ 242 /** 243 * Map interrupt level in task mode onto the hardware that the CPU 244 * actually provides. Currently, interrupt levels which do not 245 * map onto the CPU in a straight fashion are undefined. 246 */ 247 #define _CPU_ISR_Set_level( new_level ) \ 210 248 _CPU_ISR_Enable( new_level == 0 ? 1 : 0 ); 211 249 250 /** 251 * @brief Obtain the Current Interrupt Disable Level 252 * 253 * This method is invoked to return the current interrupt disable level. 254 * 255 * @return This method returns the current interrupt disable level. 256 */ 212 257 uint32_t _CPU_ISR_Get_level( void ); 213 258 214 /* 215 * FIXME: Evaluate interrupt level. 216 */ 217 #define _CPU_Context_Initialize( _the_context, _stack_base, _size, \ 218 _isr, _entry_point, _is_fp ) \ 219 do { \ 220 uint32_t _stack = (uint32_t)(_stack_base) + (_size) - 4; \ 221 (_the_context)->fp = (void *)_stack; \ 222 (_the_context)->sp = (void *)_stack; \ 223 (_the_context)->ra = (void *)(_entry_point); \ 224 (_the_context)->status = 0x1; /* IRQs enabled */ \ 225 } while ( 0 ) 259 /** 260 * Initialize the context to a state suitable for starting a 261 * task after a context restore operation. Generally, this 262 * involves: 263 * 264 * - setting a starting address 265 * - preparing the stack 266 * - preparing the stack and frame pointers 267 * - setting the proper interrupt level in the context 268 * - initializing the floating point context 269 * 270 * @param[in] the_context points to the context area 271 * @param[in] stack_base is the low address of the allocated stack area 272 * @param[in] size is the size of the stack area in bytes 273 * @param[in] new_level is the interrupt level for the task 274 * @param[in] entry_point is the task's entry point 275 * @param[in] is_fp is set to TRUE if the task is a floating point task 276 * 277 * @note Implemented as a subroutine for the NIOS2 port. 278 */ 279 void _CPU_Context_Initialize( 280 Context_Control *the_context, 281 uint32_t *stack_base, 282 uint32_t size, 283 uint32_t new_level, 284 void *entry_point, 285 bool is_fp 286 ); 226 287 227 288 #define _CPU_Context_Restart_self( _the_context ) \
Note: See TracChangeset
for help on using the changeset viewer.