mail.coreboot.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

coreboot-gerrit

Download
Threads by month
  • ----- 2026 -----
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2019 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2018 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2017 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2016 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2015 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2014 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2013 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
coreboot-gerrit@coreboot.org

April 2013

  • 1 participants
  • 506 discussions
Patch set updated for coreboot: 98a4e62 lapic: monotonic time implementation
by Aaron Durbin April 30, 2013

April 30, 2013
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3154 -gerrit commit 98a4e62065ff9e8e8ed0fa0eae9b940ca9105bb6 Author: Aaron Durbin <adurbin(a)chromium.org> Date: Mon Apr 29 17:18:49 2013 -0500 lapic: monotonic time implementation Implement the timer_monotonic_get() functionality based off of the local apic timer. Change-Id: I1aa1ff64d15a3056d6abd1372be13da682c5ee2e Signed-off-by: Aaron Durbin <adurbin(a)chromium.org> --- src/cpu/x86/Kconfig | 7 +++++++ src/cpu/x86/lapic/apic_timer.c | 43 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/cpu/x86/Kconfig b/src/cpu/x86/Kconfig index 4c5176b..6b70ae7 100644 --- a/src/cpu/x86/Kconfig +++ b/src/cpu/x86/Kconfig @@ -11,6 +11,13 @@ config UDELAY_LAPIC bool default n +config LAPIC_MONOTONIC_TIMER + def_bool n + depends on UDELAY_LAPIC + select HAVE_MONOTONIC_TIMER + help + Expose monotonic time using the local apic. + config UDELAY_LAPIC_FIXED_FSB int diff --git a/src/cpu/x86/lapic/apic_timer.c b/src/cpu/x86/lapic/apic_timer.c index b60da27..749fef0 100644 --- a/src/cpu/x86/lapic/apic_timer.c +++ b/src/cpu/x86/lapic/apic_timer.c @@ -19,6 +19,7 @@ */ #include <stdint.h> +#include <console/console.h> #include <delay.h> #include <arch/io.h> #include <arch/cpu.h> @@ -106,3 +107,45 @@ void udelay(u32 usecs) value = lapic_read(LAPIC_TMCCT); } while((start - value) < ticks); } + +#if CONFIG_LAPIC_MONOTONIC_TIMER && !defined(__PRE_RAM__) +#include <timer.h> + +static struct monotonic_counter { + int initialized; + struct mono_time time; + uint32_t last_value; +} mono_counter; + +void timer_monotonic_get(struct mono_time *mt) +{ + uint32_t current_tick; + uint32_t usecs_elapsed; + + if (!mono_counter.initialized) { + init_timer(); + /* An FSB frequency of 200Mhz provides a 20 second polling + * interval between timer_monotonic_get() calls before wrap + * around occurs. */ + if (timer_fsb > 200) + printk(BIOS_WARNING, + "apic timer freq (%d) may be too fast.\n", + timer_fsb); + mono_counter.last_value = lapic_read(LAPIC_TMCCT); + mono_counter.initialized = 1; + } + + current_tick = lapic_read(LAPIC_TMCCT); + /* Note that the APIC timer counts down. */ + usecs_elapsed = (mono_counter.last_value - current_tick) / timer_fsb; + + /* Update current time and tick values only if a full tick occurred. */ + if (usecs_elapsed) { + mono_time_add_usecs(&mono_counter.time, usecs_elapsed); + mono_counter.last_value = current_tick; + } + + /* Save result. */ + *mt = mono_counter.time; +} +#endif
1 0
0 0
Patch set updated for coreboot: 7157ea2 tsc: provide monotonic timer
by Aaron Durbin April 30, 2013

