summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-12-03 12:04:55 -0800
committerCommit Bot <commit-bot@chromium.org>2019-12-06 23:48:34 +0000
commit5c88fa3af437636a626e2046b59dab94eeab021c (patch)
treee93616d5f135c5eeff387f1bff83b844967c0a6c /chip
parentfb10dcf474f65c92d64ccbc391a1b8991f42d1c6 (diff)
downloadchrome-ec-5c88fa3af437636a626e2046b59dab94eeab021c.tar.gz
g: display both RO and RW info map status
Cr50 firmware is required to update the rollback prevention map in INFO1 for both RO and RW images. This patch adds code to display the state of the RO map and both RO_A and RO_B headers in addition to previously reported RW information. BRANCH=cr50, cr50-mp BUG=b:136284186 TEST=loaded the new image and observed reported rollback state: > sysinfo ... Rollback: 0/1/1 0/128/128 ... Change-Id: I32206545b6a59a5693e4274e62fcf0627780f61f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1949546 Reviewed-by: Namyoon Woo <namyoon@chromium.org> (cherry picked from commit 565c54c270bd93ee30e8f8560d3d1691d128e762) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1954341
Diffstat (limited to 'chip')
-rw-r--r--chip/g/system.c61
1 files changed, 36 insertions, 25 deletions
diff --git a/chip/g/system.c b/chip/g/system.c
index 1b0c285473..2b6d63be33 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -711,41 +711,52 @@ void system_update_rollback_mask_with_both_imgs(void)
void system_get_rollback_bits(char *value, size_t value_size)
{
- int info_count;
int i;
+ size_t str_offset = 0;
struct {
- int count;
- const struct SignedHeader *h;
+ uint32_t info_map_offset;
+ uint32_t image_types[2];
} headers[] = {
- {.h = (const struct SignedHeader *)
- get_program_memory_addr(SYSTEM_IMAGE_RW)},
-
- {.h = (const struct SignedHeader *)
- get_program_memory_addr(SYSTEM_IMAGE_RW_B)},
+ { .info_map_offset = INFO_RO_MAP_OFFSET,
+ .image_types = { SYSTEM_IMAGE_RO, SYSTEM_IMAGE_RO_B } },
+ { .info_map_offset = INFO_RW_MAP_OFFSET,
+ .image_types = { SYSTEM_IMAGE_RW, SYSTEM_IMAGE_RW_B } }
};
- for (i = 0; i < INFO_MAX; i++) {
- uint32_t w;
-
- flash_physical_info_read_word(INFO_RW_MAP_OFFSET +
- i * sizeof(uint32_t),
- &w);
- if (w)
- break;
- }
- info_count = i;
-
for (i = 0; i < ARRAY_SIZE(headers); i++) {
int j;
- for (j = 0; j < INFO_MAX; j++)
- if (headers[i].h->infomap[j/32] & (1 << (j%32)))
+ /* First see how many bits are cleared in the INFO space. */
+ for (j = 0; j < INFO_MAX; j++) {
+ uint32_t w;
+
+ flash_physical_info_read_word(
+ headers[i].info_map_offset +
+ j * sizeof(uint32_t),
+ &w);
+ if (w)
break;
- headers[i].count = j;
+ }
+ /* Count of INFO space bits. */
+ str_offset += snprintf(value + str_offset,
+ value_size - str_offset, " %d", j);
+
+ /* Iterate over two sections, A and B. */
+ for (j = 0; j < ARRAY_SIZE(headers[i].image_types); j++) {
+ int k;
+ const struct SignedHeader *sh;
+
+ sh = (const struct SignedHeader *)
+ get_program_memory_addr(
+ headers[i].image_types[j]);
+ for (k = 0; k < INFO_MAX; k++)
+ if (sh->infomap[k/32] & (1 << (k%32)))
+ break;
+ str_offset += snprintf(value + str_offset,
+ value_size - str_offset, "/%d",
+ k);
+ }
}
-
- snprintf(value, value_size, "%d/%d/%d", info_count,
- headers[0].count, headers[1].count);
}
#ifdef CONFIG_EXTENDED_VERSION_INFO