]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/open-amp.git/commitdiff
Add Linux application generic initialization
authorWendy Liang <jliang@xilinx.com>
Mon, 12 Sep 2016 21:45:22 +0000 (14:45 -0700)
committerWendy Liang <jliang@xilinx.com>
Fri, 14 Oct 2016 00:14:50 +0000 (17:14 -0700)
Add apps common for RPMsg between Linux processes.

Signed-off-by: Wendy Liang <jliang@xilinx.com>
apps/system/linux/machine/generic/CMakeLists.txt [new file with mode: 0644]
apps/system/linux/machine/generic/helper.c [new file with mode: 0644]
apps/system/linux/machine/generic/platform_info.c [new file with mode: 0755]
apps/system/linux/machine/generic/platform_info.h [new file with mode: 0644]
apps/system/linux/machine/generic/rsc_table.c [new file with mode: 0644]
apps/system/linux/machine/generic/rsc_table.h [new file with mode: 0644]

diff --git a/apps/system/linux/machine/generic/CMakeLists.txt b/apps/system/linux/machine/generic/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e24ec38
--- /dev/null
@@ -0,0 +1,10 @@
+collect (APP_COMMON_SOURCES helper.c)
+collect (APP_COMMON_SOURCES rsc_table.c)
+collect (APP_COMMON_SOURCES platform_info.c)
+
+collect (APP_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
+
+if (WITH_REMOTEPROC_MASTER)
+  message(FATAL_ERROR "Remoteproc master is not currently supported on ${MACHINE}/${SYSTEM}.")
+endif (WITH_REMOTEPROC_MASTER)
+
diff --git a/apps/system/linux/machine/generic/helper.c b/apps/system/linux/machine/generic/helper.c
new file mode 100644 (file)
index 0000000..b1f2699
--- /dev/null
@@ -0,0 +1,53 @@
+
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <string.h>
+#include <stdio.h>
+#include "metal/sys.h"
+#include "metal/shmem.h"
+#include "metal/device.h"
+#include "metal/io.h"
+
+
+void init_system()
+{
+       struct metal_init_params metal_param = METAL_INIT_DEFAULTS;
+
+       metal_param.log_level = LOG_DEBUG;
+       metal_init(&metal_param);
+
+       return;
+}
+
+void cleanup_system()
+{
+       metal_finish();
+}
diff --git a/apps/system/linux/machine/generic/platform_info.c b/apps/system/linux/machine/generic/platform_info.c
new file mode 100755 (executable)
index 0000000..4dfdd0d
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2016 Xilinx, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ *       platform_info.c
+ *
+ * DESCRIPTION
+ *
+ *       This file implements APIs to get platform specific
+ *       information for OpenAMP.
+ *
+ **************************************************************************/
+
+#include <openamp/hil.h>
+#include <metal/io.h>
+#include <metal/atomic.h>
+
+#define IPI_CHN_BITMASK                   0x01000000 /* IPI channel bit mask APU<->RPU0 */
+#define REMOTE_CPU_ID                     0
+
+struct vring_ipi_info {
+       /* Socket file path */
+       char *path;
+       int fd;
+       struct metal_io_region *vring_io;
+       atomic_int sync;
+};
+
+struct rproc_info {
+       unsigned long rproc_id;
+       char *vring0_path;
+       char *vring0_bus;
+       char *vring1_path;
+       char *vring1_bus;
+       char *shm_path;
+       char *shm_bus;
+       int shm_size;
+       void *ipi0;
+       void *ipi1;
+       char *rpmsg_chnl;
+};
+
+extern struct hil_platform_ops linux_proc_ops;
+
+static struct vring_ipi_info ipi_table[] = {
+       { "unixs:/tmp/openamp.event.0", -1, NULL, 0 },
+       { "unixs:/tmp/openamp.event.1", -1, NULL, 0 },
+       { "unix:/tmp/openamp.event.0", -1, NULL, 0 },
+       { "unix:/tmp/openamp.event.1", -1, NULL, 0 },
+};
+
+static struct rproc_info rproc_table [] = {
+       {
+               0,
+               "openamp.vrings",
+               NULL,
+               "openamp.vrings",
+               NULL,
+               "openamp.shm",
+               NULL,
+               0x40000,
+               (void *)&ipi_table[0],
+               (void *)&ipi_table[1],
+               "rpmsg-openamp-demo-channel",
+       },
+       {
+               0,
+               "openamp.vrings",
+               NULL,
+               "openamp.vrings",
+               NULL,
+               "openamp.shm",
+               NULL,
+               0x40000,
+               (void *)&ipi_table[2],
+               (void *)&ipi_table[3],
+               "rpmsg-openamp-demo-channel",
+       },
+};
+
+const struct firmware_info fw_table[] =
+{
+       {"unknown",
+        0,
+        0}
+};
+
+const int fw_table_size = sizeof(fw_table)/sizeof(struct firmware_info);
+
+struct hil_proc *platform_create_proc(int proc_index)
+{
+
+       struct hil_proc *proc;
+       struct rproc_info *proc_data;
+       if (sizeof(rproc_table)/sizeof(struct rproc_info) <=
+               (unsigned long)proc_index){
+               fprintf(stderr, "ERROR: CPU id is invalid: %d.\n", proc_index);
+               return NULL;
+       }
+       proc_data = &rproc_table[proc_index];
+       proc = hil_create_proc(&linux_proc_ops, proc_data->rproc_id, NULL);
+       if (!proc)
+               return NULL;
+
+       /* Setup IPI info */
+       hil_set_ipi(proc, 0, (unsigned int)(-1), proc_data->ipi0);
+       hil_set_ipi(proc, 1, (unsigned int)(-1), proc_data->ipi1);
+       /* Setup vring info */
+       hil_set_vring(proc, 0, proc_data->vring0_bus, proc_data->vring0_path);
+       hil_set_vring(proc, 1, proc_data->vring1_bus, proc_data->vring1_path);
+       /* Setup shared memory info */
+       hil_set_shm (proc, proc_data->shm_bus, proc_data->shm_path,
+               0, proc_data->shm_size);
+       /* Setup RPMSG channel info */
+       hil_set_rpmsg_channel(proc, 0, proc_data->rpmsg_chnl);
+
+       return proc;
+}
+
diff --git a/apps/system/linux/machine/generic/platform_info.h b/apps/system/linux/machine/generic/platform_info.h
new file mode 100644 (file)
index 0000000..2903d2a
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include "openamp/hil.h"
+#include "openamp/remoteproc_plat.h"
+
+/* remoteproc platform data structure */
+struct rproc_info_plat_local {
+       struct proc_info_hdr proc_hdr; /**< hil proc header */
+       struct plat_vring vring0; /**< vring0 data */
+       struct plat_vring vring1; /**< vring1 data */
+       struct plat_shm shm; /**< shared memory data */
+       struct plat_rpmsg_chnl rpmsg_chnl; /**< RPMSG channel data */
+       unsigned int last_type;
+};
diff --git a/apps/system/linux/machine/generic/rsc_table.c b/apps/system/linux/machine/generic/rsc_table.c
new file mode 100644 (file)
index 0000000..71c8c66
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2016 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include "openamp/open_amp.h"
+#include "rsc_table.h"
+
+/* Place resource table in special ELF section */
+#define __section_t(S)          __attribute__((__section__(#S)))
+#define __resource              __section_t(.resource_table)
+
+#define RPMSG_IPU_C0_FEATURES        1
+
+/* VirtIO rpmsg device id */
+#define VIRTIO_ID_RPMSG_             7
+
+/* Remote supports Name Service announcement */
+#define VIRTIO_RPMSG_F_NS           0
+
+#define NUM_VRINGS                  0x02
+#define VRING_ALIGN                 0x1000
+#define RING_TX                     0x00000000
+#define RING_RX                     0x00004000
+#define VRING_SIZE                  256
+
+#define NUM_TABLE_ENTRIES           1
+
+const struct remote_resource_table __resource resources = {
+       /* Version */
+       1,
+
+       /* NUmber of table entries */
+       NUM_TABLE_ENTRIES,
+       /* reserved fields */
+       {0, 0,},
+
+       /* Offsets of rsc entries */
+       {
+        offsetof(struct remote_resource_table, rpmsg_vdev),
+       },
+
+       /* Virtio device entry */
+       {
+        RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
+        NUM_VRINGS, {0, 0},
+        },
+
+       /* Vring rsc entry - part of vdev rsc entry */
+       {RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0},
+       {RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0},
+};
+
+const void *get_resource_table (int rsc_id, int *len)
+{
+       (void) rsc_id;
+       *len = sizeof(resources);
+       return &resources;
+}
diff --git a/apps/system/linux/machine/generic/rsc_table.h b/apps/system/linux/machine/generic/rsc_table.h
new file mode 100644 (file)
index 0000000..698a6f3
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2016 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include <stddef.h>
+#include "openamp/open_amp.h"
+
+#define NO_RESOURCE_ENTRIES         1
+
+/* Resource table for the given remote */
+struct remote_resource_table {
+       unsigned int version;
+       unsigned int num;
+       unsigned int reserved[2];
+       unsigned int offset[NO_RESOURCE_ENTRIES];
+       /* rpmsg vdev entry */
+       struct fw_rsc_vdev rpmsg_vdev;
+       struct fw_rsc_vdev_vring rpmsg_vring0;
+       struct fw_rsc_vdev_vring rpmsg_vring1;
+};