70 DescriptorBlock = GET_GUID_HOB_DATA (GuidHob);
71 ASSERT (DescriptorBlock);
74 return EFI_INVALID_PARAMETER;
81 return SmramAccessOpen (&This->LockState, &This->OpenState);
118 DescriptorBlock = GET_GUID_HOB_DATA (GuidHob);
119 ASSERT (DescriptorBlock);
122 return EFI_INVALID_PARAMETER;
129 return SmramAccessClose (&This->LockState, &This->OpenState);
165 DescriptorBlock = GET_GUID_HOB_DATA (GuidHob);
166 ASSERT (DescriptorBlock);
169 return EFI_INVALID_PARAMETER;
176 return SmramAccessLock (&This->LockState, &This->OpenState);
206 return SmramAccessGetCapabilities (
224 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
225 &gPeiSmmAccessPpiGuid, &mAccess
244GetSystemMemorySizeBelow4gb (
254 return ((Cmos0x35 << 8 | Cmos0x34) << 16) + SIZE_16MB;
262SmmAccessPeiEntryPoint (
267 UINT16 HostBridgeDevId;
270 UINT32 TopOfLowRam, TopOfLowRamMb;
280 HostBridgeDevId =
PciRead16 (OVMF_HOSTBRIDGE_DID);
281 if (HostBridgeDevId != INTEL_Q35_MCH_DEVICE_ID) {
284 "%a: no SMRAM with host bridge DID=0x%04x; only "
285 "DID=0x%04x (Q35) is supported\n",
288 INTEL_Q35_MCH_DEVICE_ID
300 EsmramcVal =
PciRead8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC));
301 RegMask8 = MCH_ESMRAMC_SM_CACHE | MCH_ESMRAMC_SM_L1 | MCH_ESMRAMC_SM_L2;
302 if ((EsmramcVal & RegMask8) != RegMask8) {
305 "%a: this Q35 implementation lacks SMRAM\n",
311 TopOfLowRam = GetSystemMemorySizeBelow4gb ();
312 ASSERT ((TopOfLowRam & (SIZE_1MB - 1)) == 0);
313 TopOfLowRamMb = TopOfLowRam >> 20;
324 PciWrite16 (DRAMC_REGISTER_Q35 (MCH_GGC), MCH_GGC_IVD);
330 DRAMC_REGISTER_Q35 (MCH_TOLUD),
331 (UINT16)(TopOfLowRamMb << MCH_TOLUD_MB_SHIFT)
339 DRAMC_REGISTER_Q35 (MCH_GBSM),
340 TopOfLowRamMb << MCH_GBSM_MB_SHIFT
343 DRAMC_REGISTER_Q35 (MCH_BGSM),
344 TopOfLowRamMb << MCH_BGSM_MB_SHIFT
352 DRAMC_REGISTER_Q35 (MCH_TSEGMB),
353 (TopOfLowRamMb - mQ35TsegMbytes) << MCH_TSEGMB_MB_SHIFT
361 EsmramcVal &= ~(UINT32)MCH_ESMRAMC_TSEG_MASK;
362 EsmramcVal |= mQ35TsegMbytes == 8 ? MCH_ESMRAMC_TSEG_8MB :
363 mQ35TsegMbytes == 2 ? MCH_ESMRAMC_TSEG_2MB :
364 mQ35TsegMbytes == 1 ? MCH_ESMRAMC_TSEG_1MB :
365 MCH_ESMRAMC_TSEG_EXT;
366 EsmramcVal |= MCH_ESMRAMC_T_EN;
367 PciWrite8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC), EsmramcVal);
374 DRAMC_REGISTER_Q35 (MCH_SMRAM),
375 (UINT8)((~(UINT32)MCH_SMRAM_D_LCK) & 0xff),
379 GetStates (&mAccess.LockState, &mAccess.OpenState);
400 return EFI_UNSUPPORTED;
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID EFIAPI CpuDeadLoop(VOID)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
UINT8 EFIAPI IoWrite8(IN UINTN Port, IN UINT8 Value)
UINT8 EFIAPI IoRead8(IN UINTN Port)
#define DEBUG(Expression)
UINT8 EFIAPI PciRead8(IN UINTN Address)
UINT32 EFIAPI PciWrite32(IN UINTN Address, IN UINT32 Value)
UINT8 EFIAPI PciAndThenOr8(IN UINTN Address, IN UINT8 AndData, IN UINT8 OrData)
UINT8 EFIAPI PciWrite8(IN UINTN Address, IN UINT8 Value)
UINT16 EFIAPI PciWrite16(IN UINTN Address, IN UINT16 Value)
UINT16 EFIAPI PciRead16(IN UINTN Address)
#define FeaturePcdGet(TokenName)
VOID * EFI_PEI_FILE_HANDLE
STATIC EFI_STATUS EFIAPI SmmAccessPeiGetCapabilities(IN EFI_PEI_SERVICES **PeiServices, IN PEI_SMM_ACCESS_PPI *This, IN OUT UINTN *SmramMapSize, IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap)
STATIC EFI_STATUS EFIAPI SmmAccessPeiClose(IN EFI_PEI_SERVICES **PeiServices, IN PEI_SMM_ACCESS_PPI *This, IN UINTN DescriptorIndex)
STATIC EFI_STATUS EFIAPI SmmAccessPeiOpen(IN EFI_PEI_SERVICES **PeiServices, IN PEI_SMM_ACCESS_PPI *This, IN UINTN DescriptorIndex)
STATIC EFI_STATUS EFIAPI SmmAccessPeiLock(IN EFI_PEI_SERVICES **PeiServices, IN PEI_SMM_ACCESS_PPI *This, IN UINTN DescriptorIndex)
VOID InitQ35SmramAtDefaultSmbase(VOID)
VOID GetStates(OUT BOOLEAN *LockState, OUT BOOLEAN *OpenState)
VOID InitQ35TsegMbytes(VOID)
UINT32 NumberOfSmmReservedRegions