2 #include <linux/init.h>
6 #include <asm/processor-cyrix.h>
7 #include <asm/processor-flags.h>
11 /* Put the processor into a state where MTRRs can be safely set */
12 void set_mtrr_prepare_save(struct set_mtrr_context
*ctxt
)
16 /* Disable interrupts locally */
17 local_irq_save(ctxt
->flags
);
19 if (use_intel() || is_cpu(CYRIX
)) {
21 /* Save value of CR4 and clear Page Global Enable (bit 7) */
23 ctxt
->cr4val
= read_cr4();
24 write_cr4(ctxt
->cr4val
& ~X86_CR4_PGE
);
27 /* Disable and flush caches. Note that wbinvd flushes the TLBs as
29 cr0
= read_cr0() | X86_CR0_CD
;
36 rdmsr(MTRRdefType_MSR
, ctxt
->deftype_lo
, ctxt
->deftype_hi
);
38 /* Cyrix ARRs - everything else were excluded at the top */
39 ctxt
->ccr3
= getCx86(CX86_CCR3
);
43 void set_mtrr_cache_disable(struct set_mtrr_context
*ctxt
)
46 /* Disable MTRRs, and set the default type to uncached */
47 mtrr_wrmsr(MTRRdefType_MSR
, ctxt
->deftype_lo
& 0xf300UL
,
49 else if (is_cpu(CYRIX
))
50 /* Cyrix ARRs - everything else were excluded at the top */
51 setCx86(CX86_CCR3
, (ctxt
->ccr3
& 0x0f) | 0x10);
54 /* Restore the processor after a set_mtrr_prepare */
55 void set_mtrr_done(struct set_mtrr_context
*ctxt
)
57 if (use_intel() || is_cpu(CYRIX
)) {
59 /* Flush caches and TLBs */
62 /* Restore MTRRdefType */
64 /* Intel (P6) standard MTRRs */
65 mtrr_wrmsr(MTRRdefType_MSR
, ctxt
->deftype_lo
, ctxt
->deftype_hi
);
67 /* Cyrix ARRs - everything else was excluded at the top */
68 setCx86(CX86_CCR3
, ctxt
->ccr3
);
71 write_cr0(read_cr0() & 0xbfffffff);
73 /* Restore value of CR4 */
75 write_cr4(ctxt
->cr4val
);
77 /* Re-enable interrupts locally (if enabled previously) */
78 local_irq_restore(ctxt
->flags
);