blob: cd648ea00b72cd106dfb3bc7f83d0c814c42dfce [file] [log] [blame]
Vadim Bendebury6f72d692011-09-21 16:12:39 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
18 */
19
20#ifndef __TIMESTAMP_H__
21#define __TIMESTAMP_H__
22
Stefan Reinauer3a6550d2013-08-01 13:31:44 -070023#include <stdint.h>
24
Vadim Bendebury6f72d692011-09-21 16:12:39 -070025struct timestamp_entry {
26 uint32_t entry_id;
27 uint64_t entry_stamp;
28} __attribute__((packed));
29
30struct timestamp_table {
31 uint64_t base_time;
32 uint32_t max_entries;
33 uint32_t num_entries;
34 struct timestamp_entry entries[0]; /* Variable number of entries */
35} __attribute__((packed));
36
37enum timestamp_id {
Stefan Reinauerbf729ba2011-11-04 12:31:58 -070038 TS_START_ROMSTAGE = 1,
39 TS_BEFORE_INITRAM = 2,
40 TS_AFTER_INITRAM = 3,
41 TS_END_ROMSTAGE = 4,
Aaron Durbin22919ce2013-03-01 17:07:51 -060042 TS_START_VBOOT = 5,
43 TS_END_VBOOT = 6,
Stefan Reinauerbf729ba2011-11-04 12:31:58 -070044 TS_START_COPYRAM = 8,
45 TS_END_COPYRAM = 9,
46 TS_START_RAMSTAGE = 10,
Furquan Shaikh42e23a62014-10-14 15:18:38 -070047 TS_START_BOOTBLOCK = 11,
48 TS_END_BOOTBLOCK = 12,
Julius Wernera7d92442014-12-02 20:51:19 -080049 TS_START_COPYROM = 13,
50 TS_END_COPYROM = 14,
51 TS_START_ULZMA = 15,
52 TS_END_ULZMA = 16,
Stefan Reinauerbf729ba2011-11-04 12:31:58 -070053 TS_DEVICE_ENUMERATE = 30,
Martin Rotha6427162014-04-25 14:12:13 -060054 TS_FSP_BEFORE_ENUMERATE,
55 TS_FSP_AFTER_ENUMERATE,
Stefan Reinauerbf729ba2011-11-04 12:31:58 -070056 TS_DEVICE_CONFIGURE = 40,
57 TS_DEVICE_ENABLE = 50,
58 TS_DEVICE_INITIALIZE = 60,
59 TS_DEVICE_DONE = 70,
Stefan Reinauerbb11e602012-05-10 12:15:18 -070060 TS_CBMEM_POST = 75,
Stefan Reinauerbf729ba2011-11-04 12:31:58 -070061 TS_WRITE_TABLES = 80,
Martin Rotha6427162014-04-25 14:12:13 -060062 TS_FSP_BEFORE_FINALIZE,
63 TS_FSP_AFTER_FINALIZE,
Stefan Reinauerbf729ba2011-11-04 12:31:58 -070064 TS_LOAD_PAYLOAD = 90,
Duncan Lauriecde78012011-10-19 15:32:39 -070065 TS_ACPI_WAKE_JUMP = 98,
66 TS_SELFBOOT_JUMP = 99,
Julius Wernera7d92442014-12-02 20:51:19 -080067
68 /* 500+ reserved for vendorcode extensions (500-600: google/chromeos) */
69 TS_START_COPYVER = 501,
70 TS_END_COPYVER = 502,
71 TS_START_TPMINIT = 503,
72 TS_END_TPMINIT = 504,
73 TS_START_VERIFY_SLOT = 505,
74 TS_END_VERIFY_SLOT = 506,
75 TS_START_HASH_BODY = 507,
76 TS_DONE_LOADING = 508,
77 TS_DONE_HASHING = 509,
78 TS_END_HASH_BODY = 510,
79
80 /* 1000+ reserved for payloads (1000-1200: ChromeOS depthcharge) */
Vadim Bendebury6f72d692011-09-21 16:12:39 -070081};
82
Kyösti Mälkki26447932013-10-11 21:14:59 +030083#if CONFIG_COLLECT_TIMESTAMPS && (CONFIG_EARLY_CBMEM_INIT || !defined(__PRE_RAM__))
Stefan Reinauer3a6550d2013-08-01 13:31:44 -070084void timestamp_init(uint64_t base);
85void timestamp_add(enum timestamp_id id, uint64_t ts_time);
Vadim Bendebury6f72d692011-09-21 16:12:39 -070086void timestamp_add_now(enum timestamp_id id);
Kyösti Mälkkicbf5bdf2013-09-10 00:07:21 +030087void timestamp_reinit(void);
Stefan Reinauerbf729ba2011-11-04 12:31:58 -070088#else
89#define timestamp_init(base)
90#define timestamp_add(id, time)
91#define timestamp_add_now(id)
Kyösti Mälkkicbf5bdf2013-09-10 00:07:21 +030092#define timestamp_reinit()
Stefan Reinauerbf729ba2011-11-04 12:31:58 -070093#endif
Vadim Bendebury6f72d692011-09-21 16:12:39 -070094
Stefan Reinauer3a6550d2013-08-01 13:31:44 -070095/* Implemented by the architecture code */
96uint64_t timestamp_get(void);
97uint64_t get_initial_timestamp(void);
98
Vadim Bendebury6f72d692011-09-21 16:12:39 -070099#endif