diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2011-09-23 14:07:04 -0700 |
---|---|---|
committer | Vadim Bendebury <vbendeb@chromium.org> | 2011-09-26 11:14:51 -0700 |
commit | 9cc79dbbd72b2200763357a0c0fdd16190f3ed5e (patch) | |
tree | 9afab9c256c01acd9208d5ed318ad9ab2d70f16b /arch | |
parent | e57479c1e59afa58a644ece6e578da66427d74cd (diff) |
Enable coreboot timestamp facility support in u-boot.
This change turns on the code which allows u-boot to add
timestamps to the timestamp table created by coreboot.
Since u-boot does not use the tsc_t like structure to represent
HW counter readings, this structure is being replaced by 64 bit
integer.
The timestamp_init() function is now initializing the base timer
value used by u-boot to calculate the HW counter increments.
Timestamp facility is initialized as soon as the timestamp table
pointer is found in the coreboot table. The u-boot generated
timer events' ID will start at 1000 to clearly separate u-boot
events from coreboot events in the timer trace.
BUG=chromium-os:20733
TEST=manual
A Python script was used to retrieve the CBMEM timestamp table
while running CromeOS. The script will later be submitted into
the ChromeOS tools directory.
The following output was generated by the script:
localhost ~ # /var/vbendeb/cbmem.py
id 1, value 804,824,023
id 2, value 7,846,816,530
id 1000, value 19,356,528,758
Change-Id: I48c46e7b5cd2b2601d12465e0d8946152f31126e
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/8274
Reviewed-by: Stefan Reinauer <reinauer@google.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/cpu/coreboot/Makefile | 1 | ||||
-rw-r--r-- | arch/x86/cpu/coreboot/timestamp.c | 48 |
2 files changed, 12 insertions, 37 deletions
diff --git a/arch/x86/cpu/coreboot/Makefile b/arch/x86/cpu/coreboot/Makefile index 7af7fa0d65f..7672b1ab15f 100644 --- a/arch/x86/cpu/coreboot/Makefile +++ b/arch/x86/cpu/coreboot/Makefile @@ -37,6 +37,7 @@ COBJS-$(CONFIG_SYS_COREBOOT) += tables.o COBJS-$(CONFIG_SYS_COREBOOT) += ipchecksum.o COBJS-$(CONFIG_SYS_COREBOOT) += sdram.o COBJS-$(CONFIG_SYS_COREBOOT) += sysinfo.o +COBJS-$(CONFIG_SYS_COREBOOT) += timestamp.o SOBJS-$(CONFIG_SYS_COREBOOT) += coreboot_car.o diff --git a/arch/x86/cpu/coreboot/timestamp.c b/arch/x86/cpu/coreboot/timestamp.c index bbb8197dca6..3a16d37a7c0 100644 --- a/arch/x86/cpu/coreboot/timestamp.c +++ b/arch/x86/cpu/coreboot/timestamp.c @@ -17,55 +17,29 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA */ -#include <stdint.h> -#include <console/console.h> -#include <cbmem.h> -#include <timestamp.h> +#include <common.h> +#include <coreboot/timestamp.h> +#include <asm/ic/coreboot/sysinfo.h> -#define MAX_TIMESTAMPS 30 +static struct timestamp_table *ts_table; -#ifndef __PRE_RAM__ -static struct timestamp_table* ts_table; -#endif - -static uint64_t tsc_to_uint64(tsc_t tstamp) +void timestamp_init(void) { - return (((uint64_t)tstamp.hi) << 32) + tstamp.lo; + ts_table = lib_sysinfo.tstamp_table; + set_base_timer_value(ts_table->base_time); + timestamp_add_now(TS_U_BOOT_INITTED); } -void timestamp_init(tsc_t base) -{ - struct timestamp_table* tst; - - tst = cbmem_add(CBMEM_ID_TIMESTAMP, - sizeof(struct timestamp_table) + - MAX_TIMESTAMPS * sizeof(struct timestamp_entry)); - - if (!tst) { - printk(BIOS_ERR, "ERROR: failed to allocate timstamp table\n"); - return; - } - - tst->base_time = tsc_to_uint64(base); - tst->max_entries = MAX_TIMESTAMPS; - tst->num_entries = 0; -} - -void timestamp_add(enum timestamp_id id, tsc_t ts_time) +void timestamp_add(enum timestamp_id id, uint64_t ts_time) { struct timestamp_entry *tse; -#ifdef __PRE_RAM__ - struct timestamp_table *ts_table = cbmem_find(CBMEM_ID_TIMESTAMP); -#else - if (!ts_table) - ts_table = cbmem_find(CBMEM_ID_TIMESTAMP); -#endif + if (!ts_table || (ts_table->num_entries == ts_table->max_entries)) return; tse = &ts_table->entries[ts_table->num_entries++]; tse->entry_id = id; - tse->entry_stamp = tsc_to_uint64(ts_time) - ts_table->base_time; + tse->entry_stamp = ts_time - ts_table->base_time; } void timestamp_add_now(enum timestamp_id id) |