Hardware abstraction
Every system has at least one clock counter. As with any hardware device in a machine, this counter too is represented and managed by a structure. Hardware abstraction is provided by struct clocksource
, defined in the include/linux/clocksource.h
header file. This structure provides callbacks to access and handle power management on the counter through the read
, enable
, disable
, suspend
, and resume
routines:
structclocksource{u64(*read)(structclocksource*cs);u64mask;u32mult;u32shift;u64max_idle_ns;u32maxadj;#ifdef CONFIG_ARCH_CLOCKSOURCE_DATAstructarch_clocksource_dataarchdata;#endifu64max_cycles;constchar*name;structlist_headlist;intrating;int(*enable)(structclocksource*cs);void(*disable)(structclocksource*cs);unsignedlongflags;void(*suspend)(structclocksource*cs);void(*resume)(structclocksource*cs);void(*mark_unstable)(structclocksource*cs);void(*tick_stable)(structclocksource*cs);/* private: */#ifdef CONFIG_CLOCKSOURCE_WATCHDOG/* Watchdog related data, used by the framework...