comparison src/nucleus/tci.c @ 0:92470e5d0b9e

src: partial import from FC Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 May 2020 01:28:16 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:92470e5d0b9e
1 /*************************************************************************/
2 /* */
3 /* Copyright Mentor Graphics Corporation 2002 */
4 /* All Rights Reserved. */
5 /* */
6 /* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS */
7 /* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS */
8 /* SUBJECT TO LICENSE TERMS. */
9 /* */
10 /*************************************************************************/
11
12 /*************************************************************************/
13 /* */
14 /* FILE NAME VERSION */
15 /* */
16 /* tci.c Nucleus PLUS 1.14 */
17 /* */
18 /* COMPONENT */
19 /* */
20 /* TC - Thread Control */
21 /* */
22 /* DESCRIPTION */
23 /* */
24 /* This file contains the initialization routine for this */
25 /* component. */
26 /* */
27 /* DATA STRUCTURES */
28 /* */
29 /* None */
30 /* */
31 /* FUNCTIONS */
32 /* */
33 /* TCI_Initialize Thread Control Initialization*/
34 /* */
35 /* DEPENDENCIES */
36 /* */
37 /* tc_defs.h Thread Control constants */
38 /* */
39 /* HISTORY */
40 /* */
41 /* DATE REMARKS */
42 /* */
43 /* 03-01-1993 Created initial version 1.0 */
44 /* 04-19-1993 Verified version 1.0 */
45 /* 08-09-1993 Corrected problem initializing */
46 /* the LISR association table, */
47 /* resulting in version 1.0a */
48 /* 08-09-1993 Verified version 1.0a */
49 /* 03-01-1994 Changed to initialize the system */
50 /* protection rather than the */
51 /* schedule protection, resulting */
52 /* in version 1.1 */
53 /* */
54 /* 03-18-1994 Verified version 1.1 */
55 /* 04-17-1996 updated to version 1.2 */
56 /* 03-24-1998 Released version 1.3 */
57 /* 03-26-1999 Released 1.11m (new release */
58 /* numbering scheme) */
59 /* 04-17-2002 Released version 1.13m */
60 /* 11-07-2002 Released version 1.14 */
61 /*************************************************************************/
62 #define NU_SOURCE_FILE
63
64
65 #include "cs_defs.h" /* Common Service constants */
66 #include "tc_defs.h" /* Thread Control constants */
67 #include "tc_extr.h" /* Thread Control interfaces */
68
69 /* Define external inner-component global data references. */
70
71 extern CS_NODE *TCD_Created_Tasks_List;
72 extern UNSIGNED TCD_Total_Tasks;
73 extern TC_TCB *TCD_Priority_List[TC_PRIORITIES];
74 extern UNSIGNED TCD_Priority_Groups;
75 extern DATA_ELEMENT TCD_Sub_Priority_Groups[TC_MAX_GROUPS];
76 extern INT TCD_Highest_Priority;
77 extern TC_TCB *TCD_Execute_Task;
78 extern VOID *TCD_Current_Thread;
79 extern UNSIGNED_CHAR TCD_Registered_LISRs[NU_MAX_VECTORS+1];
80 extern VOID (*TCD_LISR_Pointers[NU_MAX_LISRS+1])(INT vector);
81 extern INT TCD_Interrupt_Count;
82 extern INT TCD_Stack_Switched;
83 extern TC_PROTECT TCD_List_Protect;
84 extern TC_PROTECT TCD_System_Protect;
85 extern TC_PROTECT TCD_LISR_Protect;
86 extern CS_NODE *TCD_Created_HISRs_List;
87 extern UNSIGNED TCD_Total_HISRs;
88 extern TC_HCB *TCD_Active_HISR_Heads[TC_HISR_PRIORITIES];
89 extern TC_HCB *TCD_Active_HISR_Tails[TC_HISR_PRIORITIES];
90 extern TC_HCB *TCD_Execute_HISR;
91 extern TC_PROTECT TCD_HISR_Protect;
92 extern INT TCD_Interrupt_Level;
93
94
95
96 /*************************************************************************/
97 /* */
98 /* FUNCTION */
99 /* */
100 /* TCI_Initialize */
101 /* */
102 /* DESCRIPTION */
103 /* */
104 /* This function initializes the data structures that control the */
105 /* operation of the TC component. The system is initialized as */
106 /* idle. This routine must be executed from Supervisor mode in */
107 /* Supervisor/User mode switching kernels. */
108 /* */
109 /* CALLED BY */
110 /* */
111 /* INC_Initialize System initialization */
112 /* */
113 /* CALLS */
114 /* */
115 /* None */
116 /* */
117 /* INPUTS */
118 /* */
119 /* None */
120 /* */
121 /* OUTPUTS */
122 /* */
123 /* TCD_Created_Tasks_List List of created tasks */
124 /* TCD_Total_Tasks Number of created tasks */
125 /* TCD_Priority_List Ready task array */
126 /* TCD_Priority_Groups Ready priority group bit map */
127 /* TCD_Sub_Priority_Groups Sub-priority groups bit map */
128 /* TCD_Highest_Priority Highest priority task */
129 /* TCD_Execute_Task Top priority task to execute */
130 /* TCD_Created_HISRs_List List of created HISRs */
131 /* TCD_Total_HISRs Number of created HISRs */
132 /* TCD_Active_HISR_Heads Active HISR list head ptrs */
133 /* TCD_Active_HISR_Tails Active HISR list tail ptrs */
134 /* TCD_Execute_HISR Top priority HISR to execute */
135 /* TCD_Current_Thread Current thread pointer */
136 /* TCD_Registered_LISRs Registered LISRs list */
137 /* TCD_LISR_Pointers Pointers to active LISRs */
138 /* TCD_Interrupt_Count Interrupt in progress counter*/
139 /* TCD_Stack_Switched Interrupt stack switched flag*/
140 /* TCD_List_Protect Protection of task list */
141 /* TCD_Schedule_Protect Protection of scheduling */
142 /* data structures. */
143 /* TCD_HISR_Protect Protection of created HISR */
144 /* list */
145 /* TCD_Interrupt_Level Enable interrupt level */
146 /* */
147 /* HISTORY */
148 /* */
149 /* DATE REMARKS */
150 /* */
151 /* 03-01-1993 Created initial version 1.0 */
152 /* 04-19-1993 Verified version 1.0 */
153 /* 08-09-1993 Corrected problem initializing */
154 /* the LISR association table, */
155 /* resulting in version 1.0a */
156 /* 08-09-1993 Verified version 1.0a */
157 /* 03-01-1994 Changed to initialize the system */
158 /* protection rather than the */
159 /* schedule protection, resulting */
160 /* in version 1.1 */
161 /* */
162 /* 03-18-1994 Verified version 1.1 */
163 /* */
164 /*************************************************************************/
165 VOID TCI_Initialize(VOID)
166 {
167
168 int i; /* Working index variable */
169
170
171 /* Initialize the created task list to NU_NULL. */
172 TCD_Created_Tasks_List = NU_NULL;
173
174 /* Initialize the total number of created tasks to 0. */
175 TCD_Total_Tasks = 0;
176
177 /* Initialize the array of ready task lists. */
178 for (i = 0; i < TC_PRIORITIES; i++)
179 TCD_Priority_List[i] = 0;
180
181 /* Initialize the bit maps that represent that at least one task is
182 ready at the same priority level. */
183 TCD_Priority_Groups = 0;
184
185 for (i = 0; i < TC_MAX_GROUPS; i++)
186 TCD_Sub_Priority_Groups[i] = 0;
187
188 /* Initialize the highest priority flag. */
189 TCD_Highest_Priority = TC_PRIORITIES;
190
191 /* Initialize pointers to the task to execute, HISR to execute,
192 and current thread of execution. */
193 TCD_Execute_Task = NU_NULL;
194 TCD_Execute_HISR = NU_NULL;
195 TCD_Current_Thread = NU_NULL;
196
197 /* Initialize the created HISRs list to NU_NULL. */
198 TCD_Created_HISRs_List = NU_NULL;
199
200 /* Initialize the total number of created HISRs to 0. */
201 TCD_Total_HISRs = 0;
202
203 /* Initialize the array of ready HISR list pointers. */
204 for (i = 0; i < TC_HISR_PRIORITIES; i++)
205 {
206 TCD_Active_HISR_Heads[i] = NU_NULL;
207 TCD_Active_HISR_Tails[i] = NU_NULL;
208 }
209
210 /* Initialize the LISR interrupt control data structures. */
211 for (i = 0; i <= NU_MAX_VECTORS; i++)
212 TCD_Registered_LISRs[i] = NU_FALSE;
213
214 for (i = 0; i <= NU_MAX_LISRS; i++)
215 TCD_LISR_Pointers[i] = NU_NULL;
216
217 /* Initialize the interrupt processing variables. */
218 TCD_Interrupt_Count = 0;
219 TCD_Stack_Switched = 0;
220
221 /* Initialize the task control protection structures. */
222 TCD_List_Protect.tc_tcb_pointer = NU_NULL;
223 TCD_System_Protect.tc_tcb_pointer = NU_NULL;
224 TCD_LISR_Protect.tc_tcb_pointer = NU_NULL;
225 TCD_HISR_Protect.tc_tcb_pointer = NU_NULL;
226
227 /* Initialize the interrupt level to enable all interrupts. */
228 TCD_Interrupt_Level = NU_ENABLE_INTERRUPTS;
229 }
230
231
232
233
234