Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

mtrr.c File Reference

#include <linux/types.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/tty.h>
#include <linux/timer.h>
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/wait.h>
#include <linux/string.h>
#include <linux/malloc.h>
#include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/ctype.h>
#include <linux/proc_fs.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <asm/mtrr.h>
#include <linux/init.h>
#include <linux/smp.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/processor.h>
#include <asm/system.h>
#include <asm/pgtable.h>
#include <asm/segment.h>
#include <asm/bitops.h>
#include <asm/atomic.h>
#include <asm/msr.h>
#include <asm/hardirq.h>
#include "irq.h"

Include dependency graph for mtrr.c:

Go to the source code of this file.

Defines

#define MTRR_NEED_STRINGS
#define MTRR_VERSION   "1.35a (19990819)"
#define TRUE   1
#define FALSE   0
#define MTRRcap_MSR   0x0fe
#define MTRRdefType_MSR   0x2ff
#define MTRRphysBase_MSR(reg)   (0x200 + 2 * (reg))
#define MTRRphysMask_MSR(reg)   (0x200 + 2 * (reg) + 1)
#define NUM_FIXED_RANGES   88
#define MTRRfix64K_00000_MSR   0x250
#define MTRRfix16K_80000_MSR   0x258
#define MTRRfix16K_A0000_MSR   0x259
#define MTRRfix4K_C0000_MSR   0x268
#define MTRRfix4K_C8000_MSR   0x269
#define MTRRfix4K_D0000_MSR   0x26a
#define MTRRfix4K_D8000_MSR   0x26b
#define MTRRfix4K_E0000_MSR   0x26c
#define MTRRfix4K_E8000_MSR   0x26d
#define MTRRfix4K_F0000_MSR   0x26e
#define MTRRfix4K_F8000_MSR   0x26f
#define LINE_SIZE   80
#define JIFFIE_TIMEOUT   100
#define set_mtrr(reg, base, size, type)
#define spin_lock_reschedule(lock)   while (!spin_trylock(lock)) schedule ();
#define compute_ascii()   while (0)

Typedefs

typedef u8 mtrr_type

Functions

static spinlock_t main_lock __attribute ((unused))
static void set_mtrr_prepare (struct set_mtrr_context *ctxt)
static void set_mtrr_done (struct set_mtrr_context *ctxt)
static unsigned int get_num_var_ranges (void)
static int have_wrcomb (void)
static void intel_get_mtrr (unsigned int reg, unsigned long *base, unsigned long *size, mtrr_type *type)
static void cyrix_get_arr (unsigned int reg, unsigned long *base, unsigned long *size, mtrr_type *type)
static void amd_get_mtrr (unsigned int reg, unsigned long *base, unsigned long *size, mtrr_type *type)
static void centaur_get_mcr (unsigned int reg, unsigned long *base, unsigned long *size, mtrr_type *type)
static void intel_set_mtrr_up (unsigned int reg, unsigned long base, unsigned long size, mtrr_type type, int do_safe)
static void cyrix_set_arr_up (unsigned int reg, unsigned long base, unsigned long size, mtrr_type type, int do_safe)
static void amd_set_mtrr_up (unsigned int reg, unsigned long base, unsigned long size, mtrr_type type, int do_safe)
static void centaur_set_mcr_up (unsigned int reg, unsigned long base, unsigned long size, mtrr_type type, int do_safe)
static char * attrib_to_str (int x)
static void init_table (void)
static int generic_get_free_region (unsigned long base, unsigned long size)
static int cyrix_get_free_region (unsigned long base, unsigned long size)
int mtrr_add (unsigned long base, unsigned long size, unsigned int type, char increment)
int mtrr_del (int reg, unsigned long base, unsigned long size)
 EXPORT_SYMBOL (mtrr_add)
 EXPORT_SYMBOL (mtrr_del)
 __initfunc (static void cyrix_arr_init(void))
 __initfunc (int mtrr_init(void))

Variables

static unsigned int * usage_table = NULL
static struct CENTAUR_MCR_CTXcentaur_ctx
static void(* get_mtrr )(unsigned int reg, unsigned long *base, unsigned long *size, mtrr_type *type) = NULL
static void(* set_mtrr_up )(unsigned int reg, unsigned long base, unsigned long size, mtrr_type type, int do_safe) = NULL
static int(* get_free_region )(unsigned long base, unsigned long size) = generic_get_free_region


Define Documentation

 
#define compute_ascii  )     while (0)
 

Definition at line 300 of file mtrr.c.

Referenced by init_table(), mtrr_add(), and mtrr_del().

#define FALSE   0
 

Definition at line 256 of file mtrr.c.

