Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 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. |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef ELOG_H_ |
| 17 | #define ELOG_H_ |
| 18 | |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 19 | #define MAX_EVENT_SIZE 0x7F |
| 20 | |
| 21 | /* End of log */ |
| 22 | #define ELOG_TYPE_EOL 0xFF |
| 23 | |
| 24 | /* |
| 25 | * Standard SMBIOS event log types below 0x80 |
| 26 | */ |
| 27 | #define ELOG_TYPE_UNDEFINED_EVENT 0x00 |
| 28 | #define ELOG_TYPE_SINGLE_BIT_ECC_MEM_ERR 0x01 |
| 29 | #define ELOG_TYPE_MULTI_BIT_ECC_MEM_ERR 0x02 |
| 30 | #define ELOG_TYPE_MEM_PARITY_ERR 0x03 |
| 31 | #define ELOG_TYPE_BUS_TIMEOUT 0x04 |
| 32 | #define ELOG_TYPE_IO_CHECK 0x05 |
| 33 | #define ELOG_TYPE_SW_NMI 0x06 |
| 34 | #define ELOG_TYPE_POST_MEM_RESIZE 0x07 |
| 35 | #define ELOG_TYPE_POST_ERR 0x08 |
| 36 | #define ELOG_TYPE_PCI_PERR 0x09 |
| 37 | #define ELOG_TYPE_PCI_SERR 0x0A |
| 38 | #define ELOG_TYPE_CPU_FAIL 0x0B |
| 39 | #define ELOG_TYPE_EISA_TIMEOUT 0x0C |
| 40 | #define ELOG_TYPE_CORRECTABLE_MEMLOG_DIS 0x0D |
| 41 | #define ELOG_TYPE_LOG_DISABLED 0x0E |
| 42 | #define ELOG_TYPE_UNDEFINED_EVENT2 0x0F |
| 43 | #define ELOG_TYPE_SYS_LIMIT_EXCEED 0x10 |
| 44 | #define ELOG_TYPE_ASYNC_HW_TIMER_EXPIRED 0x11 |
| 45 | #define ELOG_TYPE_SYS_CONFIG_INFO 0x12 |
| 46 | #define ELOG_TYPE_HDD_INFO 0x13 |
| 47 | #define ELOG_TYPE_SYS_RECONFIG 0x14 |
| 48 | #define ELOG_TYPE_CPU_ERROR 0x15 |
| 49 | #define ELOG_TYPE_LOG_CLEAR 0x16 |
| 50 | #define ELOG_TYPE_BOOT 0x17 |
| 51 | |
| 52 | /* |
| 53 | * Extended defined OEM event types start at 0x80 |
| 54 | */ |
| 55 | |
| 56 | /* OS/kernel events */ |
| 57 | #define ELOG_TYPE_OS_EVENT 0x81 |
| 58 | |
| 59 | /* Last event from coreboot */ |
| 60 | #define ELOG_TYPE_OS_BOOT 0x90 |
| 61 | |
| 62 | /* Embedded controller event */ |
| 63 | #define ELOG_TYPE_EC_EVENT 0x91 |
Furquan Shaikh | 941e27b | 2016-11-11 13:55:56 -0800 | [diff] [blame] | 64 | #define EC_EVENT_LID_CLOSED 0x01 |
| 65 | #define EC_EVENT_LID_OPEN 0x02 |
| 66 | #define EC_EVENT_POWER_BUTTON 0x03 |
| 67 | #define EC_EVENT_AC_CONNECTED 0x04 |
| 68 | #define EC_EVENT_AC_DISCONNECTED 0x05 |
| 69 | #define EC_EVENT_BATTERY_LOW 0x06 |
| 70 | #define EC_EVENT_BATTERY_CRITICAL 0x07 |
| 71 | #define EC_EVENT_BATTERY 0x08 |
| 72 | #define EC_EVENT_THERMAL_THRESHOLD 0x09 |
Duncan Laurie | b14aefe | 2017-06-29 23:53:48 -0700 | [diff] [blame] | 73 | #define EC_EVENT_DEVICE_EVENT 0x0a |
Furquan Shaikh | 941e27b | 2016-11-11 13:55:56 -0800 | [diff] [blame] | 74 | #define EC_EVENT_THERMAL 0x0b |
| 75 | #define EC_EVENT_USB_CHARGER 0x0c |
| 76 | #define EC_EVENT_KEY_PRESSED 0x0d |
| 77 | #define EC_EVENT_INTERFACE_READY 0x0e |
| 78 | #define EC_EVENT_KEYBOARD_RECOVERY 0x0f |
| 79 | #define EC_EVENT_THERMAL_SHUTDOWN 0x10 |
| 80 | #define EC_EVENT_BATTERY_SHUTDOWN 0x11 |
| 81 | #define EC_EVENT_FAN_ERROR 0x12 |
| 82 | #define EC_EVENT_THROTTLE_STOP 0x13 |
| 83 | #define EC_EVENT_HANG_DETECT 0x14 |
| 84 | #define EC_EVENT_HANG_REBOOT 0x15 |
| 85 | #define EC_EVENT_PD_MCU 0x16 |
| 86 | #define EC_EVENT_BATTERY_STATUS 0x17 |
| 87 | #define EC_EVENT_PANIC 0x18 |
Furquan Shaikh | 644f1dc | 2017-03-08 16:04:16 -0800 | [diff] [blame] | 88 | #define EC_EVENT_KEYBOARD_FASTBOOT 0x19 |
| 89 | #define EC_EVENT_RTC 0x1a |
| 90 | #define EC_EVENT_MKBP 0x1b |
| 91 | #define EC_EVENT_USB_MUX 0x1c |
| 92 | #define EC_EVENT_MODE_CHANGE 0x1d |
| 93 | #define EC_EVENT_KEYBOARD_RECOVERY_HWREINIT 0x1e |
| 94 | #define EC_EVENT_EXTENDED 0x1f |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 95 | |
| 96 | /* Power */ |
| 97 | #define ELOG_TYPE_POWER_FAIL 0x92 |
| 98 | #define ELOG_TYPE_SUS_POWER_FAIL 0x93 |
| 99 | #define ELOG_TYPE_PWROK_FAIL 0x94 |
| 100 | #define ELOG_TYPE_SYS_PWROK_FAIL 0x95 |
| 101 | #define ELOG_TYPE_POWER_ON 0x96 |
| 102 | #define ELOG_TYPE_POWER_BUTTON 0x97 |
| 103 | #define ELOG_TYPE_POWER_BUTTON_OVERRIDE 0x98 |
| 104 | |
| 105 | /* Reset */ |
| 106 | #define ELOG_TYPE_RESET_BUTTON 0x99 |
| 107 | #define ELOG_TYPE_SYSTEM_RESET 0x9a |
| 108 | #define ELOG_TYPE_RTC_RESET 0x9b |
| 109 | #define ELOG_TYPE_TCO_RESET 0x9c |
| 110 | |
| 111 | /* Sleep/Wake */ |
| 112 | #define ELOG_TYPE_ACPI_ENTER 0x9d |
Richard Spiegel | e680990 | 2018-08-20 13:51:30 -0700 | [diff] [blame] | 113 | /* |
| 114 | * Deep Sx wake variant is provided below - 0xad |
| 115 | * Sleep/"wake pending" event log provided below - 0xb1 - 0x01/0x02 |
| 116 | */ |
| 117 | |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 118 | #define ELOG_TYPE_ACPI_WAKE 0x9e |
| 119 | #define ELOG_TYPE_WAKE_SOURCE 0x9f |
| 120 | #define ELOG_WAKE_SOURCE_PCIE 0x00 |
| 121 | #define ELOG_WAKE_SOURCE_PME 0x01 |
| 122 | #define ELOG_WAKE_SOURCE_PME_INTERNAL 0x02 |
| 123 | #define ELOG_WAKE_SOURCE_RTC 0x03 |
| 124 | #define ELOG_WAKE_SOURCE_GPIO 0x04 |
| 125 | #define ELOG_WAKE_SOURCE_SMBUS 0x05 |
Duncan Laurie | d604090 | 2013-03-08 17:16:37 -0800 | [diff] [blame] | 126 | #define ELOG_WAKE_SOURCE_PWRBTN 0x06 |
Furquan Shaikh | b858157 | 2017-05-25 00:13:01 -0700 | [diff] [blame] | 127 | #define ELOG_WAKE_SOURCE_PME_HDA 0x07 |
| 128 | #define ELOG_WAKE_SOURCE_PME_GBE 0x08 |
| 129 | #define ELOG_WAKE_SOURCE_PME_EMMC 0x09 |
| 130 | #define ELOG_WAKE_SOURCE_PME_SDCARD 0x0a |
| 131 | #define ELOG_WAKE_SOURCE_PME_PCIE1 0x0b |
| 132 | #define ELOG_WAKE_SOURCE_PME_PCIE2 0x0c |
| 133 | #define ELOG_WAKE_SOURCE_PME_PCIE3 0x0d |
| 134 | #define ELOG_WAKE_SOURCE_PME_PCIE4 0x0e |
| 135 | #define ELOG_WAKE_SOURCE_PME_PCIE5 0x0f |
| 136 | #define ELOG_WAKE_SOURCE_PME_PCIE6 0x10 |
| 137 | #define ELOG_WAKE_SOURCE_PME_PCIE7 0x11 |
| 138 | #define ELOG_WAKE_SOURCE_PME_PCIE8 0x12 |
| 139 | #define ELOG_WAKE_SOURCE_PME_PCIE9 0x13 |
| 140 | #define ELOG_WAKE_SOURCE_PME_PCIE10 0x14 |
| 141 | #define ELOG_WAKE_SOURCE_PME_PCIE11 0x15 |
| 142 | #define ELOG_WAKE_SOURCE_PME_PCIE12 0x16 |
| 143 | #define ELOG_WAKE_SOURCE_PME_SATA 0x17 |
| 144 | #define ELOG_WAKE_SOURCE_PME_CSE 0x18 |
| 145 | #define ELOG_WAKE_SOURCE_PME_CSE2 0x19 |
| 146 | #define ELOG_WAKE_SOURCE_PME_CSE3 0x1a |
| 147 | #define ELOG_WAKE_SOURCE_PME_XHCI 0x1b |
| 148 | #define ELOG_WAKE_SOURCE_PME_XDCI 0x1c |
Furquan Shaikh | 0f1dc0e | 2017-06-08 15:46:42 -0700 | [diff] [blame] | 149 | #define ELOG_WAKE_SOURCE_PME_XHCI_USB_2 0x1d |
| 150 | #define ELOG_WAKE_SOURCE_PME_XHCI_USB_3 0x1e |
Naresh G Solanki | 3c6377f | 2017-07-03 21:57:11 +0530 | [diff] [blame] | 151 | #define ELOG_WAKE_SOURCE_PME_WIFI 0x1f |
Vadim Bendebury | b9126fe | 2017-03-22 16:16:34 -0700 | [diff] [blame] | 152 | |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 153 | struct elog_event_data_wake { |
| 154 | u8 source; |
| 155 | u32 instance; |
Stefan Reinauer | 6a00113 | 2017-07-13 02:20:27 +0200 | [diff] [blame] | 156 | } __packed; |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 157 | |
| 158 | /* Chrome OS related events */ |
| 159 | #define ELOG_TYPE_CROS_DEVELOPER_MODE 0xa0 |
| 160 | #define ELOG_TYPE_CROS_RECOVERY_MODE 0xa1 |
Duncan Laurie | 8de8844 | 2012-07-16 12:47:45 -0700 | [diff] [blame] | 161 | #define ELOG_CROS_RECOVERY_MODE_BUTTON 0x02 |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 162 | |
Duncan Laurie | c1c9435 | 2012-07-13 10:11:54 -0700 | [diff] [blame] | 163 | /* Management Engine Events */ |
| 164 | #define ELOG_TYPE_MANAGEMENT_ENGINE 0xa2 |
Duncan Laurie | 5c88c6f | 2012-09-01 14:00:23 -0700 | [diff] [blame] | 165 | #define ELOG_TYPE_MANAGEMENT_ENGINE_EXT 0xa4 |
| 166 | struct elog_event_data_me_extended { |
| 167 | u8 current_working_state; |
| 168 | u8 operation_state; |
| 169 | u8 operation_mode; |
| 170 | u8 error_code; |
| 171 | u8 progress_code; |
| 172 | u8 current_pmevent; |
| 173 | u8 current_state; |
Stefan Reinauer | 6a00113 | 2017-07-13 02:20:27 +0200 | [diff] [blame] | 174 | } __packed; |
Duncan Laurie | c1c9435 | 2012-07-13 10:11:54 -0700 | [diff] [blame] | 175 | |
Duncan Laurie | 4dceba2 | 2012-08-13 09:40:02 -0700 | [diff] [blame] | 176 | /* Last post code from previous boot */ |
| 177 | #define ELOG_TYPE_LAST_POST_CODE 0xa3 |
Duncan Laurie | d5686fe | 2013-06-10 10:21:41 -0700 | [diff] [blame] | 178 | #define ELOG_TYPE_POST_EXTRA 0xa6 |
Duncan Laurie | 4dceba2 | 2012-08-13 09:40:02 -0700 | [diff] [blame] | 179 | |
Duncan Laurie | 19afe8d | 2012-11-26 14:53:42 -0800 | [diff] [blame] | 180 | /* EC Shutdown Reason */ |
| 181 | #define ELOG_TYPE_EC_SHUTDOWN 0xa5 |
| 182 | |
Aaron Durbin | d5be4e3 | 2016-11-04 10:53:43 -0500 | [diff] [blame] | 183 | /* ARM/generic versions of sleep/wake - These came from another firmware |
| 184 | * apparently, but not all the firmware sources were updated so that the |
| 185 | * elog namespace was coherent. */ |
| 186 | #define ELOG_TYPE_SLEEP 0xa7 |
| 187 | #define ELOG_TYPE_WAKE 0xa8 |
| 188 | #define ELOG_TYPE_FW_WAKE 0xa9 |
| 189 | |
Aaron Durbin | 7d9068f | 2016-11-04 10:07:14 -0500 | [diff] [blame] | 190 | /* Memory Cache Update */ |
| 191 | #define ELOG_TYPE_MEM_CACHE_UPDATE 0xaa |
| 192 | #define ELOG_MEM_CACHE_UPDATE_SLOT_NORMAL 0 |
Furquan Shaikh | cab1c01 | 2016-11-05 23:57:02 -0700 | [diff] [blame] | 193 | #define ELOG_MEM_CACHE_UPDATE_SLOT_RECOVERY 1 |
Andrey Petrov | ef9a9ea | 2016-11-08 08:30:06 -0800 | [diff] [blame] | 194 | #define ELOG_MEM_CACHE_UPDATE_SLOT_VARIABLE 2 |
Aaron Durbin | 7d9068f | 2016-11-04 10:07:14 -0500 | [diff] [blame] | 195 | #define ELOG_MEM_CACHE_UPDATE_STATUS_SUCCESS 0 |
| 196 | #define ELOG_MEM_CACHE_UPDATE_STATUS_FAIL 1 |
| 197 | struct elog_event_mem_cache_update { |
| 198 | u8 slot; |
| 199 | u8 status; |
Stefan Reinauer | 6a00113 | 2017-07-13 02:20:27 +0200 | [diff] [blame] | 200 | } __packed; |
Aaron Durbin | 7d9068f | 2016-11-04 10:07:14 -0500 | [diff] [blame] | 201 | |
Duncan Laurie | 6cbd398 | 2017-03-05 14:35:57 -0800 | [diff] [blame] | 202 | /* CPU Thermal Trip */ |
| 203 | #define ELOG_TYPE_THERM_TRIP 0xab |
| 204 | |
Vadim Bendebury | b9126fe | 2017-03-22 16:16:34 -0700 | [diff] [blame] | 205 | /* Cr50 */ |
| 206 | #define ELOG_TYPE_CR50_UPDATE 0xac |
| 207 | |
Furquan Shaikh | 75ef6ec | 2017-05-19 10:50:02 -0700 | [diff] [blame] | 208 | /* Deep Sx wake variant */ |
| 209 | #define ELOG_TYPE_ACPI_DEEP_WAKE 0xad |
| 210 | |
Duncan Laurie | b14aefe | 2017-06-29 23:53:48 -0700 | [diff] [blame] | 211 | /* EC Device Event */ |
| 212 | #define ELOG_TYPE_EC_DEVICE_EVENT 0xae |
| 213 | #define ELOG_EC_DEVICE_EVENT_TRACKPAD 0x01 |
| 214 | #define ELOG_EC_DEVICE_EVENT_DSP 0x02 |
| 215 | #define ELOG_EC_DEVICE_EVENT_WIFI 0x03 |
| 216 | |
Furquan Shaikh | 2dc5ead | 2017-10-14 18:12:25 -0700 | [diff] [blame] | 217 | /* S0ix sleep/wake */ |
| 218 | #define ELOG_TYPE_S0IX_ENTER 0xaf |
| 219 | #define ELOG_TYPE_S0IX_EXIT 0xb0 |
| 220 | |
Richard Spiegel | e680990 | 2018-08-20 13:51:30 -0700 | [diff] [blame] | 221 | /* Extended events */ |
| 222 | #define ELOG_TYPE_EXTENDED_EVENT 0xb1 |
| 223 | #define ELOG_SLEEP_PENDING_PM1_WAKE 0x01 |
| 224 | #define ELOG_SLEEP_PENDING_GPE0_WAKE 0x02 |
| 225 | |
Keith Short | e0f3400 | 2019-02-05 16:15:10 -0700 | [diff] [blame] | 226 | /* Cr50 reset to enable TPM */ |
| 227 | #define ELOG_TYPE_CR50_NEED_RESET 0xb2 |
| 228 | |
Richard Spiegel | e680990 | 2018-08-20 13:51:30 -0700 | [diff] [blame] | 229 | struct elog_event_extended_event { |
| 230 | u8 event_type; |
| 231 | u32 event_complement; |
| 232 | } __packed; |
| 233 | |
Martin Roth | 9634547 | 2017-06-24 14:13:53 -0600 | [diff] [blame] | 234 | #if IS_ENABLED(CONFIG_ELOG) |
David Hendricks | 9acbd6f | 2014-04-13 16:45:31 -0700 | [diff] [blame] | 235 | /* Eventlog backing storage must be initialized before calling elog_init(). */ |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 236 | extern int elog_init(void); |
| 237 | extern int elog_clear(void); |
Aaron Durbin | eec1c28 | 2016-08-06 10:02:37 -0500 | [diff] [blame] | 238 | /* Event addition functions return < 0 on failure and 0 on success. */ |
| 239 | extern int elog_add_event_raw(u8 event_type, void *data, u8 data_size); |
| 240 | extern int elog_add_event(u8 event_type); |
| 241 | extern int elog_add_event_byte(u8 event_type, u8 data); |
| 242 | extern int elog_add_event_word(u8 event_type, u16 data); |
| 243 | extern int elog_add_event_dword(u8 event_type, u32 data); |
| 244 | extern int elog_add_event_wake(u8 source, u32 instance); |
Duncan Laurie | 472ec9c | 2012-06-23 16:13:42 -0700 | [diff] [blame] | 245 | extern int elog_smbios_write_type15(unsigned long *current, int handle); |
Richard Spiegel | e680990 | 2018-08-20 13:51:30 -0700 | [diff] [blame] | 246 | extern int elog_add_extended_event(u8 type, u32 complement); |
David Hendricks | d0d57a7 | 2014-05-08 20:04:02 -0700 | [diff] [blame] | 247 | #else |
| 248 | /* Stubs to help avoid littering sources with #if CONFIG_ELOG */ |
| 249 | static inline int elog_init(void) { return -1; } |
| 250 | static inline int elog_clear(void) { return -1; } |
Aaron Durbin | d9b1050 | 2016-11-04 11:17:54 -0500 | [diff] [blame] | 251 | static inline int elog_add_event_raw(u8 event_type, void *data, |
| 252 | u8 data_size) { return 0; } |
Aaron Durbin | eec1c28 | 2016-08-06 10:02:37 -0500 | [diff] [blame] | 253 | static inline int elog_add_event(u8 event_type) { return 0; } |
| 254 | static inline int elog_add_event_byte(u8 event_type, u8 data) { return 0; } |
| 255 | static inline int elog_add_event_word(u8 event_type, u16 data) { return 0; } |
| 256 | static inline int elog_add_event_dword(u8 event_type, u32 data) { return 0; } |
| 257 | static inline int elog_add_event_wake(u8 source, u32 instance) { return 0; } |
David Hendricks | d0d57a7 | 2014-05-08 20:04:02 -0700 | [diff] [blame] | 258 | static inline int elog_smbios_write_type15(unsigned long *current, |
| 259 | int handle) { |
| 260 | return 0; |
| 261 | } |
Richard Spiegel | e680990 | 2018-08-20 13:51:30 -0700 | [diff] [blame] | 262 | static inline int elog_add_extended_event(u8 type, u32 complement) { return 0; } |
David Hendricks | d0d57a7 | 2014-05-08 20:04:02 -0700 | [diff] [blame] | 263 | #endif |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 264 | |
Duncan Laurie | 79bbbd9 | 2012-06-23 16:48:38 -0700 | [diff] [blame] | 265 | extern u32 gsmi_exec(u8 command, u32 *param); |
Duncan Laurie | 79bbbd9 | 2012-06-23 16:48:38 -0700 | [diff] [blame] | 266 | |
Daniel Kurtz | f55c3c2 | 2018-05-24 18:00:45 -0600 | [diff] [blame] | 267 | #if IS_ENABLED(CONFIG_ELOG_BOOT_COUNT) |
Duncan Laurie | f4d3623 | 2012-06-23 16:37:45 -0700 | [diff] [blame] | 268 | u32 boot_count_read(void); |
Daniel Kurtz | f55c3c2 | 2018-05-24 18:00:45 -0600 | [diff] [blame] | 269 | #else |
| 270 | static inline u32 boot_count_read(void) |
| 271 | { |
| 272 | return 0; |
| 273 | } |
| 274 | #endif |
Duncan Laurie | f4d3623 | 2012-06-23 16:37:45 -0700 | [diff] [blame] | 275 | u32 boot_count_increment(void); |
Duncan Laurie | f4d3623 | 2012-06-23 16:37:45 -0700 | [diff] [blame] | 276 | |
Furquan Shaikh | 2dc5ead | 2017-10-14 18:12:25 -0700 | [diff] [blame] | 277 | /* |
| 278 | * Callback from GSMI handler to allow platform to log any wake source |
| 279 | * information. |
| 280 | */ |
| 281 | void elog_gsmi_cb_platform_log_wake_source(void); |
| 282 | |
| 283 | /* |
| 284 | * Callback from GSMI handler to allow mainboard to log any wake source |
| 285 | * information. |
| 286 | */ |
| 287 | void elog_gsmi_cb_mainboard_log_wake_source(void); |
| 288 | |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 289 | #endif /* ELOG_H_ */ |