TianoCore EDK2 master
Loading...
Searching...
No Matches
MemoryAttributesTable.c File Reference

Go to the source code of this file.

Data Structures

struct  IMAGE_PROPERTIES_PRIVATE_DATA
 

Macros

#define PREVIOUS_MEMORY_DESCRIPTOR(MemoryDescriptor, Size)    ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size)))
 
#define IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE   SIGNATURE_32 ('I','P','P','D')
 

Functions

EFI_STATUS EFIAPI CoreGetMemoryMapWithSeparatedImageSection (IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, OUT UINTN *MapKey, OUT UINTN *DescriptorSize, OUT UINT32 *DescriptorVersion)
 
VOID InstallMemoryAttributesTable (VOID)
 
VOID InstallMemoryAttributesTableOnMemoryAllocation (IN EFI_MEMORY_TYPE MemoryType)
 
VOID EFIAPI InstallMemoryAttributesTableOnReadyToBoot (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI InstallMemoryAttributesTableOnEndOfDxe (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI CoreInitializeMemoryAttributesTable (VOID)
 
STATIC VOID CoreAcquiremMemoryAttributesTableLock (VOID)
 
STATIC VOID CoreReleasemMemoryAttributesTableLock (VOID)
 
VOID MergeMemoryMap (IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN OUT UINTN *MemoryMapSize, IN UINTN DescriptorSize)
 
STATIC VOID EnforceMemoryMapAttribute (IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN MemoryMapSize, IN UINTN DescriptorSize)
 
VOID InsertImageRecord (IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage)
 
VOID RemoveImageRecord (IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage)
 

Variables

STATIC IMAGE_PROPERTIES_PRIVATE_DATA mImagePropertiesPrivateData
 
STATIC EFI_LOCK mMemoryAttributesTableLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY)
 
BOOLEAN mMemoryAttributesTableEnable = TRUE
 
EFI_MEMORY_ATTRIBUTES_TABLE * mMemoryAttributesTable = NULL
 
BOOLEAN mMemoryAttributesTableReadyToBoot = FALSE
 
BOOLEAN gMemoryAttributesTableForwardCfi = TRUE
 

Detailed Description

UEFI MemoryAttributesTable support

Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file MemoryAttributesTable.c.

Macro Definition Documentation

◆ IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE

#define IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE   SIGNATURE_32 ('I','P','P','D')

Definition at line 71 of file MemoryAttributesTable.c.

◆ PREVIOUS_MEMORY_DESCRIPTOR

#define PREVIOUS_MEMORY_DESCRIPTOR (   MemoryDescriptor,
  Size 
)     ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size)))

Definition at line 68 of file MemoryAttributesTable.c.

Function Documentation

◆ CoreAcquiremMemoryAttributesTableLock()

STATIC VOID CoreAcquiremMemoryAttributesTableLock ( VOID  )

Acquire memory lock on mMemoryAttributesTableLock.

Definition at line 357 of file MemoryAttributesTable.c.

◆ CoreGetMemoryMapWithSeparatedImageSection()

EFI_STATUS EFIAPI CoreGetMemoryMapWithSeparatedImageSection ( IN OUT UINTN *  MemoryMapSize,
IN OUT EFI_MEMORY_DESCRIPTOR *  MemoryMap,
OUT UINTN *  MapKey,
OUT UINTN *  DescriptorSize,
OUT UINT32 *  DescriptorVersion 
)

This function for GetMemoryMap() with properties table capability.

It calls original GetMemoryMap() to get the original memory map information. Then plus the additional memory map entries for PE Code/Data seperation.

Parameters
MemoryMapSizeA pointer to the size, in bytes, of the MemoryMap buffer. On input, this is the size of the buffer allocated by the caller. On output, it is the size of the buffer returned by the firmware if the buffer was large enough, or the size of the buffer needed to contain the map if the buffer was too small.
MemoryMapA pointer to the buffer in which firmware places the current memory map.
MapKeyA pointer to the location in which firmware returns the key for the current memory map.
DescriptorSizeA pointer to the location in which firmware returns the size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
DescriptorVersionA pointer to the location in which firmware returns the version number associated with the EFI_MEMORY_DESCRIPTOR.
Return values
EFI_SUCCESSThe memory map was returned in the MemoryMap buffer.
EFI_BUFFER_TOO_SMALLThe MemoryMap buffer was too small. The current buffer size needed to hold the memory map is returned in MemoryMapSize.
EFI_INVALID_PARAMETEROne of the parameters has an invalid value.

Definition at line 518 of file MemoryAttributesTable.c.

◆ CoreInitializeMemoryAttributesTable()

VOID EFIAPI CoreInitializeMemoryAttributesTable ( VOID  )

Initialize MemoryAttrubutesTable support.

