Timer Interrupt Handler

Adam Lackorzynski adam at os.inf.tu-dresden.de
Thu Jul 17 23:20:54 CEST 2014


On Wed Jul 16, 2014 at 15:10:29 +0200, Xavier LEBARS wrote:
> I'm always trying to configure the timer for my Zedboard and the system
> clock doesn't advance. I checked this in the Timer::system_clock()
> function
> 
>  
> 
> In order to construct my timer driver, I use mptimer option, so I
> configured the private timer of my board in the file
> timer-arm-mptimer.cpp. Private Timers call the function interval() which
> use the global timer of the board  (bsp/zynq/ timer-arm-mptimer-zynq.cpp
> file) Here is a part of the implementation of my global timer (I just
> launch counter) : 
> 
>  
> 
>   Mmio_register_block t(Kmem::mmio_remap(Mem_layout::Gpt_phys_base));
> 
>  
> 
>   t.write<Mword>(0, GPT_CR);
> 
>   t.write<Mword>(0, GPT_CNT0);
> 
>   t.write<Mword>(0, GPT_CNT1);
> 
>  
> 
>   t.modify<Mword>(GPT_CR_EN, 0, GPT_CR);
> 
>  
> 
>   Mword vc = start_as_counter();
> 
>   while (t.read<Mword>(GPT_CNT0) < Gpt_ticks)
> 
>     ;
> 
>   
> 
>   Mword interval = (vc - stop_counter()) / Ticks; 
> 
>   t.write<Mword>(0, GPT_CR);
> 
>   return interval;

Is this calculating a proper interval value? For a start you can also
just return a fixed value.

> The private timers are bind to the GIC with the IRQ 27, so I mentioned
> this value in the static unsigned irq() function.

Why 27 and not 29?
 
> GIC is initialized in the bsp/zynq/pic-arm-zynq.cpp file (similar to the
> iMX6 architecture)
> 
> Pic::init()
> {
>   typedef Irq_mgr_multi_chip<Gic_sz> M;
>   M *m = new Boot_object<M>(1);
>   gic.construct(Kmem::mmio_remap(Mem_layout::Gic_cpu_phys_base),
>                 Kmem::mmio_remap(Mem_layout::Gic_dist_phys_base));
>   m->add_chip(0, gic, gic->nr_irqs());
>   Irq_mgr::mgr = m;
> }

This looks fine.

> To finish I saw timer_tick class. It seems to be a good way to update
> system clock because there are interrupts handler which call the
> update_system_clock function. So I added a call to  the
> Timer_tick::setup() function in my startup-arm.cpp file after timer
> initialization. But when I boot the sytem I obtain the following message

I do not think you need to add anything there.

> Panic - Could not allocate scheduling IRQ 27
> 
> The origin of this problem is the allocate_irq() function 
> 
> So do I have to modify something in my IRQ manager or did I forget one
> step during the construction of my timer driver ? Thanks in advance

For the mptimer it should just work given a proper interval() value.
So does the mptimer tick, i.e. reading the counter register multiple
times gives a changing value everytime? Regarding the interrupt number,
timer-arm-mptimer.cpp already has it defined.



Adam
-- 
Adam                 adam at os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/




More information about the l4-hackers mailing list