mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
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>
This commit is contained in:
committed by
chrome-bot
parent
85110d5bcb
commit
b03f92fbcc
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user