ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_nsc_eth.c
Go to the documentation of this file.
1
17
18#include <stdint.h>
19
20#include "ra8_check.h"
21#include "ra8_err.h"
22#include "ra8_net_pal.h"
23#include "ra8_nsc.h"
24#include "ra8_nsc_veneer.h"
25
26static const char* s_tag = "NSCETH";
27
50RA8_NSC_VENEER ra8_err_t ra8_nsc_eth_send(const uint8_t* ns_frame, uint16_t len)
51{
52 RA8_CHECK_NULL_PTR(ns_frame, s_tag, "eth_send: ns_frame");
53 if ((len == 0U) || (len > (uint16_t)k_ra8_nsc_eth_frame_max)) {
55 }
56 RA8_NSC_CHECK_NS_RANGE_R(ns_frame, len);
57 return ra8_net_pal_send_frame(ns_frame, len);
58}
59
82RA8_NSC_VENEER ra8_err_t ra8_nsc_eth_recv(uint8_t* ns_buf, uint16_t* inout_len)
83{
84 RA8_CHECK_NULL_PTR(ns_buf, s_tag, "eth_recv: ns_buf");
85 RA8_CHECK_NULL_PTR(inout_len, s_tag, "eth_recv: inout_len");
86 /* Range-validate the NS caller's inout_len pointer BEFORE dereferencing it.
87 * A hostile NS caller could aim inout_len at Secure memory; the capacity read
88 * below would then read Secure state. cmse_check_address_range exists to
89 * prevent exactly this deref-before-check ordering (T5-07). */
90 RA8_NSC_CHECK_NS_RANGE_RW(inout_len, sizeof(*inout_len));
91 if (*inout_len < (uint16_t)k_ra8_nsc_eth_frame_max) {
93 }
94 RA8_NSC_CHECK_NS_RANGE_RW(ns_buf, *inout_len);
95 return ra8_net_pal_recv_frame(ns_buf, inout_len);
96}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
#define RA8_NSC_VENEER
Mark a TrustZone Secure-to-Non-Secure entry-point veneer.
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Network Platform Abstraction Layer for the RA8D2 ESWM block.
ra8_err_t ra8_net_pal_send_frame(const uint8_t *frame, uint16_t len)
Hand a complete ethernet frame to the MAC for transmit.
ra8_err_t ra8_net_pal_recv_frame(uint8_t *out_buf, uint16_t *inout_len)
Pull the next received ethernet frame, if any, into a buffer.
Non-Secure Callable veneers – the only NS->S gateway.
@ k_ra8_nsc_eth_frame_max
Max ethernet frame bytes.
Definition ra8_nsc.h:409
ra8_err_t ra8_nsc_eth_send(const uint8_t *ns_frame, uint16_t len)
NSC veneer: transmit an Ethernet frame from Non-Secure code.
Definition ra8_nsc_eth.c:50
ra8_err_t ra8_nsc_eth_recv(uint8_t *ns_buf, uint16_t *inout_len)
NSC veneer: receive an Ethernet frame into a Non-Secure buffer.
Definition ra8_nsc_eth.c:82
Macros for declaring Non-Secure Callable veneer functions.
#define RA8_NSC_CHECK_NS_RANGE_R(ptr, len)
RA8 NSC CHECK NS RANGE r.
#define RA8_NSC_CHECK_NS_RANGE_RW(ptr, len)
RA8 NSC CHECK NS RANGE RW.