Linux 内核时钟架构之时钟设备描述符

时钟设备是一种可编程设备,对其编程可产生中断。可以有定时中断,oneshot模式中断等。

/**  * struct clock_event_device - clock event device descriptor  * @event_handler: Assigned by the framework to be called by the low  *   level handler of the event source  * @set_next_event: set next event function using a clocksource delta  * @set_next_ktime: set next event function using a direct ktime value  * @next_event:  local storage for the next event in oneshot mode  * @max_delta_ns: maximum delta value in ns  * @min_delta_ns: minimum delta value in ns  * @mult:  nanosecond to cycles multiplier  * @shift:  nanoseconds to cycles divisor (power of two)  * @state_use_accessors:current state of the device, assigned by the core code  * @features:  features  * @retries:  number of forced programming retries  * @set_state_periodic: switch state to periodic  * @set_state_oneshot: switch state to oneshot  * @set_state_oneshot_stopped: switch state to oneshot_stopped  * @set_state_shutdown: switch state to shutdown  * @tick_resume: resume clkevt device  * @broadcast:  function to broadcast events  * @min_delta_ticks: minimum delta value in ticks stored for reconfiguration  * @max_delta_ticks: maximum delta value in ticks stored for reconfiguration  * @name:  ptr to clock event name  * @rating:  variable to rate clock event devices  * @irq:  IRQ number (only for non CPU local devices)  * @bound_on:  Bound on CPU  * @cpumask:  cpumask to indicate for which CPUs this device works  * @list:  list head for the management code  * @owner:  module reference  */ struct clock_event_device {  void   (*event_handler)(struct clock_event_device *);

上面这个句柄是此结构的关键,提供中断处理函数。  int   (*set_next_event)(unsigned long evt, struct clock_event_device *);

设置下一次中断到期时间。或者说是下一次到期的中断。  int   (*set_next_ktime)(ktime_t expires, struct clock_event_device *);  ktime_t   next_event;  u64   max_delta_ns;  u64   min_delta_ns;  u32   mult;  u32   shift;  enum clock_event_state state_use_accessors;  unsigned int  features;  unsigned long  retries;

 int   (*set_state_periodic)(struct clock_event_device *);  int   (*set_state_oneshot)(struct clock_event_device *);  int   (*set_state_oneshot_stopped)(struct clock_event_device *);  int   (*set_state_shutdown)(struct clock_event_device *);  int   (*tick_resume)(struct clock_event_device *);

 void   (*broadcast)(const struct cpumask *mask);  void   (*suspend)(struct clock_event_device *);  void   (*resume)(struct clock_event_device *);  unsigned long  min_delta_ticks;  unsigned long  max_delta_ticks;

 const char  *name;  int   rating;  int   irq;  int   bound_on;  const struct cpumask *cpumask;  struct list_head list;  struct module  *owner; } ____cacheline_aligned;

相关数据结构定义:
/* The registered clock event devices */
static LIST_HEAD(clockevent_devices);
static LIST_HEAD(clockevents_released);
/* Protection for the above */
static DEFINE_RAW_SPINLOCK(clockevents_lock);
/* Protection for unbind operations */
static DEFINE_MUTEX(clockevents_mutex);
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值