* Typically a state will take 4 time samples: * 1. Before state entry callbacks * 2. After state entry callbacks / Before state function. * 3. After state function / Before state exit callbacks. * 4. After state exit callbacks. */
| 217 | * 4. After state exit callbacks. |
| 218 | */ |
| 219 | static void bs_sample_time(struct boot_state *state) |
| 220 | { |
| 221 | static const char *const sample_id[] = { "entry", "run", "exit" }; |
| 222 | static struct mono_time previous_sample; |
| 223 | struct mono_time this_sample; |
| 224 | long console; |
| 225 | |
| 226 | if (!CONFIG(HAVE_MONOTONIC_TIMER)) |
| 227 | return; |
| 228 | |
| 229 | console = console_time_get_and_reset(); |
| 230 | timer_monotonic_get(&this_sample); |
| 231 | state->num_samples++; |
| 232 | |
| 233 | int i = state->num_samples - 2; |
| 234 | if ((i >= 0) && (i < ARRAY_SIZE(sample_id))) { |
| 235 | long execution = mono_time_diff_microseconds(&previous_sample, &this_sample); |
| 236 | |
| 237 | /* Report with millisecond precision to reduce log diffs. */ |
| 238 | execution = DIV_ROUND_CLOSEST(execution, USECS_PER_MSEC); |
| 239 | console = DIV_ROUND_CLOSEST(console, USECS_PER_MSEC); |
| 240 | if (execution) { |
| 241 | printk(BIOS_DEBUG, "BS: %s %s times (exec / console): %ld / %ld ms\n", |
| 242 | state->name, sample_id[i], execution - console, console); |
| 243 | /* Reset again to ignore printk() time above. */ |
| 244 | console_time_get_and_reset(); |
| 245 | } |
| 246 | } |
| 247 | timer_monotonic_get(&previous_sample); |
| 248 | } |
| 249 | |
| 250 | #if CONFIG(TIMER_QUEUE) |
| 251 | static void bs_run_timers(int drain) |
no test coverage detected