| 229 | } |
| 230 | |
| 231 | uc_err reload_timer(uc_engine *uc, uint32_t id) { |
| 232 | struct TimerState* timers = &uc->fw->timers; |
| 233 | #ifdef DEBUG_TIMER |
| 234 | // This is a rather hot path due to input consumption timeouts, so skip checks outside debugging |
| 235 | if(id >= MAX_TIMERS) { |
| 236 | perror("[TIMER ERROR] reload_timer: Too high id passed\n"); |
| 237 | exit(-1); |
| 238 | } else if(!timers->timers[id].in_use) { |
| 239 | printf("[TIMER ERROR] reload_timer: Unused timer to be reset (id=%u)\n", id); |
| 240 | print_timer(id); |
| 241 | exit(-1); |
| 242 | } |
| 243 | |
| 244 | printf("[TIMER] reload_timer(%d)\n", id); fflush(stdout); |
| 245 | #endif |
| 246 | |
| 247 | struct Timer *tim = &timers->timers[id]; |
| 248 | |
| 249 | if(tim->is_active) { |
| 250 | uc->get_timer_countdown(uc->ctx, &uc->fw->timers.cur_countdown); |
| 251 | tim->ticker_val = tim->reload_val + (timers->cur_interval-timers->cur_countdown); |
| 252 | sort_timer_back(timers, tim); |
| 253 | } else { |
| 254 | tim->ticker_val = tim->reload_val; |
| 255 | } |
| 256 | |
| 257 | return UC_ERR_OK; |
| 258 | } |
| 259 | |
| 260 | uc_err set_timer_reload_val(uc_engine *uc, uint32_t id, uint64_t reload_val) { |
| 261 | struct TimerState* timers = &uc->fw->timers; |
no test coverage detected