|
AquilaOS documentation
How it works, and its code
|
x86: the 8254 programmable interval timer (PIT). More...
#include <core/system.h>#include <core/string.h>#include <core/kargs.h>#include <cpu/io.h>#include <platform/misc.h>Go to the source code of this file.
Data Structures | |
| struct | pit_cmd_register |
| The PIT's command register: which channel, how it is loaded, and in which mode it counts. More... | |
Macros | |
| #define | PIT_CHANNEL0 0x00 |
| #define | PIT_CHANNEL2 0x02 |
| #define | PIT_CMD 0x03 |
| #define | PIT_GATE_PORT 0x61 |
| #define | GATE2 0x01 |
| #define | SPEAKER 0x02 |
| #define | OUT2 0x20 |
| #define | PIT_MODE_RATE_GENERATOR 0x2 |
| #define | PIT_MODE_SQUARE_WAVE 0x3 |
| #define | PIT_ACCESS_LOHIBYTE 0x3 |
| #define | FBASE 1193182ULL |
Functions | |
| int | x86_pit_setup (struct ioaddr *io) |
| Sets where the PIT's ports are. | |
| static uint32_t | atou32 (const char *s) |
| Converts a decimal string to a number. | |
| uint32_t | x86_pit_period_set (uint32_t period_ns) |
| Makes channel 0 interrupt periodically, for the scheduler's tick. | |
| void | x86_pit_delay (uint32_t us) |
| Waits us microseconds, at most 54 ms, busy. | |
Variables | |
| static struct ioaddr | pit_ioaddr |
x86: the 8254 programmable interval timer (PIT).
Its channel 0 is the scheduler's tick when there's no APIC (IRQ 0). Its channel 2, normally the speaker's, measures short delays: to calibrate the TSC and the local APIC's timer, and to wait while starting the other CPUs.
Definition in file pit.c.
| #define FBASE 1193182ULL |
Definition at line 59 of file pit.c.
Referenced by x86_pit_delay(), and x86_pit_period_set().
| #define GATE2 0x01 |
Definition at line 24 of file pit.c.
Referenced by x86_pit_delay().
| #define OUT2 0x20 |
Definition at line 26 of file pit.c.
Referenced by x86_pit_delay().
| #define PIT_ACCESS_LOHIBYTE 0x3 |
Definition at line 44 of file pit.c.
Referenced by x86_pit_delay(), and x86_pit_period_set().
| #define PIT_CHANNEL0 0x00 |
Definition at line 18 of file pit.c.
Referenced by x86_pit_period_set().
| #define PIT_CHANNEL2 0x02 |
Definition at line 19 of file pit.c.
Referenced by x86_pit_delay().
| #define PIT_CMD 0x03 |
Definition at line 20 of file pit.c.
Referenced by x86_pit_delay(), and x86_pit_period_set().
| #define PIT_GATE_PORT 0x61 |
Definition at line 23 of file pit.c.
Referenced by x86_pit_delay().
| #define PIT_MODE_SQUARE_WAVE 0x3 |
Definition at line 43 of file pit.c.
Referenced by x86_pit_period_set().
| #define SPEAKER 0x02 |
Definition at line 25 of file pit.c.
Referenced by x86_pit_delay().
|
static |
Converts a decimal string to a number.
Definition at line 62 of file pit.c.
References atou32().
Referenced by atou32(), and x86_pit_period_set().
| void x86_pit_delay | ( | uint32_t | us | ) |
Waits us microseconds, at most 54 ms, busy.
Channel 2 counts down once, and its output goes high at 0; channel 0 keeps the tick.
| us | how long to wait, in microseconds |
Definition at line 123 of file pit.c.
References FBASE, GATE2, io_in8(), io_out8(), IOADDR_PORT, OUT2, PIT_ACCESS_LOHIBYTE, PIT_CHANNEL2, PIT_CMD, PIT_GATE_PORT, pit_ioaddr, printk(), SPEAKER, and x86_pit_delay().
Referenced by ap_boot(), timer_calibrate(), tsc_calibrate(), and x86_pit_delay().
Makes channel 0 interrupt periodically, for the scheduler's tick.
The i8254.div kernel argument sets the divisor directly.
| period_ns | the period wanted, in ns |
Definition at line 82 of file pit.c.
References atou32(), FBASE, io_out8(), kargs_get(), NULL, PIT_ACCESS_LOHIBYTE, PIT_CHANNEL0, PIT_CMD, pit_ioaddr, PIT_MODE_SQUARE_WAVE, printk(), and x86_pit_period_set().
Referenced by platform_timer_setup(), and x86_pit_period_set().
| int x86_pit_setup | ( | struct ioaddr * | io | ) |
Sets where the PIT's ports are.
| io | its ports (0x40) |
Definition at line 52 of file pit.c.
References ioaddr::addr, ioaddr_type_str(), pit_ioaddr, printk(), and x86_pit_setup().
Referenced by x86_pc_pit_init(), and x86_pit_setup().
|
static |
Definition at line 16 of file pit.c.
Referenced by x86_pit_delay(), x86_pit_period_set(), and x86_pit_setup().