-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src/soc/intel/baytrail/smihandler.c: wip
Signed-off-by: Filip Lewiński <[email protected]>
- Loading branch information
1 parent
dca19de
commit 15a2467
Showing
5 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <stdbool.h> | ||
|
||
|
||
void platform_lockdown_config(void *unused); | ||
void enable_smm_bwp(void); | ||
bool wpd_status(void); | ||
void disable_smm_bwp(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include <stdint.h> | ||
#include <acpi/acpi_gnvs.h> | ||
#include <arch/io.h> | ||
#include <device/pci_ops.h> | ||
#include <console/console.h> | ||
#include <cpu/x86/cache.h> | ||
#include <cpu/x86/smm.h> | ||
#include <cpu/intel/em64t100_save_state.h> | ||
#include <device/pci_def.h> | ||
#include <elog.h> | ||
#include <halt.h> | ||
#include <spi-generic.h> | ||
#include <smmstore.h> | ||
#include <soc/spi.h> | ||
#include <soc/iomap.h> | ||
#include <soc/iosf.h> | ||
#include <soc/pci_devs.h> | ||
#include <soc/pm.h> | ||
#include <soc/nvs.h> | ||
#include <soc/device_nvs.h> | ||
#include <soc/lockdown.h> | ||
#include <bootstate.h> | ||
|
||
// huge overkill with the includes | ||
// let's worry about that later, when it works | ||
|
||
void enable_smm_bwp(void){ | ||
void *scs = (void *)(SPI_BASE_ADDRESS + SCS); | ||
void *bcr = (void *)(SPI_BASE_ADDRESS + BCR); | ||
uint32_t reg; | ||
|
||
// Set to enable SMI generation on WP attempts | ||
reg = read32(scs); | ||
reg |= SMIWPEN; // Set SMIWPEN | ||
write32(scs, reg); | ||
|
||
reg = read32(bcr); | ||
// Set to enforce SMM-based protection | ||
reg |= EISS; | ||
// Set to lock the BIOS write protection settings | ||
reg |= BCR_LE; | ||
// Unset WPDisable | ||
// reg &= ~BCR_WPD; | ||
write32(bcr, reg); | ||
} | ||
|
||
void disable_smm_bwp(void){ | ||
void *scs = (void *)(SPI_BASE_ADDRESS + SCS); | ||
void *bcr = (void *)(SPI_BASE_ADDRESS + BCR); | ||
uint32_t reg; | ||
|
||
write32(scs, read32(scs) & ~SMIWPEN); | ||
reg = (read32(bcr) & ~SRC_MASK) | BCR_WPD; | ||
reg &= ~EISS; | ||
write32(bcr, reg); | ||
} | ||
|
||
bool wpd_status(void) | ||
{ | ||
void *bcr = (void *)(SPI_BASE_ADDRESS + BCR); | ||
uint32_t reg; | ||
reg = read32(bcr); | ||
return (reg & BCR_WPD); | ||
} | ||
|
||
void platform_lockdown_config(void *unused){ | ||
if(CONFIG(BOOTMEDIA_SMM_BWP)){ | ||
enable_smm_bwp(); | ||
} | ||
} | ||
|
||
BOOT_STATE_INIT_ENTRY(BS_DEV_RESOURCES, BS_ON_EXIT, platform_lockdown_config, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters