mirror of
https://github.com/OpenAMP/open-amp.git
synced 2026-02-07 20:29:09 +08:00
app: update to adapt on ns_unbind_cb
Rework of the endpoint management based on new ns_unbind callback. slave core destroys its endpoint when receive rpmsg shutdown message. Master core destroys its endpoint when receive ns unbind callback. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
This commit is contained in:
committed by
wjliang
parent
6032b22f1c
commit
703eba29c6
@@ -15,7 +15,7 @@ This application echoes back data that was sent to it by the master core. */
|
||||
#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__)
|
||||
|
||||
static struct rpmsg_endpoint lept;
|
||||
static int ept_deleted = 0;
|
||||
static int shutdown_req = 0;
|
||||
|
||||
/* External functions */
|
||||
extern int init_system(void);
|
||||
@@ -33,7 +33,7 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
/* On reception of a shutdown we signal the application to terminate */
|
||||
if ((*(unsigned int *)data) == SHUTDOWN_MSG) {
|
||||
LPRINTF("shutdown message is received.\n");
|
||||
rpmsg_destroy_ept(ept);
|
||||
shutdown_req = 1;
|
||||
return RPMSG_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -44,11 +44,11 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
return RPMSG_SUCCESS;
|
||||
}
|
||||
|
||||
static void rpmsg_endpoint_destroy(struct rpmsg_endpoint *ept)
|
||||
static void rpmsg_service_unbind(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
(void)ept;
|
||||
LPRINTF("Endpoint is destroyed\n");
|
||||
ept_deleted = 1;
|
||||
LPRINTF("unexpected Remote endpoint destroy\n");
|
||||
shutdown_req = 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*
|
||||
@@ -63,7 +63,7 @@ int app(struct rpmsg_device *rdev, void *priv)
|
||||
|
||||
ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME,
|
||||
0, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
||||
rpmsg_endpoint_destroy);
|
||||
rpmsg_service_unbind);
|
||||
if (ret) {
|
||||
LPERROR("Failed to create endpoint.\n");
|
||||
return -1;
|
||||
@@ -73,10 +73,11 @@ int app(struct rpmsg_device *rdev, void *priv)
|
||||
while(1) {
|
||||
platform_poll(priv);
|
||||
/* we got a shutdown request, exit */
|
||||
if (ept_deleted) {
|
||||
if (shutdown_req) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
rpmsg_destroy_ept(&lept);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -69,10 +69,11 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
return RPMSG_SUCCESS;
|
||||
}
|
||||
|
||||
static void rpmsg_endpoint_destroy(struct rpmsg_endpoint *ept)
|
||||
static void rpmsg_service_unbind(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
(void)ept;
|
||||
LPRINTF("Endpoint is destroyed\n");
|
||||
rpmsg_destroy_ept(&lept);
|
||||
LPRINTF("echo test: service is destroyed\n");
|
||||
ept_deleted = 1;
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ static void rpmsg_name_service_bind_cb(struct rpmsg_device *rdev,
|
||||
(void)rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME,
|
||||
APP_EPT_ADDR, src,
|
||||
rpmsg_endpoint_cb,
|
||||
rpmsg_endpoint_destroy);
|
||||
rpmsg_service_unbind);
|
||||
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ int app (struct rpmsg_device *rdev, void *priv)
|
||||
/* Create RPMsg endpoint */
|
||||
ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME, APP_EPT_ADDR,
|
||||
RPMSG_ADDR_ANY,
|
||||
rpmsg_endpoint_cb, rpmsg_endpoint_destroy);
|
||||
rpmsg_endpoint_cb, rpmsg_service_unbind);
|
||||
|
||||
if (ret) {
|
||||
LPERROR("Failed to create RPMsg endpoint.\n");
|
||||
@@ -166,7 +167,6 @@ int app (struct rpmsg_device *rdev, void *priv)
|
||||
LPRINTF("**********************************\n");
|
||||
/* Send shutdown message to remote */
|
||||
rpmsg_send(&lept, &shutdown_msg, sizeof(int));
|
||||
rpmsg_destroy_ept(&lept);
|
||||
while(!ept_deleted)
|
||||
platform_poll(priv);
|
||||
LPRINTF("Quitting application .. Echo test end\n");
|
||||
|
||||
@@ -148,10 +148,11 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data,
|
||||
return RPMSG_SUCCESS;
|
||||
}
|
||||
|
||||
static void rpmsg_endpoint_destroy(struct rpmsg_endpoint *ept)
|
||||
static void rpmsg_service_unbind(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
(void)ept;
|
||||
LPERROR("Endpoint is destroyed\n");
|
||||
rpmsg_destroy_ept(&lept);
|
||||
LPRINTF("echo test: service is destroyed\n");
|
||||
ept_deleted = 1;
|
||||
}
|
||||
|
||||
@@ -164,7 +165,7 @@ static void rpmsg_name_service_bind_cb(struct rpmsg_device *rdev,
|
||||
(void)rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME,
|
||||
APP_EPT_ADDR, src,
|
||||
rpmsg_endpoint_cb,
|
||||
rpmsg_endpoint_destroy);
|
||||
rpmsg_service_unbind);
|
||||
|
||||
}
|
||||
|
||||
@@ -185,7 +186,7 @@ int app (struct rpmsg_device *rdev, void *priv)
|
||||
/* Create RPMsg endpoint */
|
||||
ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME, APP_EPT_ADDR,
|
||||
RPMSG_ADDR_ANY,
|
||||
rpmsg_endpoint_cb, rpmsg_endpoint_destroy);
|
||||
rpmsg_endpoint_cb, rpmsg_service_unbind);
|
||||
if (ret) {
|
||||
LPERROR("Failed to create RPMsg endpoint.\n");
|
||||
return ret;
|
||||
@@ -223,7 +224,6 @@ int app (struct rpmsg_device *rdev, void *priv)
|
||||
|
||||
/* Send shutdown message to remote */
|
||||
rpmsg_send(&lept, &shutdown_msg, sizeof(int));
|
||||
rpmsg_destroy_ept(&lept);
|
||||
while(!ept_deleted)
|
||||
platform_poll(priv);
|
||||
LPRINTF("Quitting application .. Matrix multiplication end\n");
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef struct _matrix {
|
||||
|
||||
/* Local variables */
|
||||
static struct rpmsg_endpoint lept;
|
||||
static int ept_deleted = 0;
|
||||
static int shutdown_req = 0;
|
||||
|
||||
/* External functions */
|
||||
extern int init_system(void);
|
||||
@@ -67,7 +67,7 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
|
||||
if ((*(unsigned int *)data) == SHUTDOWN_MSG) {
|
||||
LPRINTF("shutdown message is received.\n");
|
||||
rpmsg_destroy_ept(&lept);
|
||||
shutdown_req = 1;
|
||||
return RPMSG_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -82,11 +82,11 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
return RPMSG_SUCCESS;
|
||||
}
|
||||
|
||||
static void rpmsg_endpoint_destroy(struct rpmsg_endpoint *ept)
|
||||
static void rpmsg_service_unbind(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
(void)ept;
|
||||
LPERROR("Endpoint is destroyed\n");
|
||||
ept_deleted = 1;
|
||||
shutdown_req = 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*
|
||||
@@ -98,7 +98,7 @@ int app(struct rpmsg_device *rdev, void *priv)
|
||||
|
||||
ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME,
|
||||
0, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
||||
rpmsg_endpoint_destroy);
|
||||
rpmsg_service_unbind);
|
||||
if (ret) {
|
||||
LPERROR("Failed to create endpoint.\n");
|
||||
return -1;
|
||||
@@ -108,10 +108,11 @@ int app(struct rpmsg_device *rdev, void *priv)
|
||||
while(1) {
|
||||
platform_poll(priv);
|
||||
/* we got a shutdown request, exit */
|
||||
if (ept_deleted) {
|
||||
if (shutdown_req) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
rpmsg_destroy_ept(&lept);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -221,9 +221,10 @@ static int handle_rpc(struct rpmsg_rpc_syscall *syscall,
|
||||
|
||||
return retval;
|
||||
}
|
||||
static void rpmsg_endpoint_destroy(struct rpmsg_endpoint *ept)
|
||||
static void rpmsg_service_unbind(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
(void)ept;
|
||||
rpmsg_destroy_ept(&app_ept);
|
||||
LPRINTF("Endpoint is destroyed\n");
|
||||
ept_deleted = 1;
|
||||
}
|
||||
@@ -312,7 +313,7 @@ int app(struct rpmsg_device *rdev, void *priv)
|
||||
|
||||
ret = rpmsg_create_ept(&app_ept, rdev, RPMSG_SERVICE_NAME,
|
||||
0, RPMSG_ADDR_ANY, rpmsg_endpoint_cb,
|
||||
rpmsg_endpoint_destroy);
|
||||
rpmsg_service_unbind);
|
||||
if (ret) {
|
||||
LPERROR("Failed to create endpoint.\n");
|
||||
return -EINVAL;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#define MSG_LIMIT 100
|
||||
|
||||
static struct rpmsg_endpoint lept;
|
||||
static int ept_deleted = 0;
|
||||
static int shutdown_req = 0;
|
||||
|
||||
/* External functions */
|
||||
extern int init_system(void);
|
||||
@@ -54,15 +54,15 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
return RPMSG_SUCCESS;
|
||||
|
||||
destroy_ept:
|
||||
rpmsg_destroy_ept(ept);
|
||||
shutdown_req = 1;
|
||||
return RPMSG_SUCCESS;
|
||||
}
|
||||
|
||||
static void rpmsg_endpoint_destroy(struct rpmsg_endpoint *ept)
|
||||
static void rpmsg_service_unbind(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
(void)ept;
|
||||
LPRINTF("Endpoint is destroyed\n");
|
||||
ept_deleted = 1;
|
||||
LPRINTF("unexpected Remote endpoint destroy\n");
|
||||
shutdown_req = 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*
|
||||
@@ -76,7 +76,7 @@ int app(struct rpmsg_device *rdev, void *priv)
|
||||
LPRINTF("Try to create rpmsg endpoint.\n");
|
||||
|
||||
ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERV_NAME, 0, RPMSG_ADDR_ANY,
|
||||
rpmsg_endpoint_cb, rpmsg_endpoint_destroy);
|
||||
rpmsg_endpoint_cb, rpmsg_service_unbind);
|
||||
if (ret) {
|
||||
LPERROR("Failed to create endpoint.\n");
|
||||
return -1;
|
||||
@@ -86,10 +86,11 @@ int app(struct rpmsg_device *rdev, void *priv)
|
||||
while (1) {
|
||||
platform_poll(priv);
|
||||
/* we got a shutdown request, exit */
|
||||
if (ept_deleted) {
|
||||
if (shutdown_req) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
rpmsg_destroy_ept(&lept);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -73,10 +73,11 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
return RPMSG_SUCCESS;
|
||||
}
|
||||
|
||||
static void rpmsg_endpoint_destroy(struct rpmsg_endpoint *ept)
|
||||
static void rpmsg_service_unbind(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
(void)ept;
|
||||
LPRINTF("Endpoint is destroyed\n");
|
||||
rpmsg_destroy_ept(&lept);
|
||||
LPRINTF("echo test: service is destroyed\n");
|
||||
ept_deleted = 1;
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ static void rpmsg_new_endpoint_cb(struct rpmsg_device *rdev, const char *name,
|
||||
(void)rpmsg_create_ept(&lept, rdev, RPMSG_SERV_NAME,
|
||||
APP_EPT_ADDR, src,
|
||||
rpmsg_endpoint_cb,
|
||||
rpmsg_endpoint_destroy);
|
||||
rpmsg_service_unbind);
|
||||
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ int app(struct rpmsg_device *rdev, void *priv)
|
||||
/* Create RPMsg endpoint */
|
||||
ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERV_NAME, APP_EPT_ADDR,
|
||||
RPMSG_ADDR_ANY,
|
||||
rpmsg_endpoint_cb, rpmsg_endpoint_destroy);
|
||||
rpmsg_endpoint_cb, rpmsg_service_unbind);
|
||||
|
||||
if (ret) {
|
||||
LPERROR("Failed to create RPMsg endpoint.\n");
|
||||
@@ -142,7 +143,6 @@ int app(struct rpmsg_device *rdev, void *priv)
|
||||
LPRINTF("**********************************\n");
|
||||
LPRINTF(" Test Results: Error count = %d\n", err_cnt);
|
||||
LPRINTF("**********************************\n");
|
||||
rpmsg_destroy_ept(&lept);
|
||||
while (!ept_deleted)
|
||||
platform_poll(priv);
|
||||
LPRINTF("Quitting application .. rpmsg sample test end\n");
|
||||
|
||||
@@ -69,9 +69,10 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
return RPMSG_SUCCESS;
|
||||
}
|
||||
|
||||
static void rpmsg_endpoint_destroy(struct rpmsg_endpoint *ept)
|
||||
static void rpmsg_service_unbind(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
(void)ept;
|
||||
rpmsg_destroy_ept(&lept);
|
||||
LPRINTF("Endpoint is destroyed\n");
|
||||
ept_deleted = 1;
|
||||
}
|
||||
@@ -86,7 +87,7 @@ static void rpmsg_name_service_bind_cb(struct rpmsg_device *rdev,
|
||||
(void)rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME,
|
||||
APP_EPT_ADDR, src,
|
||||
rpmsg_endpoint_cb,
|
||||
rpmsg_endpoint_destroy);
|
||||
rpmsg_service_unbind);
|
||||
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ int app (struct rpmsg_device *rdev, void *priv)
|
||||
/* Create RPMsg endpoint */
|
||||
ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME, APP_EPT_ADDR,
|
||||
RPMSG_ADDR_ANY,
|
||||
rpmsg_endpoint_cb, rpmsg_endpoint_destroy);
|
||||
rpmsg_endpoint_cb, rpmsg_service_unbind);
|
||||
|
||||
if (ret) {
|
||||
LPERROR("Failed to create RPMsg endpoint.\n");
|
||||
@@ -166,7 +167,6 @@ int app (struct rpmsg_device *rdev, void *priv)
|
||||
LPRINTF("**********************************\n");
|
||||
/* Send shutdown message to remote */
|
||||
rpmsg_send(&lept, &shutdown_msg, sizeof(int));
|
||||
rpmsg_destroy_ept(&lept);
|
||||
while(!ept_deleted)
|
||||
platform_poll(priv);
|
||||
LPRINTF("Quitting application .. Echo test end\n");
|
||||
|
||||
@@ -15,7 +15,7 @@ This application echoes back data that was sent to it by the master core. */
|
||||
#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__)
|
||||
|
||||
static struct rpmsg_endpoint lept;
|
||||
static int ept_deleted = 0;
|
||||
static int shutdown_req = 0;
|
||||
|
||||
/* External functions */
|
||||
extern int init_system(void);
|
||||
@@ -33,7 +33,7 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
/* On reception of a shutdown we signal the application to terminate */
|
||||
if ((*(unsigned int *)data) == SHUTDOWN_MSG) {
|
||||
LPRINTF("shutdown message is received.\n");
|
||||
rpmsg_destroy_ept(ept);
|
||||
shutdown_req = 1;
|
||||
return RPMSG_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
static void rpmsg_endpoint_destroy(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
(void)ept;
|
||||
LPRINTF("Endpoint is destroyed\n");
|
||||
ept_deleted = 1;
|
||||
LPRINTF("unexpected Remote endpoint destroy\n");
|
||||
shutdown_req = 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*
|
||||
@@ -73,10 +73,11 @@ int app(struct rpmsg_device *rdev, void *priv)
|
||||
while(1) {
|
||||
platform_poll(priv);
|
||||
/* we got a shutdown request, exit */
|
||||
if (ept_deleted) {
|
||||
if (shutdown_req) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
rpmsg_destroy_ept(&lept);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user