Stefan Reinauer (stefan.reinauer@coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3115
-gerrit
commit a3d7da4d1ec532f77828a621924b32881c2e8a95 Author: Stefan Reinauer reinauer@chromium.org Date: Thu Apr 18 18:01:34 2013 -0700
Eliminate use of pointers in coreboot table
Because pointers can be 32bit or 64bit big, using them in the coreboot table requires the OS and the firmware to operate in the same mode which is not always the case. Hence, use 64bit for all pointers stored in the coreboot table. Guess we'll have to fix this up once we port to the first 128bit machines.
Change-Id: I46fc1dad530e5230986f7aa5740595428ede4f93 Signed-off-by: Stefan Reinauer reinauer@google.com --- payloads/libpayload/include/coreboot_tables.h | 6 +++--- src/include/boot/coreboot_tables.h | 4 ++-- src/lib/coreboot_table.c | 2 +- src/vendorcode/google/chromeos/gnvs.c | 4 ++-- src/vendorcode/google/chromeos/gnvs.h | 2 +- util/cbmem/cbmem.c | 26 +++++++++++++++++++++++--- 6 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index 02c9449..3889ede 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -188,7 +188,7 @@ struct cb_gpios { struct cb_vdat { uint32_t tag; uint32_t size; /* size of the entire entry */ - void *vdat_addr; + uint64_t vdat_addr; uint32_t vdat_size; };
@@ -198,7 +198,7 @@ struct cb_vdat { struct cb_cbmem_tab { uint32_t tag; uint32_t size; - void *cbmem_tab; + uint64_t cbmem_tab; };
#define CB_TAG_VBNV 0x0019 @@ -213,7 +213,7 @@ struct cb_vbnv { struct cb_vboot_handoff { uint32_t tag; uint32_t size; - void *vboot_handoff_addr; + uint64_t vboot_handoff_addr; uint32_t vboot_handoff_size; };
diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h index a7e4ab0..ee1c29f 100644 --- a/src/include/boot/coreboot_tables.h +++ b/src/include/boot/coreboot_tables.h @@ -218,7 +218,7 @@ struct lb_vdat { uint32_t tag; uint32_t size;
- void *vdat_addr; + uint64_t vdat_addr; uint32_t vdat_size; };
@@ -246,7 +246,7 @@ struct lb_vboot_handoff { uint32_t tag; uint32_t size;
- void *vboot_handoff_addr; + uint64_t vboot_handoff_addr; uint32_t vboot_handoff_size; };
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c index 765c510..d25b59d 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -232,7 +232,7 @@ static void lb_vboot_handoff(struct lb_header *header) vbho = (struct lb_vboot_handoff *)lb_new_record(header); vbho->tag = LB_TAB_VBOOT_HANDOFF; vbho->size = sizeof(*vbho); - vbho->vboot_handoff_addr = addr; + vbho->vboot_handoff_addr = (intptr_t)addr; vbho->vboot_handoff_size = size; } #else diff --git a/src/vendorcode/google/chromeos/gnvs.c b/src/vendorcode/google/chromeos/gnvs.c index 0d40950..5ee3665 100644 --- a/src/vendorcode/google/chromeos/gnvs.c +++ b/src/vendorcode/google/chromeos/gnvs.c @@ -79,8 +79,8 @@ void chromeos_set_me_hash(u32 *hash, int len) memcpy(me_hash_saved, hash, len*sizeof(u32)); }
-void acpi_get_vdat_info(void **vdat_addr, uint32_t *vdat_size) +void acpi_get_vdat_info(uint64_t *vdat_addr, uint32_t *vdat_size) { - *vdat_addr = vboot_data; + *vdat_addr = (intptr_t)vboot_data; *vdat_size = sizeof(*vboot_data); } diff --git a/src/vendorcode/google/chromeos/gnvs.h b/src/vendorcode/google/chromeos/gnvs.h index 4067494..00fe443 100644 --- a/src/vendorcode/google/chromeos/gnvs.h +++ b/src/vendorcode/google/chromeos/gnvs.h @@ -64,6 +64,6 @@ typedef struct { extern chromeos_acpi_t *vboot_data; void chromeos_init_vboot(chromeos_acpi_t *chromeos); void chromeos_set_me_hash(u32*, int); -void acpi_get_vdat_info(void **vdat_addr, uint32_t *vdat_size); +void acpi_get_vdat_info(uint64_t *vdat_addr, uint32_t *vdat_size);
#endif diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c index 1ff9a08..44d936d 100644 --- a/util/cbmem/cbmem.c +++ b/util/cbmem/cbmem.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <inttypes.h> #include <getopt.h> #include <errno.h> #include <fcntl.h> @@ -127,12 +128,31 @@ static struct lb_cbmem_ref timestamps; static struct lb_cbmem_ref console; static struct lb_memory_range cbmem;
+/* This is a work-around for a nasty problem introduced by initially having + * pointer sized entries in the lb_cbmem_ref structures. This caused problems + * on 64bit x86 systems because coreboot is 32bit on those systems. + * When the problem was found, it was corrected, but there are a lot of systems + * out there with a firmware that does not produce the right lb_cbmem_ref structure. + * Hence we try to autocorrect this issue here. + */ +static struct lb_cbmem_ref parse_cbmem_ref(struct lb_cbmem_ref *cbmem_ref) +{ + static struct lb_cbmem_ref ret; + + ret = *cbmem_ref; + + if (cbmem_ref->size < sizeof(*cbmem_ref)) + ret.cbmem_addr &= 0xffffffff; + + return ret; +} + static int parse_cbtable(u64 address) { int i, found = 0; void *buf;
- debug("Looking for coreboot table at %llx\n", address); + debug("Looking for coreboot table at %" PRIx64 "\n", address); buf = map_memory(address);
/* look at every 16 bytes within 4K of the base */ @@ -183,12 +203,12 @@ static int parse_cbtable(u64 address) } case LB_TAG_TIMESTAMPS: { debug(" Found timestamp table.\n"); - timestamps = *(struct lb_cbmem_ref *) lbr_p; + timestamps = parse_cbmem_ref((struct lb_cbmem_ref *) lbr_p); continue; } case LB_TAG_CBMEM_CONSOLE: { debug(" Found cbmem console.\n"); - console = *(struct lb_cbmem_ref *) lbr_p; + console = parse_cbmem_ref((struct lb_cbmem_ref *) lbr_p); continue; } case LB_TAG_FORWARD: {