Angel Pons | 32859fc | 2020-04-02 23:48:27 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 2 | |
| 3 | #ifndef ELOG_H_ |
| 4 | #define ELOG_H_ |
| 5 | |
Ricardo Quesada | cb4bb39 | 2021-07-16 16:44:58 -0700 | [diff] [blame] | 6 | #include <commonlib/bsd/elog.h> |
Elyes HAOUAS | 5817c56 | 2020-07-12 09:03:22 +0200 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 9 | #if CONFIG(ELOG) |
David Hendricks | 9acbd6f | 2014-04-13 16:45:31 -0700 | [diff] [blame] | 10 | /* Eventlog backing storage must be initialized before calling elog_init(). */ |
Elyes Haouas | 3813ca5 | 2023-01-14 07:30:21 +0100 | [diff] [blame] | 11 | int elog_init(void); |
| 12 | int elog_clear(void); |
Aaron Durbin | eec1c28 | 2016-08-06 10:02:37 -0500 | [diff] [blame] | 13 | /* Event addition functions return < 0 on failure and 0 on success. */ |
Elyes Haouas | 3813ca5 | 2023-01-14 07:30:21 +0100 | [diff] [blame] | 14 | int elog_add_event_raw(u8 event_type, void *data, u8 data_size); |
| 15 | int elog_add_event(u8 event_type); |
| 16 | int elog_add_event_byte(u8 event_type, u8 data); |
| 17 | int elog_add_event_word(u8 event_type, u16 data); |
| 18 | int elog_add_event_dword(u8 event_type, u32 data); |
| 19 | int elog_add_event_wake(u8 source, u32 instance); |
| 20 | int elog_smbios_write_type15(unsigned long *current, int handle); |
| 21 | int elog_add_extended_event(u8 type, u32 complement); |
David Hendricks | d0d57a7 | 2014-05-08 20:04:02 -0700 | [diff] [blame] | 22 | #else |
| 23 | /* Stubs to help avoid littering sources with #if CONFIG_ELOG */ |
| 24 | static inline int elog_init(void) { return -1; } |
| 25 | static inline int elog_clear(void) { return -1; } |
Aaron Durbin | d9b1050 | 2016-11-04 11:17:54 -0500 | [diff] [blame] | 26 | static inline int elog_add_event_raw(u8 event_type, void *data, |
| 27 | u8 data_size) { return 0; } |
Aaron Durbin | eec1c28 | 2016-08-06 10:02:37 -0500 | [diff] [blame] | 28 | static inline int elog_add_event(u8 event_type) { return 0; } |
| 29 | static inline int elog_add_event_byte(u8 event_type, u8 data) { return 0; } |
| 30 | static inline int elog_add_event_word(u8 event_type, u16 data) { return 0; } |
| 31 | static inline int elog_add_event_dword(u8 event_type, u32 data) { return 0; } |
| 32 | 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] | 33 | static inline int elog_smbios_write_type15(unsigned long *current, |
| 34 | int handle) { |
| 35 | return 0; |
| 36 | } |
Richard Spiegel | e680990 | 2018-08-20 13:51:30 -0700 | [diff] [blame] | 37 | 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] | 38 | #endif |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 39 | |
Kyösti Mälkki | 9dd1a12 | 2019-11-06 11:04:27 +0200 | [diff] [blame] | 40 | #if CONFIG(ELOG_GSMI) |
| 41 | #define elog_gsmi_add_event elog_add_event |
| 42 | #define elog_gsmi_add_event_byte elog_add_event_byte |
| 43 | #define elog_gsmi_add_event_word elog_add_event_word |
| 44 | #else |
| 45 | static inline int elog_gsmi_add_event(u8 event_type) { return 0; } |
| 46 | static inline int elog_gsmi_add_event_byte(u8 event_type, u8 data) { return 0; } |
| 47 | static inline int elog_gsmi_add_event_word(u8 event_type, u16 data) { return 0; } |
| 48 | #endif |
| 49 | |
Elyes Haouas | 3813ca5 | 2023-01-14 07:30:21 +0100 | [diff] [blame] | 50 | u32 gsmi_exec(u8 command, u32 *param); |
Duncan Laurie | 79bbbd9 | 2012-06-23 16:48:38 -0700 | [diff] [blame] | 51 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 52 | #if CONFIG(ELOG_BOOT_COUNT) |
Duncan Laurie | f4d3623 | 2012-06-23 16:37:45 -0700 | [diff] [blame] | 53 | u32 boot_count_read(void); |
Daniel Kurtz | f55c3c2 | 2018-05-24 18:00:45 -0600 | [diff] [blame] | 54 | #else |
| 55 | static inline u32 boot_count_read(void) |
| 56 | { |
| 57 | return 0; |
| 58 | } |
| 59 | #endif |
Duncan Laurie | f4d3623 | 2012-06-23 16:37:45 -0700 | [diff] [blame] | 60 | u32 boot_count_increment(void); |
Duncan Laurie | f4d3623 | 2012-06-23 16:37:45 -0700 | [diff] [blame] | 61 | |
Kyösti Mälkki | 7f50afb | 2019-09-11 17:12:26 +0300 | [diff] [blame] | 62 | static inline void elog_boot_notify(int s3_resume) |
| 63 | { |
| 64 | if (CONFIG(ELOG_BOOT_COUNT) && !s3_resume) |
| 65 | boot_count_increment(); |
| 66 | } |
| 67 | |
Furquan Shaikh | 2dc5ead | 2017-10-14 18:12:25 -0700 | [diff] [blame] | 68 | /* |
| 69 | * Callback from GSMI handler to allow platform to log any wake source |
| 70 | * information. |
| 71 | */ |
| 72 | void elog_gsmi_cb_platform_log_wake_source(void); |
| 73 | |
| 74 | /* |
| 75 | * Callback from GSMI handler to allow mainboard to log any wake source |
| 76 | * information. |
| 77 | */ |
| 78 | void elog_gsmi_cb_mainboard_log_wake_source(void); |
| 79 | |
Duncan Laurie | 7d2b81c | 2012-06-23 16:08:47 -0700 | [diff] [blame] | 80 | #endif /* ELOG_H_ */ |