#define JIFFIE_TIMEOUT   100
 

Definition at line 288 of file mtrr.c.

Referenced by smp_call_function().

#define LINE_SIZE   80
 

Definition at line 287 of file mtrr.c.

Referenced by init_table().

#define MTRR_NEED_STRINGS
 

Definition at line 235 of file mtrr.c.

#define MTRR_VERSION   "1.35a (19990819)"
 

Definition at line 253 of file mtrr.c.

#define MTRRcap_MSR   0x0fe
 

Definition at line 258 of file mtrr.c.

Referenced by get_num_var_ranges(), and have_wrcomb().

#define MTRRdefType_MSR   0x2ff
 

Definition at line 259 of file mtrr.c.

Referenced by set_mtrr_done(), and set_mtrr_prepare().

#define MTRRfix16K_80000_MSR   0x258
 

Definition at line 266 of file mtrr.c.

#define MTRRfix16K_A0000_MSR   0x259
 

Definition at line 267 of file mtrr.c.

#define MTRRfix4K_C0000_MSR   0x268
 

Definition at line 268 of file mtrr.c.

#define MTRRfix4K_C8000_MSR   0x269
 

Definition at line 269 of file mtrr.c.

#define MTRRfix4K_D0000_MSR   0x26a
 

Definition at line 270 of file mtrr.c.

#define MTRRfix4K_D8000_MSR   0x26b
 

Definition at line 271 of file mtrr.c.

#define MTRRfix4K_E0000_MSR   0x26c
 

Definition at line 272 of file mtrr.c.

#define MTRRfix4K_E8000_MSR   0x26d
 

Definition at line 273 of file mtrr.c.

#define MTRRfix4K_F0000_MSR   0x26e
 

Definition at line 274 of file mtrr.c.

#define MTRRfix4K_F8000_MSR   0x26f
 

Definition at line 275 of file mtrr.c.

#define MTRRfix64K_00000_MSR   0x250
 

Definition at line 265 of file mtrr.c.

#define MTRRphysBase_MSR reg   )     (0x200 + 2 * (reg))
 

Definition at line 261 of file mtrr.c.

Referenced by intel_get_mtrr(), and intel_set_mtrr_up().

#define MTRRphysMask_MSR reg   )     (0x200 + 2 * (reg) + 1)
 

Definition at line 262 of file mtrr.c.

Referenced by intel_get_mtrr(), and intel_set_mtrr_up().

#define NUM_FIXED_RANGES   88
 

Definition at line 264 of file mtrr.c.

#define set_mtrr reg,
base,
size,
type   ) 
 

Value:

(*set_mtrr_up) (reg, base, size, type, \
                                                       TRUE)

Definition at line 293 of file mtrr.c.

Referenced by mtrr_add(), and mtrr_del().

#define spin_lock_reschedule lock   )     while (!spin_trylock(lock)) schedule ();
 

Definition at line 297 of file mtrr.c.

Referenced by mtrr_add(), and mtrr_del().

#define TRUE   1
 

Definition at line 255 of file mtrr.c.


Typedef Documentation

typedef u8 mtrr_type
 

Definition at line 285 of file mtrr.c.


Function Documentation

static spinlock_t main_lock __attribute (unused)   )  [static]
 

__initfunc int   mtrr_init(void)  ) 
 

Definition at line 1870 of file mtrr.c.

References boot_cpu_data, init_table(), proc_register(), proc_root, cpuinfo_x86::x86, cpuinfo_x86::x86_capability, X86_FEATURE_MTRR, cpuinfo_x86::x86_vendor, X86_VENDOR_AMD, X86_VENDOR_CENTAUR, X86_VENDOR_CYRIX, and X86_VENDOR_INTEL.

Here is the call graph for this function:

__initfunc static void   cyrix_arr_init(void)  ) 
 

Definition at line 1625 of file mtrr.c.

References set_mtrr_context::ccr3, CX86_CCR0, CX86_CCR1, CX86_CCR2, CX86_CCR4, CX86_CCR5, CX86_CCR6, cyrix_get_arr(), getCx86, printk, set_mtrr_done(), set_mtrr_prepare(), setCx86, x02, and x20.

Here is the call graph for this function:

static void amd_get_mtrr unsigned int  reg,
unsigned long base,
unsigned long size,
mtrr_type type
[static]
 

Definition at line 566 of file mtrr.c.

References high(), MTRR_TYPE_UNCACHABLE, MTRR_TYPE_WRCOMB, and rdmsr.

Here is the call graph for this function:

static void amd_set_mtrr_up unsigned int  reg,
unsigned long  base,
unsigned long  size,
mtrr_type  type,
int  do_safe
[static]
 

