ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
nimble_transport_stubs.h File Reference

Weak link stubs standing in for the NimBLE transport core. More...

#include <stdint.h>
Include dependency graph for nimble_transport_stubs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void * ble_transport_alloc_evt (int discardable)
 Allocate an HCI event buffer (upstream ble_transport.h).
struct os_mbuf * ble_transport_alloc_acl_from_ll (void)
 Allocate an ACL mbuf for the LL-to-host direction.
void ble_transport_free (void *buf)
 Release a buffer obtained from ble_transport_alloc_evt().
int ble_transport_to_hs_evt (void *buf)
 Push an HCI event up to the host stack.
int ble_transport_to_hs_acl (struct os_mbuf *om)
 Push an ACL packet up to the host stack.
int os_mbuf_append (struct os_mbuf *om, const void *data, uint16_t len)
 Append bytes to an mbuf chain (upstream os_mbuf.h).
int os_mbuf_free_chain (struct os_mbuf *om)
 Free every mbuf in a chain.
uint16_t os_mbuf_len (const struct os_mbuf *om)
 Total payload length of an mbuf chain.
int os_mbuf_copydata (const struct os_mbuf *om, int off, int len, void *dst)
 Copy a byte range out of an mbuf chain.
int ble_transport_to_ll_cmd (void *buf)
 Host-to-controller HCI command entry point.
int ble_transport_to_ll_acl (struct os_mbuf *om)
 Host-to-controller ACL entry point.
void ble_transport_ll_init (void)
 Bring this port's controller-side transport up.
int ble_transport_to_ll_cmd_impl (void *buf)
 Controller-side handler for an HCI command from the host.
int ble_transport_to_ll_acl_impl (struct os_mbuf *om)
 Controller-side handler for an ACL packet from the host.
int ble_transport_to_ll_iso_impl (struct os_mbuf *om)
 Controller-side handler for an ISO packet from the host.

Detailed Description

Weak link stubs standing in for the NimBLE transport core.

Tag
[Ring 4 / PORT] {World: S}

The build compiles no upstream NimBLE source at all – not the nimble/transport object library, and not the host or NPL either (cmake/nimble.cmake contributes include directories only). So the symbols those libraries would define are missing at link time while ble_hci_ra8_ble.c still references them. nimble_npl_threadx.c supplies weak no-op definitions to close the link; the linker prefers the strong upstream symbols the moment the real TUs are added to the build, so nothing here has to be removed first.

These prototypes cannot come from upstream. The declarations live in nimble/transport.h, nimble/transport_impl.h and os/os_mbuf.h, and reaching them means pulling in the whole Mynewt porting layer (os/os_mempool.h hard-errors without a matching OS_ALIGNMENT) – precisely the dependency the curated build is avoiding. So the port declares what the port defines, which is also what puts a prototype in front of each definition: without one, a stub whose signature drifts from the upstream contract it is standing in for compiles clean and fails at link, or worse, links against a mismatched ABI.

Signatures here are copied from the upstream headers named above and must stay identical to them.

