coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
smm.h File Reference
#include <arch/cpu.h>
#include <commonlib/region.h>
#include <types.h>
Include dependency graph for smm.h:

Go to the source code of this file.

Data Structures

struct  smm_runtime
 
struct  smm_module_params
 
struct  smm_stub_params
 
struct  smm_loader_params
 

Macros

#define SMM_DEFAULT_BASE   0x30000
 
#define SMM_DEFAULT_SIZE   0x10000
 
#define SMM_BASE   0xa0000
 
#define SMM_ENTRY_OFFSET   0x8000
 
#define SMM_SAVE_STATE_BEGIN(x)   (SMM_ENTRY_OFFSET + (x))
 
#define APM_CNT   0xb2
 
#define APM_CNT_NOOP_SMI   0x00
 
#define APM_CNT_ACPI_DISABLE   0x1e
 
#define APM_CNT_ACPI_ENABLE   0xe1
 
#define APM_CNT_ROUTE_ALL_XHCI   0xca
 
#define APM_CNT_FINALIZE   0xcb
 
#define APM_CNT_LEGACY   0xcc
 
#define APM_CNT_MBI_UPDATE   0xeb
 
#define APM_CNT_SMMINFO   0xec
 
#define APM_CNT_SMMSTORE   0xed
 
#define APM_CNT_ELOG_GSMI   0xef
 
#define APM_STS   0xb3
 
#define SMM_REVISION_OFFSET_FROM_TOP   (0x8000 - 0x7efc)
 

Typedefs

typedef asmlinkage void(* smm_handler_t) (void *)
 

Enumerations

enum  { SMM_SUBREGION_HANDLER , SMM_SUBREGION_CACHE , SMM_SUBREGION_CHIPSET , SMM_SUBREGION_NUM }
 

Functions

int apm_control (u8 cmd)
 
u8 apm_get_apmc (void)
 
void io_trap_handler (int smif)
 
int southbridge_io_trap_handler (int smif)
 
int mainboard_io_trap_handler (int smif)
 
void southbridge_smi_set_eos (void)
 Set the EOS bit. More...
 
void global_smi_enable (void)
 Set the EOS bit and enable SMI generation from southbridge. More...
 
void global_smi_enable_no_pwrbtn (void)
 
void cpu_smi_handler (void)
 
void northbridge_smi_handler (void)
 
void southbridge_smi_handler (void)
 Interrupt handler for SMI#. More...
 
void mainboard_smi_gpi (u32 gpi_sts)
 
int mainboard_smi_apmc (u8 data)
 
void mainboard_smi_sleep (u8 slp_typ)
 
void mainboard_smi_finalize (void)
 
void smm_soc_early_init (void)
 
void smm_soc_exit (void)
 
asmlinkage void smm_handler_start (void *params)
 
voidsmm_get_save_state (int cpu)
 
bool smm_region_overlaps_handler (const struct region *r)
 
static bool smm_points_to_smram (const void *ptr, const size_t len)
 
int smm_setup_stack (const uintptr_t perm_smbase, const size_t perm_smram_size, const unsigned int total_cpus, const size_t stack_size)
 
int smm_setup_relocation_handler (struct smm_loader_params *params)
 
int smm_load_module (uintptr_t smram_base, size_t smram_size, struct smm_loader_params *params)
 
u32 smm_get_cpu_smbase (unsigned int cpu_num)
 
voidbackup_default_smm_area (void)
 
void restore_default_smm_area (void *smm_save_area)
 
void smm_region (uintptr_t *start, size_t *size)
 
int smm_subregion (int sub, uintptr_t *start, size_t *size)
 
void smm_list_regions (void)
 
uint32_t smm_revision (void)
 
uint16_t pm_acpi_smi_cmd_port (void)
 

Variables

unsigned char _binary_smm_start []
 
unsigned char _binary_smm_end []
 
struct smm_runtime __packed
 

Macro Definition Documentation

◆ APM_CNT

#define APM_CNT   0xb2

Definition at line 19 of file smm.h.

◆ APM_CNT_ACPI_DISABLE

#define APM_CNT_ACPI_DISABLE   0x1e

Definition at line 21 of file smm.h.

