perf_event: x86: Allocate the fake_cpuc
[linux-2.6/libata-dev.git] / arch / x86 / kernel / cpu / mtrr / state.c
blobdfc80b4e6b0db79d8499600a486f926ad36afb5f
1 #include <linux/init.h>
2 #include <linux/io.h>
3 #include <linux/mm.h>
5 #include <asm/processor-cyrix.h>
6 #include <asm/processor-flags.h>
7 #include <asm/mtrr.h>
8 #include <asm/msr.h>
10 #include "mtrr.h"
12 /* Put the processor into a state where MTRRs can be safely set */
13 void set_mtrr_prepare_save(struct set_mtrr_context *ctxt)
15 unsigned int cr0;
17 /* Disable interrupts locally */
18 local_irq_save(ctxt->flags);
20 if (use_intel() || is_cpu(CYRIX)) {
22 /* Save value of CR4 and clear Page Global Enable (bit 7) */
23 if (cpu_has_pge) {
24 ctxt->cr4val = read_cr4();
25 write_cr4(ctxt->cr4val & ~X86_CR4_PGE);
29 * Disable and flush caches. Note that wbinvd flushes the TLBs
30 * as a side-effect
32 cr0 = read_cr0() | X86_CR0_CD;
33 wbinvd();
34 write_cr0(cr0);
35 wbinvd();
37 if (use_intel()) {
38 /* Save MTRR state */
39 rdmsr(MSR_MTRRdefType, ctxt->deftype_lo, ctxt->deftype_hi);
40 } else {
42 * Cyrix ARRs -
43 * everything else were excluded at the top
45 ctxt->ccr3 = getCx86(CX86_CCR3);
50 void set_mtrr_cache_disable(struct set_mtrr_context *ctxt)
52 if (use_intel()) {
53 /* Disable MTRRs, and set the default type to uncached */
54 mtrr_wrmsr(MSR_MTRRdefType, ctxt->deftype_lo & 0xf300UL,
55 ctxt->deftype_hi);
56 } else {
57 if (is_cpu(CYRIX)) {
58 /* Cyrix ARRs - everything else were excluded at the top */
59 setCx86(CX86_CCR3, (ctxt->ccr3 & 0x0f) | 0x10);
64 /* Restore the processor after a set_mtrr_prepare */
65 void set_mtrr_done(struct set_mtrr_context *ctxt)
67 if (use_intel() || is_cpu(CYRIX)) {
69 /* Flush caches and TLBs */
70 wbinvd();
72 /* Restore MTRRdefType */
73 if (use_intel()) {
74 /* Intel (P6) standard MTRRs */
75 mtrr_wrmsr(MSR_MTRRdefType, ctxt->deftype_lo,
76 ctxt->deftype_hi);
77 } else {
79 * Cyrix ARRs -
80 * everything else was excluded at the top
82 setCx86(CX86_CCR3, ctxt->ccr3);
85 /* Enable caches */
86 write_cr0(read_cr0() & 0xbfffffff);
88 /* Restore value of CR4 */
89 if (cpu_has_pge)
90 write_cr4(ctxt->cr4val);
92 /* Re-enable interrupts locally (if enabled previously) */
93 local_irq_restore(ctxt->flags);