Ejemplo n.º 1
0
/*!
 * \brief This function sets up the FLOATING POINT context of a new task descriptor.
 * 
 * \param[in] td_ptr the address of the task descriptor
 */
bool _psp_build_float_context
   (
      /* [IN] the address of the task descriptor */
      TD_STRUCT_PTR    td_ptr
   )
{
    PSP_BLOCKED_FP_STRUCT_PTR fp_ptr;

    /* Allocate space for saving/restoring the DSP registers */
    fp_ptr = (PSP_BLOCKED_FP_STRUCT_PTR)_mem_alloc_zero((_mem_size)sizeof(PSP_BLOCKED_FP_STRUCT));

#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
    if (!fp_ptr) {
        /* Couldn't allocate memory for the DSP register context */
        _task_set_error_td_internal(td_ptr, MQX_OUT_OF_MEMORY);
        return FALSE;
    }
#endif

    _mem_set_type(fp_ptr, MEM_TYPE_FP_CONTEXT);
    /*
    ** Transfer the block to the task being created. This will ensure the
    ** float context will be freed if the task is destroyed.
    */
    _mem_transfer_internal((void *)fp_ptr, td_ptr);

    /* This field should never be overwitten */
    fp_ptr->TID = td_ptr->TASK_ID;

    td_ptr->FLOAT_CONTEXT_PTR = (void *)fp_ptr;

    return TRUE;
}
Ejemplo n.º 2
0
void _int_default_isr
   (
      /* [IN] the parameter passed to the ISR by the kernel */
      pointer vector_number
   )
{ /* Body */
   KERNEL_DATA_STRUCT_PTR kernel_data;
   TD_STRUCT_PTR          td_ptr;

   _GET_KERNEL_DATA(kernel_data);

   td_ptr = kernel_data->ACTIVE_PTR;
   _KLOGE5(KLOG_int_default_isr, td_ptr, vector_number, 
      &vector_number, vector_number);

   _int_disable();
   if (td_ptr->STATE != UNHANDLED_INT_BLOCKED) {
      td_ptr->STATE = UNHANDLED_INT_BLOCKED;
      td_ptr->INFO  = (_mqx_uint)vector_number;
      _task_set_error_td_internal(td_ptr, MQX_UNHANDLED_INTERRUPT);
      _QUEUE_UNLINK(td_ptr);
   } /* Endif */
   _int_enable();

} /* Endbody */
Ejemplo n.º 3
0
/*!
 * \brief An MQX-provided default ISR for unhandled interrupts. The function
 * depends on the PSP.
 *
 * The function changes the state of the active task to UNHANDLED_INT_BLOCKED and
 * blocks the task.
 * \n The function uses the default I/O channel to display at least:
 * \li Vector number that caused the unhandled exception.
 * \li Task ID and task descriptor of the active task.
 *
 * \n Depending on the PSP, more information might be displayed.
 *
 * \param[in] parameter Parameter passed to the default ISR.
 *
 * \note
 * Since the ISR uses printf() to display information to the default I/O channel,
 * default I/O must not be on a channel that uses interrupt-driven I/O or the
 * debugger.
 * \warning Blocks the active task.
 *
 * \see _int_install_unexpected_isr
 */
void _int_unexpected_isr
   (
      pointer parameter
   )
{ /* Body */
   KERNEL_DATA_STRUCT_PTR            kernel_data;
   PSP_BASIC_INT_FRAME_STRUCT_PTR    basic_frame_ptr;
   PSP_INTERRUPT_FRAME_STRUCT_PTR    frame_ptr;
   TD_STRUCT_PTR                     td_ptr;
   volatile uint_32                           vector, offset;

   _GET_KERNEL_DATA(kernel_data);
   td_ptr      = kernel_data->ACTIVE_PTR;

   if (kernel_data->IN_ISR == 1) {
      /* Get the pointer to the data stored on the task stack */
      basic_frame_ptr = (pointer)td_ptr->STACK_PTR;
   } else {
      frame_ptr = (PSP_INTERRUPT_FRAME_STRUCT_PTR)&parameter;
      basic_frame_ptr = &frame_ptr->BASIC_FRAME;
   }/* Endif */

   vector = PSP_FAV_GET_VECTOR_NUMBER(basic_frame_ptr->FRAME.FORMAT_AND_VECTOR);
   offset = PSP_FAV_GET_VECTOR_OFFSET(basic_frame_ptr->FRAME.FORMAT_AND_VECTOR);

   printf( "\n*** UNHANDLED INTERRUPT ***\n");
   printf( "Vector #: %d  0x%x\n\r",vector,vector);
   printf( "Offset  : %d  0x%x\n\r",offset,offset);
   printf( "Task Id: 0x%0x Td_ptr 0x%x Stack Frame: 0x%x\n\r",
      td_ptr->TASK_ID, td_ptr, basic_frame_ptr);

   printf( "Interrupt_nesting level: %d   PC: 0x%08x   SR: 0x%04x\n\r",
      kernel_data->IN_ISR,
      basic_frame_ptr->FRAME.RETURN_ADDRESS,
      basic_frame_ptr->FRAME.STATUS_REGISTER );

   td_ptr->STATE = UNHANDLED_INT_BLOCKED;
   _task_set_error_td_internal(td_ptr, MQX_UNHANDLED_INTERRUPT);

   kernel_data->IN_ISR = 0;
   _task_block();

} /* Endbody */