hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/boot/timer.zig
blob: 428c695859014a2c371f660bd97980fcc8e327ab (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 its just port writes the vm can drive

var ticks: u64 = 0;

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

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