Marc Jones (marc.jones@se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7905
-gerrit
commit 9bdbe0c10ee002dc59355b7f8fff0ba010f1d7ec Author: Furquan Shaikh furquan@google.com Date: Tue May 13 13:47:32 2014 -0700
libpayload: Fix pointer related casts
Fix pointer related casts since this can create a problem for 64-bit systems.
BUG=None BRANCH=None TEST=Compiled successfully for link, nyan using emerge-* libpayload
Original-Change-Id: I4cbd2d9f1efaaac87c3eba69204337fd6893ed66 Original-Reviewed-on: https://chromium-review.googlesource.com/199564 Original-Reviewed-by: Furquan Shaikh furquan@chromium.org Original-Commit-Queue: Furquan Shaikh furquan@chromium.org Original-Tested-by: Furquan Shaikh furquan@chromium.org (cherry picked from commit 914b118a64b0691aeca463dff24252db9c24109e) Signed-off-by: Marc Jones marc.jones@se-eng.com
Change-Id: I11f070ed5d3eddd8b9be30c428cb24c8439e617b --- payloads/libpayload/drivers/usb/xhci.c | 2 +- payloads/libpayload/include/usb/usb.h | 3 ++- payloads/libpayload/libc/malloc.c | 9 +++++---- payloads/libpayload/libcbfs/cbfs.c | 10 +++++----- 4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/payloads/libpayload/drivers/usb/xhci.c b/payloads/libpayload/drivers/usb/xhci.c index c60a967..9807858 100644 --- a/payloads/libpayload/drivers/usb/xhci.c +++ b/payloads/libpayload/drivers/usb/xhci.c @@ -166,7 +166,7 @@ xhci_init (unsigned long physical_bar) controller->poll_intr_queue = xhci_poll_intr_queue; controller->pcidev = 0;
- controller->reg_base = (u32)physical_bar; + controller->reg_base = (uintptr_t)physical_bar; controller->instance = xzalloc(sizeof(xhci_t)); xhci_t *const xhci = (xhci_t *)controller->instance;
diff --git a/payloads/libpayload/include/usb/usb.h b/payloads/libpayload/include/usb/usb.h index ec9912a..4d8b2c2 100644 --- a/payloads/libpayload/include/usb/usb.h +++ b/payloads/libpayload/include/usb/usb.h @@ -31,6 +31,7 @@ #define __USB_H #include <libpayload.h> #include <pci/pci.h> +#include <stdint.h>
typedef enum { host_to_device = 0, device_to_host = 1 } dev_req_dir; typedef enum { standard_type = 0, class_type = 1, vendor_type = @@ -210,7 +211,7 @@ typedef enum { OHCI = 0, UHCI = 1, EHCI = 2, XHCI = 3} hc_type;
struct usbdev_hc { hci_t *next; - u32 reg_base; + uintptr_t reg_base; pcidev_t pcidev; // 0 if not used (eg on ARM) hc_type type; int latest_address; diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c index 0f2845d..1d99a9c 100644 --- a/payloads/libpayload/libc/malloc.c +++ b/payloads/libpayload/libc/malloc.c @@ -41,6 +41,7 @@
#define IN_MALLOC_C #include <libpayload.h> +#include <stdint.h>
struct memory_type { void *start; @@ -158,7 +159,7 @@ static void *alloc(int len, struct memory_type *type)
if (header & FLAG_FREE) { if (len <= size) { - hdrtype_t volatile *nptr = (hdrtype_t volatile *)((int)ptr + HDRSIZE + len); + hdrtype_t volatile *nptr = (hdrtype_t volatile *)((uintptr_t)ptr + HDRSIZE + len); int nsize = size - (HDRSIZE + len);
/* If there is still room in this block, @@ -177,11 +178,11 @@ static void *alloc(int len, struct memory_type *type) *ptr = USED_BLOCK(size); }
- return (void *)((int)ptr + HDRSIZE); + return (void *)((uintptr_t)ptr + HDRSIZE); } }
- ptr = (hdrtype_t volatile *)((int)ptr + HDRSIZE + size); + ptr = (hdrtype_t volatile *)((uintptr_t)ptr + HDRSIZE + size);
} while (ptr < (hdrtype_t *) type->end);
@@ -353,7 +354,7 @@ static struct align_region_t *allocate_region(int alignment, int num_elements, s free(new_region); return NULL; } - new_region->start_data = (void*)((u32)(new_region->start + num_elements + alignment - 1) & (~(alignment-1))); + new_region->start_data = (void*)((uintptr_t)(new_region->start + num_elements + alignment - 1) & (~(alignment-1))); new_region->size = num_elements * alignment; new_region->free = num_elements; new_region->next = type->align_regions; diff --git a/payloads/libpayload/libcbfs/cbfs.c b/payloads/libpayload/libcbfs/cbfs.c index 5610555..c4f01b5 100644 --- a/payloads/libpayload/libcbfs/cbfs.c +++ b/payloads/libpayload/libcbfs/cbfs.c @@ -135,21 +135,21 @@ void * cbfs_load_stage(struct cbfs_media *media, const char *name) cbfs_get_file_content(media, name, CBFS_TYPE_STAGE, NULL); /* this is a mess. There is no ntohll. */ /* for now, assume compatible byte order until we solve this. */ - uint32_t entry; + uintptr_t entry; uint32_t final_size;
if (stage == NULL) return (void *) -1;
- LOG("loading stage %s @ 0x%x (%d bytes), entry @ 0x%llx\n", + LOG("loading stage %s @ 0x%p (%d bytes), entry @ 0x%llx\n", name, - (uint32_t) stage->load, stage->memlen, + (void*)(uintptr_t) stage->load, stage->memlen, stage->entry);
final_size = cbfs_decompress(stage->compression, ((unsigned char *) stage) + sizeof(struct cbfs_stage), - (void *) (uint32_t) stage->load, + (void *) (uintptr_t) stage->load, stage->len); if (!final_size) return (void *) -1; @@ -180,7 +180,7 @@ int cbfs_execute_stage(struct cbfs_media *media, const char *name) }
/* FIXME: This isn't right */ - LOG("run @ %p\n", (void *) ntohl((uint32_t) stage->entry)); + LOG("run @ %p\n", (void *) (uintptr_t)ntohll(stage->entry)); return run_address((void *)(uintptr_t)ntohll(stage->entry)); }