summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bf25254)
raw | patch | inline | side by side (parent: bf25254)
author | Wendy Liang <jliang@xilinx.com> | |
Mon, 15 Aug 2016 22:47:07 +0000 (15:47 -0700) | ||
committer | Wendy Liang <jliang@xilinx.com> | |
Thu, 13 Oct 2016 05:01:48 +0000 (22:01 -0700) |
Add the Linux system and ZynqMP layer to do the ZynqMP
Linux system specific initialization.
Signed-off-by: Wendy Liang <jliang@xilinx.com>
Linux system specific initialization.
Signed-off-by: Wendy Liang <jliang@xilinx.com>
apps/machine/zynqmp/CMakeLists.txt | [new file with mode: 0644] | patch | blob |
apps/machine/zynqmp/platform_info.c | [new file with mode: 0755] | patch | blob |
apps/machine/zynqmp/platform_info.h | [new file with mode: 0644] | patch | blob |
apps/machine/zynqmp/rsc_table.c | [new file with mode: 0644] | patch | blob |
apps/machine/zynqmp/rsc_table.h | [new file with mode: 0644] | patch | blob |
apps/system/linux/CMakeLists.txt | [new file with mode: 0644] | patch | blob |
apps/system/linux/helper.c | [new file with mode: 0644] | patch | blob |
diff --git a/apps/machine/zynqmp/CMakeLists.txt b/apps/machine/zynqmp/CMakeLists.txt
--- /dev/null
@@ -0,0 +1,4 @@
+collect (APP_COMMON_SOURCES platform_info.c)
+collect (APP_COMMON_SOURCES rsc_table.c)
+collect (APP_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
+
diff --git a/apps/machine/zynqmp/platform_info.c b/apps/machine/zynqmp/platform_info.c
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 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 "openamp/remoteproc_plat.h"
+#include "metal/atomic.h"
+#include "platform_info.h"
+
+#define IPI_CHN_BITMASK 0x00000100 /* IPI channel bit mask APU<->RPU0 */
+#define REMOTE_CPU_ID 0
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_chn_mask;
+ int need_reg;
+ atomic_int sync;
+};
+/* 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_a53_r5_proc_ops;
+
+static struct ipi_info chn_ipi_info[] = {
+ { IPI_CHN_BITMASK, 1, 0},
+ { IPI_CHN_BITMASK, 0, 0},
+};
+
+struct rproc_info_plat_local proc_table = {
+ {
+ /* CPU ID of master */
+ REMOTE_CPU_ID,
+
+ /* HIL platform ops table. */
+ &zynqmp_a53_r5_proc_ops,
+ },
+ /* vring0 ipi device and vring descriptors memory device */
+ {
+ PLAT_RSC_VRING,
+ "platform",
+ "ff340000.ipi",
+ &chn_ipi_info[0],
+ "platform",
+ "3ed00000.vring",
+ },
+ /* vring0 ipi device and vring descriptors memory device */
+ {
+ PLAT_RSC_VRING,
+ "platform",
+ "ff340000.ipi",
+ &chn_ipi_info[1],
+ "platform",
+ "3ed00000.vring",
+ },
+ /* Shared memory device */
+ {
+ PLAT_RSC_SHM,
+ "shm",
+ 0, /* UNDEFINED, up to the I/O region size */
+ },
+ /* Shared memory device */
+ {
+ PLAT_RSC_RPMSG_CHANNEL,
+ "rpmsg-openamp-demo-channel",
+ },
+ PLAT_RSC_LAST,
+};
+
+const struct firmware_info fw_table[] =
+{
+ {"unknown",
+ 0,
+ 0}
+};
+
+int fw_table_size = sizeof(fw_table)/sizeof(struct firmware_info);
diff --git a/apps/machine/zynqmp/platform_info.h b/apps/machine/zynqmp/platform_info.h
--- /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/machine/zynqmp/rsc_table.c b/apps/machine/zynqmp/rsc_table.c
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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 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 0x3ED00000
+#define RING_RX 0x3ED04000
+#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},
+};
diff --git a/apps/machine/zynqmp/rsc_table.h b/apps/machine/zynqmp/rsc_table.h
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 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;
+};
diff --git a/apps/system/linux/CMakeLists.txt b/apps/system/linux/CMakeLists.txt
--- /dev/null
@@ -0,0 +1,13 @@
+collect (APP_COMMON_SOURCES helper.c)
+
+if (WITH_REMOTEPROC_MASTER)
+ message(FATAL_ERROR "Remoteproc master is not currently supported on ${MACHINE}/${SYSTEM}.")
+else (WITH_REMOTEPROC_MASTER)
+ set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_remote.ld")
+endif (WITH_REMOTEPROC_MASTER)
+
+set_property (GLOBAL PROPERTY APP_LINKER_SCRIPT "${_linker_script}")
+
+find_library(LIBXIL_LIB NAMES xil PATHS ${CMAKE_FIND_ROOT_PATH})
+get_filename_component(LIBXIL_LIB_DIR ${LIBXIL_LIB} DIRECTORY)
+collect(PROJECT_LIB_DIRS ${LIBXIL_LIB_DIR})
diff --git a/apps/system/linux/helper.c b/apps/system/linux/helper.c
--- /dev/null
@@ -0,0 +1,84 @@
+
+/*
+ * 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"
+
+#define SHM_DEV_NAME "3ed10000.shm"
+#define SHM_BUS_NAME "platform"
+
+static struct metal_device *shm_dev;
+static struct metal_generic_shmem shm;
+
+void init_system()
+{
+ int ret;
+ struct metal_io_region *io;
+ struct metal_init_params metal_param = METAL_INIT_DEFAULTS;
+
+ metal_init(&metal_param);
+
+ /* Register the UIO shared memory */
+ /* This will be a temporary solution, we should
+ * use DMA memory in fugure.
+ */
+ ret = metal_device_open(SHM_BUS_NAME, SHM_DEV_NAME, &shm_dev);
+ if (ret) {
+ fprintf(stderr, "ERROR: Failed to open shared memory device.\n");
+ return;
+ }
+ io = metal_device_io_region(shm_dev, 0);
+ if (!io) {
+ fprintf(stderr, "ERROR: Failed to get the I/O region of shared memory.\n");
+ return;
+ }
+
+ memset(&shm, 0, sizeof(struct metal_generic_shmem));
+ shm.name = "shm";
+ memcpy((void *)&shm.io, io, sizeof(struct metal_io_region));
+ ret = metal_shmem_register_generic(&shm);
+ if (ret) {
+ fprintf(stderr, "ERROR: Failed to registered shared memory.\n");
+ return;
+ }
+ return;
+}
+
+void cleanup_system()
+{
+ if (shm_dev)
+ metal_device_close(shm_dev);
+ metal_finish();
+}