File indexing completed on 2025-05-11 08:23:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include <assert.h>
0026
0027 #include <bsp/bestcomm/bestcomm_api.h>
0028 #include <bsp/bestcomm/bestcomm_glue.h>
0029 #include <bsp/bestcomm/task_api/tasksetup_bdtable.h>
0030 #include <bsp/bestcomm/include/mgt5200/mgt5200.h>
0031
0032 #ifdef __MWERKS__
0033 __declspec(section ".text") extern const uint32 taskTable;
0034 __declspec(section ".text") extern const uint32 taskTableBytes;
0035 __declspec(section ".text") extern const uint32 taskTableTasks;
0036 __declspec(section ".text") extern const uint32 offsetEntry;
0037 #else
0038 extern const uint32 taskTable;
0039 extern const uint32 taskTableBytes;
0040 extern const uint32 taskTableTasks;
0041 extern const uint32 offsetEntry;
0042 #endif
0043
0044 TaskBDIdxTable_t TaskBDIdxTable[MAX_TASKS];
0045
0046 void TaskSetup_BDTable(volatile uint32 *BasePtr, volatile uint32 *LastPtr, volatile uint32 *StartPtr,
0047 int TaskNum, uint32 NumBD, uint16 MaxBD,
0048 uint8 NumPtr, ApiConfig_t ApiConfig, uint32 Status)
0049 {
0050 int i, j;
0051 uint32 *ptr;
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 if (TaskBDIdxTable[TaskNum].BDTablePtr == 0) {
0064 size_t AllocSize = 0;
0065 void *AllocBegin = NULL;
0066
0067 switch (NumPtr) {
0068 case 1:
0069 AllocSize += MaxBD*sizeof(TaskBD1_t);
0070 break;
0071 case 2:
0072 AllocSize += MaxBD*sizeof(TaskBD2_t);
0073 break;
0074 default:
0075 assert(0);
0076 break;
0077 }
0078
0079 AllocBegin = bestcomm_malloc(AllocSize);
0080 assert(AllocBegin != NULL);
0081
0082 TaskBDIdxTable[TaskNum].BDTablePtr = AllocBegin;
0083 TaskBDIdxTable[TaskNum].numPtr = NumPtr;
0084 TaskBDIdxTable[TaskNum].apiConfig = ApiConfig;
0085 TaskBDIdxTable[TaskNum].BDStartPtr = StartPtr;
0086
0087 *StartPtr = *BasePtr = (uint32)((uint32)TaskBDIdxTable[TaskNum].BDTablePtr
0088 + MBarPhysOffsetGlobal);
0089 }
0090
0091 TaskBDIdxTable[TaskNum].currBDInUse = 0;
0092 TaskBDIdxTable[TaskNum].numBD = (uint16)NumBD;
0093 switch (NumPtr) {
0094 case 1:
0095 *LastPtr = (uint32)(*BasePtr + sizeof(TaskBD1_t) * (NumBD - 1));
0096 break;
0097 case 2:
0098 *LastPtr = (uint32)(*BasePtr + sizeof(TaskBD2_t) * (NumBD - 1));
0099 break;
0100 default:
0101
0102 break;
0103 }
0104
0105
0106
0107
0108 if (MaxBD > 0) {
0109 ptr = TaskBDIdxTable[TaskNum].BDTablePtr;
0110 for (i = 0; i < NumBD; i++) {
0111 *(ptr++) = Status;
0112 for (j = 0; j < NumPtr; j++) {
0113 *(ptr++) = 0x0;
0114 }
0115 }
0116 }
0117 }