wiki:tim_driver

Version 5 (modified by alain, 10 years ago) (diff)

--

GIET-VM / TIM Driver

The tim_driver.c and tim_driver.h files define the TIM driver.

The vci_multi_timer component is a multi-channels timer controller. It is an external peripheral.

The total number of channels must be defined by the configuration parameter NB_TIM_CHANNELS in the hard_config.h file.

The user timers are allocated to applications by the GIET-VM in the boot phase, as defined in the mapping. The corresponding global index is stored in the context of the task.

The SEG_TIM_BASE address must be defined in the hard_config.h file.

The virtual base address of the associated segment is: vbase = SEG_TIM_BASE + cluster_io << 32.

The addressable registers map is defined here.

int _timer_start( unsigned int channel, unsigned int period )

This function activates a timer channel in the vci_timer component by writing in the proper register the period value.

  • channel : Timer channel global index
  • period : interrupt period (cycles)

Return 0 in case of success. Return -1 if timer index too large.

int _timer_stop( unsigned int channel )

This function desactivates a timer channel in the vci_timer component by writing in the proper register.

Return 0 in case of success. Return -1 if timer index too large.

int _timer_reset_irq( unsigned int channel )

This function can be used by the the _isr_timer() to acknowlege a timer interrupt in the vci_timer component by writing in the proper register.

Return 0 in case of success. Return -1 if timer index too large.

int _timer_reset_cpt( unsigned int cluster_xy, unsigned int local_id)

This function resets the timer counter, by re-writing the period in the proper register, what causes the count to restart. This function is called during a context switch (user or preemptive).

Return 0 in case of success. Return -1 if timer index too large.

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

This Interrupt Service Routine handles the IRQs generated by the "user" timers. It can be a HWI or a PTI. The channel argument is the timer global index. The ISR acknowledges the IRQ, registers the event in the proper entry of the _user_timer_event[] array, and a log message is displayed on TTY0.