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

Go to the source code of this file.

Macros

#define MIN_T0SZ   16
 
#define BITS_PER_LEVEL   9
 
#define MAX_VA_BITS_48   48
 
#define MAX_VA_BITS   52
 

Functions

STATIC BOOLEAN TranslationRegimeIsDual (VOID)
 
STATIC UINT64 ArmMemoryAttributeToPageAttribute (IN ARM_MEMORY_REGION_ATTRIBUTES Attributes)
 
STATIC VOID SetOutputAddress (IN UINTN *Entry, IN UINTN Address, IN BOOLEAN Lpa2Enabled)
 
STATIC UINT64 GetOutputAddress (IN UINT64 Entry, IN BOOLEAN Lpa2Enabled)
 
STATIC UINTN GetRootTableEntryCount (IN UINTN T0SZ)
 
STATIC INTN GetRootTableLevel (IN UINTN T0SZ)
 
STATIC VOID ReplaceTableEntry (IN UINT64 *Entry, IN UINT64 Value, IN UINT64 RegionStart, IN UINT64 BlockMask, IN BOOLEAN IsLiveBlockMapping)
 
STATIC VOID FreePageTablesRecursive (IN UINT64 *TranslationTable, IN UINTN Level, IN BOOLEAN Lpa2Enabled)
 
STATIC BOOLEAN IsBlockEntry (IN UINT64 Entry, IN UINTN Level)
 
STATIC BOOLEAN IsTableEntry (IN UINT64 Entry, IN UINTN Level)
 
STATIC EFI_STATUS UpdateRegionMappingRecursive (IN UINT64 RegionStart, IN UINT64 RegionEnd, IN UINT64 AttributeSetMask, IN UINT64 AttributeClearMask, IN UINT64 *PageTable, IN INTN Level, IN BOOLEAN IsRootTable, IN BOOLEAN TableIsLive, IN BOOLEAN Lpa2Enabled)
 
STATIC EFI_STATUS UpdateRegionMapping (IN UINT64 RegionStart, IN UINT64 RegionLength, IN UINT64 AttributeSetMask, IN UINT64 AttributeClearMask, IN UINT64 *RootTable, IN BOOLEAN TableIsLive, IN BOOLEAN Lpa2Enabled)
 
STATIC EFI_STATUS FillTranslationTable (IN UINT64 *RootTable, IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryRegion, IN BOOLEAN Lpa2Enabled)
 
STATIC UINT64 GcdAttributeToPageAttribute (IN UINT64 GcdAttributes)
 
EFI_STATUS ArmSetMemoryAttributes (IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes, IN UINT64 AttributeMask)
 
EFI_STATUS EFIAPI ArmConfigureMmu (IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable, OUT VOID **TranslationTableBase OPTIONAL, OUT UINTN *TranslationTableSize OPTIONAL)
 
BOOLEAN ArmLpa2Enabled (VOID)
 
RETURN_STATUS EFIAPI ArmMmuBaseLibConstructor (VOID)
 

Variables

STATIC ARM_REPLACE_LIVE_TRANSLATION_ENTRY mReplaceLiveEntryFunc = ArmReplaceLiveTranslationEntry
 

Detailed Description

File managing the MMU for ARMv8 architecture

Copyright (c) 2011-2025, ARM Limited. All rights reserved. Copyright (c) 2016, Linaro Limited. All rights reserved. Copyright (c) 2017, Intel Corporation. All rights reserved.

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

Definition in file ArmMmuLibCore.c.

Macro Definition Documentation

◆ BITS_PER_LEVEL

#define BITS_PER_LEVEL   9

Definition at line 96 of file ArmMmuLibCore.c.

◆ MAX_VA_BITS

#define MAX_VA_BITS   52

Definition at line 98 of file ArmMmuLibCore.c.

◆ MAX_VA_BITS_48

#define MAX_VA_BITS_48   48

Definition at line 97 of file ArmMmuLibCore.c.

◆ MIN_T0SZ

#define MIN_T0SZ   16

Definition at line 95 of file ArmMmuLibCore.c.

Function Documentation

◆ ArmConfigureMmu()

EFI_STATUS EFIAPI ArmConfigureMmu ( IN ARM_MEMORY_REGION_DESCRIPTOR MemoryTable,
OUT VOID **TranslationTableBase  OPTIONAL,
OUT UINTN *TranslationTableSize  OPTIONAL 
)

Definition at line 631 of file ArmMmuLibCore.c.

◆ ArmLpa2Enabled()

BOOLEAN ArmLpa2Enabled ( VOID  )

Check whether a 52-bit output address can be described by the translation tables (FEAT_LPA2).

Return values
TRUE52-bit output address is enabled (LPA2 enabled).
FALSE52-bit output address is disabled (LPA2 disabled).

Definition at line 833 of file ArmMmuLibCore.c.

◆ ArmMemoryAttributeToPageAttribute()

STATIC UINT64 ArmMemoryAttributeToPageAttribute ( IN ARM_MEMORY_REGION_ATTRIBUTES  Attributes)

Definition at line 46 of file ArmMmuLibCore.c.

◆ ArmMmuBaseLibConstructor()

RETURN_STATUS EFIAPI ArmMmuBaseLibConstructor ( VOID  )

Definition at line 848 of file ArmMmuLibCore.c.

◆ ArmSetMemoryAttributes()

EFI_STATUS ArmSetMemoryAttributes ( IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64  Attributes,
IN UINT64  AttributeMask 
)

