Philip Prindeville (pprindeville(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/499
-gerrit
commit db051bf5228810b95952960bdc66fb37f004c09f
Author: Philip Prindeville <philipp(a)redfish-solutions.com>
Date: Fri Dec 23 17:36:09 2011 -0700
Fix missing VM mapping
When processing FORWARD records, we weren't accounting for the pointer
being in the physical address space and not the virtual space instead.
Change-Id: I35ef637fbec7886d4cfeac5fd650a17eae8d555a
Signed-off-by: Philip Prindeville <philipp(a)redfish-solutions.com>
---
payloads/libpayload/arch/i386/coreboot.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/payloads/libpayload/arch/i386/coreboot.c b/payloads/libpayload/arch/i386/coreboot.c
index 3c99c4f..709f8ae 100644
--- a/payloads/libpayload/arch/i386/coreboot.c
+++ b/payloads/libpayload/arch/i386/coreboot.c
@@ -113,6 +113,7 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
{
struct cb_header *header;
unsigned char *ptr = addr;
+ void *forward;
int i;
for (i = 0; i < len; i += 16, ptr += 16) {
@@ -145,7 +146,8 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
/* We only care about a few tags here (maybe more later). */
switch (rec->tag) {
case CB_TAG_FORWARD:
- return cb_parse_header((void *)(unsigned long)((struct cb_forward *)rec)->forward, len, info);
+ forward = phys_to_virt((void *)(unsigned long)((struct cb_forward *)rec)->forward);
+ return cb_parse_header(forward, len, info);
continue;
case CB_TAG_MEMORY:
cb_parse_memory(ptr, info);
Philip Prindeville (pprindeville(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/503
-gerrit
commit e11cec94e22b2a6c4086656006a0667ec648e0d5
Author: Philip Prindeville <philipp(a)redfish-solutions.com>
Date: Fri Dec 23 18:33:05 2011 -0700
Let lib_get_sysinfo() pass through the success of get_coreboot_info()
The return status of get_coreboot_info() might be handy to a platform
driver calling lib_get_sysinfo() to test for the presence of coreboot.
Change-Id: I0176c93ee92c9dff733112026ee50f2ca797bdff
Signed-off-by: Philip Prindeville <philipp(a)redfish-solutions.com>
---
payloads/libpayload/arch/i386/sysinfo.c | 8 ++++++--
payloads/libpayload/arch/powerpc/sysinfo.c | 8 ++++++--
payloads/libpayload/include/libpayload.h | 2 +-
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/payloads/libpayload/arch/i386/sysinfo.c b/payloads/libpayload/arch/i386/sysinfo.c
index 599a811..6c1ef3f 100644
--- a/payloads/libpayload/arch/i386/sysinfo.c
+++ b/payloads/libpayload/arch/i386/sysinfo.c
@@ -45,8 +45,10 @@ struct sysinfo_t lib_sysinfo = {
#endif
};
-void lib_get_sysinfo(void)
+int lib_get_sysinfo(void)
{
+ int ret;
+
/* Get the CPU speed (for delays). */
lib_sysinfo.cpu_khz = get_cpu_speed();
@@ -59,7 +61,7 @@ void lib_get_sysinfo(void)
/* Get information from the coreboot tables,
* if they exist */
- get_coreboot_info(&lib_sysinfo);
+ ret = get_coreboot_info(&lib_sysinfo);
if (!lib_sysinfo.n_memranges) {
/* If we can't get a good memory range, use the default. */
@@ -73,4 +75,6 @@ void lib_get_sysinfo(void)
lib_sysinfo.memrange[1].size = 31 * 1024 * 1024;
lib_sysinfo.memrange[1].type = CB_MEM_RAM;
}
+
+ return ret;
}
diff --git a/payloads/libpayload/arch/powerpc/sysinfo.c b/payloads/libpayload/arch/powerpc/sysinfo.c
index 599a811..6c1ef3f 100644
--- a/payloads/libpayload/arch/powerpc/sysinfo.c
+++ b/payloads/libpayload/arch/powerpc/sysinfo.c
@@ -45,8 +45,10 @@ struct sysinfo_t lib_sysinfo = {
#endif
};
-void lib_get_sysinfo(void)
+int lib_get_sysinfo(void)
{
+ int ret;
+
/* Get the CPU speed (for delays). */
lib_sysinfo.cpu_khz = get_cpu_speed();
@@ -59,7 +61,7 @@ void lib_get_sysinfo(void)
/* Get information from the coreboot tables,
* if they exist */
- get_coreboot_info(&lib_sysinfo);
+ ret = get_coreboot_info(&lib_sysinfo);
if (!lib_sysinfo.n_memranges) {
/* If we can't get a good memory range, use the default. */
@@ -73,4 +75,6 @@ void lib_get_sysinfo(void)
lib_sysinfo.memrange[1].size = 31 * 1024 * 1024;
lib_sysinfo.memrange[1].type = CB_MEM_RAM;
}
+
+ return ret;
}
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 8c8abc4..d9f7d21 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -369,7 +369,7 @@ int sysinfo_have_multiboot(unsigned long *addr);
int get_coreboot_info(struct sysinfo_t *info);
int get_multiboot_info(struct sysinfo_t *info);
-void lib_get_sysinfo(void);
+int lib_get_sysinfo(void);
/* Timer functions - defined by each architecture. */
unsigned int get_cpu_speed(void);
Philip Prindeville (pprindeville(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/501
-gerrit
commit 3aa126fcf9ced443618b7600069376b0202edaee
Author: Philip Prindeville <philipp(a)redfish-solutions.com>
Date: Fri Dec 23 18:09:25 2011 -0700
cb_parse_header() should not assume table in 4K of contiguous memory
If we have the CB table in E820 memory, we might not have an entire 4K
(0x1000) bytes of memory to scan through. Instead, a better strategy
is to pass in a pointer to the end of the region or the start + 4K
(which ever is lower). This change prepares the cb_parse_header()
calling convention for that change.
Change-Id: I9257726c6a7065b5596d4c32ab451edd0a3cdc10
Signed-off-by: Philip Prindeville <philipp(a)redfish-solutions.com>
---
payloads/libpayload/arch/i386/coreboot.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/payloads/libpayload/arch/i386/coreboot.c b/payloads/libpayload/arch/i386/coreboot.c
index 709f8ae..135c59c 100644
--- a/payloads/libpayload/arch/i386/coreboot.c
+++ b/payloads/libpayload/arch/i386/coreboot.c
@@ -109,21 +109,21 @@ static void cb_parse_framebuffer(void *ptr, struct sysinfo_t *info)
}
#endif
-static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
+static int cb_parse_header(void *addr, void *end, struct sysinfo_t *info)
{
struct cb_header *header;
- unsigned char *ptr = addr;
+ unsigned char *ptr;
void *forward;
int i;
- for (i = 0; i < len; i += 16, ptr += 16) {
+ for (ptr = addr; (void *)ptr < end; ptr += 16) {
header = (struct cb_header *)ptr;
if (!strncmp((const char *)header->signature, "LBIO", 4))
break;
}
/* We walked the entire space and didn't find anything. */
- if (i >= len)
+ if ((void *)ptr >= end)
return -1;
if (!header->table_bytes)
@@ -147,7 +147,7 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
switch (rec->tag) {
case CB_TAG_FORWARD:
forward = phys_to_virt((void *)(unsigned long)((struct cb_forward *)rec)->forward);
- return cb_parse_header(forward, len, info);
+ return cb_parse_header(forward, forward + 0x1000, info);
continue;
case CB_TAG_MEMORY:
cb_parse_memory(ptr, info);
@@ -176,6 +176,9 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
}
ptr += rec->size;
+
+ if ((void *)ptr >= end)
+ return -1;
}
return 1;
@@ -186,10 +189,13 @@ 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(phys_to_virt(0x00000000), 0x1000, info);
+ void *base = phys_to_virt(0x00000000);
+ int ret = cb_parse_header(base, base + 0x1000, info);
- if (ret != 1)
- ret = cb_parse_header(phys_to_virt(0x000f0000), 0x1000, info);
+ if (ret != 1) {
+ base = phys_to_virt(0x000f0000);
+ ret = cb_parse_header(base, base + 0x1000, info);
+ }
return (ret == 1) ? 0 : -1;
}
Philip Prindeville (pprindeville(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/497
-gerrit
commit bde765381d216bb9144b3950aa101d6e987ebc07
Author: Philip Prindeville <philipp(a)redfish-solutions.com>
Date: Fri Dec 23 17:22:05 2011 -0700
Use convenience function to checksum
That coreboot uses the IP checksum is an artifact, not a deliberate
requirement to be compatible with the Internet Protocole suite. Use
a wrapper to abstract the computation of coreboot's checksum.
Change-Id: I6491b9ba5efb9ffe5cb12a6172653a6ac80a1370
Signed-off-by: Philip Prindeville <philipp(a)redfish-solutions.com>
---
payloads/coreinfo/coreboot_module.c | 6 +++---
payloads/libpayload/include/coreboot_tables.h | 5 +++++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/payloads/coreinfo/coreboot_module.c b/payloads/coreinfo/coreboot_module.c
index 5d13128..7289366 100644
--- a/payloads/coreinfo/coreboot_module.c
+++ b/payloads/coreinfo/coreboot_module.c
@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <coreboot_tables.h>
#include "coreinfo.h"
+#include <coreboot_tables.h>
#ifdef CONFIG_MODULE_COREBOOT
@@ -189,10 +189,10 @@ static int parse_header(void *addr, int len)
/* FIXME: Check the checksum. */
- if (ipchksum((uint16_t *) header, sizeof(*header)))
+ if (cb_checksum(header, sizeof(*header)))
return -1;
- if (ipchksum((uint16_t *) (ptr + sizeof(*header)), header->table_bytes)
+ if (cb_checksum((ptr + sizeof(*header)), header->table_bytes)
!= header->table_checksum)
return -1;
diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h
index 3b3b7d2..574469a 100644
--- a/payloads/libpayload/include/coreboot_tables.h
+++ b/payloads/libpayload/include/coreboot_tables.h
@@ -223,6 +223,11 @@ static inline u64 cb_unpack64(struct cbuint64 val)
return (((u64) val.hi) << 32) | val.lo;
}
+static inline u16 cb_checksum(const void *ptr, unsigned len)
+{
+ return ipchksum(ptr, len);
+}
+
/* Helpful macros */
#define MEM_RANGE_COUNT(_rec) \