TianoCore EDK2 master
|
#include <Uefi.h>
#include <Library/BaseLib.h>
#include <Library/CacheLib.h>
#include <Library/CacheAsRamLib.h>
#include "CacheLibInternal.h"
Go to the source code of this file.
Data Structures | |
struct | EFI_FIXED_MTRR |
Functions | |
EFI_STATUS | SearchForExactMtrr (IN EFI_PHYSICAL_ADDRESS MemoryAddress, IN UINT64 MemoryLength, IN UINT64 ValidMtrrAddressMask, OUT UINT32 *UsedMsrNum, OUT EFI_MEMORY_CACHE_TYPE *MemoryCacheType) |
BOOLEAN | IsDefaultType (IN EFI_MEMORY_CACHE_TYPE MemoryCacheType) |
UINT32 | CheckMtrrAlignment (IN UINT64 BaseAddress, IN UINT64 Size) |
INT8 | CheckDirection (IN UINT64 Input) |
VOID | EfiDisableCacheMtrr (OUT UINT64 *OldMtrr) |
VOID | EfiRecoverCacheMtrr (IN BOOLEAN EnableMtrr, IN UINT64 OldMtrr) |
VOID | EfiProgramMtrr (IN UINT32 MtrrNumber, IN EFI_PHYSICAL_ADDRESS MemoryAddress, IN UINT64 MemoryLength, IN EFI_MEMORY_CACHE_TYPE MemoryCacheType, IN UINT64 ValidMtrrAddressMask) |
UINT64 | Power2MaxMemory (IN UINT64 MemoryAddress, IN UINT64 MemoryLength) |
EFI_STATUS | ProgramFixedMtrr (IN EFI_MEMORY_CACHE_TYPE MemoryCacheType, IN UINT64 *Base, IN UINT64 *Len) |
BOOLEAN | CheckMtrrOverlap (IN EFI_PHYSICAL_ADDRESS Start, IN EFI_PHYSICAL_ADDRESS End) |
EFI_STATUS EFIAPI | SetCacheAttributes (IN EFI_PHYSICAL_ADDRESS MemoryAddress, IN UINT64 MemoryLength, IN EFI_MEMORY_CACHE_TYPE MemoryCacheType) |
EFI_STATUS EFIAPI | ResetCacheAttributes (VOID) |
Variables | |
EFI_FIXED_MTRR | mFixedMtrrTable [] |
Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file CacheLib.c.
INT8 CheckDirection | ( | IN UINT64 | Input | ) |
Given the input, check if the number of MTRR is lesser. if positive or subtractive.
[in] | Input | Length of Memory to program MTRR. |
Zero | do positive. |
Non-Zero | do subtractive. |
Definition at line 96 of file CacheLib.c.
Return MTRR alignment requirement for base address and size.
[in] | BaseAddress | Base address. |
[in] | Size | Size. |
Zero | Aligned. |
Non-Zero | Not aligned. |
Definition at line 255 of file CacheLib.c.
BOOLEAN CheckMtrrOverlap | ( | IN EFI_PHYSICAL_ADDRESS | Start, |
IN EFI_PHYSICAL_ADDRESS | End | ||
) |
Check if there is a valid variable MTRR that overlaps the given range.
[in] | Start | Base Address of the range to check. |
[in] | End | End address of the range to check. |
TRUE | Mtrr overlap. |
FALSE | Mtrr not overlap. |
Definition at line 354 of file CacheLib.c.
VOID EfiDisableCacheMtrr | ( | OUT UINT64 * | OldMtrr | ) |
Disable cache and its mtrr.
[out] | OldMtrr | To return the Old MTRR value |
Definition at line 110 of file CacheLib.c.
VOID EfiProgramMtrr | ( | IN UINT32 | MtrrNumber, |
IN EFI_PHYSICAL_ADDRESS | MemoryAddress, | ||
IN UINT64 | MemoryLength, | ||
IN EFI_MEMORY_CACHE_TYPE | MemoryCacheType, | ||
IN UINT64 | ValidMtrrAddressMask | ||
) |
Programming MTRR according to Memory address, length, and type.
[in] | MtrrNumber | the variable MTRR index number |
[in] | MemoryAddress | the address of target memory |
[in] | MemoryLength | the length of target memory |
[in] | MemoryCacheType | the cache type of target memory |
[in] | ValidMtrrAddressMask | the MTRR address mask |
Definition at line 166 of file CacheLib.c.
Recover cache MTRR.
[in] | EnableMtrr | Whether to enable the MTRR |
[in] | OldMtrr | The saved old MTRR value to restore when not to enable the MTRR |
Definition at line 133 of file CacheLib.c.
BOOLEAN IsDefaultType | ( | IN EFI_MEMORY_CACHE_TYPE | MemoryCacheType | ) |
Check if CacheType match current default setting.
[in] | MemoryCacheType | input cache type to be checked. |
TRUE | MemoryCacheType is default MTRR setting. |
FALSE | MemoryCacheType is NOT default MTRR setting. |
Check if CacheType match current default setting.
[in] | MemoryCacheType | input cache type to be checked. |
TRUE | MemoryCacheType is default MTRR setting. |
TRUE | MemoryCacheType is NOT default MTRR setting. |
Definition at line 698 of file CacheLib.c.
Calculate the maximum value which is a power of 2, but less the MemoryLength.
[in] | MemoryAddress | Memory address. |
[in] | MemoryLength | The number to pass in. |
Definition at line 208 of file CacheLib.c.
EFI_STATUS ProgramFixedMtrr | ( | IN EFI_MEMORY_CACHE_TYPE | MemoryCacheType, |
IN UINT64 * | Base, | ||
IN UINT64 * | Len | ||
) |
Programs fixed MTRRs registers.
[in] | MemoryCacheType | The memory type to set. |
[in] | Base | The base address of memory range. |
[in] | Length | The length of memory range. |
RETURN_SUCCESS | The cache type was updated successfully |
RETURN_UNSUPPORTED | The requested range or cache type was invalid for the fixed MTRRs. |
Definition at line 290 of file CacheLib.c.
EFI_STATUS EFIAPI ResetCacheAttributes | ( | VOID | ) |
Reset all the MTRRs to a known state.
EFI_SUCCESS | All MTRRs have been reset successfully. |
Definition at line 582 of file CacheLib.c.
EFI_STATUS SearchForExactMtrr | ( | IN EFI_PHYSICAL_ADDRESS | MemoryAddress, |
IN UINT64 | MemoryLength, | ||
IN UINT64 | ValidMtrrAddressMask, | ||
OUT UINT32 * | UsedMsrNum, | ||
OUT EFI_MEMORY_CACHE_TYPE * | UsedMemoryCacheType | ||
) |
Search the memory cache type for specific memory from MTRR.
[in] | MemoryAddress | the address of target memory |
[in] | MemoryLength | the length of target memory |
[in] | ValidMtrrAddressMask | the MTRR address mask |
[out] | UsedMsrNum | the used MSR number |
[out] | UsedMemoryCacheType | the cache type for the target memory |
EFI_SUCCESS | The memory is found in MTRR and cache type is returned |
EFI_NOT_FOUND | The memory is not found in MTRR |
Definition at line 649 of file CacheLib.c.
EFI_STATUS EFIAPI SetCacheAttributes | ( | IN EFI_PHYSICAL_ADDRESS | MemoryAddress, |
IN UINT64 | MemoryLength, | ||
IN EFI_MEMORY_CACHE_TYPE | MemoryCacheType | ||
) |
Given the memory range and cache type, programs the MTRRs.
[in] | MemoryAddress | Base Address of Memory to program MTRR. |
[in] | MemoryLength | Length of Memory to program MTRR. |
[in] | MemoryCacheType | Cache Type. |
EFI_SUCCESS | Mtrr are set successfully. |
EFI_LOAD_ERROR | No empty MTRRs to use. |
EFI_INVALID_PARAMETER | The input parameter is not valid. |
others | An error occurs when setting MTTR. |
Definition at line 377 of file CacheLib.c.
EFI_FIXED_MTRR mFixedMtrrTable[] |
Definition at line 71 of file CacheLib.c.