◆ APM_CNT_ACPI_ENABLE

#define APM_CNT_ACPI_ENABLE   0xe1

Definition at line 22 of file smm.h.

◆ APM_CNT_ELOG_GSMI

#define APM_CNT_ELOG_GSMI   0xef

Definition at line 29 of file smm.h.

◆ APM_CNT_FINALIZE

#define APM_CNT_FINALIZE   0xcb

Definition at line 24 of file smm.h.

◆ APM_CNT_LEGACY

#define APM_CNT_LEGACY   0xcc

Definition at line 25 of file smm.h.

◆ APM_CNT_MBI_UPDATE

#define APM_CNT_MBI_UPDATE   0xeb

Definition at line 26 of file smm.h.

◆ APM_CNT_NOOP_SMI

#define APM_CNT_NOOP_SMI   0x00

Definition at line 20 of file smm.h.

◆ APM_CNT_ROUTE_ALL_XHCI

#define APM_CNT_ROUTE_ALL_XHCI   0xca

Definition at line 23 of file smm.h.

◆ APM_CNT_SMMINFO

#define APM_CNT_SMMINFO   0xec

Definition at line 27 of file smm.h.

◆ APM_CNT_SMMSTORE

#define APM_CNT_SMMSTORE   0xed

Definition at line 28 of file smm.h.

◆ APM_STS

#define APM_STS   0xb3

Definition at line 30 of file smm.h.

◆ SMM_BASE

#define SMM_BASE   0xa0000

Definition at line 14 of file smm.h.

◆ SMM_DEFAULT_BASE

#define SMM_DEFAULT_BASE   0x30000

Definition at line 10 of file smm.h.

◆ SMM_DEFAULT_SIZE

#define SMM_DEFAULT_SIZE   0x10000

Definition at line 11 of file smm.h.

◆ SMM_ENTRY_OFFSET

#define SMM_ENTRY_OFFSET   0x8000

Definition at line 16 of file smm.h.

◆ SMM_REVISION_OFFSET_FROM_TOP

#define SMM_REVISION_OFFSET_FROM_TOP   (0x8000 - 0x7efc)

Definition at line 187 of file smm.h.

◆ SMM_SAVE_STATE_BEGIN

#define SMM_SAVE_STATE_BEGIN (   x)    (SMM_ENTRY_OFFSET + (x))

Definition at line 17 of file smm.h.

Typedef Documentation

◆ smm_handler_t

typedef asmlinkage void(* smm_handler_t) (void *)

Definition at line 100 of file smm.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SMM_SUBREGION_HANDLER 
SMM_SUBREGION_CACHE 
SMM_SUBREGION_CHIPSET 
SMM_SUBREGION_NUM 

Definition at line 169 of file smm.h.

Function Documentation

◆ apm_control()

int apm_control ( u8  cmd)

Definition at line 31 of file smi_trigger.c.

References APM_CNT, apmc_log(), BIOS_DEBUG, CONFIG, ENV_SMM, outb(), and printk.

Referenced by aseg_smm_relocate(), finalize_chipset(), i82801gx_set_acpi_mode(), i82801ix_set_acpi_mode(), i82801jx_set_acpi_mode(), lpc_final(), mainboard_suspend_resume(), pch_set_acpi_mode(), soc_finalize(), and usb_xhci_init().

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

◆ apm_get_apmc()

u8 apm_get_apmc ( void  )

Definition at line 46 of file smi_trigger.c.

References APM_CNT, apmc_log(), and inb().

Referenced by smihandler_southbridge_apmc(), and southbridge_smi_apmc().

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

◆ backup_default_smm_area()

void* backup_default_smm_area ( void  )

Definition at line 9 of file backup_default_smm.c.

References acpi_is_wakeup_s3(), BIOS_DEBUG, cbmem_add(), CBMEM_ID_SMM_SAVE_SPACE, CONFIG, memcpy(), NULL, printk, SMM_DEFAULT_BASE, and SMM_DEFAULT_SIZE.

Referenced by aseg_smm_relocate().

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

◆ cpu_smi_handler()

void cpu_smi_handler ( void  )

Definition at line 206 of file smm_module_handler.c.

Referenced by smm_handler_start().

Here is the caller graph for this function:

