FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/gpf/osl/os_tim_fl.c @ 475:dcb543907cbb
os_mem_fl.c: os_CreatePartitionPool(): fixed error check logic
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 27 Jun 2014 02:24:27 +0000 |
parents | 9cacd09e8ef3 |
children | 5639b4fa8672 |
rev | line source |
---|---|
454
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This C module is a reconstruction based on the disassembly of |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * os_tim.obj in frame_na7_db_fl.lib from the Leonardo package. |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 /* set of included headers from COFF symtab: */ |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdio.h> |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include "gpfconf.h" /* FreeCalypso addition */ |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include "../../nucleus/nucleus.h" |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "typedefs.h" |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "os.h" |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "gdi.h" |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "os_types.h" |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "os_glob.h" |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 extern UNSIGNED TMD_Timer; |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 extern INT TMD_Timer_State; |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 extern T_OS_TIMER_ENTRY TimerTable[]; |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 extern T_OS_TIMER_TABLE_ENTRY *p_list[]; |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 |
457
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
22 extern void os_Timeout(UNSIGNED t_handle); |
454
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 extern void timer_error(int err); |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 unsigned os_time_to_tick_multiplier = TIME_TO_TICK_TDMA_FRAME_MULTIPLIER; |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 unsigned os_tick_to_time_multiplier = TICK_TO_TIME_TDMA_FRAME_MULTIPLIER; |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 unsigned t_start_ticks; |
459
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
29 T_OS_TIMER_TABLE_ENTRY * volatile t_running; |
454
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 int used_timers; |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 int next_t_handle; |
459
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
32 int volatile t_list_access; |
454
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 int max_used_timers; |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 NU_SEMAPHORE TimSemCB; |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 NU_TIMER os_timer_cb; |
8d5a9f254dfc
OSL: os_tim_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 |
455
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
37 GLOBAL LONG |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
38 os_set_tick(int os_system_tick) |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
39 { |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
40 switch (os_system_tick) { |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
41 case SYSTEM_TICK_TDMA_FRAME: |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
42 os_time_to_tick_multiplier = TIME_TO_TICK_TDMA_FRAME_MULTIPLIER; |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
43 os_tick_to_time_multiplier = TICK_TO_TIME_TDMA_FRAME_MULTIPLIER; |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
44 return(OS_OK); |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
45 case SYSTEM_TICK_10_MS: |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
46 os_time_to_tick_multiplier = TIME_TO_TICK_10MS_MULTIPLIER; |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
47 os_tick_to_time_multiplier = TICK_TO_TIME_10MS_MULTIPLIER; |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
48 return(OS_OK); |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
49 default: |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
50 return(OS_ERROR); |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
51 } |
2081103418e9
os_tim_fl.c: os_set_tick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
454
diff
changeset
|
52 } |
456
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
53 |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
54 GLOBAL LONG |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
55 os_TimerInformation(USHORT Index, char *Buffer) |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
56 { |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
57 static int t_info_read; |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
58 |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
59 if (t_info_read) { |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
60 t_info_read = 0; |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
61 return(OS_ERROR); |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
62 } |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
63 sprintf(Buffer, "Maximum %d of %d available timers running", |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
64 max_used_timers, MaxSimultaneousTimer); |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
65 t_info_read = 1; |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
66 return(OS_OK); |
6e54a3fb01b9
os_tim_fl.c: os_TimerInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
455
diff
changeset
|
67 } |
457
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
68 |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
69 GLOBAL LONG |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
70 os_TimInit(void) |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
71 { |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
72 int i; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
73 |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
74 if (NU_Create_Semaphore(&TimSemCB, "TIMSEM", 1, NU_PRIORITY) |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
75 != NU_SUCCESS) |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
76 return(OS_ERROR); |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
77 if (NU_Create_Timer(&os_timer_cb, "OS_TIMER", os_Timeout, 0, 1, 0, |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
78 NU_DISABLE_TIMER) != NU_SUCCESS) |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
79 return(OS_ERROR); |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
80 used_timers = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
81 max_used_timers = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
82 next_t_handle = 1; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
83 t_list_access = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
84 t_start_ticks = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
85 p_list[0] = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
86 for (i = 1; i < MaxSimultaneousTimer; i++) { |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
87 TimerTable[i].entry.status = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
88 TimerTable[i].entry.next = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
89 TimerTable[i].entry.prev = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
90 TimerTable[i].next_t_handle = i + 1; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
91 p_list[i] = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
92 } |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
93 TimerTable[MaxSimultaneousTimer].entry.status = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
94 TimerTable[MaxSimultaneousTimer].next_t_handle = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
95 t_running = 0; |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
96 return(OS_OK); |
103b06ef644a
os_tim_fl.c: os_TimInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
456
diff
changeset
|
97 } |
458
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
98 |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
99 GLOBAL LONG |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
100 os_RecoverTick(OS_TICK ticks) |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
101 { |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
102 UNSIGNED current_system_clock; |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
103 |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
104 current_system_clock = NU_Retrieve_Clock(); |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
105 NU_Set_Clock(current_system_clock + ticks); |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
106 if (TMD_Timer_State == TM_ACTIVE) { |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
107 if (TMD_Timer <= ticks) { |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
108 TMD_Timer_State = TM_EXPIRED; |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
109 TMD_Timer = 0; |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
110 } else |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
111 TMD_Timer -= ticks; |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
112 } |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
113 return(OS_OK); |
705030e1e8b2
os_tim_fl.c: os_RecoverTick() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
457
diff
changeset
|
114 } |
459
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
115 |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
116 GLOBAL LONG |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
117 os_QueryTimer(OS_HANDLE TaskHandle, OS_HANDLE TimerHandle, |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
118 OS_TIME *RemainingTime) |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
119 { |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
120 T_OS_TIMER_TABLE_ENTRY *timer, *t_r0, *t_r3; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
121 OS_TICK c_ticks, r_ticks, e_ticks; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
122 STATUS sts; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
123 |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
124 t_list_access = 1; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
125 if (TimerHandle > MaxSimultaneousTimer) { |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
126 error_out: t_list_access = 0; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
127 return(OS_ERROR); |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
128 } |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
129 timer = &TimerTable[TimerHandle].entry; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
130 if (!timer->status) |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
131 goto error_out; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
132 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND); |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
133 if (sts != NU_SUCCESS) |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
134 timer_error(15); |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
135 c_ticks = NU_Retrieve_Clock(); |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
136 e_ticks = c_ticks - t_start_ticks; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
137 t_r0 = t_running; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
138 *RemainingTime = 0; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
139 t_r3 = t_running; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
140 if (t_r0 == t_r3) |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
141 r_ticks = t_r0->r_ticks - e_ticks; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
142 else |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
143 r_ticks = t_r0->r_ticks; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
144 while (t_r0 != timer) { |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
145 t_r0 = t_r0->next; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
146 if (t_r0 == t_r3) |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
147 goto out; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
148 r_ticks += t_r0->r_ticks; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
149 } |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
150 *RemainingTime = SYSTEM_TICKS_TO_TIME(r_ticks); |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
151 out: if (sts == NU_SUCCESS) |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
152 NU_Release_Semaphore(&TimSemCB); |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
153 t_list_access = 0; |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
154 return(OS_OK); |
38afaeb194ea
os_tim_fl.c: os_QueryTimer() decompiled w/o real understanding of the logic
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
458
diff
changeset
|
155 } |
460
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
156 |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
157 GLOBAL LONG |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
158 os_InactivityTicks(int *next_event, OS_TICK *next_event_ticks) |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
159 { |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
160 *next_event = 1; |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
161 switch (TMD_Timer_State) { |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
162 case TM_ACTIVE: |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
163 *next_event_ticks = TMD_Timer; |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
164 return(OS_OK); |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
165 case TM_NOT_ACTIVE: |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
166 *next_event_ticks = 0; |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
167 *next_event = 0; |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
168 return(OS_OK); |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
169 default: |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
170 *next_event_ticks = 0; |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
171 return(OS_OK); |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
172 } |
9cacd09e8ef3
OSL: os_tim_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
459
diff
changeset
|
173 } |