hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/boot/timer.zig
blob: 4569d6a8548ac5c1bd960ce87498c54833922705 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// PIT channel 0 tick counter
// configuring the PIT itself (outb to 0x43/0x40) is done in revo (kernel
// `pit_init`), since it's just port writes the VM can drive

var ticks: u64 = 0;

// called from the IRQ0 handler
pub fn onIrq() void {
    const t: *volatile u64 = &ticks;
    t.* +%= 1;
}

// called from the event loop
pub fn now() u64 {
    const t: *volatile u64 = &ticks;
    return t.*;
}