]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/edma3_lld.git/blobdiff - packages/ti/sdo/edma3/rm/sample/src/sample_init.c
PRSDK-3125: Update remainig
[keystone-rtos/edma3_lld.git] / packages / ti / sdo / edma3 / rm / sample / src / sample_init.c
index 7b04571d883f5b6b371fec03b196381f22d93db8..fea26bbb8edf7220e5f62376cd7d78886dbb59a5 100755 (executable)
 */\r
 \r
 #include <ti/sysbios/hal/Hwi.h>\r
-#include <ti/sysbios/ipc/Semaphore.h>\r
+#include <ti/sysbios/knl/Semaphore.h>\r
 #include <ti/sysbios/family/c64p/EventCombiner.h>\r
 \r
 #include <ti/sdo/edma3/rm/sample/bios6_edma3_rm_sample.h>\r
 \r
 /** @brief EDMA3 Driver Instance specific Semaphore handle */\r
-extern EDMA3_OS_Sem_Handle rmSemHandle[];\r
+extern EDMA3_OS_Sem_Handle SemHandle[EDMA3_MAX_EDMA3_INSTANCES];\r
 \r
 /**  To Register the ISRs with the underlying OS, if required. */\r
-extern void registerEdma3Interrupts (unsigned int edma3Id);\r
+extern void registerEdma3Interrupts (uint32_t edma3Id);\r
 /**  To Unregister the ISRs with the underlying OS, if previously registered. */\r
-extern void unregisterEdma3Interrupts (unsigned int edma3Id);\r
+extern void unregisterEdma3Interrupts (uint32_t edma3Id);\r
 \r
 /* To find out the DSP# */\r
-extern unsigned short determineProcId();\r
+extern uint16_t determineProcId(void);\r
 \r
 /**\r
  * To check whether the global EDMA3 configuration is required or not.\r
@@ -62,29 +62,33 @@ extern unsigned short determineProcId();
  * by one of the masters. Hence this function will return TRUE only once\r
  * and FALSE for all other masters. \r
  */\r
-extern unsigned short isGblConfigRequired(unsigned int dspNum);\r
+extern uint16_t isGblConfigRequired(uint32_t dspNum);\r
 \r
 /**\r
  * DSP instance number on which the executable is running. Its value is\r
  * determined by reading the processor specific register DNUM.\r
  */\r
-unsigned int dsp_num;\r
+uint32_t dsp_num;\r
 \r
 /**\r
  * Shadow Region on which the executable is runnig. Its value is populated\r
  * with the dsp_num here in this case.\r
  */\r
-unsigned int region_id;\r
+uint32_t region_id;\r
 \r
 /* Number of EDMA3 controllers present in the system */\r
-extern const unsigned int numEdma3Instances;\r
+extern const uint32_t numEdma3Instances;\r
 \r
 /* External Global Configuration Structure */\r
-extern EDMA3_RM_GblConfigParams sampleEdma3GblCfgParams[];\r
+extern EDMA3_RM_GblConfigParams sampleEdma3GblCfgParams[EDMA3_MAX_EDMA3_INSTANCES];\r
 \r
 /* External Instance Specific Configuration Structure */\r
-extern EDMA3_RM_InstanceInitConfig sampleInstInitConfig[][EDMA3_MAX_REGIONS];\r
+extern EDMA3_RM_InstanceInitConfig sampleInstInitConfig[EDMA3_MAX_EDMA3_INSTANCES][EDMA3_MAX_REGIONS];\r
 \r
+#ifdef DMA_XBAR_AVAILABLE
+extern EDMA3_RM_Result sampleInitXbarEvt(EDMA3_RM_Handle hEdma, uint32_t edma3Id);
+#endif
+
 /**\r
  * \brief   EDMA3 Initialization\r
  *\r
@@ -93,7 +97,7 @@ extern EDMA3_RM_InstanceInitConfig sampleInstInitConfig[][EDMA3_MAX_REGIONS];
  *\r
   * \return  EDMA3_RM_SOK if success, else error code\r
  */\r