April 30, 2013
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3155 -gerrit commit 7157ea223c9c9c096e24e32164703fa8767c599e Author: Aaron Durbin <adurbin(a)chromium.org> Date: Mon Apr 29 22:22:55 2013 -0500 tsc: provide monotonic timer Implement the timer_monotonic_get() using the TSC. Change-Id: I5118da6fb9bccc75d2ce012317612e0ab20a2cac Signed-off-by: Aaron Durbin <adurbin(a)chromium.org> --- src/cpu/x86/Kconfig | 7 +++++++ src/cpu/x86/tsc/delay_tsc.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/cpu/x86/Kconfig b/src/cpu/x86/Kconfig index 6b70ae7..5cf40fa 100644 --- a/src/cpu/x86/Kconfig +++ b/src/cpu/x86/Kconfig @@ -25,6 +25,13 @@ config UDELAY_TSC bool default n +config TSC_MONOTONIC_TIMER + def_bool n + depends on UDELAY_TSC + select HAVE_MONOTONIC_TIMER + help + Expose monotonic time using the TSC. + config UDELAY_TIMER2 bool default n diff --git a/src/cpu/x86/tsc/delay_tsc.c b/src/cpu/x86/tsc/delay_tsc.c index 1907a9c..e4993d0 100644 --- a/src/cpu/x86/tsc/delay_tsc.c +++ b/src/cpu/x86/tsc/delay_tsc.c @@ -164,3 +164,40 @@ void udelay(unsigned us) count = rdtscll(); } } + +#if CONFIG_TSC_MONOTONIC_TIMER +#include <timer.h> + +static struct monotonic_counter { + int initialized; + struct mono_time time; + uint64_t last_value; +} mono_counter; + +void timer_monotonic_get(struct mono_time *mt) +{ + uint64_t current_tick; + uint64_t ticks_elapsed; + + if (!mono_counter.initialized) { + init_timer(); + mono_counter.last_value = rdtscll(); + mono_counter.initialized = 1; + } + + current_tick = rdtscll(); + ticks_elapsed = current_tick - mono_counter.last_value; + + /* Update current time and tick values only if a full tick occurred. */ + if (ticks_elapsed >= clocks_per_usec) { + uint64_t usecs_elapsed; + + usecs_elapsed = ticks_elapsed / clocks_per_usec; + mono_time_add_usecs(&mono_counter.time, (long)usecs_elapsed); + mono_counter.last_value = current_tick; + } + + /* Save result. */ + *mt = mono_counter.time; +} +#endif
1 0
0 0
Patch set updated for coreboot: 24b6aba haswell: 24MHz monotonic time implementation
by Aaron Durbin April 30, 2013

April 30, 2013
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3153 -gerrit commit 24b6abaff5d42024a563a3c238525370c64a3083 Author: Aaron Durbin <adurbin(a)chromium.org> Date: Mon Apr 29 16:57:10 2013 -0500 haswell: 24MHz monotonic time implementation Haswell ULT devices have a 24MHz package-level counter. Use this counter to provide a timer_monotonic_get() implementation. Change-Id: Ic79843fcbfbbb6462ee5ebd12b39502307750dbb Signed-off-by: Aaron Durbin <adurbin(a)chromium.org> --- src/cpu/intel/haswell/Kconfig | 7 ++++ src/cpu/intel/haswell/Makefile.inc | 1 + src/cpu/intel/haswell/monotonic_timer.c | 62 +++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/src/cpu/intel/haswell/Kconfig b/src/cpu/intel/haswell/Kconfig index 5f27d4c..13861f9 100644 --- a/src/cpu/intel/haswell/Kconfig +++ b/src/cpu/intel/haswell/Kconfig @@ -54,4 +54,11 @@ config RESET_ON_INVALID_RAMSTAGE_CACHE the system will reset otherwise the ramstage will be reloaded from cbfs. +config MONOTONIC_TIMER_MSR + def_bool n + depends on INTEL_LYNXPOINT_LP + select HAVE_MONOTONIC_TIMER + help + Provide a monotonic timer using the 24MHz MSR counter. + endif diff --git a/src/cpu/intel/haswell/Makefile.inc b/src/cpu/intel/haswell/Makefile.inc index a19a8c5..90ffd66 100644 --- a/src/cpu/intel/haswell/Makefile.inc +++ b/src/cpu/intel/haswell/Makefile.inc @@ -5,6 +5,7 @@ romstage-y += romstage.c ramstage-$(CONFIG_GENERATE_ACPI_TABLES) += acpi.c ramstage-$(CONFIG_HAVE_SMI_HANDLER) += smmrelocate.c +ramstage-$(CONFIG_MONOTONIC_TIMER_MSR) += monotonic_timer.c cpu_microcode-$(CONFIG_CPU_MICROCODE_CBFS_GENERATE) += microcode_blob.c diff --git a/src/cpu/intel/haswell/monotonic_timer.c b/src/cpu/intel/haswell/monotonic_timer.c new file mode 100644 index 0000000..c51bcbd --- /dev/null +++ b/src/cpu/intel/haswell/monotonic_timer.c @@ -0,0 +1,62 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2013 Google, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include <stdint.h> +#include <cpu/x86/msr.h> +#include <timer.h> + +#define MSR_COUNTER_24_MHz 0x637 +static struct monotonic_counter { + int initialized; + struct mono_time time; + uint32_t last_value; +} mono_counter; + +static inline uint32_t read_counter_msr(void) +{ + /* Even though the MSR is 64-bit it is assumed that the hardware + * is polled frequently enough to only use the lower 32-bits. */ + msr_t counter_msr; + + counter_msr = rdmsr(MSR_COUNTER_24_MHz); + + return counter_msr.lo; +} + +void timer_monotonic_get(struct mono_time *mt) +{ + uint32_t current_tick; + uint32_t usecs_elapsed; + + if (!mono_counter.initialized) { + mono_counter.last_value = read_counter_msr(); + mono_counter.initialized = 1; + } + + current_tick = read_counter_msr(); + usecs_elapsed = (current_tick - mono_counter.last_value) / 24; + + /* Update current time and tick values only if a full tick occurred. */ + if (usecs_elapsed) { + mono_time_add_usecs(&mono_counter.time, usecs_elapsed); + mono_counter.last_value = current_tick; + } + + /* Save result. */ + *mt = mono_counter.time; +}
1 0
0 0
Patch set updated for coreboot: 7a219b0 boot state: track times for each state
by Aaron Durbin April 30, 2013

