source: rtems/c/src/lib/libbsp/powerpc/gen5200/bestcomm/task_api/tasksetup_general.h @ d4b4664b

4.104.115
Last change on this file since d4b4664b was 6c45275a, checked in by Joel Sherrill <joel.sherrill@…>, on 09/03/08 at 16:36:27

2008-09-03 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, bestcomm/load_task.c, bestcomm/task_api/tasksetup_general.h: Eliminate requirement to build bestcomm as a relocatable lump. This should reduce the minimum footprint considerably.
  • Property mode set to 100644
File size: 20.0 KB
Line 
1/******************************************************************************
2*
3* Copyright (c) 2004 Freescale Semiconductor, Inc.
4*
5* Permission is hereby granted, free of charge, to any person obtaining a
6* copy of this software and associated documentation files (the "Software"),
7* to deal in the Software without restriction, including without limitation
8* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9* and/or sell copies of the Software, and to permit persons to whom the
10* Software is furnished to do so, subject to the following conditions:
11*
12* The above copyright notice and this permission notice shall be included
13* in all copies or substantial portions of the Software.
14*
15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21* OTHER DEALINGS IN THE SOFTWARE.
22*
23******************************************************************************/
24
25/*
26 * Task builder generates a set #defines per configured task to
27 * condition this templete file.
28 */
29
30/**********************************************************
31 *
32 * Required #defines:
33 * ------------------
34 * TASKSETUP_NAME:
35 *   TaskSetup function name, set to TaskSetup_<TASK_NAME>
36 * TASK_API:
37 *   task API defined in dma_image.h
38 * MAX_BD:
39 *   <=0 : non-BD task
40 *   else: number of BD in BD table
41 * BD_FLAG:
42 *   0   : no flag implemented for BD
43 *   else: flags can be passed on a per BD basis
44 * MISALIGNED:
45 *   0   : task API supports Bytes%IncrBytes==0
46 *   else: task API supports any parameter settings
47 * AUTO_START:
48 *   <-1       : do not start a task after task completion
49 *   -1        : auto start the task after task completion
50 *   <MAX_TASKS: auto start task with the TaskID = AUTO_START
51 *    else     : do not start a task after task completion
52 * INITIATOR_DATA:
53 *   <0  : runtime configurable
54 *   else: assume INITATOR_DATA equal hard-coded task initiator
55 * TYPE_SRC: (needs to be consistent with Task API)
56 *   FLEX_T  : Task API TYPE_SRC = flex, SzSrc defines size
57 *   UINT8_T : Task API TYPE_SRC = char
58 *   UINT16_T: Task API TASK_SRC = short
59 *   UINT32_T: Task API TASK_SRC = int
60 * INCR_TYPE_SRC:
61 *   0   : FIFO address, do not implement data pointer
62 *   1   : automatic, set INCR_SRC based on SzSrc parameter
63 *   2   : runtime, set INCR_SRC to IncrSrc parameter
64 *   else: used hard-coded INCR_SRC
65 * INCR_SRC:
66 *   INCR_TYPE_SRC=0: force INCR_SRC=0
67 *   else           : use for src pointer increment
68 * TYPE_DST: (needs to be consistent with Task API)
69 *   FLEX_T  : Task API TYPE_DST = flex, SzDst defines size
70 *   UINT8_T : Task API TYPE_DST = char
71 *   UINT16_T: Task API TASK_DST = short
72 *   UINT32_T: Task API TASK_DST = int
73 * INCR_TYPE_DST:
74 *   0   : FIFO address, do not implement data pointer
75 *   1   : automatic, set INCR_DST based on SzDst parameter
76 *   2   : runtime, set INCR_DST to IncrDst parameter
77 *   else: used hard-coded INCR_DST
78 * INCR_DST:
79 *   INCR_TYPE_DST=0: force INCR_DST=0
80 *   else           : use for dst pointer increment
81 * PRECISE_INCREMENT:
82 *   0   : increment when possible
83 *   else: increment at end of iteration
84 * NO_ERROR_RESET:
85 *   0   : reset error flags on task enable
86 *   else: leave error flags unmodified on task enable
87 * PACK_DATA:
88 *   0   : do not pack data
89 *   else: pack data based on data type
90 * INTEGER_MODE:
91 *   0   : type conversions handle as fixed point numbers
92 *   else: type conversions handle as integers
93 * WRITE_LINE_BUFFER:
94 *   0   : do not use write line buffers
95 *   else: enable write line buffers
96 * READ_LINE_BUFFER:
97 *   0   : do not use read line buffers
98 *   else: enable read line buffers
99 * SPEC_READS:
100 *   0   : do not speculatively read
101 *   else: speculatively read data ahead of DMA engine
102 *
103 * Optional #defines:
104 * ------------------
105 * MAX_TASKS:
106 *   1   : #define MAX_TASKS>0
107 *   else: 16
108 * ITERATIONS:
109 *   1   : #define ITERATIONS>0
110 *   else: 1
111 * INCR_BYTES:
112 *   This macro is defined based on following priority:
113 *   1   : INCR_SRC != 0
114 *   2   : DST_TYPE != 0
115 *   3   : #defined INCR_BYTES<0
116 *   else: -4 (SZ_UINT32)
117 * DEBUG_BESTCOMM_API:
118 *   >0  : print basic debug messages
119 *   >=10: also print C-API interface variables
120 *   >=20: also print task API interface variables
121 *   else: do nothing
122 *
123 **********************************************************/
124
125#if defined(__rtems__) || defined(MPC5200_BAPI_LIBC_HEADERS)
126#include <stdlib.h>
127#endif
128
129#include "../dma_image.h"
130
131#include "../bestcomm_api.h"
132#include "tasksetup_bdtable.h"
133
134#include "bestcomm_api_mem.h"
135#include "bestcomm_cntrl.h"
136
137#ifndef  DEBUG_BESTCOMM_API
138 #define DEBUG_BESTCOMM_API 0
139#endif
140
141#ifdef FLEX_T
142 #undef FLEX_T
143#endif
144#define FLEX_T SZ_FLEX
145
146#ifdef UINT8_T
147 #undef UINT8_T
148#endif
149#define UINT8_T SZ_UINT8
150
151#ifdef UINT16_T
152 #undef UINT16_T
153#endif
154#define UINT16_T SZ_UINT16
155
156#ifdef UINT32_T
157 #undef UINT32_T
158#endif
159#define UINT32_T SZ_UINT32
160
161#if (INCR_TYPE_SRC==0)   /* FIFO address, no data pointer */
162 #undef  INCR_SRC
163 #define INCR_SRC     0
164#endif
165
166#if (INCR_TYPE_DST==0)   /* FIFO address, no data pointer */
167 #undef  INCR_DST
168 #define INCR_DST     0
169#endif
170
171#ifndef  MAX_TASKS
172 #define MAX_TASKS   16
173#else
174 #if (MAX_TASKS<=0)
175  #undef  MAX_TASKS
176  #define MAX_TASKS  16
177 #endif
178#endif
179
180#ifndef  ITERATIONS
181 #define ITERATIONS   1
182#else
183 #if (ITERATIONS<=0)
184  #undef  ITERATIONS
185  #define ITERATIONS  1
186 #endif
187#endif
188
189#ifndef   INCR_BYTES
190  #define INCR_BYTES -4
191#else
192 #if (INCR_BYTES>=0)
193  #undef  INCR_BYTES
194  #define INCR_BYTES -4
195 #endif
196#endif
197
198/*
199 * These ifndefs will go away when support in task_capi wrappers
200 * in the image directories
201 */
202#ifndef  PRECISE_INCREMENT
203 #define PRECISE_INCREMENT 0  /* bit=6 SAS->1, increment 0=when possible, 1=at the end of interation */
204#endif
205#ifndef  NO_ERROR_RESET
206 #define NO_ERROR_RESET    0  /* bit=5 SAS->0, do not reset error codes on task enable               */
207#endif
208#ifndef  PACK_DATA
209 #define PACK_DATA         0  /* bit=4 SAS->0, pack data enable                                      */
210#endif
211#ifndef  INTEGER_MODE
212 #define INTEGER_MODE      0  /* bit=3 SAS->0, 0=fractional(msb aligned), 1=integer(lsb aligned)     */
213#endif
214#ifndef  SPEC_READS
215 #define SPEC_READS        1  /* bit=2 SAS->0, XLB speculative read enable                           */
216#endif
217#ifndef  WRITE_LINE_BUFFER
218 #define WRITE_LINE_BUFFER 1  /* bit=1 SAS->0, write line buffer enable                              */
219#endif
220#ifndef  READ_LINE_BUFFER
221 #define READ_LINE_BUFFER  1  /* bit=0 SAS->0, read line buffer enable                               */
222#endif
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          )
231
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)
236#endif
237
238#ifndef  TASK_API
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)
242#endif
243
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)
248#endif
249
250#define DRD_INIT_MASK   0xfc1fffff
251#define DRD_EXT_FLAG    0x40000000
252#define DRD_INIT_OFFSET 21
253
254TaskId TASKSETUP_NAME(TASK_API            *TaskAPI,
255                      TaskSetupParamSet_t *TaskSetupParams)
256{
257        TaskId TaskNum;
258        uint32 Status = 0;
259#if ((INCR_TYPE_SRC!=0)||(INCR_TYPE_DST!=0)||(DEBUG_BESTCOMM_API>0))
260        uint8  NumPtr = 0;
261#endif
262#if (INITIATOR_DATA<0)  /* runtime configurable */
263        uint32 i, ext;
264#endif
265
266        INIT_DMA_IMAGE((uint8 *)(((sdma_regs *)(SDMA_TASK_BAR))->taskBar), MBarPhysOffsetGlobal);
267
268        TaskNum = (TaskId)SDMA_TASKNUM_EXT(TaskAPI->TaskNum);
269
270        TaskRunning[TaskNum] = 0;
271
272#if (DEBUG_BESTCOMM_API>0)
273        printf("\nBestComm API Debug Display Mode Enabled\n\n");
274        printf("TaskSetup: TaskID=%d\n", TaskNum);
275        if (Status!=0) {
276                printf("TaskSetup: Rx task\n");
277        } else {
278                printf("TaskSetup: Tx or DP task\n");
279        }
280#endif
281
282        /* Set the task pragma settings */
283        *(TaskAPI->TaskPragma)= (uint8) SDMA_PRAGMA;
284
285#if (MAX_BD>0)  /* Buffer Descriptors */
286
287 #if (INCR_TYPE_SRC!=0)
288        ++NumPtr;
289 #endif
290 #if (INCR_TYPE_DST!=0)
291        ++NumPtr;
292 #endif
293
294 #if (DEBUG_BESTCOMM_API>0)
295        printf("TaskSetup: Using %d buffer descriptors, each with %d data pointers\n", MAX_BD, NumPtr);
296 #endif
297
298        /* Allocate BD table SRAM storage,
299         * and pass addresses to task API */
300
301        TaskSetup_BDTable(TaskAPI->BDTableBase,
302                                          TaskAPI->BDTableLast,
303                                          TaskAPI->BDTableStart,
304                                          TaskNum,
305                                          TaskSetupParams->NumBD,
306                                          MAX_BD, NumPtr,
307                                          BD_FLAG, Status);
308
309        *TaskAPI->AddrEnable = (uint32)((uint32)(((uint16 *)SDMA_TCR)+TaskNum) + MBarPhysOffsetGlobal);
310
311 #if BD_FLAG
312
313  #if (DEBUG_BESTCOMM_API>0)
314        printf("TaskSetup: Buffer descriptor flags are enabled\n");
315  #endif
316
317        /* always assume 2nd to last DRD */
318        *((TaskAPI->AddrDRD)) = (uint32)((uint32)TaskAPI->DRD[TaskAPI->AddrDRDIdx] + MBarPhysOffsetGlobal);
319 #endif /* #if BD_FLAG */
320
321#else   /* No Buffer Descriptors */
322
323/* #error ATA should not be non-BD */
324
325  #if (DEBUG_BESTCOMM_API>0)
326        printf("TaskSetup: Task will complete %d iterations before disabling\n");
327  #endif
328
329        *((TaskAPI->IterExtra)) = (uint32)(ITERATIONS-1);
330#endif  /* #if (MAX_BD>0) */
331
332/* Setup auto start */
333#if (AUTO_START <= -2 ) /* do not start a task */
334 #if (DEBUG_BESTCOMM_API>0)
335        printf("TaskSetup: Auto task start disabled\n");
336 #endif
337        SDMA_TASK_CFG(SDMA_TCR, TaskNum, 0, TaskNum);
338#elif (AUTO_START <= -1 )       /* restart task */
339 #if (DEBUG_BESTCOMM_API>0)
340        printf("TaskSetup: Auto start task\n");
341 #endif
342        SDMA_TASK_CFG(SDMA_TCR, TaskNum, 1, TaskNum);
343#elif (AUTO_START < MAX_TASKS)  /* start specific task */
344 #if (DEBUG_BESTCOMM_API>0)
345        printf("TaskSetup: Auto start task with TaskID=%d\n", AUTO_START);
346 #endif
347        SDMA_TASK_CFG(SDMA_TCR, TaskNum, 1, AUTO_START);
348#else   /* do not start a task */
349 #if (DEBUG_BESTCOMM_API>0)
350        printf("TaskSetup: Auto task start disabled\n");
351 #endif
352        SDMA_TASK_CFG(SDMA_TCR, TaskNum, 0, TaskNum);
353#endif
354
355#if (INITIATOR_DATA<0)  /* runtime configurable */
356        SDMA_SET_INIT(SDMA_TCR, TaskNum, TaskSetupParams->Initiator);
357
358        /*
359     * Hard-code the task initiator in the DRD to avoid a problem w/ the
360     * hold initiator bit in the TCR.
361         */
362        ext = 0;
363        for (i = 0; i < TaskAPI->NumDRD; i++) {
364                if (ext == 0)
365                {
366#if (DEBUG_BESTCOMM_API>=10)
367                                printf("TaskSetup: DRD[%d] initiator = %d\n", i, ((*(TaskAPI->DRD[i]) & ~DRD_INIT_MASK) >> DRD_INIT_OFFSET));
368#endif
369                        if (((*(TaskAPI->DRD[i]) & ~DRD_INIT_MASK) >> DRD_INIT_OFFSET) != INITIATOR_ALWAYS) {
370#if (DEBUG_BESTCOMM_API>=10)
371                                printf("TaskSetup: Replacing DRD[%d] initiator with %d\n", i, TaskSetupParams->Initiator);
372#endif
373                                *(TaskAPI->DRD[i]) = (*(TaskAPI->DRD[i]) & DRD_INIT_MASK)
374                                                        | (TaskSetupParams->Initiator << DRD_INIT_OFFSET);
375                        }
376                       
377                        if ((*(TaskAPI->DRD[i]) & DRD_EXT_FLAG) != 0)
378                        {
379                                ext = 1;
380                        }
381                }
382                else
383                {
384                        if ((*(TaskAPI->DRD[i]) & DRD_EXT_FLAG) == 0)
385                        {
386                                ext = 0;
387                        }
388                }
389        }
390
391#else   /* INITIATOR_DATA >= 0 */
392        TaskSetupParams->Initiator = INITIATOR_DATA;
393#endif
394
395#if (DEBUG_BESTCOMM_API>=10)
396        printf("\nTaskSetup: C-API Parameter Settings Passed to TaskSetup:\n");
397        printf("TaskSetup: NumBD        = %d\n", TaskSetupParams->NumBD);
398 #if (MAX_BD>0)
399        printf("TaskSetup: MaxBuf       = %d\n", TaskSetupParams->Size.MaxBuf);
400 #else
401        printf("TaskSetup: NumBytes     = %d\n", TaskSetupParams->Size.NumBytes);
402 #endif
403        printf("TaskSetup: Initiator    = %d\n", TaskSetupParams->Initiator);
404        printf("TaskSetup: StartAddrSrc = 0x%08X\n", TaskSetupParams->StartAddrSrc);
405        printf("TaskSetup: IncrSrc      = %d\n", TaskSetupParams->IncrSrc);
406        printf("TaskSetup: SzSrc        = %d\n", TaskSetupParams->SzSrc);
407        printf("TaskSetup: StartAddrDst = 0x%08X\n", TaskSetupParams->StartAddrDst);
408        printf("TaskSetup: IncrDst      = %d\n", TaskSetupParams->IncrDst);
409        printf("TaskSetup: SzDst        = %d\n", TaskSetupParams->SzDst);
410#endif
411
412#if (DEBUG_BESTCOMM_API>=20)
413        printf("\nTaskSetup: Task-API Parameter Settings Before TaskSetup Initialization:\n");
414        printf("TaskSetup: TaskNum      = %d\n", (TaskAPI->TaskNum));
415        printf("TaskSetup: TaskPragma   = 0x%02X\n", *((TaskAPI->TaskPragma)));
416        printf("TaskSetup: TCR          = 0x%04x\n", SDMA_TASK_STATUS(SDMA_TCR, TaskNum));
417
418 #if (MAX_BD>0)
419        printf("TaskSetup: BDTableBase  = 0x%08X\n", *((TaskAPI->BDTableBase)));
420        printf("TaskSetup: BDTableLast  = 0x%08X\n", *((TaskAPI->BDTableLast)));
421        printf("TaskSetup: BDTableStart = 0x%08X\n", *((TaskAPI->BDTableStart)));
422        printf("TaskSetup: AddrEnable   = 0x%08X\n", *((TaskAPI->AddrEnable)));
423  #if (INCR_TYPE_SRC==0)
424        printf("TaskSetup: AddrSrcFIFO  = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
425  #endif
426  #if (INCR_TYPE_DST==0)
427        printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
428  #endif
429  #if (BD_FLAG)
430        printf("TaskSetup: AddrDRD      = 0x%08X\n", *((TaskAPI->AddrDRD)));
431        printf("TaskSetup: AddrDRDIdx   = %d\n", ((TaskAPI->AddrDRDIdx)));
432  #endif
433 #else
434        printf("TaskSetup: IterExtra    = %d\n", *((TaskAPI->IterExtra)));
435  #if (INCR_TYPE_SRC==0)
436        printf("TaskSetup: AddrSrcFIFO  = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
437  #else
438        printf("TaskSetup: StartAddrSrc = 0x%08X\n", *((TaskAPI->StartAddrSrc)));
439  #endif
440  #if (INCR_TYPE_DST==0)
441        printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
442  #else
443        printf("TaskSetup: StartAddrDst = 0x%08X\n", *((TaskAPI->StartAddrDst)));
444  #endif
445 #endif
446 #if (INCR_TYPE_SRC!=0)
447        printf("TaskSetup: IncrSrc      = 0x%04X\n", *((TaskAPI->IncrSrc)));
448  #if (MISALIGNED | MISALIGNED_START)
449        printf("TaskSetup: IncrSrcMA    = 0x%04X\n", *((TaskAPI->IncrSrcMA)));
450  #endif
451 #endif
452 #if (INCR_TYPE_DST!=0)
453        printf("TaskSetup: IncrDst      = 0x%04X\n", *((TaskAPI->IncrDst)));
454  #if (MISALIGNED | MISALIGNED_START)
455        printf("TaskSetup: IncrDstMA    = 0x%04X\n", *((TaskAPI->IncrDstMA)));
456  #endif
457 #endif
458        printf("TaskSetup: Bytes        = %d\n", *((TaskAPI->Bytes)));
459        printf("TaskSetup: IncrBytes    = %d\n", *((TaskAPI->IncrBytes)));
460#endif
461
462
463        *((TaskAPI->Bytes)) = (uint32)TaskSetupParams->Size.MaxBuf;
464
465
466#if (TYPE_SRC!=FLEX_T)  /* size fixed in task code */
467        TaskSetupParams->SzSrc = TYPE_SRC;
468#endif
469
470#if (INCR_TYPE_SRC==0)  /* no data pointer */
471        TaskSetupParams->IncrSrc = (sint16)0;
472        *((TaskAPI->AddrSrcFIFO)) = (uint32)TaskSetupParams->StartAddrSrc;
473#else
474
475 #if (INCR_TYPE_SRC==1) /* automatic */
476        if (TaskSetupParams->IncrSrc!=0) {
477                TaskSetupParams->IncrSrc = (sint16)+TaskSetupParams->SzSrc;
478        } else {
479                TaskSetupParams->IncrSrc = (sint16)+TaskSetupParams->IncrSrc;
480        }
481 #elif (INCR_TYPE_SRC!=2)       /* hard-coded */
482        TaskSetupParams->IncrSrc = (sint16)INCR_SRC;
483 #endif
484 *((TaskAPI->IncrSrc)) = (sint16)TaskSetupParams->IncrSrc;
485
486 #if (MAX_BD>0) /* pointer in BD Table */
487        /* pass back address of first BD */
488        TaskSetupParams->StartAddrSrc = (uint32)TaskGetBDRing(TaskNum);
489 #else
490        *((TaskAPI->StartAddrSrc)) = (uint32)TaskSetupParams->StartAddrSrc;
491 #endif
492
493 #if MISALIGNED | MISALIGNED_START
494        if (TaskSetupParams->IncrSrc < 0) {
495                *((TaskAPI->IncrSrcMA)) = (sint16)-1;
496        } else if (TaskSetupParams->IncrSrc > 0) {
497                *((TaskAPI->IncrSrcMA)) = (sint16)+1;
498        } else {
499                *((TaskAPI->IncrSrcMA)) = (sint16)0;
500        }
501 #endif
502#endif
503
504
505#if (TYPE_DST!=FLEX_T)  /* size fixed in task code */
506        TaskSetupParams->SzDst = TYPE_DST;
507#endif
508
509#if (INCR_TYPE_DST==0)  /* no data pointer */
510        TaskSetupParams->IncrDst = (sint16)0;
511        *((TaskAPI->AddrDstFIFO)) = (uint32)TaskSetupParams->StartAddrDst;
512#else
513 #if (INCR_TYPE_DST==1) /* automatic */
514        if (TaskSetupParams->IncrDst!=0) {
515                TaskSetupParams->IncrDst = (sint16)+TaskSetupParams->SzDst;
516        } else {
517                TaskSetupParams->IncrDst = (sint16)+TaskSetupParams->IncrDst;
518        }
519 #elif (INCR_TYPE_DST!=2)       /* hard-coded */
520        TaskSetupParams->IncrDst = (sint16)INCR_DST;
521 #endif
522        *((TaskAPI->IncrDst)) = (sint16)TaskSetupParams->IncrDst;
523
524 #if (MAX_BD>0)
525        /* pass back address of first BD */
526        TaskSetupParams->StartAddrDst = (uint32)TaskGetBDRing(TaskNum);
527 #else
528        *((TaskAPI->StartAddrDst)) = (uint32)TaskSetupParams->StartAddrDst;
529 #endif
530
531 #if MISALIGNED | MISALIGNED_START
532        if (TaskSetupParams->IncrDst < 0) {
533                *((TaskAPI->IncrDstMA)) = (sint16)-1;
534        } else if (TaskSetupParams->IncrDst > 0) {
535                *((TaskAPI->IncrDstMA)) = (sint16)+1;
536        } else {
537                *((TaskAPI->IncrDstMA)) = (sint16)0;
538        }
539 #endif
540#endif
541
542/* always use macro, only affect code with #define TYPE_? flex */
543        SDMA_SET_SIZE(SDMA_TASK_SIZE, TaskNum, TaskSetupParams->SzSrc, TaskSetupParams->SzDst);
544
545
546        if (TaskSetupParams->IncrSrc != 0) {
547                *((TaskAPI->IncrBytes)) = (sint16)-abs(TaskSetupParams->IncrSrc);
548        } else if (TaskSetupParams->IncrDst != 0) {
549                *((TaskAPI->IncrBytes)) = (sint16)-abs(TaskSetupParams->IncrDst);
550        } else {
551                *((TaskAPI->IncrBytes)) = (sint16)-abs(INCR_BYTES);
552        }
553
554
555#if (DEBUG_BESTCOMM_API>=10)
556        printf("\nTaskSetup: C-API Parameter Settings Returned from TaskSetup:\n");
557        printf("TaskSetup: NumBD        = %d\n", TaskSetupParams->NumBD);
558 #if (MAX_BD>0)
559        printf("TaskSetup: MaxBuf       = %d\n", TaskSetupParams->Size.MaxBuf);
560 #else
561        printf("TaskSetup: NumBytes     = %d\n", TaskSetupParams->Size.NumBytes);
562 #endif
563        printf("TaskSetup: Initiator    = %d\n", TaskSetupParams->Initiator);
564        printf("TaskSetup: StartAddrSrc = 0x%08X\n", TaskSetupParams->StartAddrSrc);
565        printf("TaskSetup: IncrSrc      = %d\n", TaskSetupParams->IncrSrc);
566        printf("TaskSetup: SzSrc        = %d\n", TaskSetupParams->SzSrc);
567        printf("TaskSetup: StartAddrDst = 0x%08X\n", TaskSetupParams->StartAddrDst);
568        printf("TaskSetup: IncrDst      = %d\n", TaskSetupParams->IncrDst);
569        printf("TaskSetup: SzDst        = %d\n", TaskSetupParams->SzDst);
570#endif
571
572#if (DEBUG_BESTCOMM_API>=20)
573        printf("\nTaskSetup: Task-API Parameter Settings After TaskSetup Initialization:\n");
574        printf("TaskSetup: TaskNum      = %d\n", ((TaskAPI->TaskNum)));
575        printf("TaskSetup: TaskPragma   = 0x%02X\n", *((TaskAPI->TaskPragma)));
576
577 #if (MAX_BD>0)
578        printf("TaskSetup: BDTableBase  = 0x%08X\n", *((TaskAPI->BDTableBase)));
579        printf("TaskSetup: BDTableLast  = 0x%08X\n", *((TaskAPI->BDTableLast)));
580        printf("TaskSetup: BDTableStart = 0x%08X\n", *((TaskAPI->BDTableStart)));
581        printf("TaskSetup: AddrEnable   = 0x%08X\n", *((TaskAPI->AddrEnable)));
582  #if (INCR_TYPE_SRC==0)
583        printf("TaskSetup: AddrSrcFIFO  = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
584  #endif
585  #if (INCR_TYPE_DST==0)
586        printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
587  #endif
588  #if (BD_FLAG)
589        printf("TaskSetup: AddrDRD      = 0x%08X\n", *((TaskAPI->AddrDRD)));
590        printf("TaskSetup: AddrDRDIdx   = %d\n", ((TaskAPI->AddrDRDIdx)));
591  #endif
592 #else
593        printf("TaskSetup: IterExtra    = %d\n", *((TaskAPI->IterExtra)));
594  #if (INCR_TYPE_SRC==0)
595        printf("TaskSetup: AddrSrcFIFO  = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
596  #else
597        printf("TaskSetup: StartAddrSrc = 0x%08X\n", *((TaskAPI->StartAddrSrc)));
598  #endif
599  #if (INCR_TYPE_DST==0)
600        printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
601  #else
602        printf("TaskSetup: StartAddrDst = 0x%08X\n", *((TaskAPI->StartAddrDst)));
603  #endif
604 #endif
605 #if (INCR_TYPE_SRC!=0)
606        printf("TaskSetup: IncrSrc      = 0x%04X\n", *((TaskAPI->IncrSrc)));
607  #if (MISALIGNED | MISALIGNED_START)
608        printf("TaskSetup: IncrSrcMA    = 0x%04X\n", *((TaskAPI->IncrSrcMA)));
609  #endif
610 #endif
611 #if (INCR_TYPE_DST!=0)
612        printf("TaskSetup: IncrDst      = 0x%04X\n", *((TaskAPI->IncrDst)));
613  #if (MISALIGNED | MISALIGNED_START)
614        printf("TaskSetup: IncrDstMA    = 0x%04X\n", *((TaskAPI->IncrDstMA)));
615  #endif
616 #endif
617        printf("TaskSetup: Bytes        = %d\n", *((TaskAPI->Bytes)));
618        printf("TaskSetup: IncrBytes    = %d\n", *((TaskAPI->IncrBytes)));
619#endif
620
621        return TaskNum;
622}
Note: See TracBrowser for help on using the repository browser.