]> xenbits.xensource.com Git - seabios.git/commitdiff
Determine century during init and store in VARLOW mem during runtime.
authorKevin O'Connor <kevin@koconnor.net>
Fri, 8 Feb 2013 04:41:53 +0000 (23:41 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 9 Feb 2013 16:09:36 +0000 (11:09 -0500)
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>
src/clock.c

index 3edcaf52dcc7b05451797014d642be5d42e19580..bbcafd79b5eaad26fb5ace09d6c8b8b7d577edec 100644 (file)
@@ -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);