aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWendy Liang2017-01-24 14:00:08 -0600
committerWendy Liang2017-02-03 15:41:22 -0600
commit75d03f829034646430fc91e567b9a8813360b079 (patch)
tree416f59511df343047569888d86757a3ab003333c
parent51f0c03eb92dfa05ae2b827ed910c4f24da245fc (diff)
downloadopen-amp-75d03f829034646430fc91e567b9a8813360b079.tar.gz
open-amp-75d03f829034646430fc91e567b9a8813360b079.tar.xz
open-amp-75d03f829034646430fc91e567b9a8813360b079.zip
rpmsg: remote_dev: add API to check if remote is ready
Add an API to check if the remote is ready. Signed-off-by: Wendy Liang <jliang@xilinx.com>
-rw-r--r--lib/include/openamp/rpmsg_core.h1
-rw-r--r--lib/rpmsg/remote_device.c23
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/include/openamp/rpmsg_core.h b/lib/include/openamp/rpmsg_core.h
index 62a410b..118a1b7 100644
--- a/lib/include/openamp/rpmsg_core.h
+++ b/lib/include/openamp/rpmsg_core.h
@@ -172,6 +172,7 @@ int rpmsg_rdev_init(struct hil_proc *proc,
172 rpmsg_chnl_cb_t channel_destroyed, 172 rpmsg_chnl_cb_t channel_destroyed,
173 rpmsg_rx_cb_t default_cb); 173 rpmsg_rx_cb_t default_cb);
174void rpmsg_rdev_deinit(struct remote_device *rdev); 174void rpmsg_rdev_deinit(struct remote_device *rdev);
175int rpmsg_rdev_remote_ready(struct remote_device *rdev);
175struct rpmsg_channel *rpmsg_rdev_get_chnl_from_id(struct remote_device *rdev, 176struct rpmsg_channel *rpmsg_rdev_get_chnl_from_id(struct remote_device *rdev,
176 char *rp_chnl_id); 177 char *rp_chnl_id);
177struct rpmsg_endpoint *rpmsg_rdev_get_endpoint_from_addr( 178struct rpmsg_endpoint *rpmsg_rdev_get_endpoint_from_addr(
diff --git a/lib/rpmsg/remote_device.c b/lib/rpmsg/remote_device.c
index 3d6a916..223e3cc 100644
--- a/lib/rpmsg/remote_device.c
+++ b/lib/rpmsg/remote_device.c
@@ -52,6 +52,7 @@
52#include "metal/utilities.h" 52#include "metal/utilities.h"
53#include "metal/alloc.h" 53#include "metal/alloc.h"
54#include "metal/atomic.h" 54#include "metal/atomic.h"
55#include "metal/cpu.h"
55 56
56/* Macro to initialize vring HW info */ 57/* Macro to initialize vring HW info */
57#define INIT_VRING_ALLOC_INFO(ring_info,vring_hw) \ 58#define INIT_VRING_ALLOC_INFO(ring_info,vring_hw) \
@@ -368,6 +369,28 @@ int rpmsg_rdev_init_channels(struct remote_device *rdev)
368 return RPMSG_SUCCESS; 369 return RPMSG_SUCCESS;
369} 370}
370 371
372/**
373 * check if the remote is ready to start RPMsg communication
374 */
375int rpmsg_rdev_remote_ready(struct remote_device *rdev)
376{
377 struct virtio_device *vdev = &rdev->virt_dev;
378 uint8_t status;
379 if (rdev->role == RPMSG_MASTER) {
380 while (1) {
381 /* Busy wait until the remote is ready */
382 status = vdev->func->get_status(vdev);
383 if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK)
384 return true;
385 metal_cpu_yield();
386 }
387 } else {
388 return true;
389 }
390 /* Never come here */
391 return false;
392}
393
371static void rpmsg_memset_io(struct metal_io_region *io, void *dst, int c, size_t count) 394static void rpmsg_memset_io(struct metal_io_region *io, void *dst, int c, size_t count)
372{ 395{
373 if ((io->mem_flags & METAL_IO_MAPPED)) { 396 if ((io->mem_flags & METAL_IO_MAPPED)) {