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
This commit is contained in:
Marek Vasut 2020-11-08 19:13:32 +01:00 committed by Manish Pandey
parent 77990838a4
commit 605767475e
1 changed files with 22 additions and 15 deletions

View File

@ -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;
}