From 2c26cad2ad223490d1adc7909fbdb317cc5c2c23 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Thu, 7 Apr 2016 16:43:02 -0700 Subject: Support RW_B in sysjump command when applicable If we #define CONFIG_RW_B, the firmware image can have two RW components. This CL expands the "sysinfo" command so that we can see which image we're running from when RW_B is also a possibility. BUG=chrome-os-partner:50701 BRANCH=none TEST=make buildall; test RW update on Cr50 Using test/tpm_test/tpmtest.py, update the RW firmware and reboot several times to switch between RW_A and RW_B. Note that the "sysjump" command reports the correct image each time. Change-Id: Iba3778579587f6df198728d3783cb848b4fd199d Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/337664 Reviewed-by: Randall Spangler --- common/system.c | 20 +++++++++++++++++++- include/system.h | 5 ++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/common/system.c b/common/system.c index 7c3117a292..c1236f083c 100644 --- a/common/system.c +++ b/common/system.c @@ -107,6 +107,10 @@ static uintptr_t get_program_memory_addr(enum system_image_copy_t copy) return CONFIG_PROGRAM_MEMORY_BASE + CONFIG_RO_MEM_OFF; case SYSTEM_IMAGE_RW: return CONFIG_PROGRAM_MEMORY_BASE + CONFIG_RW_MEM_OFF; +#ifdef CONFIG_RW_B + case SYSTEM_IMAGE_RW_B: + return CONFIG_PROGRAM_MEMORY_BASE + CONFIG_RW_B_MEM_OFF; +#endif default: return 0xffffffff; } @@ -126,6 +130,10 @@ static uint32_t get_size(enum system_image_copy_t copy) return CONFIG_RO_SIZE; case SYSTEM_IMAGE_RW: return CONFIG_RW_SIZE; +#ifdef CONFIG_RW_B + case SYSTEM_IMAGE_RW_B: + return CONFIG_RW_SIZE; +#endif default: return 0; } @@ -335,6 +343,12 @@ test_mockable enum system_image_copy_t system_get_image_copy(void) my_addr < (CONFIG_RW_MEM_OFF + CONFIG_RW_SIZE)) return SYSTEM_IMAGE_RW; +#ifdef CONFIG_RW_B + if (my_addr >= CONFIG_RW_B_MEM_OFF && + my_addr < (CONFIG_RW_B_MEM_OFF + CONFIG_RW_SIZE)) + return SYSTEM_IMAGE_RW_B; +#endif + return SYSTEM_IMAGE_UNKNOWN; #endif } @@ -424,7 +438,11 @@ const char *system_get_image_copy_string(void) const char *system_image_copy_t_to_string(enum system_image_copy_t copy) { - static const char * const image_names[] = {"unknown", "RO", "RW"}; + static const char * const image_names[] = {"unknown", "RO", "RW", +#ifdef CONFIG_RW_B + "RW_B", +#endif + }; return image_names[copy < ARRAY_SIZE(image_names) ? copy : 0]; } diff --git a/include/system.h b/include/system.h index 220e0790e7..0d2eebdf1e 100644 --- a/include/system.h +++ b/include/system.h @@ -37,7 +37,10 @@ void chip_save_reset_flags(int flags); enum system_image_copy_t { SYSTEM_IMAGE_UNKNOWN = 0, SYSTEM_IMAGE_RO, - SYSTEM_IMAGE_RW + SYSTEM_IMAGE_RW, +#ifdef CONFIG_RW_B + SYSTEM_IMAGE_RW_B, +#endif }; /** -- cgit v1.2.1