diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2014-12-19 16:16:26 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-12-22 21:50:07 +0000 |
commit | 29a57a037abb86f11d3390dc8de0a5acf93f442f (patch) | |
tree | e7f2d70b94ec07263982965b65a345673aee8282 | |
parent | f993fe3c66fe55421a9dc6a87f582a7c826c3dab (diff) | |
download | chrome-ec-29a57a037abb86f11d3390dc8de0a5acf93f442f.tar.gz |
system: Add function to convert passed system_image_copy_t to string
This conversion is needed in files outside of system.c, so add a new
function.
BUG=chrome-os-partner:34599
TEST=Manual on samus_pd. Run "pd 0 info" and verify "Image RW" is
printed.
BRANCH=Samus
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ia905ba9cf985f3714fa75c81670b8a39e9608f3d
Reviewed-on: https://chromium-review.googlesource.com/236980
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
-rw-r--r-- | common/system.c | 17 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 3 | ||||
-rw-r--r-- | include/system.h | 5 |
3 files changed, 18 insertions, 7 deletions
diff --git a/common/system.c b/common/system.c index 268e393b1b..b31ab43015 100644 --- a/common/system.c +++ b/common/system.c @@ -81,7 +81,6 @@ static const char * const reset_flag_descs[] = { "hibernate", "rtc-alarm", "wake-pin", "low-battery", "sysjump", "hard", "ap-off", "preserved"}; -static const char * const image_names[] = {"unknown", "RO", "RW"}; static uint32_t reset_flags; static int jumped_to_image; static int disable_jump; /* Disable ALL jumps if system is locked */ @@ -293,10 +292,11 @@ void system_disable_jump(void) } if (ret == EC_SUCCESS) { enable_mpu = 1; - CPRINTS("%s image locked", image_names[copy]); + CPRINTS("%s image locked", + system_image_copy_t_to_string(copy)); } else { CPRINTS("Failed to lock %s image (%d)", - image_names[copy], ret); + system_image_copy_t_to_string(copy), ret); } if (enable_mpu) @@ -372,8 +372,13 @@ test_mockable int system_unsafe_to_overwrite(uint32_t offset, uint32_t size) const char *system_get_image_copy_string(void) { - int copy = system_get_image_copy(); - return copy < ARRAY_SIZE(image_names) ? image_names[copy] : "?"; + return system_image_copy_t_to_string(system_get_image_copy()); +} + +const char *system_image_copy_t_to_string(enum system_image_copy_t copy) +{ + static const char * const image_names[] = {"unknown", "RO", "RW"}; + return image_names[copy < ARRAY_SIZE(image_names) ? copy : 0]; } /** @@ -469,7 +474,7 @@ int system_run_image_copy(enum system_image_copy_t copy) return EC_ERROR_UNKNOWN; #endif - CPRINTS("Jumping to image %s", image_names[copy]); + CPRINTS("Jumping to image %s", system_image_copy_t_to_string(copy)); jump_to_image(init_addr); diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 515ec40d47..97afce801f 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -2667,7 +2667,8 @@ static int command_pd(int argc, char **argv) ccprintf("Hash "); for (i = 0; i < PD_RW_HASH_SIZE / 4; i++) ccprintf("%08x ", pd[port].dev_rw_hash[i]); - ccprintf("\nImage %d\n", pd[port].current_image); + ccprintf("\nImage %s\n", system_image_copy_t_to_string( + pd[port].current_image)); } else if (!strncasecmp(argv[2], "soft", 4)) { set_state(port, PD_STATE_SOFT_RESET); task_wake(PORT_TO_TASK_ID(port)); diff --git a/include/system.h b/include/system.h index 4463c4baf9..71cad098f9 100644 --- a/include/system.h +++ b/include/system.h @@ -147,6 +147,11 @@ int system_unsafe_to_overwrite(uint32_t offset, uint32_t size); const char *system_get_image_copy_string(void); /** + * Return a text description of the passed image copy parameter. + */ +const char *system_image_copy_t_to_string(enum system_image_copy_t copy); + +/** * Return the number of bytes used in the specified image. * * This is the actual size of code+data in the image, as opposed to the |