From: Barry Rodewald [mailto:bsr@xnet.co.nz]

Subject: Update to MC146818 RTC

Hi,
Here's a small patch to the MC146818 code, which gives a basic 
implementation of the "update ended" interrupt flag.

The code is based on the behaviour of the Aleste 520EX (Russian Amstrad 
CPC clone) BIOS, which periodically (about 7 or 8 times a second) checks

the flag to see if the date and time display on the BIOS setup screen 
needs to be updated.  Without the flag implemented, the date and time 
are static on the setup screen, or if the time hasn't been initialised 
(blank NVRAM) it is blank.

The BIOS function that does this basically checks bit 4 of register 
0x0c, and if 0, ends there, otherwise it will read register 0x0b, sets 
bit 7 of the result and writes it back to register 0x0b (presumably, 
this resets the interrupt flags).  Then it continues on to the display 
refresh function.
(Disassembly attached)
This commit is contained in:
Aaron Giles 2008-09-04 09:07:03 +00:00
parent 503786f7d7
commit a50feca332

View File

@ -90,6 +90,8 @@ struct mc146818_chip
UINT16 eindex;
UINT8 edata[0x2000];
int updated; /* update ended interrupt flag */
attotime last_refresh;
};
@ -189,7 +191,7 @@ static TIMER_CALLBACK( mc146818_timer )
}
}
}
mc146818->updated = 1; /* clock has been updated */
mc146818->last_refresh = timer_get_time();
}
@ -324,6 +326,12 @@ READ8_HANDLER(mc146818_port_r)
#endif
break;
case 0xc:
if(mc146818->updated != 0) /* the clock has been updated */
data = 0x10;
else
data = 0x00;
break;
case 0xd:
/* battery ok */
data = mc146818->data[mc146818->index % MC146818_DATA_SIZE] | 0x80;
@ -354,7 +362,16 @@ WRITE8_HANDLER(mc146818_port_w)
break;
case 1:
mc146818->data[mc146818->index % MC146818_DATA_SIZE] = data;
switch(mc146818->index % MC146818_DATA_SIZE)
{
case 0x0b:
if(data & 0x80)
mc146818->updated = 0;
mc146818->data[mc146818->index % MC146818_DATA_SIZE] = data;
break;
default:
mc146818->data[mc146818->index % MC146818_DATA_SIZE] = data;
}
break;
}
}