Set the requested memory permission attributes on a region of memory.

BaseAddress and Length must be aligned to EFI_PAGE_SIZE.

If Attributes contains a memory type attribute (EFI_MEMORY_UC/WC/WT/WB), the region is mapped according to this memory type, and additional memory permission attributes (EFI_MEMORY_RP/RO/XP) are taken into account as well, discarding any permission attributes that are currently set for the region. AttributeMask is ignored in this case, and must be set to 0x0.

If Attributes contains only a combination of memory permission attributes (EFI_MEMORY_RP/RO/XP), each page in the region will retain its existing memory type, even if it is not uniformly set across the region. In this case, AttributesMask may be set to a mask of permission attributes, and memory permissions omitted from this mask will not be updated for any page in the region. All attributes appearing in Attributes must appear in AttributeMask as well. (Attributes & ~AttributeMask must produce 0x0)

Parameters
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
[in]AttributesMask of memory attributes to set.
[in]AttributeMaskMask of memory attributes to take into account.
Return values
EFI_SUCCESSThe attributes were set for the memory region.
EFI_INVALID_PARAMETERBaseAddress or Length is not suitably aligned. Invalid combination of Attributes and AttributeMask.
EFI_OUT_OF_RESOURCESRequested attributes cannot be applied due to lack of system resources.

Definition at line 579 of file ArmMmuLibCore.c.

◆ FillTranslationTable()

STATIC EFI_STATUS FillTranslationTable ( IN UINT64 *  RootTable,
IN ARM_MEMORY_REGION_DESCRIPTOR MemoryRegion,
IN BOOLEAN  Lpa2Enabled 
)

Definition at line 481 of file ArmMmuLibCore.c.

◆ FreePageTablesRecursive()

STATIC VOID FreePageTablesRecursive ( IN UINT64 *  TranslationTable,
IN UINTN  Level,
IN BOOLEAN  Lpa2Enabled 
)

Definition at line 199 of file ArmMmuLibCore.c.

◆ GcdAttributeToPageAttribute()

STATIC UINT64 GcdAttributeToPageAttribute ( IN UINT64  GcdAttributes)

Definition at line 500 of file ArmMmuLibCore.c.

◆ GetOutputAddress()

STATIC UINT64 GetOutputAddress ( IN UINT64  Entry,
IN BOOLEAN  Lpa2Enabled 
)

Definition at line 119 of file ArmMmuLibCore.c.

◆ GetRootTableEntryCount()

STATIC UINTN GetRootTableEntryCount ( IN UINTN  T0SZ)

Definition at line 133 of file ArmMmuLibCore.c.

◆ GetRootTableLevel()

STATIC INTN GetRootTableLevel ( IN UINTN  T0SZ)

Definition at line 142 of file ArmMmuLibCore.c.

◆ IsBlockEntry()

STATIC BOOLEAN IsBlockEntry ( IN UINT64  Entry,
IN UINTN  Level 
)

Definition at line 229 of file ArmMmuLibCore.c.

◆ IsTableEntry()

STATIC BOOLEAN IsTableEntry ( IN UINT64  Entry,
IN UINTN  Level 
)

Definition at line 243 of file ArmMmuLibCore.c.

◆ ReplaceTableEntry()

STATIC VOID ReplaceTableEntry ( IN UINT64 *  Entry,
IN UINT64  Value,
IN UINT64  RegionStart,
IN UINT64  BlockMask,
IN BOOLEAN  IsLiveBlockMapping 
)

Definition at line 156 of file ArmMmuLibCore.c.

◆ SetOutputAddress()

STATIC VOID SetOutputAddress ( IN UINTN Entry,
IN UINTN  Address,
IN BOOLEAN  Lpa2Enabled 
)

Definition at line 102 of file ArmMmuLibCore.c.

◆ TranslationRegimeIsDual()

STATIC BOOLEAN TranslationRegimeIsDual ( VOID  )

Whether the current translation regime is either EL1&0 or EL2&0, and therefore supports non-global, ASID-scoped memory mappings.

Definition at line 33 of file ArmMmuLibCore.c.

◆ UpdateRegionMapping()

STATIC EFI_STATUS UpdateRegionMapping ( IN UINT64  RegionStart,
IN UINT64  RegionLength,
IN UINT64  AttributeSetMask,
IN UINT64  AttributeClearMask,
IN UINT64 *  RootTable,
IN BOOLEAN  TableIsLive,
IN BOOLEAN  Lpa2Enabled 
)

Definition at line 441 of file ArmMmuLibCore.c.

◆ UpdateRegionMappingRecursive()

STATIC EFI_STATUS UpdateRegionMappingRecursive ( IN UINT64  RegionStart,
IN UINT64  RegionEnd,
IN UINT64  AttributeSetMask,
IN UINT64  AttributeClearMask,
IN UINT64 *  PageTable,
IN INTN  Level,
IN BOOLEAN  IsRootTable,
IN BOOLEAN  TableIsLive,
IN BOOLEAN  Lpa2Enabled 
)

Definition at line 261 of file ArmMmuLibCore.c.

Variable Documentation

◆ mReplaceLiveEntryFunc

STATIC ARM_REPLACE_LIVE_TRANSLATION_ENTRY mReplaceLiveEntryFunc = ArmReplaceLiveTranslationEntry

Definition at line 25 of file ArmMmuLibCore.c.