summaryrefslogtreecommitdiff
path: root/common/system.c
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2017-01-12 09:40:10 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-01-30 16:48:40 -0800
commit7cbb815732d7434f5985d3b50a869aa71ba5c507 (patch)
tree5c8714c956b96cbe3c6793d31b338e68afbacc79 /common/system.c
parent927e01da02ab68c304d95508df5ba0b50f8bb960 (diff)
downloadchrome-ec-7cbb815732d7434f5985d3b50a869aa71ba5c507.tar.gz
version: Store image size data in version struct
Store our image size (known at build time) in our version struct (now renamed to image_data). This will allow us to more efficiently determine the size of an image in a follow-up CL. Note that compatibility is broken for old ROs that do not include this CL. BUG=chromium:577915 TEST=Verify on kevin + lars + lars_pd that stored image size matches output of system_get_image_used() for both RO and RW images. BRANCH=None Change-Id: I49ea5fc27a7f11f66daba485a87d0dfe7d0c770f Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/427408 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/system.c')
-rw-r--r--common/system.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/common/system.c b/common/system.c
index ddabe3aa3c..28d846c0c5 100644
--- a/common/system.c
+++ b/common/system.c
@@ -616,14 +616,14 @@ int system_run_image_copy(enum system_image_copy_t copy)
__attribute__((weak)) /* Weird chips may need their own implementations */
const char *system_get_version(enum system_image_copy_t copy)
{
- static struct version_struct v;
+ static struct image_data data;
uintptr_t addr;
enum system_image_copy_t active_copy = system_get_image_copy();
/* Handle version of current image */
if (copy == active_copy || copy == SYSTEM_IMAGE_UNKNOWN)
- return &version_data.version[0];
+ return &current_image_data.version[0];
if (active_copy == SYSTEM_IMAGE_UNKNOWN)
return "";
@@ -632,7 +632,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 offset as in the current image. Find that offset.
*/
- addr = ((uintptr_t)&version_data -
+ addr = ((uintptr_t)&current_image_data -
get_program_memory_addr(active_copy));
/*
@@ -646,19 +646,19 @@ const char *system_get_version(enum system_image_copy_t copy)
#ifdef CONFIG_MAPPED_STORAGE
addr += CONFIG_MAPPED_STORAGE_BASE;
flash_lock_mapped_storage(1);
- memcpy(&v, (const void *)addr, sizeof(v));
+ memcpy(&data, (const void *)addr, sizeof(data));
flash_lock_mapped_storage(0);
#else
/* Read the version struct from flash into a buffer. */
- if (flash_read(addr, sizeof(v), (char *)&v))
+ if (flash_read(addr, sizeof(data), (char *)&data))
return "";
#endif
/* Make sure the version struct cookies match before returning the
* version string. */
- if (v.cookie1 == version_data.cookie1 &&
- v.cookie2 == version_data.cookie2)
- return v.version;
+ if (data.cookie1 == current_image_data.cookie1 &&
+ data.cookie2 == current_image_data.cookie2)
+ return data.version;
return "";
}