* Wait for about n microseconds (at least!). */
| 195 | * Wait for about n microseconds (at least!). |
| 196 | */ |
| 197 | void |
| 198 | DELAY(int n) |
| 199 | { |
| 200 | uint32_t cur, last, delta, usecs; |
| 201 | |
| 202 | TSENTER(); |
| 203 | /* |
| 204 | * This works by polling the timer and counting the number of |
| 205 | * microseconds that go by. |
| 206 | */ |
| 207 | last = mips_rd_count(); |
| 208 | delta = usecs = 0; |
| 209 | |
| 210 | while (n > usecs) { |
| 211 | cur = mips_rd_count(); |
| 212 | |
| 213 | /* Check to see if the timer has wrapped around. */ |
| 214 | if (cur < last) |
| 215 | delta += cur + (0xffffffff - last) + 1; |
| 216 | else |
| 217 | delta += cur - last; |
| 218 | |
| 219 | last = cur; |
| 220 | |
| 221 | if (delta >= cycles_per_usec) { |
| 222 | usecs += delta / cycles_per_usec; |
| 223 | delta %= cycles_per_usec; |
| 224 | } |
| 225 | } |
| 226 | TSEXIT(); |
| 227 | } |
| 228 | |
| 229 | static int |
| 230 | clock_start(struct eventtimer *et, sbintime_t first, sbintime_t period) |
no outgoing calls
no test coverage detected