os_sys.int_nest_cnt++;
- // Save info for preempted pcb
- preempted_pcb = get_curr_pcb();
- preempted_pcb->stack.curr = stack;
- preempted_pcb->state = ST_READY;
- OS_DEBUG(D_TASK,"Preempted %s\n",preempted_pcb->name);
-
- Os_StackPerformCheck(preempted_pcb);
+ /* Check if we interrupted a task or ISR */
+ if( os_sys.int_nest_cnt == 1 ) {
+ /* We interrupted a task */
+ POSTTASKHOOK();
- POSTTASKHOOK();
+ /* Save info for preempted pcb */
+ pPtr = get_curr_pcb();
+ pPtr->stack.curr = stack;
+ pPtr->state = ST_READY;
+ OS_DEBUG(D_TASK,"Preempted %s\n",pPtr->name);
- pcb = (struct OsPcb *)pcb_p;
- pcb->state = ST_RUNNING;
- set_curr_pcb(pcb);
+ Os_StackPerformCheck(pPtr);
+ } else {
+ /* We interrupted an ISR */
+ }
- PRETASKHOOK();
+ /* Grab the ISR "pcb" */
+ isrPtr = (struct OsPcb *)isr_p;
+ isrPtr->state = ST_RUNNING;
- // We should not get here if we're NON
- if( pcb->scheduling == NON) {
- // TODO:
- // assert(0);
- while(1);
+ if( isrPtr->proc_type & ( PROC_EXTENDED | PROC_BASIC ) ) {
+ assert(0);
}
+ Irq_SOI();
+
#ifndef CFG_HCS12D
Irq_Enable();
- pcb->entry();
+ isrPtr->entry();
Irq_Disable();
#else
- pcb->entry();
+ isrPtr->entry();
#endif
+ /* Check so that ISR2 haven't disabled the interrupts */
/** @req OS368 */
if( Os_IrqAnyDisabled() ) {
Os_IrqClearAll();