April 30, 2013
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3156 -gerrit commit 7a219b0a968ad9ab37bdec9777da4c3f215b211a Author: Aaron Durbin <adurbin(a)chromium.org> Date: Fri Apr 26 20:54:16 2013 -0500 boot state: track times for each state When the MONOTONIC_TIMER is available track the entry, run, and exit times for each state. It should be noted that the times for states that vector to OS or a payload do not have their times reported. Change-Id: I6af23fe011609e0b1e019f35ee40f1fbebd59c9d Signed-off-by: Aaron Durbin <adurbin(a)chromium.org> --- src/lib/hardwaremain.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/lib/hardwaremain.c b/src/lib/hardwaremain.c index ed2a516..7bf0237 100644 --- a/src/lib/hardwaremain.c +++ b/src/lib/hardwaremain.c @@ -37,6 +37,7 @@ #if CONFIG_HAVE_ACPI_RESUME #include <arch/acpi.h> #endif +#include <timer.h> #include <timestamp.h> #if BOOT_STATE_DEBUG @@ -58,6 +59,19 @@ static boot_state_t bs_write_tables(void *arg); static boot_state_t bs_payload_load(void *arg); static boot_state_t bs_payload_boot(void *arg); +/* + * 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. + */ +#define MAX_TIME_SAMPLES 4 +struct boot_state_times { + int num_samples; + struct mono_time samples[MAX_TIME_SAMPLES]; +}; + struct boot_state { const char *name; boot_state_t id; @@ -65,6 +79,9 @@ struct boot_state { boot_state_t (*run_state)(void *arg); void *arg; int complete; +#if CONFIG_HAVE_MONOTONIC_TIMER + struct boot_state_times times; +#endif }; #define BS_INIT(state_, run_func_) \ @@ -228,6 +245,39 @@ static boot_state_t bs_payload_boot(void *entry) return BS_PAYLOAD_BOOT; } +#if CONFIG_HAVE_MONOTONIC_TIMER +static void bs_sample_time(struct boot_state *state) +{ + struct mono_time *mt; + + mt = &state->times.samples[state->times.num_samples]; + timer_monotonic_get(mt); + state->times.num_samples++; +} + +static void bs_report_time(struct boot_state *state) +{ + struct rela_time entry_time; + struct rela_time run_time; + struct rela_time exit_time; + struct boot_state_times *times; + + times = &state->times; + entry_time = mono_time_diff(&times->samples[0], &times->samples[1]); + run_time = mono_time_diff(&times->samples[1], &times->samples[2]); + exit_time = mono_time_diff(&times->samples[2], &times->samples[3]); + + printk(BIOS_DEBUG, "BS: %s times (us): entry %ld run %ld exit %ld\n", + state->name, + rela_time_in_microseconds(&entry_time), + rela_time_in_microseconds(&run_time), + rela_time_in_microseconds(&exit_time)); +} +#else +static inline void bs_sample_time(struct boot_state *state) {} +static inline void bs_report_time(struct boot_state *state) {} +#endif + static void bs_call_callbacks(struct boot_state *state, boot_state_sequence_t seq) { @@ -262,13 +312,25 @@ static void bs_walk_state_machine(boot_state_t current_state_id) } printk(BS_DEBUG_LVL, "BS: Entering %s state.\n", state->name); + + bs_sample_time(state); + bs_call_callbacks(state, BS_ON_ENTRY); + bs_sample_time(state); + current_state_id = state->run_state(state->arg); printk(BS_DEBUG_LVL, "BS: Exiting %s state.\n", state->name); + + bs_sample_time(state); + bs_call_callbacks(state, BS_ON_EXIT); + bs_sample_time(state); + + bs_report_time(state); + state->complete = 1; } }
1 0
0 0
New patch to review for coreboot: 14f905d Define a config variable for 64 bit address capability
by Ronald G. Minnich April 30, 2013

