]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/open-amp.git/commitdiff
Apps: platform init: ZynqMP r5: use libmetal dev
authorWendy Liang <jliang@xilinx.com>
Thu, 4 Aug 2016 16:56:15 +0000 (09:56 -0700)
committerWendy Liang <jliang@xilinx.com>
Thu, 13 Oct 2016 05:01:46 +0000 (22:01 -0700)
Use libmetal device in the platform initialization data

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

index 388c5043943d3b2659c85dece2fd6034a2a6ec11..bbca0ee7ba53d98f5c92c3df7f6afa893cd957be 100755 (executable)
  * DESCRIPTION
  *
  *       This file implements APIs to get platform specific
  * DESCRIPTION
  *
  *       This file implements APIs to get platform specific
- *       information for OpenAMP. 
+ *       information for OpenAMP.
  *
  **************************************************************************/
 
 #include "openamp/hil.h"
  *
  **************************************************************************/
 
 #include "openamp/hil.h"
+#include "openamp/remoteproc_plat.h"
+#include "platform_info.h"
 
 
-/* IPC Device parameters */
-#define SHM_ADDR                          (void *)0x3ED08000
-#define SHM_SIZE                          0x00200000
-#define IPI_BASEADDR                      0xff310000
 #define IPI_CHN_BITMASK                   0x01000000 /* IPI channel bit mask APU<->RPU0 */
 #define IPI_CHN_BITMASK                   0x01000000 /* IPI channel bit mask APU<->RPU0 */
-#define VRING0_IPI_INTR_VECT              0xFFFFFFFF
-#define VRING1_IPI_INTR_VECT              65
-#define MASTER_CPU_ID                     0
-#define REMOTE_CPU_ID                     1
+#define REMOTE_CPU_ID                     0
 
 /* -- FIX ME: ipi info is to be defined -- */
 struct ipi_info {
 
 /* -- FIX ME: ipi info is to be defined -- */
 struct ipi_info {
-       uint32_t ipi_base_addr;
        uint32_t ipi_chn_mask;
        uint32_t ipi_chn_mask;
+       int need_reg;
 };
 /* Reference implementation that show cases platform_get_cpu_info and 
  platform_get_for_firmware API implementation for Bare metal environment */
 
 extern struct hil_platform_ops zynqmp_r5_a53_proc_ops;
 
 };
 /* Reference implementation that show cases platform_get_cpu_info and 
  platform_get_for_firmware API implementation for Bare metal environment */
 
 extern struct hil_platform_ops zynqmp_r5_a53_proc_ops;
 
