| 1 | = GIET-VM / Interrupt Handler functions = |
| 2 | |
| 3 | |
| 4 | The [source:soft/giet_vm/giet_kernel/irq_handler.c irq_handler.c] and [source:soft/giet_vm/giet_kernel/irq_handler.h irq_handler.h] files define the kernel data structure and functions that are used to handle interrupts. They are prefixed by ''_'' to remind that they can only be executed by a processor in kernel mode. |
| 5 | |
| 6 | [[PageOutline]] |
| 7 | |
| 8 | There is three interrupt vectors per processor (stored in each processor's scheduler) for the three HWI, PTI, and WTI interrupts types. Each interrupt vector entry contains three bits fields: |
| 9 | ||isr_id ||bits[15:0] || defines the type of ISR to be executed || |
| 10 | ||channel_id ||bits[30:16] || defines the channel for multi-channels peripherals || |
| 11 | ||valid || bit 31 || valid interrupt vector entry || |
| 12 | |
| 13 | If the peripheral is replicated in clusters, the channel_id is a global index : |
| 14 | channel_id = cluster_xy * NB_CHANNELS_MAX + loc_id |
| 15 | |
| 16 | |
| 17 | === void _irq_demux() === |
| 18 | This function access the ICU or XCU component (Interrupt Controler Unit) to get the interrupt vector entry. There is one ICU or XICU component per cluster, and these components support several output IRQs (one output IRQ per processor in a given cluster). |
| 19 | It uses the [source:soft/giet_vm/giet_drivers/xcu_driver _xcu_get_index()] or [source:soft/giet_vm/giet_drivers/icu_driver_icu_get_index()] functions to get the IRQ type (HWI / PTI / WTI), and the index in the corresponding interrupt vector. |
| 20 | Any index value larger than 31 means "no active interrupt", and the default ISR is executed. |
| 21 | |
| 22 | All ISRs (but the default ISR) must have the |
| 23 | same three arguments : |
| 24 | * unsigned int irq_type, |
| 25 | * unsigned int irq_id, |
| 26 | * unsigned int channel |
| 27 | |
| 28 | As most ISRs (Interrupt Service Routine) are associated to a specific peripheral, these ISR are defined in the |
| 29 | [wiki:periphal_drivers drivers]. But the following ISRs are defined in the [source:soft/giet_vm/giet_kernel/irq_handler.c irq_handler.c] file: |
| 30 | |
| 31 | |
| 32 | === void _isr_wakup( unsigned int irq_type, unsigned int irq_id, unsigned int channel ) === |
| 33 | This ISR can only be executed after a WTI (IPI) awake an idle processor, or to force a context switch |
| 34 | on a remote processor. The context switch is only executed if the current task is the IDLE_TASK, or if the value written in the mailbox is non zero. |
| 35 | |
| 36 | === '''void _isr_tick'''( unsigned int irq_type, unsigned int irq_id, unsigned int channel ) === |
| 37 | This ISR is in charge of context switch, and handles the IRQs generated by |
| 38 | // the "system" timers. It can be PTI in case of XCU, or it can be HWI generated |
| 39 | // by an external timer in case of ICU. |
| 40 | // The ISR acknowledges the IRQ, and calls the _ctx_switch() function. |
| 41 | |
| 42 | === void _isr_default() === |
| 43 | This default ISR is called when the interrupt handler is called, and there is no active IRQ. It simply displays a warning message on the kernel TTY[0]. |