From 31b60a04999428b27759f1ad6e48230c8c633768 Mon Sep 17 00:00:00 2001 From: Kinjal Pravinbhai Patel Date: Mon, 27 Jul 2015 17:19:41 +0530 Subject: [PATCH] sw_apps: openamp: modified echo_test application This patch modifies openamp echo_test application to remove the hardcoded shared memory region and support for the memory region configuration as per requirement of the code in MPU region settings Signed-off-by: Kinjal Pravinbhai Patel Acked-by: Anirudha Sarangi --- lib/sw_apps/openamp_echo_test/src/baremetal.c | 55 ++++++++----------- lib/sw_apps/openamp_echo_test/src/echo_test.c | 11 ---- 2 files changed, 23 insertions(+), 43 deletions(-) diff --git a/lib/sw_apps/openamp_echo_test/src/baremetal.c b/lib/sw_apps/openamp_echo_test/src/baremetal.c index 2e559fe1..2b225aae 100644 --- a/lib/sw_apps/openamp_echo_test/src/baremetal.c +++ b/lib/sw_apps/openamp_echo_test/src/baremetal.c @@ -36,6 +36,7 @@ #include "xil_cache.h" #include "xil_mmu.h" #include "baremetal.h" +#include "env.h" XScuGic InterruptController; @@ -87,38 +88,6 @@ void zynqMP_r5_irq_isr() { XScuGic_CPUWriteReg(&InterruptController,XSCUGIC_EOI_OFFSET, raw_irq); } -/*********************************************************************** - * - * - * zynqMP_r5_map_mem_region - * - * - * This function sets-up the region of memory based on the given - * attributes - * There is no MMU for R5, no need to map phy address to vrt_addr - * - * @param addr - Starting address of memory region - * @parma size - size of region - * @param attrib - Attributes for memory region - * - * - * OUTPUTS - * - * None - * - ***********************************************************************/ -void zynqMP_r5_map_mem_region(u32 addr, u32 size, u32 attrib) { - u32 Index, NumSize; - /* Calculating the number of MBs required for the shared region*/ - NumSize = size / 0x100000; - - /* Xil_SetTlbAttributes is designed to configure memory for 1MB - * region. The API is called multiple times to configure the number - * of MBs required by shared memory size (calculated as NumSize)*/ - for (Index = 0; Index < NumSize; Index ++) - Xil_SetTlbAttributes(addr + 0x100000 * Index, attrib); -} - /* *********************************************************************** * IPI handling @@ -230,6 +199,28 @@ void platform_cache_disable() { } void platform_map_mem_region(unsigned int va,unsigned int pa, unsigned int size,unsigned int flags) { + + unsigned int r5_flags; + + /* Assume DEVICE_SHARED if nothing indicates this is memory. */ + r5_flags = DEVICE_SHARED; + if (flags & SHARED_MEM) { + r5_flags = NORM_SHARED_NCACHE; + if (flags & WB_CACHE) { + r5_flags = NORM_SHARED_WB_WA; + } else if (flags & WT_CACHE) { + r5_flags = NORM_SHARED_WT_NWA; + } + } else if (flags & MEM_MAPPED) { + r5_flags = NORM_NSHARED_NCACHE; + if (flags & WB_CACHE) { + r5_flags = NORM_NSHARED_WB_WA; + } else if (flags & WT_CACHE) { + r5_flags = NORM_NSHARED_WT_NWA; + } + } + + Xil_SetMPURegion(pa, size, r5_flags | PRIV_RW_USER_RW); return; } diff --git a/lib/sw_apps/openamp_echo_test/src/echo_test.c b/lib/sw_apps/openamp_echo_test/src/echo_test.c index 412041dc..6d87e34b 100644 --- a/lib/sw_apps/openamp_echo_test/src/echo_test.c +++ b/lib/sw_apps/openamp_echo_test/src/echo_test.c @@ -86,14 +86,6 @@ #define SHUTDOWN_MSG 0xEF56A55A -/* - * Shared memory location as defined in linux device tree for remoteproc - * User may need to check with device tree of remoteproc and ensure the - * share memory address is same - */ -#define SHARED_MEMORY 0x3ED00000 -#define SHARED_SIZE 0x400000 /* size of the shared memory*/ - /* Internal functions */ static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl); static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl); @@ -156,9 +148,6 @@ static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len, static void init_system() { - /* configure MPU for shared memory region */ - zynqMP_r5_map_mem_region(SHARED_MEMORY, SHARED_SIZE, NORM_SHARED_NCACHE | PRIV_RW_USER_RW); - /* Initilaize GIC */ zynqMP_r5_gic_initialize();