summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2009-04-22 09:03:08 +0000
committerStefan Reinauer <stepan@openbios.org>2009-04-22 09:03:08 +0000
commit73d5daaf97465776a4ef6ae5c99a5badaeba292b (patch)
treeeb21aeb759061616ec4892104d010910f5196ab4
parent953253f093302ccee1cc634772a4561ffbe32355 (diff)
* 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@coresystems.de> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4170 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--src/include/boot/coreboot_tables.h2
-rw-r--r--src/pc80/mc146818rtc.c74
-rw-r--r--src/pc80/mc146818rtc_early.c18
-rw-r--r--util/options/build_opt_tbl.c6
4 files changed, 59 insertions, 41 deletions
diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h
index f0ab7af7cb..0385db9093 100644
--- a/src/include/boot/coreboot_tables.h
+++ b/src/include/boot/coreboot_tables.h
@@ -223,7 +223,7 @@ struct cmos_defaults {
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 */
};
diff --git a/src/pc80/mc146818rtc.c b/src/pc80/mc146818rtc.c
index 5da888071f..0baa389c1f 100644
--- a/src/pc80/mc146818rtc.c
+++ b/src/pc80/mc146818rtc.c
@@ -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 @@ outb((val),RTC_PORT(1)); \
# 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 @@ static int rtc_checksum_valid(int range_start, int range_end, int cks_loc)
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 @@ static void rtc_set_checksum(int range_start, int range_end, int cks_loc)
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 @@ void rtc_init(int invalid)
#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 @@ void rtc_init(int invalid)
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 @@ void rtc_init(int invalid)
#endif
/* Clear any pending interrupts */
- (void) CMOS_READ(RTC_INTR_FLAGS);
+ (void) cmos_read(RTC_INTR_FLAGS);
}
@@ -207,7 +217,7 @@ static int get_cmos_value(unsigned long bit, unsigned long length, void *vret)
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 @@ static int get_cmos_value(unsigned long bit, unsigned long length, void *vret)
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;
diff --git a/src/pc80/mc146818rtc_early.c b/src/pc80/mc146818rtc_early.c
index 0c7d822718..83e340c70b 100644
--- a/src/pc80/mc146818rtc_early.c
+++ b/src/pc80/mc146818rtc_early.c
@@ -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)
diff --git a/util/options/build_opt_tbl.c b/util/options/build_opt_tbl.c
index 4d98f8ecee..cca1b7c464 100644
--- a/util/options/build_opt_tbl.c
+++ b/util/options/build_opt_tbl.c
@@ -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 @@ int main(int argc, char **argv)
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);