3 Copyright (c) 2017-2021, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
12 @param[in] PchSpiBase PCH SPI PCI Base Address
14 @retval Return SPI BAR Address
22 return MmioRead32 (PchSpiBase
+ R_SPI_BASE
) & ~(B_SPI_BAR0_MASK
);
26 Release SPI MMIO BAR. Do nothing.
28 @param[in] PchSpiBase PCH SPI PCI Base Address
39 This function is to enable/disable BIOS Write Protect in SMM phase.
41 @param[in] EnableSmmSts Flag to Enable/disable Bios write protect
45 CpuSmmDisableBiosWriteProtect (
46 IN BOOLEAN EnableSmmSts
53 // Disable BIOS Write Protect in SMM phase.
55 Data32
= MmioRead32 ((UINTN
)(0xFED30880)) | (UINT32
)(BIT0
);
56 AsmWriteMsr32 (0x000001FE, Data32
);
59 // Enable BIOS Write Protect in SMM phase
61 Data32
= MmioRead32 ((UINTN
)(0xFED30880)) & (UINT32
)(~BIT0
);
62 AsmWriteMsr32 (0x000001FE, Data32
);
66 // Read FED30880h back to ensure the setting went through.
68 Data32
= MmioRead32 (0xFED30880);
72 This function is a hook for Spi to disable BIOS Write Protect.
74 @param[in] PchSpiBase PCH SPI PCI Base Address
75 @param[in] CpuSmmBwp Need to disable CPU SMM Bios write protection or not
77 @retval EFI_SUCCESS The protocol instance was properly initialized
78 @retval EFI_ACCESS_DENIED The BIOS Region can only be updated in SMM phase
83 DisableBiosWriteProtect (
89 // Write clear BC_SYNC_SS prior to change WPD from 0 to 1.
91 MmioOr8 (PchSpiBase
+ R_SPI_BCR
+ 1, (B_SPI_BCR_SYNC_SS
>> 8));
94 // Enable the access to the BIOS space for both read and write cycles
96 MmioOr8 (PchSpiBase
+ R_SPI_BCR
, B_SPI_BCR_BIOSWE
);
99 CpuSmmDisableBiosWriteProtect (TRUE
);
106 This function is a hook for Spi to enable BIOS Write Protect.
108 @param[in] PchSpiBase PCH SPI PCI Base Address
109 @param[in] CpuSmmBwp Need to disable CPU SMM Bios write protection or not
114 EnableBiosWriteProtect (
120 // Disable the access to the BIOS space for write cycles
122 MmioAnd8 (PchSpiBase
+ R_SPI_BCR
, (UINT8
)(~B_SPI_BCR_BIOSWE
));
124 if (CpuSmmBwp
!= 0) {
125 CpuSmmDisableBiosWriteProtect (FALSE
);
130 This function disables SPI Prefetching and caching,
131 and returns previous BIOS Control Register value before disabling.
133 @param[in] PchSpiBase PCH SPI PCI Base Address
135 @retval Previous BIOS Control Register value
139 SaveAndDisableSpiPrefetchCache (
145 BiosCtlSave
= MmioRead8 (PchSpiBase
+ R_SPI_BCR
) & B_SPI_BCR_SRC
;
148 PchSpiBase
+ R_SPI_BCR
, \
149 (UINT32
)(~B_SPI_BCR_SRC
), \
150 (UINT32
)(V_SPI_BCR_SRC_PREF_DIS_CACHE_DIS
<< B_SPI_BCR_SRC
)
157 This function updates BIOS Control Register with the given value.
159 @param[in] PchSpiBase PCH SPI PCI Base Address
160 @param[in] BiosCtlValue BIOS Control Register Value to be updated
164 SetSpiBiosControlRegister (
166 IN UINT8 BiosCtlValue
169 MmioAndThenOr8 (PchSpiBase
+ R_SPI_BCR
, (UINT8
) ~B_SPI_BCR_SRC
, BiosCtlValue
);