Definition at line 700 of file mtrr.c.

References __asm__(), high(), rdmsr, set_mtrr_done(), set_mtrr_prepare(), u32, and wrmsr.

Here is the call graph for this function:

static char* attrib_to_str int  x  )  [static]
 

Definition at line 1018 of file mtrr.c.

Referenced by mtrr_add().

static void centaur_get_mcr unsigned int  reg,
unsigned long base,
unsigned long size,
mtrr_type type
[static]
 

Definition at line 613 of file mtrr.c.

References centaur_ctx, i, CENTAUR_MCR_CTX::mcr, MTRR_NUM_TYPES, CENTAUR_MCR_CTX::type_bits, and u32.

static void centaur_set_mcr_up unsigned int  reg,
unsigned long  base,
unsigned long  size,
mtrr_type  type,
int  do_safe
[static]
 

Definition at line 744 of file mtrr.c.

References centaur_ctx, high(), CENTAUR_MCR_CTX::mcr, set_mtrr_done(), set_mtrr_prepare(), CENTAUR_MCR_CTX::type_bits, and wrmsr.

Here is the call graph for this function:

static void cyrix_get_arr unsigned int  reg,
unsigned long base,
unsigned long size,
mtrr_type type
[static]
 

Definition at line 514 of file mtrr.c.

References __cli, __restore_flags, __save_flags, CX86_ARR_BASE, CX86_CCR3, CX86_RCR_BASE, getCx86, MTRR_TYPE_UNCACHABLE, MTRR_TYPE_WRBACK, MTRR_TYPE_WRCOMB, MTRR_TYPE_WRTHROUGH, setCx86, shift, x0f, and x10.

Referenced by __initfunc(), and cyrix_get_free_region().

static int cyrix_get_free_region unsigned long  base,
unsigned long  size
[static]
 

Definition at line 1066 of file mtrr.c.

References cyrix_get_arr(), ENOSPC, and x40000.

Here is the call graph for this function:

static void cyrix_set_arr_up unsigned int  reg,
unsigned long  base,
unsigned long  size,
mtrr_type  type,
int  do_safe
[static]
 

Definition at line 663 of file mtrr.c.

References CX86_ARR_BASE, CX86_RCR_BASE, MTRR_TYPE_UNCACHABLE, MTRR_TYPE_WRCOMB, MTRR_TYPE_WRTHROUGH, set_mtrr_done(), set_mtrr_prepare(), and setCx86.

Here is the call graph for this function:

EXPORT_SYMBOL mtrr_del   ) 
 

EXPORT_SYMBOL mtrr_add   ) 
 

static int generic_get_free_region unsigned long  base,
unsigned long  size
[static]
 

Definition at line 1046 of file mtrr.c.

References ENOSPC, get_num_var_ranges(), and max.

Here is the call graph for this function:

static unsigned int get_num_var_ranges void   )  [static]
 

Definition at line 428 of file mtrr.c.

References boot_cpu_data, dummy, MTRRcap_MSR, rdmsr, cpuinfo_x86::x86, cpuinfo_x86::x86_vendor, X86_VENDOR_AMD, X86_VENDOR_CENTAUR, X86_VENDOR_CYRIX, X86_VENDOR_INTEL, and xff.

Referenced by generic_get_free_region(), init_table(), mtrr_add(), and mtrr_del().

static int have_wrcomb void   )  [static]
 

Definition at line 460 of file mtrr.c.

References boot_cpu_data, dummy, MTRRcap_MSR, rdmsr, cpuinfo_x86::x86, cpuinfo_x86::x86_vendor, X86_VENDOR_AMD, X86_VENDOR_CENTAUR, X86_VENDOR_CYRIX, and X86_VENDOR_INTEL.

Referenced by mtrr_add().

static void init_table void   )  [static]
 

Definition at line 1023 of file mtrr.c.

References compute_ascii, get_num_var_ranges(), kmalloc(), LINE_SIZE, max, NULL, printk, and usage_table.

Referenced by __initfunc().

Here is the call graph for this function:

static void intel_get_mtrr unsigned int  reg,
unsigned long base,
unsigned long size,
mtrr_type type
[static]
 

Definition at line 484 of file mtrr.c.

References dummy, MTRRphysBase_MSR, MTRRphysMask_MSR, rdmsr, and x800.

static void intel_set_mtrr_up unsigned int  reg,
unsigned long  base,
unsigned long  size,
mtrr_type  type,
int  do_safe
[static]
 

Definition at line 634 of file mtrr.c.

