hv/mod_timer: refine timer interface

1. do not allow external modules to touch internal field of a timer.
2. make timer mode internal, period_in_ticks will decide the mode.

API wise:
1. the "mode" parameter was taken out of initialize_timer().
2. a new function update_timer() was added to update the timeout and
   period fields.
3. the timer_expired() function was extended with an output parameter
   to return the remaining cycles before expiration.

Also, the "fire_tsc" field name of hv_timer was renamed to "timeout".
With the new API, however, this change should not concern user code.

Tracked-On: #5920

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Liang Yi
2021-04-19 16:55:07 +08:00
committed by wenlingz
parent 3547c9cd23
commit 6805510d77
7 changed files with 108 additions and 76 deletions

View File

@@ -166,7 +166,7 @@ void console_setup_timer(void)
fire_tsc = cpu_ticks() + period_in_cycle;
initialize_timer(&console_timer,
console_timer_callback, NULL,
fire_tsc, TICK_MODE_PERIODIC, period_in_cycle);
fire_tsc, period_in_cycle);
/* Start an periodic timer */
if (add_timer(&console_timer) != 0) {