summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3b5e7fe)
raw | patch | inline | side by side (parent: 3b5e7fe)
author | Justin Sobota <jsobota@ti.com> | |
Mon, 18 Mar 2013 20:39:02 +0000 (16:39 -0400) | ||
committer | Justin Sobota <jsobota@ti.com> | |
Mon, 18 Mar 2013 20:39:02 +0000 (16:39 -0400) |
12 files changed:
src/rm_allocator.c | patch | blob | history | |
test/k2h/c66/bios/rmK2HC66BiosSharedTestProject.txt | [new file with mode: 0644] | patch | blob |
test/k2h/c66/bios/rm_shared_test.cfg | [new file with mode: 0644] | patch | blob |
test/k2h/c66/bios/rm_test.cfg | patch | blob | history | |
test/k2k/c66/bios/rmK2KC66BiosSharedTestProject.txt | [new file with mode: 0644] | patch | blob |
test/k2k/c66/bios/rm_shared_test.cfg | [new file with mode: 0644] | patch | blob |
test/k2k/c66/bios/rm_test.cfg | patch | blob | history | |
test/rm_osal.c | patch | blob | history | |
test/rm_shared_osal.c | [new file with mode: 0644] | patch | blob |
test/rm_shared_test.c | [new file with mode: 0644] | patch | blob |
test/rm_test.c | patch | blob | history | |
test/rm_transport_setup.c | [new file with mode: 0644] | patch | blob |
diff --git a/src/rm_allocator.c b/src/rm_allocator.c
index a9ec8af3332f0f4d647053db6c6ba7a385473de8..c8dd87d45f93697ebd1bcf81e9e99fd5480588cc 100644 (file)
--- a/src/rm_allocator.c
+++ b/src/rm_allocator.c
node->allocationCount++;
newOwner->instNameNode->allocRefCount++;
+ RM_SS_OBJ_WB(newOwner, Rm_Owner);
RM_SS_OBJ_WB(newOwner->instNameNode, Rm_PolicyValidInstNode);
}
}
diff --git a/test/k2h/c66/bios/rmK2HC66BiosSharedTestProject.txt b/test/k2h/c66/bios/rmK2HC66BiosSharedTestProject.txt
--- /dev/null
@@ -0,0 +1,9 @@
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/rm_shared_test.c"
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/dts_files/global-resources.c"
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/dts_files/linux-evm.c"
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/dts_files/server-policy.c"
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/rm_shared_osal.c"
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/k2h/c66/bios/rm_shared_test.cfg"
+-ccs.setCompilerOptions "-mv6600 -g -DDEVICE_K2H --diag_warning=225 -I${PDK_INSTALL_PATH}/ti/drv/rm"
+-rtsc.enableRtsc
+
diff --git a/test/k2h/c66/bios/rm_shared_test.cfg b/test/k2h/c66/bios/rm_shared_test.cfg
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * 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.
+ *
+ * * Neither the name of Texas Instruments Incorporated 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 OWNER 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.
+ * */
+
+var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
+
+/*
+ * Get the list of names that the build device supports.
+ * I.e. ["CORE0", "CORE1", "CORE2" ... ]
+ */
+var nameList = ["CORE0", "CORE1"];
+
+/*
+ * Since this is a single-image example, we don't (at build-time) which
+ * processor we're building for. We therefore supply 'null'
+ * as the local procName and allow IPC to set the local procId at runtime.
+ */
+MultiProc.setConfig(null, nameList);
+
+/*
+ * The SysStd System provider is a good one to use for debugging
+ * but does not have the best performance. Use xdc.runtime.SysMin
+ * for better performance.
+ */
+var System = xdc.useModule('xdc.runtime.System');
+var SysStd = xdc.useModule('xdc.runtime.SysStd');
+System.SupportProxy = SysStd;
+
+/* Modules explicitly used in the application */
+var MessageQ = xdc.useModule('ti.sdo.ipc.MessageQ');
+var Ipc = xdc.useModule('ti.sdo.ipc.Ipc');
+var HeapBufMP = xdc.useModule('ti.sdo.ipc.heaps.HeapBufMP');
+var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
+
+/* BIOS/XDC modules */
+var BIOS = xdc.useModule('ti.sysbios.BIOS');
+BIOS.heapSize = 0x10000;
+var Task = xdc.useModule('ti.sysbios.knl.Task');
+
+Program.sectMap[".rmTestSharedHandle"] = new Program.SectionSpec();
+Program.sectMap[".rmTestSharedHandle"] = "MSMCSRAM";
+
+/* Read once when RM_SHARED_SERVER is initialized */
+Program.sectMap[".sharedGRL"] = new Program.SectionSpec();
+Program.sectMap[".sharedGRL"] = "L2SRAM";
+
+Program.sectMap[".sharedGlobalPolicy"] = new Program.SectionSpec();
+Program.sectMap[".sharedGlobalPolicy"] = "MSMCSRAM";
+
+/* Synchronize all processors (this will be done in Ipc_start) */
+Ipc.procSync = Ipc.ProcSync_ALL;
+
+/*
+ * Need to define the shared region. The IPC modules use this
+ * to make portable pointers. All processors need to add this
+ * call with their base address of the shared memory region.
+ * If the processor cannot access the memory, do not add it.
+ */
+var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
+SharedRegion.translate = false;
+SharedRegion.setEntryMeta(0,
+ { base: 0x0C000000,
+ len: 0x00100000,
+ ownerProcId: 0,
+ isValid: true,
+ name: "sharemem",
+ });
+
+/* PDK packages */
+var devType = "k2h"
+var Csl = xdc.useModule('ti.csl.Settings');
+Csl.deviceType = devType;
+var Rm = xdc.loadPackage('ti.drv.rm');
+
+
index 7f6dd12eb9a2e6aa8c8d2cc820125f4943a3d6c7..2356ce7670dfbe0c33ad41e34fbef6182edb8078 100644 (file)
* Get the list of names that the build device supports.
* I.e. ["CORE0", "CORE1", "CORE2" ... ]
*/
-// var nameList = MultiProc.getDeviceProcNames();
var nameList = ["CORE0", "CORE1"];
/*
BIOS.heapSize = 0x10000;
var Task = xdc.useModule('ti.sysbios.knl.Task');
-Program.sectMap[".syncObj"] = new Program.SectionSpec();
-Program.sectMap[".syncObj"] = "MSMCSRAM";
+Program.sectMap[".sharedGRL"] = new Program.SectionSpec();
+Program.sectMap[".sharedGRL"] = "L2SRAM";
+
+Program.sectMap[".sharedGlobalPolicy"] = new Program.SectionSpec();
+Program.sectMap[".sharedGlobalPolicy"] = "L2SRAM";
/* Synchronize all processors (this will be done in Ipc_start) */
Ipc.procSync = Ipc.ProcSync_ALL;
diff --git a/test/k2k/c66/bios/rmK2KC66BiosSharedTestProject.txt b/test/k2k/c66/bios/rmK2KC66BiosSharedTestProject.txt
--- /dev/null
@@ -0,0 +1,9 @@
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/rm_shared_test.c"
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/dts_files/global-resources.c"
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/dts_files/linux-evm.c"
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/dts_files/server-policy.c"
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/rm_shared_osal.c"
+-ccs.linkFile "PDK_INSTALL_PATH/ti/drv/rm/test/k2k/c66/bios/rm_shared_test.cfg"
+-ccs.setCompilerOptions "-mv6600 -g -DDEVICE_K2K --diag_warning=225 -I${PDK_INSTALL_PATH}/ti/drv/rm"
+-rtsc.enableRtsc
+
diff --git a/test/k2k/c66/bios/rm_shared_test.cfg b/test/k2k/c66/bios/rm_shared_test.cfg
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * 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.
+ *
+ * * Neither the name of Texas Instruments Incorporated 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 OWNER 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.
+ * */
+
+var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
+
+/*
+ * Get the list of names that the build device supports.
+ * I.e. ["CORE0", "CORE1", "CORE2" ... ]
+ */
+var nameList = ["CORE0", "CORE1"];
+
+/*
+ * Since this is a single-image example, we don't (at build-time) which
+ * processor we're building for. We therefore supply 'null'
+ * as the local procName and allow IPC to set the local procId at runtime.
+ */
+MultiProc.setConfig(null, nameList);
+
+/*
+ * The SysStd System provider is a good one to use for debugging
+ * but does not have the best performance. Use xdc.runtime.SysMin
+ * for better performance.
+ */
+var System = xdc.useModule('xdc.runtime.System');
+var SysStd = xdc.useModule('xdc.runtime.SysStd');
+System.SupportProxy = SysStd;
+
+/* Modules explicitly used in the application */
+var MessageQ = xdc.useModule('ti.sdo.ipc.MessageQ');
+var Ipc = xdc.useModule('ti.sdo.ipc.Ipc');
+var HeapBufMP = xdc.useModule('ti.sdo.ipc.heaps.HeapBufMP');
+var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
+
+/* BIOS/XDC modules */
+var BIOS = xdc.useModule('ti.sysbios.BIOS');
+BIOS.heapSize = 0x10000;
+var Task = xdc.useModule('ti.sysbios.knl.Task');
+
+Program.sectMap[".rmTestSharedHandle"] = new Program.SectionSpec();
+Program.sectMap[".rmTestSharedHandle"] = "MSMCSRAM";
+
+/* Read once when RM_SHARED_SERVER is initialized */
+Program.sectMap[".sharedGRL"] = new Program.SectionSpec();
+Program.sectMap[".sharedGRL"] = "L2SRAM";
+
+Program.sectMap[".sharedGlobalPolicy"] = new Program.SectionSpec();
+Program.sectMap[".sharedGlobalPolicy"] = "MSMCSRAM";
+
+/* Synchronize all processors (this will be done in Ipc_start) */
+Ipc.procSync = Ipc.ProcSync_ALL;
+
+/*
+ * Need to define the shared region. The IPC modules use this
+ * to make portable pointers. All processors need to add this
+ * call with their base address of the shared memory region.
+ * If the processor cannot access the memory, do not add it.
+ */
+var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
+SharedRegion.translate = false;
+SharedRegion.setEntryMeta(0,
+ { base: 0x0C000000,
+ len: 0x00100000,
+ ownerProcId: 0,
+ isValid: true,
+ name: "sharemem",
+ });
+
+/* PDK packages */
+var devType = "k2k"
+var Csl = xdc.useModule('ti.csl.Settings');
+Csl.deviceType = devType;
+var Rm = xdc.loadPackage('ti.drv.rm');
+
+
index 6d1dd1434f27e34081d15158c9e2d451922d38a7..586bca66e7f48bb6099d913dadd97380d291c57c 100644 (file)
* If the processor cannot access the memory, do not add it.
*/
var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
+SharedRegion.translate = false;
SharedRegion.setEntryMeta(0,
{ base: SHAREDMEM,
len: SHAREDMEMSIZE,
diff --git a/test/rm_osal.c b/test/rm_osal.c
index 7302871081d0dfb1a004ee624edb0735e86592f8..12ccad710b9e8bae7a6e88c48a1c2df1031ba9bc 100644 (file)
--- a/test/rm_osal.c
+++ b/test/rm_osal.c
/* BIOS Includes */
#include <ti/sysbios/BIOS.h>
-#include <ti/sysbios/knl/Task.h>
+#include <ti/sysbios/hal/Hwi.h>
#include <ti/sysbios/knl/Semaphore.h>
+/* CSL includes */
+#include <ti/csl/csl_cacheAux.h>
+#include <ti/csl/csl_xmcAux.h>
+
/**********************************************************************
****************************** Defines *******************************
**********************************************************************/
}
-/* FUNCTION PURPOSE: Critical section exit
+/* FUNCTION PURPOSE: Cache invalidate
***********************************************************************
* DESCRIPTION: The function is used to indicate that a block of memory is
* about to be accessed. If the memory block is cached then this
*/
void Osal_rmBeginMemAccess(void *ptr, uint32_t size)
{
-
+ uint32_t key;
+
+ /* TEMP: only do invalidate for MSMC */
+ if (((uint32_t)ptr) & 0x0C000000) {
+ /* Disable Interrupts */
+ key = Hwi_disable();
+
+ /* Cleanup the prefetch buffer also. */
+ CSL_XMC_invalidatePrefetchBuffer();
+
+#ifdef L2_CACHE
+ /* Invalidate L2 cache. This should invalidate L1D as well.
+ * Wait until operation is complete. */
+ CACHE_invL2 (ptr, size, CACHE_FENCE_WAIT);
+#else
+ /* Invalidate L1D cache and wait until operation is complete.
+ * Use this approach if L2 cache is not enabled */
+ CACHE_invL1d (ptr, size, CACHE_FENCE_WAIT);
+#endif
+
+ /* Reenable Interrupts. */
+ Hwi_restore(key);
+ }
+ return;
}
-/* FUNCTION PURPOSE: Critical section exit
+/* FUNCTION PURPOSE: Cache writeback
***********************************************************************
* DESCRIPTION: The function is used to indicate that the block of memory has
* finished being accessed. If the memory block is cached then the
*/
void Osal_rmEndMemAccess(void *ptr, uint32_t size)
{
-
+ uint32_t key;
+
+ /* TEMP: only do writeback for MSMC */
+ if (((uint32_t)ptr) & 0x0C000000) {
+ /* Disable Interrupts */
+ key = Hwi_disable();
+
+#ifdef L2_CACHE
+ /* Writeback L2 cache. This should Writeback L1D as well.
+ * Wait until operation is complete. */
+ CACHE_wbL2 (ptr, size, CACHE_FENCE_WAIT);
+
+#else
+ /* Writeback L1D cache and wait until operation is complete.
+ * Use this approach if L2 cache is not enabled */
+ CACHE_wbL1d (ptr, size, CACHE_FENCE_WAIT);
+#endif
+
+ /* Reenable Interrupts. */
+ Hwi_restore(key);
+ }
+ return;
}
/* FUNCTION PURPOSE: Creates a task blocking object
diff --git a/test/rm_shared_osal.c b/test/rm_shared_osal.c
--- /dev/null
+++ b/test/rm_shared_osal.c
@@ -0,0 +1,254 @@
+/**
+ * @file rm_osal.c
+ *
+ * @brief
+ * This is the OS abstraction layer used by the Resource Manager.
+ *
+ * \par
+ * ============================================================================
+ * @n (C) Copyright 2012-2013, Texas Instruments, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 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.
+ *
+ * Neither the name of Texas Instruments Incorporated 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
+ * OWNER 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.
+ *
+ * \par
+*/
+
+/* Standard Includes */
+#include <stdarg.h>
+
+/* XDC Includes */
+#include <xdc/std.h>
+#include <xdc/runtime/Memory.h>
+#include <xdc/runtime/Error.h>
+#include <xdc/runtime/System.h>
+
+/* BIOS Includes */
+#include <ti/sysbios/BIOS.h>
+#include <ti/sysbios/hal/Hwi.h>
+#include <ti/sysbios/knl/Semaphore.h>
+
+/* IPC includes */
+#include <ti/ipc/SharedRegion.h>
+
+/* CSL includes */
+#include <ti/csl/csl_semAux.h>
+#include <ti/csl/csl_cacheAux.h>
+#include <ti/csl/csl_xmcAux.h>
+
+/**********************************************************************
+ ****************************** Defines *******************************
+ **********************************************************************/
+
+/* Try to avoid conflict with GateMP in rm_shared_test.c */
+#define RM_HW_SEM 4
+
+/**********************************************************************
+ ************************** Global Variables **************************
+ **********************************************************************/
+uint32_t rmMallocCounter = 0;
+uint32_t rmFreeCounter = 0;
+
+/**********************************************************************
+ *************************** OSAL Functions **************************
+ **********************************************************************/
+
+/* FUNCTION PURPOSE: Allocates memory
+ ***********************************************************************
+ * DESCRIPTION: The function is used to allocate a memory block of the
+ * specified size.
+ */
+void *Osal_rmMalloc (uint32_t num_bytes)
+{
+ Error_Block errorBlock;
+
+ /* Increment the allocation counter. */
+ rmMallocCounter++;
+
+ /* Allocate memory. */
+ return Memory_alloc(SharedRegion_getHeap(0), num_bytes, 0, &errorBlock);
+}
+
+/* FUNCTION PURPOSE: Frees memory
+ ***********************************************************************
+ * DESCRIPTION: The function is used to free a memory block of the
+ * specified size.
+ */
+void Osal_rmFree (void *ptr, uint32_t size)
+{
+ /* Increment the free counter. */
+ rmFreeCounter++;
+ Memory_free(SharedRegion_getHeap(0), ptr, size);
+}
+
+/* FUNCTION PURPOSE: Critical section enter
+ ***********************************************************************
+ * DESCRIPTION: The function is used to enter a critical section.
+ * Function protects against
+ *
+ * access from multiple cores
+ * and
+ * access from multiple threads on single core
+ */
+void *Osal_rmCsEnter(void)
+{
+ /* Get the hardware semaphore for protection against multiple core access */
+ while ((CSL_semAcquireDirect (RM_HW_SEM)) == 0);
+ return NULL;
+}
+
+/* FUNCTION PURPOSE: Critical section exit
+ ***********************************************************************
+ * DESCRIPTION: The function is used to exit a critical section
+ * protected using Osal_cppiCsEnter() API.
+ */
+void Osal_rmCsExit(void *CsHandle)
+{
+ /* Release the hardware semaphore */
+ CSL_semReleaseSemaphore (RM_HW_SEM);
+}
+
+/* FUNCTION PURPOSE: Cache invalidate
+ ***********************************************************************
+ * DESCRIPTION: The function is used to indicate that a block of memory is
+ * about to be accessed. If the memory block is cached then this
+ * indicates that the application would need to ensure that the
+ * cache is updated with the data from the actual memory.
+ */
+void Osal_rmBeginMemAccess(void *ptr, uint32_t size)
+{
+ uint32_t key;
+
+ /* Disable Interrupts */
+ key = Hwi_disable();
+
+ /* Cleanup the prefetch buffer also. */
+ CSL_XMC_invalidatePrefetchBuffer();
+
+#ifdef L2_CACHE
+ /* Invalidate L2 cache. This should invalidate L1D as well.
+ * Wait until operation is complete. */
+ CACHE_invL2 (ptr, size, CACHE_FENCE_WAIT);
+#else
+ /* Invalidate L1D cache and wait until operation is complete.
+ * Use this approach if L2 cache is not enabled */
+ CACHE_invL1d (ptr, size, CACHE_FENCE_WAIT);
+#endif
+
+ /* Reenable Interrupts. */
+ Hwi_restore(key);
+ return;
+}
+
+/* FUNCTION PURPOSE: Cache writeback
+ ***********************************************************************
+ * DESCRIPTION: The function is used to indicate that the block of memory has
+ * finished being accessed. If the memory block is cached then the
+ * application would need to ensure that the contents of the cache
+ * are updated immediately to the actual memory.
+ */
+void Osal_rmEndMemAccess(void *ptr, uint32_t size)
+{
+ uint32_t key;
+
+ /* Disable Interrupts */
+ key = Hwi_disable();
+
+#ifdef L2_CACHE
+ /* Writeback L2 cache. This should Writeback L1D as well.
+ * Wait until operation is complete. */
+ CACHE_wbL2 (ptr, size, CACHE_FENCE_WAIT);
+
+#else
+ /* Writeback L1D cache and wait until operation is complete.
+ * Use this approach if L2 cache is not enabled */
+ CACHE_wbL1d (ptr, size, CACHE_FENCE_WAIT);
+#endif
+
+ /* Reenable Interrupts. */
+ Hwi_restore(key);
+ return;
+}
+
+/* FUNCTION PURPOSE: Creates a task blocking object
+ ***********************************************************************
+ * DESCRIPTION: The function is used to create a task blocking object
+ * capable of blocking the task a RM instance is running
+ * within
+ */
+void *Osal_rmTaskBlockCreate(void)
+{
+ Semaphore_Params semParams;
+
+ Semaphore_Params_init(&semParams);
+ return((void *)Semaphore_create(0, &semParams, NULL));
+}
+
+/* FUNCTION PURPOSE: Blocks a RM instance
+ ***********************************************************************
+ * DESCRIPTION: The function is used to block a task whose context a
+ * RM instance is running within.
+ */
+void Osal_rmTaskBlock(void *handle)
+{
+ Semaphore_pend((Semaphore_Handle)handle, BIOS_WAIT_FOREVER);
+}
+
+/* FUNCTION PURPOSE: unBlocks a RM instance
+ ***********************************************************************
+ * DESCRIPTION: The function is used to unblock a task whose context a
+ * RM instance is running within.
+ */
+void Osal_rmTaskUnblock(void *handle)
+{
+ Semaphore_post((Semaphore_Handle)handle);
+}
+
+/* FUNCTION PURPOSE: Deletes a task blocking object
+ ***********************************************************************
+ * DESCRIPTION: The function is used to delete a task blocking object
+ * provided to a RM instance
+ */
+void Osal_rmTaskBlockDelete(void *handle)
+{
+ Semaphore_delete((Semaphore_Handle *)&handle);
+}
+
+/* FUNCTION PURPOSE: Prints a variable list
+ ***********************************************************************
+ * DESCRIPTION: The function is used to print a string to the console
+ */
+void Osal_rmLog (char *fmt, ... )
+{
+ VaList ap;
+
+ va_start(ap, fmt);
+ System_vprintf(fmt, ap);
+ va_end(ap);
+}
+
diff --git a/test/rm_shared_test.c b/test/rm_shared_test.c
--- /dev/null
+++ b/test/rm_shared_test.c
@@ -0,0 +1,806 @@
+/*
+ * rm_shared_test.c
+ *
+ * Multicore Resource Manager test that uses the RM shared server to
+ * request resources from multiple cores.
+ *
+ * ============================================================================
+ *
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * 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.
+ *
+ * * Neither the name of Texas Instruments Incorporated 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 OWNER 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.
+ *
+ */
+
+/* Standard Includes */
+#include <string.h>
+
+/* XDC Includes */
+#include <xdc/std.h>
+#include <xdc/runtime/System.h>
+
+/* IPC Includes */
+#include <ti/ipc/Ipc.h>
+#include <ti/ipc/GateMP.h>
+
+/* BIOS Includes */
+#include <ti/sysbios/BIOS.h>
+#include <ti/sysbios/knl/Task.h>
+#include <ti/sysbios/family/c64p/Hwi.h>
+
+/* CSL Includes */
+#include <ti/csl/csl_chip.h>
+#include <ti/csl/csl_cacheAux.h>
+#include <ti/csl/csl_xmcAux.h>
+
+/* RM Includes */
+#include <ti/drv/rm/rm.h>
+#include <ti/drv/rm/rm_services.h>
+#include <ti/drv/rm/rm_osal.h>
+
+/**********************************************************************
+ ********************** RM Shared Test Symbols ************************
+ **********************************************************************/
+
+#define SYSINIT 0
+#define NUM_CORES 2
+
+/* Test FALSE */
+#define RM_TEST_FALSE 0
+/* Test TRUE */
+#define RM_TEST_TRUE 1
+
+/* Test cache align */
+#define RM_TEST_MAX_CACHE_ALIGN 128
+
+/* RM packet heap name */
+#define RM_PKT_HEAP_NAME "rmHeapBuf"
+/* Name of GateMP used to synchronize the RM test tasks */
+#define RM_TASK_GATE_NAME "rmGateMP"
+
+/* Error checking macro */
+#define ERROR_CHECK(checkVal, resultVal, rmInstName, printMsg) \
+ if (resultVal != checkVal) { \
+ char errorMsgToPrint[] = printMsg; \
+ System_printf("Error Core %d : %s : ", coreNum, rmInstName); \
+ System_printf("%s with error code : %d\n", errorMsgToPrint, resultVal); \
+ System_abort("Test Failure\n"); \
+ }
+
+/**********************************************************************
+ ****************** RM Shared Test Data Structures ********************
+ **********************************************************************/
+
+typedef struct {
+ /* RM shared server handle */
+ Rm_Handle sharedServerHandle;
+ /** Padding required to make sure linker doesn't put something else
+ * on the same cache line. */
+ uint8_t pad[RM_TEST_MAX_CACHE_ALIGN - sizeof(Rm_Handle)];
+} Test_SharedRmHandle;
+
+/**********************************************************************
+ ********************** Extern Variables ******************************
+ **********************************************************************/
+
+/* RM test Global Resource List (GRL) */
+extern const char rmGRL[];
+/* Example Linux DTB file provided to RM Server for automatic Linux Kernel resource extraction */
+extern const char rmLinuxDtb[];
+/* RM test Global Policy provided to RM Server */
+extern const char rmGlobalPolicy[];
+
+/**********************************************************************
+ ********************** Global Variables ******************************
+ **********************************************************************/
+
+/* DSP core number according to IPC */
+uint16_t coreNum;
+
+/* Task to configure application transport code for RM */
+Task_Handle rmStartupTskHandle;
+/* RM server test task */
+Task_Handle rmServerTskHandle;
+/* RM client delegate and client test task */
+Task_Handle rmClientTskHandle;
+
+/* GateMP used to synchronize tests between the two RM test tasks */
+GateMP_Handle gateHandle = NULL;
+/* GateMP key */
+IArg gateKey;
+
+/* RM Server instance name (must match with RM Global Resource List (GRL) and policies */
+char rmServerName[RM_NAME_MAX_CHARS] = "RM_Server";
+
+/* RM shared server instance handle */
+#pragma DATA_SECTION (rmSharedHandle, ".rmTestSharedHandle");
+#pragma DATA_ALIGN (rmSharedHandle, RM_TEST_MAX_CACHE_ALIGN)
+Test_SharedRmHandle rmSharedHandle = {NULL};
+
+/* RM shared server instance service handle */
+Rm_ServiceHandle *rmSharedServiceHandle = NULL;
+
+/* RM resource names (must match resource node names in GRL and policies */
+char resourceNameMemRegion[RM_NAME_MAX_CHARS] = "memory-regions";
+char resourceNameAccumCh[RM_NAME_MAX_CHARS] = "accumulator-ch";
+char resourceNameGpQ[RM_NAME_MAX_CHARS] = "gp-queue";
+char resourceNameAifQ[RM_NAME_MAX_CHARS] = "aif-queue";
+char resourceNameQosCluster[RM_NAME_MAX_CHARS] = "qos-cluster";
+char resourceNameAifRxCh[RM_NAME_MAX_CHARS] = "aif-rx-ch";
+char resourceNameInfraQ[RM_NAME_MAX_CHARS] = "infra-queue";
+
+/* Test RM NameServer name */
+char nameServerNameFavQ[RM_NAME_MAX_CHARS] = "My_Favorite_Queue";
+
+/**********************************************************************
+ *************************** Test Functions ***************************
+ **********************************************************************/
+
+void setRmRequest(Rm_ServiceReqInfo *reqInfo, Rm_ServiceType type, const char *resName, int32_t resBase,
+ uint32_t resLen, int32_t resAlign, const char *nsName, int setCallback, Rm_ServiceRespInfo *respInfo)
+{
+ memset((void *)reqInfo, 0, sizeof(Rm_ServiceReqInfo));
+ reqInfo->type = type;
+ reqInfo->resourceName = resName;
+ reqInfo->resourceBase = resBase;
+ reqInfo->resourceLength = resLen;
+ reqInfo->resourceAlignment = resAlign;
+ reqInfo->resourceNsName = nsName;
+ if (setCallback) {
+ reqInfo->callback.serviceCallback = NULL;
+ }
+ memset((void *)respInfo, 0, sizeof(Rm_ServiceRespInfo));
+}
+
+void rmCleanupTsk(UArg arg0, UArg arg1)
+{
+ int32_t result;
+
+ /* Delete the RM test tasks */
+ System_printf("Core %d: Deleting RM startup task...\n", coreNum);
+ if (rmStartupTskHandle) {
+ Task_delete(&rmStartupTskHandle);
+ /* Set the task handle to be NULL so that the delete only occurs once */
+ rmStartupTskHandle = NULL;
+ }
+
+ if (coreNum == SYSINIT) {
+ if (rmServerTskHandle) {
+ System_printf("Core %d: Deleting RM server task...\n", coreNum);
+ Task_delete(&rmServerTskHandle);
+ /* Set the task handle to be NULL so that the delete only occurs once */
+ rmServerTskHandle = NULL;
+ }
+ }
+ else {
+ if (rmClientTskHandle) {
+ System_printf("Core %d: Deleting RM client task...\n", coreNum);
+ Task_delete(&rmClientTskHandle);
+ /* Set the task handle to be NULL so that the delete only occurs once */
+ rmClientTskHandle = NULL;
+ }
+ }
+
+ /* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
+ if (coreNum == SYSINIT) {
+ Rm_serviceCloseHandle(rmSharedServiceHandle);
+
+ result = Rm_delete(rmSharedHandle.sharedServerHandle, RM_TEST_TRUE);
+ ERROR_CHECK(RM_OK, result, rmServerName, "Instance deletion failed");
+ }
+
+ BIOS_exit(0);
+}
+
+void rmServerTsk(UArg arg0, UArg arg1)
+{
+ Rm_ServiceReqInfo requestInfo;
+ Rm_ServiceRespInfo responseInfo;
+ Task_Params taskParams;
+
+ Rm_instanceStatus(rmSharedHandle.sharedServerHandle);
+
+ /* BEGIN testing UNSPECIFIED base and alignment requests on Server */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
+ RM_RESOURCE_BASE_UNSPECIFIED, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s UNSPECIFIED base %d length %d alignment : ", coreNum,
+ rmServerName,
+ resourceNameGpQ,
+ requestInfo.resourceLength,
+ requestInfo.resourceAlignment);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
+ RM_RESOURCE_BASE_UNSPECIFIED, 1, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s UNSPECIFIED base %d length UNSPECIFIED alignment : ", coreNum,
+ rmServerName,
+ resourceNameGpQ,
+ requestInfo.resourceLength);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
+ RM_RESOURCE_BASE_UNSPECIFIED, 1, 200, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s UNSPECIFIED base %d length %d alignment : ", coreNum,
+ rmServerName,
+ resourceNameGpQ,
+ requestInfo.resourceLength,
+ requestInfo.resourceAlignment);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+ /* END testing UNSPECIFIED base and alignment requests on Server */
+
+ /* Create new NameServer object */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_MAP_TO_NAME, resourceNameGpQ,
+ 1002, 1, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s create name %s tied to %s %d - %d : ", coreNum,
+ rmServerName,
+ nameServerNameFavQ,
+ responseInfo.resourceName,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ /* Wait for CD and Client retrieve resource via name, allocate the resource, free resource via name, and
+ * delete the NameServer object. */
+ gateKey = GateMP_enter(gateHandle);
+ GateMP_leave(gateHandle, gateKey);
+
+ /* Try to allocate the memory region taken by the Linux Kernel and not specified as shared */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameMemRegion,
+ 12, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameMemRegion,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState != RM_SERVICE_APPROVED) {
+ System_printf("PASSED : denial or error : %d\n", responseInfo.serviceState);
+ }
+ else {
+ System_printf("FAILED : expected denial or error\n");
+ }
+
+ /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh,
+ 14, 5, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameAifRxCh,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh,
+ 19, 31, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameAifRxCh,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ /* Wait for Client and Client Delegate to do their allocations */
+ gateKey = GateMP_enter(gateHandle);
+ GateMP_leave(gateHandle, gateKey);
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh,
+ 25, 3, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s free of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameAifRxCh,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh,
+ 34, 3, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s free of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameAifRxCh,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, resourceNameAifRxCh,
+ 28, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s free of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameAifRxCh,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh,
+ 53, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameAifRxCh,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+ /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */
+
+ /* Wait for Client and Client Delegate to do their UNSPECIFIED allocates */
+ gateKey = GateMP_enter(gateHandle);
+ GateMP_leave(gateHandle, gateKey);
+
+ /* Test allocation of a resource twice from the same instance with init and use privileges. Both
+ * should be approved but the instance should only be mentioned once in the resource's owner list */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
+ 6543, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s init allocation of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameGpQ,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
+ 6543, 10, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameGpQ,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ /* Allocate infrastructure queue taken by Linux kernel and shared with Rm_Client. Expect error or denial. */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameInfraQ,
+ 805, 1, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s init allocation of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameInfraQ,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState != RM_SERVICE_APPROVED) {
+ System_printf("PASSED : denial or error : %d\n", responseInfo.serviceState);
+ }
+ else {
+ System_printf("FAILED : expected denial or error\n");
+ }
+
+ System_printf("Core %d: Testing is complete\n", coreNum);
+
+ Rm_instanceStatus(rmSharedHandle.sharedServerHandle);
+ Rm_resourceStatus(rmSharedHandle.sharedServerHandle, RM_TEST_TRUE);
+
+ /* Create the RM cleanup task. */
+ System_printf("Core %d: Creating RM cleanup task...\n", coreNum);
+ Task_Params_init (&taskParams);
+ Task_create (rmCleanupTsk, &taskParams, NULL);
+}
+
+void rmClientTsk(UArg arg0, UArg arg1)
+{
+ Rm_ServiceReqInfo requestInfo;
+ Rm_ServiceRespInfo responseInfo;
+ Task_Params taskParams;
+
+ Rm_instanceStatus(rmSharedHandle.sharedServerHandle);
+
+ /* Retrieve a resource via a NameServer name */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_GET_BY_NAME, NULL,
+ 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s get resource with name %s : ", coreNum,
+ rmServerName,
+ nameServerNameFavQ);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ /* Allocate the resource returned from the NameServer request */
+ memset((void *)&requestInfo, 0, sizeof(Rm_ServiceReqInfo));
+ requestInfo.type = Rm_service_RESOURCE_ALLOCATE_INIT;
+ requestInfo.resourceName = responseInfo.resourceName;
+ requestInfo.resourceBase = responseInfo.resourceBase;
+ requestInfo.resourceLength = responseInfo.resourceLength;
+ requestInfo.resourceNsName = NULL;
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s init allocation of %s %d - %d : ", coreNum,
+ rmServerName,
+ responseInfo.resourceName,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ /* Free resource via a NameServer name */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_FREE, NULL,
+ 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s free resource with name %s : ", coreNum,
+ rmServerName,
+ nameServerNameFavQ);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ /* Delete the NameServer name */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_UNMAP_NAME, NULL,
+ 0, 0, 0, nameServerNameFavQ, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s delete name %s : ", coreNum,
+ rmServerName,
+ nameServerNameFavQ);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ GateMP_leave(gateHandle, gateKey);
+ gateKey = GateMP_enter(gateHandle);
+
+ /* BEGIN testing expansion/contraction of resource nodes with the AIF RX CH resource */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh,
+ 0, 6, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameAifRxCh,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameAifRxCh,
+ 50, 7, 0, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s init allocation of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameAifRxCh,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+ /* END testing expansion/contraction of resource nodes with the AIF RX CH resource */
+
+ GateMP_leave(gateHandle, gateKey);
+ gateKey = GateMP_enter(gateHandle);
+
+ /* BEGIN testing allocations with UNSPECIFIED base and alignment values */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh,
+ RM_RESOURCE_BASE_UNSPECIFIED, 5, 4, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s UNSPECIFIED base %d length %d alignment : ", coreNum,
+ rmServerName,
+ resourceNameAccumCh,
+ requestInfo.resourceLength,
+ requestInfo.resourceAlignment);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh,
+ RM_RESOURCE_BASE_UNSPECIFIED, 2, 1, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s UNSPECIFIED base %d length %d alignment : ", coreNum,
+ rmServerName,
+ resourceNameAccumCh,
+ requestInfo.resourceLength,
+ requestInfo.resourceAlignment);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAccumCh,
+ RM_RESOURCE_BASE_UNSPECIFIED, 2, RM_RESOURCE_ALIGNMENT_UNSPECIFIED, NULL, RM_TEST_TRUE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation of %s UNSPECIFIED base %d length UNSPECIFIED alignment : ", coreNum,
+ rmServerName,
+ resourceNameAccumCh,
+ requestInfo.resourceLength);
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+ /* END testing allocations with UNSPECIFIED base and alignment values */
+
+ /* BEGIN Allocating some resources without providing a callback function. RM should block and not return until the result
+ * is returned by the server. */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
+ 7000, 1, 0, NULL, FALSE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s init allocation (without callback specified) of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameGpQ,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
+ 7005, 25, 0, NULL, FALSE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation (without callback specified) of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameGpQ,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameGpQ,
+ 7010, 5, 0, NULL, FALSE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation (without callback specified) of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameGpQ,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+
+ /* Init allocation of resource already owned by Client should return approved and the resource should
+ * only be shown as allocated once to the instance in the resource print out */
+ setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_INIT, resourceNameGpQ,
+ 7011, 1, 0, NULL, FALSE, &responseInfo);
+ rmSharedServiceHandle->Rm_serviceHandler(rmSharedServiceHandle->rmHandle, &requestInfo, &responseInfo);
+ System_printf("Core %d : %s use allocation (without callback specified) of %s %d - %d : ", coreNum,
+ rmServerName,
+ resourceNameGpQ,
+ requestInfo.resourceBase,
+ (requestInfo.resourceBase + requestInfo.resourceLength - 1));
+ if (responseInfo.serviceState == RM_SERVICE_APPROVED) {
+ System_printf("PASSED\n");
+ }
+ else {
+ System_printf("FAILED : denial or error : %d\n", responseInfo.serviceState);
+ }
+ /* END Allocating some resources without providing a callback function. RM should block and not return until the result
+ * is returned by the server. */
+
+ GateMP_leave(gateHandle, gateKey);
+
+ System_printf("Core %d: Testing is complete\n", coreNum);
+
+ Rm_instanceStatus(rmSharedHandle.sharedServerHandle);
+
+ /* Create the RM cleanup task. */
+ System_printf("Core %d: Creating RM cleanup task...\n", coreNum);
+ Task_Params_init (&taskParams);
+ Task_create (rmCleanupTsk, &taskParams, NULL);
+}
+
+void rmStartupTsk(UArg arg0, UArg arg1)
+{
+ Int status;
+ GateMP_Params gateParams;
+ Task_Params taskParams;
+
+ if (coreNum == SYSINIT) {
+ GateMP_Params_init(&gateParams);
+ gateParams.name = RM_TASK_GATE_NAME;
+ gateHandle = GateMP_create(&gateParams);
+ }
+ else {
+ do {
+ status = GateMP_open(RM_TASK_GATE_NAME, &gateHandle);
+ /*
+ * Sleep for 1 clock tick to avoid inundating remote processor
+ * with interrupts if open failed
+ */
+ if (status < 0) {
+ Task_sleep(1);
+ }
+ } while (status < 0);
+ /* Take the gate right away to prepare for RM testing */
+ gateKey = GateMP_enter(gateHandle);
+ }
+
+ /* Create the RM test tasks. */
+ if (coreNum == SYSINIT) {
+ System_printf("Core %d: Creating RM server task...\n", coreNum);
+ Task_Params_init (&taskParams);
+ taskParams.priority = 1;
+ rmServerTskHandle = Task_create (rmServerTsk, &taskParams, NULL);
+ }
+ else if (coreNum) {
+ System_printf("Core %d: Creating RM client task...\n", coreNum);
+ Task_Params_init (&taskParams);
+ taskParams.priority = 1;
+ rmClientTskHandle = Task_create (rmClientTsk, &taskParams, NULL);
+ }
+}
+
+int main(Int argc, Char* argv[])
+{
+ Rm_InitCfg rmInitCfg;
+ Task_Params taskParams;
+ int status;
+ int32_t result;
+
+ System_printf ("*********************************************************\n");
+ System_printf ("***************** RM Shared Server Test *****************\n");
+ System_printf ("*********************************************************\n");
+
+ System_printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
+
+ coreNum = CSL_chipReadReg(CSL_CHIP_DNUM);
+
+ /* Initialize the heap in shared memory. Using IPC module to do that */
+ System_printf("Core %d: Starting IPC...\n", coreNum);
+ status = Ipc_start();
+ if (status < 0) {
+ System_abort("Ipc_start failed\n");
+ }
+
+ /* Initialize the RM instances - RM must be initialized before anything else in the system
+ * Core 0: 1 RM Instance - RM Server
+ * Core 1: 2 RM Instances - RM Client Delegate
+ * RM Client
+ */
+ if (coreNum == SYSINIT) {
+ /* Create the Server instance */
+ rmInitCfg.instName = rmServerName;
+ rmInitCfg.instType = Rm_instType_SHARED_SERVER;
+ rmInitCfg.instCfg.serverCfg.globalResourceList = (void *)rmGRL;
+ rmInitCfg.instCfg.serverCfg.linuxDtb = (void *)rmLinuxDtb;
+ rmInitCfg.instCfg.serverCfg.globalPolicy = (void *)rmGlobalPolicy;
+ rmSharedHandle.sharedServerHandle = Rm_init(&rmInitCfg, &result);
+ ERROR_CHECK(RM_OK, result, rmServerName, "Initialization failed");
+
+ /* Open Server service handle */
+ rmSharedServiceHandle = Rm_serviceOpenHandle(rmSharedHandle.sharedServerHandle, &result);
+ ERROR_CHECK(RM_OK, result, rmServerName, "Service handle open failed");
+
+ Osal_rmEndMemAccess((void *)&rmSharedHandle, sizeof(Test_SharedRmHandle));
+ }
+ else {
+ do {
+ Osal_rmBeginMemAccess((void *)&rmSharedHandle, sizeof(Test_SharedRmHandle));
+ } while (!rmSharedHandle.sharedServerHandle);
+ rmSharedServiceHandle = Rm_serviceOpenHandle(rmSharedHandle.sharedServerHandle, &result);
+ ERROR_CHECK(RM_OK, result, rmServerName, "Service handle open failed");
+ }
+
+ /* Create the RM startup task */
+ System_printf("Core %d: Creating RM startup task...\n", coreNum);
+ Task_Params_init (&taskParams);
+ rmStartupTskHandle = Task_create (rmStartupTsk, &taskParams, NULL);
+
+ System_printf("Core %d: Starting BIOS...\n", coreNum);
+ BIOS_start();
+
+ return (0);
+}
+
diff --git a/test/rm_test.c b/test/rm_test.c
index bfd2fc2d0baf952949b2295410b7867e3da41e56..92414f4cd678163d8d437f1c29c46ead3e981840 100644 (file)
--- a/test/rm_test.c
+++ b/test/rm_test.c
#include <ti/ipc/Ipc.h>
#include <ti/ipc/MessageQ.h>
#include <ti/ipc/HeapBufMP.h>
-#include <ti/ipc/MultiProc.h>
#include <ti/ipc/GateMP.h>
/* BIOS Includes */
#include <ti/sysbios/family/c64p/Hwi.h>
/* CSL Includes */
+#include <ti/csl/csl_chip.h>
#include <ti/csl/csl_cacheAux.h>
#include <ti/csl/csl_xmcAux.h>
#include <ti/drv/rm/rm.h>
#include <ti/drv/rm/rm_transport.h>
#include <ti/drv/rm/rm_services.h>
+#include <ti/drv/rm/rm_osal.h>
/**********************************************************************
************************** RM Test Symbols ***************************
**********************************************************************/
+#define SYSINIT 0
+#define NUM_CORES 2
+
/* Test FALSE */
-#define RM_TEST_FALSE 0
+#define RM_TEST_FALSE 0
/* Test TRUE */
-#define RM_TEST_TRUE 1
+#define RM_TEST_TRUE 1
/* IPC MessageQ heap name */
#define MSGQ_HEAP_NAME "msgQHeapBuf"
*************************** Test Functions ***************************
**********************************************************************/
-void beginMemAccess (void *ptr, uint32_t size)
-{
- uint32_t key;
-
- key = Hwi_disable();
-
- /* Cleanup the prefetch buffer also. */
- CSL_XMC_invalidatePrefetchBuffer();
- /* Invalidate L1D cache and wait until operation is complete.
- * Use this approach if L2 cache is not enabled */
- CACHE_invL1d (ptr, size, CACHE_FENCE_WAIT);
- asm (" nop 4");
- asm (" nop 4");
- asm (" nop 4");
- asm (" nop 4");
- Hwi_restore(key);
-}
-
-void endMemAccess (void *ptr, uint32_t size)
-{
- uint32_t key;
-
- key = Hwi_disable();
-
- /* Writeback L1D cache and wait until operation is complete.
- * Use this approach if L2 cache is not enabled */
- CACHE_wbL1d (ptr, size, CACHE_FENCE_WAIT);
- asm (" nop 4");
- asm (" nop 4");
- asm (" nop 4");
- asm (" nop 4");
- Hwi_restore(key);
-}
-
Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle)
{
Rm_Packet *rmPkt = NULL;
/* Create and attach RM packet to MessageQ message. All transports will allocate from the same heap */
rmPkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0);
rmPkt->pktLenBytes = pktSize;
- endMemAccess((void *)rmPkt, rmPkt->pktLenBytes);
+ Osal_rmEndMemAccess((void *)rmPkt, rmPkt->pktLenBytes);
rmMsg->rmPkt = rmPkt;
*pktHandle = (Rm_PacketHandle)rmMsg;
}
@@ -299,7 +269,7 @@ int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHa
int32_t status;
/* Write back data that was written by RM after alloc */
- endMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes);
+ Osal_rmEndMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes);
/* Send the message to the remote side */
status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg);
/* Extract the Rm_Packet from the RM msg */
rmPkt = ((MsgQ_RmPacket *)rmMsg)->rmPkt;
- beginMemAccess((void *) rmPkt, rmPkt->pktLenBytes);
+ Osal_rmBeginMemAccess((void *) rmPkt, rmPkt->pktLenBytes);
/* Provide packet to RM for processing */
if (status = Rm_receivePacket(rmTransportMap[transportMapEntry].transportHandle, rmPkt)) {
rmStartupTskHandle = NULL;
}
- if (coreNum == 0) {
+ if (coreNum == SYSINIT) {
if (rmServerTskHandle) {
System_printf("Core %d: Deleting RM server task...\n", coreNum);
Task_delete(&rmServerTskHandle);
rmServerTskHandle = NULL;
}
}
- else if (coreNum == 1) {
+ else {
if (rmClientTskHandle) {
System_printf("Core %d: Deleting RM client task...\n", coreNum);
Task_delete(&rmClientTskHandle);
}
/* Cleanup all service ports, transport handles, RM instances, and IPC constructs */
- if (coreNum == 0) {
+ if (coreNum == SYSINIT) {
Rm_serviceCloseHandle(rmServerServiceHandle);
Rm_transportUnregister(rmTransportMap[SERVER_TO_CD_MAP_ENTRY].transportHandle);
System_printf("Core %d: RM server instance delete failed with error %d\n", coreNum, result);
}
}
- else if (coreNum == 1) {
+ else {
Rm_serviceCloseHandle(rmCdServiceHandle);
Rm_serviceCloseHandle(rmClientServiceHandle);
void rmReceiveTsk(UArg arg0, UArg arg1)
{
while(1) {
- if (coreNum == 0) {
+ if (coreNum == SYSINIT) {
transportReceive(SERVER_TO_CD_MAP_ENTRY);
}
- else if (coreNum == 1) {
+ else {
transportReceive(CD_TO_SERVER_MAP_ENTRY);
transportReceive(CD_TO_CLIENT_MAP_ENTRY);
transportReceive(CLIENT_TO_CD_MAP_ENTRY);
}
/* END testing expansion/contraction of resource nodes with the AIF RX CH resource */
- /* Test execlusive rights to an allocated resource */
+ /* Test exclusive rights to an allocated resource */
setRmRequest(&requestInfo, Rm_service_RESOURCE_ALLOCATE_USE, resourceNameAifRxCh,
2, 2, 0, NULL, RM_TEST_TRUE, &responseInfo);
rmServerServiceHandle->Rm_serviceHandler(rmServerServiceHandle->rmHandle, &requestInfo, &responseInfo);
rmTransportMap[i].transportHandle = NULL;
}
- if (coreNum == 0) {
+ if (coreNum == SYSINIT) {
GateMP_Params_init(&gateParams);
gateParams.name = RM_TASK_GATE_NAME;
gateHandle = GateMP_create(&gateParams);
* 1 queues on RM Server
* 2 queues on RM Client Delegate
* 1 queues on RM Client */
- if (coreNum == 0) {
+ if (coreNum == SYSINIT) {
serverFromCdMsgQ = MessageQ_create(serverFromCdQueueName, NULL);
if (serverFromCdMsgQ == NULL) {
System_abort("MessageQ_create failed for RM Server - Client Delegate queue\n" );
}
System_printf("Core %d: RM Server MessageQ created for receiving packets from RM CD\n", coreNum);
}
- else if (coreNum == 1) {
+ else {
cdFromServerMsgQ = MessageQ_create(cdFromServerQueueName, NULL);
if (cdFromServerMsgQ == NULL) {
System_abort("MessageQ_create failed for RM Client Delegate - Server queue\n" );
}
/* Open the remote message queues. Also register the RM transports with each RM instance */
- if (coreNum == 0) {
+ if (coreNum == SYSINIT) {
/* Open the Client Delegate messageQ from the Server */
do {
status = MessageQ_open(cdFromServerQueueName, &serverToCdQId);
rmTransportMap[SERVER_TO_CD_MAP_ENTRY].receiveMsgQ = serverFromCdMsgQ;
System_printf("Core %d: Registered RM Server <=> RM CD transport with RM Server instance\n", coreNum);
}
- else if (coreNum == 1) {
+ else {
/* Open the Server messageQ from the Client Delegate */
do {
status = MessageQ_open(serverFromCdQueueName, &cdToServerQId);
rmReceiveTskHandle = Task_create (rmReceiveTsk, &taskParams, NULL);
/* Create the RM test tasks. */
- if (coreNum == 0) {
+ if (coreNum == SYSINIT) {
System_printf("Core %d: Creating RM server task...\n", coreNum);
Task_Params_init (&taskParams);
taskParams.priority = 1;
System_printf ("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), Rm_getVersionStr());
- coreNum = MultiProc_self();
+ coreNum = CSL_chipReadReg(CSL_CHIP_DNUM);
/* Initialize the RM instances - RM must be initialized before anything else in the system
* Core 0: 1 RM Instance - RM Server
* Core 1: 2 RM Instances - RM Client Delegate
* RM Client
*/
- if (coreNum == 0) {
+ if (coreNum == SYSINIT) {
/* Create the Server instance */
rmInitCfg.instName = rmServerName;
rmInitCfg.instType = Rm_instType_SERVER;
rmServerServiceHandle = Rm_serviceOpenHandle(rmServerHandle, &result);
ERROR_CHECK(RM_OK, result, rmServerName, "Service handle open failed");
}
- else if (coreNum == 1) {
+ else {
/* Create the RM Client Delegate instance */
rmInitCfg.instName = rmCdName;
rmInitCfg.instType = Rm_instType_CLIENT_DELEGATE;
diff --git a/test/rm_transport_setup.c b/test/rm_transport_setup.c
--- /dev/null
@@ -0,0 +1,416 @@
+/*
+ * rm_transport_setup.c
+ *
+ * RM test application IPC transport setup code
+ *
+ * ============================================================================
+ *
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * 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.
+ *
+ * * Neither the name of Texas Instruments Incorporated 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 OWNER 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.
+ *
+ */
+
+/* XDC includes */
+#include <xdc/std.h>
+#include <xdc/runtime/IHeap.h>
+#include <xdc/runtime/System.h>
+
+/* IPC includes */
+#include <ti/ipc/Ipc.h>
+#include <ti/ipc/MessageQ.h>
+#include <ti/ipc/HeapBufMP.h>
+
+/* BIOS Includes */
+#include <ti/sysbios/knl/Task.h>
+
+/* RM Includes */
+#include <ti/drv/rm/rm_transport.h>
+
+/* CSL RL includes */
+#include <ti/csl/csl_chip.h>
+
+#define MAX_TEST_CORES 4
+
+/* IPC MessageQ heap name */
+#define MSGQ_HEAP_NAME "msgQHeapBuf"
+/* IPC MessageQ heap ID */
+#define MSGQ_HEAP_ID 0
+
+/* RM packet heap name */
+#define RM_PKT_HEAP_NAME "rmHeapBuf"
+
+/* IPC MessageQ RM packet encapsulation structure */
+typedef struct {
+ /* IPC MessageQ header (must be first element in structure) */
+ MessageQ_MsgHeader msgQHeader;
+ /* Pointer to RM packet */
+ Rm_Packet *rmPkt;
+} MsgQ_RmPacket;
+
+/* RM registered transport map. Maps a remote RM instance's transport
+ * handle to the receive MsgQ that packets from this RM instance will be
+ * received on. */
+typedef struct {
+ /* Registered destintation RM transport handle */
+ Rm_TransportHandle transportHandle;
+ /* MessageQ receive queue tied to the transport handle */
+ MessageQ_Handle receiveMsgQ;
+} Transport_MapEntry;
+
+/************************ GLOBAL VARIABLES ********************/
+/* Numer of cores used by the test */
+uint32_t testCores = 0;
+/* Test application's initialization core */
+uint32_t initCore = 0;
+/* Application test task pointer */
+Task_FuncPtr appTestTask = NULL;
+
+/* Handle for heap that RM packets will be allocated from */
+HeapBufMP_Handle rmPktHeapHandle = NULL;
+
+/* Transport map stores the RM transport handle to IPC MessageQ queue mapping */
+Transport_MapEntry rmTransportMap[MAX_TEST_CORES];
+
+/************************ EXTERN VARIABLES ********************/
+extern Rm_Handle rmHandle;
+
+extern void Osal_rmBeginMemAccess(void *ptr, uint32_t size);
+extern void Osal_rmEndMemAccess(void *ptr, uint32_t size);
+
+/*************************** FUNCTIONS ************************/
+
+Rm_Packet *rmTransPktAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle)
+{
+ Rm_Packet *rmPkt = NULL;
+ MsgQ_RmPacket *rmMsg = NULL;
+ uint32_t corenum = CSL_chipReadReg(CSL_CHIP_DNUM);
+
+ /* Allocate a messageQ message for containing the RM packet */
+ rmMsg = (MsgQ_RmPacket *)MessageQ_alloc(MSGQ_HEAP_ID, sizeof(MsgQ_RmPacket));
+ if (rmMsg == NULL) {
+ System_printf("Error Core %d : MessageQ_alloc failed to allocate RM packet\n", corenum);
+ *pktHandle = NULL;
+ return(NULL);
+ }
+ else {
+ /* Create and attach RM packet to MessageQ message. All transports will allocate from the same heap */
+ rmPkt = HeapBufMP_alloc(rmPktHeapHandle, pktSize, 0);
+ rmPkt->pktLenBytes = pktSize;
+ Osal_rmEndMemAccess((void *)rmPkt, rmPkt->pktLenBytes);
+ rmMsg->rmPkt = rmPkt;
+ *pktHandle = (Rm_PacketHandle)rmMsg;
+ }
+ return (rmPkt);
+}
+
+void rmTransPktFree (MessageQ_Msg rmMsgQMsg, Rm_Packet *pkt)
+{
+ uint32_t pktSize = pkt->pktLenBytes;
+ uint32_t corenum = CSL_chipReadReg(CSL_CHIP_DNUM);
+ int32_t status;
+
+ /* All transports will free rmPkts to the same heap */
+ HeapBufMP_free(rmPktHeapHandle, pkt, pktSize);
+
+ status = MessageQ_free(rmMsgQMsg);
+ if (status < 0) {
+ System_printf("Error Core %d : MessageQ_free of RM packet\n", corenum);
+ }
+}
+
+int32_t rmTransPktSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
+{
+ MessageQ_QueueId remoteQueueId = (MessageQ_QueueId)appTransport;
+ MsgQ_RmPacket *rmMsg = pktHandle;
+ uint32_t corenum = CSL_chipReadReg(CSL_CHIP_DNUM);
+ int32_t status;
+
+ /* Write back data that was written by RM after alloc */
+ Osal_rmEndMemAccess((void *)rmMsg->rmPkt, rmMsg->rmPkt->pktLenBytes);
+
+ /* Send the message to the remote side */
+ status = MessageQ_put(remoteQueueId, (MessageQ_Msg)rmMsg);
+ if (status < 0) {
+ rmTransPktFree((MessageQ_Msg)rmMsg, rmMsg->rmPkt);
+ System_printf("Error Core %d : MessageQ_put sending RM packet : %d\n", corenum, status);
+ }
+ return (status);
+}
+
+void rmTransPktRcv (uint32_t transportMapEntry)
+{
+ MessageQ_Handle receiveQ;
+ int32_t numPkts;
+ MessageQ_Msg rmMsg = NULL;
+ Rm_Packet *rmPkt = NULL;
+ uint32_t corenum = CSL_chipReadReg(CSL_CHIP_DNUM);
+ int32_t status;
+ uint32_t i;
+
+ /* Check if any packets available */
+ receiveQ = rmTransportMap[transportMapEntry].receiveMsgQ;
+ numPkts = (int32_t) MessageQ_count(receiveQ);
+
+ /* Process all available packets */
+ for (i = 0; i < numPkts; i++) {
+ status = (int32_t) MessageQ_get(receiveQ, &rmMsg, MessageQ_FOREVER);
+ if (rmMsg == NULL) {
+ System_printf("Error Core %d : NULL msg returned by MessageQ\n", corenum);
+ }
+
+ /* Extract the Rm_Packet from the RM msg */
+ rmPkt = ((MsgQ_RmPacket *)rmMsg)->rmPkt;
+ Osal_rmBeginMemAccess((void *) rmPkt, rmPkt->pktLenBytes);
+
+ /* Provide packet to RM for processing */
+ if (status = Rm_receivePacket(rmTransportMap[transportMapEntry].transportHandle, rmPkt)) {
+ System_printf("Error Core %d : Receiving RM packet : %d\n", corenum, status);
+ }
+
+ /* Free RM packet buffer and messageQ message */
+ rmTransPktFree(rmMsg, rmPkt);
+ }
+}
+
+void rmReceiveTsk(UArg arg0, UArg arg1)
+{
+ uint32_t corenum = CSL_chipReadReg(CSL_CHIP_DNUM);
+ int i;
+
+ while(1) {
+ /* Check the receive MessageQs for received RM packets */
+ for (i = 0; i < testCores; i++) {
+ if (((corenum == initCore) && (i != initCore)) ||
+ ((corenum != initCore) && (i == initCore))) {
+ rmTransPktRcv(i);
+ }
+ }
+ /* Sleep for 1ms so that usageTsk can run */
+ Task_sleep(1);
+ }
+}
+
+void configRmTransportTsk(UArg arg0, UArg arg1)
+{
+ int32_t result;
+ uint32_t corenum = 0;
+ uint32_t i;
+ HeapBufMP_Params heapBufParams;
+ HeapBufMP_Handle msgQHeapHandle;
+ int status;
+ char name[RM_NAME_MAX_CHARS];
+ MessageQ_QueueId remoteRcvQId;
+ Rm_TransportCfg rmTransportCfg;
+ Task_Params taskParams;
+
+ /* Get the core number. */
+ corenum = CSL_chipReadReg(CSL_CHIP_DNUM);
+
+ /* Initialize the transport map */
+ for (i = 0; i < testCores; i++) {
+ rmTransportMap[i].transportHandle = NULL;
+ }
+
+ /* Configure IPC as the application transport used by RM to communicate between instances
+ * on different cores. */
+ if (corenum == initCore) {
+ /* Create the heap that will be used to allocate RM messages. This
+ * heap is a multi-processor heap. It will be shared amongst
+ * all RM instances. */
+ HeapBufMP_Params_init(&heapBufParams);
+ heapBufParams.regionId = 0;
+ heapBufParams.name = RM_PKT_HEAP_NAME;
+ heapBufParams.numBlocks = 16;
+ heapBufParams.blockSize = sizeof(Rm_Packet);
+ rmPktHeapHandle = HeapBufMP_create(&heapBufParams);
+ if (rmPktHeapHandle == NULL) {
+ System_printf("Error Core %d : RM packet HeapBufMP_create failed \n", corenum);
+ }
+ else {
+ System_printf("Core %d : Created RM packet heap\n", corenum);
+ }
+
+ /* Create the heap that will be used to allocate messageQ messages. */
+ HeapBufMP_Params_init(&heapBufParams);
+ heapBufParams.regionId = 0;
+ heapBufParams.name = MSGQ_HEAP_NAME;
+ heapBufParams.numBlocks = 16;
+ heapBufParams.blockSize = sizeof(MsgQ_RmPacket);
+ msgQHeapHandle = HeapBufMP_create(&heapBufParams);
+ if (msgQHeapHandle == NULL) {
+ System_printf("Error Core %d : IPC MessageQ HeapBufMP_create failed \n", corenum);
+ }
+ else {
+ System_printf("Core %d : Created IPC MessageQ heap\n", corenum);
+ }
+ }
+ else {
+ /* Open the heaps created by initCore core. Loop until opened. */
+ do {
+ status = HeapBufMP_open(RM_PKT_HEAP_NAME, &rmPktHeapHandle);
+ /*
+ * Sleep for 1 clock tick to avoid inundating remote processor
+ * with interrupts if open failed
+ */
+ if (status < 0) {
+ Task_sleep(1);
+ }
+ } while (status < 0);
+ System_printf("Core %d : Created RM packet heap\n", corenum);
+
+ do {
+ status = HeapBufMP_open(MSGQ_HEAP_NAME, &msgQHeapHandle);
+ /*
+ * Sleep for 1 clock tick to avoid inundating remote processor
+ * with interrupts if open failed
+ */
+ if (status < 0) {
+ Task_sleep(1);
+ }
+ } while (status < 0);
+ System_printf("Core %d : Created IPC MessageQ heap\n", corenum);
+ }
+
+ /* Register the MessageQ heap with MessageQ */
+ MessageQ_registerHeap(msgQHeapHandle, MSGQ_HEAP_ID);
+
+ /* Setup the MessageQs required for RM instances to communicate */
+ for (i = 0; i < testCores; i++) {
+ if ((corenum == initCore) && (i != initCore)) {
+ /* RM Server core transport registration (Should run testCores-1 times) */
+
+ /* Create a queue to receive messages from a RM client core */
+ System_sprintf(name, "serverRcvQForClient%d", i);
+ rmTransportMap[i].receiveMsgQ = MessageQ_create(name, NULL);
+ if (rmTransportMap[i].receiveMsgQ == NULL) {
+ System_printf("Error Core %d : Failed to create receive Q for Client%d\n", corenum, i);
+ }
+ else {
+ System_printf("Core %d : Created receive Q for Client%d\n", corenum, i);
+ }
+
+ /* Open the RM Client core's receive MessageQ */
+ System_sprintf(name, "client%dRcvQForServer", i);
+ do {
+ status = MessageQ_open(name, &remoteRcvQId);
+ /*
+ * Sleep for 1 clock tick to avoid inundating remote processor
+ * with interrupts if open failed
+ */
+ if (status < 0) {
+ Task_sleep(1);
+ }
+ } while (status < 0);
+ System_printf("Core %d : Opened Client%d's receive Q for Server\n", corenum, i);
+
+ /* Register Client receive Q with Server */
+ rmTransportCfg.rmHandle = rmHandle;
+ rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) remoteRcvQId;
+ rmTransportCfg.remoteInstType = Rm_instType_CLIENT;
+ System_sprintf (name, "RM_Client%d", i);
+ rmTransportCfg.remoteInstName = name;
+ rmTransportCfg.transportCallouts.rmAllocPkt = rmTransPktAlloc;
+ rmTransportCfg.transportCallouts.rmSendPkt = rmTransPktSend;
+ rmTransportMap[i].transportHandle = Rm_transportRegister(&rmTransportCfg, &result);
+ }
+ else if ((corenum != initCore) && (i == initCore)) {
+ /* RM Client core transport registration (Should only run once) */
+
+ /* Create queue to receive messages from Server */
+ System_sprintf(name, "client%dRcvQForServer", corenum);
+ rmTransportMap[i].receiveMsgQ = MessageQ_create(name, NULL);
+ if (rmTransportMap[i].receiveMsgQ == NULL) {
+ System_printf("Error Core %d : Failed to create receive Q for Server\n", corenum);
+ }
+ else {
+ System_printf("Core %d : Created receive Q for Server\n", corenum);
+ }
+
+ /* Open the RM Server core's receive MessageQ for this core */
+ System_sprintf(name, "serverRcvQForClient%d", corenum);
+ do {
+ status = MessageQ_open(name, &remoteRcvQId);
+ /*
+ * Sleep for 1 clock tick to avoid inundating remote processor
+ * with interrupts if open failed
+ */
+ if (status < 0) {
+ Task_sleep(1);
+ }
+ } while (status < 0);
+ System_printf("Core %d : Opened Server's receive Q\n", corenum);
+
+ /* Register the Server receive Q */
+ rmTransportCfg.rmHandle = rmHandle;
+ rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) remoteRcvQId;
+ rmTransportCfg.remoteInstType = Rm_instType_SERVER;
+ System_sprintf (name, "RM_Server");
+ rmTransportCfg.remoteInstName = name;
+ rmTransportCfg.transportCallouts.rmAllocPkt = rmTransPktAlloc;
+ rmTransportCfg.transportCallouts.rmSendPkt = rmTransPktSend;
+ rmTransportMap[i].transportHandle = Rm_transportRegister(&rmTransportCfg, &result);
+ }
+ }
+
+ /* Create the RM receive task. Receive task has priority of 2 so that it pre-empts the appTestTask */
+ Task_Params_init (&taskParams);
+ taskParams.priority = 2;
+ Task_create (rmReceiveTsk, &taskParams, NULL);
+
+ /* Create the application test task */
+ Task_Params_init (&taskParams);
+ taskParams.priority = 1;
+ Task_create (appTestTask, &taskParams, NULL);
+}
+
+int setupRmTransConfig(uint32_t numTestCores, uint32_t systemInitCore, Task_FuncPtr testTask)
+{
+ Task_Params taskParams;
+
+ if (numTestCores > MAX_TEST_CORES) {
+ return (-1);
+ }
+
+ /* Store application core parameters */
+ testCores = numTestCores;
+ initCore = systemInitCore;
+
+ /* Store the applications testTask for creation after the configRmTransportTsk
+ * runs */
+ appTestTask = testTask;
+
+ /* Create the RM transport configuration task */
+ Task_Params_init (&taskParams);
+ taskParams.priority = 1;
+ Task_create (configRmTransportTsk, &taskParams, NULL);
+
+ return(0);
+}
+