1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
5 * Modified from the coreboot version
9 #include <asm/arch/timestamp.h>
10 #include <asm/cb_sysinfo.h>
11 #include <asm/u-boot-x86.h>
12 #include <linux/compiler.h>
14 static struct timestamp_table *ts_table __section(".data");
16 void timestamp_init(void)
18 timestamp_add_now(TS_U_BOOT_INITTED);
21 void timestamp_add(enum timestamp_id id, uint64_t ts_time)
23 struct timestamp_entry *tse;
25 if (!ts_table || (ts_table->num_entries == ts_table->max_entries))
28 tse = &ts_table->entries[ts_table->num_entries++];
30 tse->entry_stamp = ts_time - ts_table->base_time;
33 void timestamp_add_now(enum timestamp_id id)
35 timestamp_add(id, rdtsc());
38 int timestamp_add_to_bootstage(void)
45 for (i = 0; i < ts_table->num_entries; i++) {
46 struct timestamp_entry *tse = &ts_table->entries[i];
47 const char *name = NULL;
49 switch (tse->entry_id) {
50 case TS_START_ROMSTAGE:
51 name = "start-romstage";
53 case TS_BEFORE_INITRAM:
54 name = "before-initram";
56 case TS_DEVICE_INITIALIZE:
57 name = "device-initialize";
62 case TS_SELFBOOT_JUMP:
63 name = "selfboot-jump";
67 bootstage_add_record(0, name, BOOTSTAGEF_ALLOC,