1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <common.h>
26
27#include <MCD_dma.h>
28#include <MCD_tasksInit.h>
29#include <MCD_progCheck.h>
30
31
32
33dmaRegs *MCD_dmaBar;
34
35
36
37
38
39extern TaskTableEntry MCD_realTaskTableSrc[NCHANNELS];
40extern TaskTableEntry MCD_modelTaskTableSrc[NUMOFVARIANTS];
41
42
43
44
45
46volatile TaskTableEntry *MCD_taskTable;
47TaskTableEntry *MCD_modelTaskTable;
48
49
50
51
52
53
54static int MCD_chStatus[NCHANNELS] = {
55 MCD_NO_DMA, MCD_NO_DMA, MCD_NO_DMA, MCD_NO_DMA,
56 MCD_NO_DMA, MCD_NO_DMA, MCD_NO_DMA, MCD_NO_DMA,
57 MCD_NO_DMA, MCD_NO_DMA, MCD_NO_DMA, MCD_NO_DMA,
58 MCD_NO_DMA, MCD_NO_DMA, MCD_NO_DMA, MCD_NO_DMA
59};
60
61
62static void MCD_memcpy(int *dest, int *src, u32 size);
63static void MCD_resmActions(int channel);
64
65
66
67
68
69
70#ifdef MCD_INCLUDE_EU
71extern MCD_bufDesc MCD_singleBufDescs[NCHANNELS];
72#else
73MCD_bufDesc MCD_singleBufDescs[NCHANNELS];
74#endif
75MCD_bufDesc *MCD_relocBuffDesc;
76
77
78#define DBG_CTL_COMP1_TASK (0x00002000)
79#define DBG_CTL_ENABLE (DBG_CTL_AUTO_ARM | \
80 DBG_CTL_BREAK | \
81 DBG_CTL_INT_BREAK | \
82 DBG_CTL_COMP1_TASK)
83#define DBG_CTL_DISABLE (DBG_CTL_AUTO_ARM | \
84 DBG_CTL_INT_BREAK | \
85 DBG_CTL_COMP1_TASK)
86#define DBG_KILL_ALL_STAT (0xFFFFFFFF)
87
88
89#define CSAVE_OFFSET 10
90
91
92#define MCD_BYTE_SWAP_KILLER 0xFFF8888F
93#define MCD_NO_BYTE_SWAP_ATALL 0x00040000
94
95
96#define MAC 0
97#define LUAC 1
98#define CRC 2
99#define LURC 3
100
101
102#define TASK_CHAINNOEU 0
103#define TASK_SINGLENOEU 1
104#ifdef MCD_INCLUDE_EU
105#define TASK_CHAINEU 2
106#define TASK_SINGLEEU 3
107#define TASK_FECRX 4
108#define TASK_FECTX 5
109#else
110#define TASK_CHAINEU 0
111#define TASK_SINGLEEU 1
112#define TASK_FECRX 2
113#define TASK_FECTX 3
114#endif
115
116
117
118
119
120typedef struct MCD_remVariants_struct MCD_remVariant;
121struct MCD_remVariants_struct {
122 int remDestRsdIncr[NCHANNELS];
123 int remSrcRsdIncr[NCHANNELS];
124 s16 remDestIncr[NCHANNELS];
125 s16 remSrcIncr[NCHANNELS];
126 u32 remXferSize[NCHANNELS];
127};
128
129
130MCD_remVariant MCD_remVariants;
131
132
133
134
135
136
137
138
139
140
141
142
143
144extern u32 MCD_funcDescTab0[];
145
146int MCD_initDma(dmaRegs * dmaBarAddr, void *taskTableDest, u32 flags)
147{
148 int i;
149 TaskTableEntry *entryPtr;
150
151
152 MCD_dmaBar = dmaBarAddr;
153
154
155 if ((flags & MCD_RELOC_TASKS) != 0) {
156 int fixedSize;
157 u32 *fixedPtr;
158
159 int varTabsOffset, funcDescTabsOffset, contextSavesOffset;
160 int taskDescTabsOffset;
161 int taskTableSize, varTabsSize, funcDescTabsSize,
162 contextSavesSize;
163 int taskDescTabSize;
164
165 int i;
166
167
168 if (((u32) taskTableDest & 0x000001ff) != 0)
169 return (MCD_TABLE_UNALIGNED);
170
171
172 MCD_taskTable = taskTableDest;
173
174
175
176
177
178
179
180
181
182
183 taskTableSize = NCHANNELS * sizeof(TaskTableEntry);
184
185 varTabsOffset = taskTableSize + (u32) taskTableDest;
186 if ((varTabsOffset & (VAR_TAB_SIZE - 1)) != 0)
187 varTabsOffset =
188 (varTabsOffset + VAR_TAB_SIZE) & (~VAR_TAB_SIZE);
189
190 varTabsSize = NCHANNELS * VAR_TAB_SIZE;
191 funcDescTabsOffset = varTabsOffset + varTabsSize;
192
193 if ((funcDescTabsOffset & (FUNCDESC_TAB_SIZE - 1)) != 0)
194 funcDescTabsOffset =
195 (funcDescTabsOffset +
196 FUNCDESC_TAB_SIZE) & (~FUNCDESC_TAB_SIZE);
197
198 funcDescTabsSize = FUNCDESC_TAB_NUM * FUNCDESC_TAB_SIZE;
199 contextSavesOffset = funcDescTabsOffset + funcDescTabsSize;
200 contextSavesSize = (NCHANNELS * CONTEXT_SAVE_SIZE);
201 fixedSize =
202 taskTableSize + varTabsSize + funcDescTabsSize +
203 contextSavesSize;
204
205
206 fixedPtr = (u32 *) taskTableDest;
207 for (i = 0; i < (fixedSize / 4); i++)
208 fixedPtr[i] = 0;
209
210 entryPtr = (TaskTableEntry *) MCD_taskTable;
211
212 for (i = 0; i < NCHANNELS; i++) {
213
214 entryPtr[i].varTab = (u32) varTabsOffset;
215 entryPtr[i].FDTandFlags =
216 (u32) funcDescTabsOffset | MCD_TT_FLAGS_DEF;
217 entryPtr[i].contextSaveSpace = (u32) contextSavesOffset;
218 varTabsOffset += VAR_TAB_SIZE;
219#ifdef MCD_INCLUDE_EU
220
221
222 funcDescTabsOffset += FUNCDESC_TAB_SIZE;
223#endif
224 contextSavesOffset += CONTEXT_SAVE_SIZE;
225 }
226
227 for (i = 0; i < FUNCDESC_TAB_NUM; i++) {
228 MCD_memcpy((void *)(entryPtr[i].
229 FDTandFlags & ~MCD_TT_FLAGS_MASK),
230 (void *)MCD_funcDescTab0, FUNCDESC_TAB_SIZE);
231 }
232
233
234
235 MCD_modelTaskTable = (TaskTableEntry *) contextSavesOffset;
236
237 MCD_memcpy((void *)MCD_modelTaskTable,
238 (void *)MCD_modelTaskTableSrc,
239 NUMOFVARIANTS * sizeof(TaskTableEntry));
240
241
242 entryPtr = MCD_modelTaskTable;
243 taskDescTabsOffset = (u32) MCD_modelTaskTable +
244 (NUMOFVARIANTS * sizeof(TaskTableEntry));
245
246
247
248 for (i = 0; i < NUMOFVARIANTS; i++) {
249 taskDescTabSize =
250 entryPtr[i].TDTend - entryPtr[i].TDTstart + 4;
251 MCD_memcpy((void *)taskDescTabsOffset,
252 (void *)entryPtr[i].TDTstart,
253 taskDescTabSize);
254 entryPtr[i].TDTstart = (u32) taskDescTabsOffset;
255 taskDescTabsOffset += taskDescTabSize;
256 entryPtr[i].TDTend = (u32) taskDescTabsOffset - 4;
257 }
258#ifdef MCD_INCLUDE_EU
259
260
261 MCD_relocBuffDesc =
262 (MCD_bufDesc *) (entryPtr[NUMOFVARIANTS - 1].TDTend + 4);
263#else
264
265
266 MCD_relocBuffDesc = MCD_singleBufDescs;
267#endif
268 } else {
269
270
271
272 if (((u32) MCD_realTaskTableSrc & 0x000001ff) != 0)
273 return (MCD_TABLE_UNALIGNED);
274
275
276
277
278
279 entryPtr = MCD_realTaskTableSrc;
280 for (i = 0; i < NCHANNELS; i++) {
281 if (((entryPtr[i].varTab & (VAR_TAB_SIZE - 1)) != 0) ||
282 ((entryPtr[i].
283 FDTandFlags & (FUNCDESC_TAB_SIZE - 1)) != 0))
284 return (MCD_TABLE_UNALIGNED);
285 }
286
287 MCD_taskTable = MCD_realTaskTableSrc;
288 MCD_modelTaskTable = MCD_modelTaskTableSrc;
289 MCD_relocBuffDesc = MCD_singleBufDescs;
290 }
291
292
293
294 MCD_dmaBar->taskbar = (u32) MCD_taskTable;
295 for (i = 0; i < NCHANNELS; i++) {
296 MCD_dmaBar->taskControl[i] = 0x0;
297 MCD_chStatus[i] = MCD_NO_DMA;
298 }
299
300
301
302 MCD_dmaBar->debugComp1 = 0;
303 MCD_dmaBar->debugComp2 = 0;
304 MCD_dmaBar->debugControl = DBG_CTL_DISABLE;
305 MCD_dmaBar->debugStatus = DBG_KILL_ALL_STAT;
306
307
308
309 if ((flags & MCD_COMM_PREFETCH_EN) != 0)
310 MCD_dmaBar->ptdControl &= ~PTD_CTL_COMM_PREFETCH;
311 else
312 MCD_dmaBar->ptdControl |= PTD_CTL_COMM_PREFETCH;
313
314 return (MCD_OK);
315}
316
317
318
319
320
321
322
323
324
325int MCD_dmaStatus(int channel)
326{
327 u16 tcrValue;
328
329 if ((channel < 0) || (channel >= NCHANNELS))
330 return (MCD_CHANNEL_INVALID);
331
332 tcrValue = MCD_dmaBar->taskControl[channel];
333 if ((tcrValue & TASK_CTL_EN) == 0) {
334
335 if (MCD_chStatus[channel] == MCD_RUNNING
336 || MCD_chStatus[channel] == MCD_IDLE)
337 MCD_chStatus[channel] = MCD_DONE;
338 } else {
339
340
341 if (MCD_chStatus[channel] == MCD_RUNNING
342 || MCD_chStatus[channel] == MCD_IDLE) {
343 MCD_dmaBar->ptdDebug = PTD_DBG_TSK_VLD_INIT;
344
345
346 if ((MCD_dmaBar->ptdDebug >> channel) & 0x1)
347 MCD_chStatus[channel] = MCD_RUNNING;
348 else
349 MCD_chStatus[channel] = MCD_IDLE;
350
351 }
352 }
353 return MCD_chStatus[channel];
354}
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376int MCD_startDma(int channel, s8 * srcAddr, s16 srcIncr, s8 * destAddr,
377 s16 destIncr, u32 dmaSize, u32 xferSize, u32 initiator,
378 int priority, u32 flags, u32 funcDesc
379#ifdef MCD_NEED_ADDR_TRANS
380 s8 * srcAddrVirt
381#endif
382 )
383{
384 int srcRsdIncr, destRsdIncr;
385 int *cSave;
386 short xferSizeIncr;
387 int tcrCount = 0;
388#ifdef MCD_INCLUDE_EU
389 u32 *realFuncArray;
390#endif
391
392 if ((channel < 0) || (channel >= NCHANNELS))
393 return (MCD_CHANNEL_INVALID);
394
395
396
397
398#ifndef MCD_INCLUDE_EU
399 funcDesc = MCD_FUNC_NOEU1;
400#endif
401
402#ifdef MCD_DEBUG
403 printf("startDma:Setting up params\n");
404#endif
405
406
407
408
409
410
411 MCD_dmaBar->ptdControl |= (u16) 0x8000;
412
413
414#if 1
415
416 srcRsdIncr = srcIncr < 0 ? -1 : (srcIncr > 0 ? 1 : 0);
417 destRsdIncr = destIncr < 0 ? -1 : (destIncr > 0 ? 1 : 0);
418
419 xferSizeIncr = (xferSize & 0xffff) | 0x20000000;
420
421
422 MCD_remVariants.remSrcRsdIncr[channel] = srcRsdIncr;
423 MCD_remVariants.remDestRsdIncr[channel] = destRsdIncr;
424 MCD_remVariants.remDestIncr[channel] = destIncr;
425 MCD_remVariants.remSrcIncr[channel] = srcIncr;
426 MCD_remVariants.remXferSize[channel] = xferSize;
427#endif
428
429 cSave =
430 (int *)(MCD_taskTable[channel].contextSaveSpace) + CSAVE_OFFSET +
431 CURRBD;
432
433#ifdef MCD_INCLUDE_EU
434
435 realFuncArray =
436 (u32 *) (MCD_taskTable[channel].FDTandFlags & 0xffffff00);
437
438
439 realFuncArray[(LURC * 16)] = xferSize == 4 ?
440 funcDesc : xferSize == 2 ?
441 funcDesc & 0xfffff00f : funcDesc & 0xffff000f;
442 realFuncArray[(LURC * 16 + 1)] =
443 (funcDesc & MCD_BYTE_SWAP_KILLER) | MCD_NO_BYTE_SWAP_ATALL;
444#endif
445
446
447
448
449
450 MCD_dmaBar->taskControl[channel] =
451 (initiator << 8) | TASK_CTL_HIPRITSKEN | TASK_CTL_HLDINITNUM;
452
453 while (((MCD_dmaBar->taskControl[channel] & 0x1fff) !=
454 ((initiator << 8) | TASK_CTL_HIPRITSKEN | TASK_CTL_HLDINITNUM))
455 && (tcrCount < 1000)) {
456 tcrCount++;
457
458 MCD_dmaBar->taskControl[channel] =
459 (initiator << 8) | TASK_CTL_HIPRITSKEN |
460 TASK_CTL_HLDINITNUM;
461 }
462
463 MCD_dmaBar->priority[channel] = (u8) priority & PRIORITY_PRI_MASK;
464
465
466 if (channel < 8 && channel >= 0) {
467 MCD_dmaBar->taskSize0 &= ~(0xf << (7 - channel) * 4);
468 MCD_dmaBar->taskSize0 |=
469 (xferSize & 3) << (((7 - channel) * 4) + 2);
470 MCD_dmaBar->taskSize0 |= (xferSize & 3) << ((7 - channel) * 4);
471 } else {
472 MCD_dmaBar->taskSize1 &= ~(0xf << (15 - channel) * 4);
473 MCD_dmaBar->taskSize1 |=
474 (xferSize & 3) << (((15 - channel) * 4) + 2);
475 MCD_dmaBar->taskSize1 |= (xferSize & 3) << ((15 - channel) * 4);
476 }
477
478
479
480 MCD_taskTable[channel].FDTandFlags &= ~MCD_TT_FLAGS_MASK;
481 MCD_taskTable[channel].FDTandFlags |= (MCD_TT_FLAGS_MASK & flags);
482
483 if (flags & MCD_FECTX_DMA) {
484
485 MCD_taskTable[channel].TDTstart =
486 MCD_modelTaskTable[TASK_FECTX].TDTstart;
487 MCD_taskTable[channel].TDTend =
488 MCD_modelTaskTable[TASK_FECTX].TDTend;
489 MCD_startDmaENetXmit((char *)srcAddr, (char *)srcAddr,
490 (char *)destAddr, MCD_taskTable,
491 channel);
492 } else if (flags & MCD_FECRX_DMA) {
493
494 MCD_taskTable[channel].TDTstart =
495 MCD_modelTaskTable[TASK_FECRX].TDTstart;
496 MCD_taskTable[channel].TDTend =
497 MCD_modelTaskTable[TASK_FECRX].TDTend;
498 MCD_startDmaENetRcv((char *)srcAddr, (char *)srcAddr,
499 (char *)destAddr, MCD_taskTable,
500 channel);
501 } else if (flags & MCD_SINGLE_DMA) {
502
503
504
505
506
507 MCD_relocBuffDesc[channel].srcAddr = srcAddr;
508 MCD_relocBuffDesc[channel].destAddr = destAddr;
509
510
511 MCD_relocBuffDesc[channel].lastDestAddr = destAddr;
512
513 MCD_relocBuffDesc[channel].dmaSize = dmaSize;
514 MCD_relocBuffDesc[channel].flags = 0;
515 MCD_relocBuffDesc[channel].csumResult = 0;
516 MCD_relocBuffDesc[channel].next = 0;
517
518
519
520 ((volatile int *)MCD_taskTable[channel].
521 contextSaveSpace)[SRCPTR + CSAVE_OFFSET] = (int)srcAddr;
522 ((volatile int *)MCD_taskTable[channel].
523 contextSaveSpace)[DESTPTR + CSAVE_OFFSET] = (int)destAddr;
524 ((volatile int *)MCD_taskTable[channel].
525 contextSaveSpace)[DCOUNT + CSAVE_OFFSET] = 0;
526 ((volatile int *)MCD_taskTable[channel].
527 contextSaveSpace)[CURRBD + CSAVE_OFFSET] =
528(u32) & (MCD_relocBuffDesc[channel]);
529
530
531 if (funcDesc == MCD_FUNC_NOEU1 || funcDesc == MCD_FUNC_NOEU2) {
532
533 MCD_taskTable[channel].TDTstart =
534 MCD_modelTaskTable[TASK_SINGLENOEU].TDTstart;
535 MCD_taskTable[channel].TDTend =
536 MCD_modelTaskTable[TASK_SINGLENOEU].TDTend;
537 MCD_startDmaSingleNoEu((char *)srcAddr, srcIncr,
538 (char *)destAddr, destIncr,
539 (int)dmaSize, xferSizeIncr,
540 flags, (int *)
541 &(MCD_relocBuffDesc[channel]),
542 cSave, MCD_taskTable, channel);
543 } else {
544
545 MCD_taskTable[channel].TDTstart =
546 MCD_modelTaskTable[TASK_SINGLEEU].TDTstart;
547 MCD_taskTable[channel].TDTend =
548 MCD_modelTaskTable[TASK_SINGLEEU].TDTend;
549 MCD_startDmaSingleEu((char *)srcAddr, srcIncr,
550 (char *)destAddr, destIncr,
551 (int)dmaSize, xferSizeIncr,
552 flags, (int *)
553 &(MCD_relocBuffDesc[channel]),
554 cSave, MCD_taskTable, channel);
555 }
556 } else {
557
558
559#if 1
560
561 ((volatile int *)MCD_taskTable[channel].
562 contextSaveSpace)[SRCPTR + CSAVE_OFFSET]
563 = (int)((MCD_bufDesc *) srcAddr)->srcAddr;
564 ((volatile int *)MCD_taskTable[channel].
565 contextSaveSpace)[DESTPTR + CSAVE_OFFSET]
566 = (int)((MCD_bufDesc *) srcAddr)->destAddr;
567#else
568
569
570 ((volatile int *)MCD_taskTable[channel].
571 contextSaveSpace)[SRCPTR + CSAVE_OFFSET]
572 = (int)((MCD_bufDesc *) srcAddrVirt)->srcAddr;
573 ((volatile int *)MCD_taskTable[channel].
574 contextSaveSpace)[DESTPTR + CSAVE_OFFSET]
575 = (int)((MCD_bufDesc *) srcAddrVirt)->destAddr;
576#endif
577 ((volatile int *)MCD_taskTable[channel].
578 contextSaveSpace)[DCOUNT + CSAVE_OFFSET] = 0;
579 ((volatile int *)MCD_taskTable[channel].
580 contextSaveSpace)[CURRBD + CSAVE_OFFSET] = (u32) srcAddr;
581
582 if (funcDesc == MCD_FUNC_NOEU1 || funcDesc == MCD_FUNC_NOEU2) {
583
584 MCD_taskTable[channel].TDTstart =
585 MCD_modelTaskTable[TASK_CHAINNOEU].TDTstart;
586 MCD_taskTable[channel].TDTend =
587 MCD_modelTaskTable[TASK_CHAINNOEU].TDTend;
588 MCD_startDmaChainNoEu((int *)srcAddr, srcIncr,
589 destIncr, xferSize,
590 xferSizeIncr, cSave,
591 MCD_taskTable, channel);
592 } else {
593
594 MCD_taskTable[channel].TDTstart =
595 MCD_modelTaskTable[TASK_CHAINEU].TDTstart;
596 MCD_taskTable[channel].TDTend =
597 MCD_modelTaskTable[TASK_CHAINEU].TDTend;
598 MCD_startDmaChainEu((int *)srcAddr, srcIncr, destIncr,
599 xferSize, xferSizeIncr, cSave,
600 MCD_taskTable, channel);
601 }
602 }
603 MCD_chStatus[channel] = MCD_IDLE;
604 return (MCD_OK);
605}
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637#define STABTIME 0
638
639int MCD_XferProgrQuery(int channel, MCD_XferProg * progRep)
640{
641 MCD_XferProg prevRep;
642 int again;
643
644 int i;
645 int destDiffBytes;
646
647 int numIterations;
648 int bytesNotXfered;
649 s8 *LWAlignedInitDestAddr, *LWAlignedCurrDestAddr;
650 int subModVal, addModVal;
651
652
653 if ((channel < 0) || (channel >= NCHANNELS))
654 return (MCD_CHANNEL_INVALID);
655
656
657 prevRep.lastSrcAddr =
658 (s8 *) ((volatile int *)MCD_taskTable[channel].
659 contextSaveSpace)[SRCPTR + CSAVE_OFFSET];
660 prevRep.lastDestAddr =
661 (s8 *) ((volatile int *)MCD_taskTable[channel].
662 contextSaveSpace)[DESTPTR + CSAVE_OFFSET];
663 prevRep.dmaSize =
664 ((volatile int *)MCD_taskTable[channel].contextSaveSpace)[DCOUNT +
665 CSAVE_OFFSET];
666 prevRep.currBufDesc =
667 (MCD_bufDesc *) ((volatile int *)MCD_taskTable[channel].
668 contextSaveSpace)[CURRBD + CSAVE_OFFSET];
669
670 do {
671
672 for (i = 0; i < STABTIME; i++) {
673
674
675 i += i >> 2;
676 }
677
678 progRep->lastSrcAddr =
679 (s8 *) ((volatile int *)MCD_taskTable[channel].
680 contextSaveSpace)[SRCPTR + CSAVE_OFFSET];
681 progRep->lastDestAddr =
682 (s8 *) ((volatile int *)MCD_taskTable[channel].
683 contextSaveSpace)[DESTPTR + CSAVE_OFFSET];
684 progRep->dmaSize =
685 ((volatile int *)MCD_taskTable[channel].
686 contextSaveSpace)[DCOUNT + CSAVE_OFFSET];
687 progRep->currBufDesc =
688 (MCD_bufDesc *) ((volatile int *)MCD_taskTable[channel].
689 contextSaveSpace)[CURRBD + CSAVE_OFFSET];
690
691 if (prevRep.lastSrcAddr != progRep->lastSrcAddr
692 || prevRep.lastDestAddr != progRep->lastDestAddr
693 || prevRep.dmaSize != progRep->dmaSize
694 || prevRep.currBufDesc != progRep->currBufDesc) {
695
696
697 prevRep.lastSrcAddr = progRep->lastSrcAddr;
698 prevRep.lastDestAddr = progRep->lastDestAddr;
699 prevRep.dmaSize = progRep->dmaSize;
700 prevRep.currBufDesc = progRep->currBufDesc;
701 again = MCD_TRUE;
702 } else
703 again = MCD_FALSE;
704 } while (again == MCD_TRUE);
705
706
707
708
709 switch (MCD_remVariants.remDestRsdIncr[channel]) {
710 case MINUS1:
711 subModVal =
712 ((int)progRep->
713 lastDestAddr) & ((MCD_remVariants.remXferSize[channel]) -
714 1);
715 addModVal =
716 ((int)progRep->currBufDesc->
717 destAddr) & ((MCD_remVariants.remXferSize[channel]) - 1);
718 LWAlignedInitDestAddr =
719 (progRep->currBufDesc->destAddr) - addModVal;
720 LWAlignedCurrDestAddr = (progRep->lastDestAddr) - subModVal;
721 destDiffBytes = LWAlignedInitDestAddr - LWAlignedCurrDestAddr;
722 bytesNotXfered =
723 (destDiffBytes / MCD_remVariants.remDestIncr[channel]) *
724 (MCD_remVariants.remDestIncr[channel]
725 + MCD_remVariants.remXferSize[channel]);
726 progRep->dmaSize =
727 destDiffBytes - bytesNotXfered + addModVal - subModVal;
728 break;
729 case ZERO:
730 progRep->lastDestAddr = progRep->currBufDesc->destAddr;
731 break;
732 case PLUS1:
733
734
735 subModVal =
736 ((int)progRep->currBufDesc->
737 destAddr) & ((MCD_remVariants.remXferSize[channel]) - 1);
738
739 addModVal =
740 ((int)progRep->
741 lastDestAddr) & ((MCD_remVariants.remXferSize[channel]) -
742 1);
743 LWAlignedInitDestAddr =
744 (progRep->currBufDesc->destAddr) - subModVal;
745 LWAlignedCurrDestAddr = (progRep->lastDestAddr) - addModVal;
746 destDiffBytes = (progRep->lastDestAddr - LWAlignedInitDestAddr);
747 numIterations =
748 (LWAlignedCurrDestAddr -
749 LWAlignedInitDestAddr) /
750 MCD_remVariants.remDestIncr[channel];
751 bytesNotXfered =
752 numIterations * (MCD_remVariants.remDestIncr[channel]
753 - MCD_remVariants.remXferSize[channel]);
754 progRep->dmaSize = destDiffBytes - bytesNotXfered - subModVal;
755 break;
756 default:
757 break;
758 }
759
760
761 switch (MCD_remVariants.remSrcRsdIncr[channel]) {
762 case MINUS1:
763 progRep->lastSrcAddr =
764 progRep->currBufDesc->srcAddr +
765 (MCD_remVariants.remSrcIncr[channel] *
766 (progRep->dmaSize / MCD_remVariants.remXferSize[channel]));
767 break;
768 case ZERO:
769 progRep->lastSrcAddr = progRep->currBufDesc->srcAddr;
770 break;
771 case PLUS1:
772 progRep->lastSrcAddr =
773 progRep->currBufDesc->srcAddr +
774 (MCD_remVariants.remSrcIncr[channel] *
775 (progRep->dmaSize / MCD_remVariants.remXferSize[channel]));
776 break;
777 default:
778 break;
779 }
780
781 return (MCD_OK);
782}
783
784
785
786
787
788
789
790
791
792
793static void MCD_resmActions(int channel)
794{
795 MCD_dmaBar->debugControl = DBG_CTL_DISABLE;
796 MCD_dmaBar->debugStatus = MCD_dmaBar->debugStatus;
797
798
799 MCD_dmaBar->ptdDebug = PTD_DBG_TSK_VLD_INIT;
800
801 if ((MCD_dmaBar->ptdDebug >> channel) & 0x1)
802 MCD_chStatus[channel] = MCD_RUNNING;
803 else
804 MCD_chStatus[channel] = MCD_IDLE;
805}
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821int MCD_killDma(int channel)
822{
823
824
825 if ((channel < 0) || (channel >= NCHANNELS))
826 return (MCD_CHANNEL_INVALID);
827
828 MCD_dmaBar->taskControl[channel] = 0x0;
829 MCD_resumeDma(channel);
830
831
832
833
834
835
836 MCD_chStatus[channel] = MCD_HALTED;
837
838
839
840
841
842
843
844 return (MCD_OK);
845}
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860int MCD_continDma(int channel)
861{
862 if ((channel < 0) || (channel >= NCHANNELS))
863 return (MCD_CHANNEL_INVALID);
864
865 MCD_dmaBar->taskControl[channel] |= TASK_CTL_EN;
866 MCD_chStatus[channel] = MCD_RUNNING;
867
868 return (MCD_OK);
869}
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912int MCD_pauseDma(int channel)
913{
914
915
916 if ((channel < 0) || (channel >= NCHANNELS))
917 return (MCD_CHANNEL_INVALID);
918
919 if (MCD_dmaBar->taskControl[channel] & TASK_CTL_EN) {
920 MCD_dmaBar->debugComp1 = channel;
921 MCD_dmaBar->debugControl =
922 DBG_CTL_ENABLE | (1 << (channel + 16));
923 MCD_chStatus[channel] = MCD_PAUSED;
924
925
926
927
928
929
930
931 }
932 return (MCD_OK);
933}
934
935
936
937
938
939
940
941
942
943
944int MCD_resumeDma(int channel)
945{
946 if ((channel < 0) || (channel >= NCHANNELS))
947 return (MCD_CHANNEL_INVALID);
948
949 if (MCD_dmaBar->taskControl[channel] & TASK_CTL_EN)
950 MCD_resmActions(channel);
951
952 return (MCD_OK);
953}
954
955
956
957
958
959
960
961
962
963
964
965
966
967int MCD_csumQuery(int channel, u32 * csum)
968{
969#ifdef MCD_INCLUDE_EU
970 if ((channel < 0) || (channel >= NCHANNELS))
971 return (MCD_CHANNEL_INVALID);
972
973 *csum = MCD_relocBuffDesc[channel].csumResult;
974 return (MCD_OK);
975#else
976 return (MCD_ERROR);
977#endif
978}
979
980
981
982
983
984
985
986
987int MCD_getCodeSize(void)
988{
989#ifdef MCD_INCLUDE_EU
990 return (0x2b5c);
991#else
992 return (0x173c);
993#endif
994}
995
996
997
998
999
1000
1001
1002
1003
1004
1005char MCD_versionString[] = "Multi-channel DMA API Alpha v0.3 (2004-04-26)";
1006#define MCD_REV_MAJOR 0x00
1007#define MCD_REV_MINOR 0x03
1008
1009int MCD_getVersion(char **longVersion)
1010{
1011 *longVersion = MCD_versionString;
1012 return ((MCD_REV_MAJOR << 8) | MCD_REV_MINOR);
1013}
1014
1015
1016
1017
1018
1019
1020
1021static void MCD_memcpy(int *dest, int *src, u32 size)
1022{
1023 u32 i;
1024
1025 for (i = 0; i < size; i += sizeof(int), dest++, src++)
1026 *dest = *src;
1027}
1028