1. 时钟源时钟源其实只是为了提供一个单调递增的时钟函数- struct clocksource {
-
/*
-
* First part of structure is read mostly
-
*/
-
char *name;
-
struct list_head list;
-
int rating; // 表明时钟源的能力,值越大表示精度越高
-
cycle_t (*read)(struct clocksource *cs); // 获取计数值
-
int (*enable)(struct clocksource *cs);
-
void (*disable)(struct clocksource *cs);
-
cycle_t mask; // 由于cycle_t是一个64bit的值,该mask表明多少bit是有效的
-
u32 mult; // 和下面的shift将cycle值转换为ns, 计算方式为: (cycle * mult)/2^shift = x ns
-
u32 shift;
-
u64 max_idle_ns;
-
unsigned long flags;
-
cycle_t (*vread)(void);
-
void (*suspend)(struct clocksource *cs);
-
void (*resume)(struct clocksource *cs);
-
#ifdef CONFIG_IA64
-
void *fsys_mmio; /* used by fsyscall asm code */
-
#define CLKSRC_FSYS_MMIO_SET(mmio, addr) ((mmio) = (addr))
-
#else
-
#define CLKSRC_FSYS_MMIO_SET(mmio, addr) do { } while (0)
-
#endif
-
-
/*
-
* Second part is written at each timer interrupt
-
* Keep it in a different cache line to dirty no
-
* more than one cache line.
-
*/
-
cycle_t cycle_last ____cacheline_aligned_in_smp;
-
-
#ifdef CONFIG_CLOCKSOURCE_WATCHDOG
-
/* Watchdog related data, used by the framework */
-
struct list_head wd_list;
-
cycle_t wd_last;
-
#endif
-
};
2. 时钟事件设备- struct clock_event_device {
-
const char *name;
-
unsigned int features;
-
u64 max_delta_ns;
-
u64 min_delta_ns;
-
u32 mult;
-
u32 shift;
-
int rating;
-
int irq; // 对应的中断号,区分多核和单核的情况
-
const struct cpumask *cpumask;
-
int (*set_next_event)(unsigned long evt,
-
struct clock_event_device *);
-
void (*set_mode)(enum clock_event_mode mode,
-
struct clock_event_device *); // 设置模式
-
void (*event_handler)(struct clock_event_device *);
-
void (*broadcast)(const struct cpumask *mask);
-
struct list_head list;
-
enum clock_event_mode mode;
-
ktime_t next_event;
-
unsigned long retries;
-
};
需要注意的是,其实这2个概念并无联系,而是两个独立的概念,没有任何关系,只是实现时候一般一个硬件会同时提供这两种机制,内核中,对于
clock_event_device的使用其实更多一些.
阅读(1642) | 评论(1) | 转发(0) |