2 #include "../port/lib.h"
13 if(m->cpuiddx & Acpif)
14 if(strcmp(m->cpuidid, "GenuineIntel") == 0){
22 cputemprd0(Chan*, void *a, long n, vlong offset)
31 if((regs[0] & 1) == 0)
32 return readstr(offset, a, n, "-1±-1 unsupported\n");
35 * magic undocumented msr. tj(max) is 100 or 85.
38 d = X86MODEL(m->cpuidax);
39 d |= (m->cpuidax>>12) & 0xf0;
40 if((d == 0xf && (m->cpuidax & 0xf)>1) || d == 0xe){
56 if((msr & 0x30) == 0x30)
58 snprint(buf, sizeof buf, "%ld±%uld%s\n", t, res, s);
59 return readstr(offset, a, n, buf);
63 intelcputemprd(Chan *c, void *va, long n, vlong offset)
72 for(i = 0; i < conf.nmach; i++){
75 r = cputemprd0(c, a, n, offset);
91 amd0ftemprd(Chan*, void *a, long n, vlong offset)
97 p = pcimatch(0, 0x1022, 0x1103);
99 return readstr(offset, a, n, "-1±-1 unsupported\n");
104 e = buf + sizeof buf;
105 for(j = 0; j < max; j++){
106 pcicfgw32(p, 0xe4, pcicfgr32(p, 0xe4) & ~4 | j<<2);
107 i = pcicfgr32(p, 0xe4);
108 if(X86STEPPING(m->cpuidax) == 2)
116 s = seprint(s, e, "%ld±%uld%s\n", t, 1l, "");
118 return readstr(offset, a, n, buf);
122 amd10temprd(Chan*, void *a, long n, vlong offset)
124 char *s, *e, *r, *buf;
125 long i, t, c, nb, cores[MAXMACH];
129 for(p = 0; p = pcimatch(p, 0x1022, 0x1203); ){
130 cores[nb++] = 1 + ((pcicfgr32(p, 0xe8) & 0x3000)>>12);
131 if(nb == nelem(cores))
135 return readstr(offset, a, n, "-1±-1 unsupported\n");
136 buf = smalloc(MAXMACH*4*32);
138 e = buf + MAXMACH*4*32;
141 for(p = 0; p = pcimatch(p, 0x1022, 0x1203); nb++){
142 i = pcicfgr32(p, 0xa4) & 0x7fffffff;
149 * only one value per nb; repeat per core
151 while(c++ < conf.nmach && cores[nb]--)
152 s = seprint(s, e, "%ld%s±0.5%s\n", t, r, "");
154 i = readstr(offset, a, n, buf);
163 addarchfile("cputemp", 0444, intelcputemprd, nil);
164 if(X86FAMILY(m->cpuidax) == 0x0f && !strcmp(m->cpuidid, "AuthenticAMD"))
165 addarchfile("cputemp", 0444, amd0ftemprd, nil);
166 if(X86FAMILY(m->cpuidax) == 0x10 && !strcmp(m->cpuidid, "AuthenticAMD"))
167 addarchfile("cputemp", 0444, amd10temprd, nil);