Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:52

0001 /******************************************************************************
0002 *
0003 * Copyright (c) 2004 Freescale Semiconductor, Inc.
0004 *
0005 * Permission is hereby granted, free of charge, to any person obtaining a
0006 * copy of this software and associated documentation files (the "Software"),
0007 * to deal in the Software without restriction, including without limitation
0008 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0009 * and/or sell copies of the Software, and to permit persons to whom the
0010 * Software is furnished to do so, subject to the following conditions:
0011 *
0012 * The above copyright notice and this permission notice shall be included
0013 * in all copies or substantial portions of the Software.
0014 *
0015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
0018 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
0019 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0020 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0021 * OTHER DEALINGS IN THE SOFTWARE.
0022 *
0023 ******************************************************************************/
0024 
0025 /*
0026  * Task builder generates a set #defines per configured task to
0027  * condition this templete file.
0028  */
0029 
0030 /**********************************************************
0031  *
0032  * Required #defines:
0033  * ------------------
0034  * TASKSETUP_NAME:
0035  *   TaskSetup function name, set to TaskSetup_<TASK_NAME>
0036  * TASK_API:
0037  *   task API defined in dma_image.h
0038  * MAX_BD:
0039  *   <=0 : non-BD task
0040  *   else: number of BD in BD table
0041  * BD_FLAG:
0042  *   0   : no flag implemented for BD
0043  *   else: flags can be passed on a per BD basis
0044  * MISALIGNED:
0045  *   0   : task API supports Bytes%IncrBytes==0
0046  *   else: task API supports any parameter settings
0047  * AUTO_START:
0048  *   <-1       : do not start a task after task completion
0049  *   -1        : auto start the task after task completion
0050  *   <MAX_TASKS: auto start task with the TaskID = AUTO_START
0051  *    else     : do not start a task after task completion
0052  * INITIATOR_DATA:
0053  *   <0  : runtime configurable
0054  *   else: assume INITATOR_DATA equal hard-coded task initiator
0055  * TYPE_SRC: (needs to be consistent with Task API)
0056  *   FLEX_T  : Task API TYPE_SRC = flex, SzSrc defines size
0057  *   UINT8_T : Task API TYPE_SRC = char
0058  *   UINT16_T: Task API TASK_SRC = short
0059  *   UINT32_T: Task API TASK_SRC = int
0060  * INCR_TYPE_SRC:
0061  *   0   : FIFO address, do not implement data pointer
0062  *   1   : automatic, set INCR_SRC based on SzSrc parameter
0063  *   2   : runtime, set INCR_SRC to IncrSrc parameter
0064  *   else: used hard-coded INCR_SRC
0065  * INCR_SRC:
0066  *   INCR_TYPE_SRC=0: force INCR_SRC=0
0067  *   else           : use for src pointer increment
0068  * TYPE_DST: (needs to be consistent with Task API)
0069  *   FLEX_T  : Task API TYPE_DST = flex, SzDst defines size
0070  *   UINT8_T : Task API TYPE_DST = char
0071  *   UINT16_T: Task API TASK_DST = short
0072  *   UINT32_T: Task API TASK_DST = int
0073  * INCR_TYPE_DST:
0074  *   0   : FIFO address, do not implement data pointer
0075  *   1   : automatic, set INCR_DST based on SzDst parameter
0076  *   2   : runtime, set INCR_DST to IncrDst parameter
0077  *   else: used hard-coded INCR_DST
0078  * INCR_DST:
0079  *   INCR_TYPE_DST=0: force INCR_DST=0
0080  *   else           : use for dst pointer increment
0081  * PRECISE_INCREMENT:
0082  *   0   : increment when possible
0083  *   else: increment at end of iteration
0084  * NO_ERROR_RESET:
0085  *   0   : reset error flags on task enable
0086  *   else: leave error flags unmodified on task enable
0087  * PACK_DATA:
0088  *   0   : do not pack data
0089  *   else: pack data based on data type
0090  * INTEGER_MODE:
0091  *   0   : type conversions handle as fixed point numbers
0092  *   else: type conversions handle as integers
0093  * WRITE_LINE_BUFFER:
0094  *   0   : do not use write line buffers
0095  *   else: enable write line buffers
0096  * READ_LINE_BUFFER:
0097  *   0   : do not use read line buffers
0098  *   else: enable read line buffers
0099  * SPEC_READS:
0100  *   0   : do not speculatively read
0101  *   else: speculatively read data ahead of DMA engine
0102  *
0103  * Optional #defines:
0104  * ------------------
0105  * MAX_TASKS:
0106  *   1   : #define MAX_TASKS>0
0107  *   else: 16
0108  * ITERATIONS:
0109  *   1   : #define ITERATIONS>0
0110  *   else: 1
0111  * INCR_BYTES:
0112  *   This macro is defined based on following priority:
0113  *   1   : INCR_SRC != 0
0114  *   2   : DST_TYPE != 0
0115  *   3   : #defined INCR_BYTES<0
0116  *   else: -4 (SZ_UINT32)
0117  * DEBUG_BESTCOMM_API:
0118  *   >0  : print basic debug messages
0119  *   >=10: also print C-API interface variables
0120  *   >=20: also print task API interface variables
0121  *   else: do nothing
0122  *
0123  **********************************************************/
0124 
0125 #if defined(__rtems__) || defined(MPC5200_BAPI_LIBC_HEADERS)
0126 #include <stdlib.h>
0127 #endif
0128 
0129 #include "../dma_image.h"
0130 
0131 #include "../bestcomm_api.h"
0132 #include "tasksetup_bdtable.h"
0133 
0134 #include "bestcomm_api_mem.h"
0135 #include "bestcomm_cntrl.h"
0136 
0137 #ifndef  DEBUG_BESTCOMM_API
0138  #define DEBUG_BESTCOMM_API 0
0139 #endif
0140 
0141 #ifdef FLEX_T
0142  #undef FLEX_T
0143 #endif
0144 #define FLEX_T SZ_FLEX
0145 
0146 #ifdef UINT8_T
0147  #undef UINT8_T
0148 #endif
0149 #define UINT8_T SZ_UINT8
0150 
0151 #ifdef UINT16_T
0152  #undef UINT16_T
0153 #endif
0154 #define UINT16_T SZ_UINT16
0155 
0156 #ifdef UINT32_T
0157  #undef UINT32_T
0158 #endif
0159 #define UINT32_T SZ_UINT32
0160 
0161 #if (INCR_TYPE_SRC==0)   /* FIFO address, no data pointer */
0162  #undef  INCR_SRC
0163  #define INCR_SRC     0
0164 #endif
0165 
0166 #if (INCR_TYPE_DST==0)   /* FIFO address, no data pointer */
0167  #undef  INCR_DST
0168  #define INCR_DST     0
0169 #endif
0170 
0171 #ifndef  MAX_TASKS
0172  #define MAX_TASKS   16
0173 #else
0174  #if (MAX_TASKS<=0)
0175   #undef  MAX_TASKS
0176   #define MAX_TASKS  16
0177  #endif
0178 #endif
0179 
0180 #ifndef  ITERATIONS
0181  #define ITERATIONS   1
0182 #else
0183  #if (ITERATIONS<=0)
0184   #undef  ITERATIONS
0185   #define ITERATIONS  1
0186  #endif
0187 #endif
0188 
0189 #ifndef   INCR_BYTES
0190   #define INCR_BYTES -4
0191 #else
0192  #if (INCR_BYTES>=0)
0193   #undef  INCR_BYTES
0194   #define INCR_BYTES -4
0195  #endif
0196 #endif
0197 
0198 /*
0199  * These ifndefs will go away when support in task_capi wrappers
0200  * in the image directories
0201  */
0202 #ifndef  PRECISE_INCREMENT
0203  #define PRECISE_INCREMENT 0  /* bit=6 SAS->1, increment 0=when possible, 1=at the end of interation */
0204 #endif
0205 #ifndef  NO_ERROR_RESET
0206  #define NO_ERROR_RESET    0  /* bit=5 SAS->0, do not reset error codes on task enable               */
0207 #endif
0208 #ifndef  PACK_DATA
0209  #define PACK_DATA         0  /* bit=4 SAS->0, pack data enable                                      */
0210 #endif
0211 #ifndef  INTEGER_MODE
0212  #define INTEGER_MODE      0  /* bit=3 SAS->0, 0=fractional(msb aligned), 1=integer(lsb aligned)     */
0213 #endif
0214 #ifndef  SPEC_READS
0215  #define SPEC_READS        1  /* bit=2 SAS->0, XLB speculative read enable                           */
0216 #endif
0217 #ifndef  WRITE_LINE_BUFFER
0218  #define WRITE_LINE_BUFFER 1  /* bit=1 SAS->0, write line buffer enable                              */
0219 #endif
0220 #ifndef  READ_LINE_BUFFER
0221  #define READ_LINE_BUFFER  1  /* bit=0 SAS->0, read line buffer enable                               */
0222 #endif
0223 #define  SDMA_PRAGMA (0                <<SDMA_PRAGMA_BIT_RSV         ) | \
0224                      (PRECISE_INCREMENT<<SDMA_PRAGMA_BIT_PRECISE_INC ) | \
0225                      (NO_ERROR_RESET   <<SDMA_PRAGMA_BIT_RST_ERROR_NO) | \
0226                      (PACK_DATA        <<SDMA_PRAGMA_BIT_PACK        ) | \
0227                      (INTEGER_MODE     <<SDMA_PRAGMA_BIT_INTEGER     ) | \
0228                      (SPEC_READS       <<SDMA_PRAGMA_BIT_SPECREAD    ) | \
0229                      (WRITE_LINE_BUFFER<<SDMA_PRAGMA_BIT_CW          ) | \
0230                      (READ_LINE_BUFFER <<SDMA_PRAGMA_BIT_RL          )
0231 
0232 #ifndef  TASKSETUP_NAME
0233  #define PREPEND_TASKSETUP(name) TaskSetup_ ## name
0234  #define FUNC_PREPEND_TASKSETUP(name) PREPEND_TASKSETUP(name)
0235  #define TASKSETUP_NAME FUNC_PREPEND_TASKSETUP(TASK_BASE)
0236 #endif
0237 
0238 #ifndef  TASK_API
0239  #define APPEND_API(name) name ## _api_t
0240  #define FUNC_APPEND_API(name) APPEND_API(name)
0241  #define TASK_API FUNC_APPEND_API(TASK_BASE)
0242 #endif
0243 
0244 #ifndef  INIT_DMA_IMAGE
0245  #define PREPEND_INITDMA(name) init_dma_image_ ## name
0246  #define FUNC_PREPEND_INITDMA(name) PREPEND_INITDMA(name)
0247  #define INIT_DMA_IMAGE FUNC_PREPEND_INITDMA(TASK_BASE)
0248 #endif
0249 
0250 #define DRD_INIT_MASK   0xfc1fffff
0251 #define DRD_EXT_FLAG    0x40000000
0252 #define DRD_INIT_OFFSET 21
0253 
0254 TaskId TASKSETUP_NAME(TASK_API            *TaskAPI,
0255                       TaskSetupParamSet_t *TaskSetupParams)
0256 {
0257     TaskId TaskNum;
0258 #if ((MAX_BD>0)||(DEBUG_BESTCOMM_API>0))
0259     uint32 Status = 0;
0260 #endif
0261 #if ((MAX_BD>0)&&((INCR_TYPE_SRC!=0)||(INCR_TYPE_DST!=0))||(DEBUG_BESTCOMM_API>0))
0262     uint8  NumPtr = 0;
0263 #endif
0264 #if (INITIATOR_DATA<0)  /* runtime configurable */
0265     uint32 i, ext;
0266 #endif
0267 
0268     INIT_DMA_IMAGE((uint8 *)(((sdma_regs *)(SDMA_TASK_BAR))->taskBar), MBarPhysOffsetGlobal);
0269 
0270     TaskNum = (TaskId)SDMA_TASKNUM_EXT(TaskAPI->TaskNum);
0271 
0272     TaskRunning[TaskNum] = 0;
0273 
0274 #if (DEBUG_BESTCOMM_API>0)
0275     printf("\nBestComm API Debug Display Mode Enabled\n\n");
0276     printf("TaskSetup: TaskID=%d\n", TaskNum);
0277     if (Status!=0) {
0278         printf("TaskSetup: Rx task\n");
0279     } else {
0280         printf("TaskSetup: Tx or DP task\n");
0281     }
0282 #endif
0283 
0284     /* Set the task pragma settings */
0285     *(TaskAPI->TaskPragma)= (uint8) SDMA_PRAGMA;
0286 
0287 #if (MAX_BD>0)  /* Buffer Descriptors */
0288 
0289  #if (INCR_TYPE_SRC!=0)
0290     ++NumPtr;
0291  #endif
0292  #if (INCR_TYPE_DST!=0)
0293     ++NumPtr;
0294  #endif
0295 
0296  #if (DEBUG_BESTCOMM_API>0)
0297     printf("TaskSetup: Using %d buffer descriptors, each with %d data pointers\n", MAX_BD, NumPtr);
0298  #endif
0299 
0300     /* Allocate BD table SRAM storage,
0301      * and pass addresses to task API */
0302 
0303     TaskSetup_BDTable(TaskAPI->BDTableBase,
0304                       TaskAPI->BDTableLast,
0305                       TaskAPI->BDTableStart,
0306                       TaskNum,
0307                       TaskSetupParams->NumBD,
0308                       MAX_BD, NumPtr,
0309                       BD_FLAG, Status);
0310 
0311     *TaskAPI->AddrEnable = (uint32)((uint32)(((uint16 *)SDMA_TCR)+TaskNum) + MBarPhysOffsetGlobal);
0312 
0313  #if BD_FLAG
0314 
0315   #if (DEBUG_BESTCOMM_API>0)
0316     printf("TaskSetup: Buffer descriptor flags are enabled\n");
0317   #endif
0318 
0319     /* always assume 2nd to last DRD */
0320     *((TaskAPI->AddrDRD)) = (uint32)((uint32)TaskAPI->DRD[TaskAPI->AddrDRDIdx] + MBarPhysOffsetGlobal);
0321  #endif /* #if BD_FLAG */
0322 
0323 #else   /* No Buffer Descriptors */
0324 
0325 /* #error ATA should not be non-BD */
0326 
0327   #if (DEBUG_BESTCOMM_API>0)
0328     printf("TaskSetup: Task will complete %d iterations before disabling\n");
0329   #endif
0330 
0331     *((TaskAPI->IterExtra)) = (uint32)(ITERATIONS-1);
0332 #endif  /* #if (MAX_BD>0) */
0333 
0334 /* Setup auto start */
0335 #if (AUTO_START <= -2 ) /* do not start a task */
0336  #if (DEBUG_BESTCOMM_API>0)
0337     printf("TaskSetup: Auto task start disabled\n");
0338  #endif
0339     SDMA_TASK_CFG(SDMA_TCR, TaskNum, 0, TaskNum);
0340 #elif (AUTO_START <= -1 )   /* restart task */
0341  #if (DEBUG_BESTCOMM_API>0)
0342     printf("TaskSetup: Auto start task\n");
0343  #endif
0344     SDMA_TASK_CFG(SDMA_TCR, TaskNum, 1, TaskNum);
0345 #elif (AUTO_START < MAX_TASKS)  /* start specific task */
0346  #if (DEBUG_BESTCOMM_API>0)
0347     printf("TaskSetup: Auto start task with TaskID=%d\n", AUTO_START);
0348  #endif
0349     SDMA_TASK_CFG(SDMA_TCR, TaskNum, 1, AUTO_START);
0350 #else   /* do not start a task */
0351  #if (DEBUG_BESTCOMM_API>0)
0352     printf("TaskSetup: Auto task start disabled\n");
0353  #endif
0354     SDMA_TASK_CFG(SDMA_TCR, TaskNum, 0, TaskNum);
0355 #endif
0356 
0357 #if (INITIATOR_DATA<0)  /* runtime configurable */
0358     SDMA_SET_INIT(SDMA_TCR, TaskNum, TaskSetupParams->Initiator);
0359 
0360     /*
0361      * Hard-code the task initiator in the DRD to avoid a problem w/ the
0362      * hold initiator bit in the TCR.
0363      */
0364     ext = 0;
0365     for (i = 0; i < TaskAPI->NumDRD; i++) {
0366         if (ext == 0)
0367         {
0368 #if (DEBUG_BESTCOMM_API>=10)
0369                 printf("TaskSetup: DRD[%d] initiator = %d\n", i, ((*(TaskAPI->DRD[i]) & ~DRD_INIT_MASK) >> DRD_INIT_OFFSET));
0370 #endif
0371             if (((*(TaskAPI->DRD[i]) & ~DRD_INIT_MASK) >> DRD_INIT_OFFSET) != INITIATOR_ALWAYS) {
0372 #if (DEBUG_BESTCOMM_API>=10)
0373                 printf("TaskSetup: Replacing DRD[%d] initiator with %d\n", i, TaskSetupParams->Initiator);
0374 #endif
0375                 *(TaskAPI->DRD[i]) = (*(TaskAPI->DRD[i]) & DRD_INIT_MASK)
0376                             | (TaskSetupParams->Initiator << DRD_INIT_OFFSET);
0377             }
0378 
0379             if ((*(TaskAPI->DRD[i]) & DRD_EXT_FLAG) != 0)
0380             {
0381                 ext = 1;
0382             }
0383         }
0384         else
0385         {
0386             if ((*(TaskAPI->DRD[i]) & DRD_EXT_FLAG) == 0)
0387             {
0388                 ext = 0;
0389             }
0390         }
0391     }
0392 
0393 #else   /* INITIATOR_DATA >= 0 */
0394     TaskSetupParams->Initiator = INITIATOR_DATA;
0395 #endif
0396 
0397 #if (DEBUG_BESTCOMM_API>=10)
0398     printf("\nTaskSetup: C-API Parameter Settings Passed to TaskSetup:\n");
0399     printf("TaskSetup: NumBD        = %d\n", TaskSetupParams->NumBD);
0400  #if (MAX_BD>0)
0401     printf("TaskSetup: MaxBuf       = %d\n", TaskSetupParams->Size.MaxBuf);
0402  #else
0403     printf("TaskSetup: NumBytes     = %d\n", TaskSetupParams->Size.NumBytes);
0404  #endif
0405     printf("TaskSetup: Initiator    = %d\n", TaskSetupParams->Initiator);
0406     printf("TaskSetup: StartAddrSrc = 0x%08X\n", TaskSetupParams->StartAddrSrc);
0407     printf("TaskSetup: IncrSrc      = %d\n", TaskSetupParams->IncrSrc);
0408     printf("TaskSetup: SzSrc        = %d\n", TaskSetupParams->SzSrc);
0409     printf("TaskSetup: StartAddrDst = 0x%08X\n", TaskSetupParams->StartAddrDst);
0410     printf("TaskSetup: IncrDst      = %d\n", TaskSetupParams->IncrDst);
0411     printf("TaskSetup: SzDst        = %d\n", TaskSetupParams->SzDst);
0412 #endif
0413 
0414 #if (DEBUG_BESTCOMM_API>=20)
0415     printf("\nTaskSetup: Task-API Parameter Settings Before TaskSetup Initialization:\n");
0416     printf("TaskSetup: TaskNum      = %d\n", (TaskAPI->TaskNum));
0417     printf("TaskSetup: TaskPragma   = 0x%02X\n", *((TaskAPI->TaskPragma)));
0418     printf("TaskSetup: TCR          = 0x%04x\n", SDMA_TASK_STATUS(SDMA_TCR, TaskNum));
0419 
0420  #if (MAX_BD>0)
0421     printf("TaskSetup: BDTableBase  = 0x%08X\n", *((TaskAPI->BDTableBase)));
0422     printf("TaskSetup: BDTableLast  = 0x%08X\n", *((TaskAPI->BDTableLast)));
0423     printf("TaskSetup: BDTableStart = 0x%08X\n", *((TaskAPI->BDTableStart)));
0424     printf("TaskSetup: AddrEnable   = 0x%08X\n", *((TaskAPI->AddrEnable)));
0425   #if (INCR_TYPE_SRC==0)
0426     printf("TaskSetup: AddrSrcFIFO  = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
0427   #endif
0428   #if (INCR_TYPE_DST==0)
0429     printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
0430   #endif
0431   #if (BD_FLAG)
0432     printf("TaskSetup: AddrDRD      = 0x%08X\n", *((TaskAPI->AddrDRD)));
0433     printf("TaskSetup: AddrDRDIdx   = %d\n", ((TaskAPI->AddrDRDIdx)));
0434   #endif
0435  #else
0436     printf("TaskSetup: IterExtra    = %d\n", *((TaskAPI->IterExtra)));
0437   #if (INCR_TYPE_SRC==0)
0438     printf("TaskSetup: AddrSrcFIFO  = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
0439   #else
0440     printf("TaskSetup: StartAddrSrc = 0x%08X\n", *((TaskAPI->StartAddrSrc)));
0441   #endif
0442   #if (INCR_TYPE_DST==0)
0443     printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
0444   #else
0445     printf("TaskSetup: StartAddrDst = 0x%08X\n", *((TaskAPI->StartAddrDst)));
0446   #endif
0447  #endif
0448  #if (INCR_TYPE_SRC!=0)
0449     printf("TaskSetup: IncrSrc      = 0x%04X\n", *((TaskAPI->IncrSrc)));
0450   #if (MISALIGNED | MISALIGNED_START)
0451     printf("TaskSetup: IncrSrcMA    = 0x%04X\n", *((TaskAPI->IncrSrcMA)));
0452   #endif
0453  #endif
0454  #if (INCR_TYPE_DST!=0)
0455     printf("TaskSetup: IncrDst      = 0x%04X\n", *((TaskAPI->IncrDst)));
0456   #if (MISALIGNED | MISALIGNED_START)
0457     printf("TaskSetup: IncrDstMA    = 0x%04X\n", *((TaskAPI->IncrDstMA)));
0458   #endif
0459  #endif
0460     printf("TaskSetup: Bytes        = %d\n", *((TaskAPI->Bytes)));
0461     printf("TaskSetup: IncrBytes    = %d\n", *((TaskAPI->IncrBytes)));
0462 #endif
0463 
0464 
0465     *((TaskAPI->Bytes)) = (uint32)TaskSetupParams->Size.MaxBuf;
0466 
0467 
0468 #if (TYPE_SRC!=FLEX_T)  /* size fixed in task code */
0469     TaskSetupParams->SzSrc = TYPE_SRC;
0470 #endif
0471 
0472 #if (INCR_TYPE_SRC==0)  /* no data pointer */
0473     TaskSetupParams->IncrSrc = (sint16)0;
0474     *((TaskAPI->AddrSrcFIFO)) = (uint32)TaskSetupParams->StartAddrSrc;
0475 #else
0476 
0477  #if (INCR_TYPE_SRC==1) /* automatic */
0478     if (TaskSetupParams->IncrSrc!=0) {
0479         TaskSetupParams->IncrSrc = (sint16)+TaskSetupParams->SzSrc;
0480     } else {
0481         TaskSetupParams->IncrSrc = (sint16)+TaskSetupParams->IncrSrc;
0482     }
0483  #elif (INCR_TYPE_SRC!=2)   /* hard-coded */
0484     TaskSetupParams->IncrSrc = (sint16)INCR_SRC;
0485  #endif
0486  *((TaskAPI->IncrSrc)) = (sint16)TaskSetupParams->IncrSrc;
0487 
0488  #if (MAX_BD>0) /* pointer in BD Table */
0489     /* pass back address of first BD */
0490     TaskSetupParams->StartAddrSrc = (uint32)TaskGetBDRing(TaskNum);
0491  #else
0492     *((TaskAPI->StartAddrSrc)) = (uint32)TaskSetupParams->StartAddrSrc;
0493  #endif
0494 
0495  #if MISALIGNED | MISALIGNED_START
0496     if (TaskSetupParams->IncrSrc < 0) {
0497         *((TaskAPI->IncrSrcMA)) = (sint16)-1;
0498     } else if (TaskSetupParams->IncrSrc > 0) {
0499         *((TaskAPI->IncrSrcMA)) = (sint16)+1;
0500     } else {
0501         *((TaskAPI->IncrSrcMA)) = (sint16)0;
0502     }
0503  #endif
0504 #endif
0505 
0506 
0507 #if (TYPE_DST!=FLEX_T)  /* size fixed in task code */
0508     TaskSetupParams->SzDst = TYPE_DST;
0509 #endif
0510 
0511 #if (INCR_TYPE_DST==0)  /* no data pointer */
0512     TaskSetupParams->IncrDst = (sint16)0;
0513     *((TaskAPI->AddrDstFIFO)) = (uint32)TaskSetupParams->StartAddrDst;
0514 #else
0515  #if (INCR_TYPE_DST==1) /* automatic */
0516     if (TaskSetupParams->IncrDst!=0) {
0517         TaskSetupParams->IncrDst = (sint16)+TaskSetupParams->SzDst;
0518     } else {
0519         TaskSetupParams->IncrDst = (sint16)+TaskSetupParams->IncrDst;
0520     }
0521  #elif (INCR_TYPE_DST!=2)   /* hard-coded */
0522     TaskSetupParams->IncrDst = (sint16)INCR_DST;
0523  #endif
0524     *((TaskAPI->IncrDst)) = (sint16)TaskSetupParams->IncrDst;
0525 
0526  #if (MAX_BD>0)
0527     /* pass back address of first BD */
0528     TaskSetupParams->StartAddrDst = (uint32)TaskGetBDRing(TaskNum);
0529  #else
0530     *((TaskAPI->StartAddrDst)) = (uint32)TaskSetupParams->StartAddrDst;
0531  #endif
0532 
0533  #if MISALIGNED | MISALIGNED_START
0534     if (TaskSetupParams->IncrDst < 0) {
0535         *((TaskAPI->IncrDstMA)) = (sint16)-1;
0536     } else if (TaskSetupParams->IncrDst > 0) {
0537         *((TaskAPI->IncrDstMA)) = (sint16)+1;
0538     } else {
0539         *((TaskAPI->IncrDstMA)) = (sint16)0;
0540     }
0541  #endif
0542 #endif
0543 
0544 /* always use macro, only affect code with #define TYPE_? flex */
0545     SDMA_SET_SIZE(SDMA_TASK_SIZE, TaskNum, TaskSetupParams->SzSrc, TaskSetupParams->SzDst);
0546 
0547 
0548     if (TaskSetupParams->IncrSrc != 0) {
0549         *((TaskAPI->IncrBytes)) = (sint16)-abs(TaskSetupParams->IncrSrc);
0550     } else if (TaskSetupParams->IncrDst != 0) {
0551         *((TaskAPI->IncrBytes)) = (sint16)-abs(TaskSetupParams->IncrDst);
0552     } else {
0553         *((TaskAPI->IncrBytes)) = (sint16)-abs(INCR_BYTES);
0554     }
0555 
0556 
0557 #if (DEBUG_BESTCOMM_API>=10)
0558     printf("\nTaskSetup: C-API Parameter Settings Returned from TaskSetup:\n");
0559     printf("TaskSetup: NumBD        = %d\n", TaskSetupParams->NumBD);
0560  #if (MAX_BD>0)
0561     printf("TaskSetup: MaxBuf       = %d\n", TaskSetupParams->Size.MaxBuf);
0562  #else
0563     printf("TaskSetup: NumBytes     = %d\n", TaskSetupParams->Size.NumBytes);
0564  #endif
0565     printf("TaskSetup: Initiator    = %d\n", TaskSetupParams->Initiator);
0566     printf("TaskSetup: StartAddrSrc = 0x%08X\n", TaskSetupParams->StartAddrSrc);
0567     printf("TaskSetup: IncrSrc      = %d\n", TaskSetupParams->IncrSrc);
0568     printf("TaskSetup: SzSrc        = %d\n", TaskSetupParams->SzSrc);
0569     printf("TaskSetup: StartAddrDst = 0x%08X\n", TaskSetupParams->StartAddrDst);
0570     printf("TaskSetup: IncrDst      = %d\n", TaskSetupParams->IncrDst);
0571     printf("TaskSetup: SzDst        = %d\n", TaskSetupParams->SzDst);
0572 #endif
0573 
0574 #if (DEBUG_BESTCOMM_API>=20)
0575     printf("\nTaskSetup: Task-API Parameter Settings After TaskSetup Initialization:\n");
0576     printf("TaskSetup: TaskNum      = %d\n", ((TaskAPI->TaskNum)));
0577     printf("TaskSetup: TaskPragma   = 0x%02X\n", *((TaskAPI->TaskPragma)));
0578 
0579  #if (MAX_BD>0)
0580     printf("TaskSetup: BDTableBase  = 0x%08X\n", *((TaskAPI->BDTableBase)));
0581     printf("TaskSetup: BDTableLast  = 0x%08X\n", *((TaskAPI->BDTableLast)));
0582     printf("TaskSetup: BDTableStart = 0x%08X\n", *((TaskAPI->BDTableStart)));
0583     printf("TaskSetup: AddrEnable   = 0x%08X\n", *((TaskAPI->AddrEnable)));
0584   #if (INCR_TYPE_SRC==0)
0585     printf("TaskSetup: AddrSrcFIFO  = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
0586   #endif
0587   #if (INCR_TYPE_DST==0)
0588     printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
0589   #endif
0590   #if (BD_FLAG)
0591     printf("TaskSetup: AddrDRD      = 0x%08X\n", *((TaskAPI->AddrDRD)));
0592     printf("TaskSetup: AddrDRDIdx   = %d\n", ((TaskAPI->AddrDRDIdx)));
0593   #endif
0594  #else
0595     printf("TaskSetup: IterExtra    = %d\n", *((TaskAPI->IterExtra)));
0596   #if (INCR_TYPE_SRC==0)
0597     printf("TaskSetup: AddrSrcFIFO  = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
0598   #else
0599     printf("TaskSetup: StartAddrSrc = 0x%08X\n", *((TaskAPI->StartAddrSrc)));
0600   #endif
0601   #if (INCR_TYPE_DST==0)
0602     printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
0603   #else
0604     printf("TaskSetup: StartAddrDst = 0x%08X\n", *((TaskAPI->StartAddrDst)));
0605   #endif
0606  #endif
0607  #if (INCR_TYPE_SRC!=0)
0608     printf("TaskSetup: IncrSrc      = 0x%04X\n", *((TaskAPI->IncrSrc)));
0609   #if (MISALIGNED | MISALIGNED_START)
0610     printf("TaskSetup: IncrSrcMA    = 0x%04X\n", *((TaskAPI->IncrSrcMA)));
0611   #endif
0612  #endif
0613  #if (INCR_TYPE_DST!=0)
0614     printf("TaskSetup: IncrDst      = 0x%04X\n", *((TaskAPI->IncrDst)));
0615   #if (MISALIGNED | MISALIGNED_START)
0616     printf("TaskSetup: IncrDstMA    = 0x%04X\n", *((TaskAPI->IncrDstMA)));
0617   #endif
0618  #endif
0619     printf("TaskSetup: Bytes        = %d\n", *((TaskAPI->Bytes)));
0620     printf("TaskSetup: IncrBytes    = %d\n", *((TaskAPI->IncrBytes)));
0621 #endif
0622 
0623     return TaskNum;
0624 }