Contribute
Register

[Guide] How to patch DSDT for working battery status

Joined
Feb 15, 2016
Messages
82
Motherboard
Asus X550LB
CPU
i5 4200U
Graphics
HD 4400
Mobile Phone
  1. iOS
Your _REG method is coded incorrectly. The EC related things from _OFF should only be done when the EC is ready.

Sorry this may be off-topic, but I can't seem to disassemble DSDT into .dsl with iasl. I get

Code:
ACPI Exception: AE_ALREADY_EXISTS, During name lookup/catalog (20141107/psobject-305)

Doesn't work neither with patchmatic nor F4. All necessary files (if you need to debug) are in my post above. The iasl creates DSDT.dsl file but the contents are:

Code:
Could not parse ACPI tables, AE_ALREADY_EXISTS
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
188,867
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Sorry this may be off-topic, but I can't seem to disassemble DSDT into .dsl with iasl. I get

Code:
ACPI Exception: AE_ALREADY_EXISTS, During name lookup/catalog (20141107/psobject-305)

Doesn't work neither with patchmatic nor F4. All necessary files (if you need to debug) are in my post above. The iasl creates DSDT.dsl file but the contents are:

Code:
Could not parse ACPI tables, AE_ALREADY_EXISTS

See guide: https://www.tonymacx86.com/threads/guide-patching-laptop-dsdt-ssdts.152573/
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
188,867
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
I was indeed following the guide. But failed in the iasl step.

Read it carefully. Sounds to me like you are doing one of two things wrong:
- failing to eliminate duplicate SSDTs
- disassembling files that do not start with DSDT or SSDT

Also, you cannot reliably use patchmatic to extract native ACPI files as they may have been modified by Clover. Use Clover F4 to extract. Eliminate all files not DSDT or SSDT. Eliminate duplicate SSDTs. Then disassemble all the remaining files with refs.txt as per guide.

FYI: I had no issue disassembling your files in CLOVER.ZIP (ACPI/origin) that you provided in post #3518.
I used: iasl -da -dl -fe refs.txt DSDT.aml SSDT*.aml
 
Joined
Feb 15, 2016
Messages
82
Motherboard
Asus X550LB
CPU
i5 4200U
Graphics
HD 4400
Mobile Phone
  1. iOS
Read it carefully. Sounds to me like you are doing one of two things wrong:
- failing to eliminate duplicate SSDTs
- disassembling files that do not start with DSDT or SSDT

Also, you cannot reliably use patchmatic to extract native ACPI files as they may have been modified by Clover. Use Clover F4 to extract. Eliminate all files not DSDT or SSDT. Eliminate duplicate SSDTs. Then disassemble all the remaining files with refs.txt as per guide.

FYI: I had no issue disassembling your files in CLOVER.ZIP (ACPI/origin) that you provided in post #3518.
I used: iasl -da -dl -fe refs.txt DSDT.aml SSDT*.aml

Yeah... I don't have the code snippet you pasted (_REG method) in DSDT.dsl extracted from the ACPI/origin...
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
188,867
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Yeah... I don't have the code snippet you pasted (_REG method) in DSDT.dsl extracted from the ACPI/origin...

Of course not.
It is something you moved from _OFF and/or SGOF from one of the SSDTs as part of the guide for disabling the discrete GPU.
But you did it incorrectly.
 
Joined
Oct 15, 2015
Messages
137
Motherboard
X550JK
CPU
i5-4200H/HM86 Clover
Graphics
Intel HD Graphics 4600,1920*1080
The patch battery_Lenovo-Yoga-S1 causes some typos for Lenovo S1 Yoga. So I modify it.
 

Attachments

  • battery_Lenovo-Yoga-S1.txt
    4.3 KB · Views: 97
  • DSDT-origin.dsl
    480.3 KB · Views: 92
  • DSDT-patched.dsl
    482 KB · Views: 69

RehabMan

Moderator
Joined
May 3, 2012
Messages
188,867
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
The patch battery_Lenovo-Yoga-S1 causes some typos for Lenovo S1 Yoga. So I modify it.

