Setup linux timer for tick/jiffies

来源:互联网 发布:linux 文本文件忙 编辑:程序博客网 时间:2024/05/23 01:37

1. timer is configured at ba_set_mode() function CLOCK_EVT_MODE_PERIODIC switch(file:arch/ba/kernel/time.c):
  mtspr(SPR_TTMR,SPR_TTMR_IE|SPR_TTMR_RT|(LATCH&SPR_TTMR_PERIOD));
  LATCH is the clock tick rate, which is defined as
   #define LATCH  ((CLOCK_TICK_RATE + HZ/2) / HZ) // For divider defined in include/linux/jiffies.h:
   #define CLOCK_TICK_RATE (CONFIG_BA_CPU_CLK*1000000) //here CLOCK_TICK_RATE should use CPU clock, not system clock,defined in arch/ba/include/asm/timerx.h

2. ba_set_mode() is assigned to .set_mode pointer of struct clock_event_device. it is called by clockevents_set_mode() in kernel/time/clockevents.c

3. timer_init calling procedure: 
   timer_init()(arch/ba/kernel/time.c)
 ->clockevents_register_device()(kernel/time/clockevents.c)
  ->clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev);(kernel/time/clockevents.c)
   ->raw_notifier_call_chain(&clockevents_chain, reason, dev);(kernel/notifier.c)
    -> __raw_notifier_call_chain(nh, val, v, -1, NULL);(kernel/notifier.c)
     ->notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls);(kernel/notifier.c)
      ->tick_notify()(kernel/time/tick-common.c, tick_notify is assigned to notifier_call pointer of struct notifiel_block);
       ->tick_check_new_device(dev);(kernel/time/tick-common.c)
        ->tick_setup_device();(kernel/time/tick-common.c)
         ->tick_setup_periodic(newdev, 0);(kernel/time/tick-common.c)
          ->clockevents_set_mode(dev, CLOCK_EVT_MODE_PERIODIC);

原创粉丝点击