comparison gsm-fw/gpf/osl/os_tim_ir.c @ 465:d5cf423dad3a

os_tim_ir.c: os_Timeout() fixed
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 26 Jun 2014 04:46:53 +0000
parents 14d2a7f473c3
children d43bf2d301de
comparison
equal deleted inserted replaced
464:14d2a7f473c3 465:d5cf423dad3a
36 /* 36 /*
37 * The following function reconstructions have been contributed by Das Signal. 37 * The following function reconstructions have been contributed by Das Signal.
38 * The code passes gcc, but some polish is still likely needed. 38 * The code passes gcc, but some polish is still likely needed.
39 */ 39 */
40 40
41 /* FIXME: t_handle is unused?! */ 41 void
42 void os_Timeout(UNSIGNED t_handle) 42 os_Timeout(UNSIGNED t_handle) /* argument is unused */
43 { 43 {
44 UNSIGNED s_ticks; 44 ULONG s_ticks;
45 OS_HANDLE task_handle; 45 OS_HANDLE task_handle, e_handle;
46 OS_HANDLE e_handle; 46 USHORT t_index;
47 int t_index, i, done; 47 int i, done;
48 T_OS_TIMER_TABLE_ENTRY **t_r4; 48 T_OS_TIMER_TABLE_ENTRY **t_r4;
49 T_OS_TIMER_TABLE_ENTRY *timer; 49 T_OS_TIMER_TABLE_ENTRY *timer;
50 void (*timeout_func) (OS_HANDLE, OS_HANDLE, USHORT); 50 void (*timeout_func) (OS_HANDLE, OS_HANDLE, USHORT);
51 OS_TIME InitialTime; 51 OS_TIME resched_time;
52 52
53 if (t_list_access) { 53 if (t_list_access) {
54 t_start_ticks++; 54 t_start_ticks++;
55 NU_Reset_Timer(&os_timer_cb, os_Timeout, 1, 0, 55 NU_Reset_Timer(&os_timer_cb, os_Timeout, 1, 0,
56 NU_ENABLE_TIMER); 56 NU_ENABLE_TIMER);
57 return; 57 return;
58 } 58 }
59 59
60 t_list_access = 1; 60 t_list_access = 1;
61 timer = t_running; 61 timer = t_running;
62 if (t_running) { 62 if (timer) {
63 s_ticks = 0; 63 s_ticks = 0;
64 done = 0; 64 done = 0;
65 i = 0; 65 i = 0;
66 do { 66 do {
67 timeout_func = timer->TimeoutProc; 67 timeout_func = timer->TimeoutProc;
77 } else { 77 } else {
78 timer->prev->next = timer->next; 78 timer->prev->next = timer->next;
79 timer->next->prev = timer->prev; 79 timer->next->prev = timer->prev;
80 if (timer->next->r_ticks) { 80 if (timer->next->r_ticks) {
81 t_running = timer->next; 81 t_running = timer->next;
82 s_ticks = timer->r_ticks; 82 s_ticks = timer->next->r_ticks;
83 done = 1; 83 done = 1;
84 } else 84 } else
85 timer = timer->next; 85 timer = timer->next;
86 } 86 }
87 /* FIXME: IND$CALL() ? */ 87 timeout_func(task_handle, e_handle, t_index);
88 } 88 }
89 while (!done); 89 while (!done);
90 90
91 if (s_ticks) { 91 if (s_ticks) {
92 t_start_ticks = NU_Retrieve_Clock(); 92 t_start_ticks = NU_Retrieve_Clock();
94 NU_ENABLE_TIMER); 94 NU_ENABLE_TIMER);
95 } 95 }
96 } 96 }
97 for (t_r4 = p_list; *t_r4; t_r4++) { 97 for (t_r4 = p_list; *t_r4; t_r4++) {
98 timer = *t_r4; 98 timer = *t_r4;
99 InitialTime = SYSTEM_TICKS_TO_TIME(timer->p_ticks); 99 resched_time = SYSTEM_TICKS_TO_TIME(timer->p_ticks);
100 os_StartTimer(timer->entity_handle, timer->t_handle, 100 os_StartTimer(timer->entity_handle, timer->t_handle,
101 timer->t_index, InitialTime, InitialTime); 101 timer->t_index, resched_time, resched_time);
102 *t_r4 = NULL; 102 *t_r4 = NULL;
103 } 103 }
104 104
105 t_list_access = 0; 105 t_list_access = 0;
106 return; 106 return;