Skip to content

Commit f6bc15b

Browse files
committed
plat: renesas: Improve RZ/A platform
Improve RZ/A platform Signed-off-by: Nhut Nguyen <[email protected]>
1 parent 3a21f74 commit f6bc15b

File tree

118 files changed

+1839
-7797
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1839
-7797
lines changed

plat/renesas/rza/common/drivers/scifa.S renamed to drivers/renesas/common/scifa/scifa.S

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,69 @@
88
#include <asm_macros.S>
99
#include <console_macros.S>
1010

11-
#define SMR (0x00)
12-
#define BRR (0x02)
11+
#define SMR (0x00)
12+
#define BRR (0x02)
1313
#define MDDR (0x02)
14-
#define SCR (0x04)
14+
#define SCR (0x04)
1515
#define FTDR (0x06)
16-
#define FSR (0x08)
16+
#define FSR (0x08)
1717
#define FRDR (0x0A)
18-
#define FCR (0x0C)
19-
#define FDR (0x0E)
18+
#define FCR (0x0C)
19+
#define FDR (0x0E)
2020
#define SPTR (0x10)
21-
#define LSR (0x12)
21+
#define LSR (0x12)
2222
#define SEMR (0x14)
2323
#define FTCR (0x16)
2424

25-
#define SCR_CKE_MASK (0x03)
26-
#define SCR_CKE_INTERN (0x00)
25+
#define SCR_CKE_MASK (0x03)
26+
#define SCR_CKE_INTERN (0x00)
2727
#define SCR_RE_ON (0x10)
2828
#define SCR_TE_ON (0x20)
2929
#define SCR_INIT (0x00)
3030
#define SCR_READY (SCR_INIT | SCR_RE_ON | SCR_TE_ON)
3131

32-
#define FCR_RFRST_RST (0x02)
33-
#define FCR_TFRST_RST (0x04)
32+
#define FCR_RFRST_RST (0x02)
33+
#define FCR_TFRST_RST (0x04)
3434
#define FCR_BASE (0x00)
3535
#define FCR_RST (FCR_BASE | FCR_RFRST_RST | FCR_TFRST_RST)
3636
#define FCR_RUN (FCR_BASE)
3737

3838
#define SMR_INIT (0x00)
3939

40-
#define SEMR_NFEN_ON (0x04)
41-
#define SEMR_MDDRS_BRR (0x00)
42-
#define SEMR_MDDRS_MDDR (0x10)
43-
#define SEMR_BRME_ON (0x20)
44-
//#define SEMR_BASE (SEMR_NFEN_ON)
40+
#define SEMR_NFEN_ON (0x04)
41+
#define SEMR_MDDRS_BRR (0x00)
42+
#define SEMR_MDDRS_MDDR (0x10)
43+
#define SEMR_BRME_ON (0x20)
4544
#define SEMR_BASE (0x00)
4645
#define SEMR_BRR (SEMR_BASE | SEMR_MDDRS_BRR)
4746
#define SEMR_MDDR (SEMR_BASE | SEMR_MDDRS_MDDR | SEMR_BRME_ON)
4847

4948
#define FTCR_TTRGS (0x0080)
5049
#define FTCR_RTRGS (0x8000)
5150

52-
#define FSR_TDFE_SHIFT (5)
53-
#define FSR_TEND_SHIFT (6)
51+
#define FSR_TDFE_SHIFT (5)
52+
#define FSR_TEND_SHIFT (6)
5453
#define FSR_TEND (1<<FSR_TEND_SHIFT)
5554

56-
#define BRR_C_RSHIFT (5)
55+
#define BRR_C_RSHIFT (5)
5756
#define BRR_C_SUB (1)
5857

59-
.globl console_rza_register
60-
.globl console_rza_init
61-
.globl console_rza_putc
62-
.globl console_rza_flush
58+
/* Define a global flag */
59+
.section .bss.putc_called_flag
60+
.align 3
61+
.global putc_called_flag
62+
putc_called_flag:
63+
.skip 8
64+
65+
.text
66+
67+
.globl console_scifa_register
68+
.globl console_scifa_init
69+
.globl console_scifa_putc
70+
.globl console_scifa_flush
6371