April 30, 2013
Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3157 -gerrit commit 14f905dbef8910bd48d5598d85ab4f9de9e6d710 Author: Ronald G. Minnich <rminnich(a)gmail.com> Date: Tue Apr 30 08:38:16 2013 -0700 Define a config variable for 64 bit address capability For the most part, we don't need 64 bit addressing. In the future, it will be more important, but it's useful to have an indicator that a CPU can even run in that mode. Change-Id: I59e4061e07c16c5def7d9950749a55083612f6af Signed-off-by: Ronald G. Minnich <rminnich(a)gmail.com> --- src/cpu/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cpu/Kconfig b/src/cpu/Kconfig index ed7d6ab..5d348a3 100644 --- a/src/cpu/Kconfig +++ b/src/cpu/Kconfig @@ -1,6 +1,17 @@ # Warning: This file is included whether or not the if is here. # The if controls how the evaluation occurs. # (See also src/Kconfig) + +config HAVE_64BIT + bool + default n + help + Many of the CPUs in our tree can support 64-bit addresses. + Currently, we don't use this capability on any of them. + This variable indicates whether it is even possible, + for a given CPU, to run in 64 bit mode. For the subset of + CPUs which can support 64 bit mode it can be overridden. + if ARCH_ARMV7 source src/cpu/armltd/Kconfig
1 0
0 0
Patch set updated for coreboot: 63c7cef lapic: monotonic time implementation
by Aaron Durbin April 30, 2013