I don't see any errors after applying the existing "Lenovo Yoga S1" patch to the DSDT-origin.dsl you attached here.

Note: I don't know why those two patches were created in the section marked "# Commenting out string data"
 
Joined
Oct 15, 2015
Messages
137
Motherboard
X550JK
CPU
i5-4200H/HM86 Clover
Graphics
Intel HD Graphics 4600,1920*1080
I don't see any errors after applying the existing "Lenovo Yoga S1" patch to the DSDT-origin.dsl you attached here.

Note: I don't know why those two patches were created in the section marked "# Commenting out string data"

after applying patch
B193848E-AEB9-42B8-9C5A-FEBAAB2A92BF.jpg



before applying patch

.jpg


So I change patch.

Code:
# Fix HWAK Read
into device label EC0 code_regex HWAK,\s+16 replace_matched begin WAK0,8,WAK1,8 end;
into method label _WAK code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
into method label _L0F code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
into method label BL0F code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;

#Fix HWAK Write

into method label _WAK code_regex Store\s\(Local0,\s\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin Store (ShiftRight(Local0,8),\\_SB.PCI0.LPCB.EC0.WAK0)\nStore (Local0,\\_SB.PCI0.LPCB.EC0.WAK1 end;
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
188,867
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
after applying patch
View attachment 229923


before applying patch

View attachment 229924

So I change patch.

Code:
# Fix HWAK Read
into device label EC0 code_regex HWAK,\s+16 replace_matched begin WAK0,8,WAK1,8 end;
into method label _WAK code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
into method label _L0F code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
into method label BL0F code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;

#Fix HWAK Write

into method label _WAK code_regex Store\s\(Local0,\s\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin Store (ShiftRight(Local0,8),\\_SB.PCI0.LPCB.EC0.WAK0)\nStore (Local0,\\_SB.PCI0.LPCB.EC0.WAK1 end;

My iasl does not show an error there (that particular error has come and gone with iasl changes).
But the original patching of that code was indeed wrong.
But your proposal is also wrong. It is storing the MSB/LSB reversed.

Here is the correct diff:
Code:
diff --git a/battery/battery_Lenovo-Yoga-S1.txt b/battery/battery_Lenovo-Yoga-S1.txt
index 13a6465..a49c7f4 100644
--- a/battery/battery_Lenovo-Yoga-S1.txt
+++ b/battery/battery_Lenovo-Yoga-S1.txt
@@ -3,6 +3,7 @@

 # Created by stkov 2014-04-12
 # Modifications by akebono 2015-04-03
+# Fix for HWAK write by nayeweiyang 2017-01-12 (after corrections by RehabMan)

 # works for:
 #  Lenovo Yoga S1
@@ -87,9 +88,14 @@ into method label GBIF code_regex \(SBMN, replaceall_matched begin (RECB(0xA0, 1
 into method label GBIF code_regex Store\s\(B1B2\(BSN0 replace_matched begin /* Store (B1B2(BSN0 end;
 into method label GBIF code_regex Index\s\(Arg1,\s0x0C\)\) replace_matched begin Index (Arg1, 0x0C)) */ end;

-# Fix HWAK
+# Fix HWAK Read
 into device label EC0 code_regex HWAK,\s+16 replace_matched begin WAK0,8,WAK1,8 end;
-into method label _WAK code_regex \\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
-into method label _L0F code_regex \\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
-into method label BL0F code_regex \\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
+into method label _WAK code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
+into method label _L0F code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
+into method label BL0F code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;

+# Fix HWAK Write
+into method label _WAK code_regex Store\s\(Local0,\s\\\_SB.PCI0.LPCB.EC0.HWAK\) replaceall_matched
+begin
+Store (Local0,\\_SB.PCI0.LPCB.EC0.WAK0) Store (ShiftRight(Local0,8),\\_SB.PCI0.LPCB.EC0.WAK1)
+end;
 
Top