src/C/softirq.c
static void softirq_handler_user_isr(softirq_t * sfq)
{
    static e_task_id    previous_isr_owner  = ID_UNUSED;
    task_t             *task            = sfq->caller;
    uint8_t             irq             = sfq->irqnum;
    physaddr_t          isr_params[4]   = { 0, 0, 0, 0 };
    e_device_id         dev_id;

    isr_params[0] = sfq->handler;
    isr_params[1] = (uint8_t) (irq - 16); /* IRQ num for NVIC starts with 0 */
    isr_params[2] = sfq->status;
    isr_params[3] = sfq->data;


    // FIXME: DMA device has to be mapped in IRQ context; dma is not a device_t

    dev_id = get_device_from_interrupt(irq);
    if (dev_id != ID_DEV_UNUSED) {
        task->ctx[TASK_MODE_ISRTHREAD].dev_id = dev_id;
    }
    else {
        task->ctx[TASK_MODE_ISRTHREAD].dev_id = ID_DEV_UNUSED;
    }

    task->ctx[TASK_MODE_ISRTHREAD].irq = dev_get_irqinfo_from_irq(irq);

    /* Creating the fake stack for ISR handler and create the initial frame */
    if (sfq->caller->id != previous_isr_owner) {
        /* Zeroing the stack only if previous ISR belongs to another task */
        memset((char *)STACK_TOP_ISR - STACK_SIZE_ISR, 0, STACK_SIZE_ISR);
        previous_isr_owner = sfq->caller->id;
    }

    task->ctx[TASK_MODE_ISRTHREAD].frame = (stack_frame_t *) STACK_TOP_ISR;

    /*
     * The schedule will execute 'task->ctx[TASK_MODE_ISRTHREAD].fn' that
     * is for every tasks 'libs/libstd/arch/cores/armv7-m/m4_syscall.c:
     * do_startisr()' function. That function is a wrapper that take
     * several parameters:
     *   isr_params[0]: user handler to execute
     *   isr_params[1]: irq
     *   isr_params[2]: status
     *   isr_params[3]: data
     */
    task_create_stack(&task->ctx[TASK_MODE_ISRTHREAD], STACK_TOP_ISR,
                      (uint32_t) task->ctx[TASK_MODE_ISRTHREAD].fn,
                      isr_params);

    task->mode = TASK_MODE_ISRTHREAD;
    task->state[TASK_MODE_ISRTHREAD] = TASK_STATE_RUNNABLE;

    full_memory_barrier();
}
/*
 * This function prepare execution of the user ISR handler in user mode (with
 * PSP stack). When PendSV will request the scheduler, ISRTHREAD mode tasks
 * will be scheduled with the highest priority (note: it can
 * be preempted by any IRQ).
 */
This function prepare execution of the user ISR handler in user mode (with
PSP stack). When PendSV will request the scheduler, ISRTHREAD mode tasks
will be scheduled with the highest priority (note: it can
be preempted by any IRQ).
This function prepare execution of the user ISR handler in user mode ( with PSP stack ) . When PendSV will request the scheduler ISRTHREAD mode tasks will be scheduled with the highest priority ( note : it can be preempted by any IRQ ) .
static void softirq_handler_user_isr(softirq_t * sfq)
{
    static e_task_id    previous_isr_owner  = ID_UNUSED;
    task_t             *task            = sfq->caller;
    uint8_t             irq             = sfq->irqnum;
    physaddr_t          isr_params[4]   = { 0, 0, 0, 0 };
    e_device_id         dev_id;
    isr_params[0] = sfq->handler;
    isr_params[1] = (uint8_t) (irq - 16); 
    isr_params[2] = sfq->status;
    isr_params[3] = sfq->data;
    dev_id = get_device_from_interrupt(irq);
    if (dev_id != ID_DEV_UNUSED) {
        task->ctx[TASK_MODE_ISRTHREAD].dev_id = dev_id;
    }
    else {
        task->ctx[TASK_MODE_ISRTHREAD].dev_id = ID_DEV_UNUSED;
    }
    task->ctx[TASK_MODE_ISRTHREAD].irq = dev_get_irqinfo_from_irq(irq);
    if (sfq->caller->id != previous_isr_owner) {
        memset((char *)STACK_TOP_ISR - STACK_SIZE_ISR, 0, STACK_SIZE_ISR);
        previous_isr_owner = sfq->caller->id;
    }
    task->ctx[TASK_MODE_ISRTHREAD].frame = (stack_frame_t *) STACK_TOP_ISR;
    task_create_stack(&task->ctx[TASK_MODE_ISRTHREAD], STACK_TOP_ISR,
                      (uint32_t) task->ctx[TASK_MODE_ISRTHREAD].fn,
                      isr_params);
    task->mode = TASK_MODE_ISRTHREAD;
    task->state[TASK_MODE_ISRTHREAD] = TASK_STATE_RUNNABLE;
    full_memory_barrier();
}
static void softirq_handler_user_isr ( softirq_t * sfq ) { static e_task_id previous_isr_owner = ID_UNUSED ; task_t * task = sfq -> caller ; uint8_t irq = sfq -> irqnum ; physaddr_t isr_params [ 4 ] = { 0 , 0 , 0 , 0 } ; e_device_id dev_id ; isr_params [ 0 ] = sfq -> handler ; isr_params [ 1 ] = ( uint8_t ) ( irq - 16 ) ; isr_params [ 2 ] = sfq -> status ; isr_params [ 3 ] = sfq -> data ; dev_id = get_device_from_interrupt ( irq ) ; if ( dev_id != ID_DEV_UNUSED ) { task -> ctx [ TASK_MODE_ISRTHREAD ] . dev_id = dev_id ; } else { task -> ctx [ TASK_MODE_ISRTHREAD ] . dev_id = ID_DEV_UNUSED ; } task -> ctx [ TASK_MODE_ISRTHREAD ] . irq = dev_get_irqinfo_from_irq ( irq ) ; if ( sfq -> caller -> id != previous_isr_owner ) { memset ( ( char * ) STACK_TOP_ISR - STACK_SIZE_ISR , 0 , STACK_SIZE_ISR ) ; previous_isr_owner = sfq -> caller -> id ; } task -> ctx [ TASK_MODE_ISRTHREAD ] . frame = ( stack_frame_t * ) STACK_TOP_ISR ; task_create_stack ( & task -> ctx [ TASK_MODE_ISRTHREAD ] , STACK_TOP_ISR , ( uint32_t ) task -> ctx [ TASK_MODE_ISRTHREAD ] . fn , isr_params ) ; task -> mode = TASK_MODE_ISRTHREAD ; task -> state [ TASK_MODE_ISRTHREAD ] = TASK_STATE_RUNNABLE ; full_memory_barrier ( ) ; }
This function prepare execution of the user ISR handler in user mode (with
 PSP stack).
This function prepare execution of the user ISR handler in user mode ( with PSP stack ) .
/* IRQ num for NVIC starts with 0 */ // FIXME: DMA device has to be mapped in IRQ context; dma is not a device_t /* Creating the fake stack for ISR handler and create the initial frame */ /* Zeroing the stack only if previous ISR belongs to another task */ /*
     * The schedule will execute 'task->ctx[TASK_MODE_ISRTHREAD].fn' that
     * is for every tasks 'libs/libstd/arch/cores/armv7-m/m4_syscall.c:
     * do_startisr()' function. That function is a wrapper that take
     * several parameters:
     *   isr_params[0]: user handler to execute
     *   isr_params[1]: irq
     *   isr_params[2]: status
     *   isr_params[3]: data
     */