6472
/* -----------------------------------------------
65-
* int console_rza_register(
73+
* int console_scifa_register(
6674
* uintptr_t base, uint32_t clk, uint32_t baud,
6775
* console_t *console)
6876
* Function to initialize and register a new console.
@@ -76,32 +84,32 @@
7684
* Clobber list : x0, x1, x2, x6, x7, x14
7785
* -----------------------------------------------
7886
*/
79-
func console_rza_register
87+
func console_scifa_register
8088
mov x7, x30
8189
mov x6, x3
8290
cbz x6, register_fail
8391
str x0, [x6, #CONSOLE_T_BASE]
8492

85-
bl console_rza_init
93+
bl console_scifa_init
8694

8795
mov x0, x6
8896
mov x30, x7
89-
finish_console_register rza, putc=1, getc=0, flush=1
97+
finish_console_register scifa, putc=1, getc=0, flush=1
9098
b l_ret
9199

92100
register_fail:
93101
mov x0, #0
94102

95103
l_ret:
96104
ret x7
97-
endfunc console_rza_register
105+
endfunc console_scifa_register
98106

99107
/* -----------------------------------------------
100-
* int console_rza_init(unsigned long base_addr,
108+
* int console_scifa_init(unsigned long base_addr,
101109
* unsigned int uart_clk, unsigned int baud_rate)
102110
* Function to initialize the console without a
103111
* C Runtime to print debug information. This
104-
* function will be accessed by console_rza_register
112+
* function will be accessed by console_scifa_register
105113
* and crash reporting.
106114
* In: x0 - console base address
107115
* w1 - Uart clock in Hz
@@ -110,7 +118,7 @@ endfunc console_rza_register
110118
* Clobber list : x3
111119
* -----------------------------------------------
112120
*/
113-
func console_rza_init
121+
func console_scifa_init
114122
mov w3, #(SCR_INIT)
115123
strh w3, [x0, #SCR]
116124

@@ -163,10 +171,10 @@ func console_rza_init
163171

164172
mov x0, #1
165173
ret
166-
endfunc console_rza_init
174+
endfunc console_scifa_init
167175

168176
/* --------------------------------------------------------
169-
* int console_rza_putc(int c, console_t *console)
177+
* int console_scifa_putc(int c, console_t *console)
170178
* Function to output a character over the console. It
171179
* returns the character printed on success or -1 on error.
172180
* In : w0 - character to be printed
@@ -175,7 +183,7 @@ endfunc console_rza_init
175183
* Clobber list : x2
176184
* --------------------------------------------------------
177185
*/
178-
func console_rza_putc
186+
func console_scifa_putc
179187
ldr x1, [x1, #CONSOLE_T_BASE]
180188
cmp w0, #0xA
181189
/* Prepend '\r' to '\n' */
@@ -202,10 +210,10 @@ func console_rza_putc
202210
strh w2, [x1, #FSR]
203211

204212
ret
205-
endfunc console_rza_putc
213+
endfunc console_scifa_putc
206214

207215
/* ---------------------------------------------
208-
* int console_rza_flush(console_t *console)
216+
* int console_scifa_flush(console_t *console)
209217
* Function to force a write of all buffered
210218
* data that hasn't been output. It returns 0
211219
* upon successful completion, otherwise it
@@ -215,15 +223,23 @@ endfunc console_rza_putc
215223
* Clobber list : x1
216224
* ---------------------------------------------
217225
*/
218-
func console_rza_flush
226+
func console_scifa_flush
219227
ldr x0, [x0, #CONSOLE_T_BASE]
228+
229+
/* Check if putc_called_flag is set */
230+
adrp x1, putc_called_flag
231+
add x1, x1, :lo12:putc_called_flag
232+
ldr x1, [x1]
233+
cbz x1, flush_done
234+
220235
1:
221236
/* Check TEND flag */
222237
ldrh w1, [x0, #FSR]
223238
and w1, w1, #FSR_TEND
224239
cmp w1, #FSR_TEND
225240
bne 1b
226241

242+
flush_done:
227243
mov w0, #0
228244
ret
229-
endfunc console_rza_flush
245+
endfunc console_scifa_flush
File renamed without changes.

plat/renesas/rza/common/drivers/auth/auth_mod.c renamed to drivers/renesas/rza/auth/auth_mod.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
#include "../../include/drivers/auth/auth_common.h"
2121
#include "../../include/drivers/auth/sblib/crypto_sblib.h"
2222

23-
#define return_if_error(rc) \
24-
do { \
25-
if (rc != 0) { \
26-
return rc; \
27-
} \
28-
} while (0)
29-
3023
#define TBBR_COT_GETTER(id) \
3124
__extension__({ \
3225
assert((id) < cot_desc_size); \
@@ -110,24 +103,30 @@ static int auth_sblib(const auth_method_param_sblib_t *param,
110103

111104
/* Get the content certificate that is the parent of the image */
112105
content_cert_desc = img_desc->parent;
113-
rc = auth_get_param(param->key_cert, content_cert_desc,
106+
rc = auth_get_param(param->content_cert, content_cert_desc,
114107
&content_cert_ptr, &content_cert_len);
115-
return_if_error(rc);
108+
if (rc != 0) {
109+
return rc;
110+
}
116111

117112
/* Get the key certificate that is the parent of the content certificate */
118113
key_cert_desc = content_cert_desc->parent;
119-
rc = auth_get_param(param->content_cert, key_cert_desc, &key_cert_ptr,
114+
rc = auth_get_param(param->key_cert, key_cert_desc, &key_cert_ptr,
120115
&key_cert_len);
121-
return_if_error(rc);
116+
if (rc != 0) {
117+
return rc;
118+
}
122119

123120
/* Get the data to authenticate from the current image */
124121
rc = img_parser_get_auth_param(img_desc->img_type, param->data, img,
125122
img_len, &data_ptr, &data_len);
126-
return_if_error(rc);
123+
if (rc != 0) {
124+
return rc;
125+
}
127126

128127
/* Ask Renesas SB-Lib to authenticate this image */
129-
rc = crypto_sblib_auth(data_ptr, data_len, key_cert_ptr, key_cert_len,
130-
content_cert_ptr, content_cert_len);
128+
rc = crypto_sblib_auth(key_cert_ptr, key_cert_len, content_cert_ptr,
129+
content_cert_len);
131130

132131
return rc;
133132
}
@@ -196,7 +195,9 @@ int auth_mod_verify_img(unsigned int img_id, void *img_ptr,
196195

197196
/* Ask the parser to check the image integrity */
198197
rc = img_parser_check_integrity(img_desc->img_type, img_ptr, img_len);
199-
return_if_error(rc);
198+
if (rc != 0) {
199+
return rc;
200+
}
200201

201202
/* Authenticate the image using the methods indicated in the image descriptor. */
202203
if (img_desc->img_auth_methods == NULL)
@@ -216,7 +217,10 @@ int auth_mod_verify_img(unsigned int img_id, void *img_ptr,
216217
rc = 1;
217218
break;
218219
}
219-
return_if_error(rc);
220+
221+
if (rc != 0) {
222+
return rc;
223+
}
220224
}
221225

222226
/* Extract the parameters indicated in the image descriptor to
@@ -233,7 +237,9 @@ int auth_mod_verify_img(unsigned int img_id, void *img_ptr,
233237
img_desc->img_type,
234238
img_desc->authenticated_data[i].type_desc,
235239
img_ptr, img_len, &param_ptr, &param_len);
236-
return_if_error(rc);
240+
if (rc != 0) {
241+
return rc;
242+
}
237243

238244
/* Check parameter size */
239245
if (param_len >

plat/renesas/rza/common/drivers/auth/sblib/crypto_sblib.c renamed to drivers/renesas/rza/auth/sblib/crypto_sblib.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@
1717

1818
static sb_secure_boot_api_t secure_boot_api;
1919

20-
int crypto_sblib_auth(void *data_ptr, size_t len, const void *key_cert,
21-
unsigned int key_cert_len, const void *content_cert,
22-
unsigned int content_cert_len)
20+
int crypto_sblib_auth(const void *key_cert, unsigned int key_cert_len,
21+
const void *content_cert, unsigned int content_cert_len)
2322
{
2423
sb_ret_t rc;
2524

2625
assert(secure_boot_api != NULL);
2726

2827
rc = secure_boot_api(key_cert, key_cert_len, content_cert,
2928
content_cert_len, NULL);
30-
if (SB_RET_SUCCESS != rc)
29+
if (rc != SB_RET_SUCCESS)
3130
return CRYPTO_ERR_UNKNOWN;
3231

3332
return CRYPTO_SUCCESS;

plat/renesas/rza/common/drivers/auth/sblib/sblib_api_private.h renamed to drivers/renesas/rza/auth/sblib/sblib_api_private.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
#define SB_RET_SAME_IMAGE_VERSION ((sb_ret_t)0x55005501UL)
3030

31-
/** A internal failure */
31+
/** An internal failure */
3232
#define SB_RET_ERR_INTERNAL_FAIL ((sb_ret_t)0xAAAA0000UL)
3333

3434
/** An invalid argument was entered */
@@ -82,7 +82,7 @@
8282
/** CRC mismatch */
8383
#define SB_RET_ERR_CRC_MISMATCH ((sb_ret_t)0xAAAA0300UL)
8484

85-
/** Unsupported polynominal */
85+
/** Unsupported polynomial */
8686
#define SB_RET_ERR_CRC_UNSUPPORTED_POLYNOMIAL ((sb_ret_t)0xAAAA0301UL)
8787

8888
/** Image version lower than the current image version is installed */

plat/renesas/rza/common/drivers/auth/sblib/sblib_parser.c renamed to drivers/renesas/rza/auth/sblib/sblib_parser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void clear_temp_vars(void)
3030
do { \
3131
zeromem(&x, sizeof(x)); \
3232
clean_dcache_range((uintptr_t) &x, sizeof(x)); \
33-
} while (0);
33+
} while (0)
3434

3535
#undef ZERO_AND_CLEAN
3636
}
@@ -61,7 +61,7 @@ static int check_integrity(void *img, unsigned int img_len)
6161
int rc;
6262
uint32_t magic;
6363

64-
if (SB_MANIFEST_LEN_MIN > img_len)
64+
if (img_len < SB_MANIFEST_LEN_MIN)
6565
return IMG_PARSER_ERR_FORMAT;
6666

6767
magic = *(uint32_t *)img;

0 commit comments

Comments
 (0)