39 if ((dst ==
nullptr) || (cap == 0U)) {
43 if ((src ==
nullptr) || (src->data ==
nullptr)) {
47 const size_t room = (size_t)cap - 1U;
48 const size_t take = (src->len < room) ? src->len : room;
49 for (
size_t i = 0U; i < take; i++) {
50 dst[i] = (char)src->data[i];
66 dst->
octet[i] = src->data[i];
73 if ((link ==
nullptr) || (ev ==
nullptr)) {
79 if (link->
stats !=
nullptr) {
89 if ((link ==
nullptr) || (view ==
nullptr)) {
92 const uint8_t* payload = &link->
rx[view->
offset];
94 if (view->
if_type == (uint8_t)ESP_SERIAL_IF) {
97 if ((view->
if_type == (uint8_t)ESP_STA_IF) || (view->
if_type == (uint8_t)ESP_AP_IF)) {
98 if (link->
stats !=
nullptr) {
101 if (link->
rx_cb !=
nullptr) {
110 if (link->
stats !=
nullptr) {
148 if ((link ==
nullptr) || (cfg ==
nullptr)) {
170 link->
stats =
nullptr;
180 if (link ==
nullptr) {
188 link->
rx_cb =
nullptr;
190 link->
arena =
nullptr;
191 link->
stats =
nullptr;
200 return (link !=
nullptr) && link->
open;
205 if ((link ==
nullptr) || (out ==
nullptr)) {
214 if (link ==
nullptr) {
220 if (max_transactions == 0U) {
226 if (stats !=
nullptr) {
235 if ((link ==
nullptr) || (out ==
nullptr)) {
241 if (max_transactions == 0U) {
257 link->
tx_len = (uint16_t)caps;
258 link->
tx_if = (uint8_t)ESP_PRIV_IF;
294 const Rpc* msg = (
const Rpc*)msg_v;
297 const RpcRespGetCoprocessorFwVersion* body = msg->resp_get_coprocessor_fwversion;
298 if (body ==
nullptr) {
301 out->
major = body->major1;
302 out->
minor = body->minor1;
303 out->
patch = body->patch1;
312 if ((link ==
nullptr) || (out ==
nullptr)) {
320 RpcReqGetCoprocessorFwVersion body;
321 rpc__req__get_coprocessor_fw_version__init(&body);
325 req.msg_type = RPC_TYPE__Req;
326 req.msg_id = RPC_ID__Req_GetCoprocessorFwVersion;
327 req.payload_case = RPC__PAYLOAD_REQ_GET_COPROCESSOR_FWVERSION;
328 req.req_get_coprocessor_fwversion = &body;
333 (uint32_t)RPC_ID__Resp_GetCoprocessorFwVersion,
340 if ((link ==
nullptr) || (frame ==
nullptr)) {
353 for (uint16_t i = 0U; i < len; i++) {
357 link->
tx_if = (uint8_t)ESP_STA_IF;
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
ra8_err_t ra8_c6link_fw_version(ra8_c6link_t *link, ra8_c6link_fw_version_t *out)
Ask the co-processor to identify itself.
ra8_err_t ra8_c6link_eth_send(ra8_c6link_t *link, const uint8_t *frame, uint16_t len)
Hand one 802.3 frame to the co-processor for transmission.
ra8_err_t ra8_c6link_close(ra8_c6link_t *link)
Release a link handle.
ra8_err_t ra8_c6link_last_fault(const ra8_c6link_t *link, ra8_c6link_fault_t *out)
Report the last request that failed on this link.
static ra8_err_t internal_c6link_check_cfg(const ra8_c6link_cfg_t *cfg)
Reject a configuration the link cannot honour.
static ra8_err_t internal_c6link_take_fw(void *ctx, const void *msg_v)
Extract the co-processor identity from its answer.
void priv_c6link_emit(ra8_c6link_t *link, const ra8_c6link_event_t *ev)
Deliver one decoded announcement to the registered callback.
ra8_err_t ra8_c6link_open(ra8_c6link_t *link, const ra8_c6link_cfg_t *cfg)
Bind a transport to a link handle and make it usable.
ra8_err_t ra8_c6link_await_ready(ra8_c6link_t *link, uint16_t max_transactions, ra8_c6link_fw_version_t *out)
Announce this host and prove the co-processor is answering.
bool priv_c6link_dispatch(ra8_c6link_t *link, const ra8_c6link_rx_view_t *view)
Route one well-formed received frame to whatever understands it.
ra8_err_t ra8_c6link_poll(ra8_c6link_t *link, uint16_t max_transactions, ra8_c6link_stats_t *stats)
Clock transactions, delivering whatever the co-processor sends.
bool ra8_c6link_is_open(const ra8_c6link_t *link)
Report whether a handle is currently open.
uint8_t priv_c6link_copy_str(char *dst, uint8_t cap, const ProtobufCBinaryData *src)
Copy a length-counted binary field into a NUL-terminated string.
bool priv_c6link_copy_mac(ra8_c6link_mac_t *dst, const ProtobufCBinaryData *src)
Copy a binary field into a MAC address, all-or-nothing.
The single integration boundary between this firmware and the ESP32-C6.
struct ra8_c6link_fault ra8_c6link_fault_t
@ k_ra8_c6link_hs_giveup
Consecutive HANDSHAKE timeouts after which a pump stops early.
struct ra8_c6link_mac ra8_c6link_mac_t
@ k_ra8_c6link_event_boot
Event_ESPInit: the co-processor has booted and is accepting RPC.
struct ra8_c6link_wait ra8_c6link_wait_t
struct ra8_c6link_cfg ra8_c6link_cfg_t
@ k_ra8_c6link_header_bytes
sizeof(struct esp_payload_header) on this ABI.
@ k_ra8_c6link_mac_bytes
Octets in an IEEE 802 address.
@ k_ra8_c6link_max_payload
Largest payload one frame can carry.
@ k_ra8_c6link_arena_min
Smallest decode arena ra8_c6link_open accepts.
struct ra8_c6link_stats ra8_c6link_stats_t
struct ra8_c6link_event ra8_c6link_event_t
struct ra8_c6link_fw_version ra8_c6link_fw_version_t
struct ra8_c6link ra8_c6link_t
uint8_t priv_c6link_caps(uint8_t *out, uint8_t cap)
Build the host-capabilities announcement.
Cross-translation-unit contract inside libs/ra8_c6link.
ra8_err_t priv_c6link_pump(ra8_c6link_t *link, uint16_t max_transactions, ra8_c6link_stats_t *stats)
Clock transactions until the budget or the wait says stop.
bool priv_c6link_rpc_consume(ra8_c6link_t *link, const uint8_t *payload, uint16_t len)
Decode one control-plane payload and act on it.
struct ra8_c6link_take_ctx ra8_c6link_take_ctx_t
struct ra8_c6link_rx_view ra8_c6link_rx_view_t
ra8_err_t priv_c6link_resp(ra8_c6link_t *link, uint32_t rpc_id, int32_t resp)
Map a co-processor result code onto an ra8 error, recording it.
ra8_err_t priv_c6link_rpc_call(ra8_c6link_t *link, Rpc *req, uint32_t resp_id, ra8_c6link_take_fn_t take, void *take_ctx)
Issue one request and pump until its answer arrives.
@ k_ra8_c6link_caps_bytes
Whole frame: two header octets plus five three-octet TLVs.
struct ra8_c6link_transport ra8_c6link_transport_t
@ k_ra8_err_busy
Resource busy – blocking operation cannot proceed.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_protocol_error
Protocol-level error (e.g.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
ra8_c6link_transport_t transport
The hardware seam; every row required.
uint32_t arena_bytes
Bytes available at arena.
uint8_t * arena
Protobuf decode arena.
void * cb_ctx
Context handed to both callbacks.
ra8_c6link_rx_cb_t rx_cb
802.3 receive sink, or null to count.
ra8_c6link_event_cb_t event_cb
Announcement sink, or null to count.
ra8_c6link_event_kind_t kind
Which announcement this is.
uint32_t major
Firmware major version.
char target[16]
CONFIG_IDF_TARGET, NUL-terminated.
uint32_t patch
Firmware patch version.
uint32_t chip_id
Co-processor chip identifier.
uint32_t minor
Firmware minor version.
uint8_t target_len
Characters in target, excluding the NUL.
uint8_t octet[k_ra8_c6link_mac_bytes]
Address octets, first on the wire first.
uint16_t offset
Byte offset of the payload within the transaction.
uint16_t len
Payload length in bytes.
uint8_t if_type
Interface type from the header.
uint16_t eth_in
802.3 frames delivered to the receive callback.
uint16_t unrouted
Frames on an interface this link does not use.
uint16_t events
Announcements delivered to the event callback.
ra8_c6link_t * link
Handle the request was issued on.
void * out
Where the extracted fields go, or null.
bool(* handshake_active)(void *ctx)
Report whether the co-processor is armed for a transaction.
void(* delay_ms)(void *ctx, uint16_t ms)
Yield for approximately ms milliseconds.
ra8_err_t(* transfer)(void *ctx, const uint8_t *tx, uint8_t *rx, uint16_t len)
Clock one full-duplex transaction of exactly len bytes.
uint8_t tx_if
Interface the staged payload uses.
uint32_t arena_used
Bump offset into arena.
uint8_t rx[k_ra8_c6link_frame_bytes]
Receive transaction.
uint32_t next_uid
UID for the next request issued.
void * cb_ctx
Context for both callbacks.
uint32_t arena_bytes
Bytes available at arena.
bool boot_seen
An Event_ESPInit has arrived.
ra8_c6link_rx_cb_t rx_cb
802.3 receive sink, or null.
uint32_t arena_last
Newest live block's offset plus one, or zero when there is none.
bool open
The handle is initialised.
uint8_t * arena
Protobuf decode arena.
ra8_c6link_fault_t fault
The last failing request.
ra8_c6link_stats_t * stats
Counters for the running pump.
uint16_t tx_len
Staged payload length, or zero.
ra8_c6link_wait_t wait
The outstanding request, if any.
uint8_t tx[k_ra8_c6link_frame_bytes]
Transmit transaction.
ra8_c6link_event_cb_t event_cb
Announcement sink, or null.
ra8_c6link_transport_t transport
Bound hardware seam.