◆ global_smi_enable()

void global_smi_enable ( void  )

Set the EOS bit and enable SMI generation from southbridge.

Definition at line 60 of file smi_util.c.

References dump_all_status(), GBL_EN, PWRBTN_EN, smi_enabled(), smi_read32(), SMI_REG_SMITRIG0, smi_write32(), SMITRG0_EOS, SMITRG0_SMIENB, and smm_southbridge_enable().

Referenced by mainboard_enable().

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

◆ global_smi_enable_no_pwrbtn()

void global_smi_enable_no_pwrbtn ( void  )

Definition at line 69 of file smm.c.

References GBL_EN, and smm_southbridge_enable().

Referenced by post_mp_init().

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

◆ io_trap_handler()

void io_trap_handler ( int  smif)

Definition at line 58 of file smihandler.c.

References BIOS_DEBUG, mainboard_io_trap_handler(), printk, and southbridge_io_trap_handler().

Referenced by smihandler_southbridge_monitor(), and southbridge_smi_monitor().

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

◆ mainboard_io_trap_handler()

◆ mainboard_smi_apmc()

int mainboard_smi_apmc ( u8  data)

Definition at line 209 of file smihandler.c.

References ACPI_SMI_CMD_DISABLE, ACPI_SMI_CMD_ENABLE, APM_CNT_ACPI_DISABLE, APM_CNT_ACPI_ENABLE, APM_CNT_BOARD_SMI, APM_CNT_FINALIZE, BIOS_DEBUG, chromeec_smi_apmc(), CONFIG, EC_ACPI_DISABLE, EC_ACPI_ENABLE, ec_clear_out_queue(), EC_CMD_DISABLE_ACPI_MODE, EC_CMD_ENABLE_ACPI_MODE, EC_CMD_NOTIFY_ACPI_ENTER, EC_CMD_NOTIFY_ACPI_EXIT, ec_enter_acpi_mode(), ec_enter_apm_mode(), EC_HOST_EVENT_NONE, ec_kbc_write_cmd(), ec_kbc_write_ib(), EC_LID_GEVENT, EC_LID_GPI, EC_MAILBOX_PORT, ec_set_ports(), EC_SMI_DISABLE, EC_SMI_ENABLE, ec_smi_handler(), ec_write(), ec_write_cmd(), gnvs, google_chromeec_get_event(), google_chromeec_set_sci_mask(), google_chromeec_set_smi_mask(), GPE_EC_SCI, GPE_PALMDET1, GPE_PALMDET2, GPI_IS_SCI, GPI_IS_SMI, gpi_route_interrupt(), GPIO_133, gpio_set(), hudson_configure_gevent_smi(), hudson_disable_gevent_smi(), inb(), info, LINK_EC_SCI_EVENTS, LINK_EC_SMI_EVENTS, MAINBOARD_EC_SCI_EVENTS, MAINBOARD_EC_SMI_EVENTS, outb(), PCI_DEV, pci_read_config8(), pci_write_config8(), printk, SCH5545_GLOBAL_PME_EN, SCH5545_GLOBAL_PME_STS, SCH5545_KBD_PME_EN, SCH5545_MOUSE_PME_EN, SCH5545_RR_PME_EN, SCH5545_RR_PME_EN1, SCH5545_RR_PME_STS, SCH5545_RUNTIME_REG_BASE, send_ec_command(), send_ec_data(), SMI_LVL_LOW, SMI_MODE_SMI, global_nvs::smif, stout_ec_finalize_smm(), val, variant_get_event_info(), and wilco_ec_smi_apmc().

Referenced by fch_apmc_smi_handler(), hudson_apmc_smi_handler(), smihandler_southbridge_apmc(), and southbridge_smi_apmc().

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

◆ mainboard_smi_finalize()

void mainboard_smi_finalize ( void  )

Definition at line 211 of file smihandler.c.

References CONFIG, and mainboard_config_cbi_wp().

Referenced by finalize().

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

◆ mainboard_smi_gpi()

◆ mainboard_smi_sleep()

void mainboard_smi_sleep ( u8  slp_typ)

Definition at line 210 of file smihandler.c.

