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 <types.h>
4 #include <console/console.h>
5 #include <cpu/x86/smm.h>
6 #include <device/pci_def.h>
8 #include "i82801jx.h"
9 
10 /* While we read PMBASE dynamically in case it changed, let's
11  * initialize it with a sane value
12  */
14 
16 {
17 #define IOTRAP(x) (trap_sts & (1 << x))
18  u32 trap_sts, trap_cycle;
19  u32 data, mask = 0;
20  int i;
21 
22  trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
23  RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
24 
25  trap_cycle = RCBA32(0x1e10);
26  for (i=16; i<20; i++) {
27  if (trap_cycle & (1 << i))
28  mask |= (0xff << ((i - 16) << 3));
29  }
30 
31  /* IOTRAP(3) SMI function call (unused) */
32  if (IOTRAP(3)) {
33  printk(BIOS_DEBUG, "SMI function call not implemented\n");
34  return;
35  }
36 
37  /* IOTRAP(2) currently unused
38  * IOTRAP(1) currently unused */
39 
40  /* IOTRAP(0) SMIC */
41  if (IOTRAP(0)) {
42  if (!(trap_cycle & (1 << 24))) { // It's a write
43  printk(BIOS_DEBUG, "SMI1 command\n");
44  data = RCBA32(0x1e18);
45  data &= mask;
46  // if (smi1)
47  // southbridge_smi_command(data);
48  // return;
49  }
50  // Fall through to debug
51  }
52 
53  printk(BIOS_DEBUG, " trapped io address = 0x%x\n", trap_cycle & 0xfffc);
54  for (i=0; i < 4; i++) if (IOTRAP(i)) printk(BIOS_DEBUG, " TRAP = %d\n", i);
55  printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
56  printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
57  printk(BIOS_DEBUG, " read/write: %s\n", (trap_cycle & (1 << 24)) ? "read" : "write");
58 
59  if (!(trap_cycle & (1 << 24))) {
60  /* Write Cycle */
61  data = RCBA32(0x1e18);
62  printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", data);
63  }
64 #undef IOTRAP
65 }
66 
68 {
69 }
#define printk(level,...)
Definition: stdlib.h:16
#define DEFAULT_PMBASE
Definition: iomap.h:14
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
static const int mask[4]
Definition: gpio.c:308
void southbridge_finalize_all(void)
Definition: smihandler.c:215
void southbridge_smi_monitor(void)
Definition: smihandler.c:89
#define RCBA32(x)
Definition: rcba.h:14
u16 pmbase
Definition: smihandler.c:25
#define IOTRAP(x)
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48