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

Go to the source code of this file.

Macros

#define EFI_MEMORY_PRESENT   0x0100000000000000ULL
 
#define EFI_MEMORY_INITIALIZED   0x0200000000000000ULL
 
#define EFI_MEMORY_TESTED   0x0400000000000000ULL
 
#define PREVIOUS_MEMORY_DESCRIPTOR(MemoryDescriptor, Size)    ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size)))
 

Functions

STATIC VOID SortMemoryMap (IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN MemoryMapSize, IN UINTN DescriptorSize)
 
BOOLEAN IsUefiPageNotPresent (IN EFI_MEMORY_DESCRIPTOR *MemoryMap)
 
STATIC VOID MergeMemoryMapForNotPresentEntry (IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN OUT UINTN *MemoryMapSize, IN UINTN DescriptorSize)
 
VOID GetGcdMemoryMap (VOID)
 
VOID GetUefiMemoryAttributesTable (VOID)
 
VOID GetUefiMemoryMap (VOID)
 
VOID UpdateUefiMemMapAttributes (VOID)
 
EFI_PHYSICAL_ADDRESS GetSmmProfileData (IN OUT UINT64 *Size)
 
BOOLEAN IsNonMmramLoggingAddress (IN UINT64 Address)
 
BOOLEAN IsSmmCommBufferForbiddenAddress (IN UINT64 Address)
 
VOID CreateExtendedProtectionRange (OUT MM_CPU_MEMORY_REGION **MemoryRegion, OUT UINTN *MemoryRegionCount)
 
VOID CreateNonMmramMemMap (IN UINT8 PhysicalAddressBits, OUT MM_CPU_MEMORY_REGION **MemoryRegion, OUT UINTN *MemoryRegionCount)
 

Variables

EFI_MEMORY_DESCRIPTORmUefiMemoryMap
 
UINTN mUefiMemoryMapSize
 
UINTN mUefiDescriptorSize
 
EFI_GCD_MEMORY_SPACE_DESCRIPTORmGcdMemSpace = NULL
 
UINTN mGcdMemNumberOfDesc = 0
 
EFI_MEMORY_ATTRIBUTES_TABLEmUefiMemoryAttributesTable = NULL
 

Detailed Description

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

Definition in file NonMmramMapDxeSmm.c.

Macro Definition Documentation

◆ EFI_MEMORY_INITIALIZED

#define EFI_MEMORY_INITIALIZED   0x0200000000000000ULL

Definition at line 17 of file NonMmramMapDxeSmm.c.

◆ EFI_MEMORY_PRESENT

#define EFI_MEMORY_PRESENT   0x0100000000000000ULL

Definition at line 16 of file NonMmramMapDxeSmm.c.

◆ EFI_MEMORY_TESTED

#define EFI_MEMORY_TESTED   0x0400000000000000ULL

Definition at line 18 of file NonMmramMapDxeSmm.c.

◆ PREVIOUS_MEMORY_DESCRIPTOR

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

Definition at line 20 of file NonMmramMapDxeSmm.c.

Function Documentation

◆ CreateExtendedProtectionRange()

VOID CreateExtendedProtectionRange ( OUT MM_CPU_MEMORY_REGION **  MemoryRegion,
OUT UINTN MemoryRegionCount 
)

Create extended protection MemoryRegion. Return all MMIO ranges that are reported in GCD service at EndOfDxe.

The caller is responsible for freeing MemoryRegion via FreePool().

Parameters
[out]MemoryRegionReturned Non-Mmram Memory regions.
[out]MemoryRegionCountA pointer to the number of Memory regions.

Definition at line 609 of file NonMmramMapDxeSmm.c.

◆ CreateNonMmramMemMap()

VOID CreateNonMmramMemMap ( IN UINT8  PhysicalAddressBits,
OUT MM_CPU_MEMORY_REGION **  MemoryRegion,
OUT UINTN MemoryRegionCount 
)

Create the Non-Mmram Memory Region. Build MemoryRegion to cover [0, 2^PhysicalAddressBits) by excluding all Smram range. The memory attribute is all-allowed (read/write/executable).

The caller is responsible for freeing MemoryRegion via FreePool().

Parameters
[in]PhysicalAddressBitsThe bits of physical address to map.
[out]MemoryRegionReturned Non-Mmram Memory regions.
[out]MemoryRegionCountA pointer to the number of Memory regions.

