1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #ifndef ELOG_H_
4 #define ELOG_H_
5
6 #include <commonlib/bsd/elog.h>
7 #include <stdint.h>
8
9 #if CONFIG(ELOG)
10 /* Eventlog backing storage must be initialized before calling elog_init(). */
11 int elog_init(void);
12 int elog_clear(void);
13 /* Event addition functions return < 0 on failure and 0 on success. */
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);
22 #else
23 /* Stubs to help avoid littering sources with #if CONFIG_ELOG */
elog_init(void)24 static inline int elog_init(void) { return -1; }
elog_clear(void)25 static inline int elog_clear(void) { return -1; }
elog_add_event_raw(u8 event_type,void * data,u8 data_size)26 static inline int elog_add_event_raw(u8 event_type, void *data,
27 u8 data_size) { return 0; }
elog_add_event(u8 event_type)28 static inline int elog_add_event(u8 event_type) { return 0; }
elog_add_event_byte(u8 event_type,u8 data)29 static inline int elog_add_event_byte(u8 event_type, u8 data) { return 0; }
elog_add_event_word(u8 event_type,u16 data)30 static inline int elog_add_event_word(u8 event_type, u16 data) { return 0; }
elog_add_event_dword(u8 event_type,u32 data)31 static inline int elog_add_event_dword(u8 event_type, u32 data) { return 0; }
elog_add_event_wake(u8 source,u32 instance)32 static inline int elog_add_event_wake(u8 source, u32 instance) { return 0; }
elog_smbios_write_type15(unsigned long * current,int handle)33 static inline int elog_smbios_write_type15(unsigned long *current,
34 int handle) {
35 return 0;
36 }
elog_add_extended_event(u8 type,u32 complement)37 static inline int elog_add_extended_event(u8 type, u32 complement) { return 0; }
38 #endif
39
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
elog_gsmi_add_event(u8 event_type)45 static inline int elog_gsmi_add_event(u8 event_type) { return 0; }
elog_gsmi_add_event_byte(u8 event_type,u8 data)46 static inline int elog_gsmi_add_event_byte(u8 event_type, u8 data) { return 0; }
elog_gsmi_add_event_word(u8 event_type,u16 data)47 static inline int elog_gsmi_add_event_word(u8 event_type, u16 data) { return 0; }
48 #endif
49
50 u32 gsmi_exec(u8 command, u32 *param);
51
52 #if CONFIG(ELOG_BOOT_COUNT)
53 u32 boot_count_read(void);
54 #else
boot_count_read(void)55 static inline u32 boot_count_read(void)
56 {
57 return 0;
58 }
59 #endif
60 u32 boot_count_increment(void);
61
elog_boot_notify(int s3_resume)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
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
80 #endif /* ELOG_H_ */
81