9321b584ad54431b2db04689c7c32dcd9eef1734
2 * Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
11 #include <arch_helpers.h>
12 #include <platform_def.h>
13 #include <bakery_lock.h>
15 #include "rcar_private.h"
16 #include "rcar_printf.h"
18 #define INDEX_TIMER_COUNT (4U)
20 extern RCAR_INSTANTIATE_LOCK
typedef struct log_head
{
27 typedef struct log_map
{
29 uint8_t log_data
[RCAR_BL31_LOG_MAX
];
30 uint8_t res_data
[RCAR_LOG_RES_SIZE
];
33 int32_t rcar_set_log_data(int32_t c
)
37 t_log
= (logmap_t
*) RCAR_BL31_LOG_BASE
;
42 * If index is broken, then index and size initialize
44 if (t_log
->header
.index
>= (uint32_t) RCAR_BL31_LOG_MAX
) {
45 t_log
->header
.index
= 0U;
46 t_log
->header
.size
= 0U;
49 * data store to log area then index and size renewal
51 t_log
->log_data
[t_log
->header
.index
] = (uint8_t) c
;
52 t_log
->header
.index
++;
53 if (t_log
->header
.size
< t_log
->header
.index
) {
54 t_log
->header
.size
= t_log
->header
.index
;
56 if (t_log
->header
.index
>= (uint32_t) RCAR_BL31_LOG_MAX
) {
57 t_log
->header
.index
= 0U;
65 int32_t rcar_log_init(void)
68 static const uint8_t const_header
[] = "TLOG";
70 int16_t init_flag
= 0;
72 t_log
= (logmap_t
*) RCAR_BL31_LOG_BASE
;
74 ((const void *)t_log
->header
.head
, (const void *)const_header
,
75 sizeof(t_log
->header
.head
)) != 0) {
77 * Log header is not "TLOG", then log area initialize
81 if (t_log
->header
.index
>= (uint32_t) RCAR_BL31_LOG_MAX
) {
83 * index is broken, then log area initialize
88 (void)memset((void *)t_log
->log_data
, 0,
89 (size_t) RCAR_BL31_LOG_MAX
);
90 (void)memcpy((void *)t_log
->header
.head
,
91 (const void *)const_header
,
92 sizeof(t_log
->header
.head
));
93 t_log
->header
.index
= 0U;
94 t_log
->header
.size
= 0U;
96 rcar_stack_generic_timer
[INDEX_TIMER_COUNT
] = 0U;