summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-05-08 04:50:56 +0800
committerChromeBot <chrome-bot@google.com>2013-05-07 20:59:53 -0700
commit5007bbc009ccc8c8e64fac5f5540c85573d4ae80 (patch)
treeb0e7f1c5d4bd2ec286d8866759711b30cb5345a2 /common
parent235e6e1d0d713ddad79fa77d6982c006378053cd (diff)
downloadchrome-ec-5007bbc009ccc8c8e64fac5f5540c85573d4ae80.tar.gz
Use uintptr_t when converting integer from/to pointer
Perviously we use uint32_t for this, but this doesn't compile for 64-bit environment (and likely doesn't for 16-bit either.) Use uintptr_t so that we don't get size mismatch errors. BUG=chrome-os-partner:19257 TEST=Run host emulated tests BRANCH=None Change-Id: I3cd66a745fa171c41a5f142514284ec106586acb Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/50358 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/hooks.c2
-rw-r--r--common/memory_commands.c4
-rw-r--r--common/shared_mem.c2
-rw-r--r--common/system_common.c21
-rw-r--r--common/util.c4
5 files changed, 17 insertions, 16 deletions
diff --git a/common/hooks.c b/common/hooks.c
index d239e3abc2..7dbe08b5fe 100644
--- a/common/hooks.c
+++ b/common/hooks.c
@@ -61,7 +61,7 @@ void hook_notify(enum hook_type type)
start = hook_list[type].start;
end = hook_list[type].end;
- count = ((uint32_t)end - (uint32_t)start) / sizeof(struct hook_data);
+ count = end - start;
/* Call all the hooks in priority order */
while (called < count) {
diff --git a/common/memory_commands.c b/common/memory_commands.c
index dae18777fd..c8a1ea76df 100644
--- a/common/memory_commands.c
+++ b/common/memory_commands.c
@@ -17,7 +17,7 @@ static int command_write_word(int argc, char **argv)
if (argc != 3)
return EC_ERROR_PARAM_COUNT;
- address = (uint32_t *)strtoi(argv[1], &e, 0);
+ address = (uint32_t *)(uintptr_t)strtoi(argv[1], &e, 0);
if (*e)
return EC_ERROR_PARAM1;
@@ -46,7 +46,7 @@ static int command_read_word(int argc, char **argv)
if (argc != 2)
return EC_ERROR_PARAM_COUNT;
- address = (uint32_t *)strtoi(argv[1], &e, 0);
+ address = (uint32_t *)(uintptr_t)strtoi(argv[1], &e, 0);
if (*e)
return EC_ERROR_PARAM1;
diff --git a/common/shared_mem.c b/common/shared_mem.c
index 7ccf18c4b7..219019ef62 100644
--- a/common/shared_mem.c
+++ b/common/shared_mem.c
@@ -22,7 +22,7 @@ int shared_mem_size(void)
* allocated from the start of RAM, so we can use everything up to the
* jump data at the end of RAM.
*/
- return system_usable_ram_end() - (uint32_t)__shared_mem_buf;
+ return system_usable_ram_end() - (uintptr_t)__shared_mem_buf;
}
int shared_mem_acquire(int size, char **dest_ptr)
diff --git a/common/system_common.c b/common/system_common.c
index 239dd12a75..4df9aa70df 100644
--- a/common/system_common.c
+++ b/common/system_common.c
@@ -104,7 +104,7 @@ int system_is_locked(void)
#endif
}
-test_mockable int system_usable_ram_end(void)
+test_mockable uintptr_t system_usable_ram_end(void)
{
/* Leave space at the end of RAM for jump data and tags.
*
@@ -113,7 +113,7 @@ test_mockable int system_usable_ram_end(void)
* tags after a sysjump. When verified boot runs after a reboot, it'll
* have as much RAM as we can give it; after verified boot jumps to
* another image there'll be less RAM, but we'll care less too. */
- return (uint32_t)jdata - jdata->jump_tag_total;
+ return (uintptr_t)jdata - jdata->jump_tag_total;
}
uint32_t system_get_reset_flags(void)
@@ -215,7 +215,8 @@ void system_disable_jump(void)
enum system_image_copy_t system_get_image_copy(void)
{
- uint32_t my_addr = (uint32_t)system_get_image_copy - CONFIG_FLASH_BASE;
+ uintptr_t my_addr = (uintptr_t)system_get_image_copy -
+ CONFIG_FLASH_BASE;
if (my_addr >= CONFIG_SECTION_RO_OFF &&
my_addr < (CONFIG_SECTION_RO_OFF + CONFIG_SECTION_RO_SIZE))
@@ -293,7 +294,7 @@ const char *system_get_image_copy_string(void)
*
* @param init_addr Init address of target image
*/
-static void jump_to_image(uint32_t init_addr)
+static void jump_to_image(uintptr_t init_addr)
{
void (*resetvec)(void) = (void(*)(void))init_addr;
@@ -360,8 +361,8 @@ static uint32_t get_size(enum system_image_copy_t copy)
int system_run_image_copy(enum system_image_copy_t copy)
{
- uint32_t base;
- uint32_t init_addr;
+ uintptr_t base;
+ uintptr_t init_addr;
/* If system is already running the requested image, done */
if (system_get_image_copy() == copy)
@@ -408,7 +409,7 @@ int system_run_image_copy(enum system_image_copy_t copy)
const char *system_get_version(enum system_image_copy_t copy)
{
- uint32_t addr;
+ uintptr_t addr;
const struct version_struct *v;
/* Handle version of current image */
@@ -421,7 +422,7 @@ const char *system_get_version(enum system_image_copy_t copy)
/* The version string is always located after the reset vectors, so
* it's the same as in the current image. */
- addr += ((uint32_t)&version_data - get_base(system_get_image_copy()));
+ addr += ((uintptr_t)&version_data - get_base(system_get_image_copy()));
/* Make sure the version struct cookies match before returning the
* version string. */
@@ -456,13 +457,13 @@ const char *system_get_build_info(void)
void system_common_pre_init(void)
{
- uint32_t addr;
+ uintptr_t addr;
/*
* Put the jump data before the panic data, or at the end of RAM if
* panic data is not present.
*/
- addr = (uint32_t)panic_get_data();
+ addr = (uintptr_t)panic_get_data();
if (!addr)
addr = CONFIG_RAM_BASE + CONFIG_RAM_SIZE;
diff --git a/common/util.c b/common/util.c
index d8670759c1..5ccebeb063 100644
--- a/common/util.c
+++ b/common/util.c
@@ -196,8 +196,8 @@ void *memset(void *dest, int c, int len)
void *memmove(void *dest, const void *src, int len)
{
- if ((uint32_t)dest <= (uint32_t)src ||
- (uint32_t)dest >= (uint32_t)src + len) {
+ if ((uintptr_t)dest <= (uintptr_t)src ||
+ (uintptr_t)dest >= (uintptr_t)src + len) {
/* Start of destination doesn't overlap source, so just use
* memcpy(). */
return memcpy(dest, src, len);