/** @file
MTRR setting library
Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _MTRR_LIB_H_
#define _MTRR_LIB_H_
//
// According to IA32 SDM, MTRRs number and msr offset are always consistent
// for IA32 processor family
//
//
// The semantics of below macro is MAX_MTRR_NUMBER_OF_VARIABLE_MTRR, the real number can be read out from MTRR_CAP register.
//
//
// Firmware need reserve 2 MTRR for OS
//
//
// Below macro is deprecated, and should not be used.
//
//
// Below macro is deprecated, and should not be used.
//
//
// Structure to describe a fixed MTRR
//
typedef struct {
} FIXED_MTRR;
//
// Structure to describe a variable MTRR
//
typedef struct {
//
// Structure to hold base and mask pair for variable MTRR register
//
typedef struct _MTRR_VARIABLE_SETTING_ {
//
// Array for variable MTRRs
//
typedef struct _MTRR_VARIABLE_SETTINGS_ {
//
// Array for fixed mtrrs
//
typedef struct _MTRR_FIXED_SETTINGS_ {
//
// Structure to hold all MTRRs
//
typedef struct _MTRR_SETTINGS_ {
//
// Memory cache types
//
typedef enum {
CacheUncacheable = 0,
#define MTRR_CACHE_UNCACHEABLE 0
/**
Returns the variable MTRR count for the CPU.
@return Variable MTRR count
**/
);
/**
Returns the firmware usable variable MTRR count for the CPU.
@return Firmware usable variable MTRR count
**/
);
/**
This function attempts to set the attributes for a memory range.
@param BaseAddress The physical address that is the start address of a memory region.
@param Length The size in bytes of the memory region.
@param Attributes The bit mask of attributes to set for the memory region.
@retval RETURN_SUCCESS The attributes were set for the memory region.
@retval RETURN_INVALID_PARAMETER Length is zero.
@retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the
memory resource range specified by BaseAddress and Length.
@retval RETURN_UNSUPPORTED The bit mask of attributes is not support for the memory resource
range specified by BaseAddress and Length.
@retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by
BaseAddress and Length cannot be modified.
@retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of
the memory resource range.
**/
);
/**
This function will get the memory cache type of the specific address.
This function is mainly for debugging purposes.
@param Address The specific address
@return The memory cache type of the specific address
**/
);
/**
This function will get the raw value in variable MTRRs
@param VariableSettings A buffer to hold variable MTRRs content.
@return The buffer point to MTRR_VARIABLE_SETTINGS in which holds the content of the variable mtrr
**/
);
/**
This function sets fixed MTRRs
@param VariableSettings A buffer to hold variable MTRRs content.
@return The pointer of VariableSettings
**/
);
/**
This function gets the content in fixed MTRRs
@param FixedSettings A buffer to hold fixed MTRRs content.
@return The pointer of FixedSettings
**/
);
/**
This function sets fixed MTRRs
@param FixedSettings A buffer holding fixed MTRRs content.
@return The pointer of FixedSettings
**/
);
/**
This function gets the content in all MTRRs (variable and fixed)
@param MtrrSetting A buffer to hold all MTRRs content.
@return The pointer of MtrrSetting
**/
);
/**
This function sets all MTRRs (variable and fixed)
@param MtrrSetting A buffer to hold all MTRRs content.
@return The pointer of MtrrSetting
**/
);
/**
Get the attribute of variable MTRRs.
This function shadows the content of variable MTRRs into
an internal array: VariableMtrr
@param MtrrValidBitsMask The mask for the valid bit of the MTRR
@param MtrrValidAddressMask The valid address mask for MTRR since the base address in
MTRR must align to 4K, so valid address mask equal to
MtrrValidBitsMask & 0xfffffffffffff000ULL
@param VariableMtrr The array to shadow variable MTRRs content
@return The ruturn value of this paramter indicates the number of
MTRRs which has been used.
**/
);
/**
This function prints all MTRRs for debugging.
**/
);
/**
Checks if MTRR is supported.
@retval TRUE MTRR is supported.
@retval FALSE MTRR is not supported.
**/
);
/**
Returns the default MTRR cache type for the system.
@return The default MTRR cache type.
**/
);
#endif // _MTRR_LIB_H_