-static struct ipi_info chn_ipi_info = { IPI_BASEADDR, IPI_CHN_BITMASK };
-
-/**
- * This array provdes defnition of CPU nodes for master and remote
- * context. It contains two nodes beacuse the same file is intended
- * to use with both master and remote configurations. On zynq platform
- * only one node defintion is required for master/remote as there
- * are only two cores present in the platform.
- *
- * Only platform specific info is populated here. Rest of information
- * is obtained during resource table parsing.The platform specific
- * information includes;
- *
- * -CPU ID
- * -Shared Memory
- * -Interrupts
- * -Channel info.
- *
- * Although the channel info is not platform specific information
- * but it is conveneient to keep it in HIL so that user can easily
- * provide it without modifying the generic part.
- *
- * It is good idea to define hil_proc structure with platform
- * specific fields populated as this can be easily copied to hil_proc
- * structure passed as parameter in platform_get_processor_info. The
- * other option is to populate the required structures individually
- * and copy them one by one to hil_proc structure in platform_get_processor_info
- * function. The first option is adopted here.
- *
- *
- * 1) First node in the array is intended for the remote contexts and it
- *    defines Master CPU ID, shared memory, interrupts info, number of channels
- *    and there names. This node defines only one channel
- *   "rpmsg-openamp-demo-channel".
- *
- * 2)Second node is required by the master and it defines remote CPU ID,
- *   shared memory and interrupts info. In general no channel info is required by the
- *   Master node, however in baremetal master and linux remote case the linux
- *   rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
- *   channel info. This information is not required by the masters for baremetal
- *   remotes. 
- *
- */
-
-struct hil_proc proc_table[] = {
+static struct ipi_info chn_ipi_info[] = {
+       { IPI_CHN_BITMASK, 0},
+       { IPI_CHN_BITMASK, 1},
+};
 
 
-       /* CPU node for remote context */
+struct rproc_info_plat_local proc_table = {
        {
        {
-        /* CPU ID of master */
-        MASTER_CPU_ID,
-
-        /* HIL platform ops table. */
-        &zynqmp_r5_a53_proc_ops,
-
-        /* Shared memory info - Last field is not used currently */
-        {
-         SHM_ADDR, SHM_SIZE, 0x00},
-
-        /* VirtIO device info */
-        {
-         /* Leave these three fields empty as these are obtained from rsc
-          * table.
-          */
-         0, 0, 0,
+               /* CPU ID of master */
+               REMOTE_CPU_ID,
 
 
-         /* Vring info */
-         {
-
-          {
-           /* Provide only vring interrupts info here. Other fields are
-            * obtained from the resource table so leave them empty.
-            */
-           NULL, NULL, 0, 0,
-           {
-            VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
-            }
-           },
-          {
-           NULL, NULL, 0, 0,
-           {
-            VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
-            }
-           }
-          }
-         },
-
-        /* Number of RPMSG channels */
-        1,
-
-        /* RPMSG channel info - Only channel name is expected currently */
-        {
-         {"rpmsg-openamp-demo-channel"}
-         },
+               /* HIL platform ops table. */
+               &zynqmp_r5_a53_proc_ops,
+       },
+       /* vring0 ipi device and vring descriptors memory device */
+       {
+               PLAT_RSC_VRING,
+               "generic",
+               "ff310000.ipi",
+               &chn_ipi_info[0],
+               "generic",
+               "vrings",
+       },
+       /* vring0 ipi device and vring descriptors memory device */
+       {
+               PLAT_RSC_VRING,
+               "generic",
+               "ff310000.ipi",
+               &chn_ipi_info[1],
+               "generic",
+               "vrings",
+       },
+       /* Shared memory device */
+       {
+               PLAT_RSC_SHM,
+               "shm",
+               0,  /* UNDEFINED */
+       },
+       /* Shared memory device */
+       {
+               PLAT_RSC_RPMSG_CHANNEL,
+               "rpmsg-openamp-demo-channel",
+       },
+       PLAT_RSC_LAST,
+};
 
 
-        /* Next three fields are for future use only */
-        0,
+const struct firmware_info fw_table[] =
+{
+       {"unknown",
         0,
         0,
-        NULL,
-        {NULL, NULL}
-       },
+        0}
 };
 
 };
 
+int fw_table_size = sizeof(fw_table)/sizeof(struct firmware_info);
diff --git a/apps/machine/zynqmp_r5/platform_info.h b/apps/machine/zynqmp_r5/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;
+};
index 210ac56935d3e91f34fd9ae2e9630cd6b4923b5d..0a7222383caa925e52ce254ee6de4200f05f4bfe 100644 (file)
@@ -1,4 +1,5 @@
 collect (APP_COMMON_SOURCES helper.c)
 collect (APP_COMMON_SOURCES helper.c)
+collect (APP_COMMON_SOURCES sys_init.c)
 
 if (WITH_REMOTEPROC_MASTER)
   message(FATAL_ERROR "Remoteproc master is not currently supported on ${MACHINE}/${SYSTEM}.")
 
 if (WITH_REMOTEPROC_MASTER)
   message(FATAL_ERROR "Remoteproc master is not currently supported on ${MACHINE}/${SYSTEM}.")
index e2c8a966a9cf951fb3984a878f2418c1d8012b4b..d0d72dc3035c9132503d3f17c545f0190bd502aa 100644 (file)
@@ -41,6 +41,7 @@
 XScuGic InterruptController;
 
 extern void bm_env_isr(int vector);
 XScuGic InterruptController;
 
 extern void bm_env_isr(int vector);