References MTRRphysBase_MSR, MTRRphysMask_MSR, set_mtrr_done(), set_mtrr_prepare(), wrmsr, and x800.

Here is the call graph for this function:

int mtrr_add unsigned long  base,
unsigned long  size,
unsigned int  type,
char  increment
 

Definition at line 1098 of file mtrr.c.

References attrib_to_str(), boot_cpu_data, centaur_ctx, compute_ascii, EINVAL, ENODEV, ENOSYS, get_num_var_ranges(), have_wrcomb(), last, max, MTRR_NUM_TYPES, MTRR_TYPE_UNCACHABLE, MTRR_TYPE_WRCOMB, printk, set_mtrr, spin_lock_reschedule, spin_unlock, CENTAUR_MCR_CTX::type_bits, usage_table, x100000, cpuinfo_x86::x86, cpuinfo_x86::x86_capability, X86_FEATURE_MTRR, cpuinfo_x86::x86_mask, cpuinfo_x86::x86_model, cpuinfo_x86::x86_vendor, X86_VENDOR_AMD, X86_VENDOR_CENTAUR, X86_VENDOR_CYRIX, X86_VENDOR_INTEL, and xfff.

Referenced by __initfunc(), drm_addmap(), i2o_pci_install(), mga_init(), and r128_init().

Here is the call graph for this function:

int mtrr_del int  reg,
unsigned long  base,
unsigned long  size
 

Definition at line 1237 of file mtrr.c.

References boot_cpu_data, compute_ascii, EINVAL, ENODEV, get_num_var_ranges(), max, printk, set_mtrr, spin_lock_reschedule, spin_unlock, usage_table, cpuinfo_x86::x86_capability, and X86_FEATURE_MTRR.

Referenced by gamma_takedown(), i2o_pci_dispose(), i2o_pci_install(), i810_takedown(), mga_cleanup(), mga_takedown(), r128_takedown(), and tdfx_takedown().

Here is the call graph for this function:

static void set_mtrr_done struct set_mtrr_context ctxt  )  [static]
 

Definition at line 379 of file mtrr.c.

References __restore_flags, boot_cpu_data, set_mtrr_context::ccr3, set_mtrr_context::cr4val, CX86_CCR3, set_mtrr_context::deftype_hi, set_mtrr_context::deftype_lo, set_mtrr_context::flags, MTRRdefType_MSR, setCx86, tmp, wrmsr, cpuinfo_x86::x86, cpuinfo_x86::x86_capability, X86_FEATURE_PGE, cpuinfo_x86::x86_vendor, X86_VENDOR_AMD, X86_VENDOR_CENTAUR, X86_VENDOR_CYRIX, and X86_VENDOR_INTEL.

Referenced by __initfunc(), amd_set_mtrr_up(), centaur_set_mcr_up(), cyrix_set_arr_up(), and intel_set_mtrr_up().

static void set_mtrr_prepare struct set_mtrr_context ctxt  )  [static]
 

Definition at line 327 of file mtrr.c.

References __cli, __save_flags, boot_cpu_data, set_mtrr_context::ccr3, set_mtrr_context::cr4val, CX86_CCR3, set_mtrr_context::deftype_hi, set_mtrr_context::deftype_lo, set_mtrr_context::flags, getCx86, MTRRdefType_MSR, rdmsr, setCx86, tmp, wrmsr, x0f, x10, cpuinfo_x86::x86, cpuinfo_x86::x86_capability, X86_FEATURE_PGE, cpuinfo_x86::x86_vendor, X86_VENDOR_AMD, X86_VENDOR_CENTAUR, X86_VENDOR_CYRIX, and X86_VENDOR_INTEL.

Referenced by __initfunc(), amd_set_mtrr_up(), centaur_set_mcr_up(), cyrix_set_arr_up(), and intel_set_mtrr_up().


Variable Documentation

struct CENTAUR_MCR_CTX * centaur_ctx [static]
 

Referenced by centaur_get_mcr(), centaur_set_mcr_up(), and mtrr_add().

int(* get_free_region)(unsigned long base, unsigned long size) = generic_get_free_region [static]
 

Definition at line 1095 of file mtrr.c.

void(* get_mtrr)(unsigned int reg, unsigned long *base, unsigned long *size, mtrr_type *type) = NULL [static]
 

Definition at line 631 of file mtrr.c.

void(* set_mtrr_up)(unsigned int reg, unsigned long base, unsigned long size, mtrr_type type, int do_safe) = NULL [static]
 

Definition at line 771 of file mtrr.c.

unsigned int* usage_table = NULL [static]
 

Definition at line 307 of file mtrr.c.

Referenced by init_table(), mtrr_add(), and mtrr_del().