aboutsummaryrefslogtreecommitdiff
path: root/drivers/renesas
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut+renesas@gmail.com>2020-11-08 19:13:32 +0100
committerManish Pandey <manish.pandey2@arm.com>2020-12-08 22:27:13 +0000
commit605767475ec42f4250edbfd10be7e605f7d3aa1d (patch)
treedfacfaa401d6d610586cb0f344d052f80d8e3f0e /drivers/renesas
parent77990838a4486bc266377243af3e328c0daa9f3e (diff)
downloadtrusted-firmware-a-605767475ec42f4250edbfd10be7e605f7d3aa1d.tar.gz
rcar_gen3: drivers: console: Treat log as device memory
The BL31 log driver is registered before the xlat tables are initialized, at that point the log memory is configured as device memory and can only be accessed with up-to-32bit aligned accesses. Adjust the driver to do just that. The memset() call has to be replaced by a loop of 32bit writes to the log, the memcpy() is trivial to replace with a single 32bit write of the entire TLOG word. In the end, this even simplifies the code. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Change-Id: Ie9152e782e67d93e7236069a294df812e2b873bf
Diffstat (limited to 'drivers/renesas')
-rw-r--r--drivers/renesas/rcar/console/rcar_printf.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/drivers/renesas/rcar/console/rcar_printf.c b/drivers/renesas/rcar/console/rcar_printf.c
index e75b9f4541..ad074fe059 100644
--- a/drivers/renesas/rcar/console/rcar_printf.c
+++ b/drivers/renesas/rcar/console/rcar_printf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved.
+ * Copyright (c) 2015-2020, Renesas Electronics Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -19,11 +19,22 @@
#define INDEX_TIMER_COUNT (4U)
+#define RCAR_LOG_HEAD (('T' << 0) | ('L' << 8) | ('O' << 16) | ('G' << 24))
+
+/*
+ * The log is initialized and used before BL31 xlat tables are initialized,
+ * therefore the log memory is a device memory at that point. Make sure the
+ * memory is correclty aligned and accessed only with up-to 32bit, aligned,
+ * writes.
+ */
+CASSERT((RCAR_BL31_LOG_BASE & 0x7) == 0, assert_bl31_log_base_unaligned);
+CASSERT((RCAR_BL31_LOG_MAX & 0x7) == 0, assert_bl31_log_max_unaligned);
+
extern RCAR_INSTANTIATE_LOCK typedef struct log_head {
- uint8_t head[4];
+ uint32_t head;
uint32_t index;
uint32_t size;
- uint8_t res[4];
+ uint32_t res;
} loghead_t;
typedef struct log_map {
@@ -66,15 +77,12 @@ int32_t rcar_set_log_data(int32_t c)
int32_t rcar_log_init(void)
{
-
- static const uint8_t const_header[] = "TLOG";
- logmap_t *t_log;
+ logmap_t *t_log = (logmap_t *)RCAR_BL31_LOG_BASE;
+ uint32_t *log_data = (uint32_t *)t_log->log_data;
int16_t init_flag = 0;
+ int i;
- t_log = (logmap_t *) RCAR_BL31_LOG_BASE;
- if (memcmp
- ((const void *)t_log->header.head, (const void *)const_header,
- sizeof(t_log->header.head)) != 0) {
+ if (t_log->header.head != RCAR_LOG_HEAD) {
/*
* Log header is not "TLOG", then log area initialize
*/
@@ -87,11 +95,10 @@ int32_t rcar_log_init(void)
init_flag = 1;
}
if (init_flag == 1) {
- (void)memset((void *)t_log->log_data, 0,
- (size_t) RCAR_BL31_LOG_MAX);
- (void)memcpy((void *)t_log->header.head,
- (const void *)const_header,
- sizeof(t_log->header.head));
+ for (i = 0; i < RCAR_BL31_LOG_MAX; i += 4)
+ *log_data++ = 0;
+
+ t_log->header.head = RCAR_LOG_HEAD;
t_log->header.index = 0U;
t_log->header.size = 0U;
}