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 | |
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; |
Aaron Durbin | c49014e | 2015-08-30 21:19:55 -0500 | [diff] [blame] | 32 | uint16_t max_entries; |
| 33 | uint16_t tick_freq_mhz; |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 34 | uint32_t num_entries; |
| 35 | struct timestamp_entry entries[0]; /* Variable number of entries */ |
| 36 | } __attribute__((packed)); |
| 37 | |
| 38 | enum timestamp_id { |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 39 | TS_START_ROMSTAGE = 1, |
| 40 | TS_BEFORE_INITRAM = 2, |
| 41 | TS_AFTER_INITRAM = 3, |
| 42 | TS_END_ROMSTAGE = 4, |
Aaron Durbin | 22919ce | 2013-03-01 17:07:51 -0600 | [diff] [blame] | 43 | TS_START_VBOOT = 5, |
| 44 | TS_END_VBOOT = 6, |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 45 | TS_START_COPYRAM = 8, |
| 46 | TS_END_COPYRAM = 9, |
| 47 | TS_START_RAMSTAGE = 10, |
Furquan Shaikh | 42e23a6 | 2014-10-14 15:18:38 -0700 | [diff] [blame] | 48 | TS_START_BOOTBLOCK = 11, |
| 49 | TS_END_BOOTBLOCK = 12, |
Julius Werner | a7d9244 | 2014-12-02 20:51:19 -0800 | [diff] [blame] | 50 | TS_START_COPYROM = 13, |
| 51 | TS_END_COPYROM = 14, |
| 52 | TS_START_ULZMA = 15, |
| 53 | TS_END_ULZMA = 16, |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 54 | TS_DEVICE_ENUMERATE = 30, |
| 55 | TS_DEVICE_CONFIGURE = 40, |
| 56 | TS_DEVICE_ENABLE = 50, |
| 57 | TS_DEVICE_INITIALIZE = 60, |
| 58 | TS_DEVICE_DONE = 70, |
Stefan Reinauer | bb11e60 | 2012-05-10 12:15:18 -0700 | [diff] [blame] | 59 | TS_CBMEM_POST = 75, |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 60 | TS_WRITE_TABLES = 80, |
| 61 | TS_LOAD_PAYLOAD = 90, |
Duncan Laurie | cde7801 | 2011-10-19 15:32:39 -0700 | [diff] [blame] | 62 | TS_ACPI_WAKE_JUMP = 98, |
| 63 | TS_SELFBOOT_JUMP = 99, |
Julius Werner | a7d9244 | 2014-12-02 20:51:19 -0800 | [diff] [blame] | 64 | |
| 65 | /* 500+ reserved for vendorcode extensions (500-600: google/chromeos) */ |
| 66 | TS_START_COPYVER = 501, |
| 67 | TS_END_COPYVER = 502, |
| 68 | TS_START_TPMINIT = 503, |
| 69 | TS_END_TPMINIT = 504, |
| 70 | TS_START_VERIFY_SLOT = 505, |
| 71 | TS_END_VERIFY_SLOT = 506, |
| 72 | TS_START_HASH_BODY = 507, |
| 73 | TS_DONE_LOADING = 508, |
| 74 | TS_DONE_HASHING = 509, |
| 75 | TS_END_HASH_BODY = 510, |
| 76 | |
Lee Leahy | b817908 | 2015-02-24 11:30:38 -0800 | [diff] [blame] | 77 | /* 950+ reserved for vendorcode extensions (950-999: intel/fsp) */ |
| 78 | TS_FSP_MEMORY_INIT_START = 950, |
| 79 | TS_FSP_MEMORY_INIT_END = 951, |
| 80 | TS_FSP_TEMP_RAM_EXIT_START = 952, |
| 81 | TS_FSP_TEMP_RAM_EXIT_END = 953, |
| 82 | TS_FSP_SILICON_INIT_START = 954, |
| 83 | TS_FSP_SILICON_INIT_END = 955, |
| 84 | TS_FSP_BEFORE_ENUMERATE = 956, |
| 85 | TS_FSP_AFTER_ENUMERATE = 957, |
| 86 | TS_FSP_BEFORE_FINALIZE = 958, |
| 87 | TS_FSP_AFTER_FINALIZE = 959, |
| 88 | |
Julius Werner | a7d9244 | 2014-12-02 20:51:19 -0800 | [diff] [blame] | 89 | /* 1000+ reserved for payloads (1000-1200: ChromeOS depthcharge) */ |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
Kyösti Mälkki | 2644793 | 2013-10-11 21:14:59 +0300 | [diff] [blame] | 92 | #if CONFIG_COLLECT_TIMESTAMPS && (CONFIG_EARLY_CBMEM_INIT || !defined(__PRE_RAM__)) |
Aaron Durbin | 1936f6c | 2015-07-03 17:04:21 -0500 | [diff] [blame] | 93 | /* |
| 94 | * timestamp_init() needs to be called once for each of these cases: |
| 95 | * 1. __PRE_RAM__ (bootblock, romstage, verstage, etc) and |
| 96 | * 2. !__PRE_RAM__ (ramstage) |
| 97 | * The latter is taken care of by the generic coreboot infrastructure so |
| 98 | * it's up to the chipset/arch to call timestamp_init() in *one* of |
| 99 | * the __PRE_RAM__ stages. If multiple calls are made timestamps will be lost. |
| 100 | */ |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 101 | void timestamp_init(uint64_t base); |
Aaron Durbin | 1936f6c | 2015-07-03 17:04:21 -0500 | [diff] [blame] | 102 | /* |
| 103 | * Add a new timestamp. Depending on cbmem is available or not, this timestamp |
| 104 | * will be stored to cbmem / timestamp cache. |
| 105 | */ |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 106 | void timestamp_add(enum timestamp_id id, uint64_t ts_time); |
Aaron Durbin | 1936f6c | 2015-07-03 17:04:21 -0500 | [diff] [blame] | 107 | /* Calls timestamp_add with current timestamp. */ |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 108 | void timestamp_add_now(enum timestamp_id id); |
Stefan Reinauer | bf729ba | 2011-11-04 12:31:58 -0700 | [diff] [blame] | 109 | #else |
| 110 | #define timestamp_init(base) |
| 111 | #define timestamp_add(id, time) |
| 112 | #define timestamp_add_now(id) |
| 113 | #endif |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 114 | |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 115 | /* Implemented by the architecture code */ |
| 116 | uint64_t timestamp_get(void); |
| 117 | uint64_t get_initial_timestamp(void); |
Aaron Durbin | c49014e | 2015-08-30 21:19:55 -0500 | [diff] [blame] | 118 | /* Returns timestamp tick frequency in MHz. */ |
| 119 | int timestamp_tick_freq_mhz(void); |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 120 | |
Vadim Bendebury | 6f72d69 | 2011-09-21 16:12:39 -0700 | [diff] [blame] | 121 | #endif |