summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ee99c0f)
raw | patch | inline | side by side (parent: ee99c0f)
author | Sam Sortais <sam.sortais@xilinx.com> | |
Thu, 18 Aug 2016 04:35:44 +0000 (21:35 -0700) | ||
committer | Wendy Liang <jliang@xilinx.com> | |
Thu, 13 Oct 2016 05:01:49 +0000 (22:01 -0700) |
Signed-off-by: Sam Sortais <sam.sortais@xilinx.com>
apps/echo_test/echo_testd.c | patch | blob | history |
index 4f6a3634baaf25e156451505ed025a7122954cfd..99450fbbd2122d703399e214a84fa48070281713 100644 (file)
This application is meant to run on the remote CPU running baremetal code.
This application echoes back data that was sent to it by the master core. */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "openamp/open_amp.h"
#include "rsc_table.h"
#include "platform_info.h"
static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
unsigned long);
+
/* Globals */
-static struct rpmsg_channel *app_rp_chnl;
static struct rpmsg_endpoint *rp_ept;
static struct remote_proc *proc = NULL;
static struct rsc_table_info rsc_info;
+static int evt_chnl_deleted = 0;
extern const struct remote_resource_table resources;
extern struct rproc_info_plat_local proc_table;
/* External functions */
-extern void init_system();
-extern void cleanup_system();
+extern void init_system(void);
+extern void cleanup_system(void);
/* Application entry point */
-int main()
+int main(void)
{
int status = 0;
rpmsg_channel_deleted, rpmsg_read_cb,
&proc, 0);
- if (status < 0) {
+ if (RPROC_SUCCESS != status) {
return -1;
}
do {
hil_poll(proc->proc, 0);
- } while (!app_rp_chnl);
+ } while (!evt_chnl_deleted);
- while(app_rp_chnl) {
- hil_poll(proc->proc, 0);
- }
+ /* disable interrupts and free resources */
+ remoteproc_resource_deinit(proc);
+
+ cleanup_system();
return 0;
}
static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
{
- app_rp_chnl = rp_chnl;
rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
RPMSG_ADDR_ANY);
}
static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
{
- app_rp_chnl = NULL;
+ (void)rp_chnl;
+
+ rpmsg_destroy_ept(rp_ept);
rp_ept = NULL;
}
static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
void *priv, unsigned long src)
{
- if ((*(int *)data) == SHUTDOWN_MSG) {
- remoteproc_resource_deinit(proc);
- cleanup_system();
- } else {
- /* Send data back to master */
- rpmsg_send(rp_chnl, data, len);
- }
+ (void)priv;
+ (void)src;
+
+ if ((*(unsigned int *)data) == SHUTDOWN_MSG) {
+ evt_chnl_deleted = 1;
+ return;
+ }
+
+ /* Send data back to master */
+ rpmsg_send(rp_chnl, data, len);
}