comparison src/nucleus/tmi.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 /* tmi.c Nucleus PLUS 1.14 */
17 /* */
18 /* COMPONENT */
19 /* */
20 /* TM - Timer Management */
21 /* */
22 /* DESCRIPTION */
23 /* */
24 /* This file contains the initialization routine for the timer */
25 /* management component. */
26 /* */
27 /* DATA STRUCTURES */
28 /* */
29 /* None */
30 /* */
31 /* FUNCTIONS */
32 /* */
33 /* TMI_Initialize Timer Management Initialize */
34 /* */
35 /* DEPENDENCIES */
36 /* */
37 /* tc_extr.h Task function interfaces */
38 /* er_extr.h Error handling function */
39 /* tm_defs.h Timer component constants */
40 /* */
41 /* HISTORY */
42 /* */
43 /* DATE REMARKS */
44 /* */
45 /* 03-01-1993 Created initial version 1.0 */
46 /* 04-19-1993 Verified version 1.0 */
47 /* 08-09-1993 Removed timer task creation, */
48 /* cleared the ID of the HISR */
49 /* control block, and casted the */
50 /* HISR priority, resulting in */
51 /* version 1.0a */
52 /* 08-09-1993 Verified version 1.0a */
53 /* 03-01-1994 Changed names of HISR create */
54 /* function, removed reference to */
55 /* timer list protect since it */
56 /* was deleted, resulting in */
57 /* version 1.1 */
58 /* */
59 /* 03-18-1994 Verified version 1.1 */
60 /* 04-17-1996 updated to version 1.2 */
61 /* 03-24-1998 Released version 1.3 */
62 /* 03-26-1999 Released 1.11m (new release */
63 /* numbering scheme) */
64 /* 04-17-2002 Released version 1.13m */
65 /* 11-07-2002 Released version 1.14 */
66 /*************************************************************************/
67 #define NU_SOURCE_FILE
68
69
70 #include "tc_extr.h" /* Task control functions */
71 #include "er_extr.h" /* Error handling function */
72 #include "tm_defs.h" /* Timer constants */
73 #include "tm_extr.h" /* Timer interfaces */
74
75
76 /* Define external inner-component global data references. */
77
78 extern CS_NODE *TMD_Created_Timers_List;
79 extern UNSIGNED TMD_Total_Timers;
80 extern TM_TCB *TMD_Active_Timers_List;
81 extern INT TMD_Active_List_Busy;
82 extern TC_PROTECT TMD_Created_List_Protect;
83 extern UNSIGNED TMD_System_Clock;
84 extern UNSIGNED TMD_Timer;
85 extern INT TMD_Timer_State;
86 extern UNSIGNED TMD_Time_Slice;
87 extern TC_TCB *TMD_Time_Slice_Task;
88 extern INT TMD_Time_Slice_State;
89 extern TC_HCB TMD_HISR;
90 extern VOID *TMD_HISR_Stack_Ptr;
91 extern UNSIGNED TMD_HISR_Stack_Size;
92 extern INT TMD_HISR_Priority;
93
94
95 /* Define inner-component function prototypes. */
96
97 VOID TMC_Timer_HISR(VOID);
98
99
100 /*************************************************************************/
101 /* */
102 /* FUNCTION */
103 /* */
104 /* TMI_Initialize */
105 /* */
106 /* DESCRIPTION */
107 /* */
108 /* This function initializes the data structures that control the */
109 /* operation of the timer component (TM). There are no application */
110 /* timers created initially. This routine must be called from */
111 /* Supervisor mode in Supervisor/User mode switching kernels. */
112 /* */
113 /* CALLED BY */
114 /* */
115 /* INC_Initialize System initialization */
116 /* */
117 /* CALLS */
118 /* */
119 /* ERC_System_Error System error handing function*/
120 /* TCC_Create_HISR Create timer HISR */
121 /* TCCE_Create_HISR Create timer HISR (error chk)*/
122 /* */
123 /* INPUTS */
124 /* */
125 /* (Indirect) */
126 /* TMD_HISR_Stack_Ptr Pointer to HISR stack area */
127 /* TMD_HISR_Stack_Size Size of HISR stack */
128 /* TMD_HISR_Priority Priority of timer HISR */
129 /* */
130 /* OUTPUTS */
131 /* */
132 /* TMD_Created_Timers_List Pointer to the linked-list */
133 /* of created application */
134 /* timers */
135 /* TMD_Total_Timers Total number of created */
136 /* application timers */
137 /* TMD_Active_Timers_List Pointer to the linked-list */
138 /* of active timers. */
139 /* TMD_Active_List_Busy Flag indicating that the */
140 /* active timer list is in use*/
141 /* TMD_Created_List_Protect Created timer list protect */
142 /* structure */
143 /* TMD_System_Clock System clock */
144 /* TMD_Timer Timer count-down value */
145 /* TMD_Timer_State State of timer */
146 /* TMD_Time_Slice Time slice count-down value */
147 /* TMD_Time_Slice_Task Pointer to task to time-slice*/
148 /* TMD_Time_Slice_State State of time slice */
149 /* TMD_HISR Timer HISR control block */
150 /* */
151 /* HISTORY */
152 /* */
153 /* DATE REMARKS */
154 /* */
155 /* 03-01-1993 Created initial version 1.0 */
156 /* 04-19-1993 Verified version 1.0 */
157 /* 08-09-1993 Removed timer task creation, */
158 /* cleared the ID of the HISR */
159 /* control block, and casted the */
160 /* HISR priority, resulting in */
161 /* version 1.0a */
162 /* 08-09-1993 Verified version 1.0a */
163 /* 03-01-1994 Modified HISR create function */
164 /* interface, removed reference */
165 /* to timer list protect since it */
166 /* was deleted, resulting in */
167 /* version 1.1 */
168 /* */
169 /* 03-18-1994 Verified version 1.1 */
170 /* */
171 /*************************************************************************/
172 VOID TMI_Initialize(VOID)
173 {
174
175 STATUS status; /* Return status of creates */
176
177
178 /* Initialize the created application timer's list to NU_NULL. */
179 TMD_Created_Timers_List = NU_NULL;
180
181 /* Initialize the total number of created application timers to 0. */
182 TMD_Total_Timers = 0;
183
184 /* Initialize the active timer's list to NU_NULL. */
185 TMD_Active_Timers_List = NU_NULL;
186
187 /* Clear the active timer list busy flag. */
188 TMD_Active_List_Busy = NU_FALSE;
189
190 /* Initialize the system clock to 0. */
191 TMD_System_Clock = 0;
192
193 /* Initialize the timer to 0 and the timer state to "not active." */
194 TMD_Timer = 0;
195 TMD_Timer_State = TM_NOT_ACTIVE;
196
197 /* Initialize the time-slice timer, task pointer, and the associated
198 state variable. */
199 TMD_Time_Slice = 0;
200 TMD_Time_Slice_Task = NU_NULL;
201 TMD_Time_Slice_State = TM_NOT_ACTIVE;
202
203 /* Initialize the list protection structures. */
204 TMD_Created_List_Protect.tc_tcb_pointer = NU_NULL;
205
206 /* Clear out the timer HISR control block. */
207 TMD_HISR.tc_id = 0;
208
209 /* Create the timer HISR. The timer HISR is responsible for performing
210 the time slice function and activating the timer task if necessary. */
211 #ifdef NU_NO_ERROR_CHECKING
212
213 status = TCC_Create_HISR((NU_HISR *) &TMD_HISR, "SYSTEM H",
214 TMC_Timer_HISR, (OPTION) TMD_HISR_Priority,
215 TMD_HISR_Stack_Ptr, TMD_HISR_Stack_Size);
216 #else
217
218 status = TCCE_Create_HISR((NU_HISR *) &TMD_HISR, "SYSTEM H",
219 TMC_Timer_HISR, (OPTION) TMD_HISR_Priority,
220 TMD_HISR_Stack_Ptr, TMD_HISR_Stack_Size);
221
222 #endif
223
224 /* Check for a system error creating the timer HISR. */
225 if (status != NU_SUCCESS)
226
227 /* Call the system error handler. */
228 ERC_System_Error(NU_ERROR_CREATING_TIMER_HISR);
229 }
230
231
232
233
234