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

4.104.11
Last change on this file since 4f5d1c9f was 4f5d1c9f, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on Mar 27, 2010 at 3:00:43 PM

removed warnings

  • Property mode set to 100644
File size: 20.1 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#if ((MAX_BD>0)||(DEBUG_BESTCOMM_API>0))
259        uint32 Status = 0;
260#endif
261#if ((MAX_BD>0)&&((INCR_TYPE_SRC!=0)||(INCR_TYPE_DST!=0))||(DEBUG_BESTCOMM_API>0))
262        uint8  NumPtr = 0;
263#endif
264#if (INITIATOR_DATA<0)  /* runtime configurable */
265        uint32 i, ext;
266#endif
267
268        INIT_DMA_IMAGE((uint8 *)(((sdma_regs *)(SDMA_TASK_BAR))->taskBar), MBarPhysOffsetGlobal);
269
270        TaskNum = (TaskId)SDMA_TASKNUM_EXT(TaskAPI->TaskNum);
271
272        TaskRunning[TaskNum] = 0;
273
274#if (DEBUG_BESTCOMM_API>0)
275        printf("\nBestComm API Debug Display Mode Enabled\n\n");
276        printf("TaskSetup: TaskID=%d\n", TaskNum);
277        if (Status!=0) {
278                printf("TaskSetup: Rx task\n");
279        } else {
280                printf("TaskSetup: Tx or DP task\n");
281        }
282#endif
283
284        /* Set the task pragma settings */
285        *(TaskAPI->TaskPragma)= (uint8) SDMA_PRAGMA;
286
287#if (MAX_BD>0)  /* Buffer Descriptors */
288
289 #if (INCR_TYPE_SRC!=0)
290        ++NumPtr;
291 #endif
292 #if (INCR_TYPE_DST!=0)
293        ++NumPtr;
294 #endif
295
296 #if (DEBUG_BESTCOMM_API>0)
297        printf("TaskSetup: Using %d buffer descriptors, each with %d data pointers\n", MAX_BD, NumPtr);
298 #endif
299
300        /* Allocate BD table SRAM storage,
301         * and pass addresses to task API */
302
303        TaskSetup_BDTable(TaskAPI->BDTableBase,
304                                          TaskAPI->BDTableLast,
305                                          TaskAPI->BDTableStart,
306                                          TaskNum,
307                                          TaskSetupParams->NumBD,
308                                          MAX_BD, NumPtr,
309                                          BD_FLAG, Status);
310
311        *TaskAPI->AddrEnable = (uint32)((uint32)(((uint16 *)SDMA_TCR)+TaskNum) + MBarPhysOffsetGlobal);
312
313 #if BD_FLAG
314
315  #if (DEBUG_BESTCOMM_API>0)
316        printf("TaskSetup: Buffer descriptor flags are enabled\n");
317  #endif
318
319        /* always assume 2nd to last DRD */
320        *((TaskAPI->AddrDRD)) = (uint32)((uint32)TaskAPI->DRD[TaskAPI->AddrDRDIdx] + MBarPhysOffsetGlobal);
321 #endif /* #if BD_FLAG */
322
323#else   /* No Buffer Descriptors */
324
325/* #error ATA should not be non-BD */
326
327  #if (DEBUG_BESTCOMM_API>0)
328        printf("TaskSetup: Task will complete %d iterations before disabling\n");
329  #endif
330
331        *((TaskAPI->IterExtra)) = (uint32)(ITERATIONS-1);
332#endif  /* #if (MAX_BD>0) */
333
334/* Setup auto start */
335#if (AUTO_START <= -2 ) /* do not start a task */
336 #if (DEBUG_BESTCOMM_API>0)
337        printf("TaskSetup: Auto task start disabled\n");
338 #endif
339        SDMA_TASK_CFG(SDMA_TCR, TaskNum, 0, TaskNum);
340#elif (AUTO_START <= -1 )       /* restart task */
341 #if (DEBUG_BESTCOMM_API>0)
342        printf("TaskSetup: Auto start task\n");
343 #endif
344        SDMA_TASK_CFG(SDMA_TCR, TaskNum, 1, TaskNum);
345#elif (AUTO_START < MAX_TASKS)  /* start specific task */
346 #if (DEBUG_BESTCOMM_API>0)
347        printf("TaskSetup: Auto start task with TaskID=%d\n", AUTO_START);
348 #endif
349        SDMA_TASK_CFG(SDMA_TCR, TaskNum, 1, AUTO_START);
350#else   /* do not start a task */
351 #if (DEBUG_BESTCOMM_API>0)
352        printf("TaskSetup: Auto task start disabled\n");
353 #endif
354        SDMA_TASK_CFG(SDMA_TCR, TaskNum, 0, TaskNum);
355#endif
356
357#if (INITIATOR_DATA<0)  /* runtime configurable */
358        SDMA_SET_INIT(SDMA_TCR, TaskNum, TaskSetupParams->Initiator);
359
360        /*
361     * Hard-code the task initiator in the DRD to avoid a problem w/ the
362     * hold initiator bit in the TCR.
363         */
364        ext = 0;
365        for (i = 0; i < TaskAPI->NumDRD; i++) {
366                if (ext == 0)
367                {
368#if (DEBUG_BESTCOMM_API>=10)
369                                printf("TaskSetup: DRD[%d] initiator = %d\n", i, ((*(TaskAPI->DRD[i]) & ~DRD_INIT_MASK) >> DRD_INIT_OFFSET));
370#endif
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);
374#endif
375                                *(TaskAPI->DRD[i]) = (*(TaskAPI->DRD[i]) & DRD_INIT_MASK)
376                                                        | (TaskSetupParams->Initiator << DRD_INIT_OFFSET);
377                        }
378
379                        if ((*(TaskAPI->DRD[i]) & DRD_EXT_FLAG) != 0)
380                        {
381                                ext = 1;
382                        }
383                }
384                else
385                {
386                        if ((*(TaskAPI->DRD[i]) & DRD_EXT_FLAG) == 0)
387                        {
388                                ext = 0;
389                        }
390                }
391        }
392
393#else   /* INITIATOR_DATA >= 0 */
394        TaskSetupParams->Initiator = INITIATOR_DATA;
395#endif
396
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);
400 #if (MAX_BD>0)
401        printf("TaskSetup: MaxBuf       = %d\n", TaskSetupParams->Size.MaxBuf);
402 #else
403        printf("TaskSetup: NumBytes     = %d\n", TaskSetupParams->Size.NumBytes);
404 #endif
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);
412#endif
413
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));
419
420 #if (MAX_BD>0)
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)));
427  #endif
428  #if (INCR_TYPE_DST==0)
429        printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
430  #endif
431  #if (BD_FLAG)
432        printf("TaskSetup: AddrDRD      = 0x%08X\n", *((TaskAPI->AddrDRD)));
433        printf("TaskSetup: AddrDRDIdx   = %d\n", ((TaskAPI->AddrDRDIdx)));
434  #endif
435 #else
436        printf("TaskSetup: IterExtra    = %d\n", *((TaskAPI->IterExtra)));
437  #if (INCR_TYPE_SRC==0)
438        printf("TaskSetup: AddrSrcFIFO  = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
439  #else
440        printf("TaskSetup: StartAddrSrc = 0x%08X\n", *((TaskAPI->StartAddrSrc)));
441  #endif
442  #if (INCR_TYPE_DST==0)
443        printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
444  #else
445        printf("TaskSetup: StartAddrDst = 0x%08X\n", *((TaskAPI->StartAddrDst)));
446  #endif
447 #endif
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)));
452  #endif
453 #endif
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)));
458  #endif
459 #endif
460        printf("TaskSetup: Bytes        = %d\n", *((TaskAPI->Bytes)));
461        printf("TaskSetup: IncrBytes    = %d\n", *((TaskAPI->IncrBytes)));
462#endif
463
464
465        *((TaskAPI->Bytes)) = (uint32)TaskSetupParams->Size.MaxBuf;
466
467
468#if (TYPE_SRC!=FLEX_T)  /* size fixed in task code */
469        TaskSetupParams->SzSrc = TYPE_SRC;
470#endif
471
472#if (INCR_TYPE_SRC==0)  /* no data pointer */
473        TaskSetupParams->IncrSrc = (sint16)0;
474        *((TaskAPI->AddrSrcFIFO)) = (uint32)TaskSetupParams->StartAddrSrc;
475#else
476
477 #if (INCR_TYPE_SRC==1) /* automatic */
478        if (TaskSetupParams->IncrSrc!=0) {
479                TaskSetupParams->IncrSrc = (sint16)+TaskSetupParams->SzSrc;
480        } else {
481                TaskSetupParams->IncrSrc = (sint16)+TaskSetupParams->IncrSrc;
482        }
483 #elif (INCR_TYPE_SRC!=2)       /* hard-coded */
484        TaskSetupParams->IncrSrc = (sint16)INCR_SRC;
485 #endif
486 *((TaskAPI->IncrSrc)) = (sint16)TaskSetupParams->IncrSrc;
487
488 #if (MAX_BD>0) /* pointer in BD Table */
489        /* pass back address of first BD */
490        TaskSetupParams->StartAddrSrc = (uint32)TaskGetBDRing(TaskNum);
491 #else
492        *((TaskAPI->StartAddrSrc)) = (uint32)TaskSetupParams->StartAddrSrc;
493 #endif
494
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;
500        } else {
501                *((TaskAPI->IncrSrcMA)) = (sint16)0;
502        }
503 #endif
504#endif
505
506
507#if (TYPE_DST!=FLEX_T)  /* size fixed in task code */
508        TaskSetupParams->SzDst = TYPE_DST;
509#endif
510
511#if (INCR_TYPE_DST==0)  /* no data pointer */
512        TaskSetupParams->IncrDst = (sint16)0;
513        *((TaskAPI->AddrDstFIFO)) = (uint32)TaskSetupParams->StartAddrDst;
514#else
515 #if (INCR_TYPE_DST==1) /* automatic */
516        if (TaskSetupParams->IncrDst!=0) {
517                TaskSetupParams->IncrDst = (sint16)+TaskSetupParams->SzDst;
518        } else {
519                TaskSetupParams->IncrDst = (sint16)+TaskSetupParams->IncrDst;
520        }
521 #elif (INCR_TYPE_DST!=2)       /* hard-coded */
522        TaskSetupParams->IncrDst = (sint16)INCR_DST;
523 #endif
524        *((TaskAPI->IncrDst)) = (sint16)TaskSetupParams->IncrDst;
525
526 #if (MAX_BD>0)
527        /* pass back address of first BD */
528        TaskSetupParams->StartAddrDst = (uint32)TaskGetBDRing(TaskNum);
529 #else
530        *((TaskAPI->StartAddrDst)) = (uint32)TaskSetupParams->StartAddrDst;
531 #endif
532
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;
538        } else {
539                *((TaskAPI->IncrDstMA)) = (sint16)0;
540        }
541 #endif
542#endif
543
544/* always use macro, only affect code with #define TYPE_? flex */
545        SDMA_SET_SIZE(SDMA_TASK_SIZE, TaskNum, TaskSetupParams->SzSrc, TaskSetupParams->SzDst);
546
547
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);
552        } else {
553                *((TaskAPI->IncrBytes)) = (sint16)-abs(INCR_BYTES);
554        }
555
556
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);
560 #if (MAX_BD>0)
561        printf("TaskSetup: MaxBuf       = %d\n", TaskSetupParams->Size.MaxBuf);
562 #else
563        printf("TaskSetup: NumBytes     = %d\n", TaskSetupParams->Size.NumBytes);
564 #endif
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);
572#endif
573
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)));
578
579 #if (MAX_BD>0)
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)));
586  #endif
587  #if (INCR_TYPE_DST==0)
588        printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
589  #endif
590  #if (BD_FLAG)
591        printf("TaskSetup: AddrDRD      = 0x%08X\n", *((TaskAPI->AddrDRD)));
592        printf("TaskSetup: AddrDRDIdx   = %d\n", ((TaskAPI->AddrDRDIdx)));
593  #endif
594 #else
595        printf("TaskSetup: IterExtra    = %d\n", *((TaskAPI->IterExtra)));
596  #if (INCR_TYPE_SRC==0)
597        printf("TaskSetup: AddrSrcFIFO  = 0x%08X\n", *((TaskAPI->AddrSrcFIFO)));
598  #else
599        printf("TaskSetup: StartAddrSrc = 0x%08X\n", *((TaskAPI->StartAddrSrc)));
600  #endif
601  #if (INCR_TYPE_DST==0)
602        printf("TaskSetup: AddrDstFIFO  = 0x%08X\n", *((TaskAPI->AddrDstFIFO)));
603  #else
604        printf("TaskSetup: StartAddrDst = 0x%08X\n", *((TaskAPI->StartAddrDst)));
605  #endif
606 #endif
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)));
611  #endif
612 #endif
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)));
617  #endif
618 #endif
619        printf("TaskSetup: Bytes        = %d\n", *((TaskAPI->Bytes)));
620        printf("TaskSetup: IncrBytes    = %d\n", *((TaskAPI->IncrBytes)));
621#endif
622
623        return TaskNum;
624}
Note: See TracBrowser for help on using the repository browser.