annotate gsm-fw/gpf/osl/os_tim_ir.c @ 464:14d2a7f473c3

OSL: os_tim_ir.c reconstruction by Das Signal
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 26 Jun 2014 03:23:29 +0000
parents 7017da4978bb
children d5cf423dad3a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
461
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This C module is a reconstruction based on the disassembly of
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * os_tim.obj in frame_na7_db_ir.lib from the Leonardo package.
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 /* set of included headers from COFF symtab: */
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include "gpfconf.h" /* FreeCalypso addition */
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "../../nucleus/nucleus.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "typedefs.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "os.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "gdi.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "os_types.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "os_glob.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 extern T_OS_TIMER_ENTRY TimerTable[];
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 extern T_OS_TIMER_TABLE_ENTRY *p_list[];
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 extern unsigned os_time_to_tick_multiplier;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 extern unsigned os_tick_to_time_multiplier;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 extern unsigned t_start_ticks;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 extern T_OS_TIMER_TABLE_ENTRY * volatile t_running;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 extern int used_timers;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 extern int next_t_handle;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 extern int volatile t_list_access;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 extern int max_used_timers;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 extern NU_SEMAPHORE TimSemCB;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 extern NU_TIMER os_timer_cb;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 void
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 timer_error(int err)
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 {
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 }
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
35
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
36 /*
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
37 * The following function reconstructions have been contributed by Das Signal.
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
38 * The code passes gcc, but some polish is still likely needed.
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
39 */
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
40
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
41 /* FIXME: t_handle is unused?! */
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
42 void os_Timeout(UNSIGNED t_handle)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
43 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
44 UNSIGNED s_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
45 OS_HANDLE task_handle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
46 OS_HANDLE e_handle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
47 int t_index, i, done;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
48 T_OS_TIMER_TABLE_ENTRY **t_r4;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
49 T_OS_TIMER_TABLE_ENTRY *timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
50 void (*timeout_func) (OS_HANDLE, OS_HANDLE, USHORT);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
51 OS_TIME InitialTime;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
52
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
53 if (t_list_access) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
54 t_start_ticks++;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
55 NU_Reset_Timer(&os_timer_cb, os_Timeout, 1, 0,
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
56 NU_ENABLE_TIMER);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
57 return;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
58 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
59
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
60 t_list_access = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
61 timer = t_running;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
62 if (t_running) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
63 s_ticks = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
64 done = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
65 i = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
66 do {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
67 timeout_func = timer->TimeoutProc;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
68 if (timer->p_ticks)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
69 p_list[i++] = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
70 task_handle = timer->task_handle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
71 e_handle = timer->entity_handle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
72 t_index = timer->t_index;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
73 timer->status = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
74 if (timer->next == timer) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
75 t_running = NULL;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
76 done = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
77 } else {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
78 timer->prev->next = timer->next;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
79 timer->next->prev = timer->prev;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
80 if (timer->next->r_ticks) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
81 t_running = timer->next;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
82 s_ticks = timer->r_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
83 done = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
84 } else
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
85 timer = timer->next;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
86 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
87 /* FIXME: IND$CALL() ? */
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
88 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
89 while (!done);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
90
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
91 if (s_ticks) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
92 t_start_ticks = NU_Retrieve_Clock();
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
93 NU_Reset_Timer(&os_timer_cb, os_Timeout, s_ticks, 0,
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
94 NU_ENABLE_TIMER);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
95 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
96 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
97 for (t_r4 = p_list; *t_r4; t_r4++) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
98 timer = *t_r4;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
99 InitialTime = SYSTEM_TICKS_TO_TIME(timer->p_ticks);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
100 os_StartTimer(timer->entity_handle, timer->t_handle,
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
101 timer->t_index, InitialTime, InitialTime);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
102 *t_r4 = NULL;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
103 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
104
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
105 t_list_access = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
106 return;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
107 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
108
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
109 static int os_remove_timer_from_list(T_OS_TIMER_TABLE_ENTRY *timer)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
110 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
111 OS_TICK c_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
112
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
113 if (timer != t_running) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
114 if (timer->next != t_running)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
115 timer->next->r_ticks += timer->r_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
116 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
117 else {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
118 c_ticks = NU_Retrieve_Clock();
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
119 if (timer->next == timer) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
120 t_running = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
121 } else {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
122 timer->next->r_ticks =
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
123 t_start_ticks + timer->r_ticks +
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
124 timer->next->r_ticks - c_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
125 t_running = timer->next;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
126 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
127 NU_Control_Timer(&os_timer_cb, NU_DISABLE_TIMER);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
128 if (t_running != NULL) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
129 t_start_ticks = c_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
130 if (t_running->r_ticks != 0)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
131 NU_Reset_Timer(&os_timer_cb, os_Timeout,
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
132 t_running->r_ticks, 0,
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
133 NU_ENABLE_TIMER);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
134 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
135 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
136 if (timer->next != timer) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
137 timer->prev->next = timer->next;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
138 timer->next->prev = timer->prev;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
139 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
140 timer->next = NULL;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
141 timer->prev = NULL;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
142 timer->status = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
143 return 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
144 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
145
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
146 static unsigned os_add_timer_to_list(T_OS_TIMER_TABLE_ENTRY *timer, OS_TICK ticks)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
147 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
148 T_OS_TIMER_TABLE_ENTRY *t_list;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
149 OS_TICK c_ticks, r1_ticks, return_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
150
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
151 if (ticks == 0)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
152 ticks = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
153
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
154 c_ticks = NU_Retrieve_Clock();
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
155 t_list = t_running;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
156 if (t_list != NULL) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
157 if (t_running->r_ticks >= c_ticks - t_start_ticks) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
158 r1_ticks =
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
159 t_running->r_ticks - c_ticks + t_start_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
160 t_running->r_ticks = r1_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
161 } else {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
162 r1_ticks = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
163 t_running->r_ticks = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
164 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
165 t_start_ticks = c_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
166 return_ticks = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
167 while (ticks >= r1_ticks) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
168 ticks -= r1_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
169 t_list = t_list->next;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
170 if (t_list == t_running)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
171 goto out;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
172 r1_ticks = t_list->r_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
173 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
174 t_list->r_ticks -= ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
175 if (t_list == t_running) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
176 t_running = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
177 t_start_ticks = c_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
178 NU_Control_Timer(&os_timer_cb, NU_DISABLE_TIMER);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
179 return_ticks = ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
180 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
181 out:
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
182 timer->next = t_list;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
183 timer->prev = t_list->prev;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
184 t_list->prev->next = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
185 t_list->prev = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
186 timer->r_ticks = ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
187 } else {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
188 timer->next = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
189 timer->prev = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
190 timer->r_ticks = ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
191 t_start_ticks = c_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
192 t_running = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
193 return_ticks = ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
194 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
195 timer->status = 2;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
196 return return_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
197 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
198
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
199 GLOBAL LONG os_StartTimer(OS_HANDLE TaskHandle, OS_HANDLE TimerHandle,
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
200 USHORT Index, OS_TIME InitialTime,
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
201 OS_TIME RescheduleTime)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
202 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
203 T_OS_TIMER_TABLE_ENTRY *timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
204 OS_TICK ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
205 USHORT status;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
206 STATUS sts;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
207
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
208 t_list_access = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
209 timer = &TimerTable[TimerHandle].entry;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
210 if (TimerHandle > MaxSimultaneousTimer || timer->status == 0) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
211 t_list_access = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
212 return OS_ERROR;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
213 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
214
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
215 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
216 /* FIXME: not sure about this
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
217 if (sts != NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
218 os_MyHandle(sts);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
219 */
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
220 status = timer->status;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
221 if (status == 2)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
222 status = os_remove_timer_from_list(timer);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
223 timer->t_handle = TimerHandle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
224 timer->task_handle = os_MyHandle();
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
225 timer->entity_handle = TaskHandle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
226 timer->t_index = Index;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
227 timer->p_ticks = TIME_TO_SYSTEM_TICKS(RescheduleTime);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
228 ticks = os_add_timer_to_list(timer, TIME_TO_SYSTEM_TICKS(InitialTime));
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
229 if (ticks)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
230 NU_Reset_Timer(&os_timer_cb, os_Timeout, ticks, 0, NU_ENABLE_TIMER);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
231 if (sts == NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
232 NU_Release_Semaphore(&TimSemCB);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
233 t_list_access = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
234 return OS_OK;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
235 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
236
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
237 /* FIXME: TaskHandle is unused?! */
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
238 GLOBAL LONG os_StopTimer(OS_HANDLE TaskHandle, OS_HANDLE TimerHandle)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
239 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
240 T_OS_TIMER_ENTRY *timer_e;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
241 STATUS sts;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
242
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
243 t_list_access = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
244 timer_e = &TimerTable[TimerHandle];
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
245 if (TimerHandle > MaxSimultaneousTimer || timer_e->entry.status == 0) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
246 t_list_access = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
247 return OS_ERROR;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
248 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
249 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
250 if (timer_e->entry.status == 2)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
251 os_remove_timer_from_list(&timer_e->entry);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
252 if (sts == NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
253 NU_Release_Semaphore(&TimSemCB);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
254 t_list_access = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
255 return OS_OK;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
256 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
257
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
258 GLOBAL LONG os_IncrementTick(OS_TICK ticks)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
259 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
260 return OS_OK;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
261 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
262
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
263 /* FIXME: TaskHandle is unused?! */
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
264 GLOBAL LONG os_DestroyTimer(OS_HANDLE TaskHandle, OS_HANDLE TimerHandle)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
265 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
266 STATUS sts;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
267 T_OS_TIMER_ENTRY *timer_e;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
268
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
269 t_list_access = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
270 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
271 timer_e = &TimerTable[TimerHandle];
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
272 if (TimerHandle > MaxSimultaneousTimer || timer_e->entry.status == 0) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
273 if (sts == NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
274 NU_Release_Semaphore(&TimSemCB);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
275 t_list_access = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
276 return OS_ERROR;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
277 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
278 timer_e->next_t_handle = next_t_handle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
279 timer_e->entry.status = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
280 used_timers--;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
281 t_list_access = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
282 if (sts == NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
283 NU_Release_Semaphore(&TimSemCB);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
284 return OS_OK;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
285 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
286
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
287 /* FIXME: TaskHandle and MemPoolHandle are unused?! */
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
288 GLOBAL LONG os_CreateTimer(OS_HANDLE TaskHandle,
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
289 void (*TimeoutProc) (OS_HANDLE, OS_HANDLE, USHORT),
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
290 OS_HANDLE *TimerHandle, OS_HANDLE MemPoolHandle)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
291 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
292 STATUS sts;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
293 OS_HANDLE orig_next_t_handle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
294 T_OS_TIMER_ENTRY *timer_e;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
295
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
296 t_list_access = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
297 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
298 orig_next_t_handle = next_t_handle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
299 if (next_t_handle == 0) { /* INVALID_HANDLE */
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
300 if (sts == NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
301 NU_Release_Semaphore(&TimSemCB);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
302 t_list_access = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
303 return OS_ERROR;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
304 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
305
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
306 timer_e = &TimerTable[next_t_handle];
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
307 timer_e->entry.status = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
308 timer_e->entry.TimeoutProc = TimeoutProc;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
309 *TimerHandle = orig_next_t_handle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
310 next_t_handle = timer_e->next_t_handle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
311 used_timers++;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
312 if (max_used_timers < used_timers)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
313 max_used_timers = used_timers;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
314 if (sts == NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
315 NU_Release_Semaphore(&TimSemCB);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
316 t_list_access = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
317 return OS_OK;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
318 }