diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-08 16:58:41 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-08 16:58:41 +0100 |
commit | 8efbd243e1934288fe6a57d3f168d370f6c04493 (patch) | |
tree | efd8fb0e87482cb661864fd8422fa9654b2b3173 | |
parent | b2ffb6ccc5a5a4fcc996cc5db14ea7e2da13a411 (diff) | |
download | plan9front-8efbd243e1934288fe6a57d3f168d370f6c04493.tar.xz |
pc, pc64: cleanup cpuidentify() and some comments
-rw-r--r-- | sys/src/9/pc/devarch.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/sys/src/9/pc/devarch.c b/sys/src/9/pc/devarch.c index bd72cd07f..4058808f5 100644 --- a/sys/src/9/pc/devarch.c +++ b/sys/src/9/pc/devarch.c @@ -491,16 +491,19 @@ cpuidprint(void) * (if so turn it on) * - whether or not it supports the page global flag * (if so turn it on) + * - detect PAT feature and add write-combining entry + * - detect MTRR support and synchronize state with cpu0 + * - detect NX support and enable it for AMD64 + * - detect watchpoint support + * - detect FPU features and enable the FPU */ int cpuidentify(void) { - char *p; - int family, model, nomce; + int family, model; X86type *t, *tab; - uintptr cr4; ulong regs[4]; - vlong mca, mct, pat; + uintptr cr4; cpuid(Highstdfunc, 0, regs); memmove(m->cpuidid, ®s[1], BY2WD); /* bx */ @@ -567,14 +570,13 @@ cpuidentify(void) * If machine check was enabled clear out any lingering status. */ if(m->cpuiddx & (Pge|Mce|Pse)){ + vlong mca, mct; + cr4 = getcr4(); if(m->cpuiddx & Pse) cr4 |= 0x10; /* page size extensions */ - if(p = getconf("*nomce")) - nomce = strtoul(p, 0, 0); - else - nomce = 0; - if((m->cpuiddx & Mce) != 0 && !nomce){ + + if((m->cpuiddx & Mce) != 0 && getconf("*nomce") == nil){ if((m->cpuiddx & Mca) != 0){ vlong cap; int bank; @@ -626,7 +628,6 @@ cpuidentify(void) cr4 |= 0x80; /* page global enable bit */ m->havepge = 1; } - putcr4(cr4); if((m->cpuiddx & (Mca|Mce)) == Mce) @@ -635,10 +636,14 @@ cpuidentify(void) #ifdef PATWC /* IA32_PAT write combining */ - if((m->cpuiddx & Pat) != 0 && rdmsr(0x277, &pat) != -1){ - pat &= ~(255LL<<(PATWC*8)); - pat |= 1LL<<(PATWC*8); /* WC */ - wrmsr(0x277, pat); + if((m->cpuiddx & Pat) != 0){ + vlong pat; + + if(rdmsr(0x277, &pat) != -1){ + pat &= ~(255LL<<(PATWC*8)); + pat |= 1LL<<(PATWC*8); /* WC */ + wrmsr(0x277, pat); + } } #endif |