#Maintained by: RehabMan for: Laptop Patches #battery_Lenovo-Miix-720.txt # Created by RehabMan 2017-06-26, based on battery_Lenovo_Ideapad-Y700.txt # based on feedback from gongzhen # Works for # Lenovo Ideapad Miix 720, per gongzhen # Note, offsets for RECB/WECB based on this EC layout: # # OperationRegion (ERAM, EmbeddedControl, Zero, 0xFF) # Field (ERAM, ByteAcc, Lock, Preserve) # { #... # Offset (0x12), # FUSL, 8, # FUSH, 8, # FWBT, 64, //!!0x14 # Offset (0x4A), # ESMC, 1, # Offset (0x4C), # BFUD, 16, # Offset (0x5D), # EXSI, 8, # EXSB, 8, # EXND, 8, # SMPR, 8, # SMST, 8, # SMAD, 8, # SMCM, 8, # SMDA, 256, //!!0x64 # BCNT, 8, # SMAA, 8, # SAD0, 8, # SAD1, 8, # Offset (0x8F), # BMN0, 72, //!!0x8F # BDN0, 64, //!!0x98 # If you have different offsets, make appropriate modifications. # Credits to Rehab man for helping me, and his B1B2 methods and patches, along with his guide. # 16-Bit Register edit in EC0 into device label EC0 code_regex BFUD,\s+16 replace_matched begin B2UD,8,B3UD,8 end; into device label EC0 code_regex B1RC,\s+16 replace_matched begin B2RC,8,B3RC,8 end; into device label EC0 code_regex B1SN,\s+16 replace_matched begin B2SN,8,B3SN,8 end; into device label EC0 code_regex B1FV,\s+16 replace_matched begin B2FV,8,B3FV,8 end; into device label EC0 code_regex B1DV,\s+16 replace_matched begin B2DV,8,B3DV,8 end; into device label EC0 code_regex B1DC,\s+16 replace_matched begin B2DC,8,B3DC,8 end; into device label EC0 code_regex B1FC,\s+16 replace_matched begin B2FC,8,B3FC,8 end; into device label EC0 code_regex B1AC,\s+16 replace_matched begin B2AC,8,B3AC,8 end; into device label EC0 code_regex B1DA,\s+16 replace_matched begin B2DA,8,B3DA,8 end; # Apply B1B2 Patch into method label B1B2 remove_entry; into definitionblock code_regex . insert begin Method (B1B2, 2, NotSerialized) { Return(Or(Arg0, ShiftLeft(Arg1, 8))) }\n end; # fix 16-bit methods into method label GSBI code_regex \(BFUD, replaceall_matched begin (B1B2(B2UD,B3UD), end; into method label _BST code_regex \(B1RC, replaceall_matched begin (B1B2(B2RC,B3RC), end; into method label GSBI code_regex \(B1RC, replaceall_matched begin (B1B2(B2RC,B3RC), end; into method label SMTF code_regex \(B1RC, replaceall_matched begin (B1B2(B2RC,B3RC), end; into method label SMTE code_regex \(B1RC, replaceall_matched begin (B1B2(B2RC,B3RC), end; into method label _BIF code_regex \(B1SN, replaceall_matched begin (B1B2(B2SN,B3SN), end; into method label _BST code_regex \(B1FV, replaceall_matched begin (B1B2(B2FV,B3FV), end; into method label GSBI code_regex \(B1FV, replaceall_matched begin (B1B2(B2FV,B3FV), end; into method label SMTF code_regex \(B1FV, replaceall_matched begin (B1B2(B2FV,B3FV), end; into method label SMTE code_regex \(B1FV, replaceall_matched begin (B1B2(B2FV,B3FV), end; into method label GSBI code_regex \(B1DV, replaceall_matched begin (B1B2(B2DV,B3DV), end; into method label _BIF code_regex \(B1DV, replaceall_matched begin (B1B2(B2DV,B3DV), end; into method label _BIF code_regex \(B1DC, replaceall_matched begin (B1B2(B2DC,B3DC), end; into method label GSBI code_regex \(B1DC, replaceall_matched begin (B1B2(B2DC,B3DC), end; # To Fix the IF Statement in _BIF into method label _BIF code_regex \(B1FC replaceall_matched begin (B1B2(B2FC,B3FC) end; # To Fix IF Statement in SMTE into method label SMTE code_regex B1AC replaceall_matched begin B1B2(B2AC,B3AC) end; # End IF Statement Fixes into method label _BIF code_regex \(B1FC, replaceall_matched begin (B1B2(B2FC,B3FC), end; into method label GSBI code_regex \(B1FC, replaceall_matched begin (B1B2(B2FC,B3FC), end; into method label SMTF code_regex \(B1FC, replaceall_matched begin (B1B2(B2FC,B3FC), end; into method label SMTE code_regex \(B1FC, replaceall_matched begin (B1B2(B2FC,B3FC), end; into method label _BST code_regex \(B1AC, replaceall_matched begin (B1B2(B2AC,B3AC), end; into method label SMTF code_regex \(B1AC, replaceall_matched begin (B1B2(B2AC,B3AC), end; into method label SMTE code_regex \(B1AC, replaceall_matched begin (B1B2(B2AC,B3AC), end; into method label GSBI code_regex \(B1AC, replaceall_matched begin (B1B2(B2AC,B3AC), end; into method label GSBI code_regex \(B1DA, replaceall_matched begin (B1B2(B2DA,B3DA), end; # Buffer Fields into device label EC0 code_regex (FWBT,)\s+(64) replace_matched begin FWBX,%2,//%1%2 end; into device label EC0 code_regex (SMDA,)\s+(256) replace_matched begin SMDX,%2,//%1%2 end; into device label EC0 code_regex (BMN0,)\s+(72) replace_matched begin BMNX,%2,//%1%2 end; into device label EC0 code_regex (BDN0,)\s+(64) replace_matched begin BDNX,%2,//%1%2 end; # utility methods to read/write buffers from/to EC into method label RE1B parent_label EC0 remove_entry; into method label RECB parent_label EC0 remove_entry; into device label EC0 insert begin Method (RE1B, 1, NotSerialized)\n {\n OperationRegion(ERAM, EmbeddedControl, Arg0, 1)\n Field(ERAM, ByteAcc, NoLock, Preserve) { BYTE, 8 }\n Return(BYTE)\n }\n Method (RECB, 2, Serialized)\n // Arg0 - offset in bytes from zero-based EC\n // Arg1 - size of buffer in bits\n {\n ShiftRight(Arg1, 3, Arg1)\n Name(TEMP, Buffer(Arg1) { })\n Add(Arg0, Arg1, Arg1)\n Store(0, Local0)\n While (LLess(Arg0, Arg1))\n {\n Store(RE1B(Arg0), Index(TEMP, Local0))\n Increment(Arg0)\n Increment(Local0)\n }\n Return(TEMP)\n }\n end; into method label WE1B parent_label EC0 remove_entry; into method label WECB parent_label EC0 remove_entry; into device label EC0 insert begin Method (WE1B, 2, NotSerialized)\n {\n OperationRegion(ERAM, EmbeddedControl, Arg0, 1)\n Field(ERAM, ByteAcc, NoLock, Preserve) { BYTE, 8 }\n Store(Arg1, BYTE)\n }\n Method (WECB, 3, Serialized)\n // Arg0 - offset in bytes from zero-based EC\n // Arg1 - size of buffer in bits\n // Arg2 - value to write\n {\n ShiftRight(Arg1, 3, Arg1)\n Name(TEMP, Buffer(Arg1) { })\n Store(Arg2, TEMP)\n Add(Arg0, Arg1, Arg1)\n Store(0, Local0)\n While (LLess(Arg0, Arg1))\n {\n WE1B(Arg0, DerefOf(Index(TEMP, Local0)))\n Increment(Arg0)\n Increment(Local0)\n }\n }\n end; #Begin Patching 32-bit and over into method label MHIF code_regex \(FWBT, replaceall_matched begin (RECB(0x14,64), end; into method label GBID code_regex \(FWBT, replaceall_matched begin (RECB(0x14,64), end; into method label GSBI code_regex \(FWBT, replaceall_matched begin (RECB(0x14,64), end; into method label MHPF code_regex Store\s+\(FB4,\s+SMDA\) replaceall_matched begin WECB(0x64,256,FB4) end; into method label GSBI code_regex \(BMN0, replaceall_matched begin (RECB(0x8f,72), end; into method label _BIF code_regex \(BMN0, replaceall_matched begin (RECB(0x8f,72), end; into method label _BIF code_regex \(BDN0, replaceall_matched begin (RECB(0x98,64), end; into method label GSBI code_regex \(BDN0, replaceall_matched begin (RECB(0x98,64), end; #RehabMan: added for Lenovo Y700 into method label BATD code_regex \(\^\^PCI0\.LPCB\.EC0\.FWBT, replaceall_matched begin (^^PCI0.LPCB.EC0.RECB(0x14,64), end; into method label BATD code_regex \(\^\^PCI0\.LPCB\.EC0\.B1DA, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.B2DA,^^PCI0.LPCB.EC0.B3DA), end; #RehabMan: added for Lenovo B50-50 into method label MHPF code_regex Store\s+\(SMDA,\s+FB4\) replaceall_matched begin Store(RECB(0x64,256),FB4) end; #RehabMan: fixing BAT0._STA logic bug into method label _STA parent_label BAT0 code_regex ([\s\S]*) replace_matched begin If(!ECON) { Return(0xf) }\n %1 end;