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
);
28 * Disable and flush caches. Note that wbinvd flushes the TLBs
31 cr0
= read_cr0() | X86_CR0_CD
;
38 rdmsr(MTRRdefType_MSR
, ctxt
->deftype_lo
, ctxt
->deftype_hi
);
40 /* Cyrix ARRs - everything else were excluded at the top */
41 ctxt
->ccr3
= getCx86(CX86_CCR3
);
45 void set_mtrr_cache_disable(struct set_mtrr_context
*ctxt
)
48 /* Disable MTRRs, and set the default type to uncached */
49 mtrr_wrmsr(MTRRdefType_MSR
, ctxt
->deftype_lo
& 0xf300UL
,
51 else if (is_cpu(CYRIX
))
52 /* Cyrix ARRs - everything else were excluded at the top */
53 setCx86(CX86_CCR3
, (ctxt
->ccr3
& 0x0f) | 0x10);
56 /* Restore the processor after a set_mtrr_prepare */
57 void set_mtrr_done(struct set_mtrr_context
*ctxt
)
59 if (use_intel() || is_cpu(CYRIX
)) {
61 /* Flush caches and TLBs */
64 /* Restore MTRRdefType */
66 /* Intel (P6) standard MTRRs */
67 mtrr_wrmsr(MTRRdefType_MSR
, ctxt
->deftype_lo
, ctxt
->deftype_hi
);
69 /* Cyrix ARRs - everything else was excluded at the top */
70 setCx86(CX86_CCR3
, ctxt
->ccr3
);
73 write_cr0(read_cr0() & 0xbfffffff);
75 /* Restore value of CR4 */
77 write_cr4(ctxt
->cr4val
);
79 /* Re-enable interrupts locally (if enabled previously) */
80 local_irq_restore(ctxt
->flags
);