45f0156499a0a85d42cc7b625157aace15a2c1b9
1 /*\r
2 *\r
3 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ \r
4 * \r
5 * \r
6 * Redistribution and use in source and binary forms, with or without \r
7 * modification, are permitted provided that the following conditions \r
8 * are met:\r
9 *\r
10 * Redistributions of source code must retain the above copyright \r
11 * notice, this list of conditions and the following disclaimer.\r
12 *\r
13 * Redistributions in binary form must reproduce the above copyright\r
14 * notice, this list of conditions and the following disclaimer in the \r
15 * documentation and/or other materials provided with the \r
16 * distribution.\r
17 *\r
18 * Neither the name of Texas Instruments Incorporated nor the names of\r
19 * its contributors may be used to endorse or promote products derived\r
20 * from this software without specific prior written permission.\r
21 *\r
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
33 *\r
34 */\r
35 \r
36 \r
37 \r
38 #include <stdio.h>\r
39 #include <time.h>\r
40 #include <string.h>\r
41 \r
42 /* XDC includes */\r
43 #include <xdc/runtime/IHeap.h>\r
44 \r
45 /* BIOS includes */\r
46 #include <ti/sysbios/knl/Task.h>\r
47 #include <ti/sysbios/BIOS.h>\r
48 #include <ti/sysbios/knl/Semaphore.h>\r
49 #include <ti/sysbios/family/c64p/Hwi.h>\r
50 #include <ti/sysbios/family/c64p/EventCombiner.h>\r
51 #include <ti/sysbios/family/c66/tci66xx/CpIntc.h>\r
52 \r
53 /* IPC includes */ \r
54 #include <ti/ipc/GateMP.h>\r
55 #include <ti/ipc/Ipc.h>\r
56 #include <ti/ipc/ListMP.h>\r
57 #include <ti/ipc/SharedRegion.h>\r
58 #include <ti/ipc/MultiProc.h>\r
59 \r
60 /* CSL includes */\r
61 #include <ti/csl/soc.h>\r
62 #include <ti/csl/csl_chipAux.h>\r
63 #include <ti/csl/cslr_tpcc.h>\r
64 #include <ti/csl/cslr_tcp3d_cfg.h>\r
65 #include <ti/csl/cslr_tcp3d_dma.h>\r
66 #include <ti/csl/cslr_tcp3d_dma_offsets.h>\r
67 #include <ti/csl/csl_tsc.h>\r
68 #include <ti/csl/csl_cacheAux.h>\r
69 #include <ti/csl/csl_xmcAux.h>\r
70 #include <ti/csl/csl_pscAux.h>\r
71 \r
72 #include "sample.h"\r
73 #include "tcp3d_drv_sample.h"\r
74 #include "tcp3d_main.h"\r
75 \r
76 /**********************************************************************\r
77 ************************** Test Compile Flags ************************\r
78 **********************************************************************/\r
79 #define DEBUG_VARS 0 // add debug variables at different places in the code \r
80 \r
81 #define DEBUG_PRINT 0\r
82 \r
83 #define MY_LOG_PRINT0(x) {\\r
84 if(DEBUG_PRINT)\\r
85 {\\r
86 System_printf(#x"\n");\\r
87 }\\r
88 }\r
89 \r
90 #define MY_LOG_PRINT1(x, val) {\\r
91 if(DEBUG_PRINT)\\r
92 {\\r
93 System_printf(#x" %d\n", val);\\r
94 }\\r
95 }\r
96 \r
97 #define MY_LOG_PRINT2(x, val1, y, val2) {\\r
98 if(DEBUG_PRINT)\\r
99 {\\r
100 System_printf(#x" %d, "#y" %d\n", val1, val2);\\r
101 }\\r
102 }\r
103 \r
104 /**\r
105 * This is used for plotting timing diagram using matlab by collecting the data\r
106 * points from running the code.\r
107 * \r
108 * Requirements:\r
109 * 1) it is required to enable the logging for TCP3D in the Simulator\r
110 * Configuration file. The decoding and reset times are collected from the\r
111 * log file (c:\\Tcp3dDebug.log) generated from running the simulator.\r
112 */\r
113 #define TEST_PROFILE_LOG 1 \r
114 \r
115 /**********************************************************************\r
116 ************************** Test Definitions **************************\r
117 **********************************************************************/\r
118 #define START_CMD_PERIOD 1\r
119 \r
120 #ifdef CSL_PSC_PD_TCP3D_A\r
121 /* Convert Keystone CSL definitions ti Keystone2 CSL definitions */\r
122 #define CSL_PSC_PD_TCP3D_01 CSL_PSC_PD_TCP3D_A\r
123 #define CSL_PSC_LPSC_TCP3D_0 CSL_PSC_LPSC_TCP3D_A\r
124 #endif\r
125 \r
126 /**********************************************************************\r
127 ************************** Test Variables ****************************\r
128 **********************************************************************/\r
129 /* Code Block Test Variables */\r
130 #pragma DATA_SECTION(codeBlockSet, ".main_mem")\r
131 cbTestDesc codeBlockSet;\r
132 \r
133 Char *strMode[4] = {"3GPP(0)","LTE(1)","WIMAX(2)","WCDMA Split(3)"};\r
134 Char *strDBuf[2] = {"Disable(0)","Enable(1)"};\r
135 Char *strInst[2] = {"TCP3D_0(0)","TCP3D_1(1)"};\r
136 \r
137 UInt32 keepTestVectMem = 0;\r
138 UInt32 firstTime = 1;\r
139 UInt32 testMaxCodeBlocks;\r
140 UInt32 dspCoreID;\r
141 \r
142 /* File Operation Variables */\r
143 UInt32 testCntr = 0;\r
144 UInt32 testErrCntr = 0;\r
145 UInt32 totErrCnt;\r
146 #ifdef USE_PDK_INSTALL_BASE\r
147 Char testvectFolderBase[] = "C:\\ti\\csl_lld_keystone2_1_0_0_2\\packages\\ti\\drv\\tcp3d\\example\\testvectors\\";\r
148 #else\r
149 Char testvectFolderBase[] = "..\\..\\testvectors\\";\r
150 #endif\r
151 Char folderName[1000] = "";\r
152 Char *testFolder[] = { "lte", "wcdma", "wimax", };\r
153 /* Number of test folders computed. Alternately can be set manually as length of *testFolder[] array */\r
154 UInt32 numTests = sizeof(testFolder)/sizeof(*testFolder);\r
155 \r
156 /* Throughput calculation variables */\r
157 clock_t total_clock_end, total_clock_start;\r
158 UInt32 test_cycles;\r
159 UInt32 TotalBitsDecoded;\r
160 Float ThroughPut;\r
161 \r
162 /* BIOS variables */\r
163 Semaphore_Handle semRcvDone, semSendBlock, semSendWait, semRcvStart;\r
164 IHeap_Handle dataHeap = NULL;\r
165 IHeap_Handle drvHeap = NULL;\r
166 \r
167 /* Driver configuration variables */\r
168 Tcp3d_Result tcp3dResultSend = TCP3D_DRV_NO_ERR;\r
169 Tcp3d_Instance *tcp3dDrvInst[2] = {NULL, NULL};\r
170 Tcp3d_Instance *inst;\r
171 Tcp3d_Ctrl drvCtrl;\r
172 Tcp3d_Sts drvStatus;\r
173 \r
174 Int32 sendBlockCnt;\r
175 Int32 rcvBlockCnt;\r
176 #if TEST_PREPARE_ONLY_CODEBLOCK_PARAM_DEPENDENT\r
177 UInt32 tempICRegs[15]; /* to store 15 registers */\r
178 #endif\r
179 \r
180 /**\r
181 * EDMA3 LLD & TCP3D Driver Init/Deinit related variables\r
182 */\r
183 EDMA3_DRV_Handle hEdma;\r
184 UInt32 tpccNum;\r
185 UInt32 tpccRegionUsed;\r
186 EDMA_CONFIG edmaConfig[2];\r
187 UInt8 instNum;\r
188 /* Flags used in ISR functions */\r
189 UInt32 pingComplete, pongComplete;\r
190 UInt32 pauseIntr = 0, l2pIntr = 0;\r
191 UInt32 soldoutCntr = 0;\r
192 UInt32 tcp3dEventCntr = 0;\r
193 UInt32 tpccEvtCntr = 0;\r
194 UInt32 rcvStartFlag = 0;\r
195 UInt32 pauseIntFlag = 0;\r
196 UInt32 afterIntrSoldout = 0, afterIntrPause = 0;\r
197 UInt32 pendPauseCntr = 0;\r
198 \r
199 #if DEBUG_VARS\r
200 #include <ti/csl/src/intc/csl_intc.h>\r
201 #include <ti/csl/csl_cpIntcAux.h>\r
202 \r
203 /* To track the RCV task posting */\r
204 volatile Int semCnt;\r
205 \r
206 /* Register pointers */\r
207 CSL_TpccRegs *tpcc2Regs = (CSL_TpccRegs *) CSL_EDMA2CC_REGS;\r
208 CSL_CPINTC_RegsOvly cpintc0Regs = (CSL_CPINTC_RegsOvly) CSL_CP_INTC_0_REGS;\r
209 CSL_IntcRegsOvly gemIntcRegs = (CSL_IntcRegsOvly)CSL_CGEM0_5_REG_BASE_ADDRESS_REGS;\r
210 #endif\r
211 \r
212 /**********************************************************************\r
213 *********************** Test Local Functions *************************\r
214 **********************************************************************/\r
215 /**\r
216 * Task Functions\r
217 */\r
218 Void testerTaskFunc(Void);\r
219 Void tskHeartBeat(Void);\r
220 Void sndBlockTaskFunc(Void);\r
221 Void rcvBlockTaskFunc(Void);\r
222 \r
223 /**\r
224 * (De)Init Functions\r
225 */\r
226 Void allInit(Void);\r
227 Void allDeInit(Void);\r
228 Void getMemoryStats(Void);\r
229 \r
230 /**\r
231 * EDMA Channel ISR functions\r
232 */\r
233 Void revt0ChCallback(Void);\r
235 \r
236 /**\r
237 * Cache and other IP functions\r
238 */\r
239 #ifndef SIMULATOR_SUPPORT\r
240 static Int32 enable_ip_instance (UInt32 pwrDmnNum, UInt32 moduleNum);\r
241 #endif\r
242 static Int32 enable_tcp3d (void);\r
243 void tcp3dBeginMemAccess (void *ptr, uint32_t size);\r
244 void tcp3dEndMemAccess (void *ptr, uint32_t size);\r
245 \r
246 #if USE_LOCAL_CPINTC_DISPATCH\r
247 extern Void CpIntc_dispatchLoc(UInt hostInt);\r
248 #endif\r
249 \r
250 Void soldOutAction(Void)\r
251 {\r
252 /* clear flag */\r
253 pauseIntFlag = 0;\r
254 \r
255 #if SOLDOUT_USE_L2P_INTERRUPT\r
256 /**\r
257 * 1) enable L2P channel interrupt to get notified to try enqueue again\r
258 * 2) also enable REVT channel interrupt for PAUSE detection\r
259 */\r
260 /* Set interrupt flag on PAUSE channel */\r
261 drvCtrl.cmd = TCP3D_DRV_SET_REVT_INT;\r
262 drvCtrl.intrFlag = TEST_INTR_ENABLE; // enable\r
263 Tcp3d_control(inst, &drvCtrl);\r
264 \r
265 /* Call TCP3D driver control to set interrupt on L2P channel */\r
266 drvCtrl.cmd = TCP3D_DRV_SET_L2P_INT;\r
267 drvCtrl.intrFlag = TEST_INTR_ENABLE; // enable\r
268 Tcp3d_control(inst, &drvCtrl);\r
269 #else\r
270 /* keep trying until successful */\r
271 Semaphore_post(semSendBlock);\r
272 #endif\r
273 }\r
274 \r
275 Void soldOutActionClear (Void)\r
276 {\r
277 #if SOLDOUT_USE_L2P_INTERRUPT\r
278 if ( pauseIntFlag )\r
279 {\r
280 afterIntrSoldout++;\r
281 \r
282 /**\r
283 * 1) diable L2P channel interrupt to get notified to try enqueue again\r
284 * 2) also disable REVT channel interrupt for PAUSE detection\r
285 */\r
286 /* Call TCP3D driver control to set interrupt on L2P channel */\r
287 drvCtrl.cmd = TCP3D_DRV_SET_L2P_INT;\r
288 drvCtrl.intrFlag = TEST_INTR_DISABLE; // disable\r
289 Tcp3d_control(inst, &drvCtrl);\r
290 \r
291 /* Set interrupt flag on PAUSE channel */\r
292 drvCtrl.cmd = TCP3D_DRV_SET_REVT_INT;\r
293 drvCtrl.intrFlag = TEST_INTR_DISABLE; // disable\r
294 Tcp3d_control(inst, &drvCtrl);\r
295 }\r
296 #else\r
297 /* nothing to be done */\r
298 #endif\r
299 }\r
300 \r
301 /*******************************************************************************\r
302 TESTING METHOD 1: Copy test vector folder to workspace\r
303 --------------------------------------------------------------------------------\r
305 placed two levels higher than the unit example project .out file location.\r
306 For example, if the unit example project out file is located under\r
309 2. Ensure that the compile flag USE_PDK_INSTALL_BASE is undefined in\r
311 3. Build the project.\r
312 4. Launch the debug session to load and run the out file.\r
313 \r
314 TESTING METHOD 2: Use the test vector folder from the PDK installation\r
315 --------------------------------------------------------------------------------\r
316 1. In this method, ensure that the compile flag USE_PDK_INSTALL_BASE is defined\r
320 when the USE_PDK_INSTALL_BASE flag is defined.\r
321 3. Build the project.\r
322 4. Launch the debug session to load and run the out file.\r
323 \r
324 By default, example project is configured to test using "METHOD 1"\r
325 ******************************************************************************/\r
326 /*\r
327 * main()\r
328 */\r
329 Void main(Void)\r
330 {\r
331 Task_Params taskParams;\r
332 \r
333 /* Initialize the heap in shared memory. Using IPC module to do that */ \r
334 Ipc_start();\r
335 \r
336 /* Power on TCP3D peripheral before using it */\r
337 if (enable_tcp3d () < 0)\r
338 {\r
339 System_printf ("Error: TCP3D PSC Initialization Failed\n");\r
340 return;\r
341 }\r
342 \r
343 /* Enable time stamp counter */\r
344 CSL_tscEnable();\r
345 \r
346 /* Enable L1D cache. Disable L2 caching for our tests. */\r
347 CACHE_setL1DSize (CACHE_L1_MAXIM3); /* CACHE_L1_0KCACHE */\r
348 CACHE_setL2Size (CACHE_0KCACHE);\r
349 \r
350 /* Initialize the default Task parameters */\r
351 Task_Params_init(&taskParams);\r
352 \r
353 /* Crete the tester Task using default Task parameters */\r
354 Task_create((Task_FuncPtr)testerTaskFunc, &taskParams, NULL);\r
355 \r
356 BIOS_start();\r
357 }\r
358 \r
359 /*******************************************************************************\r
360 ******************************************************************************/\r
361 Void testerTaskFunc(Void)\r
362 {\r
363 Int i;\r
364 Task_Params taskParams;\r
365 Semaphore_Params semParams;\r
366 \r
367 /* Set the one-time global test variables */\r
368 testMaxCodeBlocks = 86; /* max possible used in init */\r
369 dspCoreID = CSL_chipReadDNUM();\r
370 \r
371 /******** Select the TCP3D Instance Number **********/\r
372 instNum = getTcp3dInstNum(dspCoreID);\r
373 \r
374 /* Initialize the default Task parameters */\r
375 Task_Params_init(&taskParams);\r
376 \r
377 /* Initialize the default Semaphore parameters */\r
378 Semaphore_Params_init(&semParams);\r
379 \r
380 /* Crete the Binary Semaphore */\r
381 semParams.mode = Semaphore_Mode_BINARY;\r
382 semRcvDone = Semaphore_create(0, &semParams, NULL);\r
383 \r
384 /* Get the Heap handles - used when ever memory allocations are needed */\r
385 //dataHeap = HeapMem_Handle_upCast(tcp3dDataHeap);\r
386 dataHeap = (IHeap_Handle) SharedRegion_getHeap(0);\r
387 drvHeap = HeapMem_Handle_upCast(tcp3dDrvHeap);\r
388 \r
389 while( testCntr < numTests )\r
390 {\r
391 \r
392 /**\r
393 * Create the Binary semaphores each time using the parameters set\r
394 * outside the tester while loop.\r
395 * \r
396 * It was observed that at times the receive semaphore count was\r
397 * non-zero after the first run and receive task was getting triggered\r
398 * before posting from the ISR callback. So, the semaphores are created\r
399 * for each test to work-around with the problem. \r
400 */\r
401 semSendBlock = Semaphore_create(0, &semParams, NULL);\r
402 semSendWait = Semaphore_create(0, &semParams, NULL);\r
403 semRcvStart = Semaphore_create(0, &semParams, NULL);\r
404 #if DEBUG_VARS\r
405 semCnt = Semaphore_getCount(semRcvStart);\r
406 #endif\r
407 \r
408 /**\r
409 * Create the send and receive tasks for each test using the default\r
410 * tak parameters.\r
411 * \r
412 * NOTE: No need to do the Task_delete() as these tasks have exits.\r
413 */\r
414 Task_create((Task_FuncPtr)sndBlockTaskFunc, &taskParams, NULL);\r
415 Task_create((Task_FuncPtr)rcvBlockTaskFunc, &taskParams, NULL);\r
416 \r
417 System_printf("\n******************************************************************\n");\r
418 System_printf("\n----- TEST #%d STARTED ------\n", testCntr);\r
419 \r
420 /**\r
421 * Prepare data for Code Blocks processing (reading test vector files).\r
422 * Allocates Memory as needed from the tcp3dDataHeap\r
423 */\r
424 if ( firstTime )\r
425 {\r
426 System_printf("\nReading test vector files started (including memory allocation)...\n");\r
427 strcpy(folderName, testvectFolderBase);\r
428 strcat(folderName, testFolder[testCntr]);\r
429 getTestSetCB(dataHeap, &codeBlockSet, folderName);\r
430 System_printf("Reading test vector files complete\n");\r
431 #if DEBUG_PRINT\r
432 System_printf("\tPrepared %d code blocks in %s mode\n", codeBlockSet.maxNumCB, strMode[codeBlockSet.mode]);\r
433 #endif\r
434 firstTime = 0;\r
435 }\r
436 else\r
437 {\r
438 System_printf("\nUsing the test vectors read before\n");\r
439 }\r
440 \r
441 System_printf("\n----- TEST INITIALIZATION STARTED -----\n\n");\r
442 allInit();\r
443 getMemoryStats(); /* Heap Stats */\r
444 System_printf("\n----- TEST INITIALIZATION COMPLETE -----\n\n");\r
445 \r
446 #if TEST_PREPARE_ONLY_BETASTATE\r
447 for (i = 0; i < codeBlockSet.maxNumCB ;i++)\r
448 {\r
449 /* Prepare fixed IC registers using the inCfgParams of first block*/\r
450 Tcp3d_prepFixedConfigRegs(codeBlockSet.cbData[i]->inCfgParams, codeBlockSet.cbData[i]->inCfg);\r
451 \r
452 /* Prepare block size dependent params */\r
453 prepareBlockSizeDepICParams(codeBlockSet.cbData[i]);\r
454 }\r
455 #elif TEST_PREPARE_ONLY_CODEBLOCK_PARAM_DEPENDENT\r
456 /* Prepare fixed IC registers using the inCfgParams of first block*/\r
457 Tcp3d_prepFixedConfigRegs(codeBlockSet.cbData[0]->inCfgParams, tempICRegs);\r
458 #endif\r
459 \r
460 /* Start the Send task first */\r
461 Semaphore_post(semSendBlock);\r
462 \r
463 /* Wait for the Receive task to complete */\r
464 Semaphore_pend(semRcvDone, BIOS_WAIT_FOREVER);\r
465 \r
466 /**\r
467 * Test Profile Calculations\r
468 * \r
469 * (Total Bits)\r
470 * Throughput (Mbps) = -----------------------------\r
471 * (Total Time)*(10^-9)*(10^6)\r
472 * \r
473 */\r
474 TotalBitsDecoded = 0;\r
475 for (i = 0; i < codeBlockSet.maxNumCB; ++i)\r
476 {\r
477 TotalBitsDecoded += codeBlockSet.cbData[i]->blockSize;\r
478 }\r
479 \r
480 test_cycles = (total_clock_end - total_clock_start);\r
481 ThroughPut = TotalBitsDecoded*1.0;\r
482 ThroughPut = (ThroughPut/test_cycles)*1000;\r
483 \r
484 /******** Free code blocks ********/\r
485 if ( keepTestVectMem )\r
486 {\r
487 System_printf("\nNo freeing - Using the test vectors read before\n");\r
488 }\r
489 else\r
490 {\r
491 System_printf("\nTest vectors memory freeing started...\n");\r
492 freeTestSetCB(dataHeap, &codeBlockSet);\r
493 System_printf("Test vectors memory freeing complete\n");\r
494 #if DEBUG_PRINT\r
495 System_printf("\tFreed memory allocated for %d code blocks in %s mode\n", codeBlockSet.maxNumCB, strMode[codeBlockSet.mode]);\r
496 #endif\r
497 firstTime = 1;\r
498 }\r
499 \r
500 System_printf("\n----- TEST DE-INITIALIZATION STARTED -----\n\n");\r
501 allDeInit();\r
502 getMemoryStats(); /* Heap Stats */\r
503 System_printf("\n----- TEST DE-INITIALIZATION COMPLETE -----\n");\r
504 \r
505 if ( totErrCnt > 0 )\r
506 {\r
507 System_printf("\n----- TEST #%d FAILED -----\n", testCntr);\r
508 testErrCntr++;\r
509 }\r
510 else\r
511 {\r
512 System_printf("\n----- TEST #%d PASSED -----\n", testCntr);\r
513 }\r
514 System_printf("\n+++++++++++++++++++++++ TEST #%d SUMMARY +++++++++++++++++++++++++\n", testCntr);\r
515 System_printf("TCP3D Peripheral Configuration\n");\r
516 System_printf(" Instance : %s\n", strInst[instNum]);\r
517 System_printf(" Mode Tested : %s\n", strMode[codeBlockSet.mode]);\r
518 System_printf(" Double Buffer Mode : %s\n", strDBuf[codeBlockSet.doubleBuffer]);\r
519 System_printf("Max code blocks (Input Capacity) : %d\n", testMaxCodeBlocks);\r
520 System_printf("Code blocks sent for decoding : %d\n", codeBlockSet.maxNumCB);\r
521 System_printf("Call back counters : %d - interrupts\n", pauseIntr);\r
522 System_printf(" (%d-SOLDOUT, %d-PAUSE, %d-PENDPAUSE)\n", afterIntrSoldout, afterIntrPause, pendPauseCntr);\r
523 System_printf("Total Notification Interrupts : %d\n", tcp3dEventCntr);\r
524 System_printf("Throughput Calculations\n");\r
525 System_printf(" Total Bits Decoded : %d\n", TotalBitsDecoded);\r
526 System_printf(" Time Taken (in cycles) : %d\n", test_cycles);\r
527 System_printf(" Effective Throughput : %f Mbps\n", ThroughPut);\r
528 System_printf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");\r
529 \r
530 System_printf("\n******************************************************************\n");\r
531 \r
532 /* Increment the test counter */\r
533 testCntr++;\r
534 \r
535 /**\r
536 * Delete the semaphores each time, so that there is no left over count.\r
537 * See the explanation at the beginning of this loop where the create\r
538 * semaphore calls are present. \r
539 */\r
540 #if DEBUG_VARS\r
541 semCnt = Semaphore_getCount(semRcvStart);\r
542 #endif\r
543 Semaphore_delete(&semSendWait);\r
544 Semaphore_delete(&semSendBlock);\r
545 Semaphore_delete(&semRcvStart);\r
546 }\r
547 \r
548 /* All test status print */\r
549 if(testErrCntr)\r
550 {\r
551 System_printf("!!! SOME TESTS FAILED !!!\n");\r
552 }\r
553 else\r
554 {\r
555 System_printf("!!! ALL TESTS PASSED !!!\n");\r
556 }\r
557 \r
558 /* Remove all creations - to make graceful system exit */\r
559 Semaphore_delete(&semRcvDone);\r
560 \r
561 System_exit(0);\r
562 }\r
563 \r
564 /*******************************************************************************\r
565 ******************************************************************************/\r
566 Void sndBlockTaskFunc(Void)\r
567 {\r
568 UInt8 notifyFlag;\r
569 cbDataDesc *cbPtr;\r
570 static UInt32 cookie = 0;\r
571 \r
572 sendBlockCnt = 0;\r
573 \r
574 #if DEBUG_VARS\r
575 semCnt = Semaphore_getCount(semSendBlock);\r
576 #endif\r
577 \r
578 total_clock_start = TSCL;\r
579 \r
580 while(1)\r
581 {\r
582 /* Pending on Semaphore to run the loop */\r
583 Semaphore_pend(semSendBlock, BIOS_WAIT_FOREVER);\r
584 \r
585 /* set TCP3D instance to use */\r
586 inst = tcp3dDrvInst[instNum];\r
587 \r
588 /* Get pointer to the code block data structure */\r
589 cbPtr = codeBlockSet.cbData[sendBlockCnt];\r
590 \r
591 /* Interrupt flag, used in Tcp3d_enqueueCodeBlock function */\r
592 notifyFlag = 0;\r
593 if ( sendBlockCnt >= (codeBlockSet.maxNumCB-2) )\r
594 {\r
595 notifyFlag = 1; /* Set for the last CB in each path (PING & PONG) */\r
596 }\r
597 \r
598 /**\r
599 * Prepare input configuration (IC) registers.\r
600 */\r
601 if ( TCP3D_DRV_INPUT_LIST_FULL == tcp3dResultSend )\r
602 {\r
603 /* IC prepare not required. Just clear soldout actions. */\r
604 soldOutActionClear();\r
605 }\r
606 else\r
607 {\r
608 /* Prepare Input Config Registers */\r
609 #if TEST_PREPARE_ONLY_BETASTATE\r
610 /* Prepare only beta state registers */\r
611 prepareBetaStateICParams(cbPtr, cbPtr->mode);\r
612 #elif TEST_PREPARE_ONLY_CODEBLOCK_PARAM_DEPENDENT \r
613 /* Prepare only registers depend on code block configuration\r
614 * (tempICRegs has the fixed registers prepare outside send loop) */\r
615 prepareIC(cbPtr, tempICRegs, 1);\r
616 #else\r
617 /* Prepare all registers */\r
618 prepareIC(cbPtr, NULL, NULL);\r
619 #endif\r
620 }\r
621 \r
622 checkBetaValues (cbPtr->inCfg);\r
623 \r
624 /* Disabling the global interrupts */\r
625 cookie = Hwi_disable();\r
626 \r
627 tcp3dEndMemAccess(cbPtr->inCfg, cbPtr->sizeCFG);\r
628 tcp3dEndMemAccess(cbPtr->inLLR, cbPtr->sizeLLR);\r
629 \r
630 tcp3dBeginMemAccess(cbPtr->outHD, cbPtr->sizeHD);\r
631 if (cbPtr->sdFlag)\r
632 tcp3dBeginMemAccess(cbPtr->outSD, cbPtr->sizeSD);\r
633 if (cbPtr->stsFlag)\r
634 tcp3dBeginMemAccess(cbPtr->outSts, cbPtr->sizeSTS);\r
635 \r
636 /* Restore interrupts */\r
637 Hwi_restore(cookie);\r
638 \r
639 /**\r
640 * WORKAROUND CODE:\r
641 * This code works in line with the code in the second while loop\r
642 * in the send task where check for completion is done.\r
643 * Here we are setting the last byte in the outHD with some value when\r
644 * the refHD has 0x00. This avoids any false completion of send task.\r
645 */\r
646 if ( sendBlockCnt >= (codeBlockSet.maxNumCB-2) )\r
647 {\r
648 /* Fill the last byte in outHD when refHD last byte is ZERO */\r
649 uint8_t *bytePtr1, *bytePtr2;\r
650 uint32_t byteSize;\r
651 \r
652 bytePtr1 = (UInt8 *) cbPtr->refHD;\r
653 bytePtr2 = (UInt8 *) cbPtr->outHD;\r
654 byteSize = (cbPtr->blockSize>>3);\r
655 \r
656 if ( bytePtr1[byteSize-1] == 0 )\r
657 {\r
658 bytePtr2[byteSize-1] = 0xde;\r
659 }\r
660 }\r
661 \r
662 \r
663 /* Enqueue the Code block */\r
664 tcp3dResultSend = Tcp3d_enqueueCodeBlock ( inst,\r
665 cbPtr->blockSize,\r
666 (UInt32 *)L2GLBMAP(dspCoreID, cbPtr->inCfg),\r
667 (Int8 *)L2GLBMAP(dspCoreID, cbPtr->inLLR),\r
668 cbPtr->llrOffset,\r
669 (UInt32 *)L2GLBMAP(dspCoreID, cbPtr->outHD),\r
670 (Int8 *)L2GLBMAP(dspCoreID, cbPtr->outSD), \r
671 cbPtr->sdOffset,\r
672 (UInt32 *)L2GLBMAP(dspCoreID, cbPtr->outSts),\r
673 notifyFlag); // 1 - GEN EVENT, 0 - NO EVENT\r
674 \r
675 \r
676 /* Check for soldout case */\r
677 if ( TCP3D_DRV_INPUT_LIST_FULL != tcp3dResultSend )\r
678 {\r
679 /* increment the block count */\r
680 sendBlockCnt++;\r
681 \r
682 /* goto next block */\r
683 Semaphore_post(semSendBlock);\r
684 }\r
685 else\r
686 {\r
687 /* increment soldout count */\r
688 soldoutCntr++;\r
689 \r
690 soldOutAction(); /* take action */\r
691 }\r
692 \r
693 /* Start the driver after START_CMD_PERIOD blocks */\r
694 if ( sendBlockCnt == START_CMD_PERIOD )\r
695 {\r
696 if ( TCP3D_DRV_NO_ERR != Tcp3d_start(inst, TCP3D_DRV_START_AUTO) )\r
697 {\r
698 System_printf("Tcp3d_start function returned error (AUTO)\n");\r
699 System_exit(0);\r
700 }\r
701 }\r
702 \r
703 /* Check for end of task and exit */\r
704 if ( sendBlockCnt >= codeBlockSet.maxNumCB )\r
705 {\r
706 /* set flags first */\r
707 pauseIntFlag = 0;\r
708 l2pIntr = pauseIntr;\r
709 pendPauseCntr = 0;\r
710 \r
711 #if SOLDOUT_USE_L2P_INTERRUPT\r
712 if ( soldoutCntr )\r
713 {\r
714 /* Call TCP3D driver control to set interrupt on L2P channel */\r
715 drvCtrl.cmd = TCP3D_DRV_SET_L2P_INT;\r
716 drvCtrl.intrFlag = TEST_INTR_DISABLE; // disable\r
717 Tcp3d_control(inst, &drvCtrl);\r
718 }\r
719 #endif\r
720 \r
721 /* Set interrupt flag PAUSE channel */\r
722 drvCtrl.cmd = TCP3D_DRV_CLR_REVT_INT;\r
723 Tcp3d_control(inst, &drvCtrl);\r
724 \r
725 /* Check to see if restart needed before exit */\r
726 if ( TCP3D_DRV_NO_ERR != Tcp3d_start(inst, TCP3D_DRV_START_AUTO) )\r
727 {\r
728 System_printf("Tcp3d_start function returned error (AUTO)\n");\r
729 System_exit(0);\r
730 }\r
731 \r
732 /* Set interrupt flag PAUSE channel */\r
733 drvCtrl.cmd = TCP3D_DRV_SET_REVT_INT;\r
734 drvCtrl.intrFlag = TEST_INTR_ENABLE; // enable\r
735 Tcp3d_control(inst, &drvCtrl);\r
736 \r
737 /* out of enqueue loop */\r
738 break;\r
739 }\r
740 } /* end of - while(1) */\r
741 \r
742 #if DEBUG_VARS\r
743 semCnt = Semaphore_getCount(semSendWait);\r
744 #endif\r
745 \r
746 /**\r
747 * Check for pending Pauses and waiting for the last block to be decoded \r
748 */\r
749 while ( 1 )\r
750 {\r
751 /* Pending on Semaphore to run the loop */\r
752 Semaphore_pend(semSendWait, BIOS_WAIT_FOREVER);\r
753 \r
754 /* Received both the completion events, so exit send task */\r
755 if ( tcp3dEventCntr >= 2 )\r
756 {\r
757 break;\r
758 } else if ( tcp3dEventCntr == 1 )\r
759 {\r
760 /* one code block test case */\r
761 if ( codeBlockSet.maxNumCB == 1 )\r
762 {\r
763 break;\r
764 }\r
765 else if ( codeBlockSet.mode == TEST_MODE_SPLIT )\r
766 { /* missing one notificatin event - possible in split mode */\r
767 /**\r
768 * WORKAROUND CODE:\r
769 * This is possibility in case of SPLIT mode, that one event is\r
770 * lost when both ping and pong channels try to generate system\r
771 * events at close proximity.\r
772 * In this test bench we have enabled notification events for\r
773 * the last two blocks, so checking the outHD & refHD last bytes\r
774 * to confirm the decoding of these blocks are completed.\r
775 */\r
776 \r
777 /* cbPtr for last two code blocks */\r
778 cbDataDesc *cbPtr1 = codeBlockSet.cbData[codeBlockSet.maxNumCB-2];\r
779 cbDataDesc *cbPtr2 = codeBlockSet.cbData[codeBlockSet.maxNumCB-1];\r
780 uint8_t *bytePtr11, *bytePtr12, *bytePtr21, *bytePtr22;\r
781 uint32_t size1, size2;\r
782 \r
783 bytePtr11 = (UInt8 *) cbPtr1->refHD;\r
784 bytePtr12 = (UInt8 *) cbPtr1->outHD;\r
785 bytePtr21 = (UInt8 *) cbPtr2->refHD;\r
786 bytePtr22 = (UInt8 *) cbPtr2->outHD;\r
787 size1 = (cbPtr1->blockSize>>3); /* in bytes */\r
788 size2 = (cbPtr2->blockSize>>3); /* in bytes */\r
789 \r
790 /* check if last HD byte of last two blocks are completed */\r
791 if ((bytePtr11[size1-1] == bytePtr12[size1-1]) &&\r
792 (bytePtr21[size2-1] == bytePtr22[size2-1]) ) \r
793 {\r
794 System_printf("Notification event missed (Race Condition)\n");\r
795 System_printf("Since the last two block decoding completed, completing send task\n");\r
796 System_printf("Block : %d\n", codeBlockSet.maxNumCB-2);\r
797 System_printf("\trefHD[%d] = 0x%x\t outHD[%d] = 0x%x\n", size1-1, bytePtr11[size1-1], size1-1, bytePtr12[size1-1]);\r
798 System_printf("Block : %d\n", codeBlockSet.maxNumCB-1);\r
799 System_printf("\trefHD[%d] = 0x%x\t outHD[%d] = 0x%x\n", size2-1, bytePtr21[size2-1], size2-1, bytePtr22[size2-1]);\r
800 break;\r
801 }\r
802 }\r
803 }\r
804 \r
805 if ( TCP3D_DRV_NO_ERR != Tcp3d_start(inst, TCP3D_DRV_START_AUTO) )\r
806 {\r
807 System_printf("Tcp3d_start function returned error\n");\r
808 System_exit(0);\r
809 }\r
810 \r
811 /* keep trying until finding two end events */\r
812 Semaphore_post(semSendWait);\r
813 \r
814 pendPauseCntr++;\r
815 }\r
816 \r
817 /* Last code block decoded - Start the receive task */\r
818 total_clock_end = TSCL;\r
819 Semaphore_post(semRcvStart);\r
820 }\r
821 \r
822 /*******************************************************************************\r
823 ******************************************************************************/\r
824 Void rcvBlockTaskFunc(Void)\r
825 {\r
826 Int32 errCnt;\r
827 \r
828 cbDataDesc *cbPtr;\r
829 Int idx, loopCnt;\r
830 Int fail = 0;\r
831 UInt8 *ptr1, *ptr2;\r
832 \r
833 rcvBlockCnt = 0;\r
834 totErrCnt = 0;\r
835 \r
836 while(1)\r
837 {\r
838 Semaphore_pend(semRcvStart, BIOS_WAIT_FOREVER);\r
839 \r
840 /* prints for send task are done here */\r
841 if ( tcp3dResultSend == TCP3D_DRV_NO_ERR )\r
842 {\r
843 #if DEBUG_PRINT\r
844 for ( loopCnt = 0; loopCnt < sendBlockCnt; loopCnt++ )\r
845 {\r
846 cbPtr = codeBlockSet.cbData[loopCnt];\r
847 System_printf("Send Task: Enqueued Block %d (Size: %d, SW0: %d)\n",\r
848 loopCnt, cbPtr->blockSize,\r
849 cbPtr->sw0LengthUsed);\r
850 }\r
851 #endif\r
852 System_printf("Send Task: Enqueued %d Blocks\n\n", sendBlockCnt);\r
853 }\r
854 else\r
855 {\r
856 System_printf("Send Task: Enqueued Blocks failed (tcp3dResultSend : %d)\n\n", tcp3dResultSend);\r
857 System_exit(0);\r
858 }\r
859 \r
860 MY_LOG_PRINT0(Rcv Task: SEM RECEIVED);\r
861 \r
862 while( rcvBlockCnt < codeBlockSet.maxNumCB )\r
863 {\r
864 /* Get the pointer to the Code Block Set */\r
865 cbPtr = codeBlockSet.cbData[rcvBlockCnt];\r
866 \r
867 /* Step 2: Verify All the outputs */\r
868 fail = 0;\r
869 /* Step 2.1: Hard Decisions Verification */\r
870 ptr1 = (UInt8 *) cbPtr->refHD;\r
871 ptr2 = (UInt8 *) cbPtr->outHD;\r
872 \r
873 /* Invalidate out HD */\r
874 CACHE_invL1d (cbPtr->outHD, cbPtr->blockSize>>3, CACHE_WAIT);\r
875 \r
876 errCnt = 0; \r
877 for (idx = 0; idx < (cbPtr->blockSize>>3); ++idx)\r
878 {\r
879 if ( ptr1[idx] != ptr2[idx] )\r
880 {\r
881 errCnt++;\r
882 System_printf("\tBlock Count %d, HD mismatch byte %d\n", rcvBlockCnt, idx);\r
883 }\r
884 }\r
885 \r
886 if (errCnt)\r
887 {\r
888 MY_LOG_PRINT2(Rcv task: HD FAILED, rcvBlockCnt, ERRORS:, errCnt);\r
889 fail++;\r
890 }\r
891 else\r
892 {\r
893 MY_LOG_PRINT1(Rcv task: HD PASSED, rcvBlockCnt);\r
894 }\r
895 \r
896 /* Step 2.2: Soft Decisions Verification */\r
897 if (cbPtr->sdFlag)\r
898 {\r
899 if ( codeBlockSet.mode == TEST_MODE_SPLIT ) /* SPLIT MODE */\r
900 loopCnt = cbPtr->blockSize;\r
901 else\r
902 loopCnt = (3*cbPtr->blockSize);\r
903 \r
904 /* Invalidate out SD */\r
905 CACHE_invL1d (cbPtr->outSD, loopCnt, CACHE_WAIT);\r
906 \r
907 /* NOTE: Assumed that the Soft Decisions are in a single array */\r
908 errCnt = 0;\r
909 for (idx = 0; idx < loopCnt; ++idx)\r
910 {\r
911 if ( cbPtr->refSD[idx] != cbPtr->outSD[idx] )\r
912 {\r
913 errCnt += 1;\r
914 System_printf("\tBlock Count %d, SD mismatch byte %d\n", rcvBlockCnt, idx);\r
915 }\r
916 }\r
917 \r
918 if (errCnt)\r
919 {\r
920 MY_LOG_PRINT2(Rcv task: SD FAILED, rcvBlockCnt, ERRORS:, errCnt);\r
921 fail++;\r
922 }\r
923 else\r
924 {\r
925 MY_LOG_PRINT1(Rcv task: SD PASSED, rcvBlockCnt);\r
926 }\r
927 } /* if (cbPtr->sdFlag) */\r
928 \r
929 /* Step 2.3: errCnt Registers Verification */\r
930 if (cbPtr->stsFlag)\r
931 {\r
932 /* Invalidate out Sts */\r
933 CACHE_invL1d (cbPtr->outSts, 12, CACHE_WAIT);\r
934 \r
935 errCnt = 0;\r
936 for (idx = 0; idx < 3; ++idx)\r
937 {\r
938 if ( cbPtr->refSts[idx] != cbPtr->outSts[idx] )\r
939 {\r
940 errCnt += 1;\r
941 System_printf("\tBlock Count %d, STS mismatch word %d\n", rcvBlockCnt, idx);\r
942 }\r
943 }\r
944 if (errCnt)\r
945 {\r
946 MY_LOG_PRINT2(Rcv task: STS FAILED, rcvBlockCnt, ERRORS:, errCnt);\r
947 fail++;\r
948 }\r
949 else\r
950 {\r
951 MY_LOG_PRINT1(Rcv task: STS PASSED, rcvBlockCnt);\r
952 }\r
953 } /* if (cbPtr->stsFlag) */\r
954 if (fail)\r
955 {\r
956 System_printf("Rcv task: Block %d FAILED\n", rcvBlockCnt);\r
957 totErrCnt++;\r
958 }\r
959 #if DEBUG_PRINT\r
960 else\r
961 {\r
962 System_printf("Rcv task: Block %d PASSED\n", rcvBlockCnt);\r
963 }\r
964 #endif\r
965 rcvBlockCnt++;\r
966 }\r
967 if(rcvBlockCnt >= codeBlockSet.maxNumCB)\r
968 {\r
969 break;\r
970 } \r
971 }\r
972 \r
973 System_printf("Rcv Task: COMPLETE - verified %d blocks\n", rcvBlockCnt);\r
974 \r
975 /* Prepare for next test, set by "tester task" */\r
976 Semaphore_post(semRcvDone);\r
977 }\r
978 \r
979 /*******************************************************************************\r
980 ******************************************************************************/\r
981 Void revt0ChCallback(Void)\r
982 {\r
983 /* Increment the ISR counter */\r
984 pauseIntr++;\r
985 \r
986 pauseIntFlag = 1;\r
987 \r
988 if ( sendBlockCnt >= codeBlockSet.maxNumCB )\r
989 Semaphore_post(semSendWait);\r
990 else\r
991 Semaphore_post(semSendBlock);\r
992 }\r
993 \r
994 /*******************************************************************************\r
995 ******************************************************************************/\r
996 Void revt1ChCallback(Void)\r
997 {\r
998 /* Increment the ISR counter */\r
999 pauseIntr++;\r
1000 \r
1001 pauseIntFlag = 2;\r
1002 \r
1003 if ( sendBlockCnt >= codeBlockSet.maxNumCB )\r
1004 Semaphore_post(semSendWait);\r
1005 else\r
1006 Semaphore_post(semSendBlock);\r
1007 }\r
1008 \r
1009 /*******************************************************************************\r
1010 ******************************************************************************/\r
1011 Void tskHeartBeat(Void)\r
1012 {\r
1013 static unsigned int counter = 0u;\r
1014 \r
1015 while (counter < 0x1000000u)\r
1016 {\r
1017 Task_sleep (1000u);\r
1018 System_printf("\n!!! EDMA3 LLD HrtBt %x\n", counter);\r
1019 counter++;\r
1020 }\r
1021 }\r
1022 \r
1023 /*******************************************************************************\r
1024 ******************************************************************************/\r
1025 Void getMemoryStats(Void)\r
1026 {\r
1027 Memory_Stats memStats;\r
1028 \r
1029 Memory_getStats(drvHeap, &memStats);\r
1030 System_printf("\nHeap Usage/Status\n");\r
1031 System_printf(" tcp3dDrvHeap : %d of %d free\n", memStats.totalFreeSize, memStats.totalSize);\r
1032 \r
1033 Memory_getStats(dataHeap, &memStats);\r
1034 System_printf(" tcp3dDataHeap : %d of %d free\n", memStats.totalFreeSize, memStats.totalSize);\r
1035 }\r
1036 \r
1037 /*******************************************************************************\r
1038 ******************************************************************************/\r
1039 Void tcp3dEventISR(UInt32 testEvtNum)\r
1040 {\r
1041 tcp3dEventCntr++;\r
1042 tpccEvtCntr++;\r
1043 \r
1044 if ( sendBlockCnt >= codeBlockSet.maxNumCB )\r
1045 Semaphore_post(semSendWait);\r
1046 else\r
1047 Semaphore_post(semSendBlock);\r
1048 }\r
1049 \r
1050 /*******************************************************************************\r
1051 ******************************************************************************/\r
1052 Void registerTcp3dEvent(Void)\r
1053 {\r
1054 static UInt32 cookie = 0;\r
1055 Int eventId = 0; /* GEM event id */\r
1056 static UInt32 mapDone = 0;\r
1057 UInt32 testEvt = getNotifyEventNum(instNum);\r
1058 UInt32 hostIntr = getHostIntrNum(dspCoreID);\r
1059 \r
1060 /* Disabling the global interrupts */\r
1061 cookie = Hwi_disable();\r
1062 \r
1063 /* Completion ISR Registration */\r
1064 CpIntc_dispatchPlug(testEvt, tcp3dEventISR, hostIntr, TRUE);\r
1065 if (!mapDone)\r
1066 CpIntc_mapSysIntToHostInt(0, testEvt, hostIntr);\r
1067 CpIntc_enableHostInt(0, hostIntr);\r
1068 eventId = CpIntc_getEventId(hostIntr);\r
1069 EventCombiner_dispatchPlug (eventId,\r
1070 #if USE_LOCAL_CPINTC_DISPATCH\r
1071 CpIntc_dispatchLoc,\r
1072 #else\r
1073 CpIntc_dispatch,\r
1074 #endif\r
1075 hostIntr,\r
1076 TRUE);\r
1077 #if DEBUG_PRINT\r
1078 System_printf("\t\t testEvt : %d \n", testEvt);\r
1079 System_printf("\t\t hostIntr : %d \n", hostIntr);\r
1080 System_printf("\t\t eventId : %d \n", eventId);\r
1081 #endif\r
1082 \r
1083 /* enable the 'global' switch */\r
1084 CpIntc_enableAllHostInts(0);\r
1085 \r
1086 mapDone = 1;\r
1087 \r
1088 /* Restore interrupts */\r
1089 Hwi_restore(cookie);\r
1090 }\r
1091 \r
1092 /*******************************************************************************\r
1093 ******************************************************************************/\r
1094 Void unregisterTcp3dEvent(Void)\r
1095 {\r
1096 static UInt32 cookie = 0;\r
1097 Int eventId = 0; /* GEM event id */\r
1098 UInt32 hostIntr = getHostIntrNum(dspCoreID);\r
1099 \r
1100 /* Disabling the global interrupts */\r
1101 cookie = Hwi_disable();\r
1102 \r
1103 /* Driver Completion ISR */\r
1104 CpIntc_disableHostInt(0, hostIntr);\r
1105 eventId = CpIntc_getEventId(hostIntr);\r
1106 EventCombiner_disableEvent(eventId);\r
1107 \r
1108 /* Restore interrupts */\r
1109 Hwi_restore(cookie);\r
1110 }\r
1111 \r
1112 /*******************************************************************************\r
1113 ******************************************************************************/\r
1114 Void allInit(Void)\r
1115 {\r
1116 Tcp3d_Result tcp3dResult = TCP3D_DRV_NO_ERR;\r
1117 EDMA3_DRV_Result edmaResult = EDMA3_DRV_SOK;\r
1118 \r
1119 /* Initialize EDMA3 first */\r
1120 hEdma = NULL;\r
1121 tpccNum = 2;\r
1122 tpccRegionUsed = 3;\r
1123 hEdma = edma3init ( tpccNum,\r
1124 &edmaResult,\r
1125 dspCoreID,\r
1126 tpccRegionUsed);\r
1127 if (edmaResult != EDMA3_DRV_SOK)\r
1128 {\r
1129 System_printf("edma3init() FAILED, error code: %d\n", edmaResult);\r
1130 }\r
1131 else\r
1132 {\r
1133 System_printf("EDMA3 LLD Initialization complete (TPCC #%d, Region #%d)\n", tpccNum, tpccRegionUsed);\r
1134 }\r
1135 \r
1136 /* Allocate all EDMA channels required for TCP3D Driver */\r
1137 System_printf("EDMA3 Channels opening started...\n");\r
1138 \r
1139 /* Open channels for one instance */\r
1140 openEdmaChannels (hEdma, instNum, &edmaConfig[instNum]);\r
1141 \r
1142 /* Register call backs */\r
1143 EDMA3_DRV_registerTccCb(hEdma, edmaConfig[instNum].pingChRes[0].chNo, (EDMA3_RM_TccCallback)&revt0ChCallback, NULL);\r
1144 EDMA3_DRV_registerTccCb(hEdma, edmaConfig[instNum].pongChRes[0].chNo, (EDMA3_RM_TccCallback)&revt1ChCallback, NULL);\r
1145 \r
1146 #if EDMA_LOCAL_COMP_ISR // flag defined in sample.h file\r
1147 /* Fill call back details */\r
1148 edmaConfig[instNum].pingChRes[0].cbFunc = (EDMA3_RM_TccCallback)&revt0ChCallback;\r
1149 edmaConfig[instNum].pingChRes[0].cbData = NULL;\r
1150 edmaConfig[instNum].pongChRes[0].cbFunc = (EDMA3_RM_TccCallback)&revt1ChCallback;\r
1151 edmaConfig[instNum].pongChRes[0].cbData = NULL;\r
1152 \r
1153 /**\r
1154 * Update the information to use with local EDMA ISR \r
1155 * (NOTE: This function must be called after the channels are opened)\r
1156 */\r
1157 updateAllocatedTccsLoc(&edmaConfig[instNum]);\r
1158 #endif\r
1159 \r
1160 System_printf("EDMA3 Channels opening complete\n");\r
1161 \r
1162 System_printf("TCP3 Decoder Driver Initialization sequence started...\n");\r
1163 \r
1164 /* Initialize the TCP3D first */\r
1165 tcp3dDrvInst[instNum] = tcp3dSampleInit (drvHeap,\r
1166 instNum,\r
1167 testMaxCodeBlocks,\r
1168 codeBlockSet.mode,\r
1169 codeBlockSet.doubleBuffer,\r
1170 codeBlockSet.lteCrcSel,\r
1171 dspCoreID,\r
1172 hEdma,\r
1173 tpccRegionUsed,\r
1174 &edmaConfig[instNum],\r
1175 &tcp3dResult);\r
1176 \r
1177 System_printf("TCP3 Decoder Driver Initialization sequence complete\n");\r
1178 \r
1179 /* Register the Notification Event for TCP3D */\r
1180 registerTcp3dEvent();\r
1181 \r
1182 /* Set the global flags to default values */\r
1183 pingComplete = 0;\r
1184 pongComplete = 0;\r
1185 pauseIntr = 0;\r
1186 l2pIntr = 0;\r
1187 tcp3dEventCntr = 0;\r
1188 pauseIntFlag = 0;\r
1189 rcvStartFlag = 0;\r
1190 soldoutCntr = 0;\r
1191 afterIntrSoldout = 0;\r
1192 afterIntrPause = 0;\r
1193 pendPauseCntr = 0;\r
1194 }\r
1195 \r
1196 /*******************************************************************************\r
1197 ******************************************************************************/\r
1198 Void allDeInit(Void)\r
1199 {\r
1200 EDMA3_DRV_Result edmaResult = EDMA3_DRV_SOK;\r
1201 \r
1202 /* Un-register the Notification Event for TCP3D */\r
1203 unregisterTcp3dEvent();\r
1204 \r
1205 /* Close all EDMA channels allocated for the test */\r
1206 System_printf("EDMA3 Channels freeing started...\n");\r
1207 \r
1208 /* Register call backs */\r
1209 EDMA3_DRV_unregisterTccCb(hEdma, edmaConfig[instNum].pingChRes[0].chNo);\r
1210 EDMA3_DRV_unregisterTccCb(hEdma, edmaConfig[instNum].pingChRes[1].chNo);\r
1211 EDMA3_DRV_unregisterTccCb(hEdma, edmaConfig[instNum].pongChRes[0].chNo);\r
1212 EDMA3_DRV_unregisterTccCb(hEdma, edmaConfig[instNum].pongChRes[1].chNo);\r
1213 \r
1214 /* Close channels */\r
1215 closeEdmaChannels(hEdma, instNum, &edmaConfig[instNum]);\r
1216 \r
1217 System_printf("EDMA3 Channels freeing complete\n");\r
1218 \r
1219 /* Deinit for TCP3D driver */\r
1220 System_printf("TCP3 Decoder Driver De-Initialization sequence started...\n");\r
1221 \r
1222 tcp3dSampleDeinit(drvHeap, instNum, tcp3dDrvInst[instNum]);\r
1223 \r
1224 System_printf("TCP3 Decoder Driver De-Initialization sequence complete\n");\r
1225 \r
1226 /* De-init EDMA3 */\r
1227 edmaResult = edma3deinit(tpccNum, hEdma);\r
1228 if (edmaResult != EDMA3_DRV_SOK)\r
1229 {\r
1230 System_printf("edma3deinit() FAILED, error code: %d\n", edmaResult);\r
1231 }\r
1232 else\r
1233 {\r
1234 System_printf("EDMA3 LLD De-Initialization complete\n");\r
1235 }\r
1236 }\r
1237 \r
1238 #ifndef SIMULATOR_SUPPORT\r
1239 /**\r
1240 * @b Description\r
1241 * @n \r
1242 * This function enables the power/clock domains for the \r
1243 * specified power domain and module. \r
1244 *\r
1245 * @retval\r
1246 * 0 for enabling power domain, -1 for failure\r
1247 */\r
1248 static Int32 enable_ip_instance (UInt32 pwrDmnNum, UInt32 moduleNum)\r
1249 {\r
1250 /* Power domains are turned OFF by default for many IP blocks. It\r
1251 * needs to be turned on before doing any device\r
1252 * register access.\r
1253 */\r
1254 /* Set IP block Power domain to ON */ \r
1255 CSL_PSC_enablePowerDomain (pwrDmnNum);\r
1256 \r
1257 /* Enable the clocks too for the IP block */\r
1258 CSL_PSC_setModuleNextState (moduleNum, PSC_MODSTATE_ENABLE);\r
1259 \r
1260 /* Start the state transition */\r
1261 CSL_PSC_startStateTransition (pwrDmnNum);\r
1262 \r
1263 /* Wait until the state transition process is completed. */\r
1264 while (!CSL_PSC_isStateTransitionDone (pwrDmnNum));\r
1265 \r
1266 /* Return IP block PSC status */\r
1267 if ((CSL_PSC_getPowerDomainState(pwrDmnNum) == PSC_PDSTATE_ON) &&\r
1268 (CSL_PSC_getModuleState (moduleNum) == PSC_MODSTATE_ENABLE))\r
1269 {\r
1270 /* IP block ON. Ready for use */ \r
1271 return 0;\r
1272 }\r
1273 else\r
1274 {\r
1275 /* IP block power on failed. Return error */ \r
1276 return -1; \r
1277 }\r
1278 }\r
1279 #endif\r
1280 \r
1281 /**\r
1282 * @b Description\r
1283 * @n \r
1284 * This function enables the power/clock domains for TCP3D. \r
1285 *\r
1286 * @retval\r
1287 * Not Applicable.\r
1288 */\r
1289 static Int32 enable_tcp3d (void)\r
1290 {\r
1291 #ifndef SIMULATOR_SUPPORT\r
1292 Int32 result;\r
1293 UInt32 coreID = CSL_chipReadDNUM();\r
1294 \r
1295 /* TCP3D power domain is turned OFF by default.\r
1296 * It needs to be turned on before doing any TCP3D device register access.\r
1297 * This is not required for the simulator. \r
1298 */\r
1299 #if (CSL_TCP3D_PER_CNT > 1)\r
1300 \r
1301 if (coreID == 0)\r
1302 {\r
1303 result = enable_ip_instance (TEST_CSL_PSC_PD_TCP3D_0, \r
1304 TEST_CSL_PSC_LPSC_TCP3D_0);\r
1305 }\r
1306 else \r
1307 {\r
1308 result = enable_ip_instance (TEST_CSL_PSC_PD_TCP3D_1, \r
1309 TEST_CSL_PSC_LPSC_TCP3D_1);\r
1310 } \r
1311 #else\r
1312 \r
1313 result = enable_ip_instance (TEST_CSL_PSC_PD_TCP3D_0, \r
1314 TEST_CSL_PSC_LPSC_TCP3D_0);\r
1315 \r
1316 #endif /* CSL_TCP3D_PER_CNT > 1 */\r
1317 \r
1318 return (result); \r
1319 #else\r
1320 /* PSC is not supported on simulator. Return success always */\r
1321 return 0;\r
1322 #endif\r
1323 }\r
1324 \r
1325 /**\r
1326 * @b Description\r
1327 * @n \r
1328 * The function is used to indicate that a block of memory is \r
1329 * about to be accessed. If the memory block is cached then this \r
1330 * indicates that the application would need to ensure that the \r
1331 * cache is updated with the data from the actual memory.\r
1332 *\r
1333 * @param[in] ptr\r
1334 * Address of memory block\r
1335 *\r
1336 * @param[in] size\r
1337 * Size of memory block\r
1338 *\r
1339 * @retval\r
1340 * Not Applicable\r
1341 */\r
1342 void tcp3dBeginMemAccess (void *ptr, uint32_t size)\r
1343 {\r
1344 /* Invalidate L1D cache and wait until operation is complete. \r
1345 * Use this approach if L2 cache is not enabled */ \r
1346 CACHE_invL1d (ptr, size, CACHE_FENCE_WAIT);\r
1347 \r
1348 /* Cleanup the prefectch buffer also. */\r
1349 CSL_XMC_invalidatePrefetchBuffer(); \r
1350 \r
1351 return;\r
1352 }\r
1353 \r
1354 /**\r
1355 * @b Description\r
1356 * @n \r
1357 * The function is used to indicate that the block of memory has \r
1358 * finished being accessed. If the memory block is cached then the \r
1359 * application would need to ensure that the contents of the cache \r
1360 * are updated immediately to the actual memory. \r
1361 *\r
1362 * @param[in] ptr\r
1363 * Address of memory block\r
1364 * @param[in] size\r
1365 * Size of memory block\r
1366 *\r
1367 * @retval\r
1368 * Not Applicable\r
1369 */\r
1370 void tcp3dEndMemAccess (void *ptr, uint32_t size)\r
1371 {\r
1372 /* Writeback L1D cache and wait until operation is complete. \r
1373 * Use this approach if L2 cache is not enabled */ \r
1374 CACHE_wbL1d (ptr, size, CACHE_FENCE_WAIT); \r
1375 \r
1376 return;\r
1377 }\r
1378 \r
1379 /* end of file */\r