April 30, 2013
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3154 -gerrit commit 63c7cefbd0fb90f1d5109cd0ec56fe1e953254fa Author: Aaron Durbin <adurbin(a)chromium.org> Date: Mon Apr 29 17:18:49 2013 -0500 lapic: monotonic time implementation Implement the time_monotonic_get() functionality based off of the local apic timer. Change-Id: I1aa1ff64d15a3056d6abd1372be13da682c5ee2e Signed-off-by: Aaron Durbin <adurbin(a)chromium.org> --- src/cpu/x86/Kconfig | 7 +++++++ src/cpu/x86/lapic/apic_timer.c | 43 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/cpu/x86/Kconfig b/src/cpu/x86/Kconfig index 4c5176b..6b70ae7 100644 --- a/src/cpu/x86/Kconfig +++ b/src/cpu/x86/Kconfig @@ -11,6 +11,13 @@ config UDELAY_LAPIC bool default n +config LAPIC_MONOTONIC_TIMER + def_bool n + depends on UDELAY_LAPIC + select HAVE_MONOTONIC_TIMER + help + Expose monotonic time using the local apic. + config UDELAY_LAPIC_FIXED_FSB int diff --git a/src/cpu/x86/lapic/apic_timer.c b/src/cpu/x86/lapic/apic_timer.c index b60da27..749fef0 100644 --- a/src/cpu/x86/lapic/apic_timer.c +++ b/src/cpu/x86/lapic/apic_timer.c @@ -19,6 +19,7 @@ */ #include <stdint.h> +#include <console/console.h> #include <delay.h> #include <arch/io.h> #include <arch/cpu.h> @@ -106,3 +107,45 @@ void udelay(u32 usecs) value = lapic_read(LAPIC_TMCCT); } while((start - value) < ticks); } + +#if CONFIG_LAPIC_MONOTONIC_TIMER && !defined(__PRE_RAM__) +#include <timer.h> + +static struct monotonic_counter { + int initialized; + struct mono_time time; + uint32_t last_value; +} mono_counter; + +void timer_monotonic_get(struct mono_time *mt) +{ + uint32_t current_tick; + uint32_t usecs_elapsed; + + if (!mono_counter.initialized) { + init_timer(); + /* An FSB frequency of 200Mhz provides a 20 second polling + * interval between timer_monotonic_get() calls before wrap + * around occurs. */ + if (timer_fsb > 200) + printk(BIOS_WARNING, + "apic timer freq (%d) may be too fast.\n", + timer_fsb); + mono_counter.last_value = lapic_read(LAPIC_TMCCT); + mono_counter.initialized = 1; + } + + current_tick = lapic_read(LAPIC_TMCCT); + /* Note that the APIC timer counts down. */ + usecs_elapsed = (mono_counter.last_value - current_tick) / timer_fsb; + + /* Update current time and tick values only if a full tick occurred. */ + if (usecs_elapsed) { + mono_time_add_usecs(&mono_counter.time, usecs_elapsed); + mono_counter.last_value = current_tick; + } + + /* Save result. */ + *mt = mono_counter.time; +} +#endif
1 0
0 0
Patch set updated for coreboot: b53e537 tsc: provide monotonic timer
by Aaron Durbin April 30, 2013

April 30, 2013
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3155 -gerrit commit b53e537b26ab56997f786dfe7685d3cf270fe6f9 Author: Aaron Durbin <adurbin(a)chromium.org> Date: Mon Apr 29 22:22:55 2013 -0500 tsc: provide monotonic timer Implement the time_monotonic_get() using the TSC. Change-Id: I5118da6fb9bccc75d2ce012317612e0ab20a2cac Signed-off-by: Aaron Durbin <adurbin(a)chromium.org> --- src/cpu/x86/Kconfig | 7 +++++++ src/cpu/x86/tsc/delay_tsc.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/cpu/x86/Kconfig b/src/cpu/x86/Kconfig index 6b70ae7..5cf40fa 100644 --- a/src/cpu/x86/Kconfig +++ b/src/cpu/x86/Kconfig @@ -25,6 +25,13 @@ config UDELAY_TSC bool default n +config TSC_MONOTONIC_TIMER + def_bool n + depends on UDELAY_TSC + select HAVE_MONOTONIC_TIMER + help + Expose monotonic time using the TSC. + config UDELAY_TIMER2 bool default n diff --git a/src/cpu/x86/tsc/delay_tsc.c b/src/cpu/x86/tsc/delay_tsc.c index 1907a9c..e4993d0 100644 --- a/src/cpu/x86/tsc/delay_tsc.c +++ b/src/cpu/x86/tsc/delay_tsc.c @@ -164,3 +164,40 @@ void udelay(unsigned us) count = rdtscll(); } } + +#if CONFIG_TSC_MONOTONIC_TIMER +#include <timer.h> + +static struct monotonic_counter { + int initialized; + struct mono_time time; + uint64_t last_value; +} mono_counter; + +void timer_monotonic_get(struct mono_time *mt) +{ + uint64_t current_tick; + uint64_t ticks_elapsed; + + if (!mono_counter.initialized) { + init_timer(); + mono_counter.last_value = rdtscll(); + mono_counter.initialized = 1; + } + + current_tick = rdtscll(); + ticks_elapsed = current_tick - mono_counter.last_value; + + /* Update current time and tick values only if a full tick occurred. */ + if (ticks_elapsed >= clocks_per_usec) { + uint64_t usecs_elapsed; + + usecs_elapsed = ticks_elapsed / clocks_per_usec; + mono_time_add_usecs(&mono_counter.time, (long)usecs_elapsed); + mono_counter.last_value = current_tick; + } + + /* Save result. */ + *mt = mono_counter.time; +} +#endif
1 0
0 0
Patch set updated for coreboot: fca7d30 coreboot: introduce monotonic timer API
by Aaron Durbin April 30, 2013

