Cleaned EDMA3 Driver Sample Initialization library
[keystone-rtos/edma3_lld.git] / packages / ti / sdo / edma3 / drv / sample / src / sample_cs.c
similarity index 77%
rename from packages/ti/sdo/edma3/drv/sample/src/bios6_edma3_drv_sample_cs.c
rename to packages/ti/sdo/edma3/drv/sample/src/sample_cs.c
index 4646e7644bb6b8d12232eb403798ed565a6d34b1..58afaf01379da30cf7d231b8f9d53160a8ca0d3b 100644 (file)
@@ -1,44 +1,43 @@
-/*******************************************************************************
-**+--------------------------------------------------------------------------+**
-**|                            ****                                          |**
-**|                            ****                                          |**
-**|                            ******o***                                    |**
-**|                      ********_///_****                                   |**
-**|                      ***** /_//_/ ****                                   |**
-**|                       ** ** (__/ ****                                    |**
-**|                           *********                                      |**
-**|                            ****                                          |**
-**|                            ***                                           |**
-**|                                                                          |**
-**|         Copyright (c) 1998-2006 Texas Instruments Incorporated           |**
-**|                        ALL RIGHTS RESERVED                               |**
-**|                                                                          |**
-**| Permission is hereby granted to licensees of Texas Instruments           |**
-**| Incorporated (TI) products to use this computer program for the sole     |**
-**| purpose of implementing a licensee product based on TI products.         |**
-**| No other rights to reproduce, use, or disseminate this computer          |**
-**| program, whether in part or in whole, are granted.                       |**
-**|                                                                          |**
-**| TI makes no representation or warranties with respect to the             |**
-**| performance of this computer program, and specifically disclaims         |**
-**| any responsibility for any damages, special or consequential,            |**
-**| connected with the use of this program.                                  |**
-**|                                                                          |**
-**+--------------------------------------------------------------------------+**
-*******************************************************************************/
-
-/** \file   bios6_edma3_drv_sample_cs.c
-
-    \brief  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.
-
-    (C) Copyright 2006, Texas Instruments, Inc
-
-    \version    1.0   Anuj Aggarwal         - Created
-
- */
+/*
+ * bios6_edma3_drv_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 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/sdo/edma3/drv/sample/bios6_edma3_drv_sample.h>
 
+extern unsigned int ccXferCompInt[][EDMA3_MAX_REGIONS];
+extern unsigned int ccErrorInt[];
+extern unsigned int tcErrorInt[][EDMA3_MAX_TC];
+
+/**
+ * DSP instance number on which the executable is running. Its value is
+ * determined by reading the processor specific register DNUM.
+ */
+extern unsigned int dsp_num;
+
 /**
  * \brief   EDMA3 OS Protect Entry
  *
@@ -67,8 +76,9 @@
  *      for EDMA3_OS_PROTECT_INTERRUPT protection level).
  * \return  None
  */
-void edma3OsProtectEntry (int level, unsigned int *intState)
-    {
+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))
@@ -86,17 +96,17 @@ void edma3OsProtectEntry (int level, unsigned int *intState)
 
             /* Disable scheduler */
             case EDMA3_OS_PROTECT_SCHEDULER :
-                               Task_disable();
+                                       Task_disable();
                 break;
 
             /* Disable EDMA3 transfer completion interrupt only */
             case EDMA3_OS_PROTECT_INTERRUPT_XFER_COMPLETION :
-                EventCombiner_disableEvent(ccXferCompInt);
+                EventCombiner_disableEvent(ccXferCompInt[edma3InstanceId][dsp_num]);
                 break;
 
             /* Disable EDMA3 CC error interrupt only */
             case EDMA3_OS_PROTECT_INTERRUPT_CC_ERROR :
-                EventCombiner_disableEvent(ccErrorInt);
+                EventCombiner_disableEvent(ccErrorInt[edma3InstanceId]);
                 break;
 
             /* Disable EDMA3 TC error interrupt only */
@@ -113,7 +123,7 @@ void edma3OsProtectEntry (int level, unsigned int *intState)
                     case 7:
                         /* Fall through... */
                         /* Disable the corresponding interrupt */
-                        EventCombiner_disableEvent(tcErrorInt[*intState]);
+                        EventCombiner_disableEvent(tcErrorInt[edma3InstanceId][*intState]);
                         break;
 
                      default:
@@ -146,7 +156,8 @@ void edma3OsProtectEntry (int level, unsigned int *intState)
  *      for EDMA3_OS_PROTECT_INTERRUPT protection level).
  * \return  None
  */
-void edma3OsProtectExit (int level, unsigned int intState)
+void edma3OsProtectExit (unsigned int edma3InstanceId,
+                        int level, unsigned int intState)
     {
     switch (level)
         {
@@ -162,12 +173,12 @@ void edma3OsProtectExit (int level, unsigned int intState)
 
         /* Enable EDMA3 transfer completion interrupt only */
         case EDMA3_OS_PROTECT_INTERRUPT_XFER_COMPLETION :
-            EventCombiner_enableEvent(ccXferCompInt);
+            EventCombiner_enableEvent(ccXferCompInt[edma3InstanceId][dsp_num]);
             break;
 
         /* Enable EDMA3 CC error interrupt only */
         case EDMA3_OS_PROTECT_INTERRUPT_CC_ERROR :
-            EventCombiner_enableEvent(ccErrorInt);
+            EventCombiner_enableEvent(ccErrorInt[edma3InstanceId]);
             break;
 
         /* Enable EDMA3 TC error interrupt only */
@@ -184,7 +195,7 @@ void edma3OsProtectExit (int level, unsigned int intState)
                 case 7:
                     /* Fall through... */
                     /* Enable the corresponding interrupt */
-                    EventCombiner_enableEvent(tcErrorInt[intState]);
+                    EventCombiner_enableEvent(tcErrorInt[edma3InstanceId][intState]);
                     break;
 
                  default:
@@ -406,6 +417,3 @@ EDMA3_DRV_Result edma3OsSemGive(EDMA3_OS_Sem_Handle hSem)
     }
 
 
-
-
-