source: rtems/c/src/lib/libbsp/powerpc/gen5200/bestcomm/tasksetup_bdtable.c @ c8423f9

4.104.114.84.95
Last change on this file since c8423f9 was c8423f9, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/02/06 at 04:48:19

Eliminate #include "../bestcomm/...

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