Definition at line 689 of file NonMmramMapDxeSmm.c.

◆ GetGcdMemoryMap()

VOID GetGcdMemoryMap ( VOID  )

This function caches the GCD memory map information.

Definition at line 170 of file NonMmramMapDxeSmm.c.

◆ GetSmmProfileData()

EFI_PHYSICAL_ADDRESS GetSmmProfileData ( IN OUT UINT64 *  Size)

Get SmmProfileData.

Parameters
[in,out]SizeReturn Size of SmmProfileData.
Returns
Address of SmmProfileData

Definition at line 489 of file NonMmramMapDxeSmm.c.

◆ GetUefiMemoryAttributesTable()

VOID GetUefiMemoryAttributesTable ( VOID  )

Get UEFI MemoryAttributesTable.

Definition at line 226 of file NonMmramMapDxeSmm.c.

◆ GetUefiMemoryMap()

VOID GetUefiMemoryMap ( VOID  )

This function caches the UEFI memory map information.

Definition at line 246 of file NonMmramMapDxeSmm.c.

◆ IsNonMmramLoggingAddress()

BOOLEAN IsNonMmramLoggingAddress ( IN UINT64  Address)

Return if the Address is the NonMmram logging Address.

Parameters
[in]Addressthe address to be checked
Returns
TRUE The address is the NonMmram logging Address.
FALSE The address is not the NonMmram logging Address.

Definition at line 522 of file NonMmramMapDxeSmm.c.

◆ IsSmmCommBufferForbiddenAddress()

BOOLEAN IsSmmCommBufferForbiddenAddress ( IN UINT64  Address)

Return if the Address is forbidden as SMM communication buffer.

Parameters
[in]Addressthe address to be checked
Returns
TRUE The address is forbidden as SMM communication buffer.
FALSE The address is allowed as SMM communication buffer.

Definition at line 540 of file NonMmramMapDxeSmm.c.

◆ IsUefiPageNotPresent()

BOOLEAN IsUefiPageNotPresent ( IN EFI_MEMORY_DESCRIPTOR MemoryMap)

Return if a UEFI memory page should be marked as not present in SMM page table. If the memory map entries type is EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory, EfiUnusableMemory, EfiACPIReclaimMemory, return TRUE. Or return FALSE.

Parameters
[in]MemoryMapA pointer to the memory descriptor.
Returns
TRUE The memory described will be marked as not present in SMM page table.
FALSE The memory described will not be marked as not present in SMM page table.

Definition at line 85 of file NonMmramMapDxeSmm.c.

◆ MergeMemoryMapForNotPresentEntry()

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

Merge continuous memory map entries whose type is EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory, EfiUnusableMemory, EfiACPIReclaimMemory, because the memory described by these entries will be set as NOT present in SMM page table.

Parameters
[in,out]MemoryMapA pointer to the buffer in which firmware places the current memory map.
[in,out]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.
[in]DescriptorSizeSize, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.

Definition at line 119 of file NonMmramMapDxeSmm.c.

◆ SortMemoryMap()

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

Sort memory map entries based upon PhysicalStart, from low to high.

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 42 of file NonMmramMapDxeSmm.c.

◆ UpdateUefiMemMapAttributes()

VOID UpdateUefiMemMapAttributes ( VOID  )

This function updates UEFI memory attribute according to UEFI memory map.

Definition at line 318 of file NonMmramMapDxeSmm.c.

Variable Documentation

◆ mGcdMemNumberOfDesc

UINTN mGcdMemNumberOfDesc = 0

Definition at line 28 of file NonMmramMapDxeSmm.c.

◆ mGcdMemSpace

Definition at line 27 of file NonMmramMapDxeSmm.c.

◆ mUefiDescriptorSize

UINTN mUefiDescriptorSize

Definition at line 25 of file NonMmramMapDxeSmm.c.

◆ mUefiMemoryAttributesTable

EFI_MEMORY_ATTRIBUTES_TABLE* mUefiMemoryAttributesTable = NULL

Definition at line 30 of file NonMmramMapDxeSmm.c.

◆ mUefiMemoryMap

EFI_MEMORY_DESCRIPTOR* mUefiMemoryMap

Definition at line 23 of file NonMmramMapDxeSmm.c.

◆ mUefiMemoryMapSize

UINTN mUefiMemoryMapSize

Definition at line 24 of file NonMmramMapDxeSmm.c.