#include <linux/init.h>
#include <linux/pci.h>
#include <linux/smp.h>
#include <linux/cpu.h>
#include <linux/mutex.h>
#include <linux/uaccess.h>
#include <linux/kvm_para.h>
#include <linux/range.h>
#include <asm/processor.h>
#include <asm/e820/api.h>
#include <asm/mtrr.h>
#include <asm/msr.h>
#include "mtrr.h"
struct var_mtrr_range_state { … };
struct var_mtrr_state { … };
#define RANGE_NUM …
static struct range __initdata range[RANGE_NUM];
static int __initdata nr_range;
static struct var_mtrr_range_state __initdata range_state[RANGE_NUM];
#define BIOS_BUG_MSG …
static int __init
x86_get_mtrr_mem_range(struct range *range, int nr_range,
unsigned long extra_remove_base,
unsigned long extra_remove_size)
{ … }
#ifdef CONFIG_MTRR_SANITIZER
static unsigned long __init sum_ranges(struct range *range, int nr_range)
{ … }
static int enable_mtrr_cleanup __initdata = …;
static int __init disable_mtrr_cleanup_setup(char *str)
{ … }
early_param(…);
static int __init enable_mtrr_cleanup_setup(char *str)
{ … }
early_param(…);
static void __init
set_var_mtrr(unsigned int reg, unsigned long basek, unsigned long sizek,
unsigned char type)
{ … }
static void __init
save_var_mtrr(unsigned int reg, unsigned long basek, unsigned long sizek,
unsigned char type)
{ … }
static void __init set_var_mtrr_all(void)
{ … }
static unsigned long to_size_factor(unsigned long sizek, char *factorp)
{ … }
static unsigned int __init
range_to_mtrr(unsigned int reg, unsigned long range_startk,
unsigned long range_sizek, unsigned char type)
{ … }
static unsigned __init
range_to_mtrr_with_hole(struct var_mtrr_state *state, unsigned long basek,
unsigned long sizek)
{ … }
static void __init
set_var_mtrr_range(struct var_mtrr_state *state, unsigned long base_pfn,
unsigned long size_pfn)
{ … }
static u64 mtrr_chunk_size __initdata = …;
static int __init parse_mtrr_chunk_size_opt(char *p)
{ … }
early_param(…);
static u64 mtrr_gran_size __initdata;
static int __init parse_mtrr_gran_size_opt(char *p)
{ … }
early_param(…);
static unsigned long nr_mtrr_spare_reg __initdata = …;
static int __init parse_mtrr_spare_reg(char *arg)
{ … }
early_param(…);
static int __init
x86_setup_var_mtrrs(struct range *range, int nr_range,
u64 chunk_size, u64 gran_size)
{ … }
struct mtrr_cleanup_result { … };
#define NUM_RESULT …
#define PSHIFT …
static struct mtrr_cleanup_result __initdata result[NUM_RESULT];
static unsigned long __initdata min_loss_pfn[RANGE_NUM];
static void __init print_out_mtrr_range_state(void)
{ … }
static int __init mtrr_need_cleanup(void)
{ … }
static unsigned long __initdata range_sums;
static void __init
mtrr_calc_range_state(u64 chunk_size, u64 gran_size,
unsigned long x_remove_base,
unsigned long x_remove_size, int i)
{ … }
static void __init mtrr_print_out_one_result(int i)
{ … }
static int __init mtrr_search_optimal_index(void)
{ … }
int __init mtrr_cleanup(void)
{ … }
#else
int __init mtrr_cleanup(void)
{
return 0;
}
#endif
static int disable_mtrr_trim;
static int __init disable_mtrr_trim_setup(char *str)
{ … }
early_param(…);
#define Tom2Enabled …
#define Tom2ForceMemTypeWB …
int __init amd_special_default_mtrr(void)
{ … }
static u64 __init
real_trim_memory(unsigned long start_pfn, unsigned long limit_pfn)
{ … }
int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
{ … }