MdePkg/Library/SmmMemLib/SmmMemLib.c File Reference


Functions

VOID SmmMemLibInternalCalculateMaximumSupportAddress (VOID)
BOOLEAN EFIAPI SmmIsBufferOutsideSmmValid (IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length)
EFI_STATUS EFIAPI SmmCopyMemToSmram (OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS EFIAPI SmmCopyMemFromSmram (OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS EFIAPI SmmCopyMem (OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS EFIAPI SmmSetMem (OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
EFI_STATUS EFIAPI SmmMemLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI SmmMemLibDestructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)

Variables

EFI_SMRAM_DESCRIPTORmSmmMemLibInternalSmramRanges
UINTN mSmmMemLibInternalSmramCount
EFI_PHYSICAL_ADDRESS mSmmMemLibInternalMaximumSupportAddress = 0

Detailed Description

Instance of SMM memory check library.

SMM memory check library library implementation. This library consumes SMM_ACCESS2_PROTOCOL to get SMRAM information. In order to use this library instance, the platform should produce all SMRAM range via SMM_ACCESS2_PROTOCOL, including the range for firmware (like SMM Core and SMM driver) and/or specific dedicated hardware.

Copyright (c) 2015, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.


Function Documentation

EFI_STATUS EFIAPI SmmCopyMem ( OUT VOID *  DestinationBuffer,
IN CONST VOID *  SourceBuffer,
IN UINTN  Length 
)

Copies a source buffer (NON-SMRAM) to a destination buffer (NON-SMRAM).

This function copies a source buffer (non-SMRAM) to a destination buffer (SMRAM). It checks if source buffer and destination buffer are valid per processor architecture and not overlap with SMRAM. If the check passes, it copies memory and returns EFI_SUCCESS. If the check fails, it returns EFI_SECURITY_VIOLATION. The implementation must be reentrant, and it must handle the case where source buffer overlaps destination buffer.

Parameters:
DestinationBuffer The pointer to the destination buffer of the memory copy.
SourceBuffer The pointer to the source buffer of the memory copy.
Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
Return values:
EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with SMRAM.
EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with SMRAM.
EFI_SUCCESS Memory is copied.

References CopyMem(), DEBUG, EFI_D_ERROR, EFI_SECURITY_VIOLATION, EFI_SUCCESS, and SmmIsBufferOutsideSmmValid().

EFI_STATUS EFIAPI SmmCopyMemFromSmram ( OUT VOID *  DestinationBuffer,
IN CONST VOID *  SourceBuffer,
IN UINTN  Length 
)

Copies a source buffer (SMRAM) to a destination buffer (NON-SMRAM).

This function copies a source buffer (non-SMRAM) to a destination buffer (SMRAM). It checks if destination buffer is valid per processor architecture and not overlap with SMRAM. If the check passes, it copies memory and returns EFI_SUCCESS. If the check fails, it returns EFI_SECURITY_VIOLATION. The implementation must be reentrant.

Parameters:
DestinationBuffer The pointer to the destination buffer of the memory copy.
SourceBuffer The pointer to the source buffer of the memory copy.
Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
Return values:
EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with SMRAM.
EFI_SUCCESS Memory is copied.

References CopyMem(), DEBUG, EFI_D_ERROR, EFI_SECURITY_VIOLATION, EFI_SUCCESS, and SmmIsBufferOutsideSmmValid().

EFI_STATUS EFIAPI SmmCopyMemToSmram ( OUT VOID *  DestinationBuffer,
IN CONST VOID *  SourceBuffer,
IN UINTN  Length 
)

Copies a source buffer (non-SMRAM) to a destination buffer (SMRAM).

This function copies a source buffer (non-SMRAM) to a destination buffer (SMRAM). It checks if source buffer is valid per processor architecture and not overlap with SMRAM. If the check passes, it copies memory and returns EFI_SUCCESS. If the check fails, it return EFI_SECURITY_VIOLATION. The implementation must be reentrant.

Parameters:
DestinationBuffer The pointer to the destination buffer of the memory copy.
SourceBuffer The pointer to the source buffer of the memory copy.
Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
Return values:
EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with SMRAM.
EFI_SUCCESS Memory is copied.

References CopyMem(), DEBUG, EFI_D_ERROR, EFI_SECURITY_VIOLATION, EFI_SUCCESS, and SmmIsBufferOutsideSmmValid().

BOOLEAN EFIAPI SmmIsBufferOutsideSmmValid ( IN EFI_PHYSICAL_ADDRESS  Buffer,
IN UINT64  Length 
)

This function check if the buffer is valid per processor architecture and not overlap with SMRAM.

Parameters:
Buffer The buffer start address to be checked.
Length The buffer length to be checked.
Return values:
TRUE This buffer is valid per processor architecture and not overlap with SMRAM.
FALSE This buffer is not valid per processor architecture or overlap with SMRAM.

References DEBUG, EFI_D_ERROR, FALSE, mSmmMemLibInternalMaximumSupportAddress, mSmmMemLibInternalSmramCount, and TRUE.

Referenced by SmmCopyMem(), SmmCopyMemFromSmram(), SmmCopyMemToSmram(), and SmmSetMem().

EFI_STATUS EFIAPI SmmMemLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The constructor function initializes the Smm Mem library

Parameters:
ImageHandle The firmware allocated handle for the EFI image.
SystemTable A pointer to the EFI System Table.
Return values:
EFI_SUCCESS The constructor always returns EFI_SUCCESS.

References AllocatePool(), ASSERT, ASSERT_EFI_ERROR, EFI_BUFFER_TOO_SMALL, EFI_SUCCESS, gBS, gEfiSmmAccess2ProtocolGuid, EFI_BOOT_SERVICES::LocateProtocol, mSmmMemLibInternalSmramCount, NULL, SmmMemLibInternalCalculateMaximumSupportAddress(), and VOID.

EFI_STATUS EFIAPI SmmMemLibDestructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The destructor function frees resource used in the Smm Mem library

Parameters:
[in] ImageHandle The firmware allocated handle for the EFI image.
[in] SystemTable A pointer to the EFI System Table.
Return values:
EFI_SUCCESS The deconstructor always returns EFI_SUCCESS.

References EFI_SUCCESS, and FreePool().

VOID SmmMemLibInternalCalculateMaximumSupportAddress ( VOID   ) 

Calculate and save the maximum support address.

References AsmCpuid(), ASSERT, DEBUG, EFI_D_INFO, EFI_HOB_TYPE_CPU, GetFirstHob(), LShiftU64(), mSmmMemLibInternalMaximumSupportAddress, NULL, and VOID.

Referenced by SmmMemLibConstructor().

EFI_STATUS EFIAPI SmmSetMem ( OUT VOID *  Buffer,
IN UINTN  Length,
IN UINT8  Value 
)

Fills a target buffer (NON-SMRAM) with a byte value.

This function fills a target buffer (non-SMRAM) with a byte value. It checks if target buffer is valid per processor architecture and not overlap with SMRAM. If the check passes, it fills memory and returns EFI_SUCCESS. If the check fails, it returns EFI_SECURITY_VIOLATION.

Parameters:
Buffer The memory to set.
Length The number of bytes to set.
Value The value with which to fill Length bytes of Buffer.
Return values:
EFI_SECURITY_VIOLATION The Buffer is invalid per processor architecture or overlap with SMRAM.
EFI_SUCCESS Memory is set.

References DEBUG, EFI_D_ERROR, EFI_SECURITY_VIOLATION, EFI_SUCCESS, SetMem(), and SmmIsBufferOutsideSmmValid().


Variable Documentation


Generated on Thu Sep 24 23:14:24 2015 for MdePkg[ALL] by  doxygen 1.5.7.1