wiki:kernel_interrupts

Version 9 (modified by alain, 9 years ago) (diff)

--

GIET-VM / Interrupt Handler

The irq_handler.c and 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.

The GIET_VM interrupt handler supports only the SOCLIB XCU interrupt controler. In a multi-cluster architectures, it must exist one XCU controller in all clusters containing processors.

Each multi-channel XCU component in a given cluster must contain (NB_PROCS_MAX * IRQ_PER_PROCESSOR) channels (one channel = one XCU output IRQ).

There is three interrupt vectors per processor (stored in each processor's scheduler) for the three interrupts types: HWI (Hardware Interrupt), PTI (Programmable Timer Interrupt), and WTI (Write Triggered Interrupt). Each interrupt vector entry contains two fields:

isr_id bits[15:0] defines the type of ISR to be executed
channel_id bits[31:16] defines the channel for multi-channels ISR

Regarding the allocation of interrupts to processors (IRQ routing using the XCU_MASK registers), the GIET-VM implement the following policy:

  • The GIET-VM uses only one XCU output IRQ per processor (index = lpid * IRQ_PER_PROCESSOR), even if the hardware platform contains more than one IRQ_PER_PROCESSOR.
  • In each cluster the HWI (hardwareinterrupts generated by the local peripherals) are statically allocated to local processors.
  • In each cluster, one PTI (timer interrupt) is statically allocated to each processor for TICK context switch.
  • In each cluster, 4 WTI (mailbox interrupts) are allocated to each processor. For each processor, the first WTI mailbox is statically allocated to WAKUP (inter processor interrupt). The three other WTI mailbox are dynamically allocated to external IRQS generated by the external peripherals through the IOPIC component.

All XCU masks for all processors are statically defined in the boot phase.

Functions used for all HWI / PTI / WTI interrupts

void _irq_demux()

This function access the XCU component to get the interrupt vector entry: It uses the _xcu_get_index() functions to get the IRQ type ( HWI / PTI / WTI ), and the index in the corresponding interrupt vector. Any index value larger than 31 means "no active interrupt", and the default ISR is executed.

All ISRs (but the default ISR) must have the same three arguments :

  • unsigned int irq_type,
  • unsigned int irq_id,
  • unsigned int channel

As most ISRs (Interrupt Service Routine) are associated to a specific peripheral, these ISR are defined in the drivers?. But the following ISRs are defined in the irq_handler.c file:

void _isr_wakup( unsigned int irq_type, unsigned int irq_id, unsigned int channel )

This ISR can only be executed after a WTI (IPI) awake an idle processor, or to force a context switch 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.

void _isr_tick( unsigned int irq_type, unsigned int irq_id, unsigned int channel )

This ISR is in charge of context switch, and handles the IRQs generated by the "system" timers. It can be PTI in case of XCU, or it can be HWI generated by an external timer in case of ICU. The ISR acknowledges the IRQ, and calls the _ctx_switch() function.

void _isr_default()

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].

Functions used for dynamic allocation of external IRQs

void _ext_irq_init()

This function is only used when the architecture contains an external IOPIC component. It initializes the _ext_irq_index[isr][channel] array, defining the IRQ index associated to (isr_type/isr_channel) couple, as specified in the mapping. This array is used by the kernel for dynamic routing of an external IRQ signaling completion to the processor that launched the I/O operation.

void _ext_irq_alloc( unsigned int isr_type , unsigned int isr_channel , unsigned int* wti_index )

This function is used when the architecture contains an external IOPIC component. It dynamically routes an external IRQ signaling completion of an I/O operation to the processor P[x,y,p] running the calling task. The two (isr_type, isr_channel) arguments define actually the external IRQ to be routed.

  • isr_type : type of ISR to be executed
  • isr_channel : ISR channel (for multi-channels peripherals)
  • wti_index : return value defining the index of the WTI mailbox allocated to P[x,y,p]

This function does three things:

  1. it allocates a WTI mailbox in the XCU of cluster[x,y] to the requesting processor ( index is in [4*p+1, 4*p+2, 4*p+3] ) ;
  2. it initialises the IOPIC entry associated to the (isr_type/isr_channel) IRQ.
  3. it initializes the proper entry in the WTI interrupt vector associated to processor P[x,y,p].

void _ext_irq_release( unsigned int isr_type , unsigned int isr_channel , unsigned int* wti_index )

This function is used when the architecture contains an external IOPIC component. It desallocates the ressources allocated by the previous _ext_irq_alloc() function to the calling processor. The two (isr_type, isr_channel) arguments define actually the external IRQ to be released.

  • isr_type : type of ISR to be executed
  • isr_channel : ISR channel (for multi-channels peripherals)
  • wti_index : index of the WTI mailbox allocated to P[x,y,p]

This function does only two things:

  1. it desactivates the PIC entry associated to the (isr_type/isr_channel) IRQ.
  2. it releases the WTI mailbox allocated to P[x,y,p].
  3. The WTI interrupt vector is NOT modified