My Kernel v0.1.0
timer.h File Reference
#include <kernel/time.h>
#include <kernel/types.h>
Include dependency graph for timer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HZ   CLOCK_PER_SECOND
 The frequency used for the timer (in Hz)
 
#define SEC_TO_TICKS(_time)   SEC((_time) * HZ)
 Compute the number of ticks in a given time frame.
 
#define MS_TO_TICKS(_time)   MS_TO_SEC(SEC_TO_TICKS(_time))
 Compute the number of ticks in a given time frame.
 
#define US_TO_TICKS(_time)   US_TO_SEC(SEC_TO_TICKS(_time))
 Compute the number of ticks in a given time frame.
 
#define NS_TO_TICKS(_time)   NS_TO_SEC(SEC_TO_TICKS(_time))
 Compute the number of ticks in a given time frame.
 
#define TICKS_TO_SEC(_ticks)   SEC((_ticks) / HZ)
 Convert a number of ticks into a regular time unit.
 
#define TICKS_TO_MS(_ticks)   MS(TICKS_TO_SEC(_ticks))
 Convert a number of ticks into a regular time unit.
 
#define TICKS_TO_US(_ticks)   US(TICKS_TO_SEC(_ticks))
 Convert a number of ticks into a regular time unit.
 
#define TICKS_TO_NS(_ticks)   NS(TICKS_TO_SEC(_ticks))
 Convert a number of ticks into a regular time unit.
 

Functions

void timer_start (u32 frequency)
 Start the global timekeeping timer. More...
 
static clock_t timer_gettick (void)
 
static bool timer_tick (void)
 Increment the timekeeping timer's tick count. More...
 
static time_t timer_get_ms (void)
 
static time_t timer_get_us (void)
 
static time_t timer_get_ns (void)
 
static void clock_get_time (struct timespec *time)
 Fill a timespec structure with the current time of the day. More...
 
void timer_wait_ms (time_t)
 Wait a certain amount of miliseconds. More...
 

Variables

volatile clock_t timer_ticks_counter
 This is where we keep track of the number of intervals reported by the timer. More...
 
volatile u32 timer_kernel_frequency
 Frequency of the global timekeeping timer.