+extern int platform_register_metal_device(void);
 
 void zynqmp_r5_irq_isr()
 {
 
 void zynqmp_r5_irq_isr()
 {
@@ -94,7 +95,11 @@ int zynqmp_r5_gic_initialize()
 
 void init_system()
 {
 
 void init_system()
 {
+       struct metal_init_params metal_param = METAL_INIT_DEFAULTS;
+
+       metal_init(&metal_param);
        zynqmp_r5_gic_initialize();
        zynqmp_r5_gic_initialize();
+       platform_register_metal_device();
 }
 
 void cleanup_system()
 }
 
 void cleanup_system()
diff --git a/apps/system/generic/machine/zynqmp_r5/sys_init.c b/apps/system/generic/machine/zynqmp_r5/sys_init.c
new file mode 100644 (file)
index 0000000..fd847f1
--- /dev/null
@@ -0,0 +1,142 @@
+
+/*
+ * 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 "xparameters.h"
+#include "xil_exception.h"
+#include "xscugic.h"
+#include "metal/sys.h"
+#include "metal/device.h"
+#include "metal/io.h"
+#include "metal/shmem.h"
+
+/** Device base address */
+#define IPI_BASE_ADDR           0xFF310000
+#define UNDEFINE_BASE_ADDR      0x0
+
+#define UNDEFINE_MEM_SIZE       0xFFFFFFFF
+
+/** IPI IRQ ID */
+#define IPI_IRQ_VECT_ID         65
+
+#define IPI_DEV_NAME            "ff310000.ipi"
+#define VRING_DEV_NAME          "vrings"
+#define SHM_NAME                "shm"
+
+const metal_phys_addr_t ipi_base_addr = IPI_BASE_ADDR;
+const metal_phys_addr_t undefine_mem_addr = UNDEFINE_BASE_ADDR;
+
+struct metal_device metal_dev_table[] = {
+       {
+               /* IPI device */
+               IPI_DEV_NAME,
+               NULL,
+               1,
+               {
+                       {
+                               (void *)IPI_BASE_ADDR,
+                               &ipi_base_addr,
+                               0x1000,
+                               (sizeof(metal_phys_addr_t) << 3),
+                               (unsigned long)(-1),
+                               METAL_UNCACHED,
+                               {NULL},
+                       }
+               },
+               {NULL},
+               1,
+               (void *)IPI_IRQ_VECT_ID,
+
+       },
+       {
+               /* Shared memory management device */
+               VRING_DEV_NAME,
+               NULL,
+               1,
+               {
+                       {
+                               (void *)UNDEFINE_BASE_ADDR,
+                               &undefine_mem_addr,
+                               UNDEFINE_MEM_SIZE,
+                               (sizeof(metal_phys_addr_t) << 3),
+                               (unsigned long)(-1),
+                               METAL_UNCACHED | METAL_SHARED_MEM,
+                               {NULL},
+                       }
+               },
+               {NULL},
+               0,
+               NULL,
+
+       },
+};
+
+struct metal_generic_shmem shm = {
+       SHM_NAME,
+       {
+               (void *)UNDEFINE_BASE_ADDR,
+               &undefine_mem_addr,
+               UNDEFINE_MEM_SIZE,
+               (sizeof(metal_phys_addr_t) << 3),
+               (unsigned long)(-1),
+               0,
+               {NULL},
+       },
+       {NULL, NULL},
+};
+
+/**
+ * This funciton is to install baremeta/RTOS libmetal devices.
+ */
+extern char RPROC_DEBUG[];
+int platform_register_metal_device(void)
+{
+       int i;
+       int ret;
+       struct metal_device *dev;
+
+       /* Register device */
+       metal_bus_register(&metal_generic_bus);
+       for (i = 0;
+            i < (int)(sizeof(metal_dev_table)/sizeof(struct metal_device));
+            i++) {
+               dev = &metal_dev_table[i];
+               ret = metal_register_generic_device(dev);
+               if (ret)
+                       return ret;
+       }
+
+       /* Register shared memory */
+       metal_shmem_register_generic(&shm);
+
+       return 0;
+}
+