Data Structures | |||||
struct | timeout | ||||
Timeout variable structure. More... | |||||
Defines | |||||
#define | LATCH_COUNT 0x00 | ||||
To copy chip count. | |||||
#define | TIMER0 0x40 | ||||
I/O port for timer channel 0. | |||||
#define | TIMER2 0x42 | ||||
I/O port for timer channel 2. | |||||
#define | TIMER_MODE 0x43 | ||||
I/O port for timer mode control. | |||||
#define | SQUARE_WAVE 0x36 | ||||
The sqare-wave form. | |||||
#define | TIMER_FREQ 1193182L | ||||
Clock frequency for timer in PC. | |||||
#define | TIMER_COUNT (unsigned)(TIMER_FREQ/HZ) | ||||
Value to initialize timer. | |||||
#define | LATCH ((TIMER_FREQ + HZ/2) / HZ) | ||||
LATCH is used for the interval timer. | |||||
#define | HZ 200 | ||||
Clock Frequancy (User settable, default=200Hz). | |||||
#define | usleep(m) delay(m) | ||||
Macro equivalent to delay(dword millisec). | |||||
Typedefs | |||||
typedef timeout | timeout_t | ||||
Timeout variable structure. | |||||
Functions | |||||
void | init_clock () | ||||
Initialize channel 0 of the 8253A timer. | |||||
void | stop_clock () | ||||
Reset the clock for rebooting. | |||||
dword | sys_get_ticks (void) | ||||
Return the system ticks.
| |||||
void | delay (dword millisec) | ||||
Delay some milliseconds
| |||||
void | set_timeout (timeout_t *t, unsigned int millisec) | ||||
Initialize a timeout variable.
| |||||
bool | is_timeout (timeout_t *t) | ||||
Check if a timeout has been elapsed.
| |||||
void | clock_thread () | ||||
This is a task that occurs at every clock tick. |
|
Clock Frequancy (User settable, default=200Hz).
|
|
LATCH is used for the interval timer.
|
|
To copy chip count.
|
|
The sqare-wave form.
|
|
I/O port for timer channel 0.
|
|
I/O port for timer channel 2.
|
|
Value to initialize timer.
|
|
Clock frequency for timer in PC.
|
|
I/O port for timer mode control.
|
|
Macro equivalent to delay(dword millisec).
|
|
Timeout variable structure.
|
|
This is a task that occurs at every clock tick.
Into this routine you can put every periodical task. Definition at line 109 of file clock.c.
00110 { 00111 ticks++; 00112 floppy_thread(); 00113 } |
|
Delay some milliseconds
Definition at line 51 of file clock.c.
00052 { 00053 dword count, elapsed; 00054 dword IF = GET_IF(); 00055 00056 // Start timer // 00057 elapsed = 0; 00058 00059 while (elapsed < millisec) 00060 { 00061 // Poll ticks in memory // 00062 count = ticks; 00063 00064 // Auto-sleep // 00065 enable(); 00066 idle(); 00067 00068 // Update elapsed time // 00069 elapsed += (ticks - count)*1000/HZ; 00070 } 00071 00072 SET_IF(IF); 00073 } |
|
Initialize channel 0 of the 8253A timer.
Definition at line 21 of file clock.c.
00022 { 00023 dword IF = GET_IF(); 00024 00025 disable(); 00026 00027 outportb(TIMER_MODE, SQUARE_WAVE); // set timer on 00028 outportb(TIMER0, TIMER_COUNT & 0xFF); // timer low byte 00029 outportb(TIMER0, TIMER_COUNT >> 8); // timer high byte 00030 00031 SET_IF(IF); 00032 } |
|
Check if a timeout has been elapsed.
Definition at line 87 of file clock.c.
00088 { 00089 // Check if a timeout has gone // 00090 uint32_t elapsed; 00091 elapsed = ticks - t->start_ticks; 00092 return( elapsed >= t->ticks_to_wait ); 00093 } |
|
Initialize a timeout variable.
Definition at line 79 of file clock.c.
00080 { 00081 t->start_ticks = ticks; 00082 t->ticks_to_wait = millisec * HZ / 1000; 00083 } |
|
Reset the clock for rebooting.
Definition at line 35 of file clock.c.
|
|
Return the system ticks.
Definition at line 97 of file clock.c.
00098 {
00099 return(ticks);
00100 }
|