Programmable interval timer (8253/8254) controller. More...
#include <core.h>
#include <kernel/x86/cpu.h>
#include <kernel/device/timer.h>
#include <kernel/interrupt/interrupt.h>
Go to the source code of this file.
Macros | |
#define | TIMER_PORT_DATA_CH0 0x40 |
Channel 0 data port. More... | |
#define | TIMER_PORT_DATA_CH1 0x41 |
Channel 1 data port. More... | |
#define | TIMER_PORT_DATA_CH2 0x42 |
Channel 2 data port. More... | |
#define | TIMER_PORT_CMD 0x43 |
Timer command port. More... | |
#define | MIN_FREQUENCY 19 |
#define | MAX_FREQUENCY 1193181 |
Functions | |
static void | isr_timer (const interrupt_context_t *context) |
void | timer_init (uint32_t frequency) |
Initialize the timer controller so that it interrupts the kernel at the requested frequency. More... | |
void | timer_enable () |
Enable timer interrupts. More... | |
void | timer_disable () |
Disable timer interrupts. More... | |
Programmable interval timer (8253/8254) controller.
Definition in file timer.c.
#define TIMER_PORT_DATA_CH0 0x40 |
#define TIMER_PORT_CMD 0x43 |
#define MIN_FREQUENCY 19 |
Definition at line 22 of file timer.c.
Referenced by timer_init().
#define MAX_FREQUENCY 1193181 |
Definition at line 23 of file timer.c.
Referenced by timer_init().
|
static |
Definition at line 26 of file timer.c.
Referenced by timer_init().
void timer_init | ( | uint32_t | frequency | ) |
Initialize the timer controller so that it interrupts the kernel at the requested frequency.
Interrupts are enabled at the end of the function, so timer_enable does not need to be called after timer_init.
Due to the clock granularity (1193181Hz), the requested frequency may not be perfectly met.
[in] | frequency | The interrupt frequency in Hz. Clamped to the range [19:1193181]. |
Definition at line 37 of file timer.c.
Referenced by kmain().