/** * rpmsg_virtio_get_tx_buffer * * Provides buffer to transmit messages. * * @param rvdev - pointer to rpmsg device * @param len - length of returned buffer * @param idx - buffer index * * return - pointer to buffer. */ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev, uint32_t *len, uint16_t *idx) { unsigned int role = rpmsg_virtio_get_role(rvdev); void *data = NULL; #ifndef VIRTIO_SLAVE_ONLY if (role == RPMSG_MASTER) { data = virtqueue_get_buffer(rvdev->svq, len, idx); if (data == NULL) { data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool, RPMSG_BUFFER_SIZE); *len = RPMSG_BUFFER_SIZE; } } #endif /*!VIRTIO_SLAVE_ONLY*/ #ifndef VIRTIO_MASTER_ONLY if (role == RPMSG_REMOTE) { data = virtqueue_get_available_buffer(rvdev->svq, idx, len); } #endif /*!VIRTIO_MASTER_ONLY*/ return data; }
/** * rpmsg_get_rx_buffer * * Retrieves the received buffer from the virtqueue. * * @param rdev - pointer to remote device * @param len - size of received buffer * @param idx - index of buffer * * @return - pointer to received buffer * */ void *rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len, unsigned short *idx) { void *data; if (rdev->role == RPMSG_REMOTE) { data = virtqueue_get_buffer(rdev->rvq, len); } else { data = virtqueue_get_available_buffer(rdev->rvq, idx, len); } return ((void *) env_map_vatopa(data)); }
/** * rpmsg_get_tx_buffer * * Provides buffer to transmit messages. * * @param rdev - pointer to remote device * @param len - length of returned buffer * @param idx - buffer index * * return - pointer to buffer. */ void *rpmsg_get_tx_buffer(struct remote_device *rdev, int *len, unsigned short *idx) { void *data; if (rdev->role == RPMSG_REMOTE) { data = virtqueue_get_buffer(rdev->tvq, (unsigned long *) len); if (data == RPMSG_NULL) { data = sh_mem_get_buffer(rdev->mem_pool); *len = RPMSG_BUFFER_SIZE; } } else { data = virtqueue_get_available_buffer(rdev->tvq, idx, (unsigned long *) len); } return ((void *) env_map_vatopa(data)); }