coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
smi.c File Reference
#include <device/device.h>
#include <device/pci.h>
#include <console/console.h>
#include <acpi/acpi.h>
#include <arch/io.h>
#include <device/pci_ops.h>
#include <cpu/x86/cache.h>
#include <cpu/x86/smm.h>
#include <cpu/x86/smi_deprecated.h>
#include <string.h>
#include "i82801dx.h"
Include dependency graph for smi.c:

Go to the source code of this file.

Macros

#define D_OPEN   (1 << 6)
 
#define D_CLS   (1 << 5)
 
#define D_LCK   (1 << 4)
 
#define G_SMRAME   (1 << 3)
 
#define C_BASE_SEG   ((0 << 2) | (1 << 1) | (0 << 0))
 

Functions

void northbridge_write_smram (u8 smram)
 
static u16 reset_pm1_status (void)
 read and clear PM1_STS More...
 
static void dump_pm1_status (u16 pm1_sts)
 
static u32 reset_smi_status (void)
 read and clear SMI_STS More...
 
static void dump_smi_status (u32 smi_sts)
 
static u32 reset_gpe0_status (void)
 read and clear GPE0_STS More...
 
static void dump_gpe0_status (u32 gpe0_sts)
 
static u16 reset_alt_gp_smi_status (void)
 read and clear ALT_GP_SMI_STS More...
 
static void dump_alt_gp_smi_status (u16 alt_gp_smi_sts)
 
static u32 reset_tco_status (void)
 read and clear TCOx_STS More...
 
static void dump_tco_status (u32 tco_sts)
 
static void smi_set_eos (void)
 Set the EOS bit. More...
 
static void aseg_smm_relocate (void)
 
static void aseg_smm_install (void)
 
void smm_init (void)
 
void smm_init_completion (void)
 
void aseg_smm_lock (void)
 

Variables

static u16 pmbase = PMBASE_ADDR
 
uint8_t smm_relocation_start
 
uint8_t smm_relocation_end
 
static voiddefault_smm_area = NULL
 

Macro Definition Documentation

◆ C_BASE_SEG

#define C_BASE_SEG   ((0 << 2) | (1 << 1) | (0 << 0))

Definition at line 22 of file smi.c.

◆ D_CLS

#define D_CLS   (1 << 5)

Definition at line 19 of file smi.c.

◆ D_LCK

#define D_LCK   (1 << 4)

Definition at line 20 of file smi.c.

◆ D_OPEN

#define D_OPEN   (1 << 6)

Definition at line 18 of file smi.c.

◆ G_SMRAME

#define G_SMRAME   (1 << 3)

Definition at line 21 of file smi.c.

Function Documentation

◆ aseg_smm_install()

static void aseg_smm_install ( void  )
static

Definition at line 290 of file smi.c.

References _binary_smm_end, _binary_smm_start, memcpy(), and wbinvd().

Referenced by smm_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aseg_smm_lock()

void aseg_smm_lock ( void  )

Definition at line 315 of file smi.c.

◆ aseg_smm_relocate()

static void aseg_smm_relocate ( void  )
static

There are several methods of raising a controlled SMI# via software, among them:

  • Writes to io 0xb2 (APMC)
  • Writes to the Local Apic ICR with Delivery mode SMI.

Using the local APIC is a bit more tricky. According to AMD Family 11 Processor BKDG no destination shorthand must be used. The whole SMM initialization is quite a bit hardware specific, so I'm not too worried about the better of the methods at the moment

Definition at line 215 of file smi.c.

References APM_CNT_NOOP_SMI, apm_control(), APMC_EN, backup_default_smm_area(), BIOS_DEBUG, BIOS_EN, BIOS_INFO, BIOS_SPEW, CONFIG, default_smm_area, dump_alt_gp_smi_status(), dump_gpe0_status(), dump_pm1_status(), dump_smi_status(), dump_tco_status(), EOS, GBL_EN, GBL_SMI_EN, inl(), memcpy(), outl(), outw(), pci_read_config16(), pcidev_on_root(), PERIODIC_EN, PM1_EN, pmbase, printk, PWRBTN_EN, reset_alt_gp_smi_status(), reset_gpe0_status(), reset_pm1_status(), reset_smi_status(), reset_tco_status(), SLP_SMI_EN, SMI_EN, smm_relocation_end, smm_relocation_start, TCO_EN, and wbinvd().

