This source file includes following definitions.
- hwt_start
- hwt_stop
- hwt_init
- hwt_restart
- hwt_read
- hwt_quick_read
- hwt_wait_time
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include "h/types.h"
27 #include "h/fddi.h"
28 #include "h/smc.h"
29
30 #ifndef lint
31 static const char ID_sccs[] = "@(#)hwt.c 1.13 97/04/23 (C) SK " ;
32 #endif
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 #define HWT_MAX (65000)
58
59 void hwt_start(struct s_smc *smc, u_long time)
60 {
61 u_short cnt ;
62
63 if (time > HWT_MAX)
64 time = HWT_MAX ;
65
66 smc->hw.t_start = time ;
67 smc->hw.t_stop = 0L ;
68
69 cnt = (u_short)time ;
70
71
72
73
74 if (!cnt)
75 cnt++ ;
76
77 outpd(ADDR(B2_TI_INI), (u_long) cnt * 200) ;
78 outpw(ADDR(B2_TI_CRTL), TIM_START) ;
79
80 smc->hw.timer_activ = TRUE ;
81 }
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97 void hwt_stop(struct s_smc *smc)
98 {
99 outpw(ADDR(B2_TI_CRTL), TIM_STOP) ;
100 outpw(ADDR(B2_TI_CRTL), TIM_CL_IRQ) ;
101
102 smc->hw.timer_activ = FALSE ;
103 }
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119 void hwt_init(struct s_smc *smc)
120 {
121 smc->hw.t_start = 0 ;
122 smc->hw.t_stop = 0 ;
123 smc->hw.timer_activ = FALSE ;
124
125 hwt_restart(smc) ;
126 }
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142 void hwt_restart(struct s_smc *smc)
143 {
144 hwt_stop(smc) ;
145 }
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160 u_long hwt_read(struct s_smc *smc)
161 {
162 u_short tr ;
163 u_long is ;
164
165 if (smc->hw.timer_activ) {
166 hwt_stop(smc) ;
167 tr = (u_short)((inpd(ADDR(B2_TI_VAL))/200) & 0xffff) ;
168
169 is = GET_ISR() ;
170
171 if ((tr > smc->hw.t_start) || (is & IS_TIMINT)) {
172 hwt_restart(smc) ;
173 smc->hw.t_stop = smc->hw.t_start ;
174 }
175 else
176 smc->hw.t_stop = smc->hw.t_start - tr ;
177 }
178 return smc->hw.t_stop;
179 }
180
181 #ifdef PCI
182
183
184
185
186
187
188
189
190
191
192
193
194
195 u_long hwt_quick_read(struct s_smc *smc)
196 {
197 u_long interval ;
198 u_long time ;
199
200 interval = inpd(ADDR(B2_TI_INI)) ;
201 outpw(ADDR(B2_TI_CRTL), TIM_STOP) ;
202 time = inpd(ADDR(B2_TI_VAL)) ;
203 outpd(ADDR(B2_TI_INI),time) ;
204 outpw(ADDR(B2_TI_CRTL), TIM_START) ;
205 outpd(ADDR(B2_TI_INI),interval) ;
206
207 return time;
208 }
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223 void hwt_wait_time(struct s_smc *smc, u_long start, long int duration)
224 {
225 long diff ;
226 long interval ;
227 int wrapped ;
228
229
230
231
232 if (smc->hw.timer_activ == FALSE ||
233 hwt_quick_read(smc) == hwt_quick_read(smc)) {
234 return ;
235 }
236
237 interval = inpd(ADDR(B2_TI_INI)) ;
238 if (interval > duration) {
239 do {
240 diff = (long)(start - hwt_quick_read(smc)) ;
241 if (diff < 0) {
242 diff += interval ;
243 }
244 } while (diff <= duration) ;
245 }
246 else {
247 diff = interval ;
248 wrapped = 0 ;
249 do {
250 if (!wrapped) {
251 if (hwt_quick_read(smc) >= start) {
252 diff += interval ;
253 wrapped = 1 ;
254 }
255 }
256 else {
257 if (hwt_quick_read(smc) < start) {
258 wrapped = 0 ;
259 }
260 }
261 } while (diff <= duration) ;
262 }
263 }
264 #endif
265