TianoCore EDK2 master
|
#include <PiSmm.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/SmmServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/HobLib.h>
#include <Protocol/SmmAccess2.h>
#include <Protocol/SmmReadyToLock.h>
#include <Protocol/SmmEndOfDxe.h>
#include <Guid/MemoryAttributesTable.h>
Go to the source code of this file.
Macros | |
#define | EFI_MEMORY_PRESENT 0x0100000000000000ULL |
#define | EFI_MEMORY_INITIALIZED 0x0200000000000000ULL |
#define | EFI_MEMORY_TESTED 0x0400000000000000ULL |
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 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file SmmMemLib.c.
#define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL |
Definition at line 34 of file SmmMemLib.c.
#define EFI_MEMORY_PRESENT 0x0100000000000000ULL |
Definition at line 33 of file SmmMemLib.c.
#define EFI_MEMORY_TESTED 0x0400000000000000ULL |
Definition at line 35 of file SmmMemLib.c.
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.
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. |
EFI_SECURITY_VIOLATION | The DestinationBuffer 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. |
Definition at line 328 of file SmmMemLib.c.
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.
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. |
EFI_SECURITY_VIOLATION | The DestinationBuffer is invalid per processor architecture or overlap with SMRAM. |
EFI_SUCCESS | Memory is copied. |
Definition at line 293 of file SmmMemLib.c.
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.
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. |
EFI_SECURITY_VIOLATION | The SourceBuffer is invalid per processor architecture or overlap with SMRAM. |
EFI_SUCCESS | Memory is copied. |
Definition at line 259 of file SmmMemLib.c.
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.
Buffer | The buffer start address to be checked. |
Length | The buffer length to be checked. |
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. |
Definition at line 114 of file SmmMemLib.c.
EFI_STATUS EFIAPI SmmLibInternalEndOfDxeNotify | ( | IN CONST EFI_GUID * | Protocol, |
IN VOID * | Interface, | ||
IN EFI_HANDLE | Handle | ||
) |
Notification for SMM EndOfDxe protocol.
[in] | Protocol | Points to the protocol's unique identifier. |
[in] | Interface | Points to the interface instance. |
[in] | Handle | The handle on which the interface was installed. |
EFI_SUCCESS | Notification runs successfully. |
Definition at line 469 of file SmmMemLib.c.
EFI_STATUS EFIAPI SmmLibInternalReadyToLockNotify | ( | IN CONST EFI_GUID * | Protocol, |
IN VOID * | Interface, | ||
IN EFI_HANDLE | Handle | ||
) |
Notification for SMM ReadyToLock protocol.
[in] | Protocol | Points to the protocol's unique identifier. |
[in] | Interface | Points to the interface instance. |
[in] | Handle | The handle on which the interface was installed. |
EFI_SUCCESS | Notification runs successfully. |
Definition at line 584 of file SmmMemLib.c.
EFI_STATUS EFIAPI SmmMemLibConstructor | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
The constructor function initializes the Smm Mem library
ImageHandle | The firmware allocated handle for the EFI image. |
SystemTable | A pointer to the EFI System Table. |
EFI_SUCCESS | The constructor always returns EFI_SUCCESS. |
Definition at line 605 of file SmmMemLib.c.
EFI_STATUS EFIAPI SmmMemLibDestructor | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
The destructor function frees resource used in the Smm Mem library
[in] | ImageHandle | The firmware allocated handle for the EFI image. |
[in] | SystemTable | A pointer to the EFI System Table. |
EFI_SUCCESS | The deconstructor always returns EFI_SUCCESS. |
Definition at line 662 of file SmmMemLib.c.
VOID SmmMemLibInternalCalculateMaximumSupportAddress | ( | VOID | ) |
Calculate and save the maximum support address.
Definition at line 64 of file SmmMemLib.c.
VOID SmmMemLibInternalGetGcdMemoryMap | ( | VOID | ) |
Get GCD memory map. Only record untested memory as invalid communication buffer.
Definition at line 386 of file SmmMemLib.c.
VOID SmmMemLibInternalGetUefiMemoryAttributesTable | ( | VOID | ) |
Get UEFI MemoryAttributesTable.
Definition at line 442 of file SmmMemLib.c.
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.
Buffer | The memory to set. |
Length | The number of bytes to set. |
Value | The value with which to fill Length bytes of Buffer. |
EFI_SECURITY_VIOLATION | The Buffer is invalid per processor architecture or overlap with SMRAM. |
EFI_SUCCESS | Memory is set. |
Definition at line 366 of file SmmMemLib.c.
UINTN mDescriptorSize |
Definition at line 47 of file SmmMemLib.c.
EFI_MEMORY_DESCRIPTOR* mMemoryMap |
Definition at line 46 of file SmmMemLib.c.
UINTN mMemoryMapEntryCount |
Definition at line 45 of file SmmMemLib.c.
VOID* mRegistrationEndOfDxe |
Definition at line 54 of file SmmMemLib.c.
VOID* mRegistrationReadyToLock |
Definition at line 55 of file SmmMemLib.c.
UINTN mSmmMemLibGcdMemNumberOfDesc = 0 |
Definition at line 50 of file SmmMemLib.c.
EFI_GCD_MEMORY_SPACE_DESCRIPTOR* mSmmMemLibGcdMemSpace = NULL |
Definition at line 49 of file SmmMemLib.c.
EFI_PHYSICAL_ADDRESS mSmmMemLibInternalMaximumSupportAddress = 0 |
Definition at line 43 of file SmmMemLib.c.
UINTN mSmmMemLibInternalSmramCount |
Definition at line 38 of file SmmMemLib.c.
EFI_SMRAM_DESCRIPTOR* mSmmMemLibInternalSmramRanges |
Definition at line 37 of file SmmMemLib.c.
EFI_MEMORY_ATTRIBUTES_TABLE* mSmmMemLibMemoryAttributesTable = NULL |
Definition at line 52 of file SmmMemLib.c.
BOOLEAN mSmmMemLibSmmReadyToLock = FALSE |
Definition at line 57 of file SmmMemLib.c.