comparison gsm-fw/gpf/osl/os_tim_ir.c @ 481:5639b4fa8672

os_tim_{fl,ir}.c: use TMR_* constant definitions
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 29 Jun 2014 04:06:24 +0000
parents 6adbacc0f255
children 9d80090a9e0c
comparison
equal deleted inserted replaced
480:334a3381f569 481:5639b4fa8672
68 if (timer->p_ticks) 68 if (timer->p_ticks)
69 p_list[i++] = timer; 69 p_list[i++] = timer;
70 task_handle = timer->task_handle; 70 task_handle = timer->task_handle;
71 e_handle = timer->entity_handle; 71 e_handle = timer->entity_handle;
72 t_index = timer->t_index; 72 t_index = timer->t_index;
73 timer->status = 1; 73 timer->status = TMR_USED;
74 if (timer->next == timer) { 74 if (timer->next == timer) {
75 t_running = NULL; 75 t_running = NULL;
76 done = 1; 76 done = 1;
77 } else { 77 } else {
78 timer->prev->next = timer->next; 78 timer->prev->next = timer->next;
137 timer->prev->next = timer->next; 137 timer->prev->next = timer->next;
138 timer->next->prev = timer->prev; 138 timer->next->prev = timer->prev;
139 } 139 }
140 timer->next = NULL; 140 timer->next = NULL;
141 timer->prev = NULL; 141 timer->prev = NULL;
142 timer->status = 1; 142 timer->status = TMR_USED;
143 return 1; 143 return TMR_USED;
144 } 144 }
145 145
146 static unsigned 146 static unsigned
147 os_add_timer_to_list(T_OS_TIMER_TABLE_ENTRY *timer, OS_TICK ticks) 147 os_add_timer_to_list(T_OS_TIMER_TABLE_ENTRY *timer, OS_TICK ticks)
148 { 148 {
190 timer->r_ticks = ticks; 190 timer->r_ticks = ticks;
191 t_start_ticks = c_ticks; 191 t_start_ticks = c_ticks;
192 t_running = timer; 192 t_running = timer;
193 return_ticks = ticks; 193 return_ticks = ticks;
194 } 194 }
195 timer->status = 2; 195 timer->status = TMR_ACTIVE;
196 return return_ticks; 196 return return_ticks;
197 } 197 }
198 198
199 GLOBAL LONG os_StartTimer(OS_HANDLE TaskHandle, OS_HANDLE TimerHandle, 199 GLOBAL LONG os_StartTimer(OS_HANDLE TaskHandle, OS_HANDLE TimerHandle,
200 USHORT Index, OS_TIME InitialTime, 200 USHORT Index, OS_TIME InitialTime,
205 USHORT status; 205 USHORT status;
206 STATUS sts; 206 STATUS sts;
207 207
208 t_list_access = 1; 208 t_list_access = 1;
209 timer = &TimerTable[TimerHandle].entry; 209 timer = &TimerTable[TimerHandle].entry;
210 if (TimerHandle > MaxSimultaneousTimer || timer->status == 0) { 210 if (TimerHandle > MaxSimultaneousTimer || timer->status == TMR_FREE) {
211 t_list_access = 0; 211 t_list_access = 0;
212 return OS_ERROR; 212 return OS_ERROR;
213 } 213 }
214 214
215 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND); 215 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND);
216 /* Disassembly reveals this bogon in the original code: 216 /* Disassembly reveals this bogon in the original code:
217 if (sts != NU_SUCCESS) 217 if (sts != NU_SUCCESS)
218 os_MyHandle(); 218 os_MyHandle();
219 */ 219 */
220 status = timer->status; 220 status = timer->status;
221 if (status == 2) 221 if (status == TMR_ACTIVE)
222 status = os_remove_timer_from_list(timer); 222 status = os_remove_timer_from_list(timer);
223 timer->t_handle = TimerHandle; 223 timer->t_handle = TimerHandle;
224 timer->task_handle = os_MyHandle(); 224 timer->task_handle = os_MyHandle();
225 timer->entity_handle = TaskHandle; 225 timer->entity_handle = TaskHandle;
226 timer->t_index = Index; 226 timer->t_index = Index;
241 T_OS_TIMER_ENTRY *timer_e; 241 T_OS_TIMER_ENTRY *timer_e;
242 STATUS sts; 242 STATUS sts;
243 243
244 t_list_access = 1; 244 t_list_access = 1;
245 timer_e = &TimerTable[TimerHandle]; 245 timer_e = &TimerTable[TimerHandle];
246 if (TimerHandle > MaxSimultaneousTimer || timer_e->entry.status == 0) { 246 if (TimerHandle > MaxSimultaneousTimer ||
247 timer_e->entry.status == TMR_FREE) {
247 t_list_access = 0; 248 t_list_access = 0;
248 return OS_ERROR; 249 return OS_ERROR;
249 } 250 }
250 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND); 251 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND);
251 if (timer_e->entry.status == 2) 252 if (timer_e->entry.status == TMR_ACTIVE)
252 os_remove_timer_from_list(&timer_e->entry); 253 os_remove_timer_from_list(&timer_e->entry);
253 if (sts == NU_SUCCESS) 254 if (sts == NU_SUCCESS)
254 NU_Release_Semaphore(&TimSemCB); 255 NU_Release_Semaphore(&TimSemCB);
255 t_list_access = 0; 256 t_list_access = 0;
256 return OS_OK; 257 return OS_OK;
268 T_OS_TIMER_ENTRY *timer_e; 269 T_OS_TIMER_ENTRY *timer_e;
269 270
270 t_list_access = 1; 271 t_list_access = 1;
271 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND); 272 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND);
272 timer_e = &TimerTable[TimerHandle]; 273 timer_e = &TimerTable[TimerHandle];
273 if (TimerHandle > MaxSimultaneousTimer || timer_e->entry.status == 0) { 274 if (TimerHandle > MaxSimultaneousTimer ||
275 timer_e->entry.status == TMR_FREE) {
274 if (sts == NU_SUCCESS) 276 if (sts == NU_SUCCESS)
275 NU_Release_Semaphore(&TimSemCB); 277 NU_Release_Semaphore(&TimSemCB);
276 t_list_access = 0; 278 t_list_access = 0;
277 return OS_ERROR; 279 return OS_ERROR;
278 } 280 }
279 timer_e->next_t_handle = next_t_handle; 281 timer_e->next_t_handle = next_t_handle;
280 next_t_handle = TimerHandle; 282 next_t_handle = TimerHandle;
281 timer_e->entry.status = 0; 283 timer_e->entry.status = TMR_FREE;
282 used_timers--; 284 used_timers--;
283 t_list_access = 0; 285 t_list_access = 0;
284 if (sts == NU_SUCCESS) 286 if (sts == NU_SUCCESS)
285 NU_Release_Semaphore(&TimSemCB); 287 NU_Release_Semaphore(&TimSemCB);
286 return OS_OK; 288 return OS_OK;
302 t_list_access = 0; 304 t_list_access = 0;
303 return OS_ERROR; 305 return OS_ERROR;
304 } 306 }
305 307
306 timer_e = &TimerTable[next_t_handle]; 308 timer_e = &TimerTable[next_t_handle];
307 timer_e->entry.status = 1; 309 timer_e->entry.status = TMR_USED;
308 timer_e->entry.TimeoutProc = TimeoutProc; 310 timer_e->entry.TimeoutProc = TimeoutProc;
309 *TimerHandle = next_t_handle; 311 *TimerHandle = next_t_handle;
310 next_t_handle = timer_e->next_t_handle; 312 next_t_handle = timer_e->next_t_handle;
311 used_timers++; 313 used_timers++;
312 if (max_used_timers < used_timers) 314 if (max_used_timers < used_timers)