source: rtems/bsps/powerpc/gen5200/bestcomm/tasksetup_bdtable.c @ a0f04d6

5
Last change on this file since a0f04d6 was a0f04d6, checked in by Sebastian Huber <sebastian.huber@…>, on 04/22/18 at 13:32:38

bsp/gen5200: Move bestcomm to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 3.8 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#include <assert.h>
26
27#include <bsp/bestcomm/bestcomm_api.h>
28#include <bsp/bestcomm/bestcomm_glue.h>
29#include <bsp/bestcomm/task_api/tasksetup_bdtable.h>
30#include <bsp/bestcomm/include/mgt5200/mgt5200.h>
31
32#ifdef __MWERKS__
33__declspec(section ".text") extern const uint32 taskTable;
34__declspec(section ".text") extern const uint32 taskTableBytes;
35__declspec(section ".text") extern const uint32 taskTableTasks;
36__declspec(section ".text") extern const uint32 offsetEntry;
37#else
38extern const uint32 taskTable;
39extern const uint32 taskTableBytes;
40extern const uint32 taskTableTasks;
41extern const uint32 offsetEntry;
42#endif
43
44TaskBDIdxTable_t TaskBDIdxTable[MAX_TASKS];
45
46void TaskSetup_BDTable(volatile uint32 *BasePtr, volatile uint32 *LastPtr, volatile uint32 *StartPtr,
47                                           int TaskNum, uint32 NumBD, uint16 MaxBD,
48                                           uint8 NumPtr, ApiConfig_t ApiConfig, uint32 Status)
49{
50        int i, j;
51        uint32 *ptr;
52
53        /*
54         * First time through the Buffer Descriptor table configuration
55         * set the buffer descriptor table with parameters that will not
56         * change since they are determined by the task itself. The
57         * SramOffsetGlobal variable must be updated to reflect the new SRAM
58         * space used by the buffer descriptor table.  The next time through
59         * this function (i.e. TaskSetup called again) the only parameters
60         * that should be changed are the LastPtr pointers and the NumBD part
61         * of the table.
62         */
63        if (TaskBDIdxTable[TaskNum].BDTablePtr == 0) {
64                size_t AllocSize = 0;
65                void *AllocBegin = NULL;
66
67                switch (NumPtr) {
68                        case 1:
69                                AllocSize += MaxBD*sizeof(TaskBD1_t);
70                                break;
71                        case 2:
72                                AllocSize += MaxBD*sizeof(TaskBD2_t);
73                                break;
74                        default:
75                                assert(0);
76                                break;
77                }
78
79                AllocBegin = bestcomm_malloc(AllocSize);
80                assert(AllocBegin != NULL);
81
82                TaskBDIdxTable[TaskNum].BDTablePtr  = AllocBegin;
83                TaskBDIdxTable[TaskNum].numPtr      = NumPtr;
84                TaskBDIdxTable[TaskNum].apiConfig   = ApiConfig;
85                TaskBDIdxTable[TaskNum].BDStartPtr  = StartPtr;
86
87                *StartPtr = *BasePtr  = (uint32)((uint32)TaskBDIdxTable[TaskNum].BDTablePtr
88                                        + MBarPhysOffsetGlobal);
89        }
90
91        TaskBDIdxTable[TaskNum].currBDInUse     = 0;
92        TaskBDIdxTable[TaskNum].numBD           = (uint16)NumBD;
93        switch (NumPtr) {
94                case 1:
95                        *LastPtr = (uint32)(*BasePtr + sizeof(TaskBD1_t) * (NumBD - 1));
96                        break;
97                case 2:
98                        *LastPtr = (uint32)(*BasePtr + sizeof(TaskBD2_t) * (NumBD - 1));
99                        break;
100                default:
101                        /* error */
102                        break;
103        }
104
105        /*
106         * Set the status bits. Clear the data pointers.
107         */
108        if (MaxBD > 0) {
109                ptr = TaskBDIdxTable[TaskNum].BDTablePtr;
110                for (i = 0; i < NumBD; i++) {
111                        *(ptr++) = Status;
112                        for (j = 0; j < NumPtr; j++) {
113                                *(ptr++) = 0x0;
114                        }
115                }
116        }
117}
Note: See TracBrowser for help on using the repository browser.