Skip to content

Commit

Permalink
openamp: move notify_wait() in rpmsg virtio to rpmsg.
Browse files Browse the repository at this point in the history
This ops can do in rpmsg without coupling to virtio.

Signed-off-by: wangyongrong <[email protected]>
  • Loading branch information
wyr-7 committed Jan 31, 2024
1 parent eaa3ca6 commit 02140b8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/include/openamp/rpmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ typedef void (*rpmsg_ept_release_cb)(struct rpmsg_endpoint *ept);
typedef void (*rpmsg_ns_unbind_cb)(struct rpmsg_endpoint *ept);
typedef void (*rpmsg_ns_bind_cb)(struct rpmsg_device *rdev,
const char *name, uint32_t dest);
typedef int (*rpmsg_notify_wait_cb)(struct rpmsg_device *rdev, uint32_t id);

/**
* @brief Structure that binds a local RPMsg address to its user
Expand Down Expand Up @@ -143,6 +144,9 @@ struct rpmsg_device {
/** Callback handler for name service announcement, called when remote ept is destroyed */
rpmsg_ns_bind_cb ns_unbind_cb;

/** callback handler for rpmsg service, called when service can't get tx buffer */
rpmsg_notify_wait_cb notify_wait_cb;

/** RPMsg device operations */
struct rpmsg_device_ops ops;

Expand Down
8 changes: 8 additions & 0 deletions lib/rpmsg/rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,11 @@ void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
(void)rpmsg_send_ns_message(ept, RPMSG_NS_DESTROY);
rpmsg_unregister_endpoint(ept);
}

int rpmsg_notify_wait(struct rpmsg_device *rdev, uint32_t id)
{
if (rdev->notify_wait_cb)
return rdev->notify_wait_cb(rdev, id);

return RPMSG_ERR_NXIO;
}
2 changes: 2 additions & 0 deletions lib/rpmsg/rpmsg_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ rpmsg_get_ept_from_addr(struct rpmsg_device *rdev, uint32_t addr)
return rpmsg_get_endpoint(rdev, NULL, addr, RPMSG_ADDR_ANY);
}

int rpmsg_notify_wait(struct rpmsg_device *rdev, uint32_t id);

/**
* @internal
*
Expand Down
10 changes: 10 additions & 0 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,16 @@ static void rpmsg_virtio_release_rx_buffer(struct rpmsg_device *rdev,
metal_mutex_release(&rdev->lock);
}

static int rpmsg_virtio_notify_wait(struct rpmsg_virtio_device *rvdev,
struct virtqueue *vq)
{
struct virtio_vring_info *vring_info;

vring_info = &rvdev->vdev->vrings_info[vq->vq_queue_index];

return rpmsg_notify_wait(&rvdev->rdev, vring_info->notifyid);
}

static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
uint32_t *len, int wait)
{
Expand Down

0 comments on commit 02140b8

Please sign in to comment.