lib/timestamp: Init TSC frequency early on x86
When get_us_since_boot() is called in pre-ram stages on x86 init the TSC frequency. The TSC frequency is necessary to calculate the time spent since boot. When get_us_since_boot() is not used in pre-ram stages the function timestamp_tick_freq_mhz() will also be dropped by the linker, thus there's no code size increase for common code. Will be used in the following commit in pre-ram stages. Change-Id: I7fd9eeadf3063a629dd589498fcb957b9bd66536 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/88793 Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
parent
b0a63052b7
commit
3b2962929b
1 changed files with 10 additions and 0 deletions
|
|
@ -274,6 +274,16 @@ uint32_t get_us_since_boot(void)
|
|||
{
|
||||
struct timestamp_table *ts = timestamp_table_get();
|
||||
|
||||
/*
|
||||
* Bootbock size is limited on some platforms, thus only
|
||||
* enable get_us_since_boot() in PRERAM stages on x86 platforms
|
||||
* for now. When get_us_since_boot() isn't used in preram the linker
|
||||
* will drop timestamp_tick_freq_mhz().
|
||||
*/
|
||||
if (CONFIG(ARCH_X86) && ENV_ROMSTAGE_OR_BEFORE &&
|
||||
ts && ts->tick_freq_mhz == 0)
|
||||
ts->tick_freq_mhz = timestamp_tick_freq_mhz();
|
||||
|
||||
if (ts == NULL || ts->tick_freq_mhz == 0)
|
||||
return 0;
|
||||
return (timestamp_get() - ts->base_time) / ts->tick_freq_mhz;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue