Mercurial > vordog
comparison vordog.c @ 8:a28764b2a28e
modify selection of timeout for 2^n nanoseconds
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 08 Jul 2008 17:10:01 +0800 |
parents | 5a281ce7453c |
children | b4f4a69ea86a |
comparison
equal
deleted
inserted
replaced
7:5a281ce7453c | 8:a28764b2a28e |
---|---|
199 * | 199 * |
200 * Since, only SFTMR1_STS is work, in my experience, and it is triggered | 200 * Since, only SFTMR1_STS is work, in my experience, and it is triggered |
201 * after 4 times of initial value. So, it only (i * 4) seconds in range | 201 * after 4 times of initial value. So, it only (i * 4) seconds in range |
202 * of 4 ~ (255 * 4), where i is one of positive integer, are supported. | 202 * of 4 ~ (255 * 4), where i is one of positive integer, are supported. |
203 * | 203 * |
204 * The supported time intervals of watchdog(9) are 2^31~2^39 nanoseconds. | 204 * The supported time intervals of watchdog(9) are 2^32~2^39 nanoseconds. |
205 * vordog used a (i * 4) seconds for 2^n seconds while i * 4 seconds is | 205 * vordog used a (i * 4) seconds for 2^n seconds while i * 4 seconds is |
206 * smallest one of intervals that bigger than 2^n seconds. | 206 * closest to 2^n nanoseconds. The variances between i * 4 seconds and |
207 * 2^n nanoseconds are less than 7% (6.8678%). | |
207 */ | 208 */ |
208 static void | 209 static void |
209 vordog_wd9_evh(void *priv_data, u_int cmd, int *error) { | 210 vordog_wd9_evh(void *priv_data, u_int cmd, int *error) { |
210 vd_softc_t sc; | 211 vd_softc_t sc; |
211 u_int timeout, u; | 212 u_int timeout, u; |
212 /* 2^31, 2^32, ..., 2^39 nanoseconds */ | 213 /* 2^32, 2^33, ..., 2^39 nanoseconds */ |
213 static const int timeouts[] = { 1, 2, 3, 5, 9, 18, 35, 69, 138}; | 214 static const int timeouts[] = { 1, 2, 4, 9, 17, 34, 69, 137}; |
214 | 215 |
215 sc = (vd_softc_t)priv_data; | 216 sc = (vd_softc_t)priv_data; |
216 | 217 |
217 u = cmd & WD_INTERVAL; | 218 u = cmd & WD_INTERVAL; |
218 if(u < 31 || u > 39) { | 219 if(u < 32 || u > 39) { |
219 /* Out of range! Can not be configured. */ | 220 /* Out of range! Can not be configured. */ |
220 vordog_wd9_disable(); | 221 vordog_wd9_disable(); |
221 sc->init_val = 0; | 222 sc->init_val = 0; |
222 return; | 223 return; |
223 } | 224 } |