RTC: Fix "safe read bit", fix time test that was reversed and causing major delays for time/date access

This commit is contained in:
Jonathan Campbell 2023-04-13 14:58:48 -07:00
parent 378d194972
commit 83785c99bc

View File

@ -423,21 +423,13 @@ static Bitu cmos_readreg(Bitu port,Bitu iolen) {
case 0x05: /* Hours Alarm */ case 0x05: /* Hours Alarm */
return cmos.regs[cmos.reg]; return cmos.regs[cmos.reg];
case 0x0a: /* Status register A */ case 0x0a: /* Status register A */
if(date_host_forced) { // take bit 7 of reg b into account (if set, never updates)
// take bit 7 of reg b into account (if set, never updates) gettimeofday (&cmos.safetime, NULL); // get current UTC time
gettimeofday (&cmos.safetime, NULL); // get current UTC time if (cmos.lock || // if lock then never updated, so reading safe
if (cmos.lock || // if lock then never updated, so reading safe cmos.safetime.tv_usec >= (1000-244)) { // if 0, at least 244 usec should be available
cmos.safetime.tv_usec < (1000-244)) { // if 0, at least 244 usec should be available return cmos.regs[0x0a]; // reading safe
return cmos.regs[0x0a]; // reading safe
} else {
return cmos.regs[0x0a] | 0x80; // reading not safe!
}
} else { } else {
if (PIC_TickIndex()<0.002) { return cmos.regs[0x0a] | 0x80; // reading not safe!
return (cmos.regs[0x0a]&0x7f) | 0x80;
} else {
return (cmos.regs[0x0a]&0x7f);
}
} }
case 0x0c: /* Status register C */ case 0x0c: /* Status register C */
{ {