April 30, 2013
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3152 -gerrit commit fca7d309eb2ae71f52c7e0808c4ae6a4a7b060df Author: Aaron Durbin <adurbin(a)chromium.org> Date: Mon Apr 29 22:31:51 2013 -0500 coreboot: introduce monotonic timer API The notion of a monotonic timer is introduced. Along with it are helper functions and other types for comparing times. This is just the framework where it is the responsibility of the chipset/board to provide the implementation of timer_monotonic_get(). The reason structs are used instead of native types is to allow for future changes to the data structure without chaning all the call sites. Change-Id: Ie56b9ab9dedb0da69dea86ef87ca744004eb1ae3 Signed-off-by: Aaron Durbin <adurbin(a)chromium.org> --- src/Kconfig | 5 ++ src/include/timer.h | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) diff --git a/src/Kconfig b/src/Kconfig index c3cc6bf..a49643e 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -313,6 +313,11 @@ config HAVE_INIT_TIMER default n if UDELAY_IO default y +config HAVE_MONOTONIC_TIMER + def_bool n + help + The board/chipset provides a monotonic timer. + config HIGH_SCRATCH_MEMORY_SIZE hex default 0x0 diff --git a/src/include/timer.h b/src/include/timer.h new file mode 100644 index 0000000..2b112dd --- /dev/null +++ b/src/include/timer.h @@ -0,0 +1,140 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2013 Google, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef TIMER_H +#define TIMER_H + +#define USECS_PER_SEC 1000000 +#define MSECS_PER_SEC 1000 +#define USECS_PER_MSEC (USECS_PER_SEC / MSECS_PER_SEC) + +/* The time structures are defined to be a representation of the time since + * coreboot started executing one of its stages. The reason for using structures + * is to allow for changes in the future. The structures' details are exposed + * so that the compiler can allocate space on the stack and use in other + * structures. In other words, accessing any field within this structure + * outside of the core timer code is not supported. */ + +struct mono_time { + long microseconds; +}; + +struct rela_time { + long microseconds; +}; + +/* Obtain the current monotonic time. The assumption is that the time counts + * up from the value 0 with value 0 being the point when the timer was + * initialized. Additionally, the timer is assumed to only be valid for the + * duration of the boot. + * + * Note that any implementations of timer_monotonic_get() + * need to ensure its timesource does not roll over within 10 secs. The reason + * is that the time between calls to timer_monotonic_get() may be on order + * of 10 seconds. */ +void timer_monotonic_get(struct mono_time *mt); + +/* Add microseconds to an absoute time. */ +static inline void mono_time_add_usecs(struct mono_time *mt, long us) +{ + mt->microseconds += us; +} + +/* Add milliseconds to an absoute time. */ +static inline void mono_time_add_msecs(struct mono_time *mt, long ms) +{ + mono_time_add_usecs(mt, ms * USECS_PER_MSEC); +} + +static inline void mono_time_add_rela_time(struct mono_time *mt, + const struct rela_time *t) +{ + mono_time_add_usecs(mt, t->microseconds); +} + +/* Compare two absoluted times: Return -1, 0, or 1 if t1 is <, =, or > t2, + * respectively. */ +static inline int mono_time_cmp(const struct mono_time *t1, + const struct mono_time *t2) +{ + if (t1->microseconds == t2->microseconds) + return 0; + + if (t1->microseconds < t2->microseconds) + return -1; + + return 1; +} + +static inline int rela_time_cmp(const struct rela_time *t1, + const struct rela_time *t2) +{ + if (t1->microseconds == t2->microseconds) + return 0; + + if (t1->microseconds < t2->microseconds) + return -1; + + return 1; +} + +/* Iniitalize a rela_time structure. */ +static inline struct rela_time rela_time_init_usecs(long us) +{ + struct rela_time t; + t.microseconds = us; + return t; +} + +/* Return time difference between t1 and t2. i.e. t2 - t1. */ +static struct rela_time mono_time_diff(const struct mono_time *t1, + const struct mono_time *t2) +{ + return rela_time_init_usecs(t2->microseconds - t1->microseconds); +} + +/* Return true if t1 after t2 */ +static inline int mono_time_after(const struct mono_time *t1, + const struct mono_time *t2) +{ + return mono_time_cmp(t1, t2) > 0; +} + +/* Return true if t1 before t2. */ +static inline int mono_time_before(const struct mono_time *t1, + const struct mono_time *t2) +{ + return mono_time_cmp(t1, t2) < 0; +} + +/* Return the difference between now and t. */ +static inline struct rela_time current_time_from(const struct mono_time *t) +{ + struct mono_time now; + + timer_monotonic_get(&now); + return mono_time_diff(t, &now); + +} + +static inline long rela_time_in_microseconds(const struct rela_time *rt) +{ + return rt->microseconds; +} + +#endif /* TIMER_H */
1 0
0 0
Patch set updated for coreboot: d86f98c haswell: 24MHz monotonic time implementation
by Aaron Durbin April 30, 2013

