Skip to content

Commit 004e6b3

Browse files
committed
Define THRM1-3 bits
1 parent aa2d280 commit 004e6b3

2 files changed

Lines changed: 47 additions & 25 deletions

File tree

include/ogc/machine/asm.h

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -335,22 +335,44 @@
335335
#define ECID2 926
336336
#define ECID3 927
337337

338-
#define MSR_LE 0x00000001
339-
#define MSR_RI 0x00000002
340-
#define MSR_PM 0x00000004
341-
#define MSR_DR 0x00000010
342-
#define MSR_IR 0x00000020
343-
#define MSR_IP 0x00000040
344-
#define MSR_FE1 0x00000100
345-
#define MSR_BE 0x00000200
346-
#define MSR_SE 0x00000400
347-
#define MSR_FE0 0x00000800
348-
#define MSR_ME 0x00001000
349-
#define MSR_FP 0x00002000
350-
#define MSR_PR 0x00004000
351-
#define MSR_EE 0x00008000
352-
#define MSR_ILE 0x00010000
353-
#define MSR_POW 0x00040000
338+
#define MSR_LE 0x00000001
339+
#define MSR_RI 0x00000002
340+
#define MSR_PM 0x00000004
341+
#define MSR_DR 0x00000010
342+
#define MSR_IR 0x00000020
343+
#define MSR_IP 0x00000040
344+
#define MSR_FE1 0x00000100
345+
#define MSR_BE 0x00000200
346+
#define MSR_SE 0x00000400
347+
#define MSR_FE0 0x00000800
348+
#define MSR_ME 0x00001000
349+
#define MSR_FP 0x00002000
350+
#define MSR_PR 0x00004000
351+
#define MSR_EE 0x00008000
352+
#define MSR_ILE 0x00010000
353+
#define MSR_POW 0x00040000
354+
355+
#define THRM1_TIN 0x80000000
356+
#define THRM1_TIV 0x40000000
357+
#define THRM1_THRESHOLD_MASK 0x3F800000
358+
#define THRM1_THRESHOLD(n) (((n) << 23) & THRM1_THRESHOLD_MASK)
359+
#define THRM1_TID 0x00000004
360+
#define THRM1_TIE 0x00000002
361+
#define THRM1_V 0x00000001
362+
363+
#define THRM2_TIN THRM1_TIN
364+
#define THRM2_TIV THRM1_TIV
365+
#define THRM2_THRESHOLD_MASK THRM1_THRESHOLD_MASK
366+
#define THRM2_THRESHOLD(n) THRM1_THRESHOLD(n)
367+
#define THRM2_TID THRM1_TID
368+
#define THRM2_TIE THRM1_TIE
369+
#define THRM2_V THRM1_V
370+
371+
#define THRM3_CALIBRATION_MASK 0x3E000000
372+
#define THRM3_CALIBRATION(x) (((x) << 25) & THRM3_CALIBRATION_MASK)
373+
#define THRM3_SITV_MASK 0x00003FFE
374+
#define THRM3_SITV(n) (((n) << 1) & THRM3_SITV_MASK)
375+
#define THRM3_E 0x00000001
354376

355377
#define PPC_ALIGNMENT 8
356378

libogc/system.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,24 +2046,24 @@ u32 SYS_GetCoreFrequency(void)
20462046

20472047
s8 SYS_GetCoreTemperature(void)
20482048
{
2049-
s32 i,ret;
2049+
s32 i,temp;
20502050
u32 pvr,thrm;
20512051

20522052
pvr = mfpvr();
20532053
if(_SHIFTR(pvr,16,16)!=0x8 || _SHIFTR(pvr,12,4)==0x7) return -1;
2054-
if(!(mfthrm3()&1))
2055-
mtthrm3((_SHIFTL(0x04,25,5)|_SHIFTL(8000,1,13)|1));
2054+
if(!(mfthrm3()&THRM3_E))
2055+
mtthrm3(THRM3_CALIBRATION(0x04)|THRM3_SITV(8000)|THRM3_E);
20562056

20572057
i = 5;
2058-
ret = 64;
2058+
temp = 64;
20592059
while(i--) {
2060-
mtthrm2((_SHIFTL(ret,23,7)|1));
2060+
mtthrm2(THRM2_THRESHOLD(temp)|THRM2_V);
20612061
do {
20622062
thrm = mfthrm2();
2063-
} while(!(thrm&0x40000000));
2064-
if(thrm&0x80000000) ret += (2<<i);
2065-
else ret -= (2<<i);
2063+
} while(!(thrm&THRM2_TIV));
2064+
if(thrm&THRM2_TIN) temp += (2<<i);
2065+
else temp -= (2<<i);
20662066
}
20672067
mtthrm2(0);
2068-
return ret;
2068+
return temp;
20692069
}

0 commit comments

Comments
 (0)