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