Move the timestamp code out of x86/cpu/coreboot to lib/coreboot and make it generic. This lets us migrate the timestamp table from coreboot into U-Boot's version of boot stage timing and use it on ARM based devices. --- arch/x86/cpu/coreboot/Makefile | 1 - arch/x86/cpu/coreboot/coreboot.c | 6 +----- arch/x86/lib/bootm.c | 5 ++--- arch/x86/lib/zimage.c | 3 --- .../timestamp.h => include/coreboot_timestamp.h | 7 ------- lib/coreboot/Makefile | 1 + lib/coreboot/cb_sysinfo.c | 3 +++ {arch/x86/cpu => lib}/coreboot/timestamp.c | 13 ++++++++----- 8 files changed, 15 insertions(+), 24 deletions(-) rename arch/x86/include/asm/arch-coreboot/timestamp.h => include/coreboot_timestamp.h (68%) rename {arch/x86/cpu => lib}/coreboot/timestamp.c (84%)
diff --git a/arch/x86/cpu/coreboot/Makefile b/arch/x86/cpu/coreboot/Makefile index a6c7d0e56d50..f7ba346b83cd 100644 --- a/arch/x86/cpu/coreboot/Makefile +++ b/arch/x86/cpu/coreboot/Makefile @@ -20,4 +20,3 @@ else obj-y += sdram.o endif obj-y += coreboot.o -obj-y += timestamp.o diff --git a/arch/x86/cpu/coreboot/coreboot.c b/arch/x86/cpu/coreboot/coreboot.c index e1dbce4f0b29..33e37376e9f4 100644 --- a/arch/x86/cpu/coreboot/coreboot.c +++ b/arch/x86/cpu/coreboot/coreboot.c @@ -6,6 +6,7 @@ */ #include <cb_sysinfo.h> +#include <coreboot_timestamp.h> #include <cpu_func.h> #include <event.h> #include <fdtdec.h> @@ -15,7 +16,6 @@ #include <asm/io.h> #include <asm/msr.h> #include <asm/mtrr.h> -#include <asm/arch/timestamp.h> #include <dm/ofnode.h> int arch_cpu_init(void) @@ -35,8 +35,6 @@ int arch_cpu_init(void) gd_set_acpi_start(map_to_sysmem(lib_sysinfo.rsdp)); gd_set_smbios_start(lib_sysinfo.smbios_start); - timestamp_init(); - return 0; } @@ -74,8 +72,6 @@ static void board_final_init(void) static int last_stage_init(void) { - timestamp_add_to_bootstage(); - if (IS_ENABLED(CONFIG_XPL_BUILD)) return 0; diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c index 0827a884b1d2..f46d78946929 100644 --- a/arch/x86/lib/bootm.c +++ b/arch/x86/lib/bootm.c @@ -10,6 +10,8 @@ #include <bootm.h> #include <bootstage.h> #include <command.h> +#include <coreboot_tables.h> +#include <coreboot_timestamp.h> #include <efi.h> #include <hang.h> #include <log.h> @@ -24,9 +26,6 @@ #include <asm/cpu.h> #include <asm/byteorder.h> #include <asm/zimage.h> -#ifdef CONFIG_SYS_COREBOOT -#include <asm/arch/timestamp.h> -#endif DECLARE_GLOBAL_DATA_PTR; diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 2ea9bcf59c27..8d40714dad0b 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -31,9 +31,6 @@ #include <asm/bootparam.h> #include <asm/efi.h> #include <asm/global_data.h> -#ifdef CONFIG_SYS_COREBOOT -#include <asm/arch/timestamp.h> -#endif #include <linux/compiler.h> #include <linux/ctype.h> #include <linux/libfdt.h> diff --git a/arch/x86/include/asm/arch-coreboot/timestamp.h b/include/coreboot_timestamp.h similarity index 68% rename from arch/x86/include/asm/arch-coreboot/timestamp.h rename to include/coreboot_timestamp.h index 227316975047..8f34d801037d 100644 --- a/arch/x86/include/asm/arch-coreboot/timestamp.h +++ b/include/coreboot_timestamp.h @@ -14,11 +14,4 @@ void timestamp_init(void); void timestamp_add(enum timestamp_id id, uint64_t ts_time); void timestamp_add_now(enum timestamp_id id); -/** - * timestamp_add_to_bootstage - Add important coreboot timestamps to bootstage - * - * Return: 0 if ok, -1 if no timestamps were found - */ -int timestamp_add_to_bootstage(void); - #endif diff --git a/lib/coreboot/Makefile b/lib/coreboot/Makefile index 0f5cb90a056e..daeebc6654e3 100644 --- a/lib/coreboot/Makefile +++ b/lib/coreboot/Makefile @@ -15,3 +15,4 @@ obj-y += cb_sysinfo.o ifndef CONFIG_XPL_BUILD obj-y += sdram.o endif +obj-y += timestamp.o diff --git a/lib/coreboot/cb_sysinfo.c b/lib/coreboot/cb_sysinfo.c index 0155b72ff37e..ec9a47242e34 100644 --- a/lib/coreboot/cb_sysinfo.c +++ b/lib/coreboot/cb_sysinfo.c @@ -7,6 +7,7 @@ */ #include <cb_sysinfo.h> +#include <coreboot_timestamp.h> #include <fdt_support.h> #include <init.h> #include <mapmem.h> @@ -491,6 +492,8 @@ int get_coreboot_info(struct sysinfo_t *info) gd->arch.coreboot_table = addr; gd->flags |= GD_FLG_SKIP_LL_INIT; + timestamp_init(); + return 0; } diff --git a/arch/x86/cpu/coreboot/timestamp.c b/lib/coreboot/timestamp.c similarity index 84% rename from arch/x86/cpu/coreboot/timestamp.c rename to lib/coreboot/timestamp.c index 18be969ccea6..192a28d7188a 100644 --- a/arch/x86/cpu/coreboot/timestamp.c +++ b/lib/coreboot/timestamp.c @@ -7,10 +7,12 @@ #include <bootstage.h> #include <cb_sysinfo.h> +#include <coreboot_tables.h> +#include <coreboot_timestamp.h> +#include <event.h> #include <errno.h> -#include <asm/arch/timestamp.h> -#include <asm/u-boot-x86.h> #include <linux/compiler.h> +#include <time.h> void timestamp_init(void) { @@ -33,10 +35,10 @@ void timestamp_add(enum timestamp_id id, uint64_t ts_time) void timestamp_add_now(enum timestamp_id id) { - timestamp_add(id, rdtsc()); + timestamp_add(id, get_ticks()); } -int timestamp_add_to_bootstage(void) +static int timestamp_add_to_bootstage(void) { const struct sysinfo_t *info = cb_get_sysinfo(); const struct timestamp_table *ts_table = info->tstamp_table; @@ -69,9 +71,10 @@ int timestamp_add_to_bootstage(void) if (name) { bootstage_add_record(0, name, BOOTSTAGEF_ALLOC, tse->entry_stamp / - get_tbclk_mhz()); + (get_tbclk() / 1000000)); } } return 0; } +EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, timestamp_add_to_bootstage); -- Sent by a computer, using git, on the internet