[coreboot] [v2] r4170 - in trunk/coreboot-v2: src/include/boot src/pc80 util/options

svn at coreboot.org svn at coreboot.org
Wed Apr 22 11:03:08 CEST 2009


Author: stepan
Date: 2009-04-22 11:03:08 +0200 (Wed, 22 Apr 2009)
New Revision: 4170

Modified:
   trunk/coreboot-v2/src/include/boot/coreboot_tables.h
   trunk/coreboot-v2/src/pc80/mc146818rtc.c
   trunk/coreboot-v2/src/pc80/mc146818rtc_early.c
   trunk/coreboot-v2/util/options/build_opt_tbl.c
Log:
* Allow coreboot to use the full 256 bytes of CMOS memory
* Make functions out of the accessor macros in mc146818rtc.c
* don't hide reserved cmos entries from coreboot, only from the user.

Signed-off-by: Stefan Reinauer <stepan at coresystems.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>


Modified: trunk/coreboot-v2/src/include/boot/coreboot_tables.h
===================================================================
--- trunk/coreboot-v2/src/include/boot/coreboot_tables.h	2009-04-22 08:56:50 UTC (rev 4169)
+++ trunk/coreboot-v2/src/include/boot/coreboot_tables.h	2009-04-22 09:03:08 UTC (rev 4170)
@@ -223,7 +223,7 @@
 	uint32_t size;               /* length of this record */
 	uint32_t name_length;        /* length of the following name field */
 	uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */
-#define CMOS_IMAGE_BUFFER_SIZE 128
+#define CMOS_IMAGE_BUFFER_SIZE 256
 	uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */
 };
 

Modified: trunk/coreboot-v2/src/pc80/mc146818rtc.c
===================================================================
--- trunk/coreboot-v2/src/pc80/mc146818rtc.c	2009-04-22 08:56:50 UTC (rev 4169)
+++ trunk/coreboot-v2/src/pc80/mc146818rtc.c	2009-04-22 09:03:08 UTC (rev 4170)
@@ -4,16 +4,6 @@
 #include <boot/coreboot_tables.h>
 #include <string.h>
 
-#define CMOS_READ(addr) ({ \
-outb((addr),RTC_PORT(0)); \
-inb(RTC_PORT(1)); \
-})
-
-#define CMOS_WRITE(val, addr) ({ \
-outb((addr),RTC_PORT(0)); \
-outb((val),RTC_PORT(1)); \
-})
-
 /* control registers - Moto names
  */
 #define RTC_REG_A		10
@@ -83,7 +73,27 @@
 # define RTC_VRT 0x80		/* valid RAM and time */
 /**********************************************************************/
 
+static inline unsigned char cmos_read(unsigned char addr)
+{
+	int offs = 0;
+	if (addr >= 128) {
+		offs = 2;
+		addr -= 128;
+	}
+	outb(addr, RTC_BASE_PORT + offs + 0);
+	return inb(RTC_BASE_PORT + offs + 1);
+}
 
+static inline void cmos_write(unsigned char val, unsigned char addr)
+{
+	int offs = 0;
+	if (addr >= 128) {
+		offs = 2;
+		addr -= 128;
+	}
+	outb(addr, RTC_BASE_PORT + offs + 0);
+	outb(val, RTC_BASE_PORT + offs + 1);
+}
 
 static int rtc_checksum_valid(int range_start, int range_end, int cks_loc)
 {
@@ -91,10 +101,10 @@
 	unsigned sum, old_sum;
 	sum = 0;
 	for(i = range_start; i <= range_end; i++) {
-		sum += CMOS_READ(i);
+		sum += cmos_read(i);
 	}
 	sum = (~sum)&0x0ffff;
-	old_sum = ((CMOS_READ(cks_loc)<<8) | CMOS_READ(cks_loc+1))&0x0ffff;
+	old_sum = ((cmos_read(cks_loc)<<8) | cmos_read(cks_loc+1))&0x0ffff;
 	return sum == old_sum;
 }
 
@@ -104,11 +114,11 @@
 	unsigned sum;
 	sum = 0;
 	for(i = range_start; i <= range_end; i++) {
-		sum += CMOS_READ(i);
+		sum += cmos_read(i);
 	}
 	sum = ~(sum & 0x0ffff);
-	CMOS_WRITE(((sum >> 8) & 0x0ff), cks_loc);
-	CMOS_WRITE(((sum >> 0) & 0x0ff), cks_loc+1);
+	cmos_write(((sum >> 8) & 0x0ff), cks_loc);
+	cmos_write(((sum >> 0) & 0x0ff), cks_loc+1);
 }
 
 #define RTC_CONTROL_DEFAULT (RTC_24H)
@@ -130,7 +140,7 @@
 
 #if HAVE_OPTION_TABLE
 	/* See if there has been a CMOS power problem. */
-	x = CMOS_READ(RTC_VALID);
+	x = cmos_read(RTC_VALID);
 	cmos_invalid = !(x & RTC_VRT);
 
 	/* See if there is a CMOS checksum error */
@@ -143,31 +153,31 @@
 			cmos_invalid?" Power Problem":"",
 			checksum_invalid?" Checksum invalid":"");
 #if 0
