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>
7 #include <soc/nvs.h>
9 #include "i82801gx.h"
10 
11 /* I945 */
12 #define SMRAM 0x9d
13 #define D_OPEN (1 << 6)
14 #define D_CLS (1 << 5)
15 #define D_LCK (1 << 4)
16 #define G_SMRANE (1 << 3)
17 #define C_BASE_SEG ((0 << 2) | (1 << 1) | (0 << 0))
18 
19 /* While we read PMBASE dynamically in case it changed, let's initialize it with a sane value */
21 
23 {
24  switch (smif) {
25  case 0x32:
26  printk(BIOS_DEBUG, "OS Init\n");
27  /* gnvs->smif:
28  * On success, the IO Trap Handler returns 0
29  * On failure, the IO Trap Handler returns a value != 0
30  */
31  gnvs->smif = 0;
32  return 1; /* IO trap handled */
33  }
34 
35  /* Not handled */
36  return 0;
37 }
38 
40 {
41 #define IOTRAP(x) (trap_sts & (1 << x))
42  u32 trap_sts, trap_cycle;
43  u32 data, mask = 0;
44  int i;
45 
46  trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
47  RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
48 
49  trap_cycle = RCBA32(0x1e10);
50  for (i = 16; i < 20; i++) {
51  if (trap_cycle & (1 << i))
52  mask |= (0xff << ((i - 16) << 2));
53  }
54 
55  /* IOTRAP(3) SMI function call */
56  if (IOTRAP(3)) {
57  if (gnvs && gnvs->smif)
58  io_trap_handler(gnvs->smif); // call function smif
59  return;
60  }
61 
62  /* IOTRAP(2) currently unused
63  * IOTRAP(1) currently unused */
64 
65  /* IOTRAP(0) SMIC: currently unused */
66 
67  printk(BIOS_DEBUG, " trapped io address = 0x%x\n", trap_cycle & 0xfffc);
68  for (i = 0; i < 4; i++)
69  if (IOTRAP(i))
70  printk(BIOS_DEBUG, " TRAP = %d\n", i);
71  printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
72  printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
73  printk(BIOS_DEBUG, " read/write: %s\n", (trap_cycle & (1 << 24)) ? "read" : "write");
74 
75  if (!(trap_cycle & (1 << 24))) {
76  /* Write Cycle */
77  data = RCBA32(0x1e18);
78  printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", data);
79  }
80 #undef IOTRAP
81 }
82 
84 {
85 }
#define printk(level,...)
Definition: stdlib.h:16
void io_trap_handler(int smif)
Definition: smihandler.c:58
#define DEFAULT_PMBASE
Definition: iomap.h:14
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
struct global_nvs * gnvs
int southbridge_io_trap_handler(int smif)
Definition: smihandler.c:131
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
u8 smif
Definition: nvs.h:11