From 73e7150785c60d3cf6c236a3f22787b46045fd48 Mon Sep 17 00:00:00 2001 From: Kinjal Pravinbhai Patel Date: Mon, 27 Jul 2015 17:19:42 +0530 Subject: [PATCH] sw_apps: openamp: modified rpc_demp application This patch modifies openamp rpc_demo 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_rpc_demo/src/baremetal.c | 55 ++++++++------------ lib/sw_apps/openamp_rpc_demo/src/rpc_demo.c | 12 ----- 2 files changed, 23 insertions(+), 44 deletions(-) diff --git a/lib/sw_apps/openamp_rpc_demo/src/baremetal.c b/lib/sw_apps/openamp_rpc_demo/src/baremetal.c index 2e559fe1..2b225aae 100644 --- a/lib/sw_apps/openamp_rpc_demo/src/baremetal.c +++ b/lib/sw_apps/openamp_rpc_demo/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_rpc_demo/src/rpc_demo.c b/lib/sw_apps/openamp_rpc_demo/src/rpc_demo.c index d44d5f96..c45e20b1 100755 --- a/lib/sw_apps/openamp_rpc_demo/src/rpc_demo.c +++ b/lib/sw_apps/openamp_rpc_demo/src/rpc_demo.c @@ -108,14 +108,6 @@ extern const struct remote_resource_table resources; #define REDEF_O_APPEND 2000 #define REDEF_O_ACCMODE 3 -/* - * 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*/ - #define RPC_CHANNEL_READY_TO_CLOSE "rpc_channel_ready_to_close" /* Application entry point */ @@ -248,10 +240,6 @@ static void shutdown_cb(struct rpmsg_channel *rp_chnl) { 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();