blob: 7e51d80eb2ba76b7e712abcb3a7830cdc2b07db8 [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.
Vadim Bendebury6f72d692011-09-21 16:12:39 -070014 */
15
16#ifndef __TIMESTAMP_H__
17#define __TIMESTAMP_H__
18
Aaron Durbindc9f5cd2015-09-08 13:34:43 -050019#include <commonlib/timestamp_serialized.h>
Vadim Bendebury6f72d692011-09-21 16:12:39 -070020
Kyösti Mälkki26447932013-10-11 21:14:59 +030021#if CONFIG_COLLECT_TIMESTAMPS && (CONFIG_EARLY_CBMEM_INIT || !defined(__PRE_RAM__))
Aaron Durbin1936f6c2015-07-03 17:04:21 -050022/*
23 * timestamp_init() needs to be called once for each of these cases:
24 * 1. __PRE_RAM__ (bootblock, romstage, verstage, etc) and
25 * 2. !__PRE_RAM__ (ramstage)
26 * The latter is taken care of by the generic coreboot infrastructure so
27 * it's up to the chipset/arch to call timestamp_init() in *one* of
28 * the __PRE_RAM__ stages. If multiple calls are made timestamps will be lost.
29 */
Stefan Reinauer3a6550d2013-08-01 13:31:44 -070030void timestamp_init(uint64_t base);
Aaron Durbin1936f6c2015-07-03 17:04:21 -050031/*
32 * Add a new timestamp. Depending on cbmem is available or not, this timestamp
33 * will be stored to cbmem / timestamp cache.
34 */
Stefan Reinauer3a6550d2013-08-01 13:31:44 -070035void timestamp_add(enum timestamp_id id, uint64_t ts_time);
Aaron Durbin1936f6c2015-07-03 17:04:21 -050036/* Calls timestamp_add with current timestamp. */
Vadim Bendebury6f72d692011-09-21 16:12:39 -070037void timestamp_add_now(enum timestamp_id id);
Stefan Reinauerbf729ba2011-11-04 12:31:58 -070038#else
39#define timestamp_init(base)
40#define timestamp_add(id, time)
41#define timestamp_add_now(id)
42#endif
Vadim Bendebury6f72d692011-09-21 16:12:39 -070043
Stefan Reinauer3a6550d2013-08-01 13:31:44 -070044/* Implemented by the architecture code */
45uint64_t timestamp_get(void);
46uint64_t get_initial_timestamp(void);
Aaron Durbinc49014e2015-08-30 21:19:55 -050047/* Returns timestamp tick frequency in MHz. */
48int timestamp_tick_freq_mhz(void);
Stefan Reinauer3a6550d2013-08-01 13:31:44 -070049
Vadim Bendebury6f72d692011-09-21 16:12:39 -070050#endif