Attention is currently required from: Angel Pons, Subrata Banik, Aaron Durbin. Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/51445 )
Change subject: timestamp: Add helper fucntions ......................................................................
Patch Set 3:
(1 comment)
Commit Message:
https://review.coreboot.org/c/coreboot/+/51445/comment/3ea25e95_66d80923 PS3, Line 7: Add helper fucntions I think we should add these helpers:
// Rewind base_time in timestamp table using the delta provided in base_freq_mhz. // This function will perform the following steps: // 1. Calculate base_delta_tick in ts->tick_freq_mhz using base_delta * base_freq_mhz / ts->tick_freq_mhz. // 2. Update all entries in timestamp table by adding base_delta_tick // 3. Update ts->base_time as ts->base_time - base_delta_tick void timestamp_rewind_base(uint64_t base_delta, uint16_t base_freq_mhz);
// Add a new entry to timestamp table using the time_from_base expressed in freq_mhz // This function will perform the following steps: // 1. Calculate time_from_base in ts->tick_freq_mhz using time_from_base * freq_mhz / ts->tick_freq_mhz // 2. Call timestamp_add_table_entry using ts_table, id, time_from_base_ticks void timestamp_add_time_from_base(enum timestamp_id id, uint64_t time_from_base, uint16_t freq_mhz);
// Merge entries from provided table(new_table) into active timestamp table maintained by the library. The base_time in the provided table is expected to be the same as the active timestamp table. // This function will perform the following steps: // 1. Loop over each entry in provided table(new_table) and convert each entry from new_table->tick_freq_mhz to ts_table->tick_freq_mhz. // 2. Call timestamp_add_table_entry for each of these converted entries. void timestamp_merge(const struct timestamp_table *new_table);
You can skip the last one for now if you want. It won't be required for your case, but I see some other users taking advantage of it. In follow-up CLs, what you will have to do is:
// Use last timestamp from pre-x86 as equivalent to x86 being taken out of reset i.e. when TSC starts. So, base_time should be set to 0 (TSC start time) - ts[3] (last pre-x86 timestamp) // base_freq_mhz is 1000 since the base time is represented in ms. timestamp_rewind_base(0 - ts[3], 1000);
// Add pre-x86 timestamps with freq_mhz as 1000. Assumption is that pre-x86 time starts from 0. So ts[*] contains time delta from base 0. timestamp_add_time_from_base(TS_ME_BOOT_STALL_DONE, ts[0], 1000); timestamp_add_time_from_base(TS_ME_ICC_CONFIG_START, ts[1], 1000); timestamp_add_time_from_base(TS_ME_HOST_BOOT_PREP_DONE, ts[2], 1000); timestamp_add_time_from_base(TS_ME_RECEIVED_CRDA_FROM_PMC, ts[3], 1000);