1 | /* |
---|
2 | * COPYRIGHT (c) 1989-1999. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.OARcorp.com/rtems/license.html. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #if HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <itron.h> |
---|
17 | |
---|
18 | #include <rtems/score/thread.h> |
---|
19 | #include <rtems/score/tod.h> |
---|
20 | |
---|
21 | #include <rtems/itron/time.h> |
---|
22 | |
---|
23 | /* |
---|
24 | * set_tim - Set System Clock |
---|
25 | */ |
---|
26 | |
---|
27 | void converTime(SYSTIME ms, TOD_Control *time) |
---|
28 | { |
---|
29 | int millisecond; |
---|
30 | |
---|
31 | /* XXX need to dereference structure */ |
---|
32 | #if 0 |
---|
33 | milisecond = ms % 1000; |
---|
34 | tempSecond = ms / 1000; |
---|
35 | #else |
---|
36 | millisecond = 0; |
---|
37 | #endif |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | /* |
---|
42 | * set_tim - Set System Clock |
---|
43 | */ |
---|
44 | |
---|
45 | ER set_tim( |
---|
46 | SYSTIME *pk_tim |
---|
47 | ) |
---|
48 | { |
---|
49 | Watchdog_Interval temp; /* an integer in seconds after conversion from SYSTIME */ |
---|
50 | TOD_Control the_tod; |
---|
51 | |
---|
52 | /* convert *pk_tim which is 48 bits integer in binary into an ordinary |
---|
53 | integer in milliseconds */ |
---|
54 | |
---|
55 | /* XXX */ temp = 0; |
---|
56 | if(temp > 0) { |
---|
57 | _Thread_Disable_dispatch(); |
---|
58 | _TOD_Set(&the_tod, temp); |
---|
59 | _Thread_Enable_dispatch(); |
---|
60 | if(_TOD_Validate(&the_tod)){ |
---|
61 | return E_OK; |
---|
62 | } |
---|
63 | } |
---|
64 | return E_SYS; |
---|
65 | } |
---|
66 | |
---|
67 | /* |
---|
68 | * get_tim - Get System Clock |
---|
69 | */ |
---|
70 | |
---|
71 | ER get_tim( |
---|
72 | SYSTIME *pk_tim |
---|
73 | ) |
---|
74 | { |
---|
75 | return E_OK; |
---|
76 | } |
---|
77 | |
---|
78 | /* |
---|
79 | * dly_tsk - Delay Task |
---|
80 | */ |
---|
81 | |
---|
82 | ER dly_tsk( |
---|
83 | DLYTIME dlytim |
---|
84 | ) |
---|
85 | { |
---|
86 | Watchdog_Interval ticks; |
---|
87 | |
---|
88 | ticks = TOD_MILLISECONDS_TO_TICKS(dlytim); |
---|
89 | |
---|
90 | _Thread_Disable_dispatch(); |
---|
91 | if ( ticks == 0 ) { |
---|
92 | _Thread_Yield_processor(); |
---|
93 | } else { |
---|
94 | _Thread_Set_state( _Thread_Executing, STATES_DELAYING ); |
---|
95 | _Watchdog_Initialize( |
---|
96 | &_Thread_Executing->Timer, |
---|
97 | _Thread_Delay_ended, |
---|
98 | _Thread_Executing->Object.id, |
---|
99 | NULL |
---|
100 | ); |
---|
101 | _Watchdog_Insert_ticks( &_Thread_Executing->Timer, ticks ); |
---|
102 | } |
---|
103 | _Thread_Enable_dispatch(); |
---|
104 | return E_OK; |
---|
105 | } |
---|
106 | |
---|
107 | /* |
---|
108 | * def_cyc - Define Cyclic Handler |
---|
109 | */ |
---|
110 | |
---|
111 | ER def_cyc( |
---|
112 | HNO cycno, |
---|
113 | T_DCYC *pk_dcyc |
---|
114 | ) |
---|
115 | { |
---|
116 | Watchdog_Control *object; |
---|
117 | #if 0 |
---|
118 | Watchdog_Interval timeInterval; |
---|
119 | #endif |
---|
120 | |
---|
121 | /* XXX */ object = 0; |
---|
122 | if ( pk_dcyc->cycatr != TA_HLNG) |
---|
123 | return E_RSATR; |
---|
124 | #if 0 |
---|
125 | timeInterval = pk_dcyc->cyctim / 1000; |
---|
126 | object->delta_interval = timeInterval; |
---|
127 | #endif |
---|
128 | _Watchdog_Initialize( |
---|
129 | object, |
---|
130 | pk_dcyc->cychdr, |
---|
131 | cycno, |
---|
132 | pk_dcyc->exinf); |
---|
133 | _Watchdog_Deactivate(object); |
---|
134 | |
---|
135 | return E_OK; |
---|
136 | } |
---|
137 | |
---|
138 | /* |
---|
139 | * act_cyc - Activate Cyclic Handler |
---|
140 | */ |
---|
141 | |
---|
142 | ER act_cyc( |
---|
143 | HNO cycno, |
---|
144 | UINT cycact |
---|
145 | ) |
---|
146 | { |
---|
147 | Watchdog_Control *object; |
---|
148 | |
---|
149 | if(cycact != TCY_OFF || cycact != TCY_ON) |
---|
150 | return E_PAR; |
---|
151 | |
---|
152 | #if 0 |
---|
153 | if( object->Object_ID != cycno) |
---|
154 | return E_NOEXS; |
---|
155 | #endif |
---|
156 | |
---|
157 | _Watchdog_Activate(object); |
---|
158 | |
---|
159 | return E_OK; |
---|
160 | } |
---|
161 | |
---|
162 | /* |
---|
163 | * ref_cyc - Reference Cyclic Handler Status |
---|
164 | */ |
---|
165 | |
---|
166 | ER ref_cyc( |
---|
167 | T_RCYC *pk_rcyc, |
---|
168 | HNO cycno |
---|
169 | ) |
---|
170 | { |
---|
171 | #if 0 |
---|
172 | int timeElapse_since_actCyclic; |
---|
173 | #endif |
---|
174 | T_DCYC *pk_dcyc; |
---|
175 | #if 0 |
---|
176 | Watchdog_Control *object; |
---|
177 | #endif |
---|
178 | |
---|
179 | /* XXX */ pk_dcyc = 0; |
---|
180 | |
---|
181 | /* XXX will to use a "get" routine to map from id to object pointer */ |
---|
182 | /* XXX and the object pointer should be of type specific to this manager */ |
---|
183 | #if 0 |
---|
184 | if( object->Object_ID == cycno)) |
---|
185 | #else |
---|
186 | if ( 1 ) |
---|
187 | #endif |
---|
188 | { |
---|
189 | pk_rcyc->exinf = pk_dcyc->exinf; |
---|
190 | pk_rcyc->cycact = pk_dcyc->cycact; |
---|
191 | #if 0 |
---|
192 | pk_rcyc->lfttim = pk_dcyc->cyctim - timeElapse_since_actCyclic; |
---|
193 | #endif |
---|
194 | |
---|
195 | return E_OK; |
---|
196 | } |
---|
197 | else |
---|
198 | return E_NOEXS; |
---|
199 | } |
---|
200 | |
---|
201 | /* |
---|
202 | * def_alm - Define Alarm Handler |
---|
203 | */ |
---|
204 | |
---|
205 | ER def_alm( |
---|
206 | HNO almno, |
---|
207 | T_DALM *pk_dalm |
---|
208 | ) |
---|
209 | { |
---|
210 | #if 0 |
---|
211 | Objects_Control *objectAlrm; |
---|
212 | Watchdog_Interval timeInterval; |
---|
213 | |
---|
214 | timeInterval = pk_dalm->almtim / 1000; |
---|
215 | (void) _Watchdog_Remove(&objectAlrm); |
---|
216 | _Watchdog_Initialize( |
---|
217 | objectAlrm, |
---|
218 | pk_dalm->almhdr, |
---|
219 | almno, |
---|
220 | pk_dalm->exinf); |
---|
221 | _Watchdong_Insert_seconds(objectAlrm,timeInterval); |
---|
222 | _Thread_Enable_dispatch(); |
---|
223 | #endif |
---|
224 | |
---|
225 | return E_OK; |
---|
226 | } |
---|
227 | |
---|
228 | /* |
---|
229 | * ref_alm - Reference Alarm Handler Status |
---|
230 | */ |
---|
231 | |
---|
232 | ER ref_alm( |
---|
233 | T_RALM *pk_ralm, |
---|
234 | HNO almno |
---|
235 | ) |
---|
236 | { |
---|
237 | |
---|
238 | return E_OK; |
---|
239 | } |
---|
240 | |
---|
241 | /* |
---|
242 | * ret_tmr - Return from Timer Handler |
---|
243 | */ |
---|
244 | |
---|
245 | void ret_tmr( void ) |
---|
246 | { |
---|
247 | } |
---|
248 | |
---|