References ACPI_S3, ACPI_S4, ACPI_S5, addr, BIOS_DEBUG, BIOS_INFO, chromeec_smi_device_event_sleep(), chromeec_smi_sleep(), COMMUNITY_OFFSET_GPNORTH, CONFIG, EC_DEVICE_CONTROL_1, EC_DEVICE_CONTROL_1_BOOMER_ON, EC_DEVICE_CONTROL_2, EC_DEVICE_CONTROL_2_MPI_ON, EC_DEVICE_CONTROL_2_USB_ON, EC_EC_PSW, EC_HOST_EVENT_NONE, ec_it8518_enable_wake_events(), ec_kbc_write_cmd(), ec_kbc_write_ib(), EC_KBD_CMD_MUTE, ec_mem_read(), ec_mem_write(), EC_PERIPH_CNTL_3, EC_PSW_IKB, EC_PSW_USB, ec_read(), ec_running(), EC_USB_S3_EN, ec_write(), enable_gpe(), gnvs, google_chromeec_get_event(), google_chromeec_set_sci_mask(), google_chromeec_set_smi_mask(), google_chromeec_set_usb_charge_mode(), google_chromeec_set_wake_mask(), GPE_EC_WAKE, GPI_IS_SCI, gpi_route_interrupt(), gpio_configure_pads(), GPIO_LTE_DISABLE_L, GPIO_PP3300_CODEC_EN, GPIO_SUS1_WAKE_MASK, GPIO_SUS7_WAKE_MASK, GPIO_USB_CTL_1, GPIO_WAKE_MASK_REG0, GPIO_WLAN_DISABLE_L, inb(), info, IO_BASE_ADDRESS, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ, it8772f_gpio_led(), LED_BLINK, LED_OFF, LINK_EC_S3_WAKE_EVENTS, lpc_set_low_power(), mainboard_disable_gpios(), MAINBOARD_EC_S3_DEVICE_EVENTS, MAINBOARD_EC_S3_WAKE_EVENTS, MAINBOARD_EC_S5_WAKE_EVENTS, mainboard_gpio_smi_sleep(), mask, outb(), PCH_XHCI_DEV, pci_read_config32(), pci_write_config32(), printk, read32(), S3, global_nvs::s3u0, global_nvs::s3u1, global_nvs::s5u0, global_nvs::s5u1, set_gpio(), set_power_led(), SIO_GPIO_BASE_SET4, SIO_GPIO_BLINK_GPIO45, SUPERIO_DEV, SUPERIO_LOCK, SUPERIO_UNLOCK, SUPERIO_WRITE, USB_CHARGE_MODE_DISABLED, variant_get_event_info(), variant_sleep_gpio_table(), variant_smi_sleep(), WAKE_GPIO_EN, wilco_ec_smi_sleep(), write32(), and global_nvs::xhci.

Referenced by fch_slp_typ_handler(), smihandler_southbridge_sleep(), and southbridge_smi_sleep().

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

◆ northbridge_smi_handler()

void northbridge_smi_handler ( void  )

Definition at line 207 of file smm_module_handler.c.

Referenced by smm_handler_start().

Here is the caller graph for this function:

◆ pm_acpi_smi_cmd_port()

uint16_t pm_acpi_smi_cmd_port ( void  )

Definition at line 6 of file smi.c.

References APM_CNT, PM_ACPI_SMI_CMD, and pm_read16().

Referenced by fch_apmc_smi_handler(), and find_save_state().

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

◆ restore_default_smm_area()

void restore_default_smm_area ( void smm_save_area)

Definition at line 42 of file backup_default_smm.c.

References memcpy(), NULL, SMM_DEFAULT_BASE, and SMM_DEFAULT_SIZE.

Referenced by smm_init_completion().

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

◆ smm_get_cpu_smbase()

u32 smm_get_cpu_smbase ( unsigned int  cpu_num)

Definition at line 159 of file smm_module_loader.c.

References cpus, and cpu_smm_info::smbase.

Referenced by smm_do_relocation().

Here is the caller graph for this function:

◆ smm_get_save_state()

void* smm_get_save_state ( int  cpu)

◆ smm_handler_start()

◆ smm_list_regions()

void smm_list_regions ( void  )

Definition at line 70 of file tseg_region.c.

