aboutsummaryrefslogtreecommitdiffstats
path: root/src/clock.c
blob: 5ca2b5ca2bb0e1a3a4c3b723ef79505e4cb8b746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 16bit code to handle system clocks.
//
// Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
// Copyright (C) 2002  MandrakeSoft S.A.
//
// This file may be distributed under the terms of the GNU GPLv3 license.

#include "biosvar.h" // struct bregs
#include "util.h" // debug_enter
#include "disk.h" // floppy_tick

// INT 1Ah Time-of-day Service Entry Point
void VISIBLE
handle_1a(struct bregs *regs)
{
    debug_enter(regs);
    set_cf(regs, 1);
}

// User Timer Tick
void VISIBLE
handle_1c(struct bregs *regs)
{
    debug_enter(regs);
}

// INT 08h System Timer ISR Entry Point
void VISIBLE
handle_08(struct bregs *regs)
{
//    debug_enter(regs);

    floppy_tick();

    u32 counter = GET_BDA(timer_counter);
    counter++;
    // compare to one days worth of timer ticks at 18.2 hz
    if (counter >= 0x001800B0) {
        // there has been a midnight rollover at this point
        counter = 0;
        SET_BDA(timer_rollover, GET_BDA(timer_rollover) + 1);
    }

    SET_BDA(timer_counter, counter);
    // XXX - int #0x1c
    eoi_master_pic();
}

// int70h: IRQ8 - CMOS RTC
void VISIBLE
handle_70(struct bregs *regs)
{
    debug_enter(regs);
}