coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
smihandler.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <acpi/acpi.h>
4 #include <console/console.h>
5 #include <cpu/x86/smm.h>
7 #include <elog.h>
8 #include <halt.h>
9 #include "smm.h"
10 
12 {
14 
15  /* Log this event */
16  if (event)
18 
19  switch (event) {
21  printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n");
22 
23  poweroff();
24  break;
25  }
26  return !!event;
27 }
28 
30 {
31  /* Process all pending events */
33  ;
34 }
35 
36 static void clear_pending_events(void)
37 {
38  struct ec_response_get_next_event mkbp_event;
39 
41  ;
42 
43  printk(BIOS_DEBUG, "Clearing pending EC events. Error code EC_RES_UNAVAILABLE(9) is expected.\n");
44  while (google_chromeec_get_mkbp_event(&mkbp_event) == 0)
45  ;
46 }
47 
48 void chromeec_smi_sleep(int slp_type, uint64_t s3_mask, uint64_t s5_mask)
49 {
51  switch (slp_type) {
52  case ACPI_S3:
53  /* Enable wake events */
55  break;
56  case ACPI_S5:
57  /* Enable wake events */
59  break;
60  }
61  }
62 
63  /* Disable SCI and SMI events */
66 
67  /* Clear pending events that may trigger immediate wake */
69 }
70 
71 void chromeec_smi_device_event_sleep(int slp_type, uint64_t s3_mask,
72  uint64_t s5_mask)
73 {
74  switch (slp_type) {
75  case ACPI_S3:
76  /* Enable device wake events */
78  break;
79  case ACPI_S5:
80  /* Enable device wake events */
82  break;
83  }
84 
85  /* Read and clear pending events that may trigger immediate wake */
87 }
88 
89 void chromeec_smi_apmc(int apmc, uint64_t sci_mask, uint64_t smi_mask)
90 {
91  switch (apmc) {
96  break;
101  break;
102  }
103 }
#define ELOG_TYPE_EC_EVENT
Definition: elog.h:90
#define printk(level,...)
Definition: stdlib.h:16
int google_chromeec_set_device_enabled_events(uint64_t mask)
Definition: ec.c:323
int google_chromeec_set_wake_mask(uint64_t mask)
Definition: ec.c:1131
uint64_t google_chromeec_get_device_current_events(void)
Definition: ec.c:344
int google_chromeec_get_mkbp_event(struct ec_response_get_next_event *event)
Definition: ec.c:284
int google_chromeec_set_smi_mask(uint64_t mask)
Definition: ec.c:1125
bool google_chromeec_is_uhepi_supported(void)
Definition: ec.c:177
int google_chromeec_set_sci_mask(uint64_t mask)
Definition: ec.c:1119
enum host_event_code google_chromeec_get_event(void)
Definition: ec_i2c.c:242
void chromeec_smi_sleep(int slp_type, uint64_t s3_mask, uint64_t s5_mask)
Definition: smihandler.c:48
static void clear_pending_events(void)
Definition: smihandler.c:36
void chromeec_smi_process_events(void)
Definition: smihandler.c:29
void chromeec_smi_apmc(int apmc, uint64_t sci_mask, uint64_t smi_mask)
Definition: smihandler.c:89
static int chromeec_process_one_event(void)
Definition: smihandler.c:11
void chromeec_smi_device_event_sleep(int slp_type, uint64_t s3_mask, uint64_t s5_mask)
Definition: smihandler.c:71
@ EC_HOST_EVENT_NONE
Definition: ec_commands.h:654
@ EC_HOST_EVENT_LID_CLOSED
Definition: ec_commands.h:655
void poweroff(void)
Definition: acpi.c:13
@ ACPI_S5
Definition: acpi.h:1385
@ ACPI_S3
Definition: acpi.h:1383
#define APM_CNT_ACPI_DISABLE
Definition: smm.h:21
#define APM_CNT_ACPI_ENABLE
Definition: smm.h:22
static int elog_gsmi_add_event_byte(u8 event_type, u8 data)
Definition: elog.h:46
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
unsigned long long uint64_t
Definition: stdint.h:17
unsigned char uint8_t
Definition: stdint.h:8