TianoCore EDK2 master
Loading...
Searching...
No Matches
SmmAccessPei.c File Reference
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
#include <Library/PciLib.h>
#include <Library/PeiServicesLib.h>
#include <Ppi/SmmAccess.h>
#include <OvmfPlatforms.h>
#include "SmramInternal.h"

Go to the source code of this file.

Functions

STATIC EFI_STATUS EFIAPI SmmAccessPeiOpen (IN EFI_PEI_SERVICES **PeiServices, IN PEI_SMM_ACCESS_PPI *This, IN UINTN DescriptorIndex)
 
STATIC EFI_STATUS EFIAPI SmmAccessPeiClose (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)
 
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 UINT8 CmosRead8 (IN UINT8 Index)
 
STATIC UINT32 GetSystemMemorySizeBelow4gb (VOID)
 
EFI_STATUS EFIAPI SmmAccessPeiEntryPoint (IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
 

Variables

STATIC PEI_SMM_ACCESS_PPI mAccess
 
STATIC EFI_PEI_PPI_DESCRIPTOR mPpiList []
 

Detailed Description

A PEIM with the following responsibilities:

  • verify & configure the Q35 TSEG in the entry point,
  • provide SMRAM access by producing PEI_SMM_ACCESS_PPI

This PEIM runs from RAM, so we can write to variables with static storage duration.

Copyright (C) 2013, 2015, Red Hat, Inc.
Copyright (c) 2010 - 2024, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SmmAccessPei.c.

Function Documentation

◆ CmosRead8()

STATIC UINT8 CmosRead8 ( IN UINT8  Index)

Definition at line 234 of file SmmAccessPei.c.

◆ GetSystemMemorySizeBelow4gb()

STATIC UINT32 GetSystemMemorySizeBelow4gb ( VOID  )

Definition at line 244 of file SmmAccessPei.c.

◆ SmmAccessPeiClose()

STATIC EFI_STATUS EFIAPI SmmAccessPeiClose ( IN EFI_PEI_SERVICES **  PeiServices,
IN PEI_SMM_ACCESS_PPI This,
IN UINTN  DescriptorIndex 
)

Inhibits access to the SMRAM.

This function "closes" SMRAM so that it is not visible while outside of SMM. The function should return EFI_UNSUPPORTED if the hardware does not support hiding of SMRAM.

Parameters
PeiServicesGeneral purpose services available to every PEIM.
ThisThe pointer to the SMM Access Interface.
DescriptorIndexThe region of SMRAM to Close.
Return values
EFI_SUCCESSThe region was successfully closed.
EFI_DEVICE_ERRORThe region could not be closed because locked by chipset.
EFI_INVALID_PARAMETERThe descriptor index was out of bounds.

Definition at line 105 of file SmmAccessPei.c.

◆ SmmAccessPeiEntryPoint()

EFI_STATUS EFIAPI SmmAccessPeiEntryPoint ( IN EFI_PEI_FILE_HANDLE  FileHandle,
IN CONST EFI_PEI_SERVICES **  PeiServices 
)

Definition at line 262 of file SmmAccessPei.c.

◆ SmmAccessPeiGetCapabilities()

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 
)

Queries the memory controller for the possible regions that will support SMRAM.

Parameters
PeiServicesGeneral purpose services available to every PEIM.
ThisThe pointer to the SmmAccessPpi Interface.
SmramMapSizeThe pointer to the variable containing size of the buffer to contain the description information.
SmramMapThe buffer containing the data describing the Smram region descriptors.
Return values
EFI_BUFFER_TOO_SMALLThe user did not provide a sufficient buffer.
EFI_SUCCESSThe user provided a sufficiently-sized buffer.

Definition at line 199 of file SmmAccessPei.c.

◆ SmmAccessPeiLock()

STATIC EFI_STATUS EFIAPI SmmAccessPeiLock ( IN EFI_PEI_SERVICES **  PeiServices,
IN PEI_SMM_ACCESS_PPI This,
IN UINTN  DescriptorIndex 
)

Inhibits access to the SMRAM.

This function prohibits access to the SMRAM region. This function is usually implemented such that it is a write-once operation.

Parameters
PeiServicesGeneral purpose services available to every PEIM.
ThisThe pointer to the SMM Access Interface.
DescriptorIndexThe region of SMRAM to Close.
Return values
EFI_SUCCESSThe region was successfully locked.
EFI_DEVICE_ERRORThe region could not be locked because at least one range is still open.
EFI_INVALID_PARAMETERThe descriptor index was out of bounds.

Definition at line 152 of file SmmAccessPei.c.

◆ SmmAccessPeiOpen()

STATIC EFI_STATUS EFIAPI SmmAccessPeiOpen ( IN EFI_PEI_SERVICES **  PeiServices,
IN PEI_SMM_ACCESS_PPI This,
IN UINTN  DescriptorIndex 
)

Opens the SMRAM area to be accessible by a PEIM driver.

This function "opens" SMRAM so that it is visible while not inside of SMM. The function should return EFI_UNSUPPORTED if the hardware does not support hiding of SMRAM. The function should return EFI_DEVICE_ERROR if the SMRAM configuration is locked.

Parameters
PeiServicesGeneral purpose services available to every PEIM.
ThisThe pointer to the SMM Access Interface.
DescriptorIndexThe region of SMRAM to Open.
Return values
EFI_SUCCESSThe region was successfully opened.
EFI_DEVICE_ERRORThe region could not be opened because locked by chipset.
EFI_INVALID_PARAMETERThe descriptor index was out of bounds.

Definition at line 57 of file SmmAccessPei.c.

Variable Documentation

◆ mAccess

Initial value:
= {
}
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)
Definition: SmmAccessPei.c:199
STATIC EFI_STATUS EFIAPI SmmAccessPeiClose(IN EFI_PEI_SERVICES **PeiServices, IN PEI_SMM_ACCESS_PPI *This, IN UINTN DescriptorIndex)
Definition: SmmAccessPei.c:105
STATIC EFI_STATUS EFIAPI SmmAccessPeiOpen(IN EFI_PEI_SERVICES **PeiServices, IN PEI_SMM_ACCESS_PPI *This, IN UINTN DescriptorIndex)
Definition: SmmAccessPei.c:57
STATIC EFI_STATUS EFIAPI SmmAccessPeiLock(IN EFI_PEI_SERVICES **PeiServices, IN PEI_SMM_ACCESS_PPI *This, IN UINTN DescriptorIndex)
Definition: SmmAccessPei.c:152

Definition at line 215 of file SmmAccessPei.c.

◆ mPpiList

Initial value:
= {
{
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gPeiSmmAccessPpiGuid, &mAccess
}
}

Definition at line 222 of file SmmAccessPei.c.