-EDMA3_RM_Handle edma3init (unsigned int edma3Id, EDMA3_RM_Result *errorCode)\r
+EDMA3_RM_Handle edma3init (uint32_t edma3Id, EDMA3_RM_Result *errorCode)\r
     {\r
     EDMA3_RM_Param initParam;\r
     EDMA3_RM_Result edma3Result = EDMA3_RM_SOK;\r
@@ -104,8 +108,11 @@ EDMA3_RM_Handle edma3init (unsigned int edma3Id, EDMA3_RM_Result *errorCode)
        EDMA3_RM_Handle hEdmaResMgr = NULL;\r
 \r
        if ((edma3Id >= numEdma3Instances) || (errorCode == NULL))\r
-               return hEdmaResMgr;\r
-\r
+    {\r
+               hEdmaResMgr = NULL;\r
+    }\r
+    else\r
+    {\r
     /* DSP instance number */\r
     dsp_num = determineProcId();\r
 \r
@@ -126,13 +133,13 @@ EDMA3_RM_Handle edma3init (unsigned int edma3Id, EDMA3_RM_Result *errorCode)
                Semaphore_Params_init(&semParams);\r
 \r
                initParam.rmSemHandle = NULL;\r
-               edma3Result = edma3OsSemCreate(1, &semParams, &initParam.rmSemHandle);\r
+               edma3Result = edma3OsSemCreate((int32_t)1, &semParams, &initParam.rmSemHandle);\r
                }\r
 \r
        if (edma3Result == EDMA3_DRV_SOK)\r
                {\r
                /* Save the semaphore handle for future use */\r
-               rmSemHandle[edma3Id] = initParam.rmSemHandle;\r
+               SemHandle[edma3Id] = initParam.rmSemHandle;\r
 \r
                /* configuration structure for the Driver */\r
                instanceConfig = &sampleInstInitConfig[edma3Id][dsp_num];\r
@@ -154,7 +161,15 @@ EDMA3_RM_Handle edma3init (unsigned int edma3Id, EDMA3_RM_Result *errorCode)
                                                                                &edma3Result);\r
                }\r
 \r
-       if(hEdmaResMgr && (edma3Result == EDMA3_DRV_SOK))\r
+#ifdef DMA_XBAR_AVAILABLE
+       {\r
+       if((hEdmaResMgr != NULL) && (edma3Result == EDMA3_RM_SOK))\r
+               {\r
+               edma3Result = sampleInitXbarEvt(hEdmaResMgr, edma3Id);\r
+               }\r
+       }\r
+#endif \r
+       if((hEdmaResMgr != NULL) && (edma3Result == EDMA3_DRV_SOK))\r
                {\r
                /**\r
                * Register Interrupt Handlers for various interrupts\r
@@ -165,6 +180,7 @@ EDMA3_RM_Handle edma3init (unsigned int edma3Id, EDMA3_RM_Result *errorCode)
                }\r
 \r
        *errorCode = edma3Result;       \r
+    }\r
        return hEdmaResMgr;\r
     }\r
 \r
@@ -176,7 +192,7 @@ EDMA3_RM_Handle edma3init (unsigned int edma3Id, EDMA3_RM_Result *errorCode)
  *\r
   * \return  EDMA3_RM_SOK if success, else error code\r
  */\r
-EDMA3_RM_Result edma3deinit (unsigned int edma3Id, EDMA3_RM_Handle hEdmaResMgr)\r
+EDMA3_RM_Result edma3deinit (uint32_t edma3Id, EDMA3_RM_Handle hEdma)\r
     {\r
     EDMA3_RM_Result edma3Result = EDMA3_RM_SOK;\r
 \r
@@ -184,15 +200,15 @@ EDMA3_RM_Result edma3deinit (unsigned int edma3Id, EDMA3_RM_Handle hEdmaResMgr)
     unregisterEdma3Interrupts(edma3Id);\r
 \r
     /* Delete the semaphore */\r
-    edma3Result = edma3OsSemDelete (rmSemHandle[edma3Id]);\r
+    edma3Result = edma3OsSemDelete (SemHandle[edma3Id]);\r
 \r
     if (EDMA3_RM_SOK == edma3Result)\r
         {\r
         /* Make the semaphore handle as NULL. */\r
-        rmSemHandle[edma3Id] = NULL;\r
+        SemHandle[edma3Id] = NULL;\r
 \r
         /* Now, close the EDMA3 RM Instance */\r
-        edma3Result = EDMA3_RM_close (hEdmaResMgr, NULL);\r
+        edma3Result = EDMA3_RM_close (hEdma, NULL);\r
        }\r
        \r
     if (EDMA3_RM_SOK == edma3Result)\r