summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-09-17 11:34:16 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-21 11:23:31 -0700
commitb03f92fbccb4cd07edee75b6eea654692f3dbdf9 (patch)
tree33e62ce7e8ec3ed3813f9c9477abc1042fc61a39
parent85110d5bcbf1223f171df905ecff2af3fde56724 (diff)
downloadchrome-ec-b03f92fbccb4cd07edee75b6eea654692f3dbdf9.tar.gz
cleanup: Fix mapped storage accesses
1. Don't assume that images are present in program memory, just because storage is mapped (npcx case). 2. Use CONFIG_MAPPED_STORAGE_BASE correctly, rather than PROGRAM_MEMORY_BASE. BUG=chrome-os-partner:23796 TEST=make buildall -j BRANCH=none Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I99c2b382def2a211241d401bbdc39a88ceedca5b Reviewed-on: https://chromium-review.googlesource.com/300254 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Mulin Chao <mlchao@nuvoton.com> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/system.c6
-rw-r--r--common/vboot_hash.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/common/system.c b/common/system.c
index 3d3d3d24cd..fa79b909a1 100644
--- a/common/system.c
+++ b/common/system.c
@@ -336,9 +336,9 @@ test_mockable enum system_image_copy_t system_get_image_copy(void)
int system_get_image_used(enum system_image_copy_t copy)
{
#ifndef CONFIG_MAPPED_STORAGE
- int image_offset;
uint8_t buf[SPI_FLASH_MAX_WRITE_SIZE];
#endif
+ int image_offset;
const uint8_t *image;
int size;
size = get_size(copy);
@@ -350,10 +350,10 @@ int system_get_image_used(enum system_image_copy_t copy)
* last byte of the image. See ec.lds.S for how this is inserted at
* the end of the image.
*/
-#ifndef CONFIG_MAPPED_STORAGE
image_offset = (copy == SYSTEM_IMAGE_RW) ?
CONFIG_EC_WRITABLE_STORAGE_OFF + CONFIG_RW_STORAGE_OFF :
CONFIG_EC_PROTECTED_STORAGE_OFF + CONFIG_RO_STORAGE_OFF;
+#ifndef CONFIG_MAPPED_STORAGE
image = buf;
do {
@@ -368,7 +368,7 @@ int system_get_image_used(enum system_image_copy_t copy)
} while (*image != 0xea);
#else
- image = (const uint8_t *)get_program_memory_addr(copy);
+ image = (const uint8_t *)(image_offset + CONFIG_MAPPED_STORAGE_BASE);
for (size--; size > 0 && image[size] != 0xea; size--)
;
#endif
diff --git a/common/vboot_hash.c b/common/vboot_hash.c
index e90fe50b07..42d1a0f11c 100644
--- a/common/vboot_hash.c
+++ b/common/vboot_hash.c
@@ -112,7 +112,7 @@ static void vboot_hash_next_chunk(void)
size = MIN(CHUNK_SIZE, data_size - curr_pos);
#ifdef CONFIG_MAPPED_STORAGE
- SHA256_update(&ctx, (const uint8_t *)(CONFIG_PROGRAM_MEMORY_BASE +
+ SHA256_update(&ctx, (const uint8_t *)(CONFIG_MAPPED_STORAGE_BASE +
data_offset + curr_pos), size);
#else
if (read_and_hash_chunk(data_offset + curr_pos, size) != EC_SUCCESS)