Definition at line 309 of file MemoryAttributesTable.c.

◆ CoreReleasemMemoryAttributesTableLock()

STATIC VOID CoreReleasemMemoryAttributesTableLock ( VOID  )

Release memory lock on mMemoryAttributesTableLock.

Definition at line 369 of file MemoryAttributesTable.c.

◆ EnforceMemoryMapAttribute()

STATIC VOID EnforceMemoryMapAttribute ( IN OUT EFI_MEMORY_DESCRIPTOR *  MemoryMap,
IN UINTN  MemoryMapSize,
IN UINTN  DescriptorSize 
)

Enforce memory map attributes. This function will set EfiRuntimeServicesData to be EFI_MEMORY_XP.

Parameters
MemoryMapA pointer to the buffer in which firmware places the current memory map.
MemoryMapSizeSize, in bytes, of the MemoryMap buffer.
DescriptorSizeSize, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.

Definition at line 447 of file MemoryAttributesTable.c.

◆ InsertImageRecord()

VOID InsertImageRecord ( IN EFI_RUNTIME_IMAGE_ENTRY *  RuntimeImage)

Insert image record.

Parameters
RuntimeImageRuntime image information

Definition at line 589 of file MemoryAttributesTable.c.

◆ InstallMemoryAttributesTable()

VOID InstallMemoryAttributesTable ( VOID  )

Install MemoryAttributesTable.

Definition at line 99 of file MemoryAttributesTable.c.

◆ InstallMemoryAttributesTableOnEndOfDxe()

VOID EFIAPI InstallMemoryAttributesTableOnEndOfDxe ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Install initial MemoryAttributesTable on EndOfDxe. Then SMM can consume this information.

Parameters
[in]EventThe Event this notify function registered to.
[in]ContextPointer to the context data registered to the Event.

Definition at line 287 of file MemoryAttributesTable.c.

◆ InstallMemoryAttributesTableOnMemoryAllocation()

VOID InstallMemoryAttributesTableOnMemoryAllocation ( IN EFI_MEMORY_TYPE  MemoryType)

Install MemoryAttributesTable on memory allocation.

Parameters
[in]MemoryTypeEFI memory type.

Definition at line 247 of file MemoryAttributesTable.c.

◆ InstallMemoryAttributesTableOnReadyToBoot()

VOID EFIAPI InstallMemoryAttributesTableOnReadyToBoot ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Install MemoryAttributesTable on ReadyToBoot.

Parameters
[in]EventThe Event this notify function registered to.
[in]ContextPointer to the context data registered to the Event.

Definition at line 269 of file MemoryAttributesTable.c.

◆ MergeMemoryMap()

VOID MergeMemoryMap ( IN OUT EFI_MEMORY_DESCRIPTOR *  MemoryMap,
IN OUT UINTN *  MemoryMapSize,
IN UINTN  DescriptorSize 
)

Merge continous memory map entries whose have same attributes.

Parameters
MemoryMapA pointer to the buffer in which firmware places the current memory map.
MemoryMapSizeA pointer to the size, in bytes, of the MemoryMap buffer. On input, this is the size of the current memory map. On output, it is the size of new memory map after merge.
DescriptorSizeSize, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.

Definition at line 388 of file MemoryAttributesTable.c.

◆ RemoveImageRecord()

VOID RemoveImageRecord ( IN EFI_RUNTIME_IMAGE_ENTRY *  RuntimeImage)

Remove Image record.

Parameters
RuntimeImageRuntime image information

Definition at line 673 of file MemoryAttributesTable.c.

Variable Documentation

◆ gMemoryAttributesTableForwardCfi

BOOLEAN gMemoryAttributesTableForwardCfi = TRUE

Definition at line 92 of file MemoryAttributesTable.c.

◆ mImagePropertiesPrivateData

STATIC IMAGE_PROPERTIES_PRIVATE_DATA mImagePropertiesPrivateData
Initial value:
= {
IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE,
0,
0,
}

Definition at line 80 of file MemoryAttributesTable.c.

◆ mMemoryAttributesTable

EFI_MEMORY_ATTRIBUTES_TABLE* mMemoryAttributesTable = NULL

Definition at line 90 of file MemoryAttributesTable.c.

◆ mMemoryAttributesTableEnable

BOOLEAN mMemoryAttributesTableEnable = TRUE

Definition at line 89 of file MemoryAttributesTable.c.

◆ mMemoryAttributesTableLock

STATIC EFI_LOCK mMemoryAttributesTableLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY)

Definition at line 87 of file MemoryAttributesTable.c.

◆ mMemoryAttributesTableReadyToBoot

BOOLEAN mMemoryAttributesTableReadyToBoot = FALSE

Definition at line 91 of file MemoryAttributesTable.c.