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. |
| 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 ELOG_H_ |
| 21 | #define ELOG_H_ |
| 22 | |
| 23 | #if CONFIG_ELOG |
| 24 | |
| 25 | /* SMI command code for GSMI event logging */ |
| 26 | #define ELOG_GSMI_APM_CNT 0xEF |
| 27 | |
| 28 | #define MAX_EVENT_SIZE 0x7F |
| 29 | |
| 30 | /* End of log */ |
| 31 | #define ELOG_TYPE_EOL 0xFF |
| 32 | |
| 33 | /* |
| 34 | * Standard SMBIOS event log types below 0x80 |
| 35 | */ |
| 36 | #define ELOG_TYPE_UNDEFINED_EVENT 0x00 |
| 37 | #define ELOG_TYPE_SINGLE_BIT_ECC_MEM_ERR 0x01 |
| 38 | #define ELOG_TYPE_MULTI_BIT_ECC_MEM_ERR 0x02 |
| 39 | #define ELOG_TYPE_MEM_PARITY_ERR 0x03 |
| 40 | #define ELOG_TYPE_BUS_TIMEOUT 0x04 |
| 41 | #define ELOG_TYPE_IO_CHECK 0x05 |
| 42 | #define ELOG_TYPE_SW_NMI 0x06 |
| 43 | #define ELOG_TYPE_POST_MEM_RESIZE 0x07 |
| 44 | #define ELOG_TYPE_POST_ERR 0x08 |
| 45 | #define ELOG_TYPE_PCI_PERR 0x09 |
| 46 | #define ELOG_TYPE_PCI_SERR 0x0A |
| 47 | #define ELOG_TYPE_CPU_FAIL 0x0B |
| 48 | #define ELOG_TYPE_EISA_TIMEOUT 0x0C |
| 49 | #define ELOG_TYPE_CORRECTABLE_MEMLOG_DIS 0x0D |
| 50 | #define ELOG_TYPE_LOG_DISABLED 0x0E |
| 51 | #define ELOG_TYPE_UNDEFINED_EVENT2 0x0F |
| 52 | #define ELOG_TYPE_SYS_LIMIT_EXCEED 0x10 |
| 53 | #define ELOG_TYPE_ASYNC_HW_TIMER_EXPIRED 0x11 |
| 54 | #define ELOG_TYPE_SYS_CONFIG_INFO 0x12 |
| 55 | #define ELOG_TYPE_HDD_INFO 0x13 |
| 56 | #define ELOG_TYPE_SYS_RECONFIG 0x14 |
| 57 | #define ELOG_TYPE_CPU_ERROR 0x15 |
| 58 | #define ELOG_TYPE_LOG_CLEAR 0x16 |
| 59 | #define ELOG_TYPE_BOOT 0x17 |
| 60 | |
| 61 | /* |
| 62 | * Extended defined OEM event types start at 0x80 |
| 63 | */ |
| 64 | |
| 65 | /* OS/kernel events */ |
| 66 | #define ELOG_TYPE_OS_EVENT 0x81 |
| 67 | |
| 68 | /* Last event from coreboot */ |
| 69 | #define ELOG_TYPE_OS_BOOT 0x90 |
| 70 | |
| 71 | /* Embedded controller event */ |
| 72 | #define ELOG_TYPE_EC_EVENT 0x91 |
Duncan Laurie | 39f6bb6 | 2012-09-10 10:03:46 -0700 | [diff] [blame] | 73 | #define EC_EVENT_LID_CLOSED 0x01 |
| 74 | #define EC_EVENT_LID_OPEN 0x02 |
| 75 | #define EC_EVENT_POWER_BUTTON 0x03 |
| 76 | #define EC_EVENT_AC_CONNECTED 0x04 |
| 77 | #define EC_EVENT_AC_DISCONNECTED 0x05 |
| 78 | #define EC_EVENT_BATTERY_LOW 0x06 |
| 79 | #define EC_EVENT_BATTERY_CRITICAL 0x07 |
| 80 | #define EC_EVENT_BATTERY 0x08 |
| 81 | #define EC_EVENT_THERMAL_THRESHOLD 0x09 |
| 82 | #define EC_EVENT_THERMAL_OVERLOAD 0x0a |
| 83 | #define EC_EVENT_THERMAL 0x0b |
| 84 | #define EC_EVENT_USB_CHARGER 0x0c |
| 85 | #define EC_EVENT_KEY_PRESSED 0x0d |
| 86 | #define EC_EVENT_INTERFACE_READY 0x0e |
| 87 | #define EC_EVENT_KEYBOARD_RECOVERY 0x0f |
| 88 | #define EC_EVENT_THERMAL_SHUTDOWN 0x10 |
| 89 | #define EC_EVENT_BATTERY_SHUTDOWN 0x11 |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 90 | |
| 91 | /* Power */ |
| 92 | #define ELOG_TYPE_POWER_FAIL 0x92 |
| 93 | #define ELOG_TYPE_SUS_POWER_FAIL 0x93 |
| 94 | #define ELOG_TYPE_PWROK_FAIL 0x94 |
| 95 | #define ELOG_TYPE_SYS_PWROK_FAIL 0x95 |
| 96 | #define ELOG_TYPE_POWER_ON 0x96 |
| 97 | #define ELOG_TYPE_POWER_BUTTON 0x97 |
| 98 | #define ELOG_TYPE_POWER_BUTTON_OVERRIDE 0x98 |
| 99 | |
| 100 | /* Reset */ |
| 101 | #define ELOG_TYPE_RESET_BUTTON 0x99 |
| 102 | #define ELOG_TYPE_SYSTEM_RESET 0x9a |
| 103 | #define ELOG_TYPE_RTC_RESET 0x9b |
| 104 | #define ELOG_TYPE_TCO_RESET 0x9c |
| 105 | |
| 106 | /* Sleep/Wake */ |
| 107 | #define ELOG_TYPE_ACPI_ENTER 0x9d |
| 108 | #define ELOG_TYPE_ACPI_WAKE 0x9e |
| 109 | #define ELOG_TYPE_WAKE_SOURCE 0x9f |
| 110 | #define ELOG_WAKE_SOURCE_PCIE 0x00 |
| 111 | #define ELOG_WAKE_SOURCE_PME 0x01 |
| 112 | #define ELOG_WAKE_SOURCE_PME_INTERNAL 0x02 |
| 113 | #define ELOG_WAKE_SOURCE_RTC 0x03 |
| 114 | #define ELOG_WAKE_SOURCE_GPIO 0x04 |
| 115 | #define ELOG_WAKE_SOURCE_SMBUS 0x05 |
| 116 | struct elog_event_data_wake { |
| 117 | u8 source; |
| 118 | u32 instance; |
| 119 | } __attribute__ ((packed)); |
| 120 | |
| 121 | /* Chrome OS related events */ |
| 122 | #define ELOG_TYPE_CROS_DEVELOPER_MODE 0xa0 |
| 123 | #define ELOG_TYPE_CROS_RECOVERY_MODE 0xa1 |
Duncan Laurie | 8de8844 | 2012-07-16 12:47:45 -0700 | [diff] [blame] | 124 | #define ELOG_CROS_RECOVERY_MODE_BUTTON 0x02 |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 125 | |
Duncan Laurie | c1c9435 | 2012-07-13 10:11:54 -0700 | [diff] [blame] | 126 | /* Management Engine Events */ |
| 127 | #define ELOG_TYPE_MANAGEMENT_ENGINE 0xa2 |
Duncan Laurie | 5c88c6f | 2012-09-01 14:00:23 -0700 | [diff] [blame] | 128 | #define ELOG_TYPE_MANAGEMENT_ENGINE_EXT 0xa4 |
| 129 | struct elog_event_data_me_extended { |
| 130 | u8 current_working_state; |
| 131 | u8 operation_state; |
| 132 | u8 operation_mode; |
| 133 | u8 error_code; |
| 134 | u8 progress_code; |
| 135 | u8 current_pmevent; |
| 136 | u8 current_state; |
| 137 | } __attribute__ ((packed)); |
Duncan Laurie | c1c9435 | 2012-07-13 10:11:54 -0700 | [diff] [blame] | 138 | |
Duncan Laurie | 4dceba2 | 2012-08-13 09:40:02 -0700 | [diff] [blame] | 139 | /* Last post code from previous boot */ |
| 140 | #define ELOG_TYPE_LAST_POST_CODE 0xa3 |
| 141 | |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 142 | extern int elog_init(void); |
| 143 | extern int elog_clear(void); |
| 144 | extern void elog_add_event_raw(u8 event_type, void *data, u8 data_size); |
| 145 | extern void elog_add_event(u8 event_type); |
| 146 | extern void elog_add_event_byte(u8 event_type, u8 data); |
| 147 | extern void elog_add_event_word(u8 event_type, u16 data); |
| 148 | extern void elog_add_event_dword(u8 event_type, u32 data); |
| 149 | extern void elog_add_event_wake(u8 source, u32 instance); |
Duncan Laurie | 472ec9c | 2012-06-23 16:13:42 -0700 | [diff] [blame] | 150 | extern int elog_smbios_write_type15(unsigned long *current, int handle); |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 151 | |
Duncan Laurie | 79bbbd9 | 2012-06-23 16:48:38 -0700 | [diff] [blame] | 152 | #if CONFIG_ELOG_GSMI |
| 153 | extern u32 gsmi_exec(u8 command, u32 *param); |
| 154 | #endif |
| 155 | |
Duncan Laurie | f4d3623 | 2012-06-23 16:37:45 -0700 | [diff] [blame] | 156 | #if CONFIG_ELOG_BOOT_COUNT |
| 157 | u32 boot_count_read(void); |
| 158 | u32 boot_count_increment(void); |
| 159 | #endif |
| 160 | |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 161 | #endif /* !CONFIG_ELOG */ |
| 162 | |
| 163 | #endif /* ELOG_H_ */ |