Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Functions
clocksource.h File Reference
#include <linux/types.h>
#include <linux/timex.h>
#include <linux/time.h>
#include <linux/list.h>
#include <linux/cache.h>
#include <linux/timer.h>
#include <linux/init.h>
#include <asm/div64.h>
#include <asm/io.h>

Go to the source code of this file.

Data Structures

struct  cyclecounter
 
struct  timecounter
 
struct  clocksource
 

Typedefs

typedef u64 cycle_t
 

Functions

void timecounter_init (struct timecounter *tc, const struct cyclecounter *cc, u64 start_tstamp)
 
u64 timecounter_read (struct timecounter *tc)
 
u64 timecounter_cyc2time (struct timecounter *tc, cycle_t cycle_tstamp)
 

: ptr to clocksource name

struct clocksource - hardware abstraction for a free running counter Provides mostly state-free accessors to the underlying hardware. This is the structure used for system time.

: list head for registration : rating value for selection (higher is better) To avoid rating inflation the following list should give you a guide as to how to assign your clocksource a rating 1-99: Unfit for real use Only available for bootup and testing purposes. 100-199: Base level usability. Functional for real use, but not desired. 200-299: Good. A correct and usable clocksource. 300-399: Desired. A reasonably fast and accurate clocksource. 400-499: Perfect The ideal clocksource. A must-use where available. : returns a cycle value, passes clocksource as argument : optional function to enable the clocksource : optional function to disable the clocksource : bitmask for two's complement subtraction of non 64 bit counters : cycle to nanosecond multiplier : cycle to nanosecond divisor (power of two) : max idle time permitted by the clocksource (nsecs) : maximum adjustment value to mult (~11%) : flags describing special properties : arch-specific data : suspend function for the clocksource, if necessary : resume function for the clocksource, if necessary : most recent cycle counter value seen by read()

#define CLOCK_SOURCE_IS_CONTINUOUS   0x01
 
#define CLOCK_SOURCE_MUST_VERIFY   0x02
 
#define CLOCK_SOURCE_WATCHDOG   0x10
 
#define CLOCK_SOURCE_VALID_FOR_HRES   0x20
 
#define CLOCK_SOURCE_UNSTABLE   0x40
 
#define CLOCKSOURCE_MASK(bits)   (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
 
struct clocksource ____cacheline_aligned
 
int clocksource_register (struct clocksource *)
 
void clocksource_unregister (struct clocksource *)
 
void clocksource_touch_watchdog (void)
 
struct clocksourceclocksource_get_next (void)
 
void clocksource_change_rating (struct clocksource *cs, int rating)
 
void clocksource_suspend (void)
 
void clocksource_resume (void)
 
struct clocksource *__init __weak clocksource_default_clock (void)
 
void clocksource_mark_unstable (struct clocksource *cs)
 
void clocks_calc_mult_shift (u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec)
 
int __clocksource_register_scale (struct clocksource *cs, u32 scale, u32 freq)
 
void __clocksource_updatefreq_scale (struct clocksource *cs, u32 scale, u32 freq)
 
void timekeeping_notify (struct clocksource *clock)
 
cycle_t clocksource_mmio_readl_up (struct clocksource *)
 
cycle_t clocksource_mmio_readl_down (struct clocksource *)
 
cycle_t clocksource_mmio_readw_up (struct clocksource *)
 
cycle_t clocksource_mmio_readw_down (struct clocksource *)
 
int clocksource_mmio_init (void __iomem *, const char *, unsigned long, int, unsigned, cycle_t(*)(struct clocksource *))
 
int clocksource_i8253_init (void)
 

Macro Definition Documentation

#define CLOCK_SOURCE_IS_CONTINUOUS   0x01

Definition at line 203 of file clocksource.h.

#define CLOCK_SOURCE_MUST_VERIFY   0x02

Definition at line 204 of file clocksource.h.

#define CLOCK_SOURCE_UNSTABLE   0x40

Definition at line 208 of file clocksource.h.

#define CLOCK_SOURCE_VALID_FOR_HRES   0x20

Definition at line 207 of file clocksource.h.

#define CLOCK_SOURCE_WATCHDOG   0x10

Definition at line 206 of file clocksource.h.

#define CLOCKSOURCE_MASK (   bits)    (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)

Definition at line 211 of file clocksource.h.

Typedef Documentation

typedef u64 cycle_t

Definition at line 22 of file clocksource.h.

Function Documentation

int __clocksource_register_scale ( struct clocksource cs,
u32  scale,
u32  freq 
)

__clocksource_register_scale - Used to install new clocksources : clocksource to be registered : Scale factor multiplied against freq to get clocksource hz : clocksource frequency (cycles per second) divided by scale

Returns -EBUSY if registration fails, zero otherwise.

This SHOULD NOT be called directly! Please use the clocksource_register_hz() or clocksource_register_khz helper functions.

Definition at line 711 of file clocksource.c.

void __clocksource_updatefreq_scale ( struct clocksource cs,
u32  scale,
u32  freq 
)

