125#if defined(__rtems__) || defined(MPC5200_BAPI_LIBC_HEADERS)
129#include "../dma_image.h"
131#include "../bestcomm_api.h"
132#include "tasksetup_bdtable.h"
134#include "bestcomm_api_mem.h"
135#include "bestcomm_cntrl.h"
137#ifndef DEBUG_BESTCOMM_API
138 #define DEBUG_BESTCOMM_API 0
144#define FLEX_T SZ_FLEX
149#define UINT8_T SZ_UINT8
154#define UINT16_T SZ_UINT16
159#define UINT32_T SZ_UINT32
161#if (INCR_TYPE_SRC==0)
166#if (INCR_TYPE_DST==0)
190 #define INCR_BYTES -4
194 #define INCR_BYTES -4
202#ifndef PRECISE_INCREMENT
203 #define PRECISE_INCREMENT 0
205#ifndef NO_ERROR_RESET
206 #define NO_ERROR_RESET 0
212 #define INTEGER_MODE 0
217#ifndef WRITE_LINE_BUFFER
218 #define WRITE_LINE_BUFFER 1
220#ifndef READ_LINE_BUFFER
221 #define READ_LINE_BUFFER 1
223#define SDMA_PRAGMA (0 <<SDMA_PRAGMA_BIT_RSV ) | \
224 (PRECISE_INCREMENT<<SDMA_PRAGMA_BIT_PRECISE_INC ) | \
225 (NO_ERROR_RESET <<SDMA_PRAGMA_BIT_RST_ERROR_NO) | \
226 (PACK_DATA <<SDMA_PRAGMA_BIT_PACK ) | \
227 (INTEGER_MODE <<SDMA_PRAGMA_BIT_INTEGER ) | \
228 (SPEC_READS <<SDMA_PRAGMA_BIT_SPECREAD ) | \
229 (WRITE_LINE_BUFFER<<SDMA_PRAGMA_BIT_CW ) | \
230 (READ_LINE_BUFFER <<SDMA_PRAGMA_BIT_RL )
232#ifndef TASKSETUP_NAME
233 #define PREPEND_TASKSETUP(name) TaskSetup_ ## name
234 #define FUNC_PREPEND_TASKSETUP(name) PREPEND_TASKSETUP(name)
235 #define TASKSETUP_NAME FUNC_PREPEND_TASKSETUP(TASK_BASE)
239 #define APPEND_API(name) name ## _api_t
240 #define FUNC_APPEND_API(name) APPEND_API(name)
241 #define TASK_API FUNC_APPEND_API(TASK_BASE)
244#ifndef INIT_DMA_IMAGE
245 #define PREPEND_INITDMA(name) init_dma_image_ ## name
246 #define FUNC_PREPEND_INITDMA(name) PREPEND_INITDMA(name)
247 #define INIT_DMA_IMAGE FUNC_PREPEND_INITDMA(TASK_BASE)
250#define DRD_INIT_MASK 0xfc1fffff
251#define DRD_EXT_FLAG 0x40000000
252#define DRD_INIT_OFFSET 21
254TaskId TASKSETUP_NAME(TASK_API *TaskAPI,
258#if ((MAX_BD>0)||(DEBUG_BESTCOMM_API>0))
261#if ((MAX_BD>0)&&((INCR_TYPE_SRC!=0)||(INCR_TYPE_DST!=0))||(DEBUG_BESTCOMM_API>0))
264#if (INITIATOR_DATA<0)
268 INIT_DMA_IMAGE((uint8 *)(((
sdma_regs *)(SDMA_TASK_BAR))->taskBar), MBarPhysOffsetGlobal);
270 TaskNum = (TaskId)SDMA_TASKNUM_EXT(TaskAPI->TaskNum);
272 TaskRunning[TaskNum] = 0;
274#if (DEBUG_BESTCOMM_API>0)
275 printf(
"\nBestComm API Debug Display Mode Enabled\n\n");
276 printf(
"TaskSetup: TaskID=%d\n", TaskNum);
278 printf(
"TaskSetup: Rx task\n");
280 printf(
"TaskSetup: Tx or DP task\n");
285 *(TaskAPI->TaskPragma)= (uint8) SDMA_PRAGMA;
289 #if (INCR_TYPE_SRC!=0)
292 #if (INCR_TYPE_DST!=0)
296 #if (DEBUG_BESTCOMM_API>0)
297 printf(
"TaskSetup: Using %d buffer descriptors, each with %d data pointers\n", MAX_BD, NumPtr);
303 TaskSetup_BDTable(TaskAPI->BDTableBase,
304 TaskAPI->BDTableLast,
305 TaskAPI->BDTableStart,
307 TaskSetupParams->
NumBD,
311 *TaskAPI->AddrEnable = (uint32)((uint32)(((uint16 *)SDMA_TCR)+TaskNum) + MBarPhysOffsetGlobal);
315 #if (DEBUG_BESTCOMM_API>0)
316 printf(
"TaskSetup: Buffer descriptor flags are enabled\n");
320 *((TaskAPI->AddrDRD)) = (uint32)((uint32)TaskAPI->DRD[TaskAPI->AddrDRDIdx] + MBarPhysOffsetGlobal);
327 #if (DEBUG_BESTCOMM_API>0)
328 printf(
"TaskSetup: Task will complete %d iterations before disabling\n");
331 *((TaskAPI->IterExtra)) = (uint32)(ITERATIONS-1);
335#if (AUTO_START <= -2 )
336 #if (DEBUG_BESTCOMM_API>0)
337 printf(
"TaskSetup: Auto task start disabled\n");
339 SDMA_TASK_CFG(SDMA_TCR, TaskNum, 0, TaskNum);
340#elif (AUTO_START <= -1 )
341 #if (DEBUG_BESTCOMM_API>0)
342 printf(
"TaskSetup: Auto start task\n");
344 SDMA_TASK_CFG(SDMA_TCR, TaskNum, 1, TaskNum);
345#elif (AUTO_START < MAX_TASKS)
346 #if (DEBUG_BESTCOMM_API>0)
347 printf(
"TaskSetup: Auto start task with TaskID=%d\n", AUTO_START);
349 SDMA_TASK_CFG(SDMA_TCR, TaskNum, 1, AUTO_START);
351 #if (DEBUG_BESTCOMM_API>0)
352 printf(
"TaskSetup: Auto task start disabled\n");
354 SDMA_TASK_CFG(SDMA_TCR, TaskNum, 0, TaskNum);
357#if (INITIATOR_DATA<0)
358 SDMA_SET_INIT(SDMA_TCR, TaskNum, TaskSetupParams->
Initiator);
365 for (i = 0; i < TaskAPI->NumDRD; i++) {
368#if (DEBUG_BESTCOMM_API>=10)
369 printf(
"TaskSetup: DRD[%d] initiator = %d\n", i, ((*(TaskAPI->DRD[i]) & ~DRD_INIT_MASK) >> DRD_INIT_OFFSET));
371 if (((*(TaskAPI->DRD[i]) & ~DRD_INIT_MASK) >> DRD_INIT_OFFSET) != INITIATOR_ALWAYS) {
372#if (DEBUG_BESTCOMM_API>=10)
373 printf(
"TaskSetup: Replacing DRD[%d] initiator with %d\n", i, TaskSetupParams->
Initiator);
375 *(TaskAPI->DRD[i]) = (*(TaskAPI->DRD[i]) & DRD_INIT_MASK)
376 | (TaskSetupParams->
Initiator << DRD_INIT_OFFSET);
379 if ((*(TaskAPI->DRD[i]) & DRD_EXT_FLAG) != 0)
386 if ((*(TaskAPI->DRD[i]) & DRD_EXT_FLAG) == 0)
394 TaskSetupParams->
Initiator = INITIATOR_DATA;
397#if (DEBUG_BESTCOMM_API>=10)
398 printf(
"\nTaskSetup: C-API Parameter Settings Passed to TaskSetup:\n");
399 printf(
"TaskSetup: NumBD = %d\n", TaskSetupParams->
NumBD);
401 printf(
"TaskSetup: MaxBuf = %d\n", TaskSetupParams->
Size.
MaxBuf);
403 printf(
"TaskSetup: NumBytes = %d\n", TaskSetupParams->
Size.
NumBytes);
405 printf(
"TaskSetup: Initiator = %d\n", TaskSetupParams->
Initiator);
406 printf(
"TaskSetup: StartAddrSrc = 0x%08X\n", TaskSetupParams->
StartAddrSrc);
407 printf(
"TaskSetup: IncrSrc = %d\n", TaskSetupParams->
IncrSrc);
408 printf(
"TaskSetup: SzSrc = %d\n", TaskSetupParams->
SzSrc);
409 printf(
"TaskSetup: StartAddrDst = 0x%08X\n", TaskSetupParams->
StartAddrDst);
410 printf(
"TaskSetup: IncrDst = %d\n", TaskSetupParams->
IncrDst);
411 printf(
"TaskSetup: SzDst = %d\n", TaskSetupParams->
SzDst);
414#if (DEBUG_BESTCOMM_API>=20)
415 printf(
"\nTaskSetup: Task-API Parameter Settings Before TaskSetup Initialization:\n");
416 printf(
"TaskSetup: TaskNum = %d\n", (TaskAPI->TaskNum));
417 printf(
"TaskSetup: TaskPragma = 0x%02X\n", *((TaskAPI->TaskPragma)));
418 printf(
"TaskSetup: TCR = 0x%04x\n", SDMA_TASK_STATUS(SDMA_TCR, TaskNum));
421 printf(
"TaskSetup: BDTableBase = 0x%08X\n", *((TaskAPI->BDTableBase)));
422 printf(
"TaskSetup: BDTableLast = 0x%08X\n", *((TaskAPI->BDTableLast)));
423 printf(
"TaskSetup: BDTableStart = 0x%08X\n", *((TaskAPI->BDTableStart)));
424 printf(
"TaskSetup: AddrEnable = 0x%08X\n", *((TaskAPI->AddrEnable)));
425 #if (INCR_TYPE_SRC==0)
426 printf(
"TaskSetup: AddrSrcFIFO = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
428 #if (INCR_TYPE_DST==0)
429 printf(
"TaskSetup: AddrDstFIFO = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
432 printf(
"TaskSetup: AddrDRD = 0x%08X\n", *((TaskAPI->AddrDRD)));
433 printf(
"TaskSetup: AddrDRDIdx = %d\n", ((TaskAPI->AddrDRDIdx)));
436 printf(
"TaskSetup: IterExtra = %d\n", *((TaskAPI->IterExtra)));
437 #if (INCR_TYPE_SRC==0)
438 printf(
"TaskSetup: AddrSrcFIFO = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
440 printf(
"TaskSetup: StartAddrSrc = 0x%08X\n", *((TaskAPI->StartAddrSrc)));
442 #if (INCR_TYPE_DST==0)
443 printf(
"TaskSetup: AddrDstFIFO = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
445 printf(
"TaskSetup: StartAddrDst = 0x%08X\n", *((TaskAPI->StartAddrDst)));
448 #if (INCR_TYPE_SRC!=0)
449 printf(
"TaskSetup: IncrSrc = 0x%04X\n", *((TaskAPI->IncrSrc)));
450 #if (MISALIGNED | MISALIGNED_START)
451 printf(
"TaskSetup: IncrSrcMA = 0x%04X\n", *((TaskAPI->IncrSrcMA)));
454 #if (INCR_TYPE_DST!=0)
455 printf(
"TaskSetup: IncrDst = 0x%04X\n", *((TaskAPI->IncrDst)));
456 #if (MISALIGNED | MISALIGNED_START)
457 printf(
"TaskSetup: IncrDstMA = 0x%04X\n", *((TaskAPI->IncrDstMA)));
460 printf(
"TaskSetup: Bytes = %d\n", *((TaskAPI->Bytes)));
461 printf(
"TaskSetup: IncrBytes = %d\n", *((TaskAPI->IncrBytes)));
465 *((TaskAPI->Bytes)) = (uint32)TaskSetupParams->
Size.
MaxBuf;
468#if (TYPE_SRC!=FLEX_T)
469 TaskSetupParams->
SzSrc = TYPE_SRC;
472#if (INCR_TYPE_SRC==0)
473 TaskSetupParams->
IncrSrc = (sint16)0;
474 *((TaskAPI->AddrSrcFIFO)) = (uint32)TaskSetupParams->
StartAddrSrc;
477 #if (INCR_TYPE_SRC==1)
478 if (TaskSetupParams->
IncrSrc!=0) {
479 TaskSetupParams->
IncrSrc = (sint16)+TaskSetupParams->
SzSrc;
483 #elif (INCR_TYPE_SRC!=2)
484 TaskSetupParams->
IncrSrc = (sint16)INCR_SRC;
486 *((TaskAPI->IncrSrc)) = (sint16)TaskSetupParams->
IncrSrc;
490 TaskSetupParams->
StartAddrSrc = (uint32)TaskGetBDRing(TaskNum);
492 *((TaskAPI->StartAddrSrc)) = (uint32)TaskSetupParams->
StartAddrSrc;
495 #
if MISALIGNED | MISALIGNED_START
496 if (TaskSetupParams->
IncrSrc < 0) {
497 *((TaskAPI->IncrSrcMA)) = (sint16)-1;
498 }
else if (TaskSetupParams->
IncrSrc > 0) {
499 *((TaskAPI->IncrSrcMA)) = (sint16)+1;
501 *((TaskAPI->IncrSrcMA)) = (sint16)0;
507#if (TYPE_DST!=FLEX_T)
508 TaskSetupParams->
SzDst = TYPE_DST;
511#if (INCR_TYPE_DST==0)
512 TaskSetupParams->
IncrDst = (sint16)0;
513 *((TaskAPI->AddrDstFIFO)) = (uint32)TaskSetupParams->
StartAddrDst;
515 #if (INCR_TYPE_DST==1)
516 if (TaskSetupParams->
IncrDst!=0) {
517 TaskSetupParams->
IncrDst = (sint16)+TaskSetupParams->
SzDst;
521 #elif (INCR_TYPE_DST!=2)
522 TaskSetupParams->
IncrDst = (sint16)INCR_DST;
524 *((TaskAPI->IncrDst)) = (sint16)TaskSetupParams->
IncrDst;
528 TaskSetupParams->
StartAddrDst = (uint32)TaskGetBDRing(TaskNum);
530 *((TaskAPI->StartAddrDst)) = (uint32)TaskSetupParams->
StartAddrDst;
533 #
if MISALIGNED | MISALIGNED_START
534 if (TaskSetupParams->
IncrDst < 0) {
535 *((TaskAPI->IncrDstMA)) = (sint16)-1;
536 }
else if (TaskSetupParams->
IncrDst > 0) {
537 *((TaskAPI->IncrDstMA)) = (sint16)+1;
539 *((TaskAPI->IncrDstMA)) = (sint16)0;
545 SDMA_SET_SIZE(SDMA_TASK_SIZE, TaskNum, TaskSetupParams->
SzSrc, TaskSetupParams->
SzDst);
548 if (TaskSetupParams->
IncrSrc != 0) {
549 *((TaskAPI->IncrBytes)) = (sint16)-abs(TaskSetupParams->
IncrSrc);
550 }
else if (TaskSetupParams->
IncrDst != 0) {
551 *((TaskAPI->IncrBytes)) = (sint16)-abs(TaskSetupParams->
IncrDst);
553 *((TaskAPI->IncrBytes)) = (sint16)-abs(INCR_BYTES);
557#if (DEBUG_BESTCOMM_API>=10)
558 printf(
"\nTaskSetup: C-API Parameter Settings Returned from TaskSetup:\n");
559 printf(
"TaskSetup: NumBD = %d\n", TaskSetupParams->
NumBD);
561 printf(
"TaskSetup: MaxBuf = %d\n", TaskSetupParams->
Size.
MaxBuf);
563 printf(
"TaskSetup: NumBytes = %d\n", TaskSetupParams->
Size.
NumBytes);
565 printf(
"TaskSetup: Initiator = %d\n", TaskSetupParams->
Initiator);
566 printf(
"TaskSetup: StartAddrSrc = 0x%08X\n", TaskSetupParams->
StartAddrSrc);
567 printf(
"TaskSetup: IncrSrc = %d\n", TaskSetupParams->
IncrSrc);
568 printf(
"TaskSetup: SzSrc = %d\n", TaskSetupParams->
SzSrc);
569 printf(
"TaskSetup: StartAddrDst = 0x%08X\n", TaskSetupParams->
StartAddrDst);
570 printf(
"TaskSetup: IncrDst = %d\n", TaskSetupParams->
IncrDst);
571 printf(
"TaskSetup: SzDst = %d\n", TaskSetupParams->
SzDst);
574#if (DEBUG_BESTCOMM_API>=20)
575 printf(
"\nTaskSetup: Task-API Parameter Settings After TaskSetup Initialization:\n");
576 printf(
"TaskSetup: TaskNum = %d\n", ((TaskAPI->TaskNum)));
577 printf(
"TaskSetup: TaskPragma = 0x%02X\n", *((TaskAPI->TaskPragma)));
580 printf(
"TaskSetup: BDTableBase = 0x%08X\n", *((TaskAPI->BDTableBase)));
581 printf(
"TaskSetup: BDTableLast = 0x%08X\n", *((TaskAPI->BDTableLast)));
582 printf(
"TaskSetup: BDTableStart = 0x%08X\n", *((TaskAPI->BDTableStart)));
583 printf(
"TaskSetup: AddrEnable = 0x%08X\n", *((TaskAPI->AddrEnable)));
584 #if (INCR_TYPE_SRC==0)
585 printf(
"TaskSetup: AddrSrcFIFO = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
587 #if (INCR_TYPE_DST==0)
588 printf(
"TaskSetup: AddrDstFIFO = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
591 printf(
"TaskSetup: AddrDRD = 0x%08X\n", *((TaskAPI->AddrDRD)));
592 printf(
"TaskSetup: AddrDRDIdx = %d\n", ((TaskAPI->AddrDRDIdx)));
595 printf(
"TaskSetup: IterExtra = %d\n", *((TaskAPI->IterExtra)));
596 #if (INCR_TYPE_SRC==0)
597 printf(
"TaskSetup: AddrSrcFIFO = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
599 printf(
"TaskSetup: StartAddrSrc = 0x%08X\n", *((TaskAPI->StartAddrSrc)));
601 #if (INCR_TYPE_DST==0)
602 printf(
"TaskSetup: AddrDstFIFO = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
604 printf(
"TaskSetup: StartAddrDst = 0x%08X\n", *((TaskAPI->StartAddrDst)));
607 #if (INCR_TYPE_SRC!=0)
608 printf(
"TaskSetup: IncrSrc = 0x%04X\n", *((TaskAPI->IncrSrc)));
609 #if (MISALIGNED | MISALIGNED_START)
610 printf(
"TaskSetup: IncrSrcMA = 0x%04X\n", *((TaskAPI->IncrSrcMA)));
613 #if (INCR_TYPE_DST!=0)
614 printf(
"TaskSetup: IncrDst = 0x%04X\n", *((TaskAPI->IncrDst)));
615 #if (MISALIGNED | MISALIGNED_START)
616 printf(
"TaskSetup: IncrDstMA = 0x%04X\n", *((TaskAPI->IncrDstMA)));
619 printf(
"TaskSetup: Bytes = %d\n", *((TaskAPI->Bytes)));
620 printf(
"TaskSetup: IncrBytes = %d\n", *((TaskAPI->IncrBytes)));
Parameters for TaskSetup()
Definition: bestcomm_api.h:194
Sz_t SzDst
Definition: bestcomm_api.h:209
union TaskSetupParamSet_t::@583 Size
MPC5200Initiator_t Initiator
Definition: bestcomm_api.h:203
uint32 NumBytes
Definition: bestcomm_api.h:199
uint32 StartAddrSrc
Definition: bestcomm_api.h:204
Sz_t SzSrc
Definition: bestcomm_api.h:206
uint32 MaxBuf
Definition: bestcomm_api.h:198
uint32 StartAddrDst
Definition: bestcomm_api.h:207
sint16 IncrSrc
Definition: bestcomm_api.h:205
uint32 NumBD
Definition: bestcomm_api.h:195
sint16 IncrDst
Definition: bestcomm_api.h:208