1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
5 #include <cpu/x86/smm.h>
6 #include <device/pci_def.h>
8 #include <southbridge/intel/common/pmutil.h>
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))
19 /* While we read PMBASE dynamically in case it changed, let's initialize it with a sane value */
20 u16 pmbase
= DEFAULT_PMBASE
;
22 void southbridge_smi_monitor(void)
24 #define IOTRAP(x) (trap_sts & (1 << x))
25 u32 trap_sts
, trap_cycle
;
29 trap_sts
= RCBA32(0x1e00); // TRSR - Trap Status Register
30 RCBA32(0x1e00) = trap_sts
; // Clear trap(s) in TRSR
32 trap_cycle
= RCBA32(0x1e10);
33 for (i
= 16; i
< 20; i
++) {
34 if (trap_cycle
& (1 << i
))
35 mask
|= (0xff << ((i
- 16) << 3));
38 /* IOTRAP(3) SMI function call */
40 if (gnvs
&& gnvs
->smif
)
41 io_trap_handler(gnvs
->smif
); // call function smif
45 /* IOTRAP(2) currently unused
46 * IOTRAP(1) currently unused */
48 /* IOTRAP(0) SMIC: currently unused */
50 printk(BIOS_DEBUG
, " trapped io address = 0x%x\n", trap_cycle
& 0xfffc);
51 for (i
= 0; i
< 4; i
++)
53 printk(BIOS_DEBUG
, " TRAP = %d\n", i
);
54 printk(BIOS_DEBUG
, " AHBE = %x\n", (trap_cycle
>> 16) & 0xf);
55 printk(BIOS_DEBUG
, " MASK = 0x%08x\n", mask
);
56 printk(BIOS_DEBUG
, " read/write: %s\n", (trap_cycle
& (1 << 24)) ? "read" : "write");
58 if (!(trap_cycle
& (1 << 24))) {
60 data
= RCBA32(0x1e18);
61 printk(BIOS_DEBUG
, " iotrap written data = 0x%08x\n", data
);
66 void southbridge_finalize_all(void)