annotate gsm-fw/gpf/osl/os_tim_ir.c @ 924:aac4d4b15d2f

gsm-fw: static DSP patch download enabled by default
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 19 Oct 2015 18:14:23 +0000
parents 9d80090a9e0c
children
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
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
3 * os_tim.obj in frame_na7_db_ir.lib from the Leonardo package,
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
4 * subsequently reworked by Space Falcon.
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
5 *
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
6 * The original decompilation has been contributed by Das Signal.
461
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 */
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 /* set of included headers from COFF symtab: */
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <stdio.h>
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "gpfconf.h" /* FreeCalypso addition */
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "../../nucleus/nucleus.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "typedefs.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "os.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "gdi.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 #include "os_types.h"
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 #include "os_glob.h"
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 T_OS_TIMER_ENTRY TimerTable[];
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 extern T_OS_TIMER_TABLE_ENTRY *p_list[];
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 os_time_to_tick_multiplier;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 extern unsigned os_tick_to_time_multiplier;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
25 extern unsigned volatile t_start_ticks;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
26 extern T_OS_TIMER_TABLE_ENTRY *t_running;
461
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 extern int used_timers;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 extern int next_t_handle;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 extern int volatile t_list_access;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 extern int max_used_timers;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 extern NU_SEMAPHORE TimSemCB;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 extern NU_TIMER os_timer_cb;
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
34 #define BARRIER asm volatile ("": : :"memory")
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
35
461
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 void
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 timer_error(int err)
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 {
7017da4978bb OSL: os_tim_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 }
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
40
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
41 /* forward declaration */
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
42 void os_Timeout(UNSIGNED t_handle);
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
43
466
d43bf2d301de os_tim_ir.c: os_remove_timer_from_list(): minor cosmetic polish
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 465
diff changeset
44 static int
d43bf2d301de os_tim_ir.c: os_remove_timer_from_list(): minor cosmetic polish
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 465
diff changeset
45 os_remove_timer_from_list(T_OS_TIMER_TABLE_ENTRY *timer)
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
46 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
47 OS_TICK c_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
48
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
49 if (timer != t_running) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
50 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
51 timer->next->r_ticks += timer->r_ticks;
466
d43bf2d301de os_tim_ir.c: os_remove_timer_from_list(): minor cosmetic polish
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 465
diff changeset
52 } else {
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
53 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
54 if (timer->next == timer) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
55 t_running = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
56 } else {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
57 timer->next->r_ticks =
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
58 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
59 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
60 t_running = timer->next;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
61 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
62 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
63 if (t_running != NULL) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
64 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
65 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
66 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
67 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
68 NU_ENABLE_TIMER);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
69 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
70 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
71 if (timer->next != timer) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
72 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
73 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
74 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
75 timer->next = NULL;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
76 timer->prev = NULL;
481
5639b4fa8672 os_tim_{fl,ir}.c: use TMR_* constant definitions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 472
diff changeset
77 timer->status = TMR_USED;
5639b4fa8672 os_tim_{fl,ir}.c: use TMR_* constant definitions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 472
diff changeset
78 return TMR_USED;
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
79 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
80
467
aa9aec3ba437 os_tim_ir.c: os_add_timer_to_list(): minor polish
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 466
diff changeset
81 static unsigned
aa9aec3ba437 os_tim_ir.c: os_add_timer_to_list(): minor polish
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 466
diff changeset
82 os_add_timer_to_list(T_OS_TIMER_TABLE_ENTRY *timer, OS_TICK ticks)
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
83 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
84 T_OS_TIMER_TABLE_ENTRY *t_list;
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
85 OS_TICK c_ticks, e_ticks, r1_ticks, return_ticks;
464
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 if (ticks == 0)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
88 ticks = 1;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
89
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
90 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
91 t_list = t_running;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
92 if (t_list != NULL) {
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
93 e_ticks = c_ticks - t_start_ticks;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
94 if (t_list->r_ticks >= e_ticks) {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
95 r1_ticks = t_list->r_ticks - e_ticks;
467
aa9aec3ba437 os_tim_ir.c: os_add_timer_to_list(): minor polish
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 466
diff changeset
96 t_list->r_ticks = r1_ticks;
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
97 } else {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
98 r1_ticks = 0;
467
aa9aec3ba437 os_tim_ir.c: os_add_timer_to_list(): minor polish
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 466
diff changeset
99 t_list->r_ticks = 0;
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
100 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
101 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
102 return_ticks = 0;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
103 while (ticks >= r1_ticks) {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
104 ticks -= r1_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
105 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
106 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
107 goto out;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
108 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
109 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
110 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
111 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
112 t_running = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
113 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
114 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
115 return_ticks = 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 out:
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
118 timer->next = t_list;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
119 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
120 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
121 t_list->prev = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
122 timer->r_ticks = ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
123 } else {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
124 timer->next = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
125 timer->prev = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
126 timer->r_ticks = ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
127 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
128 t_running = timer;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
129 return_ticks = ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
130 }
481
5639b4fa8672 os_tim_{fl,ir}.c: use TMR_* constant definitions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 472
diff changeset
131 timer->status = TMR_ACTIVE;
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
132 return return_ticks;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
133 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
134
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
135 void
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
136 os_Timeout(UNSIGNED t_handle) /* argument is unused */
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
137 {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
138 ULONG s_ticks;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
139 OS_HANDLE task_handle, e_handle;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
140 USHORT t_index;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
141 int i, done;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
142 T_OS_TIMER_TABLE_ENTRY **t_r4;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
143 T_OS_TIMER_TABLE_ENTRY *timer;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
144 void (*timeout_func) (OS_HANDLE, OS_HANDLE, USHORT);
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
145
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
146 if (t_list_access) {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
147 t_start_ticks++;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
148 NU_Reset_Timer(&os_timer_cb, os_Timeout, 1, 0,
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
149 NU_ENABLE_TIMER);
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
150 return;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
151 }
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
152
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
153 timer = t_running;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
154 if (timer) {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
155 s_ticks = 0;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
156 done = 0;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
157 i = 0;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
158 do {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
159 timeout_func = timer->TimeoutProc;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
160 if (timer->p_ticks)
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
161 p_list[i++] = timer;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
162 task_handle = timer->task_handle;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
163 e_handle = timer->entity_handle;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
164 t_index = timer->t_index;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
165 timer->status = TMR_USED;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
166 if (timer->next == timer) {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
167 t_running = NULL;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
168 done = 1;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
169 } else {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
170 timer->prev->next = timer->next;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
171 timer->next->prev = timer->prev;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
172 if (timer->next->r_ticks) {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
173 t_running = timer->next;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
174 s_ticks = timer->next->r_ticks;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
175 done = 1;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
176 } else
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
177 timer = timer->next;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
178 }
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
179 timeout_func(task_handle, e_handle, t_index);
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
180 }
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
181 while (!done);
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
182
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
183 if (s_ticks) {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
184 t_start_ticks = NU_Retrieve_Clock();
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
185 NU_Reset_Timer(&os_timer_cb, os_Timeout, s_ticks, 0,
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
186 NU_ENABLE_TIMER);
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
187 }
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
188 }
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
189 for (t_r4 = p_list; *t_r4; t_r4++) {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
190 timer = *t_r4;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
191 s_ticks = os_add_timer_to_list(timer, timer->p_ticks);
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
192 if (s_ticks)
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
193 NU_Reset_Timer(&os_timer_cb, os_Timeout, s_ticks, 0,
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
194 NU_ENABLE_TIMER);
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
195 *t_r4 = NULL;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
196 }
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
197 }
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
198
464
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 STATUS sts;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
206
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
207 if (TimerHandle > MaxSimultaneousTimer)
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
208 return(OS_ERROR);
464
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 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND);
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
211 if (timer->status == TMR_FREE) {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
212 if (sts == NU_SUCCESS)
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
213 NU_Release_Semaphore(&TimSemCB);
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
214 return(OS_ERROR);
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
215 }
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
216 t_list_access = 1;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
217 BARRIER;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
218 if (timer->status == TMR_ACTIVE)
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
219 os_remove_timer_from_list(timer);
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
220 timer->t_handle = TimerHandle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
221 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
222 timer->entity_handle = TaskHandle;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
223 timer->t_index = Index;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
224 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
225 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
226 if (ticks)
468
6389bfe95f23 os_tim_ir.c: os_StartTimer(): polish
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 467
diff changeset
227 NU_Reset_Timer(&os_timer_cb, os_Timeout, ticks, 0,
6389bfe95f23 os_tim_ir.c: os_StartTimer(): polish
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 467
diff changeset
228 NU_ENABLE_TIMER);
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
229 BARRIER;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
230 t_list_access = 0;
464
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 return OS_OK;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
234 }
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 GLOBAL LONG os_StopTimer(OS_HANDLE TaskHandle, OS_HANDLE TimerHandle)
469
5031958cea52 os_tim_ir.c: os_StopTimer(): comment fix
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 468
diff changeset
237 /* TaskHandle argument is unused */
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
238 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
239 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
240 STATUS sts;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
241
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
242 if (TimerHandle > MaxSimultaneousTimer)
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
243 return(OS_ERROR);
464
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];
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
245 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND);
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
246 if (timer_e->entry.status == TMR_FREE) {
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
247 if (sts == NU_SUCCESS)
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
248 NU_Release_Semaphore(&TimSemCB);
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
249 return OS_ERROR;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
250 }
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
251 t_list_access = 1;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
252 BARRIER;
481
5639b4fa8672 os_tim_{fl,ir}.c: use TMR_* constant definitions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 472
diff changeset
253 if (timer_e->entry.status == TMR_ACTIVE)
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
254 os_remove_timer_from_list(&timer_e->entry);
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
255 BARRIER;
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
256 t_list_access = 0;
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
257 if (sts == NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
258 NU_Release_Semaphore(&TimSemCB);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
259 return OS_OK;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
260 }
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 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
263 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
264 return OS_OK;
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
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
267 GLOBAL LONG os_DestroyTimer(OS_HANDLE TaskHandle, OS_HANDLE TimerHandle)
470
81b941dd415d os_tim_ir.c: os_DestroyTimer(): missed assignment line
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 469
diff changeset
268 /* TaskHandle argument is unused */
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
269 {
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
270 STATUS sts;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
271 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
272
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
273 if (TimerHandle > MaxSimultaneousTimer)
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
274 return(OS_ERROR);
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
275 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
276 timer_e = &TimerTable[TimerHandle];
482
9d80090a9e0c os_tim_{fl,ir}.c: timer list concurrency interlocks redesigned
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 481
diff changeset
277 if (timer_e->entry.status != TMR_USED) {
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
278 if (sts == NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
279 NU_Release_Semaphore(&TimSemCB);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
280 return OS_ERROR;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
281 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
282 timer_e->next_t_handle = next_t_handle;
470
81b941dd415d os_tim_ir.c: os_DestroyTimer(): missed assignment line
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 469
diff changeset
283 next_t_handle = TimerHandle;
481
5639b4fa8672 os_tim_{fl,ir}.c: use TMR_* constant definitions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 472
diff changeset
284 timer_e->entry.status = TMR_FREE;
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
285 used_timers--;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
286 if (sts == NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
287 NU_Release_Semaphore(&TimSemCB);
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
288 return OS_OK;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
289 }
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
290
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
291 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
292 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
293 OS_HANDLE *TimerHandle, OS_HANDLE MemPoolHandle)
471
c8b5a8e84ef7 os_tim_ir.c: os_CreateTimer(): minor fixes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 470
diff changeset
294 /* TaskHandle and MemPoolHandle arguments are unused */
464
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 STATUS sts;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
297 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
298
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
299 sts = NU_Obtain_Semaphore(&TimSemCB, NU_SUSPEND);
471
c8b5a8e84ef7 os_tim_ir.c: os_CreateTimer(): minor fixes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 470
diff changeset
300 if (next_t_handle == 0) { /* no free timers left */
464
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
301 if (sts == NU_SUCCESS)
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
302 NU_Release_Semaphore(&TimSemCB);
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];
481
5639b4fa8672 os_tim_{fl,ir}.c: use TMR_* constant definitions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 472
diff changeset
307 timer_e->entry.status = TMR_USED;
464
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;
471
c8b5a8e84ef7 os_tim_ir.c: os_CreateTimer(): minor fixes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 470
diff changeset
309 *TimerHandle = next_t_handle;
464
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 return OS_OK;
14d2a7f473c3 OSL: os_tim_ir.c reconstruction by Das Signal
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 461
diff changeset
317 }