-		CMOS_WRITE(0, 0x01);
-		CMOS_WRITE(0, 0x03);
-		CMOS_WRITE(0, 0x05);
+		cmos_write(0, 0x01);
+		cmos_write(0, 0x03);
+		cmos_write(0, 0x05);
 		for(i = 10; i < 48; i++) {
-			CMOS_WRITE(0, i);
+			cmos_write(0, i);
 		}
 		
 		if (cmos_invalid) {
 			/* Now setup a default date of Sat 1 January 2000 */
-			CMOS_WRITE(0, 0x00); /* seconds */
-			CMOS_WRITE(0, 0x02); /* minutes */
-			CMOS_WRITE(1, 0x04); /* hours */
-			CMOS_WRITE(7, 0x06); /* day of week */
-			CMOS_WRITE(1, 0x07); /* day of month */
-			CMOS_WRITE(1, 0x08); /* month */
-			CMOS_WRITE(0, 0x09); /* year */
+			cmos_write(0, 0x00); /* seconds */
+			cmos_write(0, 0x02); /* minutes */
+			cmos_write(1, 0x04); /* hours */
+			cmos_write(7, 0x06); /* day of week */
+			cmos_write(1, 0x07); /* day of month */
+			cmos_write(1, 0x08); /* month */
+			cmos_write(0, 0x09); /* year */
 		}
 #endif
 	}
 #endif
 
 	/* Setup the real time clock */
-	CMOS_WRITE(RTC_CONTROL_DEFAULT, RTC_CONTROL);
+	cmos_write(RTC_CONTROL_DEFAULT, RTC_CONTROL);
 	/* Setup the frequency it operates at */
-	CMOS_WRITE(RTC_FREQ_SELECT_DEFAULT, RTC_FREQ_SELECT);
+	cmos_write(RTC_FREQ_SELECT_DEFAULT, RTC_FREQ_SELECT);
 
 #if HAVE_OPTION_TABLE
 	/* See if there is a LB CMOS checksum error */
@@ -182,7 +192,7 @@
 #endif
 
 	/* Clear any pending interrupts */
-	(void) CMOS_READ(RTC_INTR_FLAGS);
+	(void) cmos_read(RTC_INTR_FLAGS);
 }
 
 
@@ -207,7 +217,7 @@
 	byte=bit/8;	/* find the byte where the data starts */
 	byte_bit=bit%8; /* find the bit in the byte where the data starts */
 	if(length<9) {	/* one byte or less */
-		uchar = CMOS_READ(byte); /* load the byte */
+		uchar = cmos_read(byte); /* load the byte */
 		uchar >>= byte_bit;	/* shift the bits to byte align */
 		/* clear unspecified bits */
 		ret[0] = uchar & ((1 << length) -1);
@@ -215,7 +225,7 @@
 	else {	/* more that one byte so transfer the whole bytes */
 		for(i=0;length;i++,length-=8,byte++) {
 			/* load the byte */
-			ret[i]=CMOS_READ(byte);
+			ret[i]=cmos_read(byte);
 		}
 	}
 	return 0;

Modified: trunk/coreboot-v2/src/pc80/mc146818rtc_early.c
===================================================================
--- trunk/coreboot-v2/src/pc80/mc146818rtc_early.c	2009-04-22 08:56:50 UTC (rev 4169)
+++ trunk/coreboot-v2/src/pc80/mc146818rtc_early.c	2009-04-22 09:03:08 UTC (rev 4170)
@@ -10,14 +10,24 @@
 
 static unsigned char cmos_read(unsigned char addr)
 {
-	outb(addr, RTC_BASE_PORT + 0);
-	return inb(RTC_BASE_PORT + 1);
+	int offs = 0;
+	if (addr >= 128) {
+		offs = 2;
+		addr -= 128;
+	}
+	outb(addr, RTC_BASE_PORT + offs + 0);
+	return inb(RTC_BASE_PORT + offs + 1);
 }
 
 static void cmos_write(unsigned char val, unsigned char addr)
 {
-	outb(addr, RTC_BASE_PORT + 0);
-	outb(val, RTC_BASE_PORT + 1);
+	int offs = 0;
+	if (addr >= 128) {
+		offs = 2;
+		addr -= 128;
+	}
+	outb(addr, RTC_BASE_PORT + offs + 0);
+	outb(val, RTC_BASE_PORT + offs + 1);
 }
 
 static int cmos_error(void)

Modified: trunk/coreboot-v2/util/options/build_opt_tbl.c
===================================================================
--- trunk/coreboot-v2/util/options/build_opt_tbl.c	2009-04-22 08:56:50 UTC (rev 4169)
+++ trunk/coreboot-v2/util/options/build_opt_tbl.c	2009-04-22 09:03:08 UTC (rev 4170)
@@ -8,7 +8,7 @@
 #include "../../src/include/pc80/mc146818rtc.h"
 #include "../../src/include/boot/coreboot_tables.h"
 
-#define CMOS_IMAGE_BUFFER_SIZE 128
+#define CMOS_IMAGE_BUFFER_SIZE 256
 #define INPUT_LINE_MAX 256
 #define MAX_VALUE_BYTE_LENGTH 64
 
@@ -563,9 +563,7 @@
 				continue;
 			}
 			ce = (struct cmos_entries *)ptr;
-			if (ce->config == 'r') {
-				continue;
-			}
+
 			if (!is_ident((char *)ce->name)) {
 				fprintf(stderr, "Invalid identifier: %s\n",
 					ce->name);





More information about the coreboot mailing list