coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
me_smm.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/pci.h>
5 #include <device/pci_def.h>
6 #include <device/pci_ids.h>
7 #include <device/pci_ops.h>
8 #include <stdint.h>
9 
10 #include "me.h"
11 #include "pch.h"
12 
13 /* Send END OF POST message to the ME */
14 static int me8_mkhi_end_of_post(void)
15 {
16  struct mkhi_header mkhi = {
18  .command = MKHI_END_OF_POST,
19  };
20  struct mei_header mei = {
21  .is_complete = 1,
22  .host_address = MEI_HOST_ADDRESS,
23  .client_address = MEI_ADDRESS_MKHI,
24  .length = sizeof(mkhi),
25  };
26 
27  u32 eop_ack;
28 
29  /* Send request and wait for response */
30  printk(BIOS_NOTICE, "ME: %s\n", __func__);
31  if (mei_sendrecv(&mei, &mkhi, NULL, &eop_ack, sizeof(eop_ack)) < 0) {
32  printk(BIOS_ERR, "ME: END OF POST message failed\n");
33  return -1;
34  }
35 
36  printk(BIOS_INFO, "ME: END OF POST message successful (%d)\n", eop_ack);
37  return 0;
38 }
39 
40 /* Send END OF POST message to the ME */
41 static int me7_mkhi_end_of_post(void)
42 {
43  struct mkhi_header mkhi = {
45  .command = MKHI_END_OF_POST,
46  };
47  struct mei_header mei = {
48  .is_complete = 1,
49  .host_address = MEI_HOST_ADDRESS,
50  .client_address = MEI_ADDRESS_MKHI,
51  .length = sizeof(mkhi),
52  };
53 
54  /* Send request and wait for response */
55  if (mei_sendrecv(&mei, &mkhi, NULL, NULL, 0) < 0) {
56  printk(BIOS_ERR, "ME: END OF POST message failed\n");
57  return -1;
58  }
59 
60  printk(BIOS_INFO, "ME: END OF POST message successful\n");
61  return 0;
62 }
63 
65 {
66  union me_hfs hfs;
67 
69 
70  /* S3 path will have hidden this device already */
72  return;
73 
74  /* Make sure ME is in a mode that expects EOP */
76 
77  /* Abort and leave device alone if not normal mode */
78  if (hfs.fpt_bad ||
81  return;
82 
83  /* Try to send EOP command so ME stops accepting other commands */
85  switch (did) {
86  case 0x1c3a:
88  break;
89  case 0x1e3a:
91  break;
92  default:
93  printk(BIOS_ERR, "No finalize handler for ME %04x.\n", did);
94  }
95 
96  /* Make sure IO is disabled */
99 
100  /* Hide the PCI device */
102 }
#define printk(level,...)
Definition: stdlib.h:16
uint16_t did
Definition: tis.c:16
static __always_inline void pci_and_config16(const struct device *dev, u16 reg, u16 andmask)
Definition: pci_ops.h:147
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_NOTICE
BIOS_NOTICE - Unexpected but relatively insignificant.
Definition: loglevel.h:100
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
void intel_me_finalize_smm(void)
Definition: me_smm.c:64
static int me7_mkhi_end_of_post(void)
Definition: me_smm.c:41
static int me8_mkhi_end_of_post(void)
Definition: me_smm.c:14
#define PCI_COMMAND_IO
Definition: pci_def.h:11
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_COMMAND_MEMORY
Definition: pci_def.h:12
#define PCI_COMMAND
Definition: pci_def.h:10
#define PCI_DEVICE_ID
Definition: pci_def.h:9
#define ME_HFS_MODE_NORMAL
Definition: me.h:36
#define MEI_ADDRESS_MKHI
Definition: me.h:229
#define PCI_ME_HFS
Definition: me.h:18
#define ME_HFS_CWS_NORMAL
Definition: me.h:22
#define MEI_HOST_ADDRESS
Definition: me.h:233
#define MKHI_GROUP_ID_GEN
Definition: me.h:252
#define MKHI_END_OF_POST
Definition: me.h:254
#define PCH_DISABLE_MEI1
Definition: rcba.h:149
#define FD2
Definition: rcba.h:128
bool is_mei_base_address_valid(void)
void update_mei_base_address(void)
int mei_sendrecv(struct mei_header *mei, struct mkhi_header *mkhi, void *req_data, void *rsp_data, int rsp_bytes)
Definition: me_common.c:306
#define PCH_ME_DEV
Definition: pch.h:79
#define RCBA32_OR(x, or)
Definition: rcba.h:22
#define NULL
Definition: stddef.h:19
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
Definition: me.h:51
u32 raw
Definition: me.h:69
u32 fpt_bad
Definition: me.h:54
u32 working_state
Definition: me.h:52
u32 operation_mode
Definition: me.h:60
Definition: me.h:235
u32 is_complete
Definition: me.h:240
u32 group_id
Definition: me.h:259