UefiCpuPkg/MtrrLib: Add API MtrrGetMemoryAttributesInMtrrSettings.

MtrrGetMemoryAttributesInMtrrSettings parses the MTRR settings
either from hardware or from the parameter and returns an
array containing the memory cache types of all memory addresses.

This API could elinimate the needs of following APIs:
1. MtrrGetMemoryAttributeInVariableMtr
2. MtrrGetFixedMtrr

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>

Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
YuanhaoXie
2023-09-11 18:41:34 +08:00
committed by mergify[bot]
parent c032db3308
commit 4b7b32f846
2 changed files with 130 additions and 10 deletions

View File

@@ -359,4 +359,27 @@ MtrrSetMemoryAttributesInMtrrSettings (
IN UINTN RangeCount
);
/**
This function returns a Ranges array containing the memory cache types
of all memory addresses.
@param[in] MtrrSetting MTRR setting buffer to parse.
@param[out] Ranges Pointer to an array of MTRR_MEMORY_RANGE.
@param[in,out] RangeCount Count of MTRR_MEMORY_RANGE.
On input, the maximum entries the Ranges can hold.
On output, the actual entries that the function returns.
@retval RETURN_INVALID_PARAMETER RangeCount is NULL.
@retval RETURN_INVALID_PARAMETER *RangeCount is not 0 but Ranges is NULL.
@retval RETURN_BUFFER_TOO_SMALL *RangeCount is too small.
@retval RETURN_SUCCESS Ranges are successfully returned.
**/
RETURN_STATUS
EFIAPI
MtrrGetMemoryAttributesInMtrrSettings (
IN CONST MTRR_SETTINGS *MtrrSetting OPTIONAL,
OUT MTRR_MEMORY_RANGE *Ranges,
IN OUT UINTN *RangeCount
);
#endif // _MTRR_LIB_H_