blob: db59b76ac897db2a8400e120227ff413c24c370b [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Duncan Laurie7d2b81c2012-06-23 16:08:47 -07002
3#ifndef ELOG_H_
4#define ELOG_H_
5
Ricardo Quesadacb4bb392021-07-16 16:44:58 -07006#include <commonlib/bsd/elog.h>
Elyes HAOUAS5817c562020-07-12 09:03:22 +02007#include <stdint.h>
8
Julius Wernercd49cce2019-03-05 16:53:33 -08009#if CONFIG(ELOG)
David Hendricks9acbd6f2014-04-13 16:45:31 -070010/* Eventlog backing storage must be initialized before calling elog_init(). */
Elyes Haouas3813ca52023-01-14 07:30:21 +010011int elog_init(void);
12int elog_clear(void);
Aaron Durbineec1c282016-08-06 10:02:37 -050013/* Event addition functions return < 0 on failure and 0 on success. */
Elyes Haouas3813ca52023-01-14 07:30:21 +010014int elog_add_event_raw(u8 event_type, void *data, u8 data_size);
15int elog_add_event(u8 event_type);
16int elog_add_event_byte(u8 event_type, u8 data);
17int elog_add_event_word(u8 event_type, u16 data);
18int elog_add_event_dword(u8 event_type, u32 data);
19int elog_add_event_wake(u8 source, u32 instance);
20int elog_smbios_write_type15(unsigned long *current, int handle);
21int elog_add_extended_event(u8 type, u32 complement);
David Hendricksd0d57a72014-05-08 20:04:02 -070022#else
23/* Stubs to help avoid littering sources with #if CONFIG_ELOG */
24static inline int elog_init(void) { return -1; }
25static inline int elog_clear(void) { return -1; }
Aaron Durbind9b10502016-11-04 11:17:54 -050026static inline int elog_add_event_raw(u8 event_type, void *data,
27 u8 data_size) { return 0; }
Aaron Durbineec1c282016-08-06 10:02:37 -050028static inline int elog_add_event(u8 event_type) { return 0; }
29static inline int elog_add_event_byte(u8 event_type, u8 data) { return 0; }
30static inline int elog_add_event_word(u8 event_type, u16 data) { return 0; }
31static inline int elog_add_event_dword(u8 event_type, u32 data) { return 0; }
32static inline int elog_add_event_wake(u8 source, u32 instance) { return 0; }
David Hendricksd0d57a72014-05-08 20:04:02 -070033static inline int elog_smbios_write_type15(unsigned long *current,
34 int handle) {
35 return 0;
36}
Richard Spiegele6809902018-08-20 13:51:30 -070037static inline int elog_add_extended_event(u8 type, u32 complement) { return 0; }
David Hendricksd0d57a72014-05-08 20:04:02 -070038#endif
Duncan Laurie7d2b81c2012-06-23 16:08:47 -070039
Kyösti Mälkki9dd1a122019-11-06 11:04:27 +020040#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
45static inline int elog_gsmi_add_event(u8 event_type) { return 0; }
46static inline int elog_gsmi_add_event_byte(u8 event_type, u8 data) { return 0; }
47static inline int elog_gsmi_add_event_word(u8 event_type, u16 data) { return 0; }
48#endif
49
Elyes Haouas3813ca52023-01-14 07:30:21 +010050u32 gsmi_exec(u8 command, u32 *param);
Duncan Laurie79bbbd92012-06-23 16:48:38 -070051
Julius Wernercd49cce2019-03-05 16:53:33 -080052#if CONFIG(ELOG_BOOT_COUNT)
Duncan Laurief4d36232012-06-23 16:37:45 -070053u32 boot_count_read(void);
Daniel Kurtzf55c3c22018-05-24 18:00:45 -060054#else
55static inline u32 boot_count_read(void)
56{
57 return 0;
58}
59#endif
Duncan Laurief4d36232012-06-23 16:37:45 -070060u32 boot_count_increment(void);
Duncan Laurief4d36232012-06-23 16:37:45 -070061
Kyösti Mälkki7f50afb2019-09-11 17:12:26 +030062static inline void elog_boot_notify(int s3_resume)
63{
64 if (CONFIG(ELOG_BOOT_COUNT) && !s3_resume)
65 boot_count_increment();
66}
67
Furquan Shaikh2dc5ead2017-10-14 18:12:25 -070068/*
69 * Callback from GSMI handler to allow platform to log any wake source
70 * information.
71 */
72void 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 */
78void elog_gsmi_cb_mainboard_log_wake_source(void);
79
Duncan Laurie7d2b81c2012-06-23 16:08:47 -070080#endif /* ELOG_H_ */