Referenced by smm_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump_alt_gp_smi_status()

static void dump_alt_gp_smi_status ( u16  alt_gp_smi_sts)
static

Definition at line 153 of file smi.c.

References BIOS_DEBUG, and printk.

Referenced by aseg_smm_relocate().

Here is the caller graph for this function:

◆ dump_gpe0_status()

static void dump_gpe0_status ( u32  gpe0_sts)
static

Definition at line 114 of file smi.c.

References BIOS_DEBUG, and printk.

Referenced by aseg_smm_relocate().

Here is the caller graph for this function:

◆ dump_pm1_status()

static void dump_pm1_status ( u16  pm1_sts)
static

Definition at line 44 of file smi.c.

References BIOS_DEBUG, and printk.

Referenced by aseg_smm_relocate().

Here is the caller graph for this function:

◆ dump_smi_status()

static void dump_smi_status ( u32  smi_sts)
static

Definition at line 73 of file smi.c.

References BIOS_DEBUG, and printk.

Referenced by aseg_smm_relocate().

Here is the caller graph for this function:

◆ dump_tco_status()

static void dump_tco_status ( u32  tco_sts)
static

Definition at line 181 of file smi.c.

References BIOS_DEBUG, and printk.

Referenced by aseg_smm_relocate().

Here is the caller graph for this function:

◆ northbridge_write_smram()

void northbridge_write_smram ( u8  smram)

Definition at line 27 of file memmap.c.

References die(), NULL, pci_write_config8(), pcidev_on_root(), QPD0F1_SMRAM, QPI_SAD, and SMRAM.

Referenced by aseg_smm_lock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_alt_gp_smi_status()

static u16 reset_alt_gp_smi_status ( void  )
static

read and clear ALT_GP_SMI_STS

Returns
ALT_GP_SMI_STS register

Definition at line 142 of file smi.c.

References ALT_GP_SMI_STS, inl(), outl(), and pmbase.

Referenced by aseg_smm_relocate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_gpe0_status()

static u32 reset_gpe0_status ( void  )
static

read and clear GPE0_STS

Returns
GPE0_STS register

Definition at line 103 of file smi.c.

References GPE0_STS, inl(), outl(), and pmbase.

Referenced by aseg_smm_relocate(), and smm_southbridge_clear_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_pm1_status()

static u16 reset_pm1_status ( void  )
static

read and clear PM1_STS

Returns
PM1_STS register

Definition at line 33 of file smi.c.

References inw(), outw(), PM1_STS, and pmbase.

Referenced by aseg_smm_relocate(), and smm_southbridge_clear_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_smi_status()

static u32 reset_smi_status ( void  )
static

read and clear SMI_STS

Returns
SMI_STS register

Definition at line 62 of file smi.c.

References inl(), outl(), pmbase, and SMI_STS.

Referenced by aseg_smm_relocate(), and smm_southbridge_clear_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_tco_status()

static u32 reset_tco_status ( void  )
static

read and clear TCOx_STS

Returns
TCOx_STS registers

Definition at line 167 of file smi.c.

References inl(), outl(), and pmbase.

Referenced by aseg_smm_relocate(), and smm_southbridge_clear_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smi_set_eos()

static void smi_set_eos ( void  )
static

Set the EOS bit.

Definition at line 203 of file smi.c.

References EOS, inb(), outb(), pmbase, and SMI_EN.

Referenced by smm_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smm_init()

void smm_init ( void  )

Definition at line 298 of file smi.c.

References aseg_smm_install(), aseg_smm_relocate(), and smi_set_eos().

Here is the call graph for this function:

◆ smm_init_completion()

void smm_init_completion ( void  )

Definition at line 310 of file smi.c.

References default_smm_area, and restore_default_smm_area().

Here is the call graph for this function:

Variable Documentation

◆ default_smm_area

void* default_smm_area = NULL
static

Definition at line 213 of file smi.c.

Referenced by aseg_smm_relocate(), and smm_init_completion().

◆ pmbase

◆ smm_relocation_end

uint8_t smm_relocation_end

Definition at line 212 of file smi.c.

Referenced by aseg_smm_relocate().

◆ smm_relocation_start

uint8_t smm_relocation_start
extern

Referenced by aseg_smm_relocate().