1#ifndef __BESTCOMM_API_H
2#define __BESTCOMM_API_H 1
41#include "include/ppctypes.h"
42#include "include/mgt5200/sdma.h"
43#include "task_api/tasksetup_bdtable.h"
44#include "task_api/bestcomm_cntrl.h"
45#include "task_api/bestcomm_api_mem.h"
65#define DEBUG_BESTCOMM_API 0
77# define NULL ((void *)0)
87#define DEBUG_INTR_ID SDMA_INT_BIT_DBG
90#define TEA_INTR_ID SDMA_INT_BIT_TEA
93#define TASK_AUTOSTART_ENABLE 1
96#define TASK_AUTOSTART_DISABLE 0
99#define TASK_INTERRUPT_ENABLE 1
102#define TASK_INTERRUPT_DISABLE 0
108#define TASK_BD_TFD (1 << SDMA_DRD_BIT_TFD)
111#define TASK_BD_INT (1 << SDMA_DRD_BIT_INT)
149 INITIATOR_ALWAYS = 0,
150 INITIATOR_SCTMR_0 = 1,
151 INITIATOR_SCTMR_1 = 2,
152 INITIATOR_FEC_RX = 3,
153 INITIATOR_FEC_TX = 4,
154 INITIATOR_ATA_RX = 5,
155 INITIATOR_ATA_TX = 6,
156 INITIATOR_SCPCI_RX = 7,
157 INITIATOR_SCPCI_TX = 8,
158 INITIATOR_PSC3_RX = 9,
159 INITIATOR_PSC3_TX = 10,
160 INITIATOR_PSC2_RX = 11,
161 INITIATOR_PSC2_TX = 12,
162 INITIATOR_PSC1_RX = 13,
163 INITIATOR_PSC1_TX = 14,
164 INITIATOR_SCTMR_2 = 15,
166 INITIATOR_SCLPC = 16,
167 INITIATOR_PSC5_RX = 17,
168 INITIATOR_PSC5_TX = 18,
169 INITIATOR_PSC4_RX = 19,
170 INITIATOR_PSC4_TX = 20,
171 INITIATOR_I2C2_RX = 21,
172 INITIATOR_I2C2_TX = 22,
173 INITIATOR_I2C1_RX = 23,
174 INITIATOR_I2C1_TX = 24,
175 INITIATOR_PSC6_RX = 25,
176 INITIATOR_PSC6_TX = 26,
177 INITIATOR_IRDA_RX = 25,
178 INITIATOR_IRDA_TX = 26,
179 INITIATOR_SCTMR_3 = 27,
180 INITIATOR_SCTMR_4 = 28,
181 INITIATOR_SCTMR_5 = 29,
182 INITIATOR_SCTMR_6 = 30,
183 INITIATOR_SCTMR_7 = 31
254#include "bestcomm_priv.h"
255#include "dma_image.capi.h"
280#define TaskSetupHelper(TaskName, TaskSetupParams) \
281 TaskSetup_ ## TaskName (TaskName ## _api, TaskSetupParams)
282#define TaskSetup(TaskName, TaskSetupParams) \
283 TaskSetupHelper(TaskName, TaskSetupParams)
294int TaskStart(TaskId taskId, uint32 autoStartEnable,
295 TaskId autoStartTask, uint32 intrEnable);
297static int TaskStatus(TaskId taskId);
298BDIdx
TaskBDAssign(TaskId taskId,
void *buffer0,
void *buffer1,
299 int size, uint32 bdFlags);
302static TaskBD_t *TaskGetBD(TaskId taskId, BDIdx bd);
303static TaskBD_t *TaskGetBDRing(TaskId taskId);
305static int TaskIntClear(TaskId taskId);
306static TaskId TaskIntStatus(TaskId taskId);
307static int TaskIntPending(TaskId taskId);
308static TaskId TaskIntSource(
void);
309static uint16 TaskBDInUse(TaskId taskId);
318static inline int TaskStatus(TaskId taskId)
320 return SDMA_TASK_STATUS(SDMA_TCR, taskId) & 0x8000;
333static inline TaskBD_t *TaskGetBD(TaskId taskId, BDIdx bd)
337 bdTab = TaskBDIdxTable[taskId].BDTablePtr;
338 if (TaskBDIdxTable[taskId].numPtr == 1) {
356static inline TaskBD_t *TaskGetBDRing(TaskId taskId)
358 return (
TaskBD_t *) TaskBDIdxTable[taskId].BDTablePtr;
366static inline int TaskIntClear(TaskId taskId)
368 SDMA_CLEAR_IEVENT(SDMA_INT_PEND, taskId);
381static inline TaskId TaskIntStatus(TaskId taskId)
385 pending = SDMA_INT_PENDING(SDMA_INT_PEND, SDMA_INT_MASK);
387 if (SDMA_INT_TEST(pending, taskId)) {
404static inline int TaskIntPending(TaskId taskId)
408 pending = SDMA_INT_PENDING(SDMA_INT_PEND, SDMA_INT_MASK);
409 if (SDMA_INT_TEST(pending, taskId)) {
425static inline TaskId TaskIntSource(
void)
431 pending = SDMA_INT_PENDING(SDMA_INT_PEND, SDMA_INT_MASK);
433 if (SDMA_INT_TEST(pending, SDMA_INT_BIT_TEA)) {
434 return (TaskId)SDMA_TEA_SOURCE(SDMA_INT_PEND);
437 for (i = (
MAX_TASKS - 1); i >= 0; --i, mask >>= 1) {
438 if (pending & mask) {
451static inline uint16 TaskBDInUse(TaskId taskId)
453 return TaskBDIdxTable[taskId].currBDInUse;
int TasksInitAPI_VM(uint8 *MBarRef, uint8 *MBarPhys)
Initialize the API when virtual memory is used.
Definition: bestcomm_api.c:142
int TaskStart(TaskId taskId, uint32 autoStartEnable, TaskId autoStartTask, uint32 intrEnable)
Start an initialized task running.
Definition: bestcomm_api.c:187
BDIdx TaskBDReset(TaskId taskId)
Release all buffers.
Definition: bestcomm_api.c:404
BDIdx TaskBDAssign(TaskId taskId, void *buffer0, void *buffer1, int size, uint32 bdFlags)
Assign a buffer to a buffer descriptor.
Definition: bestcomm_api.c:247
int TaskDebug(TaskId taskId, TaskDebugParamSet_t *paramSet)
Return BestComm debug information.
Definition: bestcomm_api.c:442
const char * TaskVersion(void)
Get a string containing API version information.
Definition: bestcomm_api.c:81
int TaskStop(TaskId taskId)
Stop a running task.
Definition: bestcomm_api.c:217
void TasksLoadImage(sdma_regs *sdma)
Load BestComm tasks into SRAM.
Definition: load_task.c:68
MPC5200Initiator_t
BestComm initiators.
Definition: bestcomm_api.h:147
Sz_t
Data transfer size.
Definition: bestcomm_api.h:116
@ SZ_UINT16
Definition: bestcomm_api.h:119
@ SZ_UINT32
Definition: bestcomm_api.h:120
@ SZ_UINT8
Definition: bestcomm_api.h:118
@ SZ_FLEX
Definition: bestcomm_api.h:117
TaskErr_t
API error codes.
Definition: bestcomm_api.h:126
@ TASK_ERR_NO_ERR
Definition: bestcomm_api.h:127
@ TASK_ERR_BD_BUSY
Definition: bestcomm_api.h:136
@ TASK_ERR_API_ALREADY_INITIALIZED
Definition: bestcomm_api.h:132
@ TASK_ERR_BD_RING_FULL
Definition: bestcomm_api.h:131
@ TASK_ERR_INVALID_ARG
Definition: bestcomm_api.h:130
@ TASK_ERR_TASK_RUNNING
Definition: bestcomm_api.h:138
@ TASK_ERR_SIZE_TOO_LARGE
Definition: bestcomm_api.h:134
@ TASK_ERR_NO_INTR
Definition: bestcomm_api.h:128
@ TASK_ERR_BD_RING_EMPTY
Definition: bestcomm_api.h:135
#define MAX_TASKS
Maximum number of tasks in the system. This number is hardware-dependent and not user configuration.
Definition: bestcomm_api.h:71
#define DEBUG_INTR_ID
Debug interrupt "task ID".
Definition: bestcomm_api.h:87
BDIdx TaskBDRelease(TaskId taskId)
Release last buffer in the buffer descriptor ring.
Definition: bestcomm_api.c:346
#define TEA_INTR_ID
TEA interrupt "task ID".
Definition: bestcomm_api.h:90
int TasksInitAPI(uint8 *MBarRef)
Initialize the API.
Definition: bestcomm_api.c:100
int TasksAttachImage(sdma_regs *sdma)
Deprecated
Definition: bestcomm_api.c:170
This header file defines the RTEMS Classic API.
Single buffer descriptor.
Definition: bestcomm_api.h:235
uint32 Status
Definition: bestcomm_api.h:236
Dual buffer descriptor.
Definition: bestcomm_api.h:243
uint32 Status
Definition: bestcomm_api.h:244
Generic buffer descriptor.
Definition: bestcomm_api.h:228
uint32 Status
Definition: bestcomm_api.h:229
Parameters for TaskDebug()
Definition: bestcomm_api.h:218
Parameters for TaskSetup()
Definition: bestcomm_api.h:194
Sz_t SzDst
Definition: bestcomm_api.h:209
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