Pyro device driver API
Functions | Variables
timer.c File Reference

This file contains the timer interrupt handler and functions to return the system time (time elapsed since boot), real time (since 1970-01-01), and per-CPU idle time. More...

Functions

 SEQ_LOCK (g_sTimerSeqLock,"timer_slock")
 
 SPIN_LOCK (g_sPitTimerSpinLock,"i8253_slock")
 
bigtime_t get_system_time (void)
 Returns the time elapsed since last system boot. More...
 
bigtime_t get_real_time (void)
 Returns the number of microseconds since 1970-01-01. More...
 
bigtime_t get_idle_time (int nProcessor)
 Returns the total idle time for the given CPU. More...
 
int sys_get_raw_system_time (bigtime_t *pRes)
 Returns the time elapsed since last system boot, in microseconds. More...
 
int sys_get_raw_real_time (bigtime_t *pRes)
 Returns the number of microseconds since 1970-01-01. More...
 
int sys_get_raw_idle_time (bigtime_t *pRes, int nProcessor)
 Returns the total idle time for the given CPU, in microseconds. More...
 
int sys_set_real_time (uint32 nTimeLow, uint32 nTimeHigh)
 Sets the system clock to a new time. More...
 
void TimerInterrupt (SysCallRegs_s *psRegs)
 This is the timer interrupt handler, called INT_FREQ times per second. More...
 
void start_timer_int (void)
 Initializes the PIT timers. More...
 
void get_cmos_time (void)
 Sets the system time from the battery-backed CMOS clock. More...
 

Variables

int g_bNeedSchedule
 If true, the scheduler will be called when returning from syscall. More...
 

Detailed Description

This file contains the timer interrupt handler and functions to return the system time (time elapsed since boot), real time (since 1970-01-01), and per-CPU idle time.

All time values are returned in microseconds.

Function Documentation

void get_cmos_time ( void  )

Sets the system time from the battery-backed CMOS clock.

See Also
kernel_init()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
bigtime_t get_idle_time ( int  nProcessor)

Returns the total idle time for the given CPU.

Parameters
nProcessorthe processor for which to return the idle time.
Returns
Idle time for the given CPU, in microseconds.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
bigtime_t get_real_time ( void  )

Returns the number of microseconds since 1970-01-01.

Returns
The number of microseconds since 1970-01-01.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
bigtime_t get_system_time ( void  )

Returns the time elapsed since last system boot.

Returns
Time since last system boot, in microseconds.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
void start_timer_int ( void  )

Initializes the PIT timers.

See Also
kernel_init()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int sys_get_raw_idle_time ( bigtime_t *  pRes,
int  nProcessor 
)

Returns the total idle time for the given CPU, in microseconds.

Parameters
pResa pointer to the bigtime_t in which to store the CPU idle time.
nProcessorthe processor for which to return the idle time.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int sys_get_raw_real_time ( bigtime_t *  pRes)

Returns the number of microseconds since 1970-01-01.

Parameters
pResa pointer to the bigtime_t in which to store the current time.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int sys_get_raw_system_time ( bigtime_t *  pRes)

Returns the time elapsed since last system boot, in microseconds.

Parameters
pResa pointer to the bigtime_t in which to store the system time.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int sys_set_real_time ( uint32  nTimeLow,
uint32  nTimeHigh 
)

Sets the system clock to a new time.

Does not set the RTC.

Parameters
nTimeLowthe low 32 bits of the new system time, in microseconds since 1970-01-01.
nTimeHighthe high 32 bits of the new system time
Returns
Always returns 0.
Attention
Missing check for sufficient privileges to set the system clock.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
void TimerInterrupt ( SysCallRegs_s psRegs)

This is the timer interrupt handler, called INT_FREQ times per second.

It updates the system time and calls functions send_timer_signals() and wake_up_sleepers(). If there is no APIC present, Schedule() is also called here; otherwise, Schedule() is called for each CPU via do_smp_preempt(), which is triggered by the APIC timer.

Parameters
dummyunused.
See Also
idle_loop()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Variable Documentation

int g_bNeedSchedule

If true, the scheduler will be called when returning from syscall.