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 | |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 23 | struct timestamp_entry { |
| 24 | uint32_t entry_id; |
| 25 | uint64_t entry_stamp; |
| 26 | } __attribute__((packed)); |
| 27 | |
| 28 | struct timestamp_table { |
| 29 | uint64_t base_time; |
| 30 | uint32_t max_entries; |
| 31 | uint32_t num_entries; |
| 32 | struct timestamp_entry entries[0]; /* Variable number of entries */ |
| 33 | } __attribute__((packed)); |
| 34 | |
| 35 | enum timestamp_id { |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 36 | TS_START_ROMSTAGE = 1, |
| 37 | TS_BEFORE_INITRAM = 2, |
| 38 | TS_AFTER_INITRAM = 3, |
| 39 | TS_END_ROMSTAGE = 4, |
Aaron Durbin | 22919ce | 2013-03-01 17:07:51 -0600 | [diff] [blame] | 40 | TS_START_VBOOT = 5, |
| 41 | TS_END_VBOOT = 6, |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 42 | TS_START_COPYRAM = 8, |
| 43 | TS_END_COPYRAM = 9, |
| 44 | TS_START_RAMSTAGE = 10, |
| 45 | TS_DEVICE_ENUMERATE = 30, |
| 46 | TS_DEVICE_CONFIGURE = 40, |
| 47 | TS_DEVICE_ENABLE = 50, |
| 48 | TS_DEVICE_INITIALIZE = 60, |
| 49 | TS_DEVICE_DONE = 70, |
Stefan Reinauer | bb11e60 | 2012-05-10 12:15:18 -0700 | [diff] [blame] | 50 | TS_CBMEM_POST = 75, |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 51 | TS_WRITE_TABLES = 80, |
| 52 | TS_LOAD_PAYLOAD = 90, |
Duncan Laurie | cde7801 | 2011-10-19 15:32:39 -0700 | [diff] [blame] | 53 | TS_ACPI_WAKE_JUMP = 98, |
| 54 | TS_SELFBOOT_JUMP = 99, |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 57 | #if CONFIG_COLLECT_TIMESTAMPS |
Vadim Bendebury | 0a1c2d6 | 2012-09-27 18:42:57 -0700 | [diff] [blame] | 58 | #include <cpu/x86/tsc.h> |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 59 | void timestamp_init(tsc_t base); |
| 60 | void timestamp_add(enum timestamp_id id, tsc_t ts_time); |
| 61 | void timestamp_add_now(enum timestamp_id id); |
Stefan Reinauer | 4221a19 | 2012-10-15 15:23:20 -0700 | [diff] [blame] | 62 | void timestamp_sync(void); |
Kyösti Mälkki | e28bd4a | 2013-09-07 11:38:56 +0300 | [diff] [blame] | 63 | tsc_t get_initial_timestamp(void); |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 64 | #else |
| 65 | #define timestamp_init(base) |
| 66 | #define timestamp_add(id, time) |
| 67 | #define timestamp_add_now(id) |
Stefan Reinauer | 4221a19 | 2012-10-15 15:23:20 -0700 | [diff] [blame] | 68 | #define timestamp_sync() |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 69 | #endif |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 70 | |
| 71 | #endif |