Patchwork cmos update

login
register
about
Submitter Stefan Reinauer
Date 2010-03-29 19:14:44
Message ID <4BB0FC24.4060401@coresystems.de>
Download mbox | patch
Permalink /patch/1174/
State New
Headers show

Comments

Stefan Reinauer - 2010-03-29 19:14:44
This patch makes the assumption that the code doing the cmos choice has
CONFIG_USE_OPTION_TABLE enabled.

Is this always the case?
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Myles Watson - 2010-03-29 20:01:24
On Mon, Mar 29, 2010 at 1:14 PM, Stefan Reinauer <stepan@coresystems.de>wrote:

>  This patch makes the assumption that the code doing the cmos choice has
> CONFIG_USE_OPTION_TABLE enabled.
>
> Is this always the case?
>
I thought qemu checked CMOS values to know how much RAM there was, but
didn't have USE_OPTION_TABLE set.  It's been a long time since I looked at
it, though.

Thanks,
Myles
Stefan Reinauer - 2010-03-29 21:24:23
On 3/29/10 10:01 PM, Myles Watson wrote:
>
>
> On Mon, Mar 29, 2010 at 1:14 PM, Stefan Reinauer
> <stepan@coresystems.de <mailto:stepan@coresystems.de>> wrote:
>
>     This patch makes the assumption that the code doing the cmos
>     choice has CONFIG_USE_OPTION_TABLE enabled.
>
>     Is this always the case?
>
> I thought qemu checked CMOS values to know how much RAM there was, but
> didn't have USE_OPTION_TABLE set.  It's been a long time since I
> looked at it, though.
I thought it would, but it seems it doesn't...

If it did, we should leave the cmos primitives always in, and only make
the higher level funktions depend on USE_ or HAVE_OPTION_TABLE

Patch

Index: src/include/pc80/mc146818rtc.h
===================================================================
--- src/include/pc80/mc146818rtc.h	(revision 5314)
+++ src/include/pc80/mc146818rtc.h	(working copy)
@@ -82,7 +82,7 @@ 
 #define PC_CKS_LOC		46
 
 /* coreboot cmos checksum is usually only built over bytes 49..125 */
-#ifdef AUTOCONF_INCLUDED
+#if defined(AUTOCONF_INCLUDED) && (CONFIG_USE_OPTION_TABLE == 1)
 #include <option_table.h>
 #endif
 
Index: src/pc80/mc146818rtc_early.c
===================================================================
--- src/pc80/mc146818rtc_early.c	(revision 5314)
+++ src/pc80/mc146818rtc_early.c	(working copy)
@@ -8,6 +8,7 @@ 
 #error "CONFIG_MAX_REBOOT_CNT too high"
 #endif
 
+#if CONFIG_USE_OPTION_TABLE == 1
 static unsigned char cmos_read(unsigned char addr)
 {
 	int offs = 0;
@@ -55,19 +56,23 @@ 
 
 	return sum == old_sum;
 }
+#endif
 
-
 static inline int last_boot_normal(void)
 {
+#if CONFIG_USE_OPTION_TABLE == 1
 	unsigned char byte;
 	byte = cmos_read(RTC_BOOT_BYTE);
 	return (byte & (1 << 1));
+#else
+	return 0;
+#endif
 }
 
 static inline int do_normal_boot(void)
 {
 	unsigned char byte;
-
+#if CONFIG_USE_OPTION_TABLE == 1
 	if (cmos_error() || !cmos_chksum_valid()) {
 		/* There are no impossible values, no checksums so just
 		 * trust whatever value we have in the the cmos,
@@ -105,6 +110,9 @@ 
 	cmos_write(byte, RTC_BOOT_BYTE);
 
 	return (byte & (1<<1));
+#else
+	return 0;
+#endif
 }
 
 static inline unsigned read_option(unsigned start, unsigned size, unsigned def)