References base, BIOS_DEBUG, printk, PRIxPTR, smm_region(), smm_subregion(), and SMM_SUBREGION_NUM.

Referenced by car_stage_entry(), and romstage_main().

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

◆ smm_load_module()

◆ smm_points_to_smram()

static bool smm_points_to_smram ( const void ptr,
const size_t  len 
)
inlinestatic

Definition at line 118 of file smm.h.

References smm_region_overlaps_handler().

Referenced by backlight_off(), mainboard_smi_brightness_down(), mainboard_smi_brightness_up(), range_check(), and xhci_a0_suspend_smm_workaround().

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

◆ smm_region()

◆ smm_region_overlaps_handler()

bool smm_region_overlaps_handler ( const struct region r)

Definition at line 132 of file smihandler.c.

References region_overlap(), smm_runtime::smbase, SMM_BASE, SMM_DEFAULT_SIZE, and smm_runtime::smm_size.

Referenced by smm_points_to_smram().

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

◆ smm_revision()

uint32_t smm_revision ( void  )

Definition at line 109 of file smihandler.c.

References save_state, smm_runtime::save_state_size, SMM_BASE, SMM_ENTRY_OFFSET, smm_get_save_state(), and SMM_REVISION_OFFSET_FROM_TOP.

Referenced by init_save_state(), smi_handler(), and smm_get_save_state().

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

◆ smm_setup_relocation_handler()

int smm_setup_relocation_handler ( struct smm_loader_params params)

Definition at line 406 of file smm_module_loader.c.

References BIOS_SPEW, fxsave_area_relocation, NULL, params, printk, SMM_DEFAULT_BASE, SMM_DEFAULT_SIZE, and smm_module_setup_stub().

Here is the call graph for this function:

◆ smm_setup_stack()

int smm_setup_stack ( const uintptr_t  perm_smbase,
const size_t  perm_smram_size,
const unsigned int  total_cpus,
const size_t  stack_size 
)

Definition at line 235 of file smm_module_loader.c.

References BIOS_ERR, g_stack_size, printk, SMM_MINIMUM_STACK_SIZE, and stack_top.

Referenced by load_smm_handlers().

Here is the caller graph for this function:

◆ smm_soc_early_init()

void smm_soc_early_init ( void  )

Definition at line 214 of file smm_module_handler.c.

References __CBMEM_CONSOLE_ENABLE__, CONFIG, and replay_transfer_buffer_cbmemc().

Referenced by smm_handler_start().

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

◆ smm_soc_exit()

void smm_soc_exit ( void  )

Definition at line 215 of file smm_module_handler.c.

Referenced by smm_handler_start().

Here is the caller graph for this function:

◆ smm_subregion()

int smm_subregion ( int  sub,
uintptr_t start,
size_t size 
)

Definition at line 22 of file tseg_region.c.

References ASSERT, IS_ALIGNED, smm_region(), SMM_SUBREGION_CACHE, SMM_SUBREGION_CHIPSET, and SMM_SUBREGION_HANDLER.

Referenced by fill_in_relocation_params(), get_smm_info(), smm_info(), smm_list_regions(), and stage_cache_external_region().

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

◆ southbridge_io_trap_handler()

int southbridge_io_trap_handler ( int  smif)

Definition at line 131 of file smihandler.c.

References BIOS_DEBUG, gnvs, printk, and global_nvs::smif.

Referenced by io_trap_handler().

Here is the caller graph for this function:

◆ southbridge_smi_handler()

◆ southbridge_smi_set_eos()

void southbridge_smi_set_eos ( void  )

Set the EOS bit.

Definition at line 68 of file smi_util.c.

References enable_smi(), EOS, inb(), outb(), pmbase, pmc_enable_smi(), read_pmbase8(), SMI_EN, smi_read32(), SMI_REG_SMITRIG0, smi_write32(), SMITRG0_EOS, and write_pmbase8().

Referenced by smi_set_eos().

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

Variable Documentation

◆ __packed

◆ _binary_smm_end

unsigned char _binary_smm_end[]
extern

Referenced by aseg_smm_install(), and smm_init().

◆ _binary_smm_start

unsigned char _binary_smm_start[]
extern