__clocksource_updatefreq_scale - Used update clocksource with new freq : clocksource to be registered : Scale factor multiplied against freq to get clocksource hz : clocksource frequency (cycles per second) divided by scale

This should only be called from the clocksource->enable() method.

This SHOULD NOT be called directly! Please use the clocksource_updatefreq_hz() or clocksource_updatefreq_khz helper functions.

Definition at line 659 of file clocksource.c.

void clocks_calc_mult_shift ( u32 mult,
u32 shift,
u32  from,
u32  to,
u32  maxsec 
)

clocks_calc_mult_shift - calculate mult/shift factors for scaled math of clocks : pointer to mult variable : pointer to shift variable : frequency to convert from : frequency to convert to : guaranteed runtime conversion range in seconds

The function evaluates the shift/mult pair for the scaled math operations of clocksources and clockevents.

and are frequency values in HZ. For clock sources is NSEC_PER_SEC == 1GHz and is the counter frequency. For clock event is the counter frequency and is NSEC_PER_SEC.

The conversion range argument controls the time frame in seconds which must be covered by the runtime conversion with the calculated mult and shift factors. This guarantees that no 64bit overflow happens when the input value of the conversion is multiplied with the calculated mult factor. Larger ranges may reduce the conversion accuracy by chosing smaller mult and shift factors.

Definition at line 134 of file clocksource.c.

void clocksource_change_rating ( struct clocksource cs,
int  rating 
)

clocksource_change_rating - Change the rating of a registered clocksource : clocksource to be changed : new rating

Definition at line 767 of file clocksource.c.

struct clocksource* __init __weak clocksource_default_clock ( void  )
read

Definition at line 217 of file time.c.

struct clocksource* clocksource_get_next ( void  )
read
int clocksource_i8253_init ( void  )
void clocksource_mark_unstable ( struct clocksource cs)
int clocksource_mmio_init ( void __iomem ,
const char ,
unsigned  long,
int  ,
unsigned  ,
cycle_t(*)(struct clocksource *)   
)

Definition at line 52 of file mmio.c.

cycle_t clocksource_mmio_readl_down ( struct clocksource )

Definition at line 28 of file mmio.c.

cycle_t clocksource_mmio_readl_up ( struct clocksource )

Definition at line 23 of file mmio.c.

cycle_t clocksource_mmio_readw_down ( struct clocksource )

Definition at line 38 of file mmio.c.

cycle_t clocksource_mmio_readw_up ( struct clocksource )

Definition at line 33 of file mmio.c.

int clocksource_register ( struct clocksource cs)

clocksource_register - Used to install new clocksources : clocksource to be registered

Returns -EBUSY if registration fails, zero otherwise.

Definition at line 734 of file clocksource.c.

void clocksource_resume ( void  )

clocksource_resume - resume the clocksource(s)

Definition at line 471 of file clocksource.c.

void clocksource_suspend ( void  )

clocksource_suspend - suspend the clocksource(s)

Definition at line 459 of file clocksource.c.

void clocksource_touch_watchdog ( void  )

clocksource_touch_watchdog - Update watchdog

Update the watchdog after exception contexts such as kgdb so as not to incorrectly trip the watchdog. This might fail when the kernel was stopped in code which holds watchdog_lock.

Definition at line 489 of file clocksource.c.

void clocksource_unregister ( struct clocksource cs)

clocksource_unregister - remove a registered clocksource : clocksource to be unregistered

Definition at line 779 of file clocksource.c.

u64 timecounter_cyc2time ( struct timecounter tc,
cycle_t  cycle_tstamp 
)

timecounter_cyc2time - convert a cycle counter to same time base as values returned by timecounter_read() : Pointer to time counter. : a value returned by tc->cc->read()

Cycle counts that are converted correctly as long as they fall into the interval [-1/2 max cycle count, +1/2 max cycle count], with "max cycle count" == cs->mask+1.

This allows conversion of cycle counter values which were generated in the past.

Definition at line 88 of file clocksource.c.

void timecounter_init ( struct timecounter tc,
const struct cyclecounter cc,
u64  start_tstamp 
)

timecounter_init - initialize a time counter : Pointer to time counter which is to be initialized/reset : A cycle counter, ready to be used. : Arbitrary initial time stamp.

After this call the current cycle register (roughly) corresponds to the initial time stamp. Every call to timecounter_read() increments the time stamp counter by the number of elapsed nanoseconds.

Definition at line 34 of file clocksource.c.

u64 timecounter_read ( struct timecounter tc)

timecounter_read - return nanoseconds elapsed since timecounter_init() plus the initial time stamp : Pointer to time counter.

In other words, keeps track of time since the same epoch as the function which generated the initial time stamp.

Definition at line 75 of file clocksource.c.

void timekeeping_notify ( struct clocksource clock)

timekeeping_notify - Install a new clock source : pointer to the clock source

This function is called from clocksource.c after a new, better clock source has been registered. The caller holds the clocksource_mutex.

Definition at line 472 of file timekeeping.c.

Variable Documentation