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