mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
openamp: Update to 2020.10.0 official release
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Abdelatif Guettouche
parent
2f65c3dd74
commit
f8f1270f9b
+35
-33
@@ -1,7 +1,7 @@
|
|||||||
From 3ea08a8002de5e4992bed32567ecb05c887f31be Mon Sep 17 00:00:00 2001
|
From 34cacff47da59075d930a5e96b16d003b70d383d Mon Sep 17 00:00:00 2001
|
||||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
||||||
Date: Mon, 7 Jan 2019 02:15:42 +0800
|
Date: Mon, 7 Jan 2019 02:15:42 +0800
|
||||||
Subject: [PATCH 08/10] ns: acknowledge the received creation message
|
Subject: [PATCH 1/3] ns: acknowledge the received creation message
|
||||||
|
|
||||||
the two phase handsake make the client could initiate the transfer
|
the two phase handsake make the client could initiate the transfer
|
||||||
immediately without the server side send any dummy message first.
|
immediately without the server side send any dummy message first.
|
||||||
@@ -10,16 +10,16 @@ Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|||||||
---
|
---
|
||||||
lib/include/openamp/rpmsg.h | 1 +
|
lib/include/openamp/rpmsg.h | 1 +
|
||||||
lib/include/openamp/rpmsg_virtio.h | 1 +
|
lib/include/openamp/rpmsg_virtio.h | 1 +
|
||||||
lib/rpmsg/rpmsg.c | 7 +++++--
|
lib/rpmsg/rpmsg.c | 5 ++++-
|
||||||
lib/rpmsg/rpmsg_internal.h | 4 ++--
|
lib/rpmsg/rpmsg_internal.h | 4 ++--
|
||||||
lib/rpmsg/rpmsg_virtio.c | 12 +++++++++---
|
lib/rpmsg/rpmsg_virtio.c | 14 +++++++++++---
|
||||||
5 files changed, 18 insertions(+), 7 deletions(-)
|
5 files changed, 19 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
||||||
index 0b46ee1..318acd1 100644
|
index 8b8ec2e..efdfb2b 100644
|
||||||
--- a/lib/include/openamp/rpmsg.h
|
--- a/lib/include/openamp/rpmsg.h
|
||||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
+++ open-amp/lib/include/openamp/rpmsg.h
|
||||||
@@ -127,6 +127,7 @@ struct rpmsg_device {
|
@@ -120,6 +120,7 @@ struct rpmsg_device {
|
||||||
rpmsg_ns_bind_cb ns_bind_cb;
|
rpmsg_ns_bind_cb ns_bind_cb;
|
||||||
struct rpmsg_device_ops ops;
|
struct rpmsg_device_ops ops;
|
||||||
bool support_ns;
|
bool support_ns;
|
||||||
@@ -28,7 +28,7 @@ index 0b46ee1..318acd1 100644
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||||
index 2209a48..e6e5fa2 100644
|
index 12cb47f..4d3093b 100644
|
||||||
--- a/lib/include/openamp/rpmsg_virtio.h
|
--- a/lib/include/openamp/rpmsg_virtio.h
|
||||||
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||||
@@ -28,6 +28,7 @@ extern "C" {
|
@@ -28,6 +28,7 @@ extern "C" {
|
||||||
@@ -40,30 +40,29 @@ index 2209a48..e6e5fa2 100644
|
|||||||
/**
|
/**
|
||||||
* struct rpmsg_virtio_shm_pool - shared memory pool used for rpmsg buffers
|
* struct rpmsg_virtio_shm_pool - shared memory pool used for rpmsg buffers
|
||||||
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
|
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
|
||||||
index 0a8de1b..0cc80da 100644
|
index 46c3691..e52144b 100644
|
||||||
--- a/lib/rpmsg/rpmsg.c
|
--- a/lib/rpmsg/rpmsg.c
|
||||||
+++ open-amp/lib/rpmsg/rpmsg.c
|
+++ open-amp/lib/rpmsg/rpmsg.c
|
||||||
@@ -297,10 +297,13 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
@@ -297,10 +297,13 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
||||||
|
rpmsg_register_endpoint(rdev, ept);
|
||||||
|
metal_mutex_release(&rdev->lock);
|
||||||
|
|
||||||
rpmsg_init_ept(ept, rdev, name, addr, dest, cb, unbind_cb);
|
- /* Send NS announcement to remote processor */
|
||||||
|
+ /* Send NS announcement/acknowledge to remote processor */
|
||||||
|
if (ept->name[0] && rdev->support_ns &&
|
||||||
|
ept->dest_addr == RPMSG_ADDR_ANY)
|
||||||
|
status = rpmsg_send_ns_message(ept, RPMSG_NS_CREATE);
|
||||||
|
+ else if (ept->name[0] && rdev->support_ack &&
|
||||||
|
+ ept->dest_addr != RPMSG_ADDR_ANY)
|
||||||
|
+ status = rpmsg_send_ns_message(ept, RPMSG_NS_CREATE_ACK);
|
||||||
|
|
||||||
- if (rdev->support_ns && ept->dest_addr == RPMSG_ADDR_ANY) {
|
if (status)
|
||||||
+ if (ept->name[0]) {
|
rpmsg_unregister_endpoint(ept);
|
||||||
/* Send NS announcement to remote processor */
|
|
||||||
metal_mutex_release(&rdev->lock);
|
|
||||||
- status = rpmsg_send_ns_message(ept, RPMSG_NS_CREATE);
|
|
||||||
+ if (rdev->support_ns && ept->dest_addr == RPMSG_ADDR_ANY)
|
|
||||||
+ status = rpmsg_send_ns_message(ept, RPMSG_NS_CREATE);
|
|
||||||
+ else if (rdev->support_ack && ept->dest_addr != RPMSG_ADDR_ANY)
|
|
||||||
+ status = rpmsg_send_ns_message(ept, RPMSG_NS_CREATE_ACK);
|
|
||||||
metal_mutex_acquire(&rdev->lock);
|
|
||||||
if (status)
|
|
||||||
rpmsg_unregister_endpoint(ept);
|
|
||||||
diff --git a/lib/rpmsg/rpmsg_internal.h open-amp/lib/rpmsg/rpmsg_internal.h
|
diff --git a/lib/rpmsg/rpmsg_internal.h open-amp/lib/rpmsg/rpmsg_internal.h
|
||||||
index 3db6b24..d513a56 100644
|
index d4536d1..e64aeff 100644
|
||||||
--- a/lib/rpmsg/rpmsg_internal.h
|
--- a/lib/rpmsg/rpmsg_internal.h
|
||||||
+++ open-amp/lib/rpmsg/rpmsg_internal.h
|
+++ open-amp/lib/rpmsg/rpmsg_internal.h
|
||||||
@@ -44,12 +44,12 @@ extern "C" {
|
@@ -39,12 +39,12 @@ extern "C" {
|
||||||
*
|
*
|
||||||
* @RPMSG_NS_CREATE: a new remote service was just created
|
* @RPMSG_NS_CREATE: a new remote service was just created
|
||||||
* @RPMSG_NS_DESTROY: a known remote service was just destroyed
|
* @RPMSG_NS_DESTROY: a known remote service was just destroyed
|
||||||
@@ -79,10 +78,10 @@ index 3db6b24..d513a56 100644
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||||
index 195189d..9988a1e 100644
|
index 86a23ad..640240a 100644
|
||||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||||
@@ -586,13 +586,13 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
@@ -554,13 +554,13 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
||||||
metal_mutex_acquire(&rdev->lock);
|
metal_mutex_acquire(&rdev->lock);
|
||||||
_ept = rpmsg_get_endpoint(rdev, name, RPMSG_ADDR_ANY, dest);
|
_ept = rpmsg_get_endpoint(rdev, name, RPMSG_ADDR_ANY, dest);
|
||||||
|
|
||||||
@@ -92,15 +91,18 @@ index 195189d..9988a1e 100644
|
|||||||
_ept->dest_addr = RPMSG_ADDR_ANY;
|
_ept->dest_addr = RPMSG_ADDR_ANY;
|
||||||
metal_mutex_release(&rdev->lock);
|
metal_mutex_release(&rdev->lock);
|
||||||
if (_ept && _ept->ns_unbind_cb)
|
if (_ept && _ept->ns_unbind_cb)
|
||||||
_ept->ns_unbind_cb(ept);
|
_ept->ns_unbind_cb(_ept);
|
||||||
- } else {
|
- } else {
|
||||||
+ } else if (ns_msg->flags == RPMSG_NS_CREATE) {
|
+ } else if (ns_msg->flags == RPMSG_NS_CREATE) {
|
||||||
if (!_ept) {
|
if (!_ept) {
|
||||||
/*
|
/*
|
||||||
* send callback to application, that can
|
* send callback to application, that can
|
||||||
@@ -607,6 +607,11 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
@@ -574,7 +574,14 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
||||||
|
} else {
|
||||||
_ept->dest_addr = dest;
|
_ept->dest_addr = dest;
|
||||||
metal_mutex_release(&rdev->lock);
|
metal_mutex_release(&rdev->lock);
|
||||||
|
+ if (_ept->name[0] && rdev->support_ack)
|
||||||
|
+ rpmsg_send_ns_message(_ept, RPMSG_NS_CREATE_ACK);
|
||||||
}
|
}
|
||||||
+ } else { /* RPMSG_NS_CREATE_ACK */
|
+ } else { /* RPMSG_NS_CREATE_ACK */
|
||||||
+ /* save the received destination address */
|
+ /* save the received destination address */
|
||||||
@@ -110,7 +112,7 @@ index 195189d..9988a1e 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
return RPMSG_SUCCESS;
|
return RPMSG_SUCCESS;
|
||||||
@@ -659,6 +664,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
@@ -627,6 +634,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
||||||
#endif /*!VIRTIO_MASTER_ONLY*/
|
#endif /*!VIRTIO_MASTER_ONLY*/
|
||||||
vdev->features = rpmsg_virtio_get_features(rvdev);
|
vdev->features = rpmsg_virtio_get_features(rvdev);
|
||||||
rdev->support_ns = !!(vdev->features & (1 << VIRTIO_RPMSG_F_NS));
|
rdev->support_ns = !!(vdev->features & (1 << VIRTIO_RPMSG_F_NS));
|
||||||
@@ -118,15 +120,15 @@ index 195189d..9988a1e 100644
|
|||||||
|
|
||||||
#ifndef VIRTIO_SLAVE_ONLY
|
#ifndef VIRTIO_SLAVE_ONLY
|
||||||
if (role == RPMSG_MASTER) {
|
if (role == RPMSG_MASTER) {
|
||||||
@@ -754,7 +760,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
@@ -722,7 +730,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
||||||
* Create name service announcement endpoint if device supports name
|
* Create name service announcement endpoint if device supports name
|
||||||
* service announcement feature.
|
* service announcement feature.
|
||||||
*/
|
*/
|
||||||
- if (rdev->support_ns) {
|
- if (rdev->support_ns) {
|
||||||
+ if (rdev->support_ns || rdev->support_ack) {
|
+ if (rdev->support_ns || rdev->support_ack) {
|
||||||
rpmsg_init_ept(&rdev->ns_ept, rdev, "NS",
|
rpmsg_initialize_ept(&rdev->ns_ept, "NS",
|
||||||
RPMSG_NS_EPT_ADDR, RPMSG_NS_EPT_ADDR,
|
RPMSG_NS_EPT_ADDR, RPMSG_NS_EPT_ADDR,
|
||||||
rpmsg_virtio_ns_callback, NULL);
|
rpmsg_virtio_ns_callback, NULL);
|
||||||
--
|
--
|
||||||
2.17.1
|
2.17.1
|
||||||
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
From 5bc0ae0942fa9a4b9d321e31445457c31c888530 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
Date: Fri, 24 Apr 2020 01:44:31 +0800
|
|
||||||
Subject: [PATCH 01/10] rpmsg: remove the address check in
|
|
||||||
rpmsg_send/rpmsg_trysend
|
|
||||||
|
|
||||||
since rpmsg_send_offchannel_raw already do the same validation
|
|
||||||
|
|
||||||
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
---
|
|
||||||
lib/include/openamp/rpmsg.h | 4 ----
|
|
||||||
1 file changed, 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
|
||||||
index f2a6454..8401c38 100644
|
|
||||||
--- a/lib/include/openamp/rpmsg.h
|
|
||||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
|
||||||
@@ -146,8 +146,6 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
|
||||||
static inline int rpmsg_send(struct rpmsg_endpoint *ept, const void *data,
|
|
||||||
int len)
|
|
||||||
{
|
|
||||||
- if (ept->dest_addr == RPMSG_ADDR_ANY)
|
|
||||||
- return RPMSG_ERR_ADDR;
|
|
||||||
return rpmsg_send_offchannel_raw(ept, ept->addr, ept->dest_addr, data,
|
|
||||||
len, true);
|
|
||||||
}
|
|
||||||
@@ -216,8 +214,6 @@ static inline int rpmsg_send_offchannel(struct rpmsg_endpoint *ept,
|
|
||||||
static inline int rpmsg_trysend(struct rpmsg_endpoint *ept, const void *data,
|
|
||||||
int len)
|
|
||||||
{
|
|
||||||
- if (ept->dest_addr == RPMSG_ADDR_ANY)
|
|
||||||
- return RPMSG_ERR_ADDR;
|
|
||||||
return rpmsg_send_offchannel_raw(ept, ept->addr, ept->dest_addr, data,
|
|
||||||
len, false);
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.17.1
|
|
||||||
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
From fa4904c9d9ad16e791485d0ef22566427869144c Mon Sep 17 00:00:00 2001
|
|
||||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
Date: Mon, 11 May 2020 00:03:51 +0800
|
|
||||||
Subject: [PATCH] system: nuttx: change clock_systimespec to
|
|
||||||
clock_systime_timespec
|
|
||||||
|
|
||||||
follow up the change from NuttX side
|
|
||||||
|
|
||||||
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
---
|
|
||||||
lib/system/nuttx/time.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/lib/system/nuttx/time.c libmetal/lib/system/nuttx/time.c
|
|
||||||
index bafc957..986f1ba 100644
|
|
||||||
--- a/lib/system/nuttx/time.c
|
|
||||||
+++ libmetal/lib/system/nuttx/time.c
|
|
||||||
@@ -18,7 +18,7 @@ unsigned long long metal_get_timestamp(void)
|
|
||||||
struct timespec tp;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
- r = clock_systimespec(&tp);
|
|
||||||
+ r = clock_systime_timespec(&tp);
|
|
||||||
if (!r) {
|
|
||||||
t = (unsigned long long)tp.tv_sec * NSEC_PER_SEC;
|
|
||||||
t += tp.tv_nsec;
|
|
||||||
--
|
|
||||||
2.17.1
|
|
||||||
|
|
||||||
+19
-25
@@ -1,21 +1,21 @@
|
|||||||
From 2a64e1f23b140e1e2fdabfe77ed7a11062ef341a Mon Sep 17 00:00:00 2001
|
From effea71e4d59797cd6149a81b2c6b88dc550d972 Mon Sep 17 00:00:00 2001
|
||||||
From: anchao <anchao@pinecone.net>
|
From: Chao An <anchao@pinecone.net>
|
||||||
Date: Mon, 10 Dec 2018 16:26:39 +0800
|
Date: Mon, 10 Dec 2018 16:26:39 +0800
|
||||||
Subject: [PATCH 10/10] Negotiate individual buffer size dynamically
|
Subject: [PATCH 2/3] Negotiate individual buffer size dynamically
|
||||||
|
|
||||||
If slave support VIRTIO_RPMSG_F_BUFSZ(0x04) feature, master
|
If slave support VIRTIO_RPMSG_F_BUFSZ(0x04) feature, master
|
||||||
determine the buffer size from config space(first 8 bytes),
|
determine the buffer size from config space(first 8 bytes),
|
||||||
otherwise the default size(512 bytes) will be used.
|
otherwise the default size(512 bytes) will be used.
|
||||||
|
|
||||||
Signed-off-by: anchao <anchao@pinecone.net>
|
Signed-off-by: Chao An <anchao@pinecone.net>
|
||||||
---
|
---
|
||||||
lib/include/openamp/remoteproc.h | 17 +++++++++++++++++
|
lib/include/openamp/remoteproc.h | 17 +++++++++++++++++
|
||||||
lib/include/openamp/rpmsg_virtio.h | 4 ++++
|
lib/include/openamp/rpmsg_virtio.h | 4 ++++
|
||||||
lib/rpmsg/rpmsg_virtio.c | 22 ++++++++++++++++------
|
lib/rpmsg/rpmsg_virtio.c | 21 +++++++++++++++------
|
||||||
3 files changed, 37 insertions(+), 6 deletions(-)
|
3 files changed, 36 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
diff --git a/lib/include/openamp/remoteproc.h open-amp/lib/include/openamp/remoteproc.h
|
diff --git a/lib/include/openamp/remoteproc.h open-amp/lib/include/openamp/remoteproc.h
|
||||||
index b34cb1a..ee9162a 100644
|
index f558846..a71327b 100644
|
||||||
--- a/lib/include/openamp/remoteproc.h
|
--- a/lib/include/openamp/remoteproc.h
|
||||||
+++ open-amp/lib/include/openamp/remoteproc.h
|
+++ open-amp/lib/include/openamp/remoteproc.h
|
||||||
@@ -303,6 +303,23 @@ struct fw_rsc_vdev {
|
@@ -303,6 +303,23 @@ struct fw_rsc_vdev {
|
||||||
@@ -43,7 +43,7 @@ index b34cb1a..ee9162a 100644
|
|||||||
* struct fw_rsc_vendor - remote processor vendor specific resource
|
* struct fw_rsc_vendor - remote processor vendor specific resource
|
||||||
* @len: length of the resource
|
* @len: length of the resource
|
||||||
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||||
index 4d3093b..7f0c573 100644
|
index 4d3093b..e552b96 100644
|
||||||
--- a/lib/include/openamp/rpmsg_virtio.h
|
--- a/lib/include/openamp/rpmsg_virtio.h
|
||||||
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||||
@@ -16,6 +16,7 @@
|
@@ -16,6 +16,7 @@
|
||||||
@@ -58,7 +58,7 @@ index 4d3093b..7f0c573 100644
|
|||||||
/* The feature bitmap for virtio rpmsg */
|
/* The feature bitmap for virtio rpmsg */
|
||||||
#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
|
#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
|
||||||
#define VIRTIO_RPMSG_F_ACK 1 /* RP supports name service acknowledge */
|
#define VIRTIO_RPMSG_F_ACK 1 /* RP supports name service acknowledge */
|
||||||
+#define VIRTIO_RPMSG_F_BUFSZ 2 /* RP supports get buffer size from config space */
|
+#define VIRTIO_RPMSG_F_BUFSZ 2 /* RP supports buffer size negotiation */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct rpmsg_virtio_shm_pool - shared memory pool used for rpmsg buffers
|
* struct rpmsg_virtio_shm_pool - shared memory pool used for rpmsg buffers
|
||||||
@@ -79,21 +79,21 @@ index 4d3093b..7f0c573 100644
|
|||||||
struct virtqueue *rvq;
|
struct virtqueue *rvq;
|
||||||
struct virtqueue *svq;
|
struct virtqueue *svq;
|
||||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||||
index 9988a1e..d127084 100644
|
index 640240a..164dc70 100644
|
||||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||||
@@ -138,8 +138,8 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev,
|
@@ -145,8 +145,8 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev,
|
||||||
data = virtqueue_get_buffer(rvdev->svq, len, idx);
|
data = virtqueue_get_buffer(rvdev->svq, len, idx);
|
||||||
if (!data) {
|
if (!data && rvdev->svq->vq_free_cnt) {
|
||||||
data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool,
|
data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool,
|
||||||
- RPMSG_BUFFER_SIZE);
|
- RPMSG_BUFFER_SIZE);
|
||||||
- *len = RPMSG_BUFFER_SIZE;
|
- *len = RPMSG_BUFFER_SIZE;
|
||||||
+ rvdev->config.rxbuf_size);
|
+ rvdev->config.rxbuf_size);
|
||||||
+ *len = rvdev->config.rxbuf_size;
|
+ *len = rvdev->config.rxbuf_size;
|
||||||
*idx = 0;
|
*idx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ static int _rpmsg_virtio_get_buffer_size(struct rpmsg_virtio_device *rvdev)
|
@@ -239,7 +239,7 @@ static int _rpmsg_virtio_get_buffer_size(struct rpmsg_virtio_device *rvdev)
|
||||||
* If device role is Master then buffers are provided by us,
|
* If device role is Master then buffers are provided by us,
|
||||||
* so just provide the macro.
|
* so just provide the macro.
|
||||||
*/
|
*/
|
||||||
@@ -102,22 +102,16 @@ index 9988a1e..d127084 100644
|
|||||||
}
|
}
|
||||||
#endif /*!VIRTIO_SLAVE_ONLY*/
|
#endif /*!VIRTIO_SLAVE_ONLY*/
|
||||||
|
|
||||||
@@ -649,11 +649,14 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
@@ -619,6 +619,8 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
||||||
rvdev->vdev = vdev;
|
rvdev->vdev = vdev;
|
||||||
rdev->ns_bind_cb = ns_bind_cb;
|
rdev->ns_bind_cb = ns_bind_cb;
|
||||||
vdev->priv = rvdev;
|
vdev->priv = rvdev;
|
||||||
+ rvdev->config.txbuf_size = RPMSG_BUFFER_SIZE;
|
+ rvdev->config.txbuf_size = RPMSG_BUFFER_SIZE;
|
||||||
+ rvdev->config.rxbuf_size = RPMSG_BUFFER_SIZE;
|
+ rvdev->config.rxbuf_size = RPMSG_BUFFER_SIZE;
|
||||||
|
rdev->ops.send_offchannel_raw = rpmsg_virtio_send_offchannel_raw;
|
||||||
rdev->ops.hold_rx_buffer = rpmsg_virtio_hold_rx_buffer;
|
rdev->ops.hold_rx_buffer = rpmsg_virtio_hold_rx_buffer;
|
||||||
rdev->ops.release_rx_buffer = rpmsg_virtio_release_rx_buffer;
|
rdev->ops.release_rx_buffer = rpmsg_virtio_release_rx_buffer;
|
||||||
rdev->ops.get_tx_payload_buffer = rpmsg_virtio_get_tx_payload_buffer;
|
@@ -636,6 +638,13 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
||||||
rdev->ops.send_offchannel_nocopy = rpmsg_virtio_send_offchannel_nocopy;
|
|
||||||
rdev->ops.send_offchannel_raw = rpmsg_virtio_send_offchannel_raw;
|
|
||||||
+
|
|
||||||
role = rpmsg_virtio_get_role(rvdev);
|
|
||||||
|
|
||||||
#ifndef VIRTIO_MASTER_ONLY
|
|
||||||
@@ -666,6 +669,13 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
|
||||||
rdev->support_ns = !!(vdev->features & (1 << VIRTIO_RPMSG_F_NS));
|
rdev->support_ns = !!(vdev->features & (1 << VIRTIO_RPMSG_F_NS));
|
||||||
rdev->support_ack = !!(vdev->features & (1 << VIRTIO_RPMSG_F_ACK));
|
rdev->support_ack = !!(vdev->features & (1 << VIRTIO_RPMSG_F_ACK));
|
||||||
|
|
||||||
@@ -131,7 +125,7 @@ index 9988a1e..d127084 100644
|
|||||||
#ifndef VIRTIO_SLAVE_ONLY
|
#ifndef VIRTIO_SLAVE_ONLY
|
||||||
if (role == RPMSG_MASTER) {
|
if (role == RPMSG_MASTER) {
|
||||||
/*
|
/*
|
||||||
@@ -726,11 +736,11 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
@@ -696,11 +705,11 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
void *buffer;
|
void *buffer;
|
||||||
|
|
||||||
@@ -145,7 +139,7 @@ index 9988a1e..d127084 100644
|
|||||||
|
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
return RPMSG_ERR_NO_BUFF;
|
return RPMSG_ERR_NO_BUFF;
|
||||||
@@ -741,7 +751,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
@@ -711,7 +720,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
||||||
metal_io_block_set(shm_io,
|
metal_io_block_set(shm_io,
|
||||||
metal_io_virt_to_offset(shm_io,
|
metal_io_virt_to_offset(shm_io,
|
||||||
buffer),
|
buffer),
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
From d58fa6ab189fded40786e7d025036a1c16c773c4 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
Date: Fri, 24 Apr 2020 03:40:56 +0800
|
|
||||||
Subject: [PATCH 02/10] rpmsg: merge rpmsg_register_endpoint into
|
|
||||||
rpmsg_init_ept
|
|
||||||
|
|
||||||
so the service which use preserved address could call rpmsg_init_ept
|
|
||||||
|
|
||||||
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
---
|
|
||||||
lib/include/openamp/rpmsg.h | 19 +++++++------------
|
|
||||||
lib/rpmsg/rpmsg.c | 17 +++++++++++++----
|
|
||||||
lib/rpmsg/rpmsg_internal.h | 2 --
|
|
||||||
lib/rpmsg/rpmsg_virtio.c | 3 +--
|
|
||||||
4 files changed, 21 insertions(+), 20 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
|
||||||
index 8401c38..a08f9d3 100644
|
|
||||||
--- a/lib/include/openamp/rpmsg.h
|
|
||||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
|
||||||
@@ -271,6 +271,7 @@ static inline int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept,
|
|
||||||
* remoteproc address, endpoint callback, and destroy endpoint callback.
|
|
||||||
*
|
|
||||||
* @ept: pointer to rpmsg endpoint
|
|
||||||
+ * @rdev: pointer to the rpmsg device
|
|
||||||
* @name: service name associated to the endpoint
|
|
||||||
* @src: local address of the endpoint
|
|
||||||
* @dest: target address of the endpoint
|
|
||||||
@@ -278,18 +279,12 @@ static inline int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept,
|
|
||||||
* @ns_unbind_cb: end point service unbind callback, called when remote ept is
|
|
||||||
* destroyed.
|
|
||||||
*/
|
|
||||||
-static inline void rpmsg_init_ept(struct rpmsg_endpoint *ept,
|
|
||||||
- const char *name,
|
|
||||||
- uint32_t src, uint32_t dest,
|
|
||||||
- rpmsg_ept_cb cb,
|
|
||||||
- rpmsg_ns_unbind_cb ns_unbind_cb)
|
|
||||||
-{
|
|
||||||
- strncpy(ept->name, name ? name : "", sizeof(ept->name));
|
|
||||||
- ept->addr = src;
|
|
||||||
- ept->dest_addr = dest;
|
|
||||||
- ept->cb = cb;
|
|
||||||
- ept->ns_unbind_cb = ns_unbind_cb;
|
|
||||||
-}
|
|
||||||
+void rpmsg_init_ept(struct rpmsg_endpoint *ept,
|
|
||||||
+ struct rpmsg_device *rdev,
|
|
||||||
+ const char *name,
|
|
||||||
+ uint32_t src, uint32_t dest,
|
|
||||||
+ rpmsg_ept_cb cb,
|
|
||||||
+ rpmsg_ns_unbind_cb ns_unbind_cb);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* rpmsg_create_ept - create rpmsg endpoint and register it to rpmsg device
|
|
||||||
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
|
|
||||||
index 5b9c735..eee1c28 100644
|
|
||||||
--- a/lib/rpmsg/rpmsg.c
|
|
||||||
+++ open-amp/lib/rpmsg/rpmsg.c
|
|
||||||
@@ -182,6 +182,7 @@ static void rpmsg_unregister_endpoint(struct rpmsg_endpoint *ept)
|
|
||||||
return;
|
|
||||||
|
|
||||||
rdev = ept->rdev;
|
|
||||||
+ ept->rdev = NULL;
|
|
||||||
|
|
||||||
if (ept->addr != RPMSG_ADDR_ANY)
|
|
||||||
rpmsg_release_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE,
|
|
||||||
@@ -189,9 +190,18 @@ static void rpmsg_unregister_endpoint(struct rpmsg_endpoint *ept)
|
|
||||||
metal_list_del(&ept->node);
|
|
||||||
}
|
|
||||||
|
|
||||||
-void rpmsg_register_endpoint(struct rpmsg_device *rdev,
|
|
||||||
- struct rpmsg_endpoint *ept)
|
|
||||||
+void rpmsg_init_ept(struct rpmsg_endpoint *ept,
|
|
||||||
+ struct rpmsg_device *rdev,
|
|
||||||
+ const char *name,
|
|
||||||
+ uint32_t src, uint32_t dest,
|
|
||||||
+ rpmsg_ept_cb cb,
|
|
||||||
+ rpmsg_ns_unbind_cb ns_unbind_cb)
|
|
||||||
{
|
|
||||||
+ strncpy(ept->name, name ? name : "", sizeof(ept->name));
|
|
||||||
+ ept->addr = src;
|
|
||||||
+ ept->dest_addr = dest;
|
|
||||||
+ ept->cb = cb;
|
|
||||||
+ ept->ns_unbind_cb = ns_unbind_cb;
|
|
||||||
ept->rdev = rdev;
|
|
||||||
metal_list_add_tail(&rdev->endpoints, &ept->node);
|
|
||||||
}
|
|
||||||
@@ -224,8 +234,7 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
|
||||||
addr = rpmsg_get_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
- rpmsg_init_ept(ept, name, addr, dest, cb, unbind_cb);
|
|
||||||
- rpmsg_register_endpoint(rdev, ept);
|
|
||||||
+ rpmsg_init_ept(ept, rdev, name, addr, dest, cb, unbind_cb);
|
|
||||||
|
|
||||||
if (rdev->support_ns && ept->dest_addr == RPMSG_ADDR_ANY) {
|
|
||||||
/* Send NS announcement to remote processor */
|
|
||||||
diff --git a/lib/rpmsg/rpmsg_internal.h open-amp/lib/rpmsg/rpmsg_internal.h
|
|
||||||
index f63c958..9c46970 100644
|
|
||||||
--- a/lib/rpmsg/rpmsg_internal.h
|
|
||||||
+++ open-amp/lib/rpmsg/rpmsg_internal.h
|
|
||||||
@@ -92,8 +92,6 @@ int rpmsg_send_ns_message(struct rpmsg_endpoint *ept, unsigned long flags);
|
|
||||||
struct rpmsg_endpoint *rpmsg_get_endpoint(struct rpmsg_device *rvdev,
|
|
||||||
const char *name, uint32_t addr,
|
|
||||||
uint32_t dest_addr);
|
|
||||||
-void rpmsg_register_endpoint(struct rpmsg_device *rdev,
|
|
||||||
- struct rpmsg_endpoint *ept);
|
|
||||||
|
|
||||||
static inline struct rpmsg_endpoint *
|
|
||||||
rpmsg_get_ept_from_addr(struct rpmsg_device *rdev, uint32_t addr)
|
|
||||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
|
||||||
index 8165216..4dea4c0 100644
|
|
||||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
|
||||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
|
||||||
@@ -636,10 +636,9 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
|
||||||
* service announcement feature.
|
|
||||||
*/
|
|
||||||
if (rdev->support_ns) {
|
|
||||||
- rpmsg_init_ept(&rdev->ns_ept, "NS",
|
|
||||||
+ rpmsg_init_ept(&rdev->ns_ept, rdev, "NS",
|
|
||||||
RPMSG_NS_EPT_ADDR, RPMSG_NS_EPT_ADDR,
|
|
||||||
rpmsg_virtio_ns_callback, NULL);
|
|
||||||
- rpmsg_register_endpoint(rdev, &rdev->ns_ept);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef VIRTIO_SLAVE_ONLY
|
|
||||||
--
|
|
||||||
2.17.1
|
|
||||||
|
|
||||||
@@ -1,227 +0,0 @@
|
|||||||
From ca34df45f5d4893be223346b06cc75f370452386 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
Date: Fri, 24 Apr 2020 01:33:12 +0800
|
|
||||||
Subject: [PATCH 03/10] rpmsg: shouldn't allocate 0-1023 address in
|
|
||||||
rpmsg_create_ept
|
|
||||||
|
|
||||||
since this region is reserved for predefined services(e.g. NS use 0x35)
|
|
||||||
|
|
||||||
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
---
|
|
||||||
apps/examples/echo/rpmsg-echo.c | 2 +-
|
|
||||||
apps/examples/echo/rpmsg-ping.c | 2 +-
|
|
||||||
.../matrix_multiply/matrix_multiply.c | 2 +-
|
|
||||||
.../matrix_multiply/matrix_multiplyd.c | 2 +-
|
|
||||||
apps/examples/rpc_demo/rpc_demod.c | 2 +-
|
|
||||||
.../rpmsg_sample_echo/rpmsg-sample-ping.c | 2 +-
|
|
||||||
apps/tests/msg/rpmsg-flood-ping.c | 2 +-
|
|
||||||
apps/tests/msg/rpmsg-ping.c | 2 +-
|
|
||||||
apps/tests/msg/rpmsg-update.c | 2 +-
|
|
||||||
lib/include/openamp/rpmsg.h | 27 ++++++++++---------
|
|
||||||
lib/rpmsg/rpmsg.c | 11 +++++---
|
|
||||||
11 files changed, 30 insertions(+), 26 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/apps/examples/echo/rpmsg-echo.c open-amp/apps/examples/echo/rpmsg-echo.c
|
|
||||||
index 0c75203..71a0bbf 100644
|
|
||||||
--- a/apps/examples/echo/rpmsg-echo.c
|
|
||||||
+++ open-amp/apps/examples/echo/rpmsg-echo.c
|
|
||||||
@@ -58,7 +58,7 @@ int app(struct rpmsg_device *rdev, void *priv)
|
|
||||||
LPRINTF("Try to create rpmsg endpoint.\r\n");
|
|
||||||
|
|
||||||
ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME,
|
|
||||||
- 0, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
|
||||||
+ 1024, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
|
||||||
rpmsg_service_unbind);
|
|
||||||
if (ret) {
|
|
||||||
LPERROR("Failed to create endpoint.\r\n");
|
|
||||||
diff --git a/apps/examples/echo/rpmsg-ping.c open-amp/apps/examples/echo/rpmsg-ping.c
|
|
||||||
index 3b716b0..ff639cd 100644
|
|
||||||
--- a/apps/examples/echo/rpmsg-ping.c
|
|
||||||
+++ open-amp/apps/examples/echo/rpmsg-ping.c
|
|
||||||
@@ -11,7 +11,7 @@ This application echoes back data that was sent to it by the master core. */
|
|
||||||
#include "platform_info.h"
|
|
||||||
#include "rpmsg-echo.h"
|
|
||||||
|
|
||||||
-#define APP_EPT_ADDR 0
|
|
||||||
+#define APP_EPT_ADDR 1024
|
|
||||||
#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__)
|
|
||||||
#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
diff --git a/apps/examples/matrix_multiply/matrix_multiply.c open-amp/apps/examples/matrix_multiply/matrix_multiply.c
|
|
||||||
index b9da29b..3928088 100644
|
|
||||||
--- a/apps/examples/matrix_multiply/matrix_multiply.c
|
|
||||||
+++ open-amp/apps/examples/matrix_multiply/matrix_multiply.c
|
|
||||||
@@ -14,7 +14,7 @@ multiplies them and returns the result to the master core. */
|
|
||||||
|
|
||||||
#define MAX_SIZE 6
|
|
||||||
#define NUM_MATRIX 2
|
|
||||||
-#define APP_EPT_ADDR 0
|
|
||||||
+#define APP_EPT_ADDR 1024
|
|
||||||
|
|
||||||
#define raw_printf(format, ...) printf(format, ##__VA_ARGS__)
|
|
||||||
#define LPRINTF(format, ...) raw_printf("CLIENT> " format, ##__VA_ARGS__)
|
|
||||||
diff --git a/apps/examples/matrix_multiply/matrix_multiplyd.c open-amp/apps/examples/matrix_multiply/matrix_multiplyd.c
|
|
||||||
index 6b4a118..29c6380 100644
|
|
||||||
--- a/apps/examples/matrix_multiply/matrix_multiplyd.c
|
|
||||||
+++ open-amp/apps/examples/matrix_multiply/matrix_multiplyd.c
|
|
||||||
@@ -92,7 +92,7 @@ int app(struct rpmsg_device *rdev, void *priv)
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME,
|
|
||||||
- 0, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
|
||||||
+ 1024, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
|
||||||
rpmsg_service_unbind);
|
|
||||||
if (ret) {
|
|
||||||
LPERROR("Failed to create endpoint.\r\n");
|
|
||||||
diff --git a/apps/examples/rpc_demo/rpc_demod.c open-amp/apps/examples/rpc_demo/rpc_demod.c
|
|
||||||
index 44c92a2..a4659f3 100644
|
|
||||||
--- a/apps/examples/rpc_demo/rpc_demod.c
|
|
||||||
+++ open-amp/apps/examples/rpc_demo/rpc_demod.c
|
|
||||||
@@ -312,7 +312,7 @@ int app(struct rpmsg_device *rdev, void *priv)
|
|
||||||
LPRINTF("Try to create rpmsg endpoint.\r\n");
|
|
||||||
|
|
||||||
ret = rpmsg_create_ept(&app_ept, rdev, RPMSG_SERVICE_NAME,
|
|
||||||
- 0, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
|
||||||
+ 1024, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
|
||||||
rpmsg_service_unbind);
|
|
||||||
if (ret) {
|
|
||||||
LPERROR("Failed to create endpoint.\r\n");
|
|
||||||
diff --git a/apps/examples/rpmsg_sample_echo/rpmsg-sample-ping.c open-amp/apps/examples/rpmsg_sample_echo/rpmsg-sample-ping.c
|
|
||||||
index ee866b4..14456e3 100644
|
|
||||||
--- a/apps/examples/rpmsg_sample_echo/rpmsg-sample-ping.c
|
|
||||||
+++ open-amp/apps/examples/rpmsg_sample_echo/rpmsg-sample-ping.c
|
|
||||||
@@ -20,7 +20,7 @@
|
|
||||||
#define BYE_MSG "goodbye!"
|
|
||||||
#define MSG_LIMIT 100
|
|
||||||
|
|
||||||
-#define APP_EPT_ADDR 0
|
|
||||||
+#define APP_EPT_ADDR 1024
|
|
||||||
#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__)
|
|
||||||
#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
diff --git a/apps/tests/msg/rpmsg-flood-ping.c open-amp/apps/tests/msg/rpmsg-flood-ping.c
|
|
||||||
index 66489f8..28edc66 100644
|
|
||||||
--- a/apps/tests/msg/rpmsg-flood-ping.c
|
|
||||||
+++ open-amp/apps/tests/msg/rpmsg-flood-ping.c
|
|
||||||
@@ -12,7 +12,7 @@
|
|
||||||
#include "platform_info.h"
|
|
||||||
#include "rpmsg-ping.h"
|
|
||||||
|
|
||||||
-#define APP_EPT_ADDR 0
|
|
||||||
+#define APP_EPT_ADDR 1024
|
|
||||||
#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__)
|
|
||||||
#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
diff --git a/apps/tests/msg/rpmsg-ping.c open-amp/apps/tests/msg/rpmsg-ping.c
|
|
||||||
index 0220a27..752b16c 100644
|
|
||||||
--- a/apps/tests/msg/rpmsg-ping.c
|
|
||||||
+++ open-amp/apps/tests/msg/rpmsg-ping.c
|
|
||||||
@@ -11,7 +11,7 @@ This application echoes back data that was sent to it by the master core. */
|
|
||||||
#include "platform_info.h"
|
|
||||||
#include "rpmsg-ping.h"
|
|
||||||
|
|
||||||
-#define APP_EPT_ADDR 0
|
|
||||||
+#define APP_EPT_ADDR 1024
|
|
||||||
#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__)
|
|
||||||
#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
diff --git a/apps/tests/msg/rpmsg-update.c open-amp/apps/tests/msg/rpmsg-update.c
|
|
||||||
index 9b26cac..b8e08db 100644
|
|
||||||
--- a/apps/tests/msg/rpmsg-update.c
|
|
||||||
+++ open-amp/apps/tests/msg/rpmsg-update.c
|
|
||||||
@@ -73,7 +73,7 @@ int app(struct rpmsg_device *rdev, void *priv)
|
|
||||||
LPRINTF("Try to create rpmsg endpoint.\r\n");
|
|
||||||
|
|
||||||
ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME,
|
|
||||||
- 0, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
|
||||||
+ 1024, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
|
||||||
rpmsg_service_unbind);
|
|
||||||
if (ret) {
|
|
||||||
LPERROR("Failed to create endpoint.\r\n");
|
|
||||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
|
||||||
index a08f9d3..3403240 100644
|
|
||||||
--- a/lib/include/openamp/rpmsg.h
|
|
||||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
|
||||||
@@ -25,22 +25,23 @@ extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Configurable parameters */
|
|
||||||
-#define RPMSG_NAME_SIZE (32)
|
|
||||||
-#define RPMSG_ADDR_BMP_SIZE (128)
|
|
||||||
+#define RPMSG_NAME_SIZE (32)
|
|
||||||
+#define RPMSG_ADDR_BMP_SIZE (128)
|
|
||||||
|
|
||||||
-#define RPMSG_NS_EPT_ADDR (0x35)
|
|
||||||
-#define RPMSG_ADDR_ANY 0xFFFFFFFF
|
|
||||||
+#define RPMSG_NS_EPT_ADDR (0x35)
|
|
||||||
+#define RPMSG_RESERVED_ADDRESSES (1024)
|
|
||||||
+#define RPMSG_ADDR_ANY 0xFFFFFFFF
|
|
||||||
|
|
||||||
/* Error macros. */
|
|
||||||
-#define RPMSG_SUCCESS 0
|
|
||||||
-#define RPMSG_ERROR_BASE -2000
|
|
||||||
-#define RPMSG_ERR_NO_MEM (RPMSG_ERROR_BASE - 1)
|
|
||||||
-#define RPMSG_ERR_NO_BUFF (RPMSG_ERROR_BASE - 2)
|
|
||||||
-#define RPMSG_ERR_PARAM (RPMSG_ERROR_BASE - 3)
|
|
||||||
-#define RPMSG_ERR_DEV_STATE (RPMSG_ERROR_BASE - 4)
|
|
||||||
-#define RPMSG_ERR_BUFF_SIZE (RPMSG_ERROR_BASE - 5)
|
|
||||||
-#define RPMSG_ERR_INIT (RPMSG_ERROR_BASE - 6)
|
|
||||||
-#define RPMSG_ERR_ADDR (RPMSG_ERROR_BASE - 7)
|
|
||||||
+#define RPMSG_SUCCESS 0
|
|
||||||
+#define RPMSG_ERROR_BASE -2000
|
|
||||||
+#define RPMSG_ERR_NO_MEM (RPMSG_ERROR_BASE - 1)
|
|
||||||
+#define RPMSG_ERR_NO_BUFF (RPMSG_ERROR_BASE - 2)
|
|
||||||
+#define RPMSG_ERR_PARAM (RPMSG_ERROR_BASE - 3)
|
|
||||||
+#define RPMSG_ERR_DEV_STATE (RPMSG_ERROR_BASE - 4)
|
|
||||||
+#define RPMSG_ERR_BUFF_SIZE (RPMSG_ERROR_BASE - 5)
|
|
||||||
+#define RPMSG_ERR_INIT (RPMSG_ERROR_BASE - 6)
|
|
||||||
+#define RPMSG_ERR_ADDR (RPMSG_ERROR_BASE - 7)
|
|
||||||
|
|
||||||
struct rpmsg_endpoint;
|
|
||||||
struct rpmsg_device;
|
|
||||||
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
|
|
||||||
index eee1c28..dcc39c1 100644
|
|
||||||
--- a/lib/rpmsg/rpmsg.c
|
|
||||||
+++ open-amp/lib/rpmsg/rpmsg.c
|
|
||||||
@@ -29,7 +29,7 @@ static uint32_t rpmsg_get_address(unsigned long *bitmap, int size)
|
|
||||||
|
|
||||||
nextbit = metal_bitmap_next_clear_bit(bitmap, 0, size);
|
|
||||||
if (nextbit < (uint32_t)size) {
|
|
||||||
- addr = nextbit;
|
|
||||||
+ addr = RPMSG_RESERVED_ADDRESSES + nextbit;
|
|
||||||
metal_bitmap_set_bit(bitmap, nextbit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -48,7 +48,8 @@ static uint32_t rpmsg_get_address(unsigned long *bitmap, int size)
|
|
||||||
static void rpmsg_release_address(unsigned long *bitmap, int size,
|
|
||||||
int addr)
|
|
||||||
{
|
|
||||||
- if (addr < size)
|
|
||||||
+ addr -= RPMSG_RESERVED_ADDRESSES;
|
|
||||||
+ if (addr >= 0 && addr < size)
|
|
||||||
metal_bitmap_clear_bit(bitmap, addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -65,7 +66,8 @@ static void rpmsg_release_address(unsigned long *bitmap, int size,
|
|
||||||
*/
|
|
||||||
static int rpmsg_is_address_set(unsigned long *bitmap, int size, int addr)
|
|
||||||
{
|
|
||||||
- if (addr < size)
|
|
||||||
+ addr -= RPMSG_RESERVED_ADDRESSES;
|
|
||||||
+ if (addr >= 0 && addr < size)
|
|
||||||
return metal_bitmap_is_bit_set(bitmap, addr);
|
|
||||||
else
|
|
||||||
return RPMSG_ERR_PARAM;
|
|
||||||
@@ -84,7 +86,8 @@ static int rpmsg_is_address_set(unsigned long *bitmap, int size, int addr)
|
|
||||||
*/
|
|
||||||
static int rpmsg_set_address(unsigned long *bitmap, int size, int addr)
|
|
||||||
{
|
|
||||||
- if (addr < size) {
|
|
||||||
+ addr -= RPMSG_RESERVED_ADDRESSES;
|
|
||||||
+ if (addr >= 0 && addr < size) {
|
|
||||||
metal_bitmap_set_bit(bitmap, addr);
|
|
||||||
return RPMSG_SUCCESS;
|
|
||||||
} else {
|
|
||||||
--
|
|
||||||
2.17.1
|
|
||||||
|
|
||||||
+37
-18
@@ -1,18 +1,19 @@
|
|||||||
From 8a55f0f3c2fec8c817ad579b070040ee8058c536 Mon Sep 17 00:00:00 2001
|
From b84c7f48996a9bbacdddcef9929405f674a73a81 Mon Sep 17 00:00:00 2001
|
||||||
From: ligd <liguiding@pinecone.net>
|
From: Guiding Li <liguiding@pinecone.net>
|
||||||
Date: Wed, 20 Feb 2019 11:36:57 +0800
|
Date: Wed, 20 Feb 2019 11:36:57 +0800
|
||||||
Subject: [PATCH 04/10] rpmsg: wait ept ready in rpmsg_send
|
Subject: [PATCH 3/3] rpmsg: wait endpoint ready in rpmsg_send and
|
||||||
|
rpmsg_send_nocopy
|
||||||
|
|
||||||
since the destination address need time to return from peer
|
because the remote need time to return the destination address
|
||||||
|
|
||||||
Signed-off-by: ligd <liguiding@pinecone.net>
|
Signed-off-by: Guiding Li <liguiding@pinecone.net>
|
||||||
---
|
---
|
||||||
lib/include/openamp/rpmsg.h | 48 ++++++++++++++++++++++++-------------
|
lib/include/openamp/rpmsg.h | 59 ++++++++++++++++++++++++++-----------
|
||||||
lib/rpmsg/rpmsg_virtio.c | 7 ------
|
lib/rpmsg/rpmsg_virtio.c | 7 -----
|
||||||
2 files changed, 32 insertions(+), 23 deletions(-)
|
2 files changed, 42 insertions(+), 24 deletions(-)
|
||||||
|
|
||||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
||||||
index 3403240..7000453 100644
|
index efdfb2b..5c8b45c 100644
|
||||||
--- a/lib/include/openamp/rpmsg.h
|
--- a/lib/include/openamp/rpmsg.h
|
||||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
+++ open-amp/lib/include/openamp/rpmsg.h
|
||||||
@@ -15,6 +15,7 @@
|
@@ -15,6 +15,7 @@
|
||||||
@@ -36,8 +37,8 @@ index 3403240..7000453 100644
|
|||||||
/* Error macros. */
|
/* Error macros. */
|
||||||
#define RPMSG_SUCCESS 0
|
#define RPMSG_SUCCESS 0
|
||||||
#define RPMSG_ERROR_BASE -2000
|
#define RPMSG_ERROR_BASE -2000
|
||||||
@@ -129,6 +136,20 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
@@ -141,6 +148,19 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
||||||
uint32_t dst, const void *data, int size,
|
uint32_t dst, const void *data, int len,
|
||||||
int wait);
|
int wait);
|
||||||
|
|
||||||
+/**
|
+/**
|
||||||
@@ -50,14 +51,13 @@ index 3403240..7000453 100644
|
|||||||
+ */
|
+ */
|
||||||
+static inline unsigned int is_rpmsg_ept_ready(struct rpmsg_endpoint *ept)
|
+static inline unsigned int is_rpmsg_ept_ready(struct rpmsg_endpoint *ept)
|
||||||
+{
|
+{
|
||||||
+ return (ept->dest_addr != RPMSG_ADDR_ANY) &&
|
+ return ept && ept->rdev && ept->dest_addr != RPMSG_ADDR_ANY;
|
||||||
+ (ept->addr != RPMSG_ADDR_ANY);
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
/**
|
/**
|
||||||
* rpmsg_send() - send a message across to the remote processor
|
* rpmsg_send() - send a message across to the remote processor
|
||||||
* @ept: the rpmsg endpoint
|
* @ept: the rpmsg endpoint
|
||||||
@@ -147,8 +168,17 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
@@ -159,8 +179,17 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
||||||
static inline int rpmsg_send(struct rpmsg_endpoint *ept, const void *data,
|
static inline int rpmsg_send(struct rpmsg_endpoint *ept, const void *data,
|
||||||
int len)
|
int len)
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,27 @@ index 3403240..7000453 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -328,20 +358,6 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
@@ -433,8 +462,17 @@ static inline int rpmsg_sendto_nocopy(struct rpmsg_endpoint *ept,
|
||||||
|
static inline int rpmsg_send_nocopy(struct rpmsg_endpoint *ept,
|
||||||
|
const void *data, int len)
|
||||||
|
{
|
||||||
|
- return rpmsg_send_offchannel_nocopy(ept, ept->addr,
|
||||||
|
- ept->dest_addr, data, len);
|
||||||
|
+ int tc = 0;
|
||||||
|
+
|
||||||
|
+ for (; tc < RPMSG_TICK_COUNT; tc += RPMSG_TICKS_PER_INTERVAL) {
|
||||||
|
+ if (is_rpmsg_ept_ready(ept))
|
||||||
|
+ return rpmsg_send_offchannel_nocopy(ept, ept->addr,
|
||||||
|
+ ept->dest_addr,
|
||||||
|
+ data, len);
|
||||||
|
+ metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return RPMSG_ERR_ADDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@@ -507,19 +545,6 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
||||||
*/
|
*/
|
||||||
void rpmsg_destroy_ept(struct rpmsg_endpoint *ept);
|
void rpmsg_destroy_ept(struct rpmsg_endpoint *ept);
|
||||||
|
|
||||||
@@ -91,15 +111,14 @@ index 3403240..7000453 100644
|
|||||||
- */
|
- */
|
||||||
-static inline unsigned int is_rpmsg_ept_ready(struct rpmsg_endpoint *ept)
|
-static inline unsigned int is_rpmsg_ept_ready(struct rpmsg_endpoint *ept)
|
||||||
-{
|
-{
|
||||||
- return (ept->dest_addr != RPMSG_ADDR_ANY) &&
|
- return ept && ept->rdev && ept->dest_addr != RPMSG_ADDR_ANY;
|
||||||
- (ept->addr != RPMSG_ADDR_ANY);
|
|
||||||
-}
|
-}
|
||||||
-
|
-
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||||
index 4dea4c0..44b46d4 100644
|
index 164dc70..c357ba8 100644
|
||||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||||
@@ -8,7 +8,6 @@
|
@@ -8,7 +8,6 @@
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
From 3ea6f30819b25281ec80c68b3abd779981311a77 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
Date: Fri, 24 Apr 2020 02:22:15 +0800
|
|
||||||
Subject: [PATCH 05/10] rpmsg: return fail if either source or destination
|
|
||||||
address is zero
|
|
||||||
|
|
||||||
to help detect rpmsg_send is called before the endpoint
|
|
||||||
initialization or after the endpoint uninitialization
|
|
||||||
|
|
||||||
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
---
|
|
||||||
lib/include/openamp/rpmsg.h | 3 +--
|
|
||||||
lib/rpmsg/rpmsg.c | 2 +-
|
|
||||||
2 files changed, 2 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
|
||||||
index 7000453..1279ea2 100644
|
|
||||||
--- a/lib/include/openamp/rpmsg.h
|
|
||||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
|
||||||
@@ -146,8 +146,7 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
|
||||||
*/
|
|
||||||
static inline unsigned int is_rpmsg_ept_ready(struct rpmsg_endpoint *ept)
|
|
||||||
{
|
|
||||||
- return (ept->dest_addr != RPMSG_ADDR_ANY) &&
|
|
||||||
- (ept->addr != RPMSG_ADDR_ANY);
|
|
||||||
+ return ept && ept->rdev && ept->dest_addr && ept->dest_addr != RPMSG_ADDR_ANY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
|
|
||||||
index dcc39c1..9da38a1 100644
|
|
||||||
--- a/lib/rpmsg/rpmsg.c
|
|
||||||
+++ open-amp/lib/rpmsg/rpmsg.c
|
|
||||||
@@ -115,7 +115,7 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
|
||||||
{
|
|
||||||
struct rpmsg_device *rdev;
|
|
||||||
|
|
||||||
- if (!ept || !ept->rdev || !data || dst == RPMSG_ADDR_ANY)
|
|
||||||
+ if (!ept || !ept->rdev || !data || !dst || dst == RPMSG_ADDR_ANY)
|
|
||||||
return RPMSG_ERR_PARAM;
|
|
||||||
|
|
||||||
rdev = ept->rdev;
|
|
||||||
--
|
|
||||||
2.17.1
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,470 +0,0 @@
|
|||||||
From e2233e080ef0ad62682f1725e17abb07e939ed50 Mon Sep 17 00:00:00 2001
|
|
||||||
From: anchao <anchao@pinecone.net>
|
|
||||||
Date: Mon, 10 Dec 2018 19:39:01 +0800
|
|
||||||
Subject: [PATCH 07/10] rpmsg: bring back zero copy transfer
|
|
||||||
|
|
||||||
Commit-id:
|
|
||||||
b16ca55 Adding RPMsg Extension layer implementing zero-copy send and receive.
|
|
||||||
|
|
||||||
Signed-off-by: anchao <anchao@pinecone.net>
|
|
||||||
---
|
|
||||||
lib/include/openamp/rpmsg.h | 178 ++++++++++++++++++++++++++++++++++++
|
|
||||||
lib/rpmsg/rpmsg.c | 58 ++++++++++++
|
|
||||||
lib/rpmsg/rpmsg_internal.h | 3 +
|
|
||||||
lib/rpmsg/rpmsg_virtio.c | 130 +++++++++++++++++++++++++-
|
|
||||||
4 files changed, 367 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
|
||||||
index 1279ea2..0b46ee1 100644
|
|
||||||
--- a/lib/include/openamp/rpmsg.h
|
|
||||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
|
||||||
@@ -89,9 +89,20 @@ struct rpmsg_endpoint {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* struct rpmsg_device_ops - RPMsg device operations
|
|
||||||
+ * @hold_rx_buffer: hold RPMsg RX buffer
|
|
||||||
+ * @release_rx_buffer: release RPMsg RX buffer
|
|
||||||
+ * @get_tx_payload_buffer: get RPMsg TX buffer
|
|
||||||
+ * @send_offchannel_nocopy: send RPMsg data without copy
|
|
||||||
* @send_offchannel_raw: send RPMsg data
|
|
||||||
*/
|
|
||||||
struct rpmsg_device_ops {
|
|
||||||
+ void (*hold_rx_buffer)(struct rpmsg_device *rdev, void *rxbuf);
|
|
||||||
+ void (*release_rx_buffer)(struct rpmsg_device *rdev, void *rxbuf);
|
|
||||||
+ void *(*get_tx_payload_buffer)(struct rpmsg_device *rdev,
|
|
||||||
+ uint32_t *len, int wait);
|
|
||||||
+ int (*send_offchannel_nocopy)(struct rpmsg_device *rdev,
|
|
||||||
+ uint32_t src, uint32_t dst,
|
|
||||||
+ const void *data, int len);
|
|
||||||
int (*send_offchannel_raw)(struct rpmsg_device *rdev,
|
|
||||||
uint32_t src, uint32_t dst,
|
|
||||||
const void *data, int size, int wait);
|
|
||||||
@@ -294,6 +305,173 @@ static inline int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept,
|
|
||||||
return rpmsg_send_offchannel_raw(ept, src, dst, data, len, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * @brief Holds the rx buffer for usage outside the receive callback.
|
|
||||||
+ *
|
|
||||||
+ * Calling this function prevents the RPMsg receive buffer from being released
|
|
||||||
+ * back to the pool of shmem buffers. This API can only be called at rx
|
|
||||||
+ * callback context (rpmsg_rx_cb_t). With this API, the application doesn't
|
|
||||||
+ * need to copy the message in rx callback. Instead, the rx buffer base address
|
|
||||||
+ * is saved in application context and further processed in application
|
|
||||||
+ * process. After the message is processed, the application can release the rx
|
|
||||||
+ * buffer for future reuse in vring by calling the rpmsg_release_rx_buffer()
|
|
||||||
+ * function.
|
|
||||||
+ *
|
|
||||||
+ * @param: ept The rpmsg endpoint
|
|
||||||
+ * @param: rxbuf RX buffer with message payload
|
|
||||||
+ *
|
|
||||||
+ * @see rpmsg_release_rx_buffer
|
|
||||||
+ */
|
|
||||||
+void rpmsg_hold_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf);
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * @brief Releases the rx buffer for future reuse in vring.
|
|
||||||
+ *
|
|
||||||
+ * This API can be called at process context when the message in rx buffer is
|
|
||||||
+ * processed.
|
|
||||||
+ *
|
|
||||||
+ * @ept: the rpmsg endpoint
|
|
||||||
+ * @rxbuf: rx buffer with message payload
|
|
||||||
+ *
|
|
||||||
+ * @see rpmsg_hold_rx_buffer
|
|
||||||
+ */
|
|
||||||
+void rpmsg_release_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf);
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * @brief Gets the tx buffer for message payload.
|
|
||||||
+ *
|
|
||||||
+ * This API can only be called at process context to get the tx buffer in vring.
|
|
||||||
+ * By this way, the application can directly put its message into the vring tx
|
|
||||||
+ * buffer without copy from an application buffer.
|
|
||||||
+ * It is the application responsibility to correctly fill the allocated tx
|
|
||||||
+ * buffer by data and passing correct parameters to the rpmsg_send_nocopy() or
|
|
||||||
+ * rpmsg_sendto_nocopy() function to perform data no-copy-send mechanism.
|
|
||||||
+ *
|
|
||||||
+ * @ept: Pointer to rpmsg endpoint
|
|
||||||
+ * @len: Pointer to store tx buffer size
|
|
||||||
+ * @wait: Boolean, wait or not for buffer to become available
|
|
||||||
+ *
|
|
||||||
+ * @return The tx buffer address on success and NULL on failure
|
|
||||||
+ *
|
|
||||||
+ * @see rpmsg_send_offchannel_nocopy
|
|
||||||
+ * @see rpmsg_sendto_nocopy
|
|
||||||
+ * @see rpmsg_send_nocopy
|
|
||||||
+ */
|
|
||||||
+void *rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint *ept,
|
|
||||||
+ uint32_t *len, int wait);
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * rpmsg_send_offchannel_nocopy() - send a message in tx buffer reserved by
|
|
||||||
+ * rpmsg_get_tx_payload_buffer() across to the remote processor.
|
|
||||||
+ *
|
|
||||||
+ * This function sends buf of length len to the remote dst address,
|
|
||||||
+ * and uses src as the source address.
|
|
||||||
+ * The message will be sent to the remote processor which the ept
|
|
||||||
+ * endpoint belongs to.
|
|
||||||
+ * The application has to take the responsibility for:
|
|
||||||
+ * 1. tx buffer reserved (rpmsg_get_tx_payload_buffer() )
|
|
||||||
+ * 2. filling the data to be sent into the pre-allocated tx buffer
|
|
||||||
+ * 3. not exceeding the buffer size when filling the data
|
|
||||||
+ * 4. data cache coherency
|
|
||||||
+ *
|
|
||||||
+ * After the rpmsg_send_offchannel_nocopy() function is issued the tx buffer is
|
|
||||||
+ * no more owned by the sending task and must not be touched anymore unless the
|
|
||||||
+ * rpmsg_send_offchannel_nocopy() function fails and returns an error. In that
|
|
||||||
+ * case the application should try to re-issue the rpmsg_send_offchannel_nocopy()
|
|
||||||
+ * again.
|
|
||||||
+ *
|
|
||||||
+ * @ept: The rpmsg endpoint
|
|
||||||
+ * @src: The rpmsg endpoint local address
|
|
||||||
+ * @dst: The rpmsg endpoint remote address
|
|
||||||
+ * @data: TX buffer with message filled
|
|
||||||
+ * @len: Length of payload
|
|
||||||
+ *
|
|
||||||
+ * @return number of bytes it has sent or negative error value on failure.
|
|
||||||
+ *
|
|
||||||
+ * @see rpmsg_get_tx_payload_buffer
|
|
||||||
+ * @see rpmsg_sendto_nocopy
|
|
||||||
+ * @see rpmsg_send_nocopy
|
|
||||||
+ */
|
|
||||||
+int rpmsg_send_offchannel_nocopy(struct rpmsg_endpoint *ept, uint32_t src,
|
|
||||||
+ uint32_t dst, const void *data, int len);
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * @brief Sends a message in tx buffer allocated by rpmsg_get_tx_payload_buffer()
|
|
||||||
+ * across to the remote processor, specify dst.
|
|
||||||
+ *
|
|
||||||
+ * This function sends buf of length len to the remote dst address.
|
|
||||||
+ * The message will be sent to the remote processor which the ept
|
|
||||||
+ * endpoint belongs to, using ept's source address.
|
|
||||||
+ * The application has to take the responsibility for:
|
|
||||||
+ * 1. tx buffer allocation (rpmsg_get_tx_payload_buffer() )
|
|
||||||
+ * 2. filling the data to be sent into the pre-allocated tx buffer
|
|
||||||
+ * 3. not exceeding the buffer size when filling the data
|
|
||||||
+ * 4. data cache coherency
|
|
||||||
+ *
|
|
||||||
+ * After the rpmsg_sendto_nocopy() function is issued the tx buffer is no more
|
|
||||||
+ * owned by the sending task and must not be touched anymore unless the
|
|
||||||
+ * rpmsg_sendto_nocopy() function fails and returns an error. In that case the
|
|
||||||
+ * application should try to re-issue the rpmsg_sendto_nocopy() again.
|
|
||||||
+ *
|
|
||||||
+ * @ept: The rpmsg endpoint
|
|
||||||
+ * @data: TX buffer with message filled
|
|
||||||
+ * @len: Length of payload
|
|
||||||
+ * @dst: Destination address
|
|
||||||
+ *
|
|
||||||
+ * @return number of bytes it has sent or negative error value on failure.
|
|
||||||
+ *
|
|
||||||
+ * @see rpmsg_get_tx_payload_buffer
|
|
||||||
+ * @see rpmsg_send_offchannel_nocopy
|
|
||||||
+ * @see rpmsg_send_nocopy
|
|
||||||
+ */
|
|
||||||
+static inline int rpmsg_sendto_nocopy(struct rpmsg_endpoint *ept,
|
|
||||||
+ const void *data, int len, uint32_t dst)
|
|
||||||
+{
|
|
||||||
+ return rpmsg_send_offchannel_nocopy(ept, ept->addr, dst, data, len);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * rpmsg_send_nocopy() - send a message in tx buffer reserved by
|
|
||||||
+ * rpmsg_get_tx_payload_buffer() across to the remote processor.
|
|
||||||
+ *
|
|
||||||
+ * This function sends buf of length len on the ept endpoint.
|
|
||||||
+ * The message will be sent to the remote processor which the ept
|
|
||||||
+ * endpoint belongs to, using ept's source and destination addresses.
|
|
||||||
+ * The application has to take the responsibility for:
|
|
||||||
+ * 1. tx buffer reserved (rpmsg_get_tx_payload_buffer() )
|
|
||||||
+ * 2. filling the data to be sent into the pre-allocated tx buffer
|
|
||||||
+ * 3. not exceeding the buffer size when filling the data
|
|
||||||
+ * 4. data cache coherency
|
|
||||||
+ *
|
|
||||||
+ * After the rpmsg_send_nocopy() function is issued the tx buffer is no more
|
|
||||||
+ * owned by the sending task and must not be touched anymore unless the
|
|
||||||
+ * rpmsg_send_nocopy() function fails and returns an error. In that case the
|
|
||||||
+ * application should try to re-issue the rpmsg_send_nocopy() again.
|
|
||||||
+ *
|
|
||||||
+ * @ept: The rpmsg endpoint
|
|
||||||
+ * @data: TX buffer with message filled
|
|
||||||
+ * @len: Length of payload
|
|
||||||
+ *
|
|
||||||
+ * @return number of bytes it has sent or negative error value on failure.
|
|
||||||
+ *
|
|
||||||
+ * @see rpmsg_get_tx_payload_buffer
|
|
||||||
+ * @see rpmsg_send_offchannel_nocopy
|
|
||||||
+ * @see rpmsg_sendto_nocopy
|
|
||||||
+ */
|
|
||||||
+static inline int rpmsg_send_nocopy(struct rpmsg_endpoint *ept, const void *data, int len)
|
|
||||||
+{
|
|
||||||
+ int tc = 0;
|
|
||||||
+
|
|
||||||
+ for (; tc < RPMSG_TICK_COUNT; tc += RPMSG_TICKS_PER_INTERVAL) {
|
|
||||||
+ if (is_rpmsg_ept_ready(ept))
|
|
||||||
+ return rpmsg_send_offchannel_nocopy(ept, ept->addr,
|
|
||||||
+ ept->dest_addr, data, len);
|
|
||||||
+ metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return RPMSG_ERR_ADDR;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* rpmsg_init_ept - initialize rpmsg endpoint
|
|
||||||
*
|
|
||||||
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
|
|
||||||
index 9da38a1..0a8de1b 100644
|
|
||||||
--- a/lib/rpmsg/rpmsg.c
|
|
||||||
+++ open-amp/lib/rpmsg/rpmsg.c
|
|
||||||
@@ -144,6 +144,64 @@ int rpmsg_send_ns_message(struct rpmsg_endpoint *ept, unsigned long flags)
|
|
||||||
return RPMSG_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
+void rpmsg_hold_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf)
|
|
||||||
+{
|
|
||||||
+ struct rpmsg_device *rdev;
|
|
||||||
+
|
|
||||||
+ if (!ept || !ept->rdev || !rxbuf)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ rdev = ept->rdev;
|
|
||||||
+
|
|
||||||
+ if (rdev->ops.hold_rx_buffer)
|
|
||||||
+ rdev->ops.hold_rx_buffer(rdev, rxbuf);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void rpmsg_release_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf)
|
|
||||||
+{
|
|
||||||
+ struct rpmsg_device *rdev;
|
|
||||||
+
|
|
||||||
+ if (!ept || !ept->rdev || !rxbuf)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ rdev = ept->rdev;
|
|
||||||
+
|
|
||||||
+ if (rdev->ops.release_rx_buffer)
|
|
||||||
+ rdev->ops.release_rx_buffer(rdev, rxbuf);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void *rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint *ept,
|
|
||||||
+ uint32_t *len, int wait)
|
|
||||||
+{
|
|
||||||
+ struct rpmsg_device *rdev;
|
|
||||||
+
|
|
||||||
+ if (!ept || !ept->rdev || !len)
|
|
||||||
+ return NULL;
|
|
||||||
+
|
|
||||||
+ rdev = ept->rdev;
|
|
||||||
+
|
|
||||||
+ if (rdev->ops.get_tx_payload_buffer)
|
|
||||||
+ return rdev->ops.get_tx_payload_buffer(rdev, len, wait);
|
|
||||||
+
|
|
||||||
+ return NULL;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int rpmsg_send_offchannel_nocopy(struct rpmsg_endpoint *ept, uint32_t src,
|
|
||||||
+ uint32_t dst, const void *data, int len)
|
|
||||||
+{
|
|
||||||
+ struct rpmsg_device *rdev;
|
|
||||||
+
|
|
||||||
+ if (!ept || !ept->rdev || !data || !dst || dst == RPMSG_ADDR_ANY)
|
|
||||||
+ return RPMSG_ERR_PARAM;
|
|
||||||
+
|
|
||||||
+ rdev = ept->rdev;
|
|
||||||
+
|
|
||||||
+ if (rdev->ops.send_offchannel_nocopy)
|
|
||||||
+ return rdev->ops.send_offchannel_nocopy(rdev, src, dst, data, len);
|
|
||||||
+
|
|
||||||
+ return RPMSG_ERR_PARAM;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
struct rpmsg_endpoint *rpmsg_get_endpoint(struct rpmsg_device *rdev,
|
|
||||||
const char *name, uint32_t addr,
|
|
||||||
uint32_t dest_addr)
|
|
||||||
diff --git a/lib/rpmsg/rpmsg_internal.h open-amp/lib/rpmsg/rpmsg_internal.h
|
|
||||||
index 9c46970..3db6b24 100644
|
|
||||||
--- a/lib/rpmsg/rpmsg_internal.h
|
|
||||||
+++ open-amp/lib/rpmsg/rpmsg_internal.h
|
|
||||||
@@ -35,6 +35,9 @@ extern "C" {
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+#define RPMSG_BUF_HELD (1U << 31) /* Flag to suggest to hold the buffer */
|
|
||||||
+
|
|
||||||
+#define RPMSG_LOCATE_HDR(p) (struct rpmsg_hdr *)((char *)(p) - sizeof(struct rpmsg_hdr))
|
|
||||||
#define RPMSG_LOCATE_DATA(p) ((unsigned char *)(p) + sizeof(struct rpmsg_hdr))
|
|
||||||
/**
|
|
||||||
* enum rpmsg_ns_flags - dynamic name service announcement flags
|
|
||||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
|
||||||
index 44b46d4..195189d 100644
|
|
||||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
|
||||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
|
||||||
@@ -140,6 +140,7 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev,
|
|
||||||
data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool,
|
|
||||||
RPMSG_BUFFER_SIZE);
|
|
||||||
*len = RPMSG_BUFFER_SIZE;
|
|
||||||
+ *idx = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /*!VIRTIO_SLAVE_ONLY*/
|
|
||||||
@@ -253,6 +254,118 @@ static int _rpmsg_virtio_get_buffer_size(struct rpmsg_virtio_device *rvdev)
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static void rpmsg_virtio_hold_rx_buffer(struct rpmsg_device *rdev, void *rxbuf)
|
|
||||||
+{
|
|
||||||
+ struct rpmsg_hdr *rp_hdr;
|
|
||||||
+
|
|
||||||
+ rp_hdr = RPMSG_LOCATE_HDR(rxbuf);
|
|
||||||
+
|
|
||||||
+ /* Set held status to keep buffer */
|
|
||||||
+ rp_hdr->reserved = RPMSG_BUF_HELD;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void rpmsg_virtio_release_rx_buffer(struct rpmsg_device *rdev, void *rxbuf)
|
|
||||||
+{
|
|
||||||
+ struct rpmsg_virtio_device *rvdev;
|
|
||||||
+ struct rpmsg_hdr *rp_hdr;
|
|
||||||
+ uint16_t idx;
|
|
||||||
+ uint32_t len;
|
|
||||||
+
|
|
||||||
+ rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev);
|
|
||||||
+ rp_hdr = RPMSG_LOCATE_HDR(rxbuf);
|
|
||||||
+ /* The reserved field contains buffer index */
|
|
||||||
+ idx = rp_hdr->reserved;
|
|
||||||
+
|
|
||||||
+ metal_mutex_acquire(&rdev->lock);
|
|
||||||
+ /* Return buffer on virtqueue. */
|
|
||||||
+ len = virtqueue_get_buffer_length(rvdev->rvq, idx);
|
|
||||||
+ rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);
|
|
||||||
+ metal_mutex_release(&rdev->lock);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
|
|
||||||
+ uint32_t *len, int wait)
|
|
||||||
+{
|
|
||||||
+ struct rpmsg_virtio_device *rvdev;
|
|
||||||
+ struct rpmsg_hdr *rp_hdr;
|
|
||||||
+ uint16_t idx;
|
|
||||||
+ int tick_count;
|
|
||||||
+
|
|
||||||
+ /* Get the associated remote device for channel. */
|
|
||||||
+ rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev);
|
|
||||||
+
|
|
||||||
+ if (wait)
|
|
||||||
+ tick_count = RPMSG_TICK_COUNT / RPMSG_TICKS_PER_INTERVAL;
|
|
||||||
+ else
|
|
||||||
+ tick_count = 0;
|
|
||||||
+
|
|
||||||
+ while (1) {
|
|
||||||
+ /* Lock the device to enable exclusive access to virtqueues */
|
|
||||||
+ metal_mutex_acquire(&rdev->lock);
|
|
||||||
+ rp_hdr = rpmsg_virtio_get_tx_buffer(rvdev, len, &idx);
|
|
||||||
+ metal_mutex_release(&rdev->lock);
|
|
||||||
+ if (rp_hdr || !tick_count)
|
|
||||||
+ break;
|
|
||||||
+ metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL);
|
|
||||||
+ tick_count--;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (!rp_hdr)
|
|
||||||
+ return NULL;
|
|
||||||
+
|
|
||||||
+ /* Store the index into the reserved field to be used when sending */
|
|
||||||
+ rp_hdr->reserved = idx;
|
|
||||||
+
|
|
||||||
+ /* Actual data buffer size is vring buffer size minus rpmsg header length */
|
|
||||||
+ *len -= sizeof(struct rpmsg_hdr);
|
|
||||||
+ return RPMSG_LOCATE_DATA(rp_hdr);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int rpmsg_virtio_send_offchannel_nocopy(struct rpmsg_device *rdev,
|
|
||||||
+ uint32_t src, uint32_t dst,
|
|
||||||
+ const void *data, int len)
|
|
||||||
+{
|
|
||||||
+ struct rpmsg_virtio_device *rvdev;
|
|
||||||
+ struct rpmsg_hdr rp_hdr;
|
|
||||||
+ struct rpmsg_hdr *hdr;
|
|
||||||
+ uint16_t idx;
|
|
||||||
+ int status;
|
|
||||||
+ struct metal_io_region *io;
|
|
||||||
+
|
|
||||||
+ /* Get the associated remote device for channel. */
|
|
||||||
+ rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev);
|
|
||||||
+
|
|
||||||
+ hdr = RPMSG_LOCATE_HDR(data);
|
|
||||||
+ /* The reserved field contains buffer index */
|
|
||||||
+ idx = hdr->reserved;
|
|
||||||
+
|
|
||||||
+ /* Initialize RPMSG header. */
|
|
||||||
+ rp_hdr.dst = dst;
|
|
||||||
+ rp_hdr.src = src;
|
|
||||||
+ rp_hdr.len = len;
|
|
||||||
+ rp_hdr.reserved = 0;
|
|
||||||
+ rp_hdr.flags = 0;
|
|
||||||
+
|
|
||||||
+ /* Copy data to rpmsg buffer. */
|
|
||||||
+ io = rvdev->shbuf_io;
|
|
||||||
+ status = metal_io_block_write(io, metal_io_virt_to_offset(io, hdr),
|
|
||||||
+ &rp_hdr, sizeof(rp_hdr));
|
|
||||||
+ RPMSG_ASSERT(status == sizeof(rp_hdr), "failed to write header\r\n");
|
|
||||||
+
|
|
||||||
+ metal_mutex_acquire(&rdev->lock);
|
|
||||||
+
|
|
||||||
+ /* Enqueue buffer on virtqueue. */
|
|
||||||
+ len = virtqueue_get_buffer_length(rvdev->svq, idx);
|
|
||||||
+ status = rpmsg_virtio_enqueue_buffer(rvdev, hdr, len, idx);
|
|
||||||
+ RPMSG_ASSERT(status == VQUEUE_SUCCESS, "failed to enqueue buffer\r\n");
|
|
||||||
+ /* Let the other side know that there is a job to process. */
|
|
||||||
+ virtqueue_kick(rvdev->svq);
|
|
||||||
+
|
|
||||||
+ metal_mutex_release(&rdev->lock);
|
|
||||||
+
|
|
||||||
+ return len;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* This function sends rpmsg "message" to remote device.
|
|
||||||
*
|
|
||||||
@@ -389,6 +502,8 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
|
|
||||||
metal_mutex_release(&rdev->lock);
|
|
||||||
|
|
||||||
while (rp_hdr) {
|
|
||||||
+ rp_hdr->reserved = 0;
|
|
||||||
+
|
|
||||||
/* Get the channel node from the remote device channels list. */
|
|
||||||
metal_mutex_acquire(&rdev->lock);
|
|
||||||
ept = rpmsg_get_ept_from_addr(rdev, rp_hdr->dst);
|
|
||||||
@@ -411,8 +526,15 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
|
|
||||||
|
|
||||||
metal_mutex_acquire(&rdev->lock);
|
|
||||||
|
|
||||||
- /* Return used buffers. */
|
|
||||||
- rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);
|
|
||||||
+ /* Check whether callback wants to hold buffer */
|
|
||||||
+ if (rp_hdr->reserved & RPMSG_BUF_HELD) {
|
|
||||||
+ /* 'rp_hdr->reserved' field is now used as storage for
|
|
||||||
+ * 'idx' to release buffer later */
|
|
||||||
+ rp_hdr->reserved = idx;
|
|
||||||
+ } else {
|
|
||||||
+ /* Return used buffers. */
|
|
||||||
+ rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);
|
|
||||||
+ }
|
|
||||||
|
|
||||||
rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
|
|
||||||
if (!rp_hdr) {
|
|
||||||
@@ -522,6 +644,10 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
|
|
||||||
rvdev->vdev = vdev;
|
|
||||||
rdev->ns_bind_cb = ns_bind_cb;
|
|
||||||
vdev->priv = rvdev;
|
|
||||||
+ rdev->ops.hold_rx_buffer = rpmsg_virtio_hold_rx_buffer;
|
|
||||||
+ rdev->ops.release_rx_buffer = rpmsg_virtio_release_rx_buffer;
|
|
||||||
+ rdev->ops.get_tx_payload_buffer = rpmsg_virtio_get_tx_payload_buffer;
|
|
||||||
+ rdev->ops.send_offchannel_nocopy = rpmsg_virtio_send_offchannel_nocopy;
|
|
||||||
rdev->ops.send_offchannel_raw = rpmsg_virtio_send_offchannel_raw;
|
|
||||||
role = rpmsg_virtio_get_role(rvdev);
|
|
||||||
|
|
||||||
--
|
|
||||||
2.17.1
|
|
||||||
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
From 9bbc2dcd43f6107a7e0b1eec16bab10e533329f2 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
Date: Thu, 3 Jan 2019 14:20:48 +0800
|
|
||||||
Subject: [PATCH 09/10] implement
|
|
||||||
rproc_virtio_read_config/rproc_virtio_write_config
|
|
||||||
|
|
||||||
so the rpmsg could access the configuration space as needed
|
|
||||||
|
|
||||||
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
||||||
---
|
|
||||||
lib/include/openamp/rpmsg_virtio.h | 14 +++++++++++
|
|
||||||
lib/include/openamp/virtio.h | 1 +
|
|
||||||
lib/remoteproc/remoteproc_virtio.c | 40 ++++++++++++++++++++++++------
|
|
||||||
3 files changed, 47 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
|
||||||
index e6e5fa2..4d3093b 100644
|
|
||||||
--- a/lib/include/openamp/rpmsg_virtio.h
|
|
||||||
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
|
||||||
@@ -86,6 +86,20 @@ rpmsg_virtio_get_features(struct rpmsg_virtio_device *rvdev)
|
|
||||||
return rvdev->vdev->func->get_features(rvdev->vdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
+static inline void
|
|
||||||
+rpmsg_virtio_read_config(struct rpmsg_virtio_device *rvdev,
|
|
||||||
+ uint32_t offset, void *dst, int length)
|
|
||||||
+{
|
|
||||||
+ rvdev->vdev->func->read_config(rvdev->vdev, offset, dst, length);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static inline void
|
|
||||||
+rpmsg_virtio_write_config(struct rpmsg_virtio_device *rvdev,
|
|
||||||
+ uint32_t offset, void *dst, int length)
|
|
||||||
+{
|
|
||||||
+ rvdev->vdev->func->write_config(rvdev->vdev, offset, dst, length);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static inline int
|
|
||||||
rpmsg_virtio_create_virtqueues(struct rpmsg_virtio_device *rvdev,
|
|
||||||
int flags, unsigned int nvqs,
|
|
||||||
diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h
|
|
||||||
index 55c8ea5..9c8376e 100644
|
|
||||||
--- a/lib/include/openamp/virtio.h
|
|
||||||
+++ open-amp/lib/include/openamp/virtio.h
|
|
||||||
@@ -100,6 +100,7 @@ struct virtio_device {
|
|
||||||
virtio_dev_reset_cb reset_cb; /**< user registered device callback */
|
|
||||||
const struct virtio_dispatch *func; /**< Virtio dispatch table */
|
|
||||||
void *priv; /**< TODO: remove pointer to virtio_device private data */
|
|
||||||
+ unsigned int config_len; /**< config space length */
|
|
||||||
unsigned int vrings_num; /**< number of vrings */
|
|
||||||
struct virtio_vring_info *vrings_info;
|
|
||||||
};
|
|
||||||
diff --git a/lib/remoteproc/remoteproc_virtio.c open-amp/lib/remoteproc/remoteproc_virtio.c
|
|
||||||
index aafc48c..7505f64 100644
|
|
||||||
--- a/lib/remoteproc/remoteproc_virtio.c
|
|
||||||
+++ open-amp/lib/remoteproc/remoteproc_virtio.c
|
|
||||||
@@ -128,20 +128,43 @@ static uint32_t rproc_virtio_negotiate_features(struct virtio_device *vdev,
|
|
||||||
static void rproc_virtio_read_config(struct virtio_device *vdev,
|
|
||||||
uint32_t offset, void *dst, int length)
|
|
||||||
{
|
|
||||||
- (void)vdev;
|
|
||||||
- (void)offset;
|
|
||||||
- (void)dst;
|
|
||||||
- (void)length;
|
|
||||||
+ struct remoteproc_virtio *rpvdev;
|
|
||||||
+ struct fw_rsc_vdev *vdev_rsc;
|
|
||||||
+ struct metal_io_region *io;
|
|
||||||
+ char *config;
|
|
||||||
+
|
|
||||||
+ if (offset + length > vdev->config_len || offset + length < length)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
|
|
||||||
+ vdev_rsc = rpvdev->vdev_rsc;
|
|
||||||
+ config = (char *)(&vdev_rsc->vring[vdev->vrings_num]);
|
|
||||||
+ io = rpvdev->vdev_rsc_io;
|
|
||||||
+ metal_io_block_read(io,
|
|
||||||
+ metal_io_virt_to_offset(io, config + offset),
|
|
||||||
+ dst, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef VIRTIO_SLAVE_ONLY
|
|
||||||
static void rproc_virtio_write_config(struct virtio_device *vdev,
|
|
||||||
uint32_t offset, void *src, int length)
|
|
||||||
{
|
|
||||||
- (void)vdev;
|
|
||||||
- (void)offset;
|
|
||||||
- (void)src;
|
|
||||||
- (void)length;
|
|
||||||
+ struct remoteproc_virtio *rpvdev;
|
|
||||||
+ struct fw_rsc_vdev *vdev_rsc;
|
|
||||||
+ struct metal_io_region *io;
|
|
||||||
+ char *config;
|
|
||||||
+
|
|
||||||
+ if (offset + length > vdev->config_len || offset + length < length)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
|
|
||||||
+ vdev_rsc = rpvdev->vdev_rsc;
|
|
||||||
+ config = (char *)(&vdev_rsc->vring[vdev->vrings_num]);
|
|
||||||
+ io = rpvdev->vdev_rsc_io;
|
|
||||||
+ metal_io_block_write(io,
|
|
||||||
+ metal_io_virt_to_offset(io, config + offset),
|
|
||||||
+ src, length);
|
|
||||||
+ rpvdev->notify(rpvdev->priv, vdev->notifyid);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rproc_virtio_reset_device(struct virtio_device *vdev)
|
|
||||||
@@ -222,6 +245,7 @@ rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid,
|
|
||||||
vdev->notifyid = notifyid;
|
|
||||||
vdev->role = role;
|
|
||||||
vdev->reset_cb = rst_cb;
|
|
||||||
+ vdev->config_len = vdev_rsc->config_len;
|
|
||||||
vdev->vrings_num = num_vrings;
|
|
||||||
vdev->func = &remoteproc_virtio_dispatch_funcs;
|
|
||||||
|
|
||||||
--
|
|
||||||
2.17.1
|
|
||||||
|
|
||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
include $(TOPDIR)/Make.defs
|
include $(TOPDIR)/Make.defs
|
||||||
|
|
||||||
VERSION ?= 2020.04.0
|
VERSION ?= 2021.04.0
|
||||||
|
|
||||||
include libmetal.defs
|
include libmetal.defs
|
||||||
include open-amp.defs
|
include open-amp.defs
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ CSRCS += libmetal/lib/version.c
|
|||||||
CFLAGS += -DMETAL_INTERNAL
|
CFLAGS += -DMETAL_INTERNAL
|
||||||
|
|
||||||
LIBMETAL_HDRS_SEDEXP := \
|
LIBMETAL_HDRS_SEDEXP := \
|
||||||
"s/@PROJECT_VER_MAJOR@/0/g; \
|
"s/@PROJECT_VERSION_MAJOR@/0/g; \
|
||||||
s/@PROJECT_VER_MINOR@/1/g; \
|
s/@PROJECT_VERSION_MINOR@/1/g; \
|
||||||
s/@PROJECT_VER_PATCH@/0/g; \
|
s/@PROJECT_VERSION_PATCH@/0/g; \
|
||||||
s/@PROJECT_VER@/0.1.0/g; \
|
s/@PROJECT_VERSION@/0.1.0/g; \
|
||||||
s/@PROJECT_SYSTEM@/nuttx/g; \
|
s/@PROJECT_SYSTEM@/nuttx/g; \
|
||||||
s/@PROJECT_PROCESSOR@/$(LIBMETAL_ARCH)/g; \
|
s/@PROJECT_PROCESSOR@/$(LIBMETAL_ARCH)/g; \
|
||||||
s/@PROJECT_MACHINE@/$(CONFIG_ARCH_CHIP)/g; \
|
s/@PROJECT_MACHINE@/$(CONFIG_ARCH_CHIP)/g; \
|
||||||
@@ -63,7 +63,6 @@ libmetal.zip:
|
|||||||
$(Q) curl -L https://github.com/OpenAMP/libmetal/archive/v$(VERSION).zip -o libmetal.zip
|
$(Q) curl -L https://github.com/OpenAMP/libmetal/archive/v$(VERSION).zip -o libmetal.zip
|
||||||
$(Q) unzip -o libmetal.zip
|
$(Q) unzip -o libmetal.zip
|
||||||
$(Q) mv libmetal-$(VERSION) libmetal
|
$(Q) mv libmetal-$(VERSION) libmetal
|
||||||
$(Q) patch -p0 < 0001-system-nuttx-change-clock_systimespec-to-clock_systi.patch
|
|
||||||
|
|
||||||
.libmetal_headers: libmetal.zip
|
.libmetal_headers: libmetal.zip
|
||||||
$(eval headers := $(wildcard libmetal/lib/compiler/gcc/*.h))
|
$(eval headers := $(wildcard libmetal/lib/compiler/gcc/*.h))
|
||||||
|
|||||||
+3
-10
@@ -33,16 +33,9 @@ open-amp.zip:
|
|||||||
$(Q) curl -L https://github.com/OpenAMP/open-amp/archive/v$(VERSION).zip -o open-amp.zip
|
$(Q) curl -L https://github.com/OpenAMP/open-amp/archive/v$(VERSION).zip -o open-amp.zip
|
||||||
$(Q) unzip -o open-amp.zip
|
$(Q) unzip -o open-amp.zip
|
||||||
$(Q) mv open-amp-$(VERSION) open-amp
|
$(Q) mv open-amp-$(VERSION) open-amp
|
||||||
$(Q) patch -p0 < 0001-rpmsg-remove-the-address-check-in-rpmsg_send-rpmsg_t.patch
|
$(Q) patch -p0 < 0001-ns-acknowledge-the-received-creation-message.patch
|
||||||
$(Q) patch -p0 < 0002-rpmsg-merge-rpmsg_register_endpoint-into-rpmsg_init_.patch
|
$(Q) patch -p0 < 0002-Negotiate-individual-buffer-size-dynamically.patch
|
||||||
$(Q) patch -p0 < 0003-rpmsg-shouldn-t-allocate-0-1023-address-in-rpmsg_cre.patch
|
$(Q) patch -p0 < 0003-rpmsg-wait-endpoint-ready-in-rpmsg_send-and-rpmsg_se.patch
|
||||||
$(Q) patch -p0 < 0004-rpmsg-wait-ept-ready-in-rpmsg_send.patch
|
|
||||||
$(Q) patch -p0 < 0005-rpmsg-return-fail-if-either-source-or-destination-ad.patch
|
|
||||||
$(Q) patch -p0 < 0006-remoteproc_mmap-support-va-to-pa-da-conversion.patch
|
|
||||||
$(Q) patch -p0 < 0007-rpmsg-bring-back-zero-copy-transfer.patch
|
|
||||||
$(Q) patch -p0 < 0008-ns-acknowledge-the-received-creation-message.patch
|
|
||||||
$(Q) patch -p0 < 0009-implement-rproc_virtio_read_config-rproc_virtio_writ.patch
|
|
||||||
$(Q) patch -p0 < 0010-Negotiate-individual-buffer-size-dynamically.patch
|
|
||||||
|
|
||||||
.openamp_headers: open-amp.zip
|
.openamp_headers: open-amp.zip
|
||||||
$(eval headers := $(wildcard open-amp/lib/include/openamp/*.h))
|
$(eval headers := $(wildcard open-amp/lib/include/openamp/*.h))
|
||||||
|
|||||||
Reference in New Issue
Block a user