通过ACPI计算热区温度:
1. 由于部分批次的cpu的温度传感器读取出来的值比实际的高(10摄氏度)
只有一个版本的读出来的温度是正常的.
而如何判断批次?
通过SMRAM值:
Sram值存储的在0x430寄存器中:
+++ b/LsRefCodePkg/Core/SecMain/Asm/Start.S
@@ -311,6 +311,11 @@ bsp_start:
bl suspend_to_ram
locate:
+ dli t2,(UNCACHED_MEMORY_ADDR | 0x1fe00430)
+ ld.d t1, t2, 0x0
+ dli t2,(UNCACHED_MEMORY_ADDR | 0x1fe00438)
+ st.d t1, t2, 0x0
由于别的地方还要操作sram值,所以我们先将sram转存到别的地方.
2. 由于扩充了寄存器空间,所以让内核可以访问到的地址空间也能访问到:
--- a/LsRefCodePkg/SampleCode/Laptop/Acpi/AcpiTables/Cpu.asl
+++ b/LsRefCodePkg/SampleCode/Laptop/Acpi/AcpiTables/Cpu.asl
@@ -26,11 +26,15 @@ Scope (\_SB)
Name (IDDR,0x1fe00000) //ChipReg
Name (FREQ,0x000009c4) //Normal Max Freq:2500
- OperationRegion (BASE, SystemMemory, IDDR, 0x28)
+ OperationRegion (BASE, SystemMemory, IDDR, 0x450)
Field (BASE,AnyAcc,NoLock,Preserve)
{
Offset (0x20), //ID
- PRID,64
+ PRID, 64,
+ Offset (0x19C), //thsens
+ THSE, 32,
+ Offset (0x438), //sramctrl
+ SRAM, 64
}
3.更改内核读取温度的方式:
之前是通过EC进行读取的,现在改成由热区进行读取.
--- a/LsRefCodePkg/SampleCode/Laptop/Acpi/AcpiTables/Ec.asl
+++ b/LsRefCodePkg/SampleCode/Laptop/Acpi/AcpiTables/Ec.asl
@@ -58,7 +58,7 @@ Scope (\_SB.PCI0)
OperationRegion (ECOR, EmbeddedControl, 0x00, 0x0100)
Field (ECOR, ByteAcc, NoLock, Preserve)
{
- Offset (0x1E), /*Read current temperature. */
+ Offset (0x48), /*Read current temperature. */
CTMP, 8,
Offset (0x5A),
BLAC, 8,
4. Tz 热区的具体计算温度方法:
--- a/LsRefCodePkg/SampleCode/Laptop/Acpi/AcpiTables/Tz.asl
+++ b/LsRefCodePkg/SampleCode/Laptop/Acpi/AcpiTables/Tz.asl
@@ -29,13 +29,21 @@ Scope (\_TZ)
Method (_TMP, 0, NotSerialized) // _TMP: Temperature
{
- Store (\_SB.PCI0.LPC.EC.CTMP, Local0)
- Return (C2K (Local0))
+ Store (\_SB.THSE, Local0)
+ Store (CCNT (Local0), Local1)
+
+ Store (\_SB.SRAM, Local3)
+ if (LEqual (Local3, 0x0005000180150040 )) {
+ Return (C2K (Local1))
+ }
+ else {
+ Return (C2K (Local1 - 10))
+ }
}
Method (_CRT, 0, NotSerialized) // _CRT: Critical Temperature
{
- Return (C2K (0x60))
+ Return (C2K (0x48)) //72
}
Method (_PSL, 0, Serialized) // _PSL: Passive List
@@ -51,7 +59,7 @@ Scope (\_TZ)
Method (_PSV, 0, NotSerialized) // _PSV: Passive Temperature
{
- Return (C2K (0x46))
+ Return (C2K (0x3C)) //60
}
Name (_TC1, Zero) // _TC1: Thermal Constant 1
@@ -59,6 +67,14 @@ Scope (\_TZ)
Name (_TSP, 300) // _TSP: Thermal Sampling Period
}
+ Method (CCNT, 1, NotSerialized) //calculate cpu node temp, (reg & 0xffff) * 731 / 0x4000 - 273;
+ {
+ Multiply (And (Arg0, 0xFFFF), 0x02DB, Local0)
+ Divide (Local0, 0x4000, , Local1)
+ Subtract (Local1, 273, Local2)
+ Return (Local2)
+ }
+
Method (C2K, 1, NotSerialized) //Celsius to Kelvin