Warning
UNVALIDATED SCAFFOLD (issue #286). Every symbol declared here is a link-only no-op, not a working BLE transport.

Definition in file nimble_transport_stubs.h.

Function Documentation

◆ ble_transport_alloc_acl_from_ll()

struct os_mbuf * ble_transport_alloc_acl_from_ll ( void )

Allocate an ACL mbuf for the LL-to-host direction.

Stub: no mbuf pool exists in the curated build.

Returns
Pointer to a freshly allocated ACL mbuf chain.
Return values
NULLAlways, in the stub build.
Precondition
The NimBLE port has been initialised.
Caller is prepared for a NULL return.
Postcondition
No allocation is performed.
No global state changes.
Note
Not thread-safe unless the real transport core replaces it.
See also
ble_transport_to_hs_acl()
Since
0.1.0

Definition at line 581 of file nimble_npl_threadx.c.

Referenced by internal_acl_cb().

◆ ble_transport_alloc_evt()

void * ble_transport_alloc_evt ( int discardable)

Allocate an HCI event buffer (upstream ble_transport.h).

Stub: the curated build has no transport buffer pool, so the allocation always fails and the caller drops the event.

Parameters
[in]discardableNon-zero when the caller can tolerate a NULL return (low-priority event). Unused by the stub, kept for ABI parity with upstream.
Returns
Pointer to an event buffer.
Return values
NULLAlways, in the stub build.
Precondition
The NimBLE port has been initialised.
Caller is prepared for a NULL return.
Postcondition
No allocation is performed.
No global state changes.
Note
Not thread-safe unless the real transport core replaces it.
See also
ble_transport_free()
Since
0.1.0

Definition at line 575 of file nimble_npl_threadx.c.

Referenced by internal_event_cb().

◆ ble_transport_free()

void ble_transport_free ( void * buf)

Release a buffer obtained from ble_transport_alloc_evt().

Stub: nothing was ever allocated, so nothing is freed.

Parameters
[in]bufBuffer to release. May be NULL.
Precondition
buf came from ble_transport_alloc_evt() or is NULL.
The NimBLE port has been initialised.
Postcondition
The buffer is no longer owned by the caller.
No global state changes in the stub build.
Note
Not thread-safe unless the real transport core replaces it.
See also
ble_transport_alloc_evt()
Since
0.1.0

Definition at line 586 of file nimble_npl_threadx.c.

Referenced by ble_transport_to_ll_cmd_impl().

◆ ble_transport_ll_init()

void ble_transport_ll_init ( void )

Bring this port's controller-side transport up.

Upstream transport_impl.h calls this once from the transport core's own init. Implemented by ble_hci_ra8_ble.c.

Precondition
ble_hci_ra8_ble_init() has succeeded.
The NimBLE port has been initialised.
Postcondition
The controller side is ready to accept HCI traffic.
Repeated calls are harmless.
Note
Not thread-safe; call from the port bring-up path only.
See also
ble_transport_to_ll_cmd_impl()
Since
0.1.0

Bring this port's controller-side transport up.

Idempotent: if the app already called ble_hci_ra8_ble_init we leave the running state alone. Otherwise we attach the inbound callbacks here so the very first HCI command issued by the host has a return path ready.

Precondition
ra8_ble_init returned k_ra8_ok.
Postcondition
Adapter is in the running state.
Since
0.1.0
Precondition
Module has been initialized.
Postcondition
Side effects bounded to documented state.
Note
Not thread-safe unless documented otherwise.

Definition at line 286 of file ble_hci_ra8_ble.c.

References ble_hci_ra8_ble_init(), k_ble_hci_ra8_ble_state_running, and s_state.

◆ ble_transport_to_hs_acl()

int ble_transport_to_hs_acl ( struct os_mbuf * om)

Push an ACL packet up to the host stack.

Stub: the mbuf is dropped and success is reported.

Parameters
[in]omACL mbuf chain to deliver.
Returns
Upstream transport status code.
Return values
0Always, in the stub build.
Precondition
om is a valid mbuf chain.
The NimBLE port has been initialised.
Postcondition
Ownership of om passes to the transport.
No data reaches a host in the stub build.
Note
Not thread-safe unless the real transport core replaces it.
See also
ble_transport_to_hs_evt()
Since
0.1.0

Definition at line 597 of file nimble_npl_threadx.c.

Referenced by internal_acl_cb().

◆ ble_transport_to_hs_evt()

int ble_transport_to_hs_evt ( void * buf)

Push an HCI event up to the host stack.

Stub: the event is dropped and success is reported so the controller side does not treat the missing host as an error.

Parameters
[in]bufEvent buffer from ble_transport_alloc_evt().
Returns
Upstream transport status code.
Return values
0Always, in the stub build.
Precondition
buf is a valid event buffer.
The NimBLE port has been initialised.
Postcondition
Ownership of buf passes to the transport.
No data reaches a host in the stub build.
Note
Not thread-safe unless the real transport core replaces it.
See also
ble_transport_to_hs_acl()
Since
0.1.0

Definition at line 591 of file nimble_npl_threadx.c.

Referenced by internal_event_cb().

◆ ble_transport_to_ll_acl()

int ble_transport_to_ll_acl ( struct os_mbuf * om)

Host-to-controller ACL entry point.

Stub wrapper: forwards straight to ble_transport_to_ll_acl_impl().

Parameters
[in]omACL mbuf chain to send.
Returns
Upstream transport status code.
Return values
0Packet accepted by the controller side.
Precondition
om is a valid ACL mbuf chain.
ble_hci_ra8_ble_init() has succeeded.
Postcondition
Ownership of om passes to the controller side.
No state changes when the controller rejects the packet.
Note
Not thread-safe unless the real transport core replaces it.
See also
ble_transport_to_ll_acl_impl()
Since
0.1.0

Definition at line 637 of file nimble_npl_threadx.c.

References ble_transport_to_ll_acl_impl().

◆ ble_transport_to_ll_acl_impl()

int ble_transport_to_ll_acl_impl ( struct os_mbuf * om)

Controller-side handler for an ACL packet from the host.

Hands the packet to the RA8 BLE transport, reached the same two ways as ble_transport_to_ll_cmd_impl().

Parameters
[in]omACL mbuf chain.
Returns
Upstream transport status code.
Return values
0Packet handed to the RA8 BLE transport.
Precondition
om is a valid ACL mbuf chain.
ble_hci_ra8_ble_init() has succeeded.
Postcondition
Ownership of om passes to the RA8 BLE transport.
No state changes on rejection.
Note
Not thread-safe; one ACL packet in flight at a time.
See also
ble_transport_to_ll_acl()
Since
0.1.0

Definition at line 311 of file ble_hci_ra8_ble.c.

References k_ble_hci_acl_header_len, k_ble_hci_acl_off_handle_hi, k_ble_hci_acl_off_handle_lo, k_ble_hci_acl_off_len_hi, k_ble_hci_acl_off_len_lo, k_ble_hci_acl_off_payload, k_ble_hci_ra8_ble_acl_buf_max, k_ble_hci_shift_byte, k_ra8_ok, os_mbuf_copydata(), os_mbuf_free_chain(), os_mbuf_len(), and ra8_ble_hci_send_acl_data().

Referenced by ble_transport_to_ll_acl().

◆ ble_transport_to_ll_cmd()

int ble_transport_to_ll_cmd ( void * buf)

Host-to-controller HCI command entry point.

Stub wrapper: forwards straight to ble_transport_to_ll_cmd_impl() so an app that bypasses the upstream transport core still reaches this port's controller side.

Parameters
[in]bufHCI command buffer.
Returns
Upstream transport status code.
Return values
0Command accepted by the controller side.
Precondition
buf holds a well-formed HCI command.
ble_hci_ra8_ble_init() has succeeded.
Postcondition
Ownership of buf passes to the controller side.
No state changes when the controller rejects the command.
Note
Not thread-safe unless the real transport core replaces it.
See also
ble_transport_to_ll_cmd_impl()
Since
0.1.0

Definition at line 632 of file nimble_npl_threadx.c.

References ble_transport_to_ll_cmd_impl().

◆ ble_transport_to_ll_cmd_impl()

int ble_transport_to_ll_cmd_impl ( void * buf)

Controller-side handler for an HCI command from the host.

Hands the command to the RA8 BLE transport. The upstream transport core reaches this through ble_transport_to_ll_cmd(); the weak stub of that wrapper forwards here too, so an app that skips the core still reaches the controller.

Parameters
[in]bufHCI command buffer.
Returns
Upstream transport status code.
Return values
0Command handed to the RA8 BLE transport.
Precondition
buf holds a well-formed HCI command.
ble_hci_ra8_ble_init() has succeeded.
Postcondition
Ownership of buf passes to the RA8 BLE transport.
No state changes on rejection.
Note
Not thread-safe; one HCI command in flight at a time.
See also
ble_transport_to_ll_cmd()
Since
0.1.0

Definition at line 294 of file ble_hci_ra8_ble.c.

References ble_transport_free(), k_ble_hci_shift_byte, k_ra8_ok, and ra8_ble_hci_send_command().

Referenced by ble_transport_to_ll_cmd().

◆ ble_transport_to_ll_iso_impl()

int ble_transport_to_ll_iso_impl ( struct os_mbuf * om)

Controller-side handler for an ISO packet from the host.

The RA8 BLE transport carries no isochronous channels, so this rejects every packet rather than silently dropping it.

Parameters
[in]omISO mbuf chain.
Returns
Upstream transport status code.
Return values
0Packet accepted.
Precondition
om is a valid ISO mbuf chain.
ble_hci_ra8_ble_init() has succeeded.
Postcondition
Ownership of om passes to the RA8 BLE transport.
No state changes on rejection.
Note
Not thread-safe; one ISO packet in flight at a time.
See also
ble_transport_to_ll_acl_impl()
Since
0.1.0

Controller-side handler for an ISO packet from the host.

Bluetooth LE Audio (Core 5.2+) ISO data is not exposed through ra8_ble yet. We accept the call to keep the link satisfied, free the mbuf, and return success.

Parameters
[in]omNimBLE-allocated ISO mbuf chain.
Returns
0 on success.
Precondition
om may be NULL.
Postcondition
om has been freed (if non-NULL).
Since
0.1.0
Return values
0Success or default value.
Precondition
Module has been initialized.
Postcondition
Side effects bounded to documented state.
Note
Not thread-safe unless documented otherwise.

Definition at line 370 of file ble_hci_ra8_ble.c.

References os_mbuf_free_chain().

◆ os_mbuf_append()

int os_mbuf_append ( struct os_mbuf * om,
const void * data,
uint16_t len )

Append bytes to an mbuf chain (upstream os_mbuf.h).

Stub: no mbuf pool exists, so the append is a no-op.

Parameters
[in,out]omChain to append to.
[in]dataBytes to copy in.
[in]lenNumber of bytes at data.
Returns
Mynewt status code.
Return values
0Always, in the stub build.
Precondition
om and data are valid for len bytes.
The NimBLE port has been initialised.
Postcondition
om is unchanged in the stub build.
No allocation is performed.
Note
Not thread-safe unless the real mbuf pool replaces it.
See also
os_mbuf_len()
Since
0.1.0

Definition at line 603 of file nimble_npl_threadx.c.

Referenced by internal_acl_cb().

◆ os_mbuf_copydata()

int os_mbuf_copydata ( const struct os_mbuf * om,
int off,
int len,
void * dst )

Copy a byte range out of an mbuf chain.

Stub: copies nothing and reports success.

Parameters
[in]omChain to read from.
[in]offByte offset into the chain payload.
[in]lenNumber of bytes to copy.
[out]dstDestination buffer, at least len bytes.
Returns
Mynewt status code.
Return values
0Always, in the stub build.
Precondition
dst is writable for len bytes.
off and len lie inside the chain payload.
Postcondition
dst is untouched in the stub build.
om is not modified.
Note
Not thread-safe unless the real mbuf pool replaces it.
See also
os_mbuf_len()
Since
0.1.0

Definition at line 623 of file nimble_npl_threadx.c.

Referenced by ble_transport_to_ll_acl_impl().

◆ os_mbuf_free_chain()

int os_mbuf_free_chain ( struct os_mbuf * om)

Free every mbuf in a chain.

Stub: nothing was allocated, so nothing is freed.

Parameters
[in]omHead of the chain to release. May be NULL.
Returns
Mynewt status code.
Return values
0Always, in the stub build.
Precondition
om is a chain head or NULL.
The NimBLE port has been initialised.
Postcondition
The caller no longer owns om.
No pool state changes in the stub build.
Note
Not thread-safe unless the real mbuf pool replaces it.
See also
os_mbuf_append()
Since
0.1.0

Definition at line 611 of file nimble_npl_threadx.c.

Referenced by ble_transport_to_ll_acl_impl(), ble_transport_to_ll_iso_impl(), and internal_acl_cb().

◆ os_mbuf_len()

uint16_t os_mbuf_len ( const struct os_mbuf * om)

Total payload length of an mbuf chain.

Stub: reports an empty chain.

Parameters
[in]omChain to measure. May be NULL.
Returns
Payload length in bytes.
Return values
0Always, in the stub build.
Precondition
om is a chain head or NULL.
The NimBLE port has been initialised.
Postcondition
om is not modified.
No pool state changes.
Note
Not thread-safe unless the real mbuf pool replaces it.
See also
os_mbuf_copydata()
Since
0.1.0

Definition at line 617 of file nimble_npl_threadx.c.

Referenced by ble_transport_to_ll_acl_impl().