Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 1 | /* |
| 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 |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 17 | * Foundation, Inc. |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #ifndef __TIMESTAMP_H__ |
| 21 | #define __TIMESTAMP_H__ |
| 22 | |
Aaron Durbin | dc9f5cd | 2015-09-08 13:34:43 -0500 | [diff] [blame^] | 23 | #include <commonlib/timestamp_serialized.h> |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 24 | |
Kyösti Mälkki | 2644793 | 2013-10-11 21:14:59 +0300 | [diff] [blame] | 25 | #if CONFIG_COLLECT_TIMESTAMPS && (CONFIG_EARLY_CBMEM_INIT || !defined(__PRE_RAM__)) |
Aaron Durbin | 1936f6c | 2015-07-03 17:04:21 -0500 | [diff] [blame] | 26 | /* |
| 27 | * timestamp_init() needs to be called once for each of these cases: |
| 28 | * 1. __PRE_RAM__ (bootblock, romstage, verstage, etc) and |
| 29 | * 2. !__PRE_RAM__ (ramstage) |
| 30 | * The latter is taken care of by the generic coreboot infrastructure so |
| 31 | * it's up to the chipset/arch to call timestamp_init() in *one* of |
| 32 | * the __PRE_RAM__ stages. If multiple calls are made timestamps will be lost. |
| 33 | */ |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 34 | void timestamp_init(uint64_t base); |
Aaron Durbin | 1936f6c | 2015-07-03 17:04:21 -0500 | [diff] [blame] | 35 | /* |
| 36 | * Add a new timestamp. Depending on cbmem is available or not, this timestamp |
| 37 | * will be stored to cbmem / timestamp cache. |
| 38 | */ |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 39 | void timestamp_add(enum timestamp_id id, uint64_t ts_time); |
Aaron Durbin | 1936f6c | 2015-07-03 17:04:21 -0500 | [diff] [blame] | 40 | /* Calls timestamp_add with current timestamp. */ |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 41 | void timestamp_add_now(enum timestamp_id id); |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 42 | #else |
| 43 | #define timestamp_init(base) |
| 44 | #define timestamp_add(id, time) |
| 45 | #define timestamp_add_now(id) |
| 46 | #endif |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 47 | |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 48 | /* Implemented by the architecture code */ |
| 49 | uint64_t timestamp_get(void); |
| 50 | uint64_t get_initial_timestamp(void); |
Aaron Durbin | c49014e | 2015-08-30 21:19:55 -0500 | [diff] [blame] | 51 | /* Returns timestamp tick frequency in MHz. */ |
| 52 | int timestamp_tick_freq_mhz(void); |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 53 | |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 54 | #endif |