aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMadhukar Pappireddy <madhukar.pappireddy@arm.com>2021-06-18 15:40:20 +0200
committerTrustedFirmware Code Review <review@review.trustedfirmware.org>2021-06-18 15:40:20 +0200
commit7cfe5999be6ea1aa86fbc7b1ca5694b68c11f382 (patch)
tree70b05637627e7d87105e6ab3bb33dbf40a720890 /drivers
parent2f0004bbbfac5ac6215391340bcd52ee4ce3b14b (diff)
parenta5bcf82402ff415326b4dba42aae95c499821e94 (diff)
downloadtrusted-firmware-a-7cfe5999be6ea1aa86fbc7b1ca5694b68c11f382.tar.gz
Merge changes from topic "io_stm32image" into integration
* changes: fix(io_stm32image): invalidate cache on local buf refactor(io_stm32image): add header size variable fix(io_stm32image): uninitialized variable warning
Diffstat (limited to 'drivers')
-rw-r--r--drivers/st/io/io_stm32image.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/st/io/io_stm32image.c b/drivers/st/io/io_stm32image.c
index 3e377cd483..9fa0c50fd4 100644
--- a/drivers/st/io/io_stm32image.c
+++ b/drivers/st/io/io_stm32image.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2018-2021, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -246,10 +246,11 @@ static int stm32image_partition_size(io_entity_t *entity, size_t *length)
static int stm32image_partition_read(io_entity_t *entity, uintptr_t buffer,
size_t length, size_t *length_read)
{
- int result;
+ int result = -EINVAL;
uint8_t *local_buffer;
boot_api_image_header_t *header =
(boot_api_image_header_t *)first_lba_buffer;
+ size_t hdr_sz = sizeof(boot_api_image_header_t);
assert(entity != NULL);
assert(buffer != 0U);
@@ -286,16 +287,13 @@ static int stm32image_partition_read(io_entity_t *entity, uintptr_t buffer,
}
/* Part of image already loaded with the header */
- memcpy(local_buffer, (uint8_t *)first_lba_buffer +
- sizeof(boot_api_image_header_t),
- MAX_LBA_SIZE - sizeof(boot_api_image_header_t));
- local_buffer += MAX_LBA_SIZE - sizeof(boot_api_image_header_t);
+ memcpy(local_buffer, (uint8_t *)first_lba_buffer + hdr_sz,
+ MAX_LBA_SIZE - hdr_sz);
+ local_buffer += MAX_LBA_SIZE - hdr_sz;
offset = MAX_LBA_SIZE;
/* New image length to be read */
- local_length = round_up(length -
- ((MAX_LBA_SIZE) -
- sizeof(boot_api_image_header_t)),
+ local_length = round_up(length - ((MAX_LBA_SIZE) - hdr_sz),
stm32image_dev.lba_size);
if ((header->load_address != 0U) &&
@@ -326,7 +324,7 @@ static int stm32image_partition_read(io_entity_t *entity, uintptr_t buffer,
local_length, length_read);
/* Adding part of size already read from header */
- *length_read += MAX_LBA_SIZE - sizeof(boot_api_image_header_t);
+ *length_read += MAX_LBA_SIZE - hdr_sz;
if (result != 0) {
ERROR("%s: io_read (%i)\n", __func__, result);
@@ -348,6 +346,9 @@ static int stm32image_partition_read(io_entity_t *entity, uintptr_t buffer,
return result;
}
+ inv_dcache_range(round_up((uintptr_t)(local_buffer + length - hdr_sz),
+ CACHE_WRITEBACK_GRANULE), *length_read - length + hdr_sz);
+
io_close(backend_handle);
}