Main Page | Directories | File List | Globals

timer.c File Reference

#include <agnix/agnix.h>
#include <agnix/irq.h>
#include <agnix/tasks.h>
#include <agnix/timer.h>
#include <agnix/memory.h>
#include <agnix/adi/adi.h>
#include <agnix/spinlock.h>
#include <agnix/timers.h>
#include <agnix/counters.h>
#include <agnix/console.h>

Include dependency graph for timer.c:

Go to the source code of this file.

Defines

#define TIMER_INC_VAL   (1e6 / TIMER_HZ)
#define USEC_IN_SEC   1000000

Functions

void timer_usec_overflow (void)
void timer_actualize (void)
void timer_irq (u32 i)
int __init timer_init (void)
int timer_gettimeofday (struct timeval_s *tv)
int timer_settimeofday (struct timeval_s *tv)

Variables

timeval_s current_time
chip_s rtc_chip
chip_s i8254_chip
int counter_jiffies_desc
spinlock_t current_time_lock
irq_routine_s irq_timer = { timer_irq, 0, 0, }


Define Documentation

#define TIMER_INC_VAL   (1e6 / TIMER_HZ)
 

Definition at line 25 of file timer.c.

Referenced by timer_actualize().

#define USEC_IN_SEC   1000000
 

Definition at line 26 of file timer.c.

Referenced by timer_actualize(), and timer_usec_overflow().


Function Documentation

void timer_actualize void   ) 
 

Definition at line 43 of file timer.c.

References current_time, TIMER_INC_VAL, timer_usec_overflow(), and USEC_IN_SEC.

Referenced by timer_irq().

00044 {
00045     current_time.tv_usec += TIMER_INC_VAL;
00046     
00047     if (current_time.tv_usec > USEC_IN_SEC)
00048         timer_usec_overflow();
00049 }

Here is the call graph for this function:

int timer_gettimeofday struct timeval_s *  tv  ) 
 

Definition at line 76 of file timer.c.

References current_time, current_time_lock, flags, i8254_chip, and memcpy().

Referenced by do_sys_time(), and SYS_CALL().

00077 {
00078     u16 count;
00079     u32 flags;
00080 
00081     spin_lock_irqsave(&current_time_lock, flags);
00082     
00083     memcpy(tv, &current_time, sizeof(struct timeval_s));
00084     count = pit_ops(&i8254_chip)->read_count(&i8254_chip, 0);
00085     tv->tv_usec += (int)(count);
00086     
00087     spin_unlock_irqrestore(&current_time_lock, flags);
00088 
00089     return 0;
00090 }

Here is the call graph for this function:

int __init timer_init void   ) 
 

Definition at line 66 of file timer.c.

References current_time, current_time_lock, install_irq(), irq_timer, and rtc_chip.

Referenced by i386_init().

00067 {
00068     spin_lock_init(&current_time_lock);
00069 
00070     rtc_ops(&rtc_chip)->gettime(&rtc_chip, &current_time);
00071     install_irq(0, &irq_timer);
00072 
00073     return 0;
00074 }

Here is the call graph for this function:

void timer_irq u32  i  ) 
 

Definition at line 51 of file timer.c.

References counter_jiffies_desc, run_timers(), and timer_actualize().

00052 {
00053     if (--current_task->t_count <= 0) {
00054         current_task->t_resched = 1;
00055     }
00056     else
00057         current_task->t_resched = 0;
00058     
00059     timer_actualize();
00060     counter_inc(counter_jiffies_desc);
00061     run_timers();
00062 }

Here is the call graph for this function:

int timer_settimeofday struct timeval_s *  tv  ) 
 

Definition at line 92 of file timer.c.

References current_time, current_time_lock, flags, i8254_chip, and memcpy().

Referenced by do_sys_stime(), and SYS_CALL().

00093 {
00094     u16 count;
00095     u32 flags;
00096 
00097     spin_lock_irqsave(&current_time_lock, flags);
00098     
00099     memcpy(&current_time, tv, sizeof(struct timeval_s));
00100     count = (u16)(tv->tv_usec % 1000);
00101     pit_ops(&i8254_chip)->write_count(&i8254_chip, 0, count);
00102     
00103     spin_unlock_irqrestore(&current_time_lock, flags);
00104 
00105     return 0;
00106 }

Here is the call graph for this function:

void timer_usec_overflow void   ) 
 

Definition at line 35 of file timer.c.

References current_time, and USEC_IN_SEC.

Referenced by timer_actualize().

00036 {
00037     do {
00038         current_time.tv_usec -= USEC_IN_SEC;
00039         current_time.tv_sec++;
00040     } while (current_time.tv_usec > USEC_IN_SEC);
00041 }


Variable Documentation

int counter_jiffies_desc
 

Definition at line 18 of file counters_sys.c.

struct timeval_s current_time
 

Definition at line 28 of file timer.c.

Referenced by timer_actualize(), timer_gettimeofday(), timer_init(), timer_settimeofday(), and timer_usec_overflow().

spinlock_t current_time_lock
 

Definition at line 33 of file timer.c.

Referenced by timer_gettimeofday(), timer_init(), and timer_settimeofday().

struct chip_s i8254_chip
 

Definition at line 95 of file i8254.c.

Referenced by i8254_init(), timer_gettimeofday(), and timer_settimeofday().

struct irq_routine_s irq_timer = { timer_irq, 0, 0, }
 

Definition at line 64 of file timer.c.

Referenced by timer_init().

struct chip_s rtc_chip
 

Definition at line 84 of file rtc.c.

Referenced by rtc_init(), and timer_init().

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix