# HG changeset patch # User Michael Spacefalcon # Date 1403506480 0 # Node ID 38afaeb194ea7eacb737293873efa84be05fa23a # Parent 705030e1e8b25e58b3b015b259db580be23a1785 os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic diff -r 705030e1e8b2 -r 38afaeb194ea gsm-fw/gpf/osl/os_tim_fl.c --- a/gsm-fw/gpf/osl/os_tim_fl.c Mon Jun 23 05:44:03 2014 +0000 +++ b/gsm-fw/gpf/osl/os_tim_fl.c Mon Jun 23 06:54:40 2014 +0000 @@ -26,10 +26,10 @@ unsigned os_tick_to_time_multiplier = TICK_TO_TIME_TDMA_FRAME_MULTIPLIER; unsigned t_start_ticks; -T_OS_TIMER_TABLE_ENTRY *t_running; +T_OS_TIMER_TABLE_ENTRY * volatile t_running; int used_timers; int next_t_handle; -int t_list_access; +int volatile t_list_access; int max_used_timers; NU_SEMAPHORE TimSemCB; NU_TIMER os_timer_cb; @@ -112,3 +112,44 @@ } return(OS_OK); } + +GLOBAL LONG +os_QueryTimer(OS_HANDLE TaskHandle, OS_HANDLE TimerHandle, + OS_TIME *RemainingTime) +{ + T_OS_TIMER_TABLE_ENTRY *timer, *t_r0, *t_r3; + OS_TICK c_ticks, r_ticks, e_ticks; + STATUS sts; + + t_list_access = 1; + if (TimerHandle > MaxSimultaneousTimer) { +error_out: t_list_access = 0; + return(OS_ERROR); + } + timer = &TimerTable[TimerHandle].entry; + if (!timer->status) + goto error_out; + sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND); + if (sts != NU_SUCCESS) + timer_error(15); + c_ticks = NU_Retrieve_Clock(); + e_ticks = c_ticks - t_start_ticks; + t_r0 = t_running; + *RemainingTime = 0; + t_r3 = t_running; + if (t_r0 == t_r3) + r_ticks = t_r0->r_ticks - e_ticks; + else + r_ticks = t_r0->r_ticks; + while (t_r0 != timer) { + t_r0 = t_r0->next; + if (t_r0 == t_r3) + goto out; + r_ticks += t_r0->r_ticks; + } + *RemainingTime = SYSTEM_TICKS_TO_TIME(r_ticks); +out: if (sts == NU_SUCCESS) + NU_Release_Semaphore(&TimSemCB); + t_list_access = 0; + return(OS_OK); +}