= GIET-VM / XCU Driver = [[PageOutline]] The [source:soft/giet_vm/giet_drivers/xcu_driver.c xcu_driver.c] and [source:soft/giet_vm/giet_drivers/xcu_driver.h xcu_driver.h] files define the XCU driver. The ''vci_xcu'' component is an extended interrupt controller, available in the SoCLib components library, and supporting three types of interrupts: * '''HWI''' : Hardware Interrupts (from hardware peripherals) * '''PTI''' : Programmable Timer Interrupts (contained in the XCU component) * '''WTI''' : Write Trigered Interrupts (from software, or from a PIC controller) The GIET-VM uses three 32 entries interrupt vectors (one interrupt vector for each interrupt type). The CXU component is a replicated peripheral: it must exist one XCU per cluster, and each one can contain several channels: The number of XICU channels is equal to NB_PROCS_MAX, because there is one private XCU channel per processor in a cluster. The virtual base address of the segment associated to the component is: vbase = SEG_XCU_BASE + cluster_xy * PERI_CLUSTER_INCREMENT The SEG_XCU_BASE and PERI_CLUSTER_INCREMENT values must be defined in the hard_config.h file. The addressable registers map is defined [source:soft/giet_vm/giet_drivers/xcu_driver.h here]. === void '''_xcu_set_mask'''( unsigned int cluster_xy, unsigned int channel, unsigned int mask, unsigned int irq_type ) === This function set the mask register for the IRQ type defined by "irq_type", and for the channel identified by the "cluster_xy" and "channel" arguments. All '1' bits are set / all '0' bits are not modified. === void '''_xcu_get_index'''( unsigned int cluster_xy, unsigned int channel, unsigned int * index, unsigned int * irq_type ) === This function returns the index and the type of the highest priority active interrupt: 1. active PTI (Timer Interrupt), 2. active HWI (Hardware Interrupt), 3. active WTI (Software Interrupt) === void '''_xcu_send_wti'''( unsigned int cluster_xy, unsigned int wti_index, unsigned int wdata ) === This function writes the ''wdata'' value in the mailbox defined by the ''cluster_xy'' and ''wti_inde'' arguments. === void '''_xcu_get_wti_value'''( unsigned int cluster_xy, unsigned int wti_index, unsigned int * value ) === This function returns the value contained in a WTI mailbox defined by the ''cluster_xy'' and ''wti_index'' arguments. This value is written in the ''value'' argument, and the corresponding WTI is acknowledged. === void '''_xcu_get_wti_address'''( unsigned int wti_index, unsigned int * address ) === This function returns the physical address of the WTI mailbox in cluster [0][0], defined by the ''wti_index'' argument, in the ''address'' argument. It is used by the GIET to configurate the IOPIC component. There is no access to a specific XCU component in a specific cluster. === void '''_xcu_timer_start'''( unsigned int cluster_xy, unsigned int pti_index, unsigned int period ) === This function activates a timer contained in XCU by writing in the proper register the period value. === void '''_xcu_timer_stop'''( unsigned int cluster_xy, unsigned int pti_index ) == This function desactivates a timer in XCU component by writing in the proper register. === unsigned int '''_xcu_timer_reset_irq'''( unsigned int cluster_xy, unsigned int pti_index ) === This function acknowlegge a timer interrupt in XCU component by reading in the proper XCU register. It is used by both the isr_switch() for a system timer, or by the _isr_timer() for an user timer. === void '''_xcu_timer_reset_cpt'''( unsigned int cluster_xy, unsigned int pti_index ) === This function resets a timer counter. To do so, it read in the TIMER_PERIOD register, and rewrite the same value in the same register, what causes the count to restart. This function is called during a context switch (user or preemptive).