FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/nucleus/debug-chases/tms.c.dbg @ 143:afceeeb2cba1
Our nuc-fw is destined to become gsm-fw, so I went ahead and did the big hg mv
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 12 Nov 2013 05:35:48 +0000 |
parents | nuc-fw/nucleus/debug-chases/tms.c.dbg@85994b210f6a |
children |
comparison
equal
deleted
inserted
replaced
142:15d5977390c2 | 143:afceeeb2cba1 |
---|---|
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 /* tms.c Nucleus PLUS 1.14 */ | |
17 /* */ | |
18 /* COMPONENT */ | |
19 /* */ | |
20 /* TM - Timer Management */ | |
21 /* */ | |
22 /* DESCRIPTION */ | |
23 /* */ | |
24 /* This file contains supplemental routines for the timer */ | |
25 /* management component. */ | |
26 /* */ | |
27 /* DATA STRUCTURES */ | |
28 /* */ | |
29 /* None */ | |
30 /* */ | |
31 /* FUNCTIONS */ | |
32 /* */ | |
33 /* TMS_Create_Timer Create an application timer */ | |
34 /* TMS_Delete_Timer Delete an application timer */ | |
35 /* TMS_Reset_Timer Reset application timer */ | |
36 /* TMS_Control_Timer Enable/Disable application */ | |
37 /* timer */ | |
38 /* */ | |
39 /* DEPENDENCIES */ | |
40 /* */ | |
41 /* cs_extr.h Common Service functions */ | |
42 /* tc_extr.h Thread Control functions */ | |
43 /* tm_extr.h Timer functions */ | |
44 /* hi_extr.h History functions */ | |
45 /* */ | |
46 /* HISTORY */ | |
47 /* */ | |
48 /* DATE REMARKS */ | |
49 /* */ | |
50 /* 03-01-1994 Created initial version 1.1 from */ | |
51 /* previous version of TMC.C */ | |
52 /* */ | |
53 /* 03-18-1994 Verified version 1.1 */ | |
54 /* 04-17-1996 updated to version 1.2 */ | |
55 /* 03-24-1998 Released version 1.3. */ | |
56 /* 03-26-1999 Released 1.11m (new release */ | |
57 /* numbering scheme) */ | |
58 /* 04-17-2002 Released version 1.13m */ | |
59 /* 11-07-2002 Released version 1.14 */ | |
60 /*************************************************************************/ | |
61 #define NU_SOURCE_FILE | |
62 | |
63 | |
64 #include "cs_extr.h" /* Common service functions */ | |
65 #include "tc_extr.h" /* Thread control functions */ | |
66 #include "tm_extr.h" /* Timer functions */ | |
67 #include "hi_extr.h" /* History functions */ | |
68 #include "profiler.h" /* ProView interface */ | |
69 | |
70 | |
71 /* Define external inner-component global data references. */ | |
72 | |
73 extern CS_NODE *TMD_Created_Timers_List; | |
74 extern UNSIGNED TMD_Total_Timers; | |
75 extern TM_TCB *TMD_Active_Timers_List; | |
76 extern INT TMD_Active_List_Busy; | |
77 extern TC_PROTECT TMD_Created_List_Protect; | |
78 | |
79 | |
80 /* Define internal function prototypes. */ | |
81 | |
82 VOID TMC_Start_Timer(TM_TCB *timer, UNSIGNED time); | |
83 VOID TMC_Stop_Timer(TM_TCB *timer); | |
84 | |
85 | |
86 | |
87 /*************************************************************************/ | |
88 /* */ | |
89 /* FUNCTION */ | |
90 /* */ | |
91 /* TMS_Create_Timer */ | |
92 /* */ | |
93 /* DESCRIPTION */ | |
94 /* */ | |
95 /* This function creates an application timer and places it on the */ | |
96 /* list of created timers. The timer is activated if designated by */ | |
97 /* the enable parameter. */ | |
98 /* */ | |
99 /* CALLED BY */ | |
100 /* */ | |
101 /* Application */ | |
102 /* TMSE_Create_Timer Error checking shell */ | |
103 /* */ | |
104 /* CALLS */ | |
105 /* */ | |
106 /* CSC_Place_On_List Add node to linked-list */ | |
107 /* [HIC_Make_History_Entry] Make entry in history log */ | |
108 /* [TCT_Check_Stack] Stack checking function */ | |
109 /* TCT_Protect Data structure protect */ | |
110 /* TCT_Unprotect Un-protect data structure */ | |
111 /* TMS_Control_Timer Enable the new timer */ | |
112 /* */ | |
113 /* INPUTS */ | |
114 /* */ | |
115 /* timer_ptr Timer control block pointer */ | |
116 /* name Timer name */ | |
117 /* expiration_routine Timer expiration routine */ | |
118 /* id Timer expiration ID */ | |
119 /* initial_time Initial expiration time */ | |
120 /* reschedule_time Reschedule expiration time */ | |
121 /* enable Automatic enable option */ | |
122 /* */ | |
123 /* OUTPUTS */ | |
124 /* */ | |
125 /* NU_SUCCESS */ | |
126 /* */ | |
127 /* HISTORY */ | |
128 /* */ | |
129 /* DATE REMARKS */ | |
130 /* */ | |
131 /* 03-01-1993 Created initial version 1.0 */ | |
132 /* 04-19-1993 Verified version 1.0 */ | |
133 /* 03-01-1994 Changed function prototype, */ | |
134 /* resulting in version 1.1 */ | |
135 /* */ | |
136 /* 03-18-1994 Verified version 1.1 */ | |
137 /* */ | |
138 /*************************************************************************/ | |
139 STATUS TMS_Create_Timer(NU_TIMER *timer_ptr, CHAR *name, | |
140 VOID (*expiration_routine)(UNSIGNED), UNSIGNED id, | |
141 UNSIGNED initial_time, UNSIGNED reschedule_time, OPTION enable) | |
142 { | |
143 | |
144 R1 TM_APP_TCB *timer; /* Timer control block ptr */ | |
145 INT i; /* Working index variable */ | |
146 NU_SUPERV_USER_VARIABLES | |
147 | |
148 /* Switch to supervisor mode */ | |
149 NU_SUPERVISOR_MODE(); | |
150 | |
151 /* Move input timer pointer into internal pointer. */ | |
152 timer = (TM_APP_TCB *) timer_ptr; | |
153 | |
154 | |
155 #ifdef NU_ENABLE_STACK_CHECK | |
156 | |
157 /* Call stack checking function to check for an overflow condition. */ | |
158 TCT_Check_Stack(); | |
159 | |
160 #endif | |
161 | |
162 #ifdef NU_ENABLE_HISTORY | |
163 | |
164 /* Make an entry that corresponds to this function in the system history | |
165 log. */ | |
166 HIC_Make_History_Entry(NU_CREATE_TIMER_ID, (UNSIGNED) timer, | |
167 (UNSIGNED) name, (UNSIGNED) expiration_routine); | |
168 | |
169 #endif | |
170 | |
171 /* First, clear the timer ID just in case it is an old Timer | |
172 Control Block. */ | |
173 timer -> tm_id = 0; | |
174 | |
175 /* Fill in the timer name. */ | |
176 for (i = 0; i < NU_MAX_NAME; i++) | |
177 timer -> tm_name[i] = name[i]; | |
178 | |
179 /* Load the timer with the appropriate values. */ | |
180 timer -> tm_expiration_routine = expiration_routine; | |
181 timer -> tm_expiration_id = id; | |
182 timer -> tm_expirations = 0; | |
183 timer -> tm_initial_time = initial_time; | |
184 timer -> tm_reschedule_time = reschedule_time; | |
185 timer -> tm_actual_timer.tm_timer_type = TM_APPL_TIMER; | |
186 timer -> tm_enabled = NU_FALSE; | |
187 | |
188 /* Initialize link pointers. */ | |
189 timer -> tm_created.cs_previous = NU_NULL; | |
190 timer -> tm_created.cs_next = NU_NULL; | |
191 timer -> tm_actual_timer.tm_next_timer = NU_NULL; | |
192 timer -> tm_actual_timer.tm_previous_timer= NU_NULL; | |
193 timer -> tm_actual_timer.tm_information = (VOID *) timer; | |
194 | |
195 /* Protect against access to the list of created timers. */ | |
196 TCT_Protect(&TMD_Created_List_Protect); | |
197 | |
198 /* At this point the timer is completely built. The ID can now be | |
199 set and it can be linked into the created timer list. */ | |
200 timer -> tm_id = TM_TIMER_ID; | |
201 | |
202 /* Link the timer into the list of created timers and increment the | |
203 total number of timers in the system. */ | |
204 CSC_Place_On_List(&TMD_Created_Timers_List, &(timer -> tm_created)); | |
205 TMD_Total_Timers++; | |
206 | |
207 #ifdef INCLUDE_PROVIEW | |
208 _RTProf_DumpTimer(RT_PROF_CREATE_TIMER,timer,RT_PROF_OK); | |
209 #endif | |
210 | |
211 /* Release protection against access to the list of created timers. */ | |
212 TCT_Unprotect(); | |
213 | |
214 /* Determine if the timer should be enabled. */ | |
215 if (enable == NU_ENABLE_TIMER) | |
216 | |
217 /* Activate the timer. */ | |
218 TMS_Control_Timer(timer_ptr, NU_ENABLE_TIMER); | |
219 | |
220 /* Return to user mode */ | |
221 NU_USER_MODE(); | |
222 | |
223 /* Return successful completion. */ | |
224 return(NU_SUCCESS); | |
225 } | |
226 | |
227 | |
228 /*************************************************************************/ | |
229 /* */ | |
230 /* FUNCTION */ | |
231 /* */ | |
232 /* TMS_Delete_Timer */ | |
233 /* */ | |
234 /* DESCRIPTION */ | |
235 /* */ | |
236 /* This function deletes an application timer and removes it from */ | |
237 /* the list of created timers. */ | |
238 /* */ | |
239 /* CALLED BY */ | |
240 /* */ | |
241 /* Application */ | |
242 /* TMSE_Delete_Timer Error checking shell */ | |
243 /* */ | |
244 /* CALLS */ | |
245 /* */ | |
246 /* CSC_Remove_From_List Remove node from list */ | |
247 /* [HIC_Make_History_Entry] Make entry in history log */ | |
248 /* [TCT_Check_Stack] Stack checking function */ | |
249 /* TCT_Protect Protect created list */ | |
250 /* TCT_System_Protect Protect active list */ | |
251 /* TCT_Unprotect Release protection */ | |
252 /* */ | |
253 /* INPUTS */ | |
254 /* */ | |
255 /* timer_ptr Timer control block pointer */ | |
256 /* */ | |
257 /* OUTPUTS */ | |
258 /* */ | |
259 /* NU_NOT_DISABLED Timer not disabled first */ | |
260 /* NU_SUCCESS */ | |
261 /* */ | |
262 /* HISTORY */ | |
263 /* */ | |
264 /* DATE REMARKS */ | |
265 /* */ | |
266 /* 03-01-1993 Created initial version 1.0 */ | |
267 /* 04-19-1993 Verified version 1.0 */ | |
268 /* 03-01-1994 Modified protection logic to use */ | |
269 /* system protection, changed */ | |
270 /* function prototype, resulting */ | |
271 /* in version 1.1 */ | |
272 /* */ | |
273 /* 03-18-1994 Verified version 1.1 */ | |
274 /* */ | |
275 /*************************************************************************/ | |
276 STATUS TMS_Delete_Timer(NU_TIMER *timer_ptr) | |
277 { | |
278 | |
279 TM_APP_TCB *timer; /* Timer control block ptr */ | |
280 STATUS status; /* Completion status */ | |
281 NU_SUPERV_USER_VARIABLES | |
282 | |
283 /* Switch to supervisor mode */ | |
284 NU_SUPERVISOR_MODE(); | |
285 | |
286 /* Move input timer pointer into internal pointer. */ | |
287 timer = (TM_APP_TCB *) timer_ptr; | |
288 | |
289 | |
290 #ifdef NU_ENABLE_STACK_CHECK | |
291 | |
292 /* Call stack checking function to check for an overflow condition. */ | |
293 TCT_Check_Stack(); | |
294 | |
295 #endif | |
296 | |
297 #ifdef NU_ENABLE_HISTORY | |
298 | |
299 /* Make an entry that corresponds to this function in the system history | |
300 log. */ | |
301 HIC_Make_History_Entry(NU_DELETE_TIMER_ID, (UNSIGNED) timer, | |
302 (UNSIGNED) 0, (UNSIGNED) 0); | |
303 | |
304 #endif | |
305 | |
306 /* Initialize the status. */ | |
307 status = NU_SUCCESS; | |
308 | |
309 /* Use system protect to protect the active timer list temporarily. */ | |
310 TCT_System_Protect(); | |
311 | |
312 /* Determine if the timer is currently disabled. */ | |
313 if (timer -> tm_enabled) | |
314 { | |
315 /* Error, indicate to the caller that the timer is currently active. */ | |
316 status = NU_NOT_DISABLED; | |
317 | |
318 #ifdef INCLUDE_PROVIEW | |
319 _RTProf_DumpTimer(RT_PROF_DELETE_TIMER,timer,RT_PROF_FAIL); | |
320 #endif | |
321 | |
322 } | |
323 else | |
324 { | |
325 /* Clear the timer ID. */ | |
326 timer -> tm_id = 0; | |
327 | |
328 #ifdef INCLUDE_PROVIEW | |
329 _RTProf_DumpTimer(RT_PROF_DELETE_TIMER,timer,RT_PROF_OK); | |
330 #endif /* INCLUDE_PROVIEW */ | |
331 | |
332 } | |
333 | |
334 /* Release protection. */ | |
335 TCT_Unprotect(); | |
336 | |
337 /* Determine if an error was detected. */ | |
338 if (status == NU_SUCCESS) | |
339 { | |
340 | |
341 /* Protect against access to the list of created timers. */ | |
342 TCT_Protect(&TMD_Created_List_Protect); | |
343 | |
344 /* Remove the timer from the list of created timers. */ | |
345 CSC_Remove_From_List(&TMD_Created_Timers_List, &(timer -> tm_created)); | |
346 | |
347 /* Decrement the total number of created timers. */ | |
348 TMD_Total_Timers--; | |
349 | |
350 /* Release protection against access to the list of created timers. */ | |
351 TCT_Unprotect(); | |
352 } | |
353 | |
354 /* Return to user mode */ | |
355 NU_USER_MODE(); | |
356 | |
357 /* Return completion status. */ | |
358 return(status); | |
359 } | |
360 | |
361 | |
362 /*************************************************************************/ | |
363 /* */ | |
364 /* FUNCTION */ | |
365 /* */ | |
366 /* TMS_Reset_Timer */ | |
367 /* */ | |
368 /* DESCRIPTION */ | |
369 /* */ | |
370 /* This function resets the specified application timer. Note that */ | |
371 /* the timer must be in a disabled state prior to this call. The */ | |
372 /* timer is activated after it is reset if the enable parameter */ | |
373 /* specifies automatic activation. */ | |
374 /* */ | |
375 /* CALLED BY */ | |
376 /* */ | |
377 /* Application */ | |
378 /* TMSE_Reset_Timer Error checking shell */ | |
379 /* */ | |
380 /* CALLS */ | |
381 /* */ | |
382 /* [HIC_Make_History_Entry] Make entry in history log */ | |
383 /* [TCT_Check_Stack] Stack checking function */ | |
384 /* TCT_System_Protect Protect active list */ | |
385 /* TCT_Unprotect Release protection */ | |
386 /* TMS_Control_Timer Enable/disable timer */ | |
387 /* */ | |
388 /* INPUTS */ | |
389 /* */ | |
390 /* timer_ptr Timer control block pointer */ | |
391 /* expiration_routine Timer expiration routine */ | |
392 /* initial_time Initial expiration time */ | |
393 /* reschedule_time Reschedule expiration time */ | |
394 /* enable Automatic enable option */ | |
395 /* */ | |
396 /* OUTPUTS */ | |
397 /* */ | |
398 /* NU_NOT_DISABLED Timer not disabled first */ | |
399 /* NU_SUCCESS Successful completion */ | |
400 /* */ | |
401 /* HISTORY */ | |
402 /* */ | |
403 /* DATE REMARKS */ | |
404 /* */ | |
405 /* 03-01-1993 Created initial version 1.0 */ | |
406 /* 04-19-1993 Verified version 1.0 */ | |
407 /* 03-01-1994 Modified protection logic to use */ | |
408 /* system protection, changed */ | |
409 /* function prototype, resulting */ | |
410 /* in version 1.1 */ | |
411 /* */ | |
412 /* 03-18-1994 Verified version 1.1 */ | |
413 /* */ | |
414 /*************************************************************************/ | |
415 STATUS TMS_Reset_Timer(NU_TIMER *timer_ptr, | |
416 VOID (*expiration_routine)(UNSIGNED), | |
417 UNSIGNED initial_time, UNSIGNED reschedule_time, OPTION enable) | |
418 { | |
419 | |
420 R1 TM_APP_TCB *timer; /* Timer control block ptr */ | |
421 STATUS status; /* Completion status */ | |
422 NU_SUPERV_USER_VARIABLES | |
423 static char dbgstr[512]; | |
424 | |
425 sprintf(dbgstr, "* TMS_Reset_Timer(): timer_ptr=%08x, expiration_routine=%08x, initial_time=%x, reschedule_time=%x, enable=%x", | |
426 (unsigned)timer_ptr, (unsigned)expiration_routine, | |
427 (unsigned)initial_time, (unsigned)reschedule_time, | |
428 (unsigned)enable); | |
429 freecalypso_raw_dbgout(dbgstr); | |
430 | |
431 /* Switch to supervisor mode */ | |
432 NU_SUPERVISOR_MODE(); | |
433 | |
434 /* Move input timer pointer into internal pointer. */ | |
435 timer = (TM_APP_TCB *) timer_ptr; | |
436 | |
437 | |
438 #ifdef NU_ENABLE_STACK_CHECK | |
439 | |
440 /* Call stack checking function to check for an overflow condition. */ | |
441 TCT_Check_Stack(); | |
442 | |
443 #endif | |
444 | |
445 #ifdef NU_ENABLE_HISTORY | |
446 | |
447 /* Make an entry that corresponds to this function in the system history | |
448 log. */ | |
449 HIC_Make_History_Entry(NU_RESET_TIMER_ID, (UNSIGNED) timer, | |
450 (UNSIGNED) expiration_routine, (UNSIGNED) initial_time); | |
451 | |
452 #endif | |
453 | |
454 /* Protect against access to the active timer list. */ | |
455 TCT_System_Protect(); | |
456 | |
457 /* Determine if this timer is active. An active timer cannot be | |
458 reset. */ | |
459 if (timer -> tm_enabled) | |
460 { | |
461 | |
462 /* Indicate that the timer is active by returning the proper status. */ | |
463 status = NU_NOT_DISABLED; | |
464 | |
465 #ifdef INCLUDE_PROVIEW | |
466 _RTProf_DumpTimer(RT_PROF_RESET_TIMER,timer,RT_PROF_FAIL); | |
467 #endif /* INCLUDE_PROVIEW */ | |
468 | |
469 } | |
470 else | |
471 { | |
472 | |
473 /* Load the timer with the appropriate values. */ | |
474 timer -> tm_expiration_routine = expiration_routine; | |
475 timer -> tm_expirations = 0; | |
476 timer -> tm_initial_time = initial_time; | |
477 timer -> tm_reschedule_time = reschedule_time; | |
478 | |
479 /* Indicate successful completion status. */ | |
480 status = NU_SUCCESS; | |
481 #ifdef INCLUDE_PROVIEW | |
482 _RTProf_DumpTimer(RT_PROF_RESET_TIMER,timer,RT_PROF_OK); | |
483 #endif /* INCLUDE_PROVIEW */ | |
484 | |
485 } | |
486 | |
487 /* Release protection. */ | |
488 TCT_Unprotect(); | |
489 | |
490 /* Determine if the timer needs to be enabled. */ | |
491 if ((status == NU_SUCCESS) && (enable == NU_ENABLE_TIMER)) | |
492 | |
493 /* Activate the timer. */ | |
494 TMS_Control_Timer(timer_ptr, NU_ENABLE_TIMER); | |
495 | |
496 /* Return to user mode */ | |
497 NU_USER_MODE(); | |
498 | |
499 /* Return completion status. */ | |
500 return(status); | |
501 } | |
502 | |
503 | |
504 /*************************************************************************/ | |
505 /* */ | |
506 /* FUNCTION */ | |
507 /* */ | |
508 /* TMS_Control_Timer */ | |
509 /* */ | |
510 /* DESCRIPTION */ | |
511 /* */ | |
512 /* This function either enables or disables the specified timer. */ | |
513 /* If the timer is already in the desired state, simply leave it */ | |
514 /* alone. */ | |
515 /* */ | |
516 /* CALLED BY */ | |
517 /* */ | |
518 /* Application */ | |
519 /* TMSE_Control_Timer Error checking shell */ | |
520 /* */ | |
521 /* CALLS */ | |
522 /* */ | |
523 /* [HIC_Make_History_Entry] Make entry in history log */ | |
524 /* [TCT_Check_Stack] Stack checking function */ | |
525 /* TCT_System_Protect Protect the active list */ | |
526 /* TCT_Unprotect Release protection */ | |
527 /* TMC_Start_Timer Start a timer */ | |
528 /* TMC_Stop_Timer Stop a timer */ | |
529 /* */ | |
530 /* INPUTS */ | |
531 /* */ | |
532 /* app_timer Timer control block pointer */ | |
533 /* enable Disable/enable timer option */ | |
534 /* */ | |
535 /* OUTPUTS */ | |
536 /* */ | |
537 /* NU_SUCCESS If service is successful */ | |
538 /* */ | |
539 /* HISTORY */ | |
540 /* */ | |
541 /* DATE REMARKS */ | |
542 /* */ | |
543 /* 03-01-1993 Created initial version 1.0 */ | |
544 /* 04-19-1993 Verified version 1.0 */ | |
545 /* 03-01-1994 Modified protection logic to use */ | |
546 /* system protection, changed */ | |
547 /* function prototype, resulting */ | |
548 /* in version 1.1 */ | |
549 /* */ | |
550 /* 03-18-1994 Verified version 1.1 */ | |
551 /* */ | |
552 /*************************************************************************/ | |
553 STATUS TMS_Control_Timer(NU_TIMER *app_timer, OPTION enable) | |
554 { | |
555 | |
556 R1 TM_APP_TCB *timer; /* Timer control block ptr */ | |
557 TM_TCB *timer_ptr; /* Actual timer pointer */ | |
558 UNSIGNED time; /* Variable to hold request */ | |
559 NU_SUPERV_USER_VARIABLES | |
560 | |
561 /* Switch to supervisor mode */ | |
562 NU_SUPERVISOR_MODE(); | |
563 | |
564 /* Move input timer pointer into internal pointer. */ | |
565 timer = (TM_APP_TCB *) app_timer; | |
566 | |
567 | |
568 #ifdef NU_ENABLE_STACK_CHECK | |
569 | |
570 /* Call stack checking function to check for an overflow condition. */ | |
571 TCT_Check_Stack(); | |
572 | |
573 #endif | |
574 | |
575 #ifdef NU_ENABLE_HISTORY | |
576 | |
577 /* Make an entry that corresponds to this function in the system history | |
578 log. */ | |
579 HIC_Make_History_Entry(NU_CONTROL_TIMER_ID, (UNSIGNED) timer, | |
580 (UNSIGNED) enable, (UNSIGNED) 0); | |
581 | |
582 #endif | |
583 | |
584 /* Protect against simultaneous access to the active timer list. */ | |
585 TCT_System_Protect(); | |
586 | |
587 /* Setup pointer to actual timer part of the control block. */ | |
588 timer_ptr = &(timer -> tm_actual_timer); | |
589 | |
590 /* Determine what type of request is present. */ | |
591 if ((enable == NU_ENABLE_TIMER) && (!timer -> tm_enabled)) | |
592 { | |
593 | |
594 /* Enable timer request is present and timer is currently disabled. */ | |
595 | |
596 /* Determine how to setup the remaining field in the actual timer. */ | |
597 if (timer -> tm_expirations) | |
598 | |
599 /* Use reschedule time since this timer has expired previously. */ | |
600 time = timer -> tm_reschedule_time; | |
601 else | |
602 | |
603 /* Use initial time since this timer has never expired. */ | |
604 time = timer -> tm_initial_time; | |
605 | |
606 /* Mark the application timer as enabled. */ | |
607 timer -> tm_enabled = NU_TRUE; | |
608 | |
609 /* Call the start timer routine to actually start the timer. */ | |
610 TMC_Start_Timer(&(timer -> tm_actual_timer), time); | |
611 } | |
612 else if ((enable == NU_DISABLE_TIMER) && (timer -> tm_enabled)) | |
613 { | |
614 | |
615 /* Disable timer request is present and timer is currently enabled. */ | |
616 TMC_Stop_Timer(timer_ptr); | |
617 | |
618 /* Mark the timer as disabled. */ | |
619 timer -> tm_enabled = NU_FALSE; | |
620 } | |
621 | |
622 #ifdef INCLUDE_PROVIEW | |
623 _RTProf_DumpTimer(RT_PROF_CONTROL_TIMER,timer,RT_PROF_OK); | |
624 #endif /* INCLUDE_PROVIEW */ | |
625 /* Release protection. */ | |
626 TCT_Unprotect(); | |
627 | |
628 /* Return to user mode */ | |
629 NU_USER_MODE(); | |
630 | |
631 /* Return the completion status. */ | |
632 return(NU_SUCCESS); | |
633 } | |
634 | |
635 | |
636 | |
637 |