]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/open-amp.git/blobdiff - apps/echo_test/echo_test.c
apps: machine: zynqmp_r5: correct IPI setting.
[processor-sdk/open-amp.git] / apps / echo_test / echo_test.c
index 44df1ee77ff6793b164218c54b3fad39ae1bf64f..c947194362fee463013b0bdd6684481c211f2e0a 100644 (file)
@@ -9,7 +9,6 @@ This application echoes back data that was sent to it by the master core. */
 #include "openamp/open_amp.h"
 #include "metal/alloc.h"
 #include "rsc_table.h"
 #include "openamp/open_amp.h"
 #include "metal/alloc.h"
 #include "rsc_table.h"
-#include "platform_info.h"
 
 #define SHUTDOWN_MSG   0xEF56A55A
 #define LPRINTF(format, ...) printf(format, ##__VA_ARGS__)
 
 #define SHUTDOWN_MSG   0xEF56A55A
 #define LPRINTF(format, ...) printf(format, ##__VA_ARGS__)
@@ -18,7 +17,7 @@ This application echoes back data that was sent to it by the master core. */
 struct _payload {
        unsigned long num;
        unsigned long size;
 struct _payload {
        unsigned long num;
        unsigned long size;
-       char data[];
+       unsigned char data[];
 };
 
 static int err_cnt;
 };
 
 static int err_cnt;
@@ -46,15 +45,15 @@ static struct rsc_table_info rsc_info;
 static struct _payload *i_payload;
 static int rnum = 0;
 static int err_cnt = 0;
 static struct _payload *i_payload;
 static int rnum = 0;
 static int err_cnt = 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();
 
 /* External functions */
 extern void init_system();
 extern void cleanup_system();
+extern struct hil_proc *platform_create_proc(int proc_index);
+extern void *get_resource_table (int rsc_id, int *len);
 
 /* Application entry point */
 
 /* Application entry point */
-int main()
+int app (struct hil_proc *hproc)
 {
        int status = 0;
        int shutdown_msg = SHUTDOWN_MSG;
 {
        int status = 0;
        int shutdown_msg = SHUTDOWN_MSG;
@@ -64,11 +63,6 @@ int main()
 
        LPRINTF(" 1 - Send data to remote core, retrieve the echo");
        LPRINTF(" and validate its integrity ..\n");
 
        LPRINTF(" 1 - Send data to remote core, retrieve the echo");
        LPRINTF(" and validate its integrity ..\n");
-       /* Initialize HW system components */
-       init_system();
-
-       rsc_info.rsc_tab = (struct resource_table *)&resources;
-       rsc_info.size = sizeof(resources);
 
        i_payload =
            (struct _payload *)metal_allocate_memory(2 * sizeof(unsigned long) +
 
        i_payload =
            (struct _payload *)metal_allocate_memory(2 * sizeof(unsigned long) +
@@ -81,13 +75,13 @@ int main()
 
        /* Initialize RPMSG framework */
        status =
 
        /* Initialize RPMSG framework */
        status =
-           remoteproc_resource_init(&rsc_info, &proc_table,
+           remoteproc_resource_init(&rsc_info, hproc,
                                     rpmsg_channel_created,
                                     rpmsg_channel_deleted, rpmsg_read_cb,
                                     &proc, 1);
 
        if (status) {
                                     rpmsg_channel_created,
                                     rpmsg_channel_deleted, rpmsg_read_cb,
                                     &proc, 1);
 
        if (status) {
-               LPERROR("Failed  to initialize remoteproc resource.\n");
+               LPERROR("Failed to initialize remoteproc resource.\n");
                return -1;
        }
 
                return -1;
        }
 
@@ -174,7 +168,7 @@ static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
        /* Validate data buffer integrity. */
        for (i = 0; i < (int)r_payload->size; i++) {
                if (r_payload->data[i] != 0xA5) {
        /* Validate data buffer integrity. */
        for (i = 0; i < (int)r_payload->size; i++) {
                if (r_payload->data[i] != 0xA5) {
-                       LPRINTF("Data corruption at index %d \n", i);
+                       LPRINTF("Data corruption at index %d\n", i);
                        err_cnt++;
                        break;
                }
                        err_cnt++;
                        break;
                }
@@ -182,3 +176,35 @@ static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
        rnum = r_payload->num + 1;
 }
 
        rnum = r_payload->num + 1;
 }
 
+int main(int argc, char *argv[])
+{
+       unsigned long proc_id = 0;
+       unsigned long rsc_id = 0;
+       struct hil_proc *hproc;
+
+       /* Initialize HW system components */
+       init_system();
+
+       if (argc >= 2) {
+               proc_id = strtoul(argv[1], NULL, 0);
+       }
+
+       if (argc >= 3) {
+               rsc_id = strtoul(argv[2], NULL, 0);
+       }
+
+       /* Create HIL proc */
+       hproc = platform_create_proc(proc_id);
+       if (!hproc) {
+               LPERROR("Failed to create hil proc.\n");
+               return -1;
+       }
+       rsc_info.rsc_tab = get_resource_table(
+               (int)rsc_id, &rsc_info.size);
+       if (!rsc_info.rsc_tab) {
+               LPRINTF("Failed to get resource table data.\n");
+               return -1;
+       }
+       return app(hproc);
+}
+