|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
The two-tag envelope the co-processor's serial endpoint speaks. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_c6link.h"#include "ra8_c6link_internal.h"Go to the source code of this file.
Functions | |
| static uint16_t | internal_c6link_tlv_tag (uint8_t *out, uint16_t at, uint8_t type, uint16_t len) |
| Write one three-byte tag header at a cursor. | |
| static uint16_t | internal_c6link_tlv_len (const uint8_t *buf, uint16_t at) |
| Read one tag's little-endian 16-bit length. | |
| ra8_err_t | priv_c6link_tlv_open (uint8_t *out, uint16_t cap, uint16_t proto_len, uint16_t *body_at) |
| Write both envelope tags ahead of a protobuf payload. | |
| static bool | internal_c6link_tlv_named (const uint8_t *payload) |
| Check that a payload names one of the two RPC endpoints. | |
| const uint8_t * | priv_c6link_tlv_body (const uint8_t *payload, uint16_t len, uint16_t *proto_len) |
| Strip the envelope off a received serial payload. | |
The two-tag envelope the co-processor's serial endpoint speaks.
Six bytes of framing sit between the payload header and the protobuf message: a tag naming the endpoint, then a tag introducing the data. Upstream builds and parses them in compose_tlv() and parse_tlv() inside drivers/virtual_serial_if/serial_if.c, which this tree does not compile – its transmit path expands HOSTED_CALLOC, whose failure arm is a goto to a caller-supplied label, and NASA Power of 10 Rule 1 forbids that. The envelope itself is trivial, so it is restated here rather than dragged in with a rule violation attached.
Both endpoint names are accepted on receive. A response arrives on RPCRsp and an unsolicited event on RPCEvt; upstream requires every registered endpoint name to be the same length, and its own parser checks that, so the two are interchangeable as far as the framing is concerned.
Definition in file ra8_c6link_tlv.c.
|
static |
Read one tag's little-endian 16-bit length.
Reads what the sender wrote rather than assuming the host's own byte order, which is what makes the parser portable to a big-endian host.
| [in] | buf | Buffer holding the tag; must be non-null. |
| [in] | at | Offset of the tag's type byte. |
| 0 | The tag declares an empty value. |
at against the payload. Definition at line 84 of file ra8_c6link_tlv.c.
References k_ra8_c6link_tlv_len_hi, k_ra8_c6link_tlv_len_lo, k_ra8_c6link_tlv_shift, and RA8_INTERNAL.
Referenced by priv_c6link_tlv_body().
|
static |
Check that a payload names one of the two RPC endpoints.
Compares against both registered endpoint names at once, so a response and an unsolicited event are accepted by one pass rather than two.
| [in] | payload | Frame payload; must be non-null and long enough. |
| true | The envelope is addressed to this host's RPC endpoint. |
| false | At least one octet matched neither name. |
payload. Definition at line 133 of file ra8_c6link_tlv.c.
References k_ra8_c6link_tlv_ep_len, k_ra8_c6link_tlv_value, and RA8_INTERNAL.
Referenced by priv_c6link_tlv_body().
|
static |
Write one three-byte tag header at a cursor.
| [out] | out | Buffer being filled; must be non-null. |
One tag header is a type octet and a little-endian length, and both tags of the envelope are written by this.
| [in] | at | Offset to write at. |
| [in] | type | Tag type. |
| [in] | len | Value length that follows. |
| non-zero | The offset of the tag's value, always three past at. |
Definition at line 59 of file ra8_c6link_tlv.c.
References k_ra8_c6link_tlv_len_hi, k_ra8_c6link_tlv_len_lo, k_ra8_c6link_tlv_mask, k_ra8_c6link_tlv_shift, k_ra8_c6link_tlv_type, and k_ra8_c6link_tlv_value.
Referenced by priv_c6link_tlv_open().
|
nodiscard |
Strip the envelope off a received serial payload.
Both endpoint names are accepted, as upstream's parse_tlv() does: a response arrives on RPCRsp and an unsolicited event on RPCEvt, and the two are the same length by construction.
| [in] | payload | Frame payload; must be non-null. |
| [in] | len | Payload length in bytes. |
| [out] | proto_len | Protobuf length found; must be non-null. |
| NULL | The tags, the endpoint name or the lengths did not check out. |
len bytes are readable at payload. proto_len is writable. payload. proto_len is zero.Definition at line 146 of file ra8_c6link_tlv.c.
References internal_c6link_tlv_len(), internal_c6link_tlv_named(), k_ra8_c6link_tlv_ep_len, k_ra8_c6link_tlv_overhead, k_ra8_c6link_tlv_t_data, k_ra8_c6link_tlv_t_epname, k_ra8_c6link_tlv_type, and k_ra8_c6link_tlv_value.
Referenced by priv_c6link_rpc_consume().
|
nodiscard |
Write both envelope tags ahead of a protobuf payload.
| [out] | out | Buffer to fill; must be non-null. |
| [in] | cap | Bytes available at out. |
| [in] | proto_len | Protobuf length that will follow the envelope. |
| [out] | body_at | Offset the protobuf must be written at; must be non-null. |
| k_ra8_ok | The envelope is written and body_at names its payload. |
| k_ra8_err_null_ptr | out or body_at was null. |
| k_ra8_err_invalid_size | cap cannot hold envelope plus payload. |
cap bytes are writable at out. proto_len is the exact packed size, not an estimate. out is not modified and body_at is zero.Definition at line 91 of file ra8_c6link_tlv.c.
References internal_c6link_tlv_tag(), k_ra8_c6link_tlv_ep_len, k_ra8_c6link_tlv_overhead, k_ra8_c6link_tlv_t_data, k_ra8_c6link_tlv_t_epname, k_ra8_err_invalid_size, k_ra8_err_null_ptr, k_ra8_ok, and RA8_PRIV.
Referenced by internal_c6link_rpc_stage().