Verified 8 channel DLB on K2G QT. Added K2G example with device file.
authorgovind-j <govind.j@ti.com>
Wed, 1 Apr 2015 16:38:09 +0000 (12:38 -0400)
committergovind-j <govind.j@ti.com>
Wed, 1 Apr 2015 16:38:09 +0000 (12:38 -0400)
Currently the K2G OSAL has a work-around to suit the QT K2K build.

15 files changed:
config.bld
device/k2g/device_mcbsp_loopback.c [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/MCBSP_DigLpbkExampleProject.txt [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/bios6_edma3_drv_sample.h [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/config.bld [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.c [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.cfg [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.cmd [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk_osal.c [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/sample_cs.c [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/sample_init.c [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/sample_k2g_cfg.c [new file with mode: 0644]
example/k2g/MCBSPDigLpbk/sample_k2g_int_reg.c [new file with mode: 0644]
example/k2g/mcbspMasterDigLpbk_osal.c [new file with mode: 0644]
setupenv.bat

index dfd8bc814d54a8857ba3a8374579c1151368f424..6592da2a8b823dd06c09fd07e7fb99d75010e1f9 100644 (file)
@@ -84,5 +84,5 @@ if (miniBuild == "ON")
 }
 
 /* List all the build targets here. */
-Build.targets = [ C66LE, C66BE ];
+Build.targets = [ C66LE ];
 
diff --git a/device/k2g/device_mcbsp_loopback.c b/device/k2g/device_mcbsp_loopback.c
new file mode 100644 (file)
index 0000000..eb37b96
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ * mcbsp_device.c
+ *
+ * This file contains MCBSP IP related EVM (platform) specific routines
+ * implementation. This file contains the board specific code for enabling 
+ * the use of mcbsp driver, and may contain related device pre-driver 
+ * initialization routines. The file is provided as a sample configuration 
+ * and should be modified by customers for their own platforms and 
+ * configurations.
+ *
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  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.
+ *
+*/
+
+/* MCBSP Driver Includes. */
+#include <ti/drv/mcbsp/mcbsp_types.h>
+#include <ti/drv/mcbsp/mcbsp_drv.h>
+#include <ti/drv/mcbsp/mcbsp_osal.h>
+
+/* CSL MCBSP Register Layer */
+#include <ti/csl/cslr_mcbsp.h>
+
+#include <ti/csl/cslr_device.h>
+/* CSL Chip Functional Layer */
+// #include <ti/csl/csl_chip.h> // no functional CSL for Freon
+
+//#include <ti/csl/soc_OMAPL138.h>
+
+
+/*============================================================================*/
+/*                           IMPORTED VARIABLES                               */
+/*============================================================================*/
+
+extern Mcbsp_HwInfo Mcbsp_deviceInstInfo[CSL_MCBSP_CNT];
+extern Mcbsp_TempBuffer Mcbsp_muteBuf[CSL_MCBSP_CNT];
+
+#ifdef MCBSP_LOOPJOB_ENABLE
+extern Mcbsp_TempBuffer Mcbsp_loopDstBuf[CSL_MCBSP_CNT];
+extern Mcbsp_TempBuffer Mcbsp_loopSrcBuf[CSL_MCBSP_CNT];
+#endif /* MCBSP_LOOPJOB_ENABLE */
+
+/* ========================================================================== */
+/*                           MODULE FUNCTIONS                                 */
+/* ========================================================================== */
+/**
+ * \brief   Initializes McBSP driver's data structures
+ *
+ *          This function initializes the McBSP driver's data structures
+ *          including instance objects and channel objects. This is the 
+ *          MCBSP Driver Initialization API which needs to be invoked by 
+ *          the users to initialize the MCBSP peripheral. This call is 
+ *          *mandatory* and should be called before calling any of the 
+ *          other driver API's.  This can be modified by customers for 
+ *          their application and configuration.
+ *
+ * \return  None
+ */
+void McbspDevice_init(void)
+{
+    int32_t devId = 0;
+    void *key;
+
+    /* Begin Critical Section before accessing shared resources. */
+    key = Mcbsp_osalEnterMultipleCoreCriticalSection ();
+
+    /* Invalidate the Cache Contents */
+    Mcbsp_osalBeginMemAccess ((void *)Mcbsp_deviceInstInfo, sizeof(Mcbsp_deviceInstInfo));
+
+    /* initialize the loop job buffers and the mute buffers for all instances  */
+#ifdef MCBSP_LOOPJOB_ENABLE
+    Mcbsp_osalBeginMemAccess ((void *)Mcbsp_loopDstBuf, sizeof(Mcbsp_loopDstBuf));
+    Mcbsp_osalBeginMemAccess ((void *)Mcbsp_loopSrcBuf, sizeof(Mcbsp_loopSrcBuf));
+    memset((void *)Mcbsp_loopDstBuf,0x0,
+        sizeof(Mcbsp_TempBuffer) * CSL_MCBSP_CNT);
+    memset((void *)Mcbsp_loopSrcBuf,0x0,
+        sizeof(Mcbsp_TempBuffer) * CSL_MCBSP_CNT);
+#endif /* MCBSP_LOOPJOB_ENABLE */
+    Mcbsp_osalBeginMemAccess ((void *)Mcbsp_muteBuf, sizeof(Mcbsp_muteBuf));
+    memset((void *)Mcbsp_muteBuf,0x0,
+        sizeof(Mcbsp_TempBuffer) * CSL_MCBSP_CNT);
+
+    /* initialize the information for all the device instances                */
+    for (devId = 0; devId < CSL_MCBSP_CNT; devId++)
+    {
+        if (0 == devId)
+        {
+            /* instance 0 initialisation                                      */
+                /* instance 0 initialisation                                      */
+                           Mcbsp_deviceInstInfo[devId].obj.instNum = (uint32_t)devId;
+                           Mcbsp_deviceInstInfo[devId].obj.regs =
+                               (CSL_McbspRegsOvly)CSL_MCBSP_0_CFG_REGS;
+                           Mcbsp_deviceInstInfo[devId].obj.fifoRegs =
+                               (CSL_BfifoRegsOvly)CSL_MCBSP_0_FIFO_CFG_REGS;
+                           Mcbsp_deviceInstInfo[devId].obj.dataAddress =
+                               (CSL_BdataRegsOvly)CSL_MCBSP_0_SLV_REGS;
+                           Mcbsp_deviceInstInfo[devId].obj.edmaTxEventNum =
+                               (uint32_t)CSL_EDMACC_0_McBSP_XEVT;
+                           Mcbsp_deviceInstInfo[devId].obj.edmaRxEventNum =
+                               (uint32_t)CSL_EDMACC_0_McBSP_REVT;
+                           Mcbsp_deviceInstInfo[devId].obj.cpuTxEventNum =
+                               (uint32_t)CSL_CIC_McBSP_XINT ;
+                           Mcbsp_deviceInstInfo[devId].obj.cpuRxEventNum =
+                               (uint32_t)CSL_CIC_McBSP_RINT ;
+                       }
+#if 0
+                       else if (1 == devId)
+                       {
+                           /* instance 1 initialisation                                      */
+                           Mcbsp_deviceInstInfo[devId].obj.instNum = (uint32_t)devId;
+                           Mcbsp_deviceInstInfo[devId].obj.regs =
+                               (CSL_McbspRegsOvly)CSL_MCBSP_1_CTRL_REGS;
+                           Mcbsp_deviceInstInfo[devId].obj.fifoRegs =
+                               (CSL_BfifoRegsOvly)CSL_MCBSP_1_FIFO_REGS;
+                           Mcbsp_deviceInstInfo[devId].obj.dataAddress =
+                               (CSL_BdataRegsOvly)CSL_MCBSP_1_DATA_REGS;
+                           Mcbsp_deviceInstInfo[devId].obj.edmaTxEventNum =
+                               (uint32_t)CSL_EDMA3_CHA_MCBSP1_TX;
+                           Mcbsp_deviceInstInfo[devId].obj.edmaRxEventNum =
+                               (uint32_t)CSL_EDMA3_CHA_MCBSP1_RX;
+                           Mcbsp_deviceInstInfo[devId].obj.cpuTxEventNum =
+                               (uint32_t)CSL_INTC_EVENTID_MCBSP1_TXINT ;
+                           Mcbsp_deviceInstInfo[devId].obj.cpuRxEventNum =
+                               (uint32_t)CSL_INTC_EVENTID_MCBSP1_RXINT ;
+                       }
+#endif
+                       else
+                       {
+                           /* do nothing                                                     */
+                       }
+
+#ifdef MCBSP_LOOPJOB_ENABLE
+        /* align the buffers to the cache line size                           */
+        Mcbsp_loopSrcBuf[devId].scratchBuffer = (uint32_t *)
+            (((uint32_t)Mcbsp_loopSrcBuf[devId].scratchBuf + 0x7F) & ~0x7F);
+
+        Mcbsp_loopDstBuf[devId].scratchBuffer = (uint32_t *)
+            (((uint32_t)Mcbsp_loopDstBuf[devId].scratchBuf + 0x7F) & ~0x7F);
+
+        Mcbsp_osalEndMemAccess ((void *)Mcbsp_loopSrcBuf, sizeof(Mcbsp_loopSrcBuf));
+        Mcbsp_osalEndMemAccess ((void *)Mcbsp_loopDstBuf, sizeof(Mcbsp_loopDstBuf));
+#endif /* MCBSP_LOOPJOB_ENABLE */
+        Mcbsp_muteBuf[devId].scratchBuffer = (uint32_t *)
+            (((uint32_t)Mcbsp_muteBuf[devId].scratchBuf + 0x7F) & ~0x7F);
+        Mcbsp_osalEndMemAccess ((void *)Mcbsp_muteBuf, sizeof(Mcbsp_muteBuf));
+    }
+
+    /* Writeback Global Objects */
+    Mcbsp_osalEndMemAccess ((void *)Mcbsp_deviceInstInfo, sizeof(Mcbsp_deviceInstInfo));
+
+    /* End Critical Section */
+    Mcbsp_osalExitMultipleCoreCriticalSection (key);
+
+    return;
+}
+
+/* ========================================================================== */
+/*                              END OF FILE                                   */
+/* ========================================================================== */
diff --git a/example/k2g/MCBSPDigLpbk/MCBSP_DigLpbkExampleProject.txt b/example/k2g/MCBSPDigLpbk/MCBSP_DigLpbkExampleProject.txt
new file mode 100644 (file)
index 0000000..de4b32b
--- /dev/null
@@ -0,0 +1,13 @@
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.c" 
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/device/k2g/device_mcbsp_loopback.c"
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.cmd" 
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.cfg" 
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk_osal.c" 
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/example/k2g/MCBSPDigLpbk/sample_k2g_cfg.c" 
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/example/k2g/MCBSPDigLpbk/sample_k2g_int_reg.c" 
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/example/k2g/MCBSPDigLpbk/sample_cs.c" 
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/example/k2g/MCBSPDigLpbk/sample_init.c" 
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/src/mcbsp_drv.c"
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/src/mcbsp_edma.c"
+-ccs.linkFile "${PDK_INSTALL_PATH}/ti/drv/mcbsp/src/mcbsp_ioctl.c"
+-ccs.setCompilerOptions "-DDEVICE_K2G -DMCBSP_DEBUG_TEMP -g --diag_warning=225 -I${PDK_INSTALL_PATH} -I${BIOS_INSTALL_PATH}/packages -I${PDK_INSTALL_PATH}/ti/drv/mcbsp/example/k2g/MCBSPDigLpbk -I${PDK_INSTALL_PATH}/ti/drv/mcbsp/include -I${PDK_INSTALL_PATH}/ti/drv/mcbsp" -rtsc.enableRtsc 
diff --git a/example/k2g/MCBSPDigLpbk/bios6_edma3_drv_sample.h b/example/k2g/MCBSPDigLpbk/bios6_edma3_drv_sample.h
new file mode 100644 (file)
index 0000000..5fad8a7
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * bios6_edma3_drv_sample.h
+ *
+ * Header file for the sample application for the EDMA3 Driver.
+ *
+ * Copyright (C) 2009-2012 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  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.
+ *
+*/
+
+#ifndef _BIOS6_EDMA3_DRV_SAMPLE_H_
+#define _BIOS6_EDMA3_DRV_SAMPLE_H_
+
+#include <stdio.h>
+#include <ti/sysbios/knl/Semaphore.h>
+
+/* Include EDMA3 Driver */
+#include <ti/sdo/edma3/drv/edma3_drv.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Cache line size on the underlying SoC. It needs to be modified
+ * for different cache line sizes, if the Cache is Enabled.
+ */
+#define EDMA3_CACHE_LINE_SIZE_IN_BYTES      (128u)
+
+/* Error returned in case of buffers are not aligned on the cache boundary */
+#define EDMA3_NON_ALIGNED_BUFFERS_ERROR     (-1)
+
+/* Error returned in case of data mismatch */
+#define EDMA3_DATA_MISMATCH_ERROR           (-2)
+
+/**
+ * \brief   EDMA3 Initialization
+ *
+ * This function initializes the EDMA3 Driver for the given EDMA3 controller
+ * and opens a EDMA3 driver instance. It internally calls EDMA3_DRV_create() and
+ * EDMA3_DRV_open(), in that order.
+ *
+ * It also registers interrupt handlers for various EDMA3 interrupts like 
+ * transfer completion or error interrupts.
+ *
+ *  \param  edma3Id    [IN]            EDMA3 Controller Instance Id (Hardware
+ *                                                                     instance id, starting from 0)
+ *  \param  errorCode  [IN/OUT]        Error code while opening DRV instance
+ *  \return EDMA3_DRV_Handle: If successfully opened, the API will return the
+ *                            associated driver's instance handle.
+ */
+EDMA3_DRV_Handle edma3init (unsigned int edma3Id, EDMA3_DRV_Result *errorCode);
+
+/**
+ * \brief   EDMA3 De-initialization
+ *
+ * This function de-initializes the EDMA3 Driver for the given EDMA3 controller
+ * and closes the previously opened EDMA3 driver instance. It internally calls 
+ * EDMA3_DRV_close and EDMA3_DRV_delete(), in that order.
+ *
+ * It also un-registers the previously registered interrupt handlers for various 
+ * EDMA3 interrupts.
+ *
+ *  \param  edma3Id    [IN]            EDMA3 Controller Instance Id (Hardware
+ *                                                                     instance id, starting from 0)
+ *  \param  hEdma              [IN]            EDMA3 Driver handle, returned while using
+ *                                                                     edma3init().
+ *  \return  EDMA3_DRV_SOK if success, else error code
+ */
+EDMA3_DRV_Result edma3deinit (unsigned int edma3Id, EDMA3_DRV_Handle hEdma);
+
+
+/**
+ *  \brief   EDMA3 Cache Invalidate
+ *
+ *  This function invalidates the D cache.
+ *
+ *  \param  mem_start_ptr [IN]      Starting address of memory.
+ *                                  Please note that this should be
+ *                                  aligned according to the cache line size.
+ *  \param  num_bytes [IN]          length of buffer
+ *  \return  EDMA3_DRV_SOK if success, else error code in case of error
+ *          or non-alignment of buffers.
+ *
+ * Note: This function is required if the buffer is in DDR.
+ * For other cases, where buffer is NOT in DDR, user
+ * may or may not require the below implementation and
+ * should modify it according to her need.
+ */
+EDMA3_DRV_Result Edma3_CacheInvalidate(unsigned int mem_start_ptr,
+                           unsigned int num_bytes);
+
+
+
+/**
+ * \brief   EDMA3 Cache Flush
+ *
+ *  This function flushes (cleans) the Cache
+ *
+ *  \param  mem_start_ptr [IN]      Starting address of memory.
+ *                                  Please note that this should be
+ *                                  aligned according to the cache line size.
+ *  \param  num_bytes [IN]          length of buffer
+ *  \return  EDMA3_DRV_SOK if success, else error code in case of error
+ *          or non-alignment of buffers.
+ *
+ * Note: This function is required if the buffer is in DDR.
+ * For other cases, where buffer is NOT in DDR, user
+ * may or may not require the below implementation and
+ * should modify it according to her need.
+ */
+EDMA3_DRV_Result Edma3_CacheFlush(unsigned int mem_start_ptr,
+                      unsigned int num_bytes);
+
+
+
+/**
+  * Counting Semaphore related functions (OS dependent) should be
+  * called/implemented by the application. A handle to the semaphore
+  * is required while opening the driver/resource manager instance.
+  */
+
+/**
+ * \brief   EDMA3 OS Semaphore Create
+ *
+ *      This function creates a counting semaphore with specified
+ *      attributes and initial value. It should be used to create a semaphore
+ *      with initial value as '1'. The semaphore is then passed by the user
+ *      to the EDMA3 driver/RM for proper sharing of resources.
+ * \param   initVal [IN] is initial value for semaphore
+ * \param   semParams [IN] is the semaphore attributes.
+ * \param   hSem [OUT] is location to receive the handle to just created
+ *      semaphore.
+ * \return  EDMA3_DRV_SOK if successful, else a suitable error code.
+ */
+EDMA3_DRV_Result edma3OsSemCreate(int initVal,
+                                                       const Semaphore_Params *semParams,
+                                                       EDMA3_OS_Sem_Handle *hSem);
+
+
+
+/**
+ * \brief   EDMA3 OS Semaphore Delete
+ *
+ *      This function deletes or removes the specified semaphore
+ *      from the system. Associated dynamically allocated memory
+ *      if any is also freed up.
+ * \param   hSem [IN] handle to the semaphore to be deleted
+ * \return  EDMA3_DRV_SOK if successful else a suitable error code
+ */
+EDMA3_DRV_Result edma3OsSemDelete(EDMA3_OS_Sem_Handle hSem);
+
+#ifdef __cplusplus
+}
+#endif /* extern "C" */
+
+#endif  /* _BIOS6_EDMA3_DRV_SAMPLE_H_ */
+
diff --git a/example/k2g/MCBSPDigLpbk/config.bld b/example/k2g/MCBSPDigLpbk/config.bld
new file mode 100644 (file)
index 0000000..cb4905e
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *
+ * $Source: /cvsstl/ti/pa/f/s19/config.bld,v $
+ * $Revision: 1.6 $
+ *
+ * XDC/BIOS configuration file for I12 Topo/Feature Set
+ *
+ * Copyright 2008, Texas Instruments, Inc.  All rights reserved.
+ *
+ * $Log: config.bld,v $
+ * Revision 1.6  2009/06/10 07:51:13  mkamat
+ * MID 2487 Replace references to PA17 with PA
+ *
+ * Revision 1.5  2009/03/02 04:36:58  uparikh
+ * Add segment SDRAM_LINK_SHARED for dhared LINK memory
+ *
+ * Revision 1.4  2009/02/18 14:29:12  uparikh
+ * Partition SDRAM and re-order memory segments in ascending order
+ *
+ * Revision 1.3  2009/02/14 09:05:55  uparikh
+ * Update IRAM and SDRAM base / len
+ *
+ * Revision 1.2  2009/01/28 12:37:59  mkamat
+ * Made cache 64k and moved o/p buffer to L3 - MID 2144
+ *
+ * Revision 1.1  2008/10/21 04:45:09  mkamat
+ * Code cleanup in s19 area - MID 1923
+ *
+ * Revision 1.6  2008/10/13 05:22:54  uparikh
+ * Define section for uboot
+ *
+ * Revision 1.5  2008/09/29 11:20:53  uparikh
+ * Increase size of SDRAM for pa.out to build
+ *
+ * Revision 1.4  2008/09/09 23:35:52  lester
+ * (MID 1820) Revised to use deviceName: 'TMS320DA830',
+ * instead of deviceName: 'Primus' (deprecated).
+ *
+ * Revision 1.3  2008/09/05 17:18:42  martin
+ * Renumber array elements. Element 1 was missing in last commit
+ *
+ * Revision 1.2  2008/09/05 16:00:43  martin
+ * Move DSP image to upper SDRAM to cooperate with Linux images.
+ *
+ * Revision 1.1  2008/08/20 09:54:35  lester
+ * (MID 1820) Generated via (from latest this date):
+ * [/cygdrive/t/pa/f/s17/pai1] delog -f"t:/pa/f/s19/i12" ....
+ *
+ */
+
+/* ......................................................................... */
+
+var memory = [];
+
+
+memory[0] = ["IRAM",
+             {
+             name      : "IRAM",
+             base      : 0x10800000,
+             len       : 0x00080000,
+             space     : "code/data"
+             }];
+
+memory[1] = ["L3RAM",
+             {
+             name      : "DDR3",
+             base      : 0x80000000,
+             len       : 0x10000000,
+             space     : "data"
+             }];
+
+
+Build.platformTable['ti.platforms.generic:plat'] =
+{
+clockRate: 600,
+catalogName: 'ti.catalog.c6000',
+deviceName: 'TMS320TCI6616',
+regs: {l1DMode: "32k"},
+regs: {l1PMode: "32k"},
+regs:  {l2Mode: "64k"},
+customMemoryMap: memory
+};
diff --git a/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.c b/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.c
new file mode 100644 (file)
index 0000000..ec0ec8b
--- /dev/null
@@ -0,0 +1,969 @@
+/*
+ * mcbspMasterDigLpbk.c
+ *
+ * This file contains the test / demo code to demonstrate the McBSP driver
+ * master functionality using Digital Loopback setup. The file configures 
+ * the EVM in master mode.
+ *
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  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.
+ *
+*/
+
+/* ========================================================================== */
+/*                            INCLUDE FILES                                   */
+/* ========================================================================== */
+
+#include <ti/sysbios/BIOS.h>
+#include <xdc/std.h>
+#include <ti/sysbios/knl/Task.h>
+#include <string.h>
+#include <ti/sysbios/knl/Queue.h>
+#include <xdc/runtime/System.h>
+
+#include <xdc/cfg/global.h>
+
+/* Include EDMA3 Driver */
+#include <ti/sdo/edma3/drv/edma3_drv.h>
+
+/* CSL Chip Functional Layer */
+//#include <ti/csl/csl_chip.h>
+
+/* CSL Cache Functional Layer */
+//#include <ti/csl/csl_cacheAux.h>
+
+/* CSL CPINTC Include Files. */
+//#include<ti/csl/csl_cpIntc.h>
+
+/* MCBSP Driver Include File. */
+#include <ti/drv/mcbsp/mcbsp_drv.h>
+#include <ti/drv/mcbsp/mcbsp_osal.h>
+
+/* PlatformLib Include File */
+//#include <ti/platform/platform.h>
+
+
+/* ========================================================================== */
+/*                        EXTERNAL FUNCTIONS                                  */
+/* ========================================================================== */
+
+extern EDMA3_DRV_Handle edma3init(unsigned int edma3Id, EDMA3_DRV_Result *);
+
+extern void McbspDevice_init(void);
+
+extern int32_t Osal_dataBufferInitMemory(uint32_t dataBufferSize);
+
+extern void McbspXmtInterrupt_init(void *mcbspTxChan);
+extern void McbspRcvInterrupt_init(void *mcbspRxChan);
+
+/* FPGA Configuration Misc-1 Register offset */
+#define MCBSP_FPGA_MISC_REG_OFFSET (0x0C)
+
+/* ========================================================================== */
+/*                           MACRO DEFINTIONS                                 */
+/* ========================================================================== */
+
+#define NUM_BUFS                     2          /* Max of buffers used in each direction */
+#define FRAMESIZE                   40          /* e.g 5 ms 8 KHz samples         */
+#define NUM_OF_ENABLED_CHANNELS      8          /* Number of slots to be used     */
+#define NUM_OF_MAX_CHANNELS           128                      /* Maximum number of time slots available based on clock settings   */
+#define BUFSIZE                   (NUM_OF_ENABLED_CHANNELS * FRAMESIZE)        /* Total buffer size per frame */
+
+/* Defines the core number responsible for system initialization. */
+#define CORE_SYS_INIT         0
+/* Number of iterations to execute test: Only applicable to INTERNAL CLOCK Loopback test */
+#define NUM_OF_ITERATIONS 10
+
+/* Number of MCBSP Frame structures used for submit channel */
+#define NUM_OF_MCBSP_FRAMES 2
+
+/* Number of buffers initially submitted to Mcbsp lld: Only applicable to
+   External clock test ; Note: This should be set to 2*/
+#define INIT_SUBMIT_Q_CNT 2
+
+/*============================================================================*/
+/*                            GLOBAL VARIABLES                                */
+/*============================================================================*/
+
+/* Shared Memory Variable to ensure synchronizing MCBSP initialization
+ * with all the other cores. */
+/* Created an array to pad the cache line with MCBSP_CACHE_LENGTH size */
+#pragma DATA_ALIGN   (isMCBSPInitialized, MCBSP_MAX_CACHE_ALIGN)
+#pragma DATA_SECTION (isMCBSPInitialized, ".mcbspSharedMem");
+volatile Uint32 isMCBSPInitialized[(MCBSP_CACHE_LENGTH / sizeof(Uint32))] = { 0 };
+
+/* Handle to the EDMA driver instance */
+#pragma DATA_ALIGN   (hEdma, MCBSP_MAX_CACHE_ALIGN)
+EDMA3_DRV_Handle hEdma[(MCBSP_CACHE_LENGTH / sizeof(EDMA3_DRV_Handle))] = { NULL };
+
+/* Handle to MCBSP driver instance */
+typedef void* Mcbsp_DevHandle;
+Mcbsp_DevHandle  hMcbspDev;
+
+/* Handle to MCBSP driver channel instance */
+typedef void* Mcbsp_ChanHandle;
+Mcbsp_ChanHandle  hMcbspTxChan;
+Mcbsp_ChanHandle  hMcbspRxChan;
+
+/* Core Number Identifier */
+UInt32 coreNum = 0xFFFF;
+
+/* Array to hold the pointer to the allocated buffers     */
+void* bufRx[NUM_BUFS];
+void* bufTx[NUM_BUFS];
+
+#ifdef MCBSP_LOOP_PING_PONG
+/* Ping pong buffers used to submit to Mcbsp lld, which will be used in a loop */
+void* bufRxPingPong[INIT_SUBMIT_Q_CNT];
+void* bufTxPingPong[INIT_SUBMIT_Q_CNT];
+#endif
+/* Global Error call back function prototype */
+void mcbsp_GblErrCallback(uint32_t chanHandle,uint32_t spcr_read,uint32_t Arg3);
+
+/* Variables to indicate status of EDMA TX and RX requests */
+volatile uint32_t edmaTxDone = 0;
+volatile uint32_t edmaRxDone = 0;
+/* Global variables to track number of buffers submitted, number of iterations, error counts etc */
+int rxSubmitCount=0, txSubmitCount=0;
+uint32_t num_iterations=0;
+uint32_t num_rx_Call_backs=0, num_tx_Call_backs=0, dummy_call_backs=0;
+uint32_t rxunderflowcnt=0, txunderflowcnt=0;
+uint32_t errBuffCount=0;
+/* Debug variables */
+volatile int debugVar=1;  /* This can be used to maintain a while loop, If set to 0 will exit loop */
+volatile int debugCommand=1;  /* This can be used to set to value below to send command to restart channel  */
+
+#define DEBUG_COMMAND_RESTART_CHANNELS 1
+/**
+ * \brief    Mcbsp Sample rate generator default parameters.
+ *
+ */
+Mcbsp_srgConfig mcbspSrgCfg =
+{
+    FALSE,                     /* No gsync to be used as input is not CLKS    */
+    Mcbsp_ClkSPol_RISING_EDGE, /* Dont care as input clock is not clks        */
+    Mcbsp_SrgClk_CLKCPU,       /* McBSP internal clock to be used             */
+    //166666667,                 /* Mcbsp internal clock frequency(PLL-SYSCLK6) */
+    333333333, //sys_oscclk or cpu_clk/3
+    0                          /* frame sync pulse width (val+1) is used      */
+};
+
+/**
+ * \brief    Mcbsp device creation default parameters.
+ *
+ */
+const Mcbsp_Params Mcbsp_PARAMS =
+{
+    Mcbsp_DevMode_McBSP,       /* Use the device as MCBSP                     */
+    Mcbsp_OpMode_DMAINTERRUPT, /* Use DMA mode of operation                   */
+    TRUE,                      /* cache coherency taken care of by driver     */
+    Mcbsp_EmuMode_FREE,        /* Emulation mode free is to be enabled        */
+#ifdef    MCBSP_EXTERNAL_CLOCK
+    Mcbsp_Loopback_DISABLE,    /* Loop back mode disabled                     */
+#else
+    Mcbsp_Loopback_ENABLE,     /* Loop back mode enabled                      */
+#endif
+    &mcbspSrgCfg,              /* sample rate generator configuration         */
+    NULL,                      /* TX pending buffer queue from application    */
+    NULL,                      /* TX floating buffer queue in DMA             */
+    NULL,                      /* RX pending buffer queue from application    */
+    NULL                       /* RX floating buffer queue in DMA             */
+};
+
+#pragma DATA_ALIGN(loopTxJob, MCBSP_MAX_CACHE_ALIGN)
+static Int32 loopTxJob[16] = {
+    /* Filling with Mu law silence pattern : Can be any user defined pattern */
+    0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f,
+    0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f
+};
+#pragma DATA_ALIGN(loopRxJob, MCBSP_MAX_CACHE_ALIGN)
+static Int32 loopRxJob[16] = {
+    0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/**< settings to configure the TX or RX hardware sections                 */
+Mcbsp_DataConfig mcbspChanConfigTx =
+{
+    Mcbsp_Phase_SINGLE,
+    Mcbsp_WordLength_8,
+    Mcbsp_WordLength_8,    /* Dont care for single phase*/
+    NUM_OF_MAX_CHANNELS,
+    NUM_OF_MAX_CHANNELS,      // Only used with dual phase
+    Mcbsp_FrmSync_DETECT,
+#ifdef MCBSP_EXTERNAL_CLOCK
+    Mcbsp_DataDelay_0_BIT,
+#else
+    Mcbsp_DataDelay_1_BIT,
+#endif
+    Mcbsp_Compand_OFF_MSB_FIRST,
+    Mcbsp_BitReversal_DISABLE,
+    Mcbsp_IntMode_ON_SYNCERR,
+    Mcbsp_RxJust_RZF,  /* Dont care for TX         */
+    Mcbsp_DxEna_OFF
+};
+
+/**< settings to configure the TX or RX hardware sections                 */
+Mcbsp_DataConfig mcbspChanConfigRx =
+{
+    Mcbsp_Phase_SINGLE,
+    Mcbsp_WordLength_8,
+    Mcbsp_WordLength_8,    /* Dont care for single phase*/
+    NUM_OF_MAX_CHANNELS,
+    NUM_OF_MAX_CHANNELS,      // Only used with dual phase
+    Mcbsp_FrmSync_DETECT,
+#ifdef MCBSP_EXTERNAL_CLOCK
+    Mcbsp_DataDelay_0_BIT,
+#else
+    Mcbsp_DataDelay_1_BIT,
+#endif
+    Mcbsp_Compand_OFF_MSB_FIRST,
+    Mcbsp_BitReversal_DISABLE,
+    Mcbsp_IntMode_ON_SYNCERR,
+    Mcbsp_RxJust_RZF,  /* Dont care for TX         */
+    Mcbsp_DxEna_OFF
+};
+/**< clock setup for the TX section                     */
+Mcbsp_ClkSetup mcbspClkConfigTx =
+{
+#ifdef MCBSP_EXTERNAL_CLOCK
+    Mcbsp_FsClkMode_EXTERNAL,
+    8000,                   /* 8KHz                   */
+    Mcbsp_TxRxClkMode_EXTERNAL,
+#else
+    Mcbsp_FsClkMode_INTERNAL,
+    8000,                   /* 8KHz                   */
+    Mcbsp_TxRxClkMode_INTERNAL,
+#endif
+    Mcbsp_FsPol_ACTIVE_HIGH,
+    Mcbsp_ClkPol_RISING_EDGE
+};
+
+/**< clock setup for the RX section                     */
+Mcbsp_ClkSetup mcbspClkConfigRx =
+{
+#ifdef MCBSP_EXTERNAL_CLOCK
+    Mcbsp_FsClkMode_EXTERNAL,
+    8000,                   /* 8KHz                   */
+    Mcbsp_TxRxClkMode_EXTERNAL,
+#else
+    Mcbsp_FsClkMode_INTERNAL,
+    8000,                   /* 8KHz                   */
+    Mcbsp_TxRxClkMode_INTERNAL,
+#endif
+    Mcbsp_FsPol_ACTIVE_HIGH,
+    Mcbsp_ClkPol_FALLING_EDGE
+};
+
+/**< Multi channel setup                                                      */
+Mcbsp_McrSetup mcbspMultiChanCtrl =
+{
+    Mcbsp_McmMode_ALL_CHAN_DISABLED_UNMASKED,
+    Mcbsp_PartitionMode_CHAN_0_15,
+    Mcbsp_PartitionMode_CHAN_16_31,
+    Mcbsp_PartitionMode_2
+};
+
+
+Mcbsp_ChanParams mcbspChanparamTx =
+{
+    Mcbsp_WordLength_8,  /* wordlength configured    */
+    &loopTxJob[0],          /* loop job buffer internal */
+    8,                    /* user loopjob length      */
+    mcbsp_GblErrCallback, /* global error callback    */
+    NULL,                 /* edma Handle              */
+    1,                    /* EDMA event queue         */
+    8,                    /* hwi number               */
+    Mcbsp_BufferFormat_MULTISLOT_NON_INTERLEAVED,
+    TRUE,                 /* FIFO mode enabled        */
+    &mcbspChanConfigTx,   /* channel configuration    */
+    &mcbspClkConfigTx,    /* clock configuration      */
+    &mcbspMultiChanCtrl,  /* multi channel control    */
+    0x7531,  /* Enabled timeslots: 0, 4, 5, 8, 10, 12, 13, 14 */
+    0x00,
+    0x00,
+    0x00,
+    NUM_OF_ENABLED_CHANNELS    /* Total number of channels enabled*/
+};
+
+Mcbsp_ChanParams mcbspChanparamRx =
+{
+    Mcbsp_WordLength_8,  /* wordlength configured    */
+    &loopRxJob[0],          /* loop job buffer internal */
+    8,                    /* user loopjob length      */
+    mcbsp_GblErrCallback, /* global error callback    */
+    NULL,                 /* edma Handle              */
+    1,                    /* EDMA event queue         */
+    8,                    /* hwi number               */
+    Mcbsp_BufferFormat_MULTISLOT_NON_INTERLEAVED,
+    TRUE,                 /* FIFO mode enabled        */
+    &mcbspChanConfigRx,   /* channel configuration    */
+    &mcbspClkConfigRx,    /* clock configuration      */
+    &mcbspMultiChanCtrl,  /* multi channel control    */
+    0x7531,  /* Enabled timeslots: 0, 4, 5, 8, 10, 12, 13, 14 */
+    0x00,
+    0x00,
+    0x00,
+    NUM_OF_ENABLED_CHANNELS    /* Total number of channels enabled*/
+};
+
+
+/* ========================================================================== */
+/*                           FUNCTION DEFINITIONS                             */
+/* ========================================================================== */
+
+/*
+ *   This is the application's callback function. The driver will
+ *   call this function whenever an EDMA I/O operation is over.
+ *
+ */
+void mcbspAppCallback(void* arg, Mcbsp_IOBuf *ioBuf)
+{
+    int32_t mode;
+    int32_t *pmode = (int32_t *)arg;
+
+    mode = *pmode;
+    if (mode == MCBSP_MODE_OUTPUT)
+    {
+       if(ioBuf) {
+            num_tx_Call_backs++;
+            edmaTxDone = 1;
+        }else
+            txunderflowcnt++;
+    }
+    else if (mode == MCBSP_MODE_INPUT)
+    {
+        if(ioBuf) {
+            num_rx_Call_backs++;
+            edmaRxDone = 1;
+        }else
+            rxunderflowcnt++;
+    }else
+        dummy_call_backs++;
+    return;
+}
+
+/*
+ *   This is the application's Global error callback function 
+ */
+void mcbsp_GblErrCallback(uint32_t chanHandle,uint32_t spcr_read,uint32_t Arg3)
+{
+    System_printf ("Debug(Core %d): ERROR callback called SPCR: %x", coreNum, spcr_read);
+}
+
+/*
+ * \brief   This function demostrates the use of Mcbsp using digital loopback
+ *          communication setup.
+ *
+ * \param   None
+ *
+ * \return  None
+ */
+void mcbspDigLpbkApp(UArg arg0, UArg arg1)
+{
+    /**< Mcbsp device params                                                  */
+    Mcbsp_Params  mcbspParams;
+
+    /**< Queue to hold the pending packets received from the application      */
+    Queue_Struct  txQueuePendingList, rxQueuePendingList;
+    /**< Queue to manage floating packets in DMA                              */
+    Queue_Struct  txQueueFloatingList, rxQueueFloatingList;
+
+    uint32_t count   = 0, tempCount = 0;
+    int32_t  status  = 0, retval = 0;
+    int32_t  txChanMode = MCBSP_MODE_OUTPUT;
+    int32_t  rxChanMode = MCBSP_MODE_INPUT;
+    uint32_t mcbspTxDone = 0, mcbspRxDone = 0;
+    Mcbsp_IOBuf txFrame[NUM_OF_MCBSP_FRAMES], rxFrame[NUM_OF_MCBSP_FRAMES];
+    int txFrameIndex=0, rxFrameIndex=0;
+    int init_count=0;
+#ifdef MCBSP_LOOP_PING_PONG
+    int pingPongIndex=0;
+#endif
+
+    /* Initialize the OSAL */
+    if (Osal_dataBufferInitMemory(BUFSIZE) < 0)
+    {
+        System_printf ("Debug(Core %d): Error: Unable to initialize the OSAL. \n", coreNum);
+        return;
+    }
+
+    /* update EDMA3 handle to channel parameters */
+    mcbspChanparamTx.edmaHandle = hEdma[0];
+    mcbspChanparamRx.edmaHandle = hEdma[0];
+
+    /* create the pending and floating queue for the TX channel           */
+    Queue_construct(&txQueuePendingList, NULL);
+    Queue_construct(&txQueueFloatingList, NULL);
+
+    /* create the pending and floating queue for the RX channel           */
+    Queue_construct(&rxQueuePendingList, NULL);
+    Queue_construct(&rxQueueFloatingList, NULL);
+
+
+    mcbspParams                 = Mcbsp_PARAMS;
+    mcbspParams.txQPendingList  = &txQueuePendingList;
+    mcbspParams.txQFloatingList = &txQueueFloatingList;
+    mcbspParams.rxQPendingList  = &rxQueuePendingList;
+    mcbspParams.rxQFloatingList = &rxQueueFloatingList;
+
+
+    /* Bind the driver instance with device instance */
+    status = mcbspBindDev(&hMcbspDev, coreNum, &mcbspParams);
+
+    if (status != MCBSP_STATUS_COMPLETED)
+    {
+        System_printf ("Debug(Core %d): MCBSP LLD Bind Device Failed\n", coreNum);
+        return;
+    }
+
+    /* If the user loopjob buffer is in local L2 memory: Convert into Global memory address space */
+    if(mcbspChanparamRx.userLoopJobBuffer)
+        mcbspChanparamRx.userLoopJobBuffer = (void *)Mcbsp_osalLocal2Global(mcbspChanparamRx.userLoopJobBuffer);
+
+    /* Create a RX channel for receiving */
+    status = mcbspCreateChan(&hMcbspRxChan, hMcbspDev, MCBSP_MODE_INPUT, &mcbspChanparamRx, mcbspAppCallback, &rxChanMode);
+    if (MCBSP_STATUS_COMPLETED != status)
+    {
+        System_printf ("Debug(Core %d): Error: Create Channel (RX) failed\n", coreNum);
+        return;
+    }
+
+    /* If the user loopjob buffer is in local L2 memory: Convert into Global memory address space */
+    if(mcbspChanparamTx.userLoopJobBuffer)
+        mcbspChanparamTx.userLoopJobBuffer = Mcbsp_osalLocal2Global(mcbspChanparamTx.userLoopJobBuffer);
+
+    /* Create a TX channel for the transmission */
+    status = mcbspCreateChan(&hMcbspTxChan, hMcbspDev, MCBSP_MODE_OUTPUT, &mcbspChanparamTx, mcbspAppCallback, &txChanMode);
+    if (MCBSP_STATUS_COMPLETED != status)
+    {
+        System_printf ("Debug(Core %d): Error: Create Channel (TX) failed\n", coreNum);
+        return;
+    }
+
+    /* Register mcbsp interrupts */
+    //McbspRcvInterrupt_init(hMcbspRxChan);
+    //McbspXmtInterrupt_init(hMcbspTxChan);
+
+    /* create the buffers required for the TX and RX operations */
+    for (count = 0; count < (NUM_BUFS); count++)
+    {
+        bufTx[count] = (uint8_t *)Osal_mcbspDataBufferMalloc(BUFSIZE);
+        bufRx[count] = (uint8_t *)Osal_mcbspDataBufferMalloc(BUFSIZE);
+
+        if (bufTx[count] == NULL)
+        {
+            System_printf ("Debug(Core %d): Error: Tx Buffer (%d) Memory Allocation Failed\n", coreNum, count);
+            return;
+        }
+        if (bufRx[count] == NULL)
+        {
+            System_printf ("Debug(Core %d): Error: Rx Buffer (%d) Memory Allocation Failed\n", coreNum, count);
+            return;
+        }
+    }
+#ifdef MCBSP_LOOP_PING_PONG
+    /* create the ping pong buffers required for the TX and RX operations */
+    for (count = 0; count < (NUM_BUFS); count++)
+    {
+        bufRxPingPong[count] = (uint8_t *)Osal_mcbspDataBufferMalloc(BUFSIZE);
+        bufTxPingPong[count] = (uint8_t *)Osal_mcbspDataBufferMalloc(BUFSIZE);
+
+        if (bufTxPingPong[count] == NULL)
+        {
+            System_printf ("Debug(Core %d): Error: Tx Ping pong Buffer (%d) Memory Allocation Failed\n", coreNum, count);
+            return;
+        }
+        if (bufRxPingPong[count] == NULL)
+        {
+            System_printf ("Debug(Core %d): Error: Rx Ping pong Buffer (%d) Memory Allocation Failed\n", coreNum, count);
+            return;
+        }
+    }
+#endif
+    /* Fill the buffers with known data and transmit the same and 
+       check if the same pattern is received */
+    for (count = 0; count < (NUM_BUFS); count++)
+    {
+        memset((uint8_t *)bufTx[count], 0, BUFSIZE);
+        for (tempCount = 0; tempCount < BUFSIZE; tempCount++)
+        {
+            ((uint8_t *)bufTx[count])[tempCount] = (tempCount % 0x100);
+        }
+    }
+    System_printf ("Debug(Core %d): If required to restart set debugCommand variable to %d\n", coreNum, DEBUG_COMMAND_RESTART_CHANNELS);
+
+restart_mcbsp_point:
+    txFrameIndex=0;
+    rxFrameIndex=0;
+    init_count=0;
+#ifdef MCBSP_EXTERNAL_CLOCK
+    /* Initial loading of ping ping buffers */
+    for(init_count =0 ; init_count < INIT_SUBMIT_Q_CNT; init_count++)
+    {
+#ifdef MCBSP_LOOP_PING_PONG
+        memset((uint8_t *)bufRxPingPong[init_count], 0, BUFSIZE);
+
+        /* RX frame processing */
+        rxFrame[rxFrameIndex].cmd = Mcbsp_IOBuf_Cmd_READ;
+        rxFrame[rxFrameIndex].addr = (void*)bufRxPingPong[init_count];
+#else
+        memset((uint8_t *)bufRx[init_count], 0, BUFSIZE);
+
+
+        /* RX frame processing */
+        rxFrame[rxFrameIndex].cmd = Mcbsp_IOBuf_Cmd_READ;
+        rxFrame[rxFrameIndex].addr = (void*)bufRx[init_count];
+#endif
+
+        rxFrame[rxFrameIndex].size = BUFSIZE;
+        rxFrame[rxFrameIndex].arg = (uint32_t) hMcbspRxChan;
+        rxFrame[rxFrameIndex].status = MCBSP_STATUS_COMPLETED;
+        rxFrame[rxFrameIndex].misc = 1;   /* reserved - used in callback to indicate asynch packet */
+
+        status = mcbspSubmitChan(hMcbspRxChan, (void *)&rxFrame[rxFrameIndex]);
+        if (status != MCBSP_STATUS_PENDING)
+        {
+            System_printf ("Debug(Core %d): Error: RX buffer #%d submission FAILED\n", coreNum, init_count);
+            retval = 1;
+        }
+        else
+        {
+#ifdef MCBSP_APP_VERBOSE
+            System_printf ("Debug(Core %d): RX buffer #%d is submitted to MCBSP driver\n", coreNum, init_count);
+#endif
+        }
+        rxFrameIndex++;
+        rxFrameIndex = (rxFrameIndex >= (NUM_OF_MCBSP_FRAMES)) ? 0 : rxFrameIndex;
+
+        rxSubmitCount++;
+
+        /* TX frame processing */
+        txFrame[txFrameIndex].cmd = Mcbsp_IOBuf_Cmd_WRITE;
+#ifdef MCBSP_LOOP_PING_PONG
+        txFrame[txFrameIndex].addr = (void*)bufTxPingPong[init_count];
+#else
+        txFrame[txFrameIndex].addr = (void*)bufTx[init_count];
+#endif
+        txFrame[txFrameIndex].size = BUFSIZE;
+        txFrame[txFrameIndex].arg = (uint32_t)hMcbspTxChan;
+        txFrame[txFrameIndex].status = MCBSP_STATUS_COMPLETED;
+        txFrame[txFrameIndex].misc = 1;   /* reserved - used in callback to indicate asynch packet */
+
+        status = mcbspSubmitChan(hMcbspTxChan, (void *)&txFrame[txFrameIndex]);
+        if (status != MCBSP_STATUS_PENDING)
+        {
+            System_printf ("Debug(Core %d): Error: TX buffer  #%d submission FAILED\n", coreNum, init_count);
+            retval = 1;
+        }
+        else
+        {
+#ifdef MCBSP_APP_VERBOSE
+            System_printf ("Debug(Core %d): TX buffer  #%d submission is submitted to MCBSP driver\n", coreNum, init_count);
+#endif
+        }
+        txFrameIndex++;
+        txFrameIndex = (txFrameIndex >=(NUM_OF_MCBSP_FRAMES)) ? 0 : txFrameIndex;
+
+        txSubmitCount++;
+    }
+
+    /* Wait for TX and RX processing to complete */
+    while (1)
+    {
+        if (edmaTxDone == 1)
+        {
+#ifdef MCBSP_APP_VERBOSE
+            System_printf ("Debug(Core %d): EDMA -> Iteration-%d frames are transmitted to TX path\n", coreNum, count);
+#endif
+            edmaTxDone = 0; /* Reset for next iteration */
+            mcbspTxDone = 1;
+        }
+        if (edmaRxDone == 1)
+        {
+#ifdef MCBSP_APP_VERBOSE
+            System_printf ("Debug(Core %d): EDMA -> Iteration-%d frames are received from RX path\n", coreNum, count);
+#endif
+            edmaRxDone = 0;  /* Reset for next iteration */
+            mcbspRxDone = 1;
+        }
+        if ((mcbspTxDone == 1) && (mcbspRxDone == 1))
+        {
+            mcbspTxDone = 0;  /* Reset for next iteration */
+            mcbspRxDone = 0;  /* Reset for next iteration */
+            break;
+        }
+    }
+#ifdef MCBSP_LOOP_PING_PONG
+    /* Change ping Pong Index */
+    init_count=0;
+#endif
+#endif /* MCBSP_EXTERNAL_CLOCK */
+
+    /* Start main loop to iterate through frames */
+    while(debugVar)
+    {
+        /* submit frames to the driver */
+        for (count = init_count; count < NUM_BUFS; count++)
+        {
+#ifdef MCBSP_EXTERNAL_CLOCK
+/*   With External clock the data coming from the RX side is copied to loop back to the Tx side */
+            memcpy((uint8_t *)bufTx[count], (uint8_t *)bufRx[count], BUFSIZE);
+#endif
+#ifdef MCBSP_LOOP_PING_PONG
+            memset((uint8_t *)bufRxPingPong[pingPongIndex], 0, BUFSIZE);
+#else
+            memset((uint8_t *)bufRx[count], 0, BUFSIZE);
+            /* RX frame processing */
+            rxFrame[rxFrameIndex].cmd = Mcbsp_IOBuf_Cmd_READ;
+            rxFrame[rxFrameIndex].addr = (void*)getGlobalAddr(bufRx[count]);
+            rxFrame[rxFrameIndex].size = BUFSIZE;
+            rxFrame[rxFrameIndex].arg = (uint32_t) hMcbspRxChan;
+            rxFrame[rxFrameIndex].status = MCBSP_STATUS_COMPLETED;
+            rxFrame[rxFrameIndex].misc = 1;   /* reserved - used in callback to indicate asynch packet */
+
+            status = mcbspSubmitChan(hMcbspRxChan, (void *)&rxFrame[rxFrameIndex]);
+            if (status != MCBSP_STATUS_PENDING)
+            {
+                System_printf ("Debug(Core %d): Error: RX buffer #%d submission FAILED\n", coreNum, count);
+                retval = 1;
+            }
+            else
+            {
+#ifdef MCBSP_APP_VERBOSE
+                System_printf ("Debug(Core %d): RX buffer #%d is submitted to MCBSP driver\n", coreNum, count);
+#endif
+            }
+            rxFrameIndex++;
+            rxFrameIndex = (rxFrameIndex >= (NUM_OF_MCBSP_FRAMES)) ? 0 : rxFrameIndex;
+#endif
+            rxSubmitCount++;
+#ifdef MCBSP_LOOP_PING_PONG
+            /* Copy buffer from buffer to ping pong buffer*/
+            memcpy((uint8_t *)bufTxPingPong[pingPongIndex], (uint8_t *)bufTx[count],BUFSIZE);
+#else
+            /* TX frame processing */
+            txFrame[txFrameIndex].cmd = Mcbsp_IOBuf_Cmd_WRITE;
+            txFrame[txFrameIndex].addr = (void*)getGlobalAddr(bufTx[count]);
+            txFrame[txFrameIndex].size = BUFSIZE;
+            txFrame[txFrameIndex].arg = (uint32_t)hMcbspTxChan;
+            txFrame[txFrameIndex].status = MCBSP_STATUS_COMPLETED;
+            txFrame[txFrameIndex].misc = 1;   /* reserved - used in callback to indicate asynch packet */
+
+            status = mcbspSubmitChan(hMcbspTxChan, (void *)&txFrame[txFrameIndex]);
+            if (status != MCBSP_STATUS_PENDING)
+            {
+                System_printf ("Debug(Core %d): Error: TX buffer  #%d submission FAILED\n", coreNum, count);
+                retval = 1;
+            }
+            else
+            {
+#ifdef MCBSP_APP_VERBOSE
+                System_printf ("Debug(Core %d): TX buffer  #%d is submitted to MCBSP driver\n", coreNum, count);
+#endif
+            }
+            txFrameIndex++;
+            txFrameIndex = (txFrameIndex >= (NUM_OF_MCBSP_FRAMES)) ? 0 : txFrameIndex;
+#endif
+            txSubmitCount++;
+
+            /* Wait for TX and RX processing to complete */
+            while (1)
+            {
+                if (edmaTxDone == 1)
+                {
+#ifdef MCBSP_APP_VERBOSE
+                    System_printf ("Debug(Core %d): EDMA -> Buffer #-%d is transmitted to TX path\n", coreNum, count);
+#endif
+                    edmaTxDone = 0; /* Reset for next iteration */
+                    mcbspTxDone = 1;
+                }
+                if (edmaRxDone == 1)
+                {
+#ifdef MCBSP_APP_VERBOSE
+                    System_printf ("Debug(Core %d): EDMA -> Buffer #-%d is received from RX path\n", coreNum, count);
+#endif
+                    edmaRxDone = 0;  /* Reset for next iteration */
+                    mcbspRxDone = 1;
+                }
+                if ((mcbspTxDone == 1) && (mcbspRxDone == 1))
+                {
+                    mcbspTxDone = 0;  /* Reset for next iteration */
+                                   mcbspRxDone = 0;  /* Reset for next iteration */
+                                   break;
+                }
+            }
+#ifdef MCBSP_LOOP_PING_PONG
+            /* Change ping Pong Index */
+            pingPongIndex=(pingPongIndex)?0:1;
+
+            /* Copy buffer from buffer to other buffer*/
+            memcpy((void*)bufRx[count], (uint8_t *)bufRxPingPong[pingPongIndex],BUFSIZE);
+#endif
+            /* compare buffer contents */
+            for (tempCount = 0; tempCount < BUFSIZE; tempCount++)
+            {
+                if (((char *)bufTx[count])[tempCount] != ((char *)bufRx[count])[tempCount])
+                {
+#ifdef MCBSP_APP_VERBOSE
+                    System_printf("Debug(Core %d): Error: TX and RX frame data DOES NOT match in Buffer #-%d\n",
+                        coreNum, count);
+                    System_printf("Debug(Core %d): Error: Buffer index = %d, Tx data = %d, Rx data = %d\n", coreNum,
+                        tempCount, ((char *)bufTx[count])[tempCount], ((char *)bufRx[count])[tempCount]);
+#endif
+                    errBuffCount++;
+                    break;
+                }
+            }
+            if (tempCount >= BUFSIZE)
+            {
+#ifdef MCBSP_APP_VERBOSE
+                System_printf("Debug(Core %d): TX and RX frames data match in iteration-%d !!!\n", coreNum, count);
+#endif
+            }
+        }
+        init_count=0;
+        num_iterations++;
+#ifndef   MCBSP_EXTERNAL_CLOCK
+        if(num_iterations >= NUM_OF_ITERATIONS)
+            break;
+#endif
+        switch(debugCommand)
+        {
+        case DEBUG_COMMAND_RESTART_CHANNELS:
+            debugCommand=0;
+            /* Close channel and reopen */
+            /* Delete  RX channel */
+            status = mcbspDeleteChan(hMcbspRxChan);
+            if (MCBSP_STATUS_COMPLETED != status)
+            {
+                System_printf ("Debug(Core %d): Error: Delete Channel (RX) failed\n", coreNum);
+                return;
+            }
+
+            /* Delete TX channel*/
+            status = mcbspDeleteChan(hMcbspTxChan);
+            if (MCBSP_STATUS_COMPLETED != status)
+            {
+                System_printf ("Debug(Core %d): Error: Delete Channel (TX) failed\n", coreNum);
+                return;
+            }
+            /* Create a RX channel for receiving */
+            status = mcbspCreateChan(&hMcbspRxChan, hMcbspDev, MCBSP_MODE_INPUT, &mcbspChanparamRx, mcbspAppCallback, &rxChanMode);
+            if (MCBSP_STATUS_COMPLETED != status)
+            {
+                System_printf ("Debug(Core %d): Error: Create Channel (RX) failed\n", coreNum);
+                return;
+            }
+
+            /* Create a TX channel for the transmission */
+            status = mcbspCreateChan(&hMcbspTxChan, hMcbspDev, MCBSP_MODE_OUTPUT, &mcbspChanparamTx, mcbspAppCallback, &txChanMode);
+            if (MCBSP_STATUS_COMPLETED != status)
+            {
+                System_printf ("Debug(Core %d): Error: Create Channel (TX) failed\n", coreNum);
+                return;
+            }
+            edmaTxDone = 0;   /* Reset for next iteration */
+            edmaRxDone = 0;   /* Reset for next iteration */
+            mcbspTxDone = 0;  /* Reset for next iteration */
+            mcbspRxDone = 0;  /* Reset for next iteration */
+            goto restart_mcbsp_point;
+
+        default:
+            debugCommand=0;
+            break;
+
+        }
+
+    }
+
+    if ((errBuffCount == 0 ) & (retval ==0))
+    {
+        System_printf("Debug(Core %d): MCBSP Digital Loopback Application completed successfully : "\
+            "Num iterations %d  Num buffers per iteration %d!!!\n",
+            coreNum, num_iterations, NUM_BUFS);
+    }
+    else
+    {
+        System_printf("Debug(Core %d): MCBSP Digital Loopback application FAILED :  "\
+            "Num iterations %d  Num buffers per iteration %d Failed buffers %d!!!\n",
+            coreNum, num_iterations, NUM_BUFS, errBuffCount);
+    }
+
+    /* Delete  RX channel */
+    status = mcbspDeleteChan(hMcbspRxChan);
+    if (MCBSP_STATUS_COMPLETED != status)
+    {
+        System_printf ("Debug(Core %d): Error: Delete Channel (RX) failed\n", coreNum);
+        return;
+    }
+
+    /* Delete TX channel*/
+    status = mcbspDeleteChan(hMcbspTxChan);
+    if (MCBSP_STATUS_COMPLETED != status)
+    {
+        System_printf ("Debug(Core %d): Error: Delete Channel (TX) failed\n", coreNum);
+        return;
+    }
+    return;
+}
+
+/*
+ * \brief  Void main(Void)
+ *
+ *         Main function of the sample application. This function calls the
+ *         function to configure the mcbsp instance.
+ *
+ * \param  None
+ *
+ * \return None
+ */
+#include "ti/sysbios/hal/Cache.h"
+
+Void main(Void)
+{
+    Task_Params taskParams;
+    EDMA3_DRV_Result edmaResult = 0;
+    uint8_t uchValue, uchReadValue;
+
+    /* Get the core number. */
+    coreNum = 0; //CSL_chipReadReg (CSL_CHIP_DNUM);
+
+#ifdef SIMULATOR_SUPPORT
+#warn MCBSP Digital Loopback example is not supported on SIMULATOR !!!
+    System_printf ("MCBSP Digital Loopback example is not supported on SIMULATOR. Exiting!\n");
+    return;
+#else
+    System_printf ("Debug(Core %d): Running MCBSP Digital Loopback example on the DEVICE\n", coreNum);
+#endif
+
+    /* Initialize the system only if the core was configured to do so. */
+    if (coreNum == CORE_SYS_INIT)
+    {
+#if 0
+        System_printf ("Debug(Core %d): System Initialization for MCBSP\n", coreNum);
+        /* Read FPGA register */
+        if (0 != (platform_fpgaReadConfigReg(MCBSP_FPGA_MISC_REG_OFFSET, &uchReadValue)))
+        {
+            System_printf ("Debug(Core %d): FPGA McBSP_AMC_EN# register READ failed \n", coreNum);
+            return;
+        }
+        /* Clear field for configuration */
+        uchValue = (uchReadValue & (~0x3));
+#ifndef PLATFORM_FPGA_MCBSP_AMC_EN
+        uchValue |=  0x3;
+#endif
+        /* Drive McBSP_AMC_EN# high. Output SLCLKs, TxCLKs, RxCLKs, FSTs, FSRs as Hi-Z. 
+         * These clocks and syncs are tri-stated and McBSP is accessed over 80-pin header */
+        if (0 != (platform_fpgaWriteConfigReg(MCBSP_FPGA_MISC_REG_OFFSET, (uchValue))))
+        {
+            System_printf ("Debug(Core %d): FPGA McBSP_AMC_EN# register WRITE failed \n", coreNum);
+            return;
+        }
+
+        /* DEBUG: Verify if FPGA register is configured correctly */
+        if (0 != (platform_fpgaReadConfigReg(MCBSP_FPGA_MISC_REG_OFFSET, &uchReadValue)))
+        {
+            System_printf ("Debug(Core %d): FPGA McBSP_AMC_EN# register READ failed \n", coreNum);
+            return;
+        }
+
+        if (uchValue != uchReadValue)
+        {
+            System_printf ("Debug(Core %d): FPGA McBSP_AMC_EN# register setting failed \n", coreNum);
+            return;
+        }
+        else
+        {
+            System_printf ("Debug(Core %d): FPGA McBSP_AMC_EN# register is set to %d \n", coreNum, uchValue);
+        }
+#endif
+        /* MCBSP Driver Initialization: This should always be called before
+         * invoking the MCBSP Driver. */
+        mcbspInit();
+
+        /* Device Specific MCBSP Initializations */
+        McbspDevice_init();
+        
+        /* MCBSP Driver is operational at this time. */
+        System_printf ("Debug(Core %d): MCBSP Driver Initialization Done\n", coreNum);
+
+        /* Write to the SHARED memory location at this point in time. The other cores cannot execute
+         * till the MCBSP Driver is up and running. */
+        isMCBSPInitialized[0] = 1;
+
+        /* The MCBSP IP block has been initialized. We need to writeback the cache here because it will
+         * ensure that the rest of the cores which are waiting for MCBSP to be initialized would now be
+         * woken up. */
+        //CACHE_wbL1d ((void *) &isMCBSPInitialized[0], MCBSP_MAX_CACHE_ALIGN, CACHE_FENCE_WAIT);
+        Cache_wb ((void *) &isMCBSPInitialized[0], MCBSP_CACHE_LENGTH,0x7fff, 1);
+    }
+    else
+    {
+        /* All other cores need to wait for the MCBSP to be initialized before they proceed with the test. */ 
+        System_printf ("Debug(Core %d): Waiting for MCBSP to be initialized.\n", coreNum);
+
+        /* All other cores loop around forever till the MCBSP is up and running. 
+         * We need to invalidate the cache so that we always read this from the memory. */
+        while (isMCBSPInitialized[0] == 0)
+            //CACHE_invL1d ((void *) &isMCBSPInitialized[0], MCBSP_MAX_CACHE_ALIGN, CACHE_FENCE_WAIT);
+               Cache_inv ((void *) &isMCBSPInitialized[0], MCBSP_CACHE_LENGTH, 0x7fff, 1);
+
+
+        System_printf ("Debug(Core %d): MCBSP can now be used.\n", coreNum);
+    }
+
+    /* Initialize EDMA3 library */
+    hEdma[0] = edma3init(0, &edmaResult);
+
+    if (edmaResult != EDMA3_DRV_SOK)
+    {
+        /* Report EDMA Error */
+        System_printf("Debug(Core %d): EDMA Driver Initialization FAILED\n", coreNum);
+    }
+    else
+    {
+        System_printf("Debug(Core %d): EDMA Driver Initialization Done\n", coreNum);
+    }
+
+    /* Create the Digital Loopback Application Task */
+    Task_Params_init(&taskParams);
+    Task_create(mcbspDigLpbkApp, &taskParams, NULL);
+
+    /* Start BIOS */
+    BIOS_start();
+
+    return;
+}
+
+/* ========================================================================== */
+/*                                END OF FILE                                 */
+/* ========================================================================== */
diff --git a/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.cfg b/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.cfg
new file mode 100644 (file)
index 0000000..8c7dfd3
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *  Copyright 2012 by Texas Instruments Incorporated.
+ *
+ *  All rights reserved. Property of Texas Instruments Incorporated.
+ *  Restricted rights to use, duplicate or disclose this code are
+ *  granted through contract.
+ *
+ */
+
+/* THIS FILE WAS GENERATED BY ti.sysbios.genx */
+
+/*
+ *  ======== mcbspMasterDigLpbk.cfg ========
+ *
+ */
+
+/* Load and use the required BIOS packages */
+var BIOS    = xdc.useModule('ti.sysbios.BIOS');
+var Task    = xdc.useModule('ti.sysbios.knl.Task');
+var cache   = xdc.useModule('ti.sysbios.hal.Cache');
+var Idle    = xdc.useModule('ti.sysbios.knl.Idle');
+var Queue   = xdc.useModule('ti.sysbios.knl.Queue');
+var ECM     = xdc.useModule('ti.sysbios.family.c64p.EventCombiner');
+var CpIntc  = xdc.useModule('ti.sysbios.family.c66.tci66xx.CpIntc');
+var Memory  = xdc.useModule('xdc.runtime.Memory');
+var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
+
+/* Load and use the System Package */
+var System = xdc.useModule('xdc.runtime.System');
+var SysStd    = xdc.useModule('xdc.runtime.SysStd');
+
+/* Create a default system heap using ti.bios.HeapMem. */
+var heapMemParams1         = new HeapMem.Params;
+heapMemParams1.size        = 32768;
+heapMemParams1.sectionName = "systemHeap";
+Program.global.heap0       = HeapMem.create(heapMemParams1);
+
+/* This is the default memory heap. */
+Memory.defaultHeapInstance = Program.global.heap0;
+
+/*
+ * Create and install logger for the whole system.
+ * Enable Event Groups here and registering of ISR for specific GEM INTC is done
+ * using EventCombiner_dispatchPlug() and Hwi_eventMap() APIs
+ */
+ECM.eventGroupHwiNum[0] = 7;
+ECM.eventGroupHwiNum[1] = 8;
+ECM.eventGroupHwiNum[2] = 9;
+ECM.eventGroupHwiNum[3] = 10;
+
+/* Load and use the CSL, EDMA, PlatformLib etc. packages */
+//var cslSettings = xdc.useModule ('ti.csl.Settings');
+var Edma = xdc.loadPackage('ti.sdo.edma3.drv');
+//var PlatformLib = xdc.loadPackage('ti.platform.evmc6657l');
+
+/* Circular buffer size for System_printf() */
+System.SupportProxy = SysStd;
+
diff --git a/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.cmd b/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.cmd
new file mode 100644 (file)
index 0000000..2075530
--- /dev/null
@@ -0,0 +1,9 @@
+SECTIONS
+{
+    .init_array:     load >> L2SRAM
+    .mcbsp:          load >> L2SRAM
+    .mcbspSharedMem: load >> L2SRAM
+     platform_lib:   load >> L2SRAM
+     systemHeap:     load >> L2SRAM
+}
+
diff --git a/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk_osal.c b/example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk_osal.c
new file mode 100644 (file)
index 0000000..888513d
--- /dev/null
@@ -0,0 +1,641 @@
+/**
+ *   @file  mcbspMasterDigLpbk_osal.c
+ *
+ *   @brief   
+ *      This is the OS abstraction layer and is used by the MCBSP
+ *      driver for the MCBSP Example Digital Loopback Application. 
+ *
+ *  \par
+ *  ============================================================================
+ *  @n   (C) Copyright 2012, 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
+*/
+#include <xdc/std.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <xdc/runtime/IHeap.h>
+#include <xdc/runtime/System.h>
+#include <xdc/runtime/Memory.h>
+#include <xdc/runtime/Error.h>
+#include <ti/sysbios/knl/Semaphore.h>
+#include <ti/sysbios/BIOS.h>
+#include <ti/sysbios/knl/Task.h>
+#include <ti/sysbios/knl/Queue.h>
+#include <ti/sysbios/heaps/HeapBuf.h>
+#include <ti/sysbios/heaps/HeapMem.h>
+#include <ti/sysbios/hal/Hwi.h>
+#include <xdc/cfg/global.h>
+#include <ti/drv/mcbsp/mcbsp_drv.h>
+#if 0
+/* CSL Include Files */
+#include <ti/csl/csl_chip.h>
+#include <ti/csl/csl_semAux.h>
+#include <ti/csl/csl_cacheAux.h>
+#include <ti/csl/csl_xmcAux.h>
+#endif
+/* IPC includes */ 
+/* #include <ti/ipc/GateMP.h>
+#include <ti/ipc/Ipc.h>
+#include <ti/ipc/ListMP.h>
+#include <ti/ipc/SharedRegion.h> */
+
+/**********************************************************************
+ ************************** Local Definitions *************************
+ **********************************************************************/
+
+#define MCBSP_HW_SEM         1
+#define PLATFORM_SPI_HW_SEM     2   /**< SPI BUS arbitration - Used by platform library        */
+
+#ifdef MCBSP_LOOP_PING_PONG
+#define MAX_MEM_MGR_ENTRIES     8
+#else
+#define MAX_MEM_MGR_ENTRIES     4
+#endif
+
+typedef struct MEM_MGMT_ENTRY
+{
+    uint8_t*    ptrMemory;
+    uint32_t    isFree;
+}MEM_MGMT_ENTRY;
+
+MEM_MGMT_ENTRY     gDataBufferMemMgr[MAX_MEM_MGR_ENTRIES];
+int32_t            gDataBufferMemMgrMaxSize = 0;
+
+/**********************************************************************
+ ************************** Global Variables **************************
+ **********************************************************************/
+UInt32 malloc_counter = 0;
+UInt32 free_counter   = 0;
+
+/**********************************************************************
+ ************************** Extern Definitions ************************
+ **********************************************************************/
+
+
+/**********************************************************************
+ **************************** OSAL Functions **************************
+ **********************************************************************/
+
+/**
+ *  @b Description
+ *  @n  
+ *      Utility function which converts a local address to global.
+ *
+ *  @param[in]  addr
+ *      Local address to be converted
+ *
+ *  @retval
+ *      Global Address
+ */
+void *Osal_local2Global (void *addr)
+{
+       UInt32 corenum;
+
+       /* Get the core number. */
+       corenum = 0;//CSL_chipReadReg(CSL_CHIP_DNUM);
+       return addr;
+
+       if(((UInt32)addr & 0xff000000) == 0) {
+       /* Compute the global address. */
+               return ((void *)((UInt32)(addr) + (0x10000000 + (corenum*0x1000000))));
+       }
+       else
+               return(addr);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to allocate a memory block of the specified size.
+ *
+ *  @param[in]  numBytes
+ *      Number of bytes to be allocated.
+ *
+ *  @retval
+ *      Allocated block address
+ */
+Void* Osal_mcbspMalloc(UInt32 numBytes)
+{
+       Error_Block     errorBlock;
+    Void*       ptr;
+
+    /* Increment the allocation counter. */
+    malloc_counter++;  
+
+    /* Allocate the memory. */
+    ptr = Memory_alloc(NULL, numBytes, 0, &errorBlock);
+
+    /* Return the allocated memory block. */
+       return ptr;
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to clean up a specific memory block and is called
+ *      from the MCBSP Driver. 
+ *
+ *  @param[in]  ptr
+ *      Pointer to the memory block to be cleaned up.
+ *  @param[in]  size
+ *      Size of the memory block being cleaned up.
+ *
+ *  @retval
+ *      Not Applicable
+ */
+Void Osal_mcbspFree (Void* ptr, UInt32 size)
+{
+    /* Increment the free counter. */
+    free_counter++;    
+       Memory_free(NULL, ptr, size);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to allocate a block of memory for all the data buffer
+ *      operations. This function is called by the application.
+ *
+ *  @param[in]  numBuffers
+ *      Number of data buffers
+ *  @param[in]  dataBufferSize
+ *      Size of each data buffer
+ *
+ *  @retval
+ *      Success -   0
+ *  @retval
+ *      Error   -   <0
+ */
+int32_t Osal_dataBufferInitMemory(uint32_t dataBufferSize)
+{
+       Error_Block     errorBlock;
+    uint8_t*    ptrMemory;
+    uint32_t    index;
+
+    /* Allocate memory for all the data buffers */
+    ptrMemory = (uint8_t*)Memory_alloc(NULL, MAX_MEM_MGR_ENTRIES*dataBufferSize, 128, &errorBlock);
+    if (ptrMemory == NULL)
+        return -1;
+
+    /* Convert to a global address */
+    ptrMemory = Osal_local2Global(ptrMemory);
+    /* Now we chop up the memory and add it to the memory manager. */
+    for (index = 0; index < MAX_MEM_MGR_ENTRIES; index++)
+    {
+        /* Populate the data memory management entry. */
+        gDataBufferMemMgr[index].isFree    = 1;
+        gDataBufferMemMgr[index].ptrMemory = ptrMemory;
+
+        /* Increment the memory to the next address */
+        ptrMemory = ptrMemory + dataBufferSize;        
+    }
+
+    /* Remember the memory buffer size */
+    gDataBufferMemMgrMaxSize = dataBufferSize;
+
+    /* Memory Manager has been created. */
+    return 0;
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to allocate a data buffer of the specified
+ *      size. Data buffers should always be allocated from the global
+ *      address space.
+ *
+ *  @param[in]  numBytes
+ *      Number of bytes to be allocated.
+ *
+ *  @retval
+ *      Allocated block address
+ */
+Void* Osal_mcbspDataBufferMalloc(UInt32 numBytes)
+{
+    uint32_t    index;
+    void*       ptrMemory = NULL;
+
+    /* Basic Validation: Ensure that the memory size requested is within range. */
+    if (numBytes > gDataBufferMemMgrMaxSize)
+        return NULL;
+
+    /* Increment the allocation counter. */
+    malloc_counter++;
+
+    /* Lock out interrupts */
+    Hwi_disable();
+
+    /* Cycle through for a free entry. */
+    for (index = 0; index < MAX_MEM_MGR_ENTRIES; index++)
+    {
+        /* Check if the entry is free or not? */
+        if (gDataBufferMemMgr[index].isFree == 1) 
+        {
+            /* Entry was free. We can use it. */
+            ptrMemory = gDataBufferMemMgr[index].ptrMemory;
+
+            /* Mark the entry as used. */
+            gDataBufferMemMgr[index].isFree = 0;
+
+            /* We have found a match. */
+            break;
+        }
+    }
+
+    /* Unlock interrupts. */
+    Hwi_enable();
+
+    /* Return the allocated memory. */
+    return ptrMemory;  
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to clean up a previously allocated data buffer 
+ *      block. All data buffers are in the global address space
+ *
+ *  @param[in]  ptr
+ *      Pointer to the data buffer block to be cleaned up
+ *  @param[in]  size
+ *      Size of the data buffer
+ *
+ *  @retval
+ *      Not Applicable
+ */
+void Osal_mcbspDataBufferFree(void* ptr, uint32_t numBytes)
+{
+    uint32_t    index;
+
+    /* Increment the free counter. */
+    free_counter++;    
+
+    /* Lock out interrupts */
+    Hwi_disable();
+
+    /* Cycle through and clean up */
+    for (index = 0; index < MAX_MEM_MGR_ENTRIES; index++)
+    {
+        /* Check if the entry is free or not? */
+        if (gDataBufferMemMgr[index].ptrMemory == (uint8_t*)ptr) 
+        {
+            /* Mark the entry as free. */
+            gDataBufferMemMgr[index].isFree = 1;
+
+            /* We have found a match. */
+            break;
+        }
+    }
+
+    /* Unlock interrupts. */
+    Hwi_enable();
+    return;
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is the MCBSP OSAL Logging API which logs 
+ *      the messages on the console.
+ *
+ *  @param[in]  fmt
+ *      Formatted String.
+ *
+ *  @retval
+ *      Not Applicable
+ */
+Void Osal_mcbspLog( String fmt, ... )
+{
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to create a critical section.
+ *
+ *  @retval
+ *      Semaphore Handle created
+ */
+Void* Osal_mcbspCreateSem(Void)
+{
+    return (Void*)Semaphore_create(0, NULL, NULL);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to delete a critical section.
+ *
+ *  @param[in]  semHandle
+ *      Semaphore handle to be deleted
+ *
+ *  @retval
+ *      Not Applicable
+ */
+Void Osal_mcbspDeleteSem(Void* semHandle)
+{
+    Semaphore_delete(semHandle);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to pend on a semaphore
+ *
+ *  @param[in]  semHandle
+ *      Semaphore handle on which the API will pend
+ *
+ *  @retval
+ *      Not Applicable
+ */
+Void Osal_mcbspPendSem(Void* semHandle)
+{
+    Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to post a semaphore
+ *
+ *  @param[in]  semHandle
+ *      Semaphore handle which will be posted
+ *
+ *  @retval
+ *      Not Applicable
+ */
+Void Osal_mcbspPostSem(Void* semHandle)
+{
+    Semaphore_post(semHandle);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      This is the Multicore OSAL Implementation to protect the driver shared
+ *      resources across multiple cores.
+ *
+ *  @retval
+ *      Semaphore Opaque Handle
+ */
+void* Osal_mcbspEnterMultipleCoreCriticalSection(void)
+{
+    /* Get the hardware semaphore */
+   // while ((CSL_semAcquireDirect (MCBSP_HW_SEM)) == 0);
+    return NULL;
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is called to end the critical section which was protecting
+ *      shared resources from access across multiple cores.
+ *
+ *  @param[in]  critSectHandle
+ *      Semaphore opaque handle.
+ *
+ *  @retval
+ *      None
+ */
+Void  Osal_mcbspExitMultipleCoreCriticalSection(Void* critSectHandle)
+{
+    //CSL_semReleaseSemaphore (MCBSP_HW_SEM);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to provide critical section to prevent access of shared
+ *      resources from single core and multiple threads.  
+ *
+ *  @param[in]  drvHandle
+ *      Driver Handle which needs critical section to protect its resources.
+ *
+ *  @retval
+ *      Opaque handle
+ */
+Void* Osal_mcbspEnterSingleCoreCriticalSection()
+{
+    /* Disable interrupts */
+     return (Void*)Hwi_disable();
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is called to end the critical section access of shared resources
+ *      from single cores.
+ *
+ *  @param[in]  drvHandle
+ *      Driver Handle which needed critical section to protect its resources.
+ *  @param[in]  critSectHandle
+ *      Opaque handle retreived when the Single Core Protection Enter API was called
+ *
+ *  @retval
+ *      Not Applicable.
+ */
+Void Osal_mcbspExitSingleCoreCriticalSection(Void* critSectHandle)
+{
+    /* Driver Managed Configuration: We need to enable interrupts. */
+    Hwi_enable();
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used by the MCBSP driver to indicate that
+ *      its about to access a block of memory and we need to ensure
+ *      that the cache contents for this block are invalidated before
+ *      we try and use it.
+ *
+ *  @param[in]  ptr
+ *      Pointer to the buffer which is being accessed
+ *  @param[in]  size
+ *      Size of the buffer which is to be accessed.
+ *
+ *  @retval
+ *      None
+ */
+#include "ti/sysbios/hal/Cache.h"
+void Osal_mcbspBeginMemAccess(void* ptr, uint32_t size)
+{
+    UInt  key;
+
+    /* Disable Interrupts */
+    key = Hwi_disable();
+
+    /* Cleanup the prefetch buffer also. */
+    //CSL_XMC_invalidatePrefetchBuffer();
+
+    /* Invalidate the cache. */
+    //CACHE_invL1d (ptr, size, CACHE_FENCE_WAIT);
+
+    Cache_inv ((void *) ptr,size, 0x7fff, 1);
+
+    /* Reenable Interrupts. */
+    Hwi_restore(key);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used by the MCBSP driver to indicate that its 
+ *      ending access to a block of memory. We need to ensure that the
+ *      contents of the cache are written back to the actual memory.
+ *
+ *  @param[in]  ptr
+ *      Pointer to the buffer 
+ *  @param[in]  size
+ *      Size of the buffer 
+ *
+ *  @retval
+ *      None
+ */
+void Osal_mcbspEndMemAccess(void* ptr, uint32_t size)
+{
+    UInt  key;
+
+    /* Disable Interrupts */
+    key = Hwi_disable();
+
+    /* Writeback the cache. */
+    //CACHE_wbL1d (ptr, size, CACHE_FENCE_WAIT);
+    Cache_wb ((void *) ptr,size, 0x7fff, 1);
+    /* Reenable Interrupts. */
+    Hwi_restore(key);
+}
+
+/**
+ * @brief   The function is used by the MCBSP driver to test for an 
+ *          empty queue.
+ *
+ *  <b> Parameter </b>
+ *  @n  handle - Handle of a previously created Queue instance object 
+ *
+ *  <b> Return Value </b>
+ *  @n  TRUE - If the queue is empty
+ */
+Bool Osal_mcbspQueueEmpty(void* handle)
+{
+    return Queue_empty(handle);
+}
+
+/**
+ * @brief   The macro is used by the MCBSP driver to get an 
+ *          element from the front of queue. The function 
+ *          removes the element from the front of queue and
+ *          returns a pointer to it.
+ *
+ *  <b> Parameter </b>
+ *  @n  handle - Handle of a previously created Queue instance object 
+ *
+ *  <b> Return Value </b>
+ *  @n  Handle (pointer) to former first element
+ */
+void* Osal_mcbspQueueGet(void* handle)
+{
+    return Queue_get(handle);
+}
+
+/**
+ * @brief   The macro is used by the MCBSP driver to put an 
+ *          element at the end of queue. 
+ *
+ *  <b> Parameter </b>
+ *  @n  handle - Handle of a previously created Queue instance object 
+ *  @n  elem - Pointer to new queue element 
+ *
+ *  <b> Return Value </b>
+ *  @n  None
+ */
+void  Osal_mcbspQueuePut(void* handle, Mcbsp_QueueElem* elem)
+{
+    Queue_put(handle, (Queue_Elem *)elem);
+    return;
+}
+
+/**
+ * @brief   The macro is used by the MCBSP driver to wait 'n' 
+ *          bit clocks to ensure proper synchronization internally. 
+ *
+ *  <b> Parameter </b>
+ *  @n  nticks - Number of bit clocks to wait 
+ *
+ *  <b> Return Value </b>
+ *  @n  None
+ */
+void  Osal_mcbspWaitNBitClocks(uint32_t nticks)
+{
+    //Task_sleep(nticks);
+       int i=0;
+       for (i=0; i<100; i++);
+    return;
+}
+
+/* OSAL functions for Platform Library */
+uint8_t *Osal_platformMalloc (uint32_t num_bytes, uint32_t alignment)
+{
+       return malloc(num_bytes);
+}
+
+void Osal_platformFree (uint8_t *dataPtr, uint32_t num_bytes)
+{
+    /* Free up the memory */
+    if (dataPtr)
+    {
+        free(dataPtr);
+    }
+}
+
+void Osal_platformSpiCsEnter(void)
+{
+    /* Get the hardware semaphore.
+     *
+     * Acquire Multi core CPPI synchronization lock
+     */
+    //while ((CSL_semAcquireDirect (PLATFORM_SPI_HW_SEM)) == 0);
+
+    return;
+}
+
+void Osal_platformSpiCsExit (void)
+{
+    /* Release the hardware semaphore
+     *
+     * Release multi-core lock.
+     */
+    //CSL_semReleaseSemaphore (PLATFORM_SPI_HW_SEM);
+
+    return;
+}
diff --git a/example/k2g/MCBSPDigLpbk/sample_cs.c b/example/k2g/MCBSPDigLpbk/sample_cs.c
new file mode 100644 (file)
index 0000000..92c20ab
--- /dev/null
@@ -0,0 +1,420 @@
+/*
+ * sample_cs.c
+ *
+ * Sample functions showing the implementation of critical section entry/exit
+ * routines and various semaphore related routines (all BIOS6 depenedent).
+ * These implementations MUST be provided by the user / application, using the
+ * EDMA3 driver, for its correct functioning.
+ *
+ * Copyright (C) 2009-2012 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  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.
+ *
+*/
+
+#include <ti/sysbios/family/c64p/EventCombiner.h>
+#include <ti/sysbios/hal/Cache.h>
+#include <ti/sysbios/hal/Hwi.h>
+#include <ti/sysbios/knl/Task.h>
+#include <ti/sysbios/knl/Semaphore.h>
+
+#include "bios6_edma3_drv_sample.h"
+
+extern unsigned int ccXferCompInt[][EDMA3_MAX_REGIONS];
+extern unsigned int ccErrorInt[];
+extern unsigned int tcErrorInt[][EDMA3_MAX_TC];
+
+/**
+ * Shadow Region on which the executable is running. Its value is
+ * populated with the DSP Instance Number here in this case.
+ */
+extern unsigned int region_id;
+
+/**
+ * \brief   EDMA3 OS Protect Entry
+ *
+ *      This function saves the current state of protection in 'intState'
+ *      variable passed by caller, if the protection level is
+ *      EDMA3_OS_PROTECT_INTERRUPT. It then applies the requested level of
+ *      protection.
+ *      For EDMA3_OS_PROTECT_INTERRUPT_XFER_COMPLETION and
+ *      EDMA3_OS_PROTECT_INTERRUPT_CC_ERROR, variable 'intState' is ignored,
+ *      and the requested interrupt is disabled.
+ *      For EDMA3_OS_PROTECT_INTERRUPT_TC_ERROR, '*intState' specifies the
+ *      Transfer Controller number whose interrupt needs to be disabled.
+ *
+ * \param   level is numeric identifier of the desired degree of protection.
+ * \param   intState is memory location where current state of protection is
+ *      saved for future use while restoring it via edma3OsProtectExit() (Only
+ *      for EDMA3_OS_PROTECT_INTERRUPT protection level).
+ * \return  None
+ */
+void edma3OsProtectEntry (unsigned int edma3InstanceId,
+                                                       int level, unsigned int *intState)
+    {
+    if (((level == EDMA3_OS_PROTECT_INTERRUPT)
+        || (level == EDMA3_OS_PROTECT_INTERRUPT_TC_ERROR))
+        && (intState == NULL))
+        {
+        return;
+        }
+    else
+        {
+        switch (level)
+            {
+            /* Disable all (global) interrupts */
+            case EDMA3_OS_PROTECT_INTERRUPT :
+                *intState = Hwi_disable();
+                break;
+
+            /* Disable scheduler */
+            case EDMA3_OS_PROTECT_SCHEDULER :
+                                       Task_disable();
+                break;
+
+            /* Disable EDMA3 transfer completion interrupt only */
+            case EDMA3_OS_PROTECT_INTERRUPT_XFER_COMPLETION :
+                EventCombiner_disableEvent(ccXferCompInt[edma3InstanceId][region_id]);
+                break;
+
+            /* Disable EDMA3 CC error interrupt only */
+            case EDMA3_OS_PROTECT_INTERRUPT_CC_ERROR :
+                EventCombiner_disableEvent(ccErrorInt[edma3InstanceId]);
+                break;
+
+            /* Disable EDMA3 TC error interrupt only */
+            case EDMA3_OS_PROTECT_INTERRUPT_TC_ERROR :
+                switch (*intState)
+                    {
+                    case 0:
+                    case 1:
+                    case 2:
+                    case 3:
+                    case 4:
+                    case 5:
+                    case 6:
+                    case 7:
+                        /* Fall through... */
+                        /* Disable the corresponding interrupt */
+                        EventCombiner_disableEvent(tcErrorInt[edma3InstanceId][*intState]);
+                        break;
+
+                     default:
+                        break;
+                    }
+
+                break;
+
+            default:
+                break;
+            }
+        }
+    }
+
+
+/**
+ * \brief   EDMA3 OS Protect Exit
+ *
+ *      This function undoes the protection enforced to original state
+ *      as is specified by the variable 'intState' passed, if the protection
+ *      level is EDMA3_OS_PROTECT_INTERRUPT.
+ *      For EDMA3_OS_PROTECT_INTERRUPT_XFER_COMPLETION and
+ *      EDMA3_OS_PROTECT_INTERRUPT_CC_ERROR, variable 'intState' is ignored,
+ *      and the requested interrupt is enabled.
+ *      For EDMA3_OS_PROTECT_INTERRUPT_TC_ERROR, 'intState' specifies the
+ *      Transfer Controller number whose interrupt needs to be enabled.
+ * \param   level is numeric identifier of the desired degree of protection.
+ * \param   intState is original state of protection at time when the
+ *      corresponding edma3OsProtectEntry() was called (Only
+ *      for EDMA3_OS_PROTECT_INTERRUPT protection level).
+ * \return  None
+ */
+void edma3OsProtectExit (unsigned int edma3InstanceId,
+                        int level, unsigned int intState)
+    {
+    switch (level)
+        {
+        /* Enable all (global) interrupts */
+        case EDMA3_OS_PROTECT_INTERRUPT :
+            Hwi_restore(intState);
+            break;
+
+        /* Enable scheduler */
+        case EDMA3_OS_PROTECT_SCHEDULER :
+            Task_enable();
+            break;
+
+        /* Enable EDMA3 transfer completion interrupt only */
+        case EDMA3_OS_PROTECT_INTERRUPT_XFER_COMPLETION :
+            EventCombiner_enableEvent(ccXferCompInt[edma3InstanceId][region_id]);
+            break;
+
+        /* Enable EDMA3 CC error interrupt only */
+        case EDMA3_OS_PROTECT_INTERRUPT_CC_ERROR :
+            EventCombiner_enableEvent(ccErrorInt[edma3InstanceId]);
+            break;
+
+        /* Enable EDMA3 TC error interrupt only */
+        case EDMA3_OS_PROTECT_INTERRUPT_TC_ERROR :
+            switch (intState)
+                {
+                case 0:
+                case 1:
+                case 2:
+                case 3:
+                case 4:
+                case 5:
+                case 6:
+                case 7:
+                    /* Fall through... */
+                    /* Enable the corresponding interrupt */
+                    EventCombiner_enableEvent(tcErrorInt[edma3InstanceId][intState]);
+                    break;
+
+                 default:
+                    break;
+                }
+
+            break;
+
+        default:
+            break;
+        }
+    }
+
+
+/**
+ *  \brief   EDMA3 Cache Invalidate
+ *
+ *  This function invalidates the D cache.
+ *
+ *  \param  mem_start_ptr [IN]      Starting address of memory.
+ *                                  Please note that this should be
+ *                                  aligned according to the cache line size.
+ *  \param  num_bytes [IN]          length of buffer
+ *  \return  EDMA3_DRV_SOK if success, else error code in case of error
+ *          or non-alignment of buffers.
+ *
+ * Note: This function is required if the buffer is in DDR.
+ * For other cases, where buffer is NOT in DDR, user
+ * may or may not require the below implementation and
+ * should modify it according to her need.
+ */
+EDMA3_DRV_Result Edma3_CacheInvalidate(unsigned int mem_start_ptr,
+                           unsigned int    num_bytes)
+    {
+    EDMA3_DRV_Result cacheInvResult = EDMA3_DRV_SOK;
+
+    /* Verify whether the start address is cache aligned or not */
+    if((mem_start_ptr & (EDMA3_CACHE_LINE_SIZE_IN_BYTES-1u))    !=    0)
+        {
+#ifdef EDMA3_DRV_DEBUG
+        EDMA3_DRV_PRINTF("\r\n Cache : Memory is not %d bytes alinged\r\n",
+                            EDMA3_CACHE_LINE_SIZE_IN_BYTES);
+#endif
+        cacheInvResult = EDMA3_NON_ALIGNED_BUFFERS_ERROR;
+        }
+    else
+        {
+               Cache_inv((Ptr)mem_start_ptr, num_bytes, Cache_Type_ALL, TRUE);
+        }
+
+    return cacheInvResult;
+}
+
+
+
+/**
+ * \brief   EDMA3 Cache Flush
+ *
+ *  This function flushes (cleans) the Cache
+ *
+ *  \param  mem_start_ptr [IN]      Starting address of memory.
+ *                                  Please note that this should be
+ *                                  aligned according to the cache line size.
+ *  \param  num_bytes [IN]          length of buffer
+ *  \return  EDMA3_DRV_SOK if success, else error code in case of error
+ *          or non-alignment of buffers.
+ *
+ * Note: This function is required if the buffer is in DDR.
+ * For other cases, where buffer is NOT in DDR, user
+ * may or may not require the below implementation and
+ * should modify it according to her need.
+ */
+EDMA3_DRV_Result Edma3_CacheFlush(unsigned int mem_start_ptr,
+                      unsigned int num_bytes)
+    {
+    EDMA3_DRV_Result cacheFlushResult = EDMA3_DRV_SOK;
+
+    /* Verify whether the start address is cache aligned or not */
+    if((mem_start_ptr & (EDMA3_CACHE_LINE_SIZE_IN_BYTES-1u))    !=    0)
+        {
+#ifdef EDMA3_DRV_DEBUG
+        EDMA3_DRV_PRINTF("\r\n Cache : Memory is not %d bytes alinged\r\n",
+                            EDMA3_CACHE_LINE_SIZE_IN_BYTES);
+#endif
+        cacheFlushResult = EDMA3_NON_ALIGNED_BUFFERS_ERROR;
+        }
+    else
+        {
+               Cache_wb((Ptr)mem_start_ptr, num_bytes, Cache_Type_ALL, TRUE);
+        }
+
+    return cacheFlushResult;
+}
+
+
+/**
+  * Counting Semaphore related functions (OS dependent) should be
+  * called/implemented by the application. A handle to the semaphore
+  * is required while opening the driver/resource manager instance.
+  */
+
+/**
+ * \brief   EDMA3 OS Semaphore Create
+ *
+ *      This function creates a counting semaphore with specified
+ *      attributes and initial value. It should be used to create a semaphore
+ *      with initial value as '1'. The semaphore is then passed by the user
+ *      to the EDMA3 driver/RM for proper sharing of resources.
+ * \param   initVal [IN] is initial value for semaphore
+ * \param   semParams [IN] is the semaphore attributes.
+ * \param   hSem [OUT] is location to recieve the handle to just created
+ *      semaphore
+ * \return  EDMA3_DRV_SOK if succesful, else a suitable error code.
+ */
+EDMA3_DRV_Result edma3OsSemCreate(int initVal,
+                                                       const Semaphore_Params *semParams,
+                               EDMA3_OS_Sem_Handle *hSem)
+    {
+    EDMA3_DRV_Result semCreateResult = EDMA3_DRV_SOK;
+
+    if(NULL == hSem)
+        {
+        semCreateResult = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    else
+        {
+        *hSem = (EDMA3_OS_Sem_Handle)Semaphore_create(initVal, semParams, NULL);
+        if ( (*hSem) == NULL )
+            {
+            semCreateResult = EDMA3_DRV_E_SEMAPHORE;
+            }
+        }
+
+    return semCreateResult;
+    }
+
+
+/**
+ * \brief   EDMA3 OS Semaphore Delete
+ *
+ *      This function deletes or removes the specified semaphore
+ *      from the system. Associated dynamically allocated memory
+ *      if any is also freed up.
+ * \param   hSem [IN] handle to the semaphore to be deleted
+ * \return  EDMA3_DRV_SOK if succesful else a suitable error code
+ */
+EDMA3_DRV_Result edma3OsSemDelete(EDMA3_OS_Sem_Handle hSem)
+    {
+    EDMA3_DRV_Result semDeleteResult = EDMA3_DRV_SOK;
+
+    if(NULL == hSem)
+        {
+        semDeleteResult = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    else
+        {
+               Semaphore_delete((Semaphore_Handle *)&hSem);
+        }
+
+    return semDeleteResult;
+    }
+
+
+/**
+ * \brief   EDMA3 OS Semaphore Take
+ *
+ *      This function takes a semaphore token if available.
+ *      If a semaphore is unavailable, it blocks currently
+ *      running thread in wait (for specified duration) for
+ *      a free semaphore.
+ * \param   hSem [IN] is the handle of the specified semaphore
+ * \param   mSecTimeout [IN] is wait time in milliseconds
+ * \return  EDMA3_DRV_Result if successful else a suitable error code
+ */
+EDMA3_DRV_Result edma3OsSemTake(EDMA3_OS_Sem_Handle hSem, int mSecTimeout)
+    {
+    EDMA3_DRV_Result semTakeResult = EDMA3_DRV_SOK;
+    unsigned short semPendResult;
+
+    if(NULL == hSem)
+        {
+        semTakeResult = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    else
+        {
+        semPendResult = Semaphore_pend(hSem, mSecTimeout);
+        if (semPendResult == FALSE)
+            {
+            semTakeResult = EDMA3_DRV_E_SEMAPHORE;
+            }
+        }
+
+    return semTakeResult;
+    }
+
+
+/**
+ * \brief   EDMA3 OS Semaphore Give
+ *
+ *      This function gives or relinquishes an already
+ *      acquired semaphore token
+ * \param   hSem [IN] is the handle of the specified semaphore
+ * \return  EDMA3_DRV_Result if successful else a suitable error code
+ */
+EDMA3_DRV_Result edma3OsSemGive(EDMA3_OS_Sem_Handle hSem)
+    {
+    EDMA3_DRV_Result semGiveResult = EDMA3_DRV_SOK;
+
+    if(NULL == hSem)
+        {
+        semGiveResult = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    else
+        {
+               Semaphore_post(hSem);
+        }
+
+    return semGiveResult;
+    }
+
+/* End of File */
+
diff --git a/example/k2g/MCBSPDigLpbk/sample_init.c b/example/k2g/MCBSPDigLpbk/sample_init.c
new file mode 100644 (file)
index 0000000..54fc955
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ * sample_init.c
+ *
+ * Sample Initialization for the EDMA3 Driver for BIOS 6 based applications.
+ * It should be MANDATORILY done once before EDMA3 usage.
+ *
+ * Copyright (C) 2009-2012 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  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.
+ *
+*/
+
+#include <ti/sysbios/hal/Hwi.h>
+#include <ti/sysbios/knl/Semaphore.h>
+#include <ti/sysbios/family/c64p/EventCombiner.h>
+
+#include "bios6_edma3_drv_sample.h"
+
+/** @brief EDMA3 Driver Instance specific Semaphore handle */
+extern EDMA3_OS_Sem_Handle semHandle[];
+
+/**  To Register the ISRs with the underlying OS, if required. */
+extern void registerEdma3Interrupts (unsigned int edma3Id);
+/**  To Unregister the ISRs with the underlying OS, if previously registered. */
+extern void unregisterEdma3Interrupts (unsigned int edma3Id);
+
+/* To find out the DSP# */
+extern unsigned short determineProcId();
+
+/**
+ * To check whether the global EDMA3 configuration is required or not.
+ * It should be done ONCE by any of the masters present in the system.
+ * This function checks whether the global configuration is required by the
+ * current master or not. In case of many masters, it should be done only
+ * by one of the masters. Hence this function will return TRUE only once
+ * and FALSE for all other masters. 
+ */
+extern unsigned short isGblConfigRequired(unsigned int dspNum);
+
+/**
+ * DSP instance number on which the executable is running. Its value is
+ * determined by reading the processor specific register DNUM.
+ */
+unsigned int dsp_num;
+
+/**
+ * Shadow Region on which the executable is runnig. Its value is populated
+ * with the DSP Instance Number here in this case.
+ */
+unsigned int region_id;
+
+/* Number of EDMA3 controllers present in the system */
+extern const unsigned int numEdma3Instances;
+
+/* External Global Configuration Structure */
+extern EDMA3_DRV_GblConfigParams sampleEdma3GblCfgParams[];
+
+/* External Instance Specific Configuration Structure */
+extern EDMA3_DRV_InstanceInitConfig sampleInstInitConfig[][EDMA3_MAX_REGIONS];
+
+#if defined (CHIP_TI814X)
+extern EDMA3_DRV_Result sampleInitXbarEvt(EDMA3_DRV_Handle hEdma, unsigned int edma3Id);
+#endif
+
+/**
+ * \brief   EDMA3 Initialization
+ *
+ * This function initializes the EDMA3 Driver and registers the
+ * interrupt handlers.
+ *
+  * \return  EDMA3_DRV_SOK if success, else error code
+ */
+EDMA3_DRV_Handle edma3init (unsigned int edma3Id, EDMA3_DRV_Result *errorCode)
+    {
+    EDMA3_DRV_Result edma3Result = EDMA3_DRV_E_INVALID_PARAM;
+    Semaphore_Params semParams;
+    EDMA3_DRV_GblConfigParams *globalConfig = NULL;
+       EDMA3_DRV_InitConfig initCfg;
+       EDMA3_RM_MiscParam miscParam;
+       EDMA3_DRV_Handle hEdma = NULL;
+
+       if ((edma3Id >= numEdma3Instances) || (errorCode == NULL))
+               return hEdma;
+
+    /* DSP instance number */
+    dsp_num = determineProcId();
+//    dsp_num = 0; /* selection of region ID */
+
+       globalConfig = &sampleEdma3GblCfgParams[edma3Id];
+
+       /* Configure it as master, if required */
+       miscParam.isSlave = isGblConfigRequired(dsp_num);
+       edma3Result = EDMA3_DRV_create (edma3Id, globalConfig ,
+                                                                       (void *)&miscParam);
+
+       if (edma3Result == EDMA3_DRV_SOK)
+               {
+               /**
+               * Driver Object created successfully.
+               * Create a semaphore now for driver instance.
+               */
+               Semaphore_Params_init(&semParams);
+
+               initCfg.drvSemHandle = NULL;
+               edma3Result = edma3OsSemCreate(1, &semParams, &initCfg.drvSemHandle);
+               }
+
+       if (edma3Result == EDMA3_DRV_SOK)
+               {
+               /* Save the semaphore handle for future use */
+               semHandle[edma3Id] = initCfg.drvSemHandle;
+
+        /* Driver instance specific config NULL */
+               initCfg.drvInstInitConfig = NULL;
+
+#ifndef EDMA3_DRV_USE_DEF_RM_CFG
+        /* Hook for running examples with default RM config */
+               /* configuration structure for the Driver */
+               initCfg.drvInstInitConfig = &sampleInstInitConfig[edma3Id][dsp_num];
+#endif
+
+               initCfg.isMaster = TRUE;
+               /* Choose shadow region according to the DSP# */
+               initCfg.regionId = (EDMA3_RM_RegionId)dsp_num;
+               /*Saving the regionId for using it in the sample_cs.c file */
+               region_id = (EDMA3_RM_RegionId)dsp_num;
+               /* Driver instance specific config NULL */
+
+               initCfg.gblerrCb = NULL;
+               initCfg.gblerrData = NULL;
+
+               /* Open the Driver Instance */
+               hEdma = EDMA3_DRV_open (edma3Id, (void *) &initCfg, &edma3Result);
+               }
+
+#if defined (CHIP_TI814X)
+       {
+       if(hEdma && (edma3Result == EDMA3_DRV_SOK))
+               {
+               edma3Result = sampleInitXbarEvt(hEdma, edma3Id);
+               }
+       }
+#endif
+       if(hEdma && (edma3Result == EDMA3_DRV_SOK))
+               {
+               /**
+               * Register Interrupt Handlers for various interrupts
+               * like transfer completion interrupt, CC error
+               * interrupt, TC error interrupts etc, if required.
+               */
+               registerEdma3Interrupts(edma3Id);
+               }
+
+       *errorCode = edma3Result;       
+       return hEdma;
+    }
+
+
+/**
+ * \brief   EDMA3 De-initialization
+ *
+ * This function removes the EDMA3 Driver instance and unregisters the
+ * interrupt handlers.
+ *
+  * \return  EDMA3_DRV_SOK if success, else error code
+ */
+EDMA3_DRV_Result edma3deinit (unsigned int edma3Id, EDMA3_DRV_Handle hEdma)
+    {
+    EDMA3_DRV_Result edma3Result = EDMA3_DRV_E_INVALID_PARAM;
+
+    /* Unregister Interrupt Handlers first */
+    unregisterEdma3Interrupts(edma3Id);
+
+    /* Delete the semaphore */
+    edma3Result = edma3OsSemDelete(semHandle[edma3Id]);
+
+    if (EDMA3_DRV_SOK == edma3Result )
+        {
+        /* Make the semaphore handle as NULL. */
+        semHandle[edma3Id] = NULL;
+
+        /* Now, close the EDMA3 Driver Instance */
+        edma3Result = EDMA3_DRV_close (hEdma, NULL);
+       }
+
+       if (EDMA3_DRV_SOK == edma3Result )
+        {
+        /* Now, delete the EDMA3 Driver Object */
+        edma3Result = EDMA3_DRV_delete (edma3Id, NULL);
+        }
+
+    return edma3Result;
+    }
+
+/* End of File */
+
diff --git a/example/k2g/MCBSPDigLpbk/sample_k2g_cfg.c b/example/k2g/MCBSPDigLpbk/sample_k2g_cfg.c
new file mode 100644 (file)
index 0000000..36e4e45
--- /dev/null
@@ -0,0 +1,1217 @@
+/*
+ * sample_galileo_cfg.c
+ *
+ * Platform specific EDMA3 hardware related information like number of transfer
+ * controllers, various interrupt ids etc. It is used while interrupts
+ * enabling / disabling. It needs to be ported for different SoCs.
+ *
+ * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  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.
+ *
+*/
+
+#include <ti/sdo/edma3/rm/edma3_rm.h>
+
+/* Number of EDMA3 controllers present in the system */
+#define NUM_EDMA3_INSTANCES                    2u
+const unsigned int numEdma3Instances = NUM_EDMA3_INSTANCES;
+
+/* Number of DSPs present in the system */
+#define NUM_DSPS                                       1u
+//const unsigned int numDsps = NUM_DSPS;
+
+#define CGEM_REG_START                  (0x01800000)
+
+
+extern cregister volatile unsigned int DNUM;
+
+#define MAP_LOCAL_TO_GLOBAL_ADDR(addr) ((1<<28)|(DNUM<<24)|(((unsigned int)addr)&0x00ffffff))
+
+
+/* Determine the processor id by reading DNUM register. */
+unsigned short determineProcId()
+       {
+       volatile unsigned int *addr;
+       unsigned int core_no;
+
+    /* Identify the core number */
+    addr = (unsigned int *)(CGEM_REG_START+0x40000);
+    core_no = ((*addr) & 0x000F0000)>>16;
+
+       return core_no;
+       }
+
+signed char*  getGlobalAddr(signed char* addr)
+{
+    if (((unsigned int)addr & (unsigned int)0xFF000000) != 0)
+    {
+        return (addr); /* The address is already a global address */
+    }
+
+    return((signed char*)(MAP_LOCAL_TO_GLOBAL_ADDR(addr)));
+}
+/** Whether global configuration required for EDMA3 or not.
+ * This configuration should be done only once for the EDMA3 hardware by
+ * any one of the masters (i.e. DSPs).
+ * It can be changed depending on the use-case.
+ */
+unsigned int gblCfgReqdArray [NUM_DSPS] = {
+                                                                       0,      /* DSP#0 is Master, will do the global init */
+
+                                                                       };
+
+unsigned short isGblConfigRequired(unsigned int dspNum)
+       {
+       return gblCfgReqdArray[dspNum];
+       }
+
+/* Semaphore handles */
+EDMA3_OS_Sem_Handle semHandle[NUM_EDMA3_INSTANCES] = {NULL,NULL};
+
+
+/* Variable which will be used internally for referring number of Event Queues. */
+unsigned int numEdma3EvtQue[NUM_EDMA3_INSTANCES] = {2u, 2u};
+
+/* Variable which will be used internally for referring number of TCs. */
+unsigned int numEdma3Tc[NUM_EDMA3_INSTANCES] = {2u, 2u};
+
+/**
+ * Variable which will be used internally for referring transfer completion
+ * interrupt. Completion interrupts for all the shadow regions and all the
+ * EDMA3 controllers are captured since it is a multi-DSP platform.
+ */
+unsigned int ccXferCompInt[NUM_EDMA3_INSTANCES][EDMA3_MAX_REGIONS] = {
+                                                                                                       {
+                                                                                                       0x88, 0x89, 0x8a, 0x8b,
+                                                                                                       0x8c, 0x8d, 0x8e, 0x8f,
+                                                                                                       },
+                                                                                                       {
+                                                                                                       0x90, 0x91, 0x92, 0x93,
+                                                                                                       0x94, 0x95, 0x96, 0x97,
+                                                                                                       },
+                                                                                               };
+
+/**
+ * Variable which will be used internally for referring channel controller's
+ * error interrupt.
+ */
+unsigned int ccErrorInt[NUM_EDMA3_INSTANCES] = {0x99, 0x9c};
+
+/**
+ * Variable which will be used internally for referring transfer controllers'
+ * error interrupts.
+ */
+unsigned int tcErrorInt[NUM_EDMA3_INSTANCES][EDMA3_MAX_TC] =    {
+                                                                                                       {
+                                                                                                       0xA0,0xA1, 0u, 0u,
+                                                                                                       0u, 0u, 0u, 0u,
+                                                                                                       },
+                                                                                                       {
+                                                                                                       0xA4, 0xA5, 0u, 0u,
+                                                                                                       0u, 0u, 0u, 0u,
+                                                                                                       },
+                                                                                               };
+
+/* Driver Object Initialization Configuration */
+EDMA3_RM_GblConfigParams sampleEdma3GblCfgParams[NUM_EDMA3_INSTANCES] =
+       {
+               {
+               /* EDMA3 INSTANCE# 0 */
+               /** Total number of DMA Channels supported by the EDMA3 Controller */
+               64u,
+               /** Total number of QDMA Channels supported by the EDMA3 Controller */
+               8u,
+               /** Total number of TCCs supported by the EDMA3 Controller */
+               64u,
+               /** Total number of PaRAM Sets supported by the EDMA3 Controller */
+               512u,
+               /** Total number of Event Queues in the EDMA3 Controller */
+               2u,
+               /** Total number of Transfer Controllers (TCs) in the EDMA3 Controller */
+               2u,
+               /** Number of Regions on this EDMA3 controller */
+               8u,
+
+               /**
+                * \brief Channel mapping existence
+                * A value of 0 (No channel mapping) implies that there is fixed association
+                * for a channel number to a parameter entry number or, in other words,
+                * PaRAM entry n corresponds to channel n.
+                */
+               1u,
+
+               /** Existence of memory protection feature */
+               1u,
+
+               /** Global Register Region of CC Registers */
+               (void *)0x02700000u,
+               /** Transfer Controller (TC) Registers */
+               {
+               (void *)0x02760000u,
+               (void *)0x02768000u,
+               (void *)NULL,
+               (void *)NULL,
+               (void *)NULL,
+               (void *)NULL,
+               (void *)NULL,
+               (void *)NULL,
+               },
+               /** Interrupt no. for Transfer Completion */
+               0x88,
+               /** Interrupt no. for CC Error */
+               0x99,
+               /** Interrupt no. for TCs Error */
+               {
+               0xA0,
+               0xA1,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               },
+
+               /**
+                * \brief EDMA3 TC priority setting
+                *
+                * User can program the priority of the Event Queues
+                * at a system-wide level.  This means that the user can set the
+                * priority of an IO initiated by either of the TCs (Transfer Controllers)
+                * relative to IO initiated by the other bus masters on the
+                * device (ARM, DSP, USB, etc)
+                */
+               {
+               0u,
+               1u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               },
+               /**
+                * \brief To Configure the Threshold level of number of events
+                * that can be queued up in the Event queues. EDMA3CC error register
+                * (CCERR) will indicate whether or not at any instant of time the
+                * number of events queued up in any of the event queues exceeds
+                * or equals the threshold/watermark value that is set
+                * in the queue watermark threshold register (QWMTHRA).
+                */
+               {
+               16u,
+               16u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               },
+
+               /**
+                * \brief To Configure the Default Burst Size (DBS) of TCs.
+                * An optimally-sized command is defined by the transfer controller
+                * default burst size (DBS). Different TCs can have different
+                * DBS values. It is defined in Bytes.
+                */
+               {
+               128u,
+               128u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               },
+
+               /**
+                * \brief Mapping from each DMA channel to a Parameter RAM set,
+                * if it exists, otherwise of no use.
+                */
+               {
+               0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u,
+               8u, 9u, 10u, 11u, 12u, 13u, 14u, 15u,
+               16u, 17u, 18u, 19u, 20u, 21u, 22u, 23u,
+               24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u,
+               32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u,
+               40u, 41u, 42u, 43u, 44u, 45u, 46u, 47u,
+               48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u,
+               56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u,
+               },
+
+                /**
+                 * \brief Mapping from each DMA channel to a TCC. This specific
+                 * TCC code will be returned when the transfer is completed
+                 * on the mapped channel.
+                 */
+               {
+               0u, 1u, 2u, EDMA3_RM_CH_NO_TCC_MAP, 4u, 5u, 6u, EDMA3_RM_CH_NO_TCC_MAP,
+               8u, 9u, 10u, EDMA3_RM_CH_NO_TCC_MAP, 12u, 13u, 14u, EDMA3_RM_CH_NO_TCC_MAP,
+               16u, 17u, 18u, EDMA3_RM_CH_NO_TCC_MAP, 20u, 21u, 22u, EDMA3_RM_CH_NO_TCC_MAP,
+               24u, 25u, 26u, 27u, 28u, 29u, 30u, EDMA3_RM_CH_NO_TCC_MAP,
+               32u, 33u, 34u, 35u, 36u, 37u, 38u, EDMA3_RM_CH_NO_TCC_MAP,
+               40u, 41u, 42u, EDMA3_RM_CH_NO_TCC_MAP, 44u, 45u, 46u, EDMA3_RM_CH_NO_TCC_MAP,
+               48u, 49u, 50u, 51u, 52u, 53u, 54u, EDMA3_RM_CH_NO_TCC_MAP,
+               56u, 57u, 58u, 59u, 60u, 61u, 62u, EDMA3_RM_CH_NO_TCC_MAP
+               },
+
+               /**
+                * \brief Mapping of DMA channels to Hardware Events from
+                * various peripherals, which use EDMA for data transfer.
+                * All channels need not be mapped, some can be free also.
+                */
+               {
+               0x0F000000u,
+               0x0000000Fu
+               }
+               },
+
+               {
+               /* EDMA3 INSTANCE# 1 */
+               /** Total number of DMA Channels supported by the EDMA3 Controller */
+               64u,
+               /** Total number of QDMA Channels supported by the EDMA3 Controller */
+               8u,
+               /** Total number of TCCs supported by the EDMA3 Controller */
+               64u,
+               /** Total number of PaRAM Sets supported by the EDMA3 Controller */
+               512u,
+               /** Total number of Event Queues in the EDMA3 Controller */
+               2u,
+               /** Total number of Transfer Controllers (TCs) in the EDMA3 Controller */
+               2u,
+               /** Number of Regions on this EDMA3 controller */
+               8u,
+
+               /**
+                * \brief Channel mapping existence
+                * A value of 0 (No channel mapping) implies that there is fixed association
+                * for a channel number to a parameter entry number or, in other words,
+                * PaRAM entry n corresponds to channel n.
+                */
+               1u,
+
+               /** Existence of memory protection feature */
+               1u,
+
+               /** Global Register Region of CC Registers */
+               (void *)0x02728000U,
+               /** Transfer Controller (TC) Registers */
+               {
+               (void *)0x027b0000U,
+               (void *)0x027b8000U,
+               (void *)NULL,
+               (void *)NULL,
+               (void *)NULL,
+               (void *)NULL,
+               (void *)NULL,
+               (void *)NULL,
+               },
+               /** Interrupt no. for Transfer Completion */
+               0x90,
+               /** Interrupt no. for CC Error */
+               0x9c,
+               /** Interrupt no. for TCs Error */
+               {
+               0xA2,
+               0xA3,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               },
+
+               /**
+                * \brief EDMA3 TC priority setting
+                *
+                * User can program the priority of the Event Queues
+                * at a system-wide level.  This means that the user can set the
+                * priority of an IO initiated by either of the TCs (Transfer Controllers)
+                * relative to IO initiated by the other bus masters on the
+                * device (ARM, DSP, USB, etc)
+                */
+               {
+               0u,
+               1u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u
+               },
+               /**
+                * \brief To Configure the Threshold level of number of events
+                * that can be queued up in the Event queues. EDMA3CC error register
+                * (CCERR) will indicate whether or not at any instant of time the
+                * number of events queued up in any of the event queues exceeds
+                * or equals the threshold/watermark value that is set
+                * in the queue watermark threshold register (QWMTHRA).
+                */
+               {
+               16u,
+               16u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u
+               },
+
+               /**
+                * \brief To Configure the Default Burst Size (DBS) of TCs.
+                * An optimally-sized command is defined by the transfer controller
+                * default burst size (DBS). Different TCs can have different
+                * DBS values. It is defined in Bytes.
+                */
+               {
+               64u,
+               64u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u,
+               0u
+               },
+
+               /**
+                * \brief Mapping from each DMA channel to a Parameter RAM set,
+                * if it exists, otherwise of no use.
+                */
+               {
+               0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u,
+               8u, 9u, 10u, 11u, 12u, 13u, 14u, 15u,
+               16u, 17u, 18u, 19u, 20u, 21u, 22u, 23u,
+               24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u,
+               32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u,
+               40u, 41u, 42u, 43u, 44u, 45u, 46u, 47u,
+               48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u,
+               56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u
+               },
+
+                /**
+                 * \brief Mapping from each DMA channel to a TCC. This specific
+                 * TCC code will be returned when the transfer is completed
+                 * on the mapped channel.
+                 */
+               {
+               0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u,
+               8u, 9u, 10u, 11u, 12u, 13u, EDMA3_RM_CH_NO_TCC_MAP, EDMA3_RM_CH_NO_TCC_MAP,
+               16u, 17u, 18u, 19u, 20u, 21u, 22u, 23u,
+               24u, 25u, 26u, 27u, 28u, 29u, EDMA3_RM_CH_NO_TCC_MAP, EDMA3_RM_CH_NO_TCC_MAP,
+               32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u,
+               40u, 41u, 42u, 43u, 44u, 45u, EDMA3_RM_CH_NO_TCC_MAP, EDMA3_RM_CH_NO_TCC_MAP,
+               48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u,
+               56u, 57u, 58u, 59u, 60u, 61u, EDMA3_RM_CH_NO_TCC_MAP, EDMA3_RM_CH_NO_TCC_MAP
+               },
+
+               /**
+                * \brief Mapping of DMA channels to Hardware Events from
+                * various peripherals, which use EDMA for data transfer.
+                * All channels need not be mapped, some can be free also.
+                */
+               {
+               0x00000000u,
+               0xFFF00000u
+               }
+               },
+
+       };
+
+EDMA3_RM_InstanceInitConfig sampleInstInitConfig[NUM_EDMA3_INSTANCES][EDMA3_MAX_REGIONS] =
+       {
+               /* EDMA3 INSTANCE# 0 */
+               {
+                       /* Resources owned/reserved by region 0 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0xFFFF000Fu, 0x00000FFFu, 0x00000000u, 0x00000FFFu,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x0f00000Fu, 0x0000000Fu},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000003u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x0f00000Fu, 0x000000FFu},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000003u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,},
+
+                               /* resvdDmaChannels */
+                               /* 31           0 */
+                               {0x00000003u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31           0 */
+                               {0x00000003u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 1 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x000000F0u, 0xFFFFF000u, 0x000000FFu, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x000000F0u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x0000000Cu},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x000000F0u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000030u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000030u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000030u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 2 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000F00u, 0x00000000u, 0xFFFFFF00u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000F00u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000030u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000F00u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000300u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000300u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000300u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 3 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x0000F000u, 0x00000000u, 0x00000000u, 0xFFFFF000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x0000F000u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x000000C0u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x0000F000u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00003000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00003000u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00003000u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 4 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x0000F000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 5 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x0000F000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 6 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x0000F000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 7 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x0000F000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+                       },
+           },
+
+               /* EDMA3 INSTANCE# 1 */
+           {
+               /* Resources owned/reserved by region 0 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x0000FFFFu, 0x00F00000u, 0xFFFFFFFFu, 0xFFFFFFFFu,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0xFFFFFFFFu, 0x0000FFFFu, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x0000FFFFu, 0x00F00000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000003u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x0000FFFFu, 0x00F00000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00003FFFu, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00003FFFu, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00003FFFu, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 1 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0xFFFF0000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0xFFFF0000u, 0xFFFFFFFFu, 0xFFFFFFFFu,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0xFFFFFFFFu, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0xFFFF0000u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x0000000Cu},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0xFFFF0000u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x3FFF0000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x3FFF0000u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x3FFF0000u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 2 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x0000FFFFu, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x0000FFFFu, 0x00000000u, 0x00000000u, 0x00000000u,},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x0000FFFFu},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000030u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x0000FFFFu},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00003FFFu, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00003FFFu},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00003FFFu},
+                       },
+
+               /* Resources owned/reserved by region 3 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0xFFFF0000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0xFFFF0000u, 0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu,},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0xFFFF0000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x000000C0u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0xFFFF0000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x3FFF0000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x3FFF0000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x3FFF0000u},
+                       },
+
+               /* Resources owned/reserved by region 4 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 5 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 6 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+                       },
+
+               /* Resources owned/reserved by region 7 */
+                       {
+                               /* ownPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* ownDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* ownQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* ownTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdPaRAMSets */
+                               /* 31     0     63    32     95    64     127   96 */
+                               {0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 159  128     191  160     223  192     255  224 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 287  256     319  288     351  320     383  352 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+                               /* 415  384     447  416     479  448     511  480 */
+                                0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u},
+
+                               /* resvdDmaChannels */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+
+                               /* resvdQdmaChannels */
+                               /* 31     0 */
+                               {0x00000000u},
+
+                               /* resvdTccs */
+                               /* 31     0     63    32 */
+                               {0x00000000u, 0x00000000u},
+                       },
+           },
+       };
+
+/* End of File */
diff --git a/example/k2g/MCBSPDigLpbk/sample_k2g_int_reg.c b/example/k2g/MCBSPDigLpbk/sample_k2g_int_reg.c
new file mode 100644 (file)
index 0000000..47b68be
--- /dev/null
@@ -0,0 +1,310 @@
+/*
+ * sample_tci6616_int_reg.c
+ *
+ * Platform specific interrupt registration and un-registration routines.
+ *
+ * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  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.
+ *
+*/
+
+#include <ti/sysbios/knl/Semaphore.h>
+#include <ti/sysbios/family/c64p/Hwi.h>
+#include <ti/sysbios/family/c64p/EventCombiner.h>
+#include <ti/sysbios/family/c66/tci66xx/CpIntc.h>
+
+#include <ti/sdo/edma3/rm/sample/bios6_edma3_rm_sample.h>
+
+#include <ti/csl/csl_edma3.h>
+extern unsigned int ccXferCompInt[][EDMA3_MAX_REGIONS];
+extern unsigned int ccErrorInt[];
+extern unsigned int tcErrorInt[][EDMA3_MAX_TC];
+extern unsigned int numEdma3Tc[];
+
+void (*ptrEdma3TcIsrHandler[EDMA3_MAX_TC])(unsigned int arg) =
+                                                {
+                                                &lisrEdma3TC0ErrHandler0,
+                                                &lisrEdma3TC1ErrHandler0,
+                                                &lisrEdma3TC2ErrHandler0,
+                                                &lisrEdma3TC3ErrHandler0,
+                                                &lisrEdma3TC4ErrHandler0,
+                                                &lisrEdma3TC5ErrHandler0,
+                                                &lisrEdma3TC6ErrHandler0,
+                                                &lisrEdma3TC7ErrHandler0,
+                                                };
+#if 0
+unsigned int hwiInterrupt = 8;
+
+/* Host interrupts for transfer completion */
+//unsigned int ccXferHostInt[NUM_EDMA3_INSTANCES][NUM_DSPS] = {
+unsigned int ccXferHostInt[3][4] = {
+                                                                               {32, 24u, 40u, 56u},
+                                                                               {9u, 25u, 41u, 57u},
+                                                                               {10u, 26u, 42u, 58u},
+                                                                               };
+unsigned int edma3ErrHostInt[3][4] = {
+                                                                               {33, 27u, 43u, 59u},
+                                                                               {12u, 28u, 44u, 60u},
+                                                                               {13u, 29u, 45u, 61u},
+                                                                               };
+
+
+extern unsigned int dsp_num;
+
+/**  To Register the ISRs with the underlying OS, if required */
+void registerEdma3Interrupts (unsigned int edma3Id)
+    {
+    static UInt32 cookie = 0;
+    Int eventId = 0;   /* GEM event id */
+       unsigned int numTc = 0;
+
+    /* Disabling the global interrupts */
+    cookie = Hwi_disable();
+#if 0
+       /* Transfer completion ISR */
+#if 0
+       CpIntc_dispatchPlug(ccXferCompInt[edma3Id][dsp_num],
+                                               lisrEdma3ComplHandler0,
+                                               edma3Id,
+                                               TRUE);
+       CpIntc_mapSysIntToHostInt(0, ccXferCompInt[edma3Id][dsp_num],
+                                                               ccXferHostInt[edma3Id][dsp_num]);
+       CpIntc_enableHostInt(0, ccXferHostInt[edma3Id][dsp_num]);
+#else
+       // Map system interrupt 15 to host interrupt 8
+       CpIntc_mapSysIntToHostInt(0, 0x88, 32);
+
+       // Plug the function for event #15
+       CpIntc_dispatchPlug(0x88, lisrEdma3ComplHandler0,edma3Id,TRUE);
+
+       // Enable host interrupt #8
+       CpIntc_enableHostInt(0,32); // enable host interrupt 8
+#endif
+    eventId = CpIntc_getEventId(ccXferHostInt[edma3Id][dsp_num]);
+    eventId = 0x30;
+    EventCombiner_dispatchPlug (eventId, CpIntc_dispatch,
+                                ccXferHostInt[edma3Id][dsp_num], TRUE);
+       EventCombiner_enableEvent(eventId);
+
+       /* CC Error ISR */
+       CpIntc_dispatchPlug(ccErrorInt[edma3Id], lisrEdma3CCErrHandler0,
+                                               edma3Id, TRUE);
+       CpIntc_mapSysIntToHostInt(0, ccErrorInt[edma3Id],
+                                                               edma3ErrHostInt[edma3Id][dsp_num]);
+       /* TC Error ISR */
+    while (numTc < numEdma3Tc[edma3Id])
+           {
+               CpIntc_dispatchPlug(tcErrorInt[edma3Id][numTc],
+                                                       (CpIntc_FuncPtr )(ptrEdma3TcIsrHandler[numTc]),
+                                                       edma3Id, TRUE);
+               CpIntc_mapSysIntToHostInt(0, tcErrorInt[edma3Id][numTc],
+                                                                       edma3ErrHostInt[edma3Id][dsp_num]);
+        numTc++;
+       }
+       /* Enable the host interrupt which is common for both CC and TC error */
+       CpIntc_enableHostInt(0, edma3ErrHostInt[edma3Id][dsp_num]);
+    eventId = CpIntc_getEventId(edma3ErrHostInt[edma3Id][dsp_num]);
+    eventId = 0x31;
+    EventCombiner_dispatchPlug (eventId, CpIntc_dispatch,
+                                edma3ErrHostInt[edma3Id][dsp_num], TRUE);
+       EventCombiner_enableEvent(eventId);
+
+    Hwi_enableInterrupt(hwiInterrupt);
+#else
+
+    /* enable the 'global' switch */
+    CpIntc_enableAllHostInts(0);
+    {
+        Hwi_Params params;
+       CpIntc_mapSysIntToHostInt(0, 0x88, 32);                 // I picked host int 32 for CPINTC #0.  CPINTC #1 is for cores 4-7
+           CpIntc_dispatchPlug(0x88, lisrEdma3ComplHandler0, 0, TRUE);   //  the 'arg' parameter could be anything, doesn't have to be 149
+           CpIntc_enableHostInt(0, 32);                                     // CPINT #0 is for cores 0-3, CPINTC #1 is for cores 4-7
+           eventId = CpIntc_getEventId(32);                               // this should return the GEM event 21 (This was a bug fixed in 6.32.04)
+           eventId = 0x30;
+           Hwi_Params_init(&params);
+           params.arg = 32;                                       // required to be the host interrupt #
+           params.eventId = eventId;
+           params.enableInt = TRUE;
+           Hwi_create(8, &CpIntc_dispatch, &params, NULL); // create ISR to handle this event in Hwi vector 8
+
+    }
+#endif
+    /* Restore interrupts */
+    Hwi_restore(cookie);
+    }
+
+/**  To Unregister the ISRs with the underlying OS, if previously registered. */
+void unregisterEdma3Interrupts (unsigned int edma3Id)
+    {
+    static UInt32 cookie = 0;
+    Int eventId = 0;   /* GEM event id */
+
+    /* Disabling the global interrupts */
+    cookie = Hwi_disable();
+
+       /* Transfer completion ISR */
+       CpIntc_disableHostInt(0, ccXferHostInt[edma3Id][dsp_num]);
+    eventId = CpIntc_getEventId(ccXferHostInt[edma3Id][dsp_num]);
+       EventCombiner_disableEvent(eventId);
+
+       /* CC/TC Error ISR */
+       CpIntc_disableHostInt(0, edma3ErrHostInt[edma3Id][dsp_num]);
+    eventId = CpIntc_getEventId(edma3ErrHostInt[edma3Id][dsp_num]);
+       EventCombiner_disableEvent(eventId);
+
+    /* Restore interrupts */
+    Hwi_restore(cookie);
+    }
+
+#else
+/**  To Register the ISRs with the underlying OS, if required. */
+void registerEdma3Interrupts (unsigned int edma3Id)
+    {
+    static UInt32 cookie = 0;
+    unsigned int eventId,numTc = 0;
+    Hwi_Params params;
+
+    /* Disabling the global interrupts */
+    cookie = Hwi_disable();
+
+    /* Enable the Xfer Completion Event Interrupt */
+    EventCombiner_dispatchPlug(6,
+                                               (EventCombiner_FuncPtr)(&lisrEdma3ComplHandler0),
+                               edma3Id, 1);
+    EventCombiner_enableEvent(6);
+
+    Hwi_enableInterrupt(7);
+
+# if 0
+    /* Map the EDMA Region 0 transfer complete interrupt to the EDMA ISR Handler. */
+    CpIntc_dispatchPlug(0x88, (CpIntc_FuncPtr)lisrEdma3ComplHandler0, 0, TRUE);
+
+    /* The configuration is for CPINTC0. We map system interrupt 0x88 to Host Interrupt 32. */
+    CpIntc_mapSysIntToHostInt(0, 0x88, 32);
+
+    /* Enable the Host Interrupt. */
+    CpIntc_enableHostInt(0, 32);
+
+    /* Enable the System Interrupt */
+    CpIntc_enableSysInt(0, 0x88);
+
+    /* Get the event id associated with the host interrupt. */
+    eventId = 0x30;
+    /* enable the 'global' switch */
+
+   /* Enable the Xfer Completion Event Interrupt */
+        EventCombiner_dispatchPlug(0x30,
+                                                       (EventCombiner_FuncPtr)(&CpIntc_dispatch),
+                               32, 1);
+        EventCombiner_enableEvent(0x30);
+
+        /* Map the EDMA CC error interrupt to the EDMA ISR Handler. */
+            CpIntc_dispatchPlug(0x99, (CpIntc_FuncPtr)lisrEdma3ComplHandler0, 0, TRUE);
+
+            /* The configuration is for CPINTC0. We map system interrupt 0x99 to Host Interrupt 33. */
+            CpIntc_mapSysIntToHostInt(0, 0x99, 33);
+
+            /* Enable the Host Interrupt. */
+            CpIntc_enableHostInt(0, 33);
+
+            /* Enable the System Interrupt */
+            CpIntc_enableSysInt(0, 0x99);
+
+            /* Get the event id associated with the host interrupt. */
+            eventId = 0x31;
+            /* enable the 'global' switch */
+
+           /* Enable the Xfer Completion Event Interrupt */
+                EventCombiner_dispatchPlug(0x31,
+                                                               (EventCombiner_FuncPtr)(&CpIntc_dispatch),
+                                       33, 1);
+                EventCombiner_enableEvent(0x31);
+
+                /* Map the EDMA TC error  interrupt to the EDMA ISR Handler. */
+                           CpIntc_dispatchPlug(0x9e, (CpIntc_FuncPtr)lisrEdma3ComplHandler0, 0, TRUE);
+
+                           /* The configuration is for CPINTC0. We map system interrupt 0x9e to Host Interrupt 34. */
+                           CpIntc_mapSysIntToHostInt(0, 0x9e, 34);
+
+                           /* Enable the Host Interrupt. */
+                           CpIntc_enableHostInt(0, 34);
+
+                           /* Enable the System Interrupt */
+                           CpIntc_enableSysInt(0, 0x9e);
+
+                           /* Get the event id associated with the host interrupt. */
+                           eventId = 0x32;
+                           /* enable the 'global' switch */
+
+                          /* Enable the Xfer Completion Event Interrupt */
+                               EventCombiner_dispatchPlug(0x32,
+                                                                               (EventCombiner_FuncPtr)(&CpIntc_dispatch),
+                                                       34, 1);
+                               EventCombiner_enableEvent(0x32);
+
+
+
+        CpIntc_enableAllHostInts(0);
+        Hwi_enableInterrupt(8);
+
+
+#endif
+
+    /* Restore interrupts */
+    Hwi_restore(cookie);
+    }
+
+/**  To Unregister the ISRs with the underlying OS, if previously registered. */
+void unregisterEdma3Interrupts (unsigned int edma3Id)
+    {
+       static UInt32 cookie = 0;
+    unsigned int numTc = 0;
+
+    /* Disabling the global interrupts */
+    cookie = Hwi_disable();
+
+    /* Disable the Xfer Completion Event Interrupt */
+       EventCombiner_disableEvent(ccXferCompInt[edma3Id][0]);
+
+    /* Disable the CC Error Event Interrupt */
+       EventCombiner_disableEvent(ccErrorInt[edma3Id]);
+
+    /* Enable the TC Error Event Interrupt, according to the number of TCs. */
+    while (numTc < numEdma3Tc[edma3Id])
+       {
+        EventCombiner_disableEvent(tcErrorInt[edma3Id][numTc]);
+        numTc++;
+       }
+
+    /* Restore interrupts */
+    Hwi_restore(cookie);
+    }
+#endif
diff --git a/example/k2g/mcbspMasterDigLpbk_osal.c b/example/k2g/mcbspMasterDigLpbk_osal.c
new file mode 100644 (file)
index 0000000..888513d
--- /dev/null
@@ -0,0 +1,641 @@
+/**
+ *   @file  mcbspMasterDigLpbk_osal.c
+ *
+ *   @brief   
+ *      This is the OS abstraction layer and is used by the MCBSP
+ *      driver for the MCBSP Example Digital Loopback Application. 
+ *
+ *  \par
+ *  ============================================================================
+ *  @n   (C) Copyright 2012, 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
+*/
+#include <xdc/std.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <xdc/runtime/IHeap.h>
+#include <xdc/runtime/System.h>
+#include <xdc/runtime/Memory.h>
+#include <xdc/runtime/Error.h>
+#include <ti/sysbios/knl/Semaphore.h>
+#include <ti/sysbios/BIOS.h>
+#include <ti/sysbios/knl/Task.h>
+#include <ti/sysbios/knl/Queue.h>
+#include <ti/sysbios/heaps/HeapBuf.h>
+#include <ti/sysbios/heaps/HeapMem.h>
+#include <ti/sysbios/hal/Hwi.h>
+#include <xdc/cfg/global.h>
+#include <ti/drv/mcbsp/mcbsp_drv.h>
+#if 0
+/* CSL Include Files */
+#include <ti/csl/csl_chip.h>
+#include <ti/csl/csl_semAux.h>
+#include <ti/csl/csl_cacheAux.h>
+#include <ti/csl/csl_xmcAux.h>
+#endif
+/* IPC includes */ 
+/* #include <ti/ipc/GateMP.h>
+#include <ti/ipc/Ipc.h>
+#include <ti/ipc/ListMP.h>
+#include <ti/ipc/SharedRegion.h> */
+
+/**********************************************************************
+ ************************** Local Definitions *************************
+ **********************************************************************/
+
+#define MCBSP_HW_SEM         1
+#define PLATFORM_SPI_HW_SEM     2   /**< SPI BUS arbitration - Used by platform library        */
+
+#ifdef MCBSP_LOOP_PING_PONG
+#define MAX_MEM_MGR_ENTRIES     8
+#else
+#define MAX_MEM_MGR_ENTRIES     4
+#endif
+
+typedef struct MEM_MGMT_ENTRY
+{
+    uint8_t*    ptrMemory;
+    uint32_t    isFree;
+}MEM_MGMT_ENTRY;
+
+MEM_MGMT_ENTRY     gDataBufferMemMgr[MAX_MEM_MGR_ENTRIES];
+int32_t            gDataBufferMemMgrMaxSize = 0;
+
+/**********************************************************************
+ ************************** Global Variables **************************
+ **********************************************************************/
+UInt32 malloc_counter = 0;
+UInt32 free_counter   = 0;
+
+/**********************************************************************
+ ************************** Extern Definitions ************************
+ **********************************************************************/
+
+
+/**********************************************************************
+ **************************** OSAL Functions **************************
+ **********************************************************************/
+
+/**
+ *  @b Description
+ *  @n  
+ *      Utility function which converts a local address to global.
+ *
+ *  @param[in]  addr
+ *      Local address to be converted
+ *
+ *  @retval
+ *      Global Address
+ */
+void *Osal_local2Global (void *addr)
+{
+       UInt32 corenum;
+
+       /* Get the core number. */
+       corenum = 0;//CSL_chipReadReg(CSL_CHIP_DNUM);
+       return addr;
+
+       if(((UInt32)addr & 0xff000000) == 0) {
+       /* Compute the global address. */
+               return ((void *)((UInt32)(addr) + (0x10000000 + (corenum*0x1000000))));
+       }
+       else
+               return(addr);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to allocate a memory block of the specified size.
+ *
+ *  @param[in]  numBytes
+ *      Number of bytes to be allocated.
+ *
+ *  @retval
+ *      Allocated block address
+ */
+Void* Osal_mcbspMalloc(UInt32 numBytes)
+{
+       Error_Block     errorBlock;
+    Void*       ptr;
+
+    /* Increment the allocation counter. */
+    malloc_counter++;  
+
+    /* Allocate the memory. */
+    ptr = Memory_alloc(NULL, numBytes, 0, &errorBlock);
+
+    /* Return the allocated memory block. */
+       return ptr;
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to clean up a specific memory block and is called
+ *      from the MCBSP Driver. 
+ *
+ *  @param[in]  ptr
+ *      Pointer to the memory block to be cleaned up.
+ *  @param[in]  size
+ *      Size of the memory block being cleaned up.
+ *
+ *  @retval
+ *      Not Applicable
+ */
+Void Osal_mcbspFree (Void* ptr, UInt32 size)
+{
+    /* Increment the free counter. */
+    free_counter++;    
+       Memory_free(NULL, ptr, size);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to allocate a block of memory for all the data buffer
+ *      operations. This function is called by the application.
+ *
+ *  @param[in]  numBuffers
+ *      Number of data buffers
+ *  @param[in]  dataBufferSize
+ *      Size of each data buffer
+ *
+ *  @retval
+ *      Success -   0
+ *  @retval
+ *      Error   -   <0
+ */
+int32_t Osal_dataBufferInitMemory(uint32_t dataBufferSize)
+{
+       Error_Block     errorBlock;
+    uint8_t*    ptrMemory;
+    uint32_t    index;
+
+    /* Allocate memory for all the data buffers */
+    ptrMemory = (uint8_t*)Memory_alloc(NULL, MAX_MEM_MGR_ENTRIES*dataBufferSize, 128, &errorBlock);
+    if (ptrMemory == NULL)
+        return -1;
+
+    /* Convert to a global address */
+    ptrMemory = Osal_local2Global(ptrMemory);
+    /* Now we chop up the memory and add it to the memory manager. */
+    for (index = 0; index < MAX_MEM_MGR_ENTRIES; index++)
+    {
+        /* Populate the data memory management entry. */
+        gDataBufferMemMgr[index].isFree    = 1;
+        gDataBufferMemMgr[index].ptrMemory = ptrMemory;
+
+        /* Increment the memory to the next address */
+        ptrMemory = ptrMemory + dataBufferSize;        
+    }
+
+    /* Remember the memory buffer size */
+    gDataBufferMemMgrMaxSize = dataBufferSize;
+
+    /* Memory Manager has been created. */
+    return 0;
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to allocate a data buffer of the specified
+ *      size. Data buffers should always be allocated from the global
+ *      address space.
+ *
+ *  @param[in]  numBytes
+ *      Number of bytes to be allocated.
+ *
+ *  @retval
+ *      Allocated block address
+ */
+Void* Osal_mcbspDataBufferMalloc(UInt32 numBytes)
+{
+    uint32_t    index;
+    void*       ptrMemory = NULL;
+
+    /* Basic Validation: Ensure that the memory size requested is within range. */
+    if (numBytes > gDataBufferMemMgrMaxSize)
+        return NULL;
+
+    /* Increment the allocation counter. */
+    malloc_counter++;
+
+    /* Lock out interrupts */
+    Hwi_disable();
+
+    /* Cycle through for a free entry. */
+    for (index = 0; index < MAX_MEM_MGR_ENTRIES; index++)
+    {
+        /* Check if the entry is free or not? */
+        if (gDataBufferMemMgr[index].isFree == 1) 
+        {
+            /* Entry was free. We can use it. */
+            ptrMemory = gDataBufferMemMgr[index].ptrMemory;
+
+            /* Mark the entry as used. */
+            gDataBufferMemMgr[index].isFree = 0;
+
+            /* We have found a match. */
+            break;
+        }
+    }
+
+    /* Unlock interrupts. */
+    Hwi_enable();
+
+    /* Return the allocated memory. */
+    return ptrMemory;  
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to clean up a previously allocated data buffer 
+ *      block. All data buffers are in the global address space
+ *
+ *  @param[in]  ptr
+ *      Pointer to the data buffer block to be cleaned up
+ *  @param[in]  size
+ *      Size of the data buffer
+ *
+ *  @retval
+ *      Not Applicable
+ */
+void Osal_mcbspDataBufferFree(void* ptr, uint32_t numBytes)
+{
+    uint32_t    index;
+
+    /* Increment the free counter. */
+    free_counter++;    
+
+    /* Lock out interrupts */
+    Hwi_disable();
+
+    /* Cycle through and clean up */
+    for (index = 0; index < MAX_MEM_MGR_ENTRIES; index++)
+    {
+        /* Check if the entry is free or not? */
+        if (gDataBufferMemMgr[index].ptrMemory == (uint8_t*)ptr) 
+        {
+            /* Mark the entry as free. */
+            gDataBufferMemMgr[index].isFree = 1;
+
+            /* We have found a match. */
+            break;
+        }
+    }
+
+    /* Unlock interrupts. */
+    Hwi_enable();
+    return;
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is the MCBSP OSAL Logging API which logs 
+ *      the messages on the console.
+ *
+ *  @param[in]  fmt
+ *      Formatted String.
+ *
+ *  @retval
+ *      Not Applicable
+ */
+Void Osal_mcbspLog( String fmt, ... )
+{
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to create a critical section.
+ *
+ *  @retval
+ *      Semaphore Handle created
+ */
+Void* Osal_mcbspCreateSem(Void)
+{
+    return (Void*)Semaphore_create(0, NULL, NULL);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to delete a critical section.
+ *
+ *  @param[in]  semHandle
+ *      Semaphore handle to be deleted
+ *
+ *  @retval
+ *      Not Applicable
+ */
+Void Osal_mcbspDeleteSem(Void* semHandle)
+{
+    Semaphore_delete(semHandle);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to pend on a semaphore
+ *
+ *  @param[in]  semHandle
+ *      Semaphore handle on which the API will pend
+ *
+ *  @retval
+ *      Not Applicable
+ */
+Void Osal_mcbspPendSem(Void* semHandle)
+{
+    Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to post a semaphore
+ *
+ *  @param[in]  semHandle
+ *      Semaphore handle which will be posted
+ *
+ *  @retval
+ *      Not Applicable
+ */
+Void Osal_mcbspPostSem(Void* semHandle)
+{
+    Semaphore_post(semHandle);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      This is the Multicore OSAL Implementation to protect the driver shared
+ *      resources across multiple cores.
+ *
+ *  @retval
+ *      Semaphore Opaque Handle
+ */
+void* Osal_mcbspEnterMultipleCoreCriticalSection(void)
+{
+    /* Get the hardware semaphore */
+   // while ((CSL_semAcquireDirect (MCBSP_HW_SEM)) == 0);
+    return NULL;
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is called to end the critical section which was protecting
+ *      shared resources from access across multiple cores.
+ *
+ *  @param[in]  critSectHandle
+ *      Semaphore opaque handle.
+ *
+ *  @retval
+ *      None
+ */
+Void  Osal_mcbspExitMultipleCoreCriticalSection(Void* critSectHandle)
+{
+    //CSL_semReleaseSemaphore (MCBSP_HW_SEM);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used to provide critical section to prevent access of shared
+ *      resources from single core and multiple threads.  
+ *
+ *  @param[in]  drvHandle
+ *      Driver Handle which needs critical section to protect its resources.
+ *
+ *  @retval
+ *      Opaque handle
+ */
+Void* Osal_mcbspEnterSingleCoreCriticalSection()
+{
+    /* Disable interrupts */
+     return (Void*)Hwi_disable();
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is called to end the critical section access of shared resources
+ *      from single cores.
+ *
+ *  @param[in]  drvHandle
+ *      Driver Handle which needed critical section to protect its resources.
+ *  @param[in]  critSectHandle
+ *      Opaque handle retreived when the Single Core Protection Enter API was called
+ *
+ *  @retval
+ *      Not Applicable.
+ */
+Void Osal_mcbspExitSingleCoreCriticalSection(Void* critSectHandle)
+{
+    /* Driver Managed Configuration: We need to enable interrupts. */
+    Hwi_enable();
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used by the MCBSP driver to indicate that
+ *      its about to access a block of memory and we need to ensure
+ *      that the cache contents for this block are invalidated before
+ *      we try and use it.
+ *
+ *  @param[in]  ptr
+ *      Pointer to the buffer which is being accessed
+ *  @param[in]  size
+ *      Size of the buffer which is to be accessed.
+ *
+ *  @retval
+ *      None
+ */
+#include "ti/sysbios/hal/Cache.h"
+void Osal_mcbspBeginMemAccess(void* ptr, uint32_t size)
+{
+    UInt  key;
+
+    /* Disable Interrupts */
+    key = Hwi_disable();
+
+    /* Cleanup the prefetch buffer also. */
+    //CSL_XMC_invalidatePrefetchBuffer();
+
+    /* Invalidate the cache. */
+    //CACHE_invL1d (ptr, size, CACHE_FENCE_WAIT);
+
+    Cache_inv ((void *) ptr,size, 0x7fff, 1);
+
+    /* Reenable Interrupts. */
+    Hwi_restore(key);
+}
+
+/**
+ *  @b Description
+ *  @n  
+ *      The function is used by the MCBSP driver to indicate that its 
+ *      ending access to a block of memory. We need to ensure that the
+ *      contents of the cache are written back to the actual memory.
+ *
+ *  @param[in]  ptr
+ *      Pointer to the buffer 
+ *  @param[in]  size
+ *      Size of the buffer 
+ *
+ *  @retval
+ *      None
+ */
+void Osal_mcbspEndMemAccess(void* ptr, uint32_t size)
+{
+    UInt  key;
+
+    /* Disable Interrupts */
+    key = Hwi_disable();
+
+    /* Writeback the cache. */
+    //CACHE_wbL1d (ptr, size, CACHE_FENCE_WAIT);
+    Cache_wb ((void *) ptr,size, 0x7fff, 1);
+    /* Reenable Interrupts. */
+    Hwi_restore(key);
+}
+
+/**
+ * @brief   The function is used by the MCBSP driver to test for an 
+ *          empty queue.
+ *
+ *  <b> Parameter </b>
+ *  @n  handle - Handle of a previously created Queue instance object 
+ *
+ *  <b> Return Value </b>
+ *  @n  TRUE - If the queue is empty
+ */
+Bool Osal_mcbspQueueEmpty(void* handle)
+{
+    return Queue_empty(handle);
+}
+
+/**
+ * @brief   The macro is used by the MCBSP driver to get an 
+ *          element from the front of queue. The function 
+ *          removes the element from the front of queue and
+ *          returns a pointer to it.
+ *
+ *  <b> Parameter </b>
+ *  @n  handle - Handle of a previously created Queue instance object 
+ *
+ *  <b> Return Value </b>
+ *  @n  Handle (pointer) to former first element
+ */
+void* Osal_mcbspQueueGet(void* handle)
+{
+    return Queue_get(handle);
+}
+
+/**
+ * @brief   The macro is used by the MCBSP driver to put an 
+ *          element at the end of queue. 
+ *
+ *  <b> Parameter </b>
+ *  @n  handle - Handle of a previously created Queue instance object 
+ *  @n  elem - Pointer to new queue element 
+ *
+ *  <b> Return Value </b>
+ *  @n  None
+ */
+void  Osal_mcbspQueuePut(void* handle, Mcbsp_QueueElem* elem)
+{
+    Queue_put(handle, (Queue_Elem *)elem);
+    return;
+}
+
+/**
+ * @brief   The macro is used by the MCBSP driver to wait 'n' 
+ *          bit clocks to ensure proper synchronization internally. 
+ *
+ *  <b> Parameter </b>
+ *  @n  nticks - Number of bit clocks to wait 
+ *
+ *  <b> Return Value </b>
+ *  @n  None
+ */
+void  Osal_mcbspWaitNBitClocks(uint32_t nticks)
+{
+    //Task_sleep(nticks);
+       int i=0;
+       for (i=0; i<100; i++);
+    return;
+}
+
+/* OSAL functions for Platform Library */
+uint8_t *Osal_platformMalloc (uint32_t num_bytes, uint32_t alignment)
+{
+       return malloc(num_bytes);
+}
+
+void Osal_platformFree (uint8_t *dataPtr, uint32_t num_bytes)
+{
+    /* Free up the memory */
+    if (dataPtr)
+    {
+        free(dataPtr);
+    }
+}
+
+void Osal_platformSpiCsEnter(void)
+{
+    /* Get the hardware semaphore.
+     *
+     * Acquire Multi core CPPI synchronization lock
+     */
+    //while ((CSL_semAcquireDirect (PLATFORM_SPI_HW_SEM)) == 0);
+
+    return;
+}
+
+void Osal_platformSpiCsExit (void)
+{
+    /* Release the hardware semaphore
+     *
+     * Release multi-core lock.
+     */
+    //CSL_semReleaseSemaphore (PLATFORM_SPI_HW_SEM);
+
+    return;
+}
index 008c1a4718897314fbeb9b561c03c13f5b40ca62..9a1dbfb2587f8ae6bfbf59aa0e42f63389dac202 100644 (file)
 
 IF DEFINED PARTNO GOTO partno_defined
 @REM Configure the Part Number
-set PARTNO=C6657
+set PARTNO=K2G
 :partno_Defined
 
 IF DEFINED PDK_INSTALL_PATH GOTO pdk_defined
-set PDK_INSTALL_PATH=C:/ti/pdk_C6657_1_1_2_5/packages
+set PDK_INSTALL_PATH=C:\ti3\pdk_keystone2_3_02_00_00\packages
 :pdk_defined
 
 @REM ---------------------------------
@@ -29,11 +29,12 @@ set MINI_PACKAGE=OFF
 @echo MINI PACKAGE is set to %MINI_PACKAGE%
 
 @REM This is the base location for the various tools. 
-set XDCCGROOT=T:/c6xx/cgen7_3_02/c6000/cgtools
-set C6X_GEN_INSTALL_PATH=T:/c6xx/cgen7_3_02/c6000/cgtools
+set XDCCGROOT=T:\c6xx\cgen7_4_02\c6000\cgtools
+set C6X_GEN_INSTALL_PATH=T:\c6xx\cgen7_4_02\c6000\cgtools
+set EDMA3_INSTALL_PATH=C:\ti\edma3_lld_02_11_09_08\packages
 
 @REM EDMA3 LLD installation path variables
-set EDMA3LLD_BIOS6_INSTALLDIR=C:/ti/edma3_lld_02_11_05_02
+@REM set EDMA3LLD_BIOS6_INSTALLDIR=C:/ti/edma3_lld_02_11_05_02
 
 REM *******************************************************************************
 REM *************************** XDC PATH Configuration ****************************
@@ -48,12 +49,11 @@ REM compilations will fail.
 REM CSL/LLDs Package: CSL, MCBSP and RM are a part of the CSL/LLDs package.
 
 @REM Specify the XDC Tool Path
-set XDC_INSTALL_PATH=T:/gen/xdc/xdctools_3_22_04_46
+set XDC_INSTALL_PATH=T:/gen/xdc/xdctools_3_24_06_63
 set XDCPATH=../../..;%XDC_INSTALL_PATH%/packages
 
 @REM Configure the XDCPATH
-set XDCPATH=%XDCPATH%;%PDK_INSTALL_PATH%;%C6X_GEN_INSTALL_PATH%/include
-set XDCPATH=%XDCPATH%;%EDMA3LLD_BIOS6_INSTALLDIR%/packages
+set XDCPATH=%XDCPATH%;%PDK_INSTALL_PATH%;%C6X_GEN_INSTALL_PATH%/include;%EDMA3_INSTALL_PATH%
 
 @REM Eclipse Help Plugin (Not required by customers)
 set XDC_ECLIPSE_PLUGIN_INSTALL_PATH=T:/gen/xdc/xdc_eclipse_plugin_gen/20091203
@@ -62,14 +62,13 @@ set XDCPATH=%XDCPATH%;%XDC_ECLIPSE_PLUGIN_INSTALL_PATH%
 set XDCPATH=%XDCPATH%;%XDC_FILTER_INSTALL_PATH%
 
 @REM Configure the paths to ensure that the XDC is available.
-set PATH=%XDC_INSTALL_PATH%;%XDC_INSTALL_PATH%\bin;T:\Doxygen\doxygen\1.5.1-p1\bin
+set PATH=%PATH%;%XDC_INSTALL_PATH%;%XDC_INSTALL_PATH%\bin;T:\Doxygen\doxygen\1.5.1-p1\bin
 
 @REM Third Party Tools: Install-Jammer (Not required by customers)
 set PATH=%PATH%;T:\gen\InstallJammer\v1_3_0
 
 set PATH=%PATH%;%XDCCGROOT%\bin;T:\gen\gnu\99-11-01\cygwin-b20\H-i586-cygwin32\bin
 set PATH=%PATH%;T:\SDOApps\cg_xml\cg_xml_v2_30_00\bin
-set PATH=%PATH%;T:\ti_pdsp_cgen\20091120
 
 @REM Third Party Tools: HTML Help compiler.
 set PATH=%PATH%;T:\Doxygen\HTML_Help_Workshop\10-01-2007