aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2013-02-07 23:41:53 -0500
committerKevin O'Connor <kevin@koconnor.net>2013-02-09 11:09:36 -0500
commit0f6198a116fdffeeaa3cf6036f4ca6611a71b2b3 (patch)
tree56cb4059889df49c8fd7930b61227c9c4d59a612
parent5d47eb484efed2ab20ce21f2211ab1f5f57b963f (diff)
downloadseabios-0f6198a116fdffeeaa3cf6036f4ca6611a71b2b3.tar.gz
Determine century during init and store in VARLOW mem during runtime.
Avoid reading/writing to cmos at runtime to get the QEMU century information. Instead, read it at startup and cache the info. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/clock.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/clock.c b/src/clock.c
index 3edcaf5..bbcafd7 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -281,6 +281,8 @@ bcd2bin(u8 val)
return (val & 0xf) + ((val >> 4) * 10);
}
+u8 Century VARLOW;
+
void
timer_setup(void)
{
@@ -297,6 +299,18 @@ timer_setup(void)
ticks = ((u64)ticks * PIT_TICK_RATE) / PIT_TICK_INTERVAL;
SET_BDA(timer_counter, ticks);
+ // Setup Century storage
+ if (CONFIG_QEMU) {
+ Century = inb_cmos(CMOS_CENTURY);
+ } else {
+ // Infer current century from the year.
+ u8 year = inb_cmos(CMOS_RTC_YEAR);
+ if (year > 0x80)
+ Century = 0x19;
+ else
+ Century = 0x20;
+ }
+
enable_hwirq(0, FUNC16(entry_08));
enable_hwirq(8, FUNC16(entry_70));
}
@@ -420,14 +434,7 @@ handle_1a04(struct bregs *regs)
regs->cl = inb_cmos(CMOS_RTC_YEAR);
regs->dh = inb_cmos(CMOS_RTC_MONTH);
regs->dl = inb_cmos(CMOS_RTC_DAY_MONTH);
- if (CONFIG_COREBOOT) {
- if (regs->cl > 0x80)
- regs->ch = 0x19;
- else
- regs->ch = 0x20;
- } else {
- regs->ch = inb_cmos(CMOS_CENTURY);
- }
+ regs->ch = GET_LOW(Century);
regs->al = regs->ch;
set_success(regs);
}
@@ -454,8 +461,7 @@ handle_1a05(struct bregs *regs)
outb_cmos(regs->cl, CMOS_RTC_YEAR);
outb_cmos(regs->dh, CMOS_RTC_MONTH);
outb_cmos(regs->dl, CMOS_RTC_DAY_MONTH);
- if (!CONFIG_COREBOOT)
- outb_cmos(regs->ch, CMOS_CENTURY);
+ SET_LOW(Century, regs->ch);
// clear halt-clock bit
u8 val8 = inb_cmos(CMOS_STATUS_B) & ~RTC_B_SET;
outb_cmos(val8, CMOS_STATUS_B);