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 |
| 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 Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame^] | 23 | #include <stdint.h> |
| 24 | |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 25 | struct timestamp_entry { |
| 26 | uint32_t entry_id; |
| 27 | uint64_t entry_stamp; |
| 28 | } __attribute__((packed)); |
| 29 | |
| 30 | struct 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 | |
| 37 | enum timestamp_id { |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 38 | TS_START_ROMSTAGE = 1, |
| 39 | TS_BEFORE_INITRAM = 2, |
| 40 | TS_AFTER_INITRAM = 3, |
| 41 | TS_END_ROMSTAGE = 4, |
Aaron Durbin | 22919ce | 2013-03-01 17:07:51 -0600 | [diff] [blame] | 42 | TS_START_VBOOT = 5, |
| 43 | TS_END_VBOOT = 6, |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 44 | TS_START_COPYRAM = 8, |
| 45 | TS_END_COPYRAM = 9, |
| 46 | TS_START_RAMSTAGE = 10, |
| 47 | TS_DEVICE_ENUMERATE = 30, |
Martin Roth | a642716 | 2014-04-25 14:12:13 -0600 | [diff] [blame] | 48 | TS_FSP_BEFORE_ENUMERATE, |
| 49 | TS_FSP_AFTER_ENUMERATE, |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 50 | TS_DEVICE_CONFIGURE = 40, |
| 51 | TS_DEVICE_ENABLE = 50, |
| 52 | TS_DEVICE_INITIALIZE = 60, |
| 53 | TS_DEVICE_DONE = 70, |
Stefan Reinauer | bb11e60 | 2012-05-10 12:15:18 -0700 | [diff] [blame] | 54 | TS_CBMEM_POST = 75, |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 55 | TS_WRITE_TABLES = 80, |
Martin Roth | a642716 | 2014-04-25 14:12:13 -0600 | [diff] [blame] | 56 | TS_FSP_BEFORE_FINALIZE, |
| 57 | TS_FSP_AFTER_FINALIZE, |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 58 | TS_LOAD_PAYLOAD = 90, |
Duncan Laurie | cde7801 | 2011-10-19 15:32:39 -0700 | [diff] [blame] | 59 | TS_ACPI_WAKE_JUMP = 98, |
| 60 | TS_SELFBOOT_JUMP = 99, |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
Kyösti Mälkki | 2644793 | 2013-10-11 21:14:59 +0300 | [diff] [blame] | 63 | #if CONFIG_COLLECT_TIMESTAMPS && (CONFIG_EARLY_CBMEM_INIT || !defined(__PRE_RAM__)) |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame^] | 64 | void timestamp_init(uint64_t base); |
| 65 | void timestamp_add(enum timestamp_id id, uint64_t ts_time); |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 66 | void timestamp_add_now(enum timestamp_id id); |
Kyösti Mälkki | cbf5bdf | 2013-09-10 00:07:21 +0300 | [diff] [blame] | 67 | void timestamp_reinit(void); |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 68 | #else |
| 69 | #define timestamp_init(base) |
| 70 | #define timestamp_add(id, time) |
| 71 | #define timestamp_add_now(id) |
Kyösti Mälkki | cbf5bdf | 2013-09-10 00:07:21 +0300 | [diff] [blame] | 72 | #define timestamp_reinit() |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 73 | #endif |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 74 | |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame^] | 75 | /* Implemented by the architecture code */ |
| 76 | uint64_t timestamp_get(void); |
| 77 | uint64_t get_initial_timestamp(void); |
| 78 | |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 79 | #endif |