The wake_vec must be HAVE_ACPI_RESUME guarded because PPC uses -Werror on this file.
[coreboot.git] / src / pc80 / mc146818rtc_early.c
index 30369455fef9f20eac3212e02a3c8884a3d1b7bc..0c7d822718136e4c9a98073bf1d4830ac64a96ad 100644 (file)
@@ -4,7 +4,7 @@
 #ifndef MAX_REBOOT_CNT
 #error "MAX_REBOOT_CNT not defined"
 #endif
-#if  MAX_REBOOT_CNT > 14
+#if  MAX_REBOOT_CNT > 15
 #error "MAX_REBOOT_CNT too high"
 #endif
 
@@ -78,6 +78,12 @@ static int do_normal_boot(void)
                byte &= 0x0f; /* yes, clear the boot count */
        }
 
+       /* Properly set the last boot flag */
+       byte &= 0xfc;
+       if ((byte >> 4) < MAX_REBOOT_CNT) {
+               byte |= (1<<1);
+       }
+
        /* Are we already at the max count? */
        if ((byte >> 4) < MAX_REBOOT_CNT) {
                byte += 1 << 4; /* No, add 1 to the count */
@@ -86,13 +92,19 @@ static int do_normal_boot(void)
                byte &= 0xfc;   /* Yes, put in fallback mode */
        }
 
-       /* Is this the first boot? */
-       if ((byte >> 4) <= 1) {
-               byte = (byte & 0xfc) | ((byte & 1) << 1); /* yes, shift the boot bits */
-       }
-
        /* Save the boot byte */
        cmos_write(byte, RTC_BOOT_BYTE);
 
-       return ((byte >> 4) < MAX_REBOOT_CNT);
+       return (byte & (1<<1));
+}
+
+static unsigned read_option(unsigned start, unsigned size, unsigned def)
+{
+#if USE_OPTION_TABLE == 1
+       unsigned byte;
+       byte = cmos_read(start/8);
+       return (byte >> (start & 7U)) & ((1U << size) - 1U);
+#else
+       return def;
+#endif
 }