April 30, 2013
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3153 -gerrit commit d86f98c72eb174167c3ca072b37a45e9e4355d1c Author: Aaron Durbin <adurbin(a)chromium.org> Date: Mon Apr 29 16:57:10 2013 -0500 haswell: 24MHz monotonic time implementation Haswell ULT devices have a 24MHz package-level counter. Use this counter to provide a time_monotonic_get() implementation. Change-Id: Ic79843fcbfbbb6462ee5ebd12b39502307750dbb Signed-off-by: Aaron Durbin <adurbin(a)chromium.org> --- src/cpu/intel/haswell/Kconfig | 7 ++++ src/cpu/intel/haswell/Makefile.inc | 1 + src/cpu/intel/haswell/monotonic_timer.c | 62 +++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/src/cpu/intel/haswell/Kconfig b/src/cpu/intel/haswell/Kconfig index 5f27d4c..13861f9 100644 --- a/src/cpu/intel/haswell/Kconfig +++ b/src/cpu/intel/haswell/Kconfig @@ -54,4 +54,11 @@ config RESET_ON_INVALID_RAMSTAGE_CACHE the system will reset otherwise the ramstage will be reloaded from cbfs. +config MONOTONIC_TIMER_MSR + def_bool n + depends on INTEL_LYNXPOINT_LP + select HAVE_MONOTONIC_TIMER + help + Provide a monotonic timer using the 24MHz MSR counter. + endif diff --git a/src/cpu/intel/haswell/Makefile.inc b/src/cpu/intel/haswell/Makefile.inc index a19a8c5..90ffd66 100644 --- a/src/cpu/intel/haswell/Makefile.inc +++ b/src/cpu/intel/haswell/Makefile.inc @@ -5,6 +5,7 @@ romstage-y += romstage.c ramstage-$(CONFIG_GENERATE_ACPI_TABLES) += acpi.c ramstage-$(CONFIG_HAVE_SMI_HANDLER) += smmrelocate.c +ramstage-$(CONFIG_MONOTONIC_TIMER_MSR) += monotonic_timer.c cpu_microcode-$(CONFIG_CPU_MICROCODE_CBFS_GENERATE) += microcode_blob.c diff --git a/src/cpu/intel/haswell/monotonic_timer.c b/src/cpu/intel/haswell/monotonic_timer.c new file mode 100644 index 0000000..c51bcbd --- /dev/null +++ b/src/cpu/intel/haswell/monotonic_timer.c @@ -0,0 +1,62 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2013 Google, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include <stdint.h> +#include <cpu/x86/msr.h> +#include <timer.h> + +#define MSR_COUNTER_24_MHz 0x637 +static struct monotonic_counter { + int initialized; + struct mono_time time; + uint32_t last_value; +} mono_counter; + +static inline uint32_t read_counter_msr(void) +{ + /* Even though the MSR is 64-bit it is assumed that the hardware + * is polled frequently enough to only use the lower 32-bits. */ + msr_t counter_msr; + + counter_msr = rdmsr(MSR_COUNTER_24_MHz); + + return counter_msr.lo; +} + +void timer_monotonic_get(struct mono_time *mt) +{ + uint32_t current_tick; + uint32_t usecs_elapsed; + + if (!mono_counter.initialized) { + mono_counter.last_value = read_counter_msr(); + mono_counter.initialized = 1; + } + + current_tick = read_counter_msr(); + usecs_elapsed = (current_tick - mono_counter.last_value) / 24; + + /* Update current time and tick values only if a full tick occurred. */ + if (usecs_elapsed) { + mono_time_add_usecs(&mono_counter.time, usecs_elapsed); + mono_counter.last_value = current_tick; + } + + /* Save result. */ + *mt = mono_counter.time; +}
1 0
0 0
Patch set updated for coreboot: 13a7f70 boot state: track times for each state
by Aaron Durbin April 30, 2013

