31 static int _rtc_register;
32 static Uint8 cmos_ram[0x100];
39 DEBUG(
"RTC: register number %02X has been selected" NL, val);
45 DEBUG(
"RTC: write reg %02X with data %02X" NL, _rtc_register, val);
46 if (_rtc_register == 0xC || _rtc_register == 0xD)
return;
47 if (_rtc_register == 0xA) val &= 127;
48 cmos_ram[_rtc_register] = val;
49 #ifdef RESET_RTC_INDEX
55 static int _rtc_conv(
int bin,
int is_hour)
58 if (is_hour && (!(cmos_ram[0xB] & 2))) {
61 }
else if (bin == 12) {
63 }
else if (bin > 12) {
68 if (!(cmos_ram[0xB] & 4)) {
69 bin = ((bin / 10) << 4) | (bin % 10);
75 static void _rtc_update(
void)
78 cmos_ram[ 0] = _rtc_conv(t->tm_sec, 0);
79 cmos_ram[ 2] = _rtc_conv(t->tm_min, 0);
80 cmos_ram[ 4] = _rtc_conv(t->tm_hour, 1);
81 cmos_ram[ 6] = _rtc_conv(t->tm_wday + 1, 0);
82 cmos_ram[ 7] = _rtc_conv(t->tm_mday, 0);
83 cmos_ram[ 8] = _rtc_conv(t->tm_mon + 1, 0);
84 cmos_ram[ 9] = _rtc_conv((t->tm_year % 100) + 20, 0);
85 cmos_ram[0x32] = _rtc_conv(21, 0);
86 DEBUG(
"RTC: time/date has been updated for \"%d-%02d-%02d %02d:%02d:%02d\" at UNIX epoch %ld" NL,
100 memset(cmos_ram, 0, 0x100);
114 int i = _rtc_register;
115 #ifdef RESET_RTC_INDEX
124 DEBUG(
"RTC: reading register %02X, result will be: %02X" NL, i, cmos_ram[i]);