diff -Nur freebios/src/cpu/p6/mtrr.c freebios.mtrr/src/cpu/p6/mtrr.c --- freebios/src/cpu/p6/mtrr.c 2002-07-02 15:13:09.000000000 +0800 +++ freebios.mtrr/src/cpu/p6/mtrr.c 2002-08-13 15:36:12.000000000 +0800 @@ -205,6 +205,18 @@ unsigned int i; unsigned int fixed_msr = NUM_FIXED_RANGES >> 3; unsigned long low, high; + unsigned int tmp; + + // it is recommended that we disable and enable cache when we + // do this. + /* Disable cache */ + /* Write back the cache and flush TLB */ + asm volatile ("movl %%cr0, %0\n\t" + "orl $0x40000000, %0\n\t" + "wbinvd\n\t" + "movl %0, %%cr0\n\t" + "wbinvd\n\t":"=r" (tmp)::"memory"); + low = high = 0; /* Shut up gcc */ for(i = first; i < last; i++) { /* When I switch to a new msr read it in */ @@ -228,6 +240,11 @@ if (fixed_msr < (NUM_FIXED_RANGES >> 3)) { wrmsr(mtrr_msr[fixed_msr], low, high); } + + // turn cache back on. + asm volatile ("movl %%cr0, %0\n\t" + "andl $0x9fffffff, %0\n\t" + "movl %0, %%cr0\n\t":"=r" (tmp)::"memory"); } static unsigned fixed_mtrr_index(unsigned long addrk)