What is a "Real Time Clock" (RTC)?
A Real Time Clock (RTC) is a computer clock (in the form of integrated circuit) that keeps track
of the current time. RTC has an alternative power source (i.e. a coin-cell battery) so RTC continues to keep time when main power is removed.
Wikipedia also has very nice and clear explanations @ http://en.wikipedia.org/wiki/Real-time_clock
RTC has a very useful function called RTC Alarm. It is used to wake-up the computer from sleeping states automatically - useful when scheduled tasks are required, i.e. wake-up for recording TV-series.
However, RTC alarm needs supports from both hardware and software. Fortunately, PC has standardized hardware interface to perform (CMOS and ACPI). Most, if not all, of computers support RTC today.
I/O Ports to Access RTC
On PC, I/O ports are used to access RTC registers. Standard I/O ports are 70h/71 pairs as below:
|Read from a RTC Register|
|Write to a RTC register|
RTC registers are listed here. Note offset 00h to 0Dh are used for keeping the system time and for wake-up at particular time.
Register A to Register D are used to configure many important RTC functions including (not limited to):
1. Alarm Interrupt Enable (more below).
2. Data Mode (BCD or Binary)
3. Hour Format (12-hour or 24-hour)
and so on.
How to configure RTC wake-up
A number of RTC and ACPI register is associated to RTC wake-up.
* Seconds (00h), Minutes (02h), and Hours (04h)
* Second Alarms (01h), Minutes Alarm (03h) and Hours (05h)
* RTC_REGB (Alarm Interrupt Enable - AIE)
When AIE is set and Seconds, Minutes and Hours registers matches to the corresponding Alarm registers, RTC will fire an interrupt and set RTC_STS in ACPI Registers.
* ACPI PM registers
* PM1_STS (RTC_STS) - this is set when RTC generates an alarm
* PM1_EN (RTC_EN) - the setting of the RTC_STS bit to generate a wake event
Case Study - Why RTC fails to wake from S4 in DC mode.
Solution: To fix the problem, BIOS can implement an easy fix to check RTC AIE registers and to notify EC not to remove power. The best place to add the fix is in BIOS Sleep SMI which OS hands completely control to BIOS.