[PATCH] libpayload: rename config.h to libpayload-config.h
[coreboot.git] / payloads / libpayload / i386 / coreboot.c
index 8e4a19a5eedeeccaed84e71dd456f9053398a339..2a675afbe69b2fae28a63333016bb3de5be60876 100644 (file)
@@ -27,8 +27,8 @@
  * SUCH DAMAGE.
  */
 
+#include <libpayload-config.h>
 #include <libpayload.h>
-#include <sysinfo.h>
 #include <coreboot_tables.h>
 
 /*
@@ -75,6 +75,21 @@ static void cb_parse_serial(unsigned char *ptr, struct sysinfo_t *info)
        info->ser_ioport = ser->ioport;
 }
 
+#ifdef CONFIG_NVRAM
+static void cb_parse_optiontable(unsigned char *ptr, struct sysinfo_t *info)
+{
+       info->option_table = (struct cb_cmos_option_table *)ptr;
+}
+
+static void cb_parse_checksum(unsigned char *ptr, struct sysinfo_t *info)
+{
+       struct cb_cmos_checksum *cmos_cksum = (struct cb_cmos_checksum *)ptr;
+       info->cmos_range_start = cmos_cksum->range_start;
+       info->cmos_range_end = cmos_cksum->range_end;
+       info->cmos_checksum_location = cmos_cksum->location;
+}
+#endif
+
 static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
 {
        struct cb_header *header;
@@ -95,10 +110,10 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
                return 0;
 
        /* Make sure the checksums match. */
-       if (ipchksum((uint16_t *) header, sizeof(*header)) != 0)
+       if (ipchksum((u16 *) header, sizeof(*header)) != 0)
                return -1;
 
-       if (ipchksum((uint16_t *) (ptr + sizeof(*header)),
+       if (ipchksum((u16 *) (ptr + sizeof(*header)),
                     header->table_bytes) != header->table_checksum)
                return -1;
 
@@ -116,6 +131,14 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
                case CB_TAG_SERIAL:
                        cb_parse_serial(ptr, info);
                        break;
+#ifdef CONFIG_NVRAM
+               case CB_TAG_CMOS_OPTION_TABLE:
+                       cb_parse_optiontable(ptr, info);
+                       break;
+               case CB_TAG_OPTION_CHECKSUM:
+                       cb_parse_checksum(ptr, info);
+                       break;
+#endif
                }
 
                ptr += rec->size;
@@ -129,10 +152,10 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
 
 int get_coreboot_info(struct sysinfo_t *info)
 {
-       int ret = cb_parse_header((void *)0x0, 0x1000, info);
+       int ret = cb_parse_header(phys_to_virt(0x00000000), 0x1000, info);
 
        if (ret != 1)
-               ret = cb_parse_header((void *)0xf0000, 0x1000, info);
+               ret = cb_parse_header(phys_to_virt(0x000f0000), 0x1000, info);
 
        return (ret == 1) ? 0 : -1;
 }