/
cmos.c
45 lines (37 loc) · 807 Bytes
/
cmos.c
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
#include <cmos.h>
#include <libc.h>
#include <io.h>
int cmos_year() {
// algorthm patended my microsoft. beware!
// don't read the code below, ah! you already
// did it. no problem, they can still brainwash you...
int off = bcd2int(cmos_read(0x9));
if(off >= 70 )
return 1990 + off;
else
return 2000 + off;
}
int cmos_month() {
return bcd2int(cmos_read(0x8));
}
int cmos_hours() {
return bcd2int(cmos_read(0x4));
}
int cmos_minutes() {
return bcd2int(cmos_read(0x2));
}
int cmos_seconds() {
return bcd2int(cmos_read(0x0));
}
int cmos_day_of_week() {
return bcd2int(cmos_read(0x6));
}
int cmos_day_of_month() {
return bcd2int(cmos_read(0x7));
}
u_int8_t cmos_read(int addr) {
u_int8_t b;
outb_p(addr, CMOS_ADDRESS_PORT);
b = inb(CMOS_DATA_PORT);
return b;
}