summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-04-13 15:57:51 -0700
committerRandall Spangler <rspangler@chromium.org>2012-04-13 15:59:18 -0700
commitf3301b4944e322afe48cb271ed5d47256e110072 (patch)
tree39dc6c277aaddaa6da94fa1db6f8042b59a62c6e
parentbf2fad0a254894aabb0aca2fb3ab155b4ab81203 (diff)
downloadchrome-ec-f3301b4944e322afe48cb271ed5d47256e110072.tar.gz
Fix getting version string for other images
Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:9049 TEST=manual sysjump ro version sysjump a version sysjump b version All should return versions for RO, RW-A, RW-B. Change-Id: Ie189d2d777a4743460e2edec65750e563bc69354
-rw-r--r--common/system_common.c62
1 files changed, 30 insertions, 32 deletions
diff --git a/common/system_common.c b/common/system_common.c
index eae6d51424..95af150623 100644
--- a/common/system_common.c
+++ b/common/system_common.c
@@ -134,6 +134,24 @@ static void jump_to_image(uint32_t init_addr)
}
+/* Return the base pointer for the image copy, or 0xffffffff if error. */
+static uint32_t get_base(enum system_image_copy_t copy)
+{
+ switch (copy) {
+ case SYSTEM_IMAGE_RO:
+ return CONFIG_FW_RO_OFF;
+ case SYSTEM_IMAGE_RW_A:
+ return CONFIG_FW_A_OFF;
+#ifndef CONFIG_NO_RW_B
+ case SYSTEM_IMAGE_RW_B:
+ return CONFIG_FW_B_OFF;
+#endif
+ default:
+ return 0xffffffff;
+ }
+}
+
+
int system_run_image_copy(enum system_image_copy_t copy)
{
uint32_t base;
@@ -148,21 +166,9 @@ int system_run_image_copy(enum system_image_copy_t copy)
* - The target image must be A or B. */
/* Load the appropriate reset vector */
- switch (copy) {
- case SYSTEM_IMAGE_RO:
- base = CONFIG_FW_RO_OFF;
- break;
- case SYSTEM_IMAGE_RW_A:
- base = CONFIG_FW_A_OFF;
- break;
-#ifndef CONFIG_NO_RW_B
- case SYSTEM_IMAGE_RW_B:
- base = CONFIG_FW_B_OFF;
- break;
-#endif
- default:
+ base = get_base(copy);
+ if (base == 0xffffffff)
return EC_ERROR_INVAL;
- }
/* Make sure the reset vector is inside the destination image */
init_addr = *(uint32_t *)(base + 4);
@@ -178,32 +184,24 @@ int system_run_image_copy(enum system_image_copy_t copy)
const char *system_get_version(enum system_image_copy_t copy)
{
- int imoffset;
+ uint32_t addr;
const struct version_struct *v;
/* Handle version of current image */
if (copy == system_get_image_copy() || copy == SYSTEM_IMAGE_UNKNOWN)
return version_data.version;
- switch (copy) {
- case SYSTEM_IMAGE_RO:
- imoffset = CONFIG_FW_RO_OFF;
- break;
- case SYSTEM_IMAGE_RW_A:
- imoffset = CONFIG_FW_A_OFF;
- break;
-#ifndef CONFIG_NO_RW_B
- case SYSTEM_IMAGE_RW_B:
- imoffset = CONFIG_FW_B_OFF;
- break;
-#endif
- default:
+ addr = get_base(copy);
+ if (addr == 0xffffffff)
return "";
- }
- /* The version string is always located after the reset vectors */
- v = (const struct version_struct *)((uint8_t *)&version_data
- + imoffset);
+ /* 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()));
+
+ /* Make sure the version struct cookies match before returning the
+ * version string. */
+ v = (const struct version_struct *)addr;
if (v->cookie1 == version_data.cookie1 &&
v->cookie2 == version_data.cookie2)
return v->version;