FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/gpf/osl/os_tim_fl.c @ 459:38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 23 Jun 2014 06:54:40 +0000 |
parents | 705030e1e8b2 |
children | 9cacd09e8ef3 |
comparison
equal
deleted
inserted
replaced
458:705030e1e8b2 | 459:38afaeb194ea |
---|---|
24 | 24 |
25 unsigned os_time_to_tick_multiplier = TIME_TO_TICK_TDMA_FRAME_MULTIPLIER; | 25 unsigned os_time_to_tick_multiplier = TIME_TO_TICK_TDMA_FRAME_MULTIPLIER; |
26 unsigned os_tick_to_time_multiplier = TICK_TO_TIME_TDMA_FRAME_MULTIPLIER; | 26 unsigned os_tick_to_time_multiplier = TICK_TO_TIME_TDMA_FRAME_MULTIPLIER; |
27 | 27 |
28 unsigned t_start_ticks; | 28 unsigned t_start_ticks; |
29 T_OS_TIMER_TABLE_ENTRY *t_running; | 29 T_OS_TIMER_TABLE_ENTRY * volatile t_running; |
30 int used_timers; | 30 int used_timers; |
31 int next_t_handle; | 31 int next_t_handle; |
32 int t_list_access; | 32 int volatile t_list_access; |
33 int max_used_timers; | 33 int max_used_timers; |
34 NU_SEMAPHORE TimSemCB; | 34 NU_SEMAPHORE TimSemCB; |
35 NU_TIMER os_timer_cb; | 35 NU_TIMER os_timer_cb; |
36 | 36 |
37 GLOBAL LONG | 37 GLOBAL LONG |
110 } else | 110 } else |
111 TMD_Timer -= ticks; | 111 TMD_Timer -= ticks; |
112 } | 112 } |
113 return(OS_OK); | 113 return(OS_OK); |
114 } | 114 } |
115 | |
116 GLOBAL LONG | |
117 os_QueryTimer(OS_HANDLE TaskHandle, OS_HANDLE TimerHandle, | |
118 OS_TIME *RemainingTime) | |
119 { | |
120 T_OS_TIMER_TABLE_ENTRY *timer, *t_r0, *t_r3; | |
121 OS_TICK c_ticks, r_ticks, e_ticks; | |
122 STATUS sts; | |
123 | |
124 t_list_access = 1; | |
125 if (TimerHandle > MaxSimultaneousTimer) { | |
126 error_out: t_list_access = 0; | |
127 return(OS_ERROR); | |
128 } | |
129 timer = &TimerTable[TimerHandle].entry; | |
130 if (!timer->status) | |
131 goto error_out; | |
132 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND); | |
133 if (sts != NU_SUCCESS) | |
134 timer_error(15); | |
135 c_ticks = NU_Retrieve_Clock(); | |
136 e_ticks = c_ticks - t_start_ticks; | |
137 t_r0 = t_running; | |
138 *RemainingTime = 0; | |
139 t_r3 = t_running; | |
140 if (t_r0 == t_r3) | |
141 r_ticks = t_r0->r_ticks - e_ticks; | |
142 else | |
143 r_ticks = t_r0->r_ticks; | |
144 while (t_r0 != timer) { | |
145 t_r0 = t_r0->next; | |
146 if (t_r0 == t_r3) | |
147 goto out; | |
148 r_ticks += t_r0->r_ticks; | |
149 } | |
150 *RemainingTime = SYSTEM_TICKS_TO_TIME(r_ticks); | |
151 out: if (sts == NU_SUCCESS) | |
152 NU_Release_Semaphore(&TimSemCB); | |
153 t_list_access = 0; | |
154 return(OS_OK); | |
155 } |