summaryrefslogtreecommitdiff
path: root/sys/src/9/pc/devarch.c
diff options
context:
space:
mode:
authoraiju <devnull@localhost>2018-07-11 14:50:22 +0100
committeraiju <devnull@localhost>2018-07-11 14:50:22 +0100
commit3a77c01f43821dcc4f7cae54aff89bb20f2d95a5 (patch)
tree2934609fdeebaddaf8f5d28601b488ba5a3d8d74 /sys/src/9/pc/devarch.c
parent911df94e5d712d7e2eebb4a3997efce17e2599f2 (diff)
pc kernel: get rid of ugly and partially broken cpuid macros
Diffstat (limited to 'sys/src/9/pc/devarch.c')
-rw-r--r--sys/src/9/pc/devarch.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/sys/src/9/pc/devarch.c b/sys/src/9/pc/devarch.c
index 9ea14d06d..1808849dc 100644
--- a/sys/src/9/pc/devarch.c
+++ b/sys/src/9/pc/devarch.c
@@ -753,6 +753,17 @@ cpuidentify(void)
m->cpuidax = regs[0];
m->cpuidcx = regs[2];
m->cpuiddx = regs[3];
+
+ m->cpuidfamily = m->cpuidax >> 8 & 0xf;
+ m->cpuidmodel = m->cpuidax >> 4 & 0xf;
+ m->cpuidstepping = m->cpuidax & 0xf;
+ switch(m->cpuidfamily){
+ case 6:
+ m->cpuidmodel += m->cpuidax >> 16 & 0xf;
+ /* wet floor */
+ case 15:
+ m->cpuidfamily += m->cpuidax >> 20 & 0xff;
+ }
if(strncmp(m->cpuidid, "AuthenticAMD", 12) == 0 ||
strncmp(m->cpuidid, "Geode by NSC", 12) == 0)
@@ -764,8 +775,8 @@ cpuidentify(void)
else
tab = x86intel;
- family = X86FAMILY(m->cpuidax);
- model = X86MODEL(m->cpuidax);
+ family = m->cpuidfamily;
+ model = m->cpuidmodel;
for(t=tab; t->name; t++)
if((t->family == family && t->model == model)
|| (t->family == family && t->model == -1)
@@ -994,7 +1005,7 @@ archctlwrite(Chan*, void *a, long n, vlong)
if(strcmp(cb->f[1], "mb386") == 0)
coherence = mb386;
else if(strcmp(cb->f[1], "mb586") == 0){
- if(X86FAMILY(m->cpuidax) < 5)
+ if(m->cpuidfamily < 5)
error("invalid coherence ctl on this cpu family");
coherence = mb586;
}else if(strcmp(cb->f[1], "mfence") == 0){
@@ -1093,13 +1104,13 @@ archinit(void)
* We get another chance to set it in mpinit() for a
* multiprocessor.
*/
- if(X86FAMILY(m->cpuidax) == 3)
+ if(m->cpuidfamily == 3)
conf.copymode = 1;
- if(X86FAMILY(m->cpuidax) >= 4)
+ if(m->cpuidfamily >= 4)
cmpswap = cmpswap486;
- if(X86FAMILY(m->cpuidax) >= 5)
+ if(m->cpuidfamily >= 5)
coherence = mb586;
if(m->cpuiddx & Sse2)