April 30, 2013
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3156 -gerrit commit 13a7f70a6c7ac9c0f38d356fcc06658f097fad3b Author: Aaron Durbin <adurbin(a)chromium.org> Date: Fri Apr 26 20:54:16 2013 -0500 boot state: track times for each state When the MONOTONIC_TIMER is available track the entry, run, and exit times for each state. It should be noted that the times for states that vector to OS or a payload do not have their times reported. Change-Id: I6af23fe011609e0b1e019f35ee40f1fbebd59c9d Signed-off-by: Aaron Durbin <adurbin(a)chromium.org> --- src/lib/hardwaremain.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/lib/hardwaremain.c b/src/lib/hardwaremain.c index ed2a516..7bf0237 100644 --- a/src/lib/hardwaremain.c +++ b/src/lib/hardwaremain.c @@ -37,6 +37,7 @@ #if CONFIG_HAVE_ACPI_RESUME #include <arch/acpi.h> #endif +#include <timer.h> #include <timestamp.h> #if BOOT_STATE_DEBUG @@ -58,6 +59,19 @@ static boot_state_t bs_write_tables(void *arg); static boot_state_t bs_payload_load(void *arg); static boot_state_t bs_payload_boot(void *arg); +/* + * 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. + */ +#define MAX_TIME_SAMPLES 4 +struct boot_state_times { + int num_samples; + struct mono_time samples[MAX_TIME_SAMPLES]; +}; + struct boot_state { const char *name; boot_state_t id; @@ -65,6 +79,9 @@ struct boot_state { boot_state_t (*run_state)(void *arg); void *arg; int complete; +#if CONFIG_HAVE_MONOTONIC_TIMER + struct boot_state_times times; +#endif }; #define BS_INIT(state_, run_func_) \ @@ -228,6 +245,39 @@ static boot_state_t bs_payload_boot(void *entry) return BS_PAYLOAD_BOOT; } +#if CONFIG_HAVE_MONOTONIC_TIMER +static void bs_sample_time(struct boot_state *state) +{ + struct mono_time *mt; + + mt = &state->times.samples[state->times.num_samples]; + timer_monotonic_get(mt); + state->times.num_samples++; +} + +static void bs_report_time(struct boot_state *state) +{ + struct rela_time entry_time; + struct rela_time run_time; + struct rela_time exit_time; + struct boot_state_times *times; + + times = &state->times; + entry_time = mono_time_diff(&times->samples[0], &times->samples[1]); + run_time = mono_time_diff(&times->samples[1], &times->samples[2]); + exit_time = mono_time_diff(&times->samples[2], &times->samples[3]); + + printk(BIOS_DEBUG, "BS: %s times (us): entry %ld run %ld exit %ld\n", + state->name, + rela_time_in_microseconds(&entry_time), + rela_time_in_microseconds(&run_time), + rela_time_in_microseconds(&exit_time)); +} +#else +static inline void bs_sample_time(struct boot_state *state) {} +static inline void bs_report_time(struct boot_state *state) {} +#endif + static void bs_call_callbacks(struct boot_state *state, boot_state_sequence_t seq) { @@ -262,13 +312,25 @@ static void bs_walk_state_machine(boot_state_t current_state_id) } printk(BS_DEBUG_LVL, "BS: Entering %s state.\n", state->name); + + bs_sample_time(state); + bs_call_callbacks(state, BS_ON_ENTRY); + bs_sample_time(state); + current_state_id = state->run_state(state->arg); printk(BS_DEBUG_LVL, "BS: Exiting %s state.\n", state->name); + + bs_sample_time(state); + bs_call_callbacks(state, BS_ON_EXIT); + bs_sample_time(state); + + bs_report_time(state); + state->complete = 1; } }
1 0
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • 5
  • ...
  • 51
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.