OpenAMP / open-amp

The main OpenAMP library implementing RPMSG, Virtio, and Remoteproc for RTOS etc
https://www.openampproject.org/
Other
706 stars 288 forks source link

openamp: add new API rpmsg_virtio_get_rx_buffer_size() #521

Closed CV-Bowen closed 11 months ago

CV-Bowen commented 11 months ago

With this API, user can get the rx buffer size, and use this buffer safer in endpoint callback function. Follow shows an example:

static int rpmsgfs_ept_cb(FAR struct rpmsg_endpoint *ept,
                          FAR void *data, size_t len, uint32_t src,
                          FAR void *priv)
{
    /* No need extra stack variable or malloced buffer, user can fill the response data in the data directly,
     * And to avoid the data overflow, user can call rpmsg_virtio_get_rx_buffer_size() to get the limitation
     * of input data.
     */

    /* Call rpmsg_send(ept, data, data_len) to send the response data */
    rpmsg_send(ept, data, len);
}
CV-Bowen commented 11 months ago

Just rebase to origin/main to pass CI.