1 // SPDX-License-Identifier: GPL-2.0+
3 * This file is part of the coreboot project.
5 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
9 #include <asm/arch/timestamp.h>
10 #include <asm/arch/sysinfo.h>
11 #include <linux/compiler.h>
13 struct timestamp_entry {
18 struct timestamp_table {
22 struct timestamp_entry entries[0]; /* Variable number of entries */
25 static struct timestamp_table *ts_table __attribute__((section(".data")));
27 void timestamp_init(void)
29 timestamp_add_now(TS_U_BOOT_INITTED);
32 void timestamp_add(enum timestamp_id id, uint64_t ts_time)
34 struct timestamp_entry *tse;
36 if (!ts_table || (ts_table->num_entries == ts_table->max_entries))
39 tse = &ts_table->entries[ts_table->num_entries++];
41 tse->entry_stamp = ts_time - ts_table->base_time;
44 void timestamp_add_now(enum timestamp_id id)
46 timestamp_add(id, rdtsc());
49 int timestamp_add_to_bootstage(void)
56 for (i = 0; i < ts_table->num_entries; i++) {
57 struct timestamp_entry *tse = &ts_table->entries[i];
58 const char *name = NULL;
60 switch (tse->entry_id) {
61 case TS_START_ROMSTAGE:
62 name = "start-romstage";
64 case TS_BEFORE_INITRAM:
65 name = "before-initram";
67 case TS_DEVICE_INITIALIZE:
68 name = "device-initialize";
73 case TS_SELFBOOT_JUMP:
74 name = "selfboot-jump";
78 bootstage_add_record(0, name, BOOTSTAGEF_ALLOC,