29 static int _rtc_register;
30 static Uint8 cmos_ram[0x100];
37 DEBUG(
"RTC: register number %02X has been selected" NL, val);
43 DEBUG(
"RTC: write reg %02X with data %02X" NL, _rtc_register, val);
44 if (_rtc_register == 0xC || _rtc_register == 0xD)
return;
45 if (_rtc_register == 0xA) val &= 127;
46 cmos_ram[_rtc_register] = val;
47 #ifdef RESET_RTC_INDEX
53 static int _rtc_conv(
int bin,
int is_hour)
56 if (is_hour && (!(cmos_ram[0xB] & 2))) {
59 }
else if (bin == 12) {
61 }
else if (bin > 12) {
66 if (!(cmos_ram[0xB] & 4)) {
67 bin = ((bin / 10) << 4) | (bin % 10);
73 static void _rtc_update(
void)
76 cmos_ram[ 0] = _rtc_conv(t->tm_sec, 0);
77 cmos_ram[ 2] = _rtc_conv(t->tm_min, 0);
78 cmos_ram[ 4] = _rtc_conv(t->tm_hour, 1);
79 cmos_ram[ 6] = _rtc_conv(t->tm_wday + 1, 0);
80 cmos_ram[ 7] = _rtc_conv(t->tm_mday, 0);
81 cmos_ram[ 8] = _rtc_conv(t->tm_mon + 1, 0);
82 cmos_ram[ 9] = _rtc_conv((t->tm_year % 100) + 20, 0);
83 cmos_ram[0x32] = _rtc_conv(21, 0);
84 DEBUG(
"RTC: time/date has been updated for \"%d-%02d-%02d %02d:%02d:%02d\" at UNIX epoch %ld" NL,
98 memset(cmos_ram, 0, 0x100);
112 int i = _rtc_register;
113 #ifdef RESET_RTC_INDEX
122 DEBUG(
"RTC: reading register %02X, result will be: %02X" NL, i, cmos_ram[i]);