|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "pit.h"#include "kernel/sync/atomic.h"#include "arch/arch.h"#include "arch/x86/cpu/io.h"#include "kernel/irq/irq.h"#include "kernel/device/device.h"#include "kernel/scheduler/scheduler.h"#include "kernel/time/timer.h"#include "kernel/process/process.h"#include "common/string.h"Macros | |
| #define | PORT_61 0x61 |
| #define | GATE2 0x01u |
| #define | SPEAKER 0x02u |
| #define | OUT2 0x20u |
| #define | CHANNEL2_MODE0 0xB0u |
| #define | DELAY_PART_US 50000u |
Enumerations | |
| enum | { PIT_CHANNEL0_DATA = 0x40 , PIT_CHANNEL2_DATA = 0x42 , PIT_COMMAND = 0x43 , PIT_INPUT_FREQUENCY = 1193182 } |
| enum | { PIT_COMMAND_BINARY = 0x00 , PIT_COMMAND_MODE3 = 0x06 , PIT_COMMAND_ACCESS_LOHI = 0x30 , PIT_COMMAND_CHANNEL0 = 0x00 } |
Functions | |
| void | pit_initialize (uint32_t frequency) |
| initializes the PIT timer. | |
| uint64_t | pit_get_ticks (void) |
| returns the number of PIT interrupts since initialization. | |
| void | pit_delay_us (uint32_t us) |
| wait for a time with PIT channel 2, without interrupts. | |
| #define PORT_61 0x61 |
| #define GATE2 0x01u |
| #define SPEAKER 0x02u |
| #define OUT2 0x20u |
| #define CHANNEL2_MODE0 0xB0u |
| #define DELAY_PART_US 50000u |
| anonymous enum |
| void pit_initialize | ( | uint32_t | frequency | ) |
initializes the PIT timer.
| frequency | desired interrupt frequency in Hz. |
| uint64_t pit_get_ticks | ( | void | ) |
returns the number of PIT interrupts since initialization.
| void pit_delay_us | ( | uint32_t | us | ) |
wait for a time with PIT channel 2, without interrupts.
the wait is a busy loop, for short waits in boot code (the start of the other cores). only one core may use channel 2 at a time; the APIC timer calibration at boot also uses it.
| us | the time to wait, in microseconds. |