mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 00:51:29 +00:00
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>
This commit is contained in:
committed by
chrome-internal-fetch
parent
f993fe3c66
commit
29a57a037a
@@ -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);
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -146,6 +146,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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user