/* * Power of two, at least 4K on ARR0-ARR6, 256K on ARR7 * Note: shift==0xf means 4G, this is unsupported.
*/ if (shift)
*size = (reg < 7 ? 0x1UL : 0x40UL) << (shift - 1); else
*size = 0;
/* Bit 0 is Cache Enable on ARR7, Cache Disable on ARR0-ARR6 */ if (reg < 7) { switch (rcr) { case 1:
*type = MTRR_TYPE_UNCACHABLE; break; case 8:
*type = MTRR_TYPE_WRBACK; break; case 9:
*type = MTRR_TYPE_WRCOMB; break; case 24: default:
*type = MTRR_TYPE_WRTHROUGH; break;
}
} else { switch (rcr) { case 0:
*type = MTRR_TYPE_UNCACHABLE; break; case 8:
*type = MTRR_TYPE_WRCOMB; break; case 9:
*type = MTRR_TYPE_WRBACK; break; case 25: default:
*type = MTRR_TYPE_WRTHROUGH; break;
}
}
}
/* * cyrix_get_free_region - get a free ARR. * * @base: the starting (base) address of the region. * @size: the size (in bytes) of the region. * * Returns: the index of the region on success, else -1 on error.
*/ staticint
cyrix_get_free_region(unsignedlong base, unsignedlong size, int replace_reg)
{ unsignedlong lbase, lsize;
mtrr_type ltype; int i;
switch (replace_reg) { case 7: if (size < 0x40) break;
fallthrough; case 6: case 5: case 4: return replace_reg; case 3: case 2: case 1: case 0: return replace_reg;
} /* If we are to set up a region >32M then look at ARR7 immediately */ if (size > 0x2000) {
cyrix_get_arr(7, &lbase, &lsize, <ype); if (lsize == 0) return 7; /* Else try ARR0-ARR6 first */
} else { for (i = 0; i < 7; i++) {
cyrix_get_arr(i, &lbase, &lsize, <ype); if (lsize == 0) return i;
} /* * ARR0-ARR6 isn't free * try ARR7 but its size must be at least 256K
*/
cyrix_get_arr(i, &lbase, &lsize, <ype); if ((lsize == 0) && (size >= 0x40)) return i;
} return -ENOSPC;
}
static u32 cr4, ccr3;
staticvoid prepare_set(void)
{
u32 cr0;
/* Save value of CR4 and clear Page Global Enable (bit 7) */ if (boot_cpu_has(X86_FEATURE_PGE)) {
cr4 = __read_cr4();
__write_cr4(cr4 & ~X86_CR4_PGE);
}
/* * Disable and flush caches. * Note that wbinvd flushes the TLBs as a side-effect
*/
cr0 = read_cr0() | X86_CR0_CD;
wbinvd();
write_cr0(cr0);
wbinvd();
/* Cyrix ARRs - everything else was excluded at the top */
ccr3 = getCx86(CX86_CCR3);
/* Cyrix ARRs - everything else was excluded at the top */
setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10);
}
staticvoid post_set(void)
{ /* Flush caches and TLBs */
wbinvd();
/* Cyrix ARRs - everything else was excluded at the top */
setCx86(CX86_CCR3, ccr3);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.