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