ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1
48
49#include <stdint.h>
50#include <stdio.h>
51#include <string.h>
52
53#include "ra8_board_ek_ra8d2.h"
54#include "ra8_boot_entry.h"
55#include "ra8_cgc.h"
56#include "ra8_err.h"
57#include "ra8_isr.h"
58#include "ra8_rsip.h"
59#include "ra8_time.h"
60#include "ra8_tls.h"
61
62#ifndef RA8_OFF_TARGET
63#include "mbedtls/net_sockets.h"
64#include "mbedtls/platform.h"
65#include "mbedtls/ssl.h"
66#include "nx_api.h"
68#include "psa/crypto.h"
69#include "tx_api.h"
70#endif
71
103
114
125
138
151
164
166static const uint8_t k_demo_mac[6] = {0x02U, 0x00U, 0x00U, 0x00U, 0x00U, 0x03U};
167
169static const uint8_t k_demo_ip[4] = {(uint8_t)k_demo_ipaddr_0,
170 (uint8_t)k_demo_ipaddr_1,
171 (uint8_t)k_demo_ipaddr_2,
172 (uint8_t)k_demo_ipaddr_3};
173
175static const uint8_t k_demo_mask[4] = {(uint8_t)k_demo_netmask_b,
176 (uint8_t)k_demo_netmask_b,
177 (uint8_t)k_demo_netmask_b,
178 0U};
179
181static const uint8_t k_demo_gw[4] = {(uint8_t)k_demo_ipaddr_0,
182 (uint8_t)k_demo_ipaddr_1,
183 (uint8_t)k_demo_ipaddr_2,
184 (uint8_t)k_demo_gw_3};
185
187static const char k_demo_server_name[] = "endpoint.test";
188
190static const uint8_t k_demo_record[] = "PING over ra8_tls\n";
191
192#ifndef RA8_OFF_TARGET
193/* NetX Duo state. ThreadX requires statically-allocated control blocks
194 * (NASA Power of 10 Rule 3 -- no dynamic memory). */
195static NX_PACKET_POOL s_packet_pool;
196static NX_IP s_ip;
197static NX_TCP_SOCKET s_tls_socket;
201
202/* ThreadX worker thread + a byte pool that backs Mbed TLS's calloc/free. */
205static TX_BYTE_POOL s_byte_pool;
208static CHAR s_packet_pool_name[] = "ra8_eth_pool";
209static CHAR s_ip_name[] = "ra8_eth_ip";
210static CHAR s_socket_name[] = "tls4433";
211static CHAR s_byte_pool_name[] = "mbedtls_pool";
212static CHAR s_thread_name[] = "tls_worker";
213#endif /* !RA8_OFF_TARGET */
214
223static void demo_panic_halt(void)
224{
225 while (1) {
226 __asm__ volatile("wfi");
227 }
228}
229
239static void demo_setup_or_halt(void)
240{
241 uint32_t cpuclk0_hz = 0U;
242
243 if (ra8_cgc_init() != k_ra8_ok) {
245 }
248 }
249 if (ra8_time_init(cpuclk0_hz) != k_ra8_ok) {
251 }
254 }
257 }
258 const ra8_rsip_config_t rsip_cfg = {.run_bist = true};
259 if (ra8_rsip_init(&rsip_cfg) != k_ra8_ok) {
261 }
262}
263
274static void demo_print(const char* s)
275{
276 if (s == (const char*)0) {
277 return;
278 }
279 size_t len = strlen(s);
280 (void)ra8_board_uart_console_write((const uint8_t*)s, len);
281}
282
283#ifndef RA8_OFF_TARGET
296static ULONG demo_pack_ip(const uint8_t* octets)
297{
298 return (((ULONG)octets[k_demo_ip_oct_a]) << (ULONG)k_demo_ip_shift_a) |
302}
303
324
348psa_status_t mbedtls_psa_external_get_random(mbedtls_psa_external_random_context_t* context,
349 uint8_t* output,
350 size_t output_size,
351 size_t* output_length)
352{
353 (void)context;
354 if (output == nullptr || output_length == nullptr) {
355 return PSA_ERROR_INVALID_ARGUMENT;
356 }
357 if (ra8_rsip_trng_read((uint8_t*)output, (uint32_t)output_size) != k_ra8_ok) {
358 return PSA_ERROR_HARDWARE_FAILURE;
359 }
360 *output_length = output_size;
361 return PSA_SUCCESS;
362}
363
385static void* demo_calloc(size_t n, size_t size)
386{
387 if ((n == 0U) || (size == 0U)) {
388 return nullptr;
389 }
390 if (n > (SIZE_MAX / size)) {
391 return nullptr;
392 }
393 const size_t total = n * size;
394 VOID* p = NX_NULL;
395 if (tx_byte_allocate(&s_byte_pool, &p, (ULONG)total, TX_NO_WAIT) != TX_SUCCESS) {
396 return nullptr;
397 }
398 (void)memset((void*)p, 0, total);
399 return p;
400}
401
412static void demo_free(void* p)
413{
414 if (p == nullptr) {
415 return;
416 }
417 (void)tx_byte_release(p);
418}
419
434static int tls_bio_send(void* ctx, const uint8_t* buf, size_t len)
435{
436 (void)ctx;
437 if (buf == nullptr || len == 0U) {
438 return 0;
439 }
440 NX_PACKET* pkt = NX_NULL;
441 UINT s = nx_packet_allocate(&s_packet_pool, &pkt, NX_TCP_PACKET, NX_WAIT_FOREVER);
442 if (s != NX_SUCCESS || pkt == NX_NULL) {
443 return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
444 }
445 s =
446 nx_packet_data_append(pkt, (VOID*)(uintptr_t)buf, (ULONG)len, &s_packet_pool, NX_WAIT_FOREVER);
447 if (s != NX_SUCCESS) {
448 (void)nx_packet_release(pkt);
449 return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
450 }
451 s = nx_tcp_socket_send(&s_tls_socket, pkt, (ULONG)k_demo_recv_timeout);
452 if (s != NX_SUCCESS) {
453 (void)nx_packet_release(pkt);
454 if (s == NX_NO_PACKET || s == NX_WINDOW_OVERFLOW) {
455 return MBEDTLS_ERR_SSL_WANT_WRITE;
456 }
457 return MBEDTLS_ERR_NET_SEND_FAILED;
458 }
459 return (int)len;
460}
461
477static int tls_bio_recv(void* ctx, uint8_t* buf, size_t len)
478{
479 (void)ctx;
480 if (buf == nullptr || len == 0U) {
481 return 0;
482 }
483 NX_PACKET* pkt = NX_NULL;
484 UINT s = nx_tcp_socket_receive(&s_tls_socket, &pkt, (ULONG)k_demo_recv_timeout);
485 if (s == NX_NO_PACKET) {
486 return MBEDTLS_ERR_SSL_WANT_READ;
487 }
488 if (s != NX_SUCCESS || pkt == NX_NULL) {
489 return MBEDTLS_ERR_NET_RECV_FAILED;
490 }
491 ULONG copied = 0U;
492 (void)nx_packet_data_retrieve(pkt, (VOID*)buf, &copied);
493 (void)nx_packet_release(pkt);
494 if (copied > (ULONG)len) {
495 copied = (ULONG)len;
496 }
497 return (int)copied;
498}
499
511{
512 UINT s = nx_packet_pool_create(&s_packet_pool,
516 (ULONG)sizeof(s_pool_memory));
517 if (s != NX_SUCCESS) {
518 return s;
519 }
521
522 s = nx_ip_create(&s_ip,
523 s_ip_name,
528 (VOID*)s_ip_stack,
529 (ULONG)sizeof(s_ip_stack),
531 if (s != NX_SUCCESS) {
532 return s;
533 }
534 ULONG msw = 0U;
535 ULONG lsw = 0U;
536 demo_pack_mac(&msw, &lsw);
537 (void)nx_ip_interface_physical_address_set(&s_ip, 0U, msw, lsw, NX_TRUE);
538 (void)nx_ip_gateway_address_set(&s_ip, demo_pack_ip(k_demo_gw));
539
540 s = nx_arp_enable(&s_ip, (VOID*)s_arp_cache, (ULONG)sizeof(s_arp_cache));
541 if (s != NX_SUCCESS) {
542 return s;
543 }
544 s = nx_tcp_enable(&s_ip);
545 if (s != NX_SUCCESS) {
546 return s;
547 }
548 (void)nx_icmp_enable(&s_ip);
549 /* Fragment oversized datagrams into in-spec frames under the 128-byte MTU. */
550 (void)nx_ip_fragment_enable(&s_ip);
551 return NX_SUCCESS;
552}
553
565{
566 UINT s = nx_tcp_socket_create(&s_ip,
569 NX_IP_NORMAL,
570 NX_FRAGMENT_OKAY,
573 NX_NULL,
574 NX_NULL);
575 if (s != NX_SUCCESS) {
576 return s;
577 }
578 s = nx_tcp_client_socket_bind(&s_tls_socket, NX_ANY_PORT, NX_WAIT_FOREVER);
579 if (s != NX_SUCCESS) {
580 return s;
581 }
582 return nx_tcp_client_socket_connect(&s_tls_socket,
586}
587
602{
603 for (uint32_t i = 0U; i < (uint32_t)k_demo_handshake_max; ++i) {
604 ra8_err_t err = ra8_tls_handshake(session);
605 if (err != k_ra8_err_would_block) {
606 return err;
607 }
608 }
609 return k_ra8_err_timeout;
610}
611
626static ra8_err_t demo_exchange(ra8_tls_session_t session, uint8_t* got, size_t got_cap)
627{
628 if (got == nullptr || got_cap == 0U) {
630 }
631 size_t sent = 0U;
633 for (uint32_t i = 0U; (i < (uint32_t)k_demo_io_max) && (err == k_ra8_err_would_block); ++i) {
634 err = ra8_tls_send(session, k_demo_record, sizeof(k_demo_record) - 1U, &sent);
635 }
636 if (err != k_ra8_ok) {
637 return err;
638 }
639 size_t got_n = 0U;
641 for (uint32_t i = 0U; (i < (uint32_t)k_demo_io_max) && (err == k_ra8_err_would_block); ++i) {
642 err = ra8_tls_recv(session, got, got_cap, &got_n);
643 }
644 return err;
645}
646
657static void demo_report(ra8_tls_session_t session)
658{
659 uint16_t id = 0U;
660 char name[k_ra8_tls_cipher_name_cap] = {};
661 uint32_t flags = (uint32_t)k_demo_verify_unset;
662 (void)ra8_tls_get_cipher_suite(session, &id, name, sizeof(name));
663 (void)ra8_tls_get_verify_result(session, &flags);
664
665 demo_print("[tls] cipher=");
666 demo_print(name);
667 demo_print((flags == 0U) ? " verify=OK\r\n" : " verify=UNVERIFIED\r\n");
668}
669
681{
682 uint16_t mss = 0U;
683 if (ra8_tls_mss_clamp((uint16_t)k_demo_mtu, &mss) != k_ra8_ok) {
685 }
686 demo_print("[tls] MSS clamp applied\r\n");
687
689 if (err != k_ra8_ok) {
690 return err;
691 }
692
693 ra8_tls_session_cfg_t cfg = {};
694 cfg.bio_send = tls_bio_send;
695 cfg.bio_recv = tls_bio_recv;
696 cfg.bio_ctx = &s_tls_socket;
697 cfg.server_name = k_demo_server_name;
698 /* The test endpoint typically presents a self-signed cert; report the
699 * verification result rather than aborting the exchange. */
700 cfg.verify_mode = k_ra8_tls_verify_optional;
701
702 ra8_tls_session_t session = nullptr;
703 err = ra8_tls_session_open(&session, &cfg);
704 if (err != k_ra8_ok) {
705 (void)ra8_tls_global_deinit();
706 return err;
707 }
708
709 err = demo_handshake(session);
710 if (err == k_ra8_ok) {
711 uint8_t got[k_demo_record_cap] = {};
712 err = demo_exchange(session, got, sizeof(got));
713 demo_report(session);
714 }
715
716 (void)ra8_tls_session_close(session);
717 (void)ra8_tls_global_deinit();
718 return err;
719}
720
731static void demo_thread_entry(ULONG thread_input)
732{
733 (void)thread_input;
734 if (psa_crypto_init() != PSA_SUCCESS) {
735 demo_print("[tls] psa_crypto_init failed\r\n");
736 return;
737 }
738 demo_print("[tls] bringing NetX Duo up...\r\n");
739 if (demo_netx_bring_up() != NX_SUCCESS) {
740 demo_print("[tls] NetX bring-up failed\r\n");
741 return;
742 }
743 demo_print("[tls] connecting to 192.168.1.1:4433\r\n");
744 if (demo_tcp_connect() != NX_SUCCESS) {
745 demo_print("[tls] TCP connect failed\r\n");
746 return;
747 }
748 if (demo_run_tls() != k_ra8_ok) {
749 demo_print("[tls] session failed\r\n");
750 }
751 demo_print("[tls] done\r\n");
752}
753
764void tx_application_define(void* first_unused_memory)
765{
766 (void)first_unused_memory;
767
768 (void)tx_byte_pool_create(&s_byte_pool,
771 (ULONG)sizeof(s_byte_pool_memory));
772 mbedtls_platform_set_calloc_free(demo_calloc, demo_free);
773
774 nx_system_initialize();
775
779 0U,
781 (ULONG)sizeof(s_demo_stack),
786}
787#endif /* !RA8_OFF_TARGET */
788
797void main(void)
798{
801 demo_print("[tls] booting ThreadX + NetX Duo + ra8_tls...\r\n");
802
803#ifndef RA8_OFF_TARGET
804 tx_kernel_enter();
805#endif
806
808}
void main(void)
Secure fallback main entry point.
Definition main.c:37
static CHAR s_socket_name[]
Definition c6_cam_net.c:40
static CHAR s_ip_name[]
Definition c6_cam_net.c:38
demo_ip_octet_t
Octet indices into a packed IPv4 address.
Definition main.c:114
@ k_demo_ip_oct_d
Demo IP oct d.
Definition main.c:118
@ k_demo_ip_oct_c
Demo IP oct c.
Definition main.c:117
@ k_demo_ip_oct_b
Demo IP oct b.
Definition main.c:116
@ k_demo_ip_oct_a
Demo IP oct a.
Definition main.c:115
demo_ipv4_t
Demo IPv4 addresses (board, gateway, host) as octet enums.
Definition main.c:146
@ k_demo_ipaddr_0
192.168.1.42 board.
Definition main.c:147
@ k_demo_ipaddr_2
Demo ipaddr 2.
Definition main.c:149
@ k_demo_netmask_b
255.255.255.0 (first three octets).
Definition main.c:151
@ k_demo_ipaddr_3
Demo ipaddr 3.
Definition main.c:150
@ k_demo_ipaddr_1
Demo ipaddr 1.
Definition main.c:148
static TX_THREAD s_demo_thread
Definition main.c:237
demo_ip_shift_t
Bit shifts that pack a 4-octet IPv4 into NetX's ULONG.
Definition main.c:125
@ k_demo_ip_shift_a
Demo IP shift a.
Definition main.c:126
@ k_demo_ip_shift_d
Demo IP shift d.
Definition main.c:129
@ k_demo_ip_shift_b
Demo IP shift b.
Definition main.c:127
@ k_demo_ip_shift_c
Demo IP shift c.
Definition main.c:128
demo_mac_word_shift_t
Shifts that pack the 6-byte MAC into msw/lsw ULONG pairs.
Definition main.c:136
@ k_demo_mac_lsw_shift_b2
Demo MAC lsw shift b2.
Definition main.c:139
@ k_demo_mac_lsw_shift_b4
Demo MAC lsw shift b4.
Definition main.c:141
@ k_demo_mac_lsw_shift_b3
Demo MAC lsw shift b3.
Definition main.c:140
@ k_demo_mac_lsw_shift_b5
Demo MAC lsw shift b5.
Definition main.c:142
@ k_demo_mac_msw_shift_b0
Demo MAC msw shift b0.
Definition main.c:137
@ k_demo_mac_msw_shift_b1
Demo MAC msw shift b1.
Definition main.c:138
static ULONG s_ip_stack[k_demo_ip_stack/sizeof(ULONG)]
Definition main.c:232
demo_mac_idx_t
MAC-address byte indices.
Definition main.c:165
@ k_demo_mac_idx_0
Demo MAC index 0.
Definition main.c:166
@ k_demo_mac_idx_3
Demo MAC index 3.
Definition main.c:169
@ k_demo_mac_idx_5
Demo MAC index 5.
Definition main.c:171
@ k_demo_mac_idx_2
Demo MAC index 2.
Definition main.c:168
@ k_demo_mac_idx_1
Demo MAC index 1.
Definition main.c:167
@ k_demo_mac_idx_4
Demo MAC index 4.
Definition main.c:170
static NX_PACKET_POOL s_packet_pool
Definition main.c:228
demo_config_t
Compile-time settings for the HTTPS client demo.
Definition main.c:87
@ k_demo_recv_timeout
Ticks; ~2 s at TX_TIMER_TICKS_PER_SECOND=100.
Definition main.c:101
@ k_demo_socket_ttl
Demo socket ttl.
Definition main.c:100
@ k_demo_app_thread_pri
Demo app thread priority.
Definition main.c:91
@ k_demo_thread_stack
Demo thread stack.
Definition main.c:89
@ k_demo_handshake_max
Max ticks waiting for handshake.
Definition main.c:102
@ k_demo_ip_thread_pri
Demo IP thread priority.
Definition main.c:90
@ k_demo_packet_size
Demo packet size.
Definition main.c:92
@ k_demo_byte_pool_size
Demo byte pool size.
Definition main.c:95
@ k_demo_baud
Demo baud.
Definition main.c:88
@ k_demo_arp_cache
Demo arp cache.
Definition main.c:97
@ k_demo_pool_bytes
Demo pool bytes.
Definition main.c:94
@ k_demo_recv_window
Demo recv window.
Definition main.c:99
@ k_demo_ip_stack
Demo IP stack.
Definition main.c:96
static NX_IP s_ip
Definition main.c:229
static UCHAR s_byte_pool_memory[k_demo_byte_pool_size]
Definition main.c:240
static UCHAR s_demo_stack[k_demo_thread_stack]
Definition main.c:238
static TX_BYTE_POOL s_byte_pool
Definition main.c:239
static NX_TCP_SOCKET s_tls_socket
Definition main.c:230
static ULONG s_arp_cache[k_demo_arp_cache/sizeof(ULONG)]
Definition main.c:233
static UCHAR s_pool_memory[k_demo_pool_bytes]
Definition main.c:231
void tx_application_define(void *first_unused_memory)
ThreadX system-define hook: build worker thread + byte pool.
Definition main.c:942
static void demo_print(const char *msg)
Print a NUL-terminated string on the demo's UART stream.
Definition main.c:100
static void demo_setup_or_halt(void)
Bring up CGC + SysTick + the SCI8 console; halt forever on any failure.
Definition main.c:123
static void demo_panic_halt(void)
Halt forever in WFI – used as a panic stop on init failure.
Definition main.c:93
static UINT demo_tcp_connect(void)
Open a NetX TCP socket and connect to the TLS endpoint.
Definition main.c:564
static void demo_free(void *p)
mbedtls_free hook backed by the ThreadX byte pool.
Definition main.c:412
static ra8_err_t demo_exchange(ra8_tls_session_t session, uint8_t *got, size_t got_cap)
Send one record and read one back over the TLS session.
Definition main.c:626
@ k_demo_gw_3
192.168.1.1 gateway + TLS endpoint.
Definition main.c:149
static void demo_report(ra8_tls_session_t session)
Print the negotiated cipher + verification result to the console.
Definition main.c:657
static const uint8_t k_demo_mask[4]
Subnet mask: 255.255.255.0.
Definition main.c:175
static int tls_bio_recv(void *ctx, uint8_t *buf, size_t len)
ra8_tls BIO recv callback bound to nx_tcp_socket_receive.
Definition main.c:477
static int tls_bio_send(void *ctx, const uint8_t *buf, size_t len)
ra8_tls BIO send callback bound to nx_tcp_socket_send.
Definition main.c:434
psa_status_t mbedtls_psa_external_get_random(mbedtls_psa_external_random_context_t *context, uint8_t *output, size_t output_size, size_t *output_length)
PSA external RNG hook – feeds the RSIP TRNG straight into PSA.
Definition main.c:348
static void * demo_calloc(size_t n, size_t size)
mbedtls_calloc hook backed by the ThreadX byte pool.
Definition main.c:385
static const uint8_t k_demo_ip[4]
IPv4 address: 192.168.1.42.
Definition main.c:169
static const uint8_t k_demo_mac[6]
Locally-administered unicast MAC for this board.
Definition main.c:166
static ra8_err_t demo_handshake(ra8_tls_session_t session)
Drive the ra8_tls handshake to completion (bounded poll loop).
Definition main.c:601
static void demo_pack_mac(ULONG *msw, ULONG *lsw)
Pack the local MAC into the msw/lsw fields NetX expects.
Definition main.c:315
static const char k_demo_server_name[]
SNI hostname advertised in the ClientHello.
Definition main.c:187
@ k_demo_io_max
Bounded send/recv poll count.
Definition main.c:96
@ k_demo_mtu
#21 pinned link MTU.
Definition main.c:99
@ k_demo_verify_unset
Fail-closed verify sentinel: nonzero until the getter fills it.
Definition main.c:100
@ k_demo_line_buf
Result line buffer bytes.
Definition main.c:97
@ k_demo_connect_ticks
Max ticks waiting for connect.
Definition main.c:94
@ k_demo_record_cap
Inbound record buffer bytes.
Definition main.c:98
@ k_demo_tls_port
Default TLS endpoint port.
Definition main.c:90
static CHAR s_packet_pool_name[]
Persistent mutable names retained by NetX Duo and ThreadX objects.
Definition main.c:208
static UINT demo_netx_bring_up(void)
Bring NetX Duo up: pool, IP, gateway, ARP, TCP, ICMP.
Definition main.c:510
static ra8_err_t demo_run_tls(void)
Run the whole TLS session: open, handshake, exchange, report.
Definition main.c:680
static ULONG demo_pack_ip(const uint8_t *octets)
Pack a 4-octet IPv4 array into NetX's host-order ULONG.
Definition main.c:296
static CHAR s_thread_name[]
Definition main.c:212
static void demo_thread_entry(ULONG thread_input)
ThreadX worker entry: PSA + NetX up, connect, run the TLS session.
Definition main.c:731
static const uint8_t k_demo_gw[4]
Default gateway + TLS endpoint: 192.168.1.1.
Definition main.c:181
static CHAR s_byte_pool_name[]
Definition main.c:211
static const uint8_t k_demo_record[]
The one application record this demo sends after the handshake.
Definition main.c:190
NetX Duo network driver shim that bridges onto the RA8 ra8_eth HAL.
void nx_ether_driver_ra8_eth_set_mac(const uint8_t mac[6])
Install the local MAC address used by the driver at NX_LINK_INITIALIZE.
void nx_ether_driver_ra8_eth(NX_IP_DRIVER *driver_req)
NetX Duo network-driver entry point bridging onto ra8_eth_*.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_ethernet_init(void)
Bring up the on-board RGMII Ethernet PHY and RMAC1/ETHA1.
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
Definition ra8_cgc.c:132
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
Definition ra8_cgc.h:70
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Definition ra8_cgc.c:727
Error Code Definitions for ra8-firmware.
@ k_ra8_err_would_block
Non-blocking operation would have blocked.
Definition ra8_err.h:210
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
@ k_ra8_err_timeout
Operation exceeded its time budget.
Definition ra8_err.h:188
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
size_t strlen(const char *s)
Calculate string length.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Definition ra8_isr.c:439
Renesas Secure IP (RSIP-E50D) HAL driver – public API.
ra8_err_t ra8_rsip_init(const ra8_rsip_config_t *cfg)
Power on the RSIP engine and (optionally) run BIST.
Definition ra8_rsip.c:234
ra8_err_t ra8_rsip_trng_read(uint8_t *buf, uint32_t len)
Drain len bytes from the RSIP true RNG – fail-closed, no backend.
Definition ra8_rsip.c:338
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
Definition ra8_time.c:59
Tiny TLS facade over the vendored Mbed TLS 4.x stack.
ra8_err_t ra8_tls_get_verify_result(ra8_tls_session_t session, uint32_t *out_flags)
Report the peer-certificate verification result for a session.
Definition ra8_tls.c:631
struct ra8_tls_session_handle * ra8_tls_session_t
Opaque TLS session handle (typed pointer into the static pool).
Definition ra8_tls.h:277
ra8_err_t ra8_tls_send(ra8_tls_session_t session, const uint8_t *buf, size_t len, size_t *out_sent)
Encrypt and send application data.
Definition ra8_tls.c:517
ra8_err_t ra8_tls_recv(ra8_tls_session_t session, uint8_t *buf, size_t len, size_t *out_received)
Decrypt and receive application data.
Definition ra8_tls.c:557
@ k_ra8_tls_cipher_name_cap
Capacity (bytes) a caller must reserve for a cipher-suite name.
Definition ra8_tls.h:114
ra8_err_t ra8_tls_session_open(ra8_tls_session_t *out_session, const ra8_tls_session_cfg_t *cfg)
Allocate a TLS session from the static pool.
Definition ra8_tls.c:432
ra8_err_t ra8_tls_session_close(ra8_tls_session_t session)
Release a TLS session back to the pool.
Definition ra8_tls.c:461
@ k_ra8_tls_verify_optional
Verify but do not abort on failure.
Definition ra8_tls.h:157
ra8_err_t ra8_tls_handshake(ra8_tls_session_t session)
Iterative TLS handshake driver.
Definition ra8_tls.c:479
ra8_err_t ra8_tls_get_cipher_suite(ra8_tls_session_t session, uint16_t *out_id, char *out_name, size_t name_cap)
Report the negotiated cipher suite for a session.
Definition ra8_tls.c:600
ra8_err_t ra8_tls_mss_clamp(uint16_t mtu, uint16_t *out_mss)
Compute the TCP MSS that keeps a segment inside one MTU frame.
Definition ra8_tls.c:651
ra8_err_t ra8_tls_global_deinit(void)
Symmetric tear-down for ra8_tls_global_init.
Definition ra8_tls.c:249
ra8_err_t ra8_tls_global_init(void)
One-shot facade initialisation.
Definition ra8_tls.c:222
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
#define TX_SUCCESS
#define tx_thread_create
#define TX_NO_TIME_SLICE
char CHAR
ThreadX-compatible CHAR (host stub).
#define TX_AUTO_START
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Opaque thread stand-in for the host build.
Initial configuration for ra8_rsip_init.
Per-session configuration handed to ra8_tls_session_open.