into device label EC0 code_regex XIF0,\s+16, replace_matched begin IF00,8,IF01,8, end;
into device label EC0 code_regex XIF1,\s+16, replace_matched begin IF10,8,IF11,8, end;
into device label EC0 code_regex XIF2,\s+16, replace_matched begin IF20,8,IF21,8, end;
into device label EC0 code_regex XIF3,\s+16, replace_matched begin IF30,8,IF31,8, end;
into device label EC0 code_regex XIF4,\s+16, replace_matched begin IF40,8,IF41,8, end;
into device label EC0 code_regex XIF7,\s+16, replace_matched begin IF70,8,IF71,8, end;
into device label EC0 code_regex XST0,\s+16, replace_matched begin ST00,8,ST01,8, end;
into device label EC0 code_regex XST1,\s+16, replace_matched begin ST10,8,ST11,8, end;
into device label EC0 code_regex XST2,\s+16, replace_matched begin ST20,8,ST21,8, end;
into device label EC0 code_regex XST3,\s+16, replace_matched begin ST30,8,ST31,8, end;
into device label EC0 code_regex CYCN,\s+16, replace_matched begin YCN0,8,YCN1,8, end;
into device label EC0 code_regex BST1,\s+16, replace_matched begin YST0,8,YST1,8, end;
into method label _BIF code_regex \(\^\^PCI0.LPCB.EC0.XIF0, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF00,^^PCI0.LPCB.EC0.IF01), end;
into method label ECBE code_regex \(\^\^PCI0.LPCB.EC0.XIF1, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF10,^^PCI0.LPCB.EC0.IF11), end;
into method label _BST code_regex \(\^\^PCI0.LPCB.EC0.XIF1, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF10,^^PCI0.LPCB.EC0.IF11), end;
into method label _BIF code_regex \(\^\^PCI0.LPCB.EC0.XIF1, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF10,^^PCI0.LPCB.EC0.IF11), end;
into method label ECBE code_regex \(\^\^PCI0.LPCB.EC0.XIF2, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF20,^^PCI0.LPCB.EC0.IF21), end;
into method label _BST code_regex \^\^PCI0.LPCB.EC0.XIF2, replaceall_matched begin B1B2(^^PCI0.LPCB.EC0.IF20,^^PCI0.LPCB.EC0.IF21), end;
into method label _BIF code_regex \(\^\^PCI0.LPCB.EC0.XIF2, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF20,^^PCI0.LPCB.EC0.IF21), end;
into method label ECBE code_regex \(\^\^PCI0.LPCB.EC0.XIF3, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF30,^^PCI0.LPCB.EC0.IF31), end;
into method label _BIF code_regex \(\^\^PCI0.LPCB.EC0.XIF3, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF30,^^PCI0.LPCB.EC0.IF31), end;
into method label ECBE code_regex \(\^\^PCI0.LPCB.EC0.XIF4, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF40,^^PCI0.LPCB.EC0.IF41), end;
into method label _BIF code_regex \(\^\^PCI0.LPCB.EC0.XIF4, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF40,^^PCI0.LPCB.EC0.IF41), end;
into method label ECBE code_regex \(\^\^PCI0.LPCB.EC0.XIF7, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF70,^^PCI0.LPCB.EC0.IF71), end;
into method label _BIF code_regex \(\^\^PCI0.LPCB.EC0.XIF7, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.IF70,^^PCI0.LPCB.EC0.IF71), end;
into method label _BST code_regex \(\^\^PCI0.LPCB.EC0.XST0, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.ST00,^^PCI0.LPCB.EC0.ST01), end;
into method label _BST code_regex \(\^\^PCI0.LPCB.EC0.XST1, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.ST10,^^PCI0.LPCB.EC0.ST11), end;
into method label _BST code_regex \(\^\^PCI0.LPCB.EC0.XST2, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.ST20,^^PCI0.LPCB.EC0.ST21), end;
into method label _BST code_regex \(\^\^PCI0.LPCB.EC0.XST3, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.ST30,^^PCI0.LPCB.EC0.ST31), end;
into method label _BIF code_regex \(\^\^PCI0.LPCB.EC0.XST3, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.ST30,^^PCI0.LPCB.EC0.ST31), end;
into method label ECBE code_regex \(\^\^PCI0.LPCB.EC0.CYCN, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.YCN0,^^PCI0.LPCB.EC0.YCN1), end;
into method label _BST code_regex \(\^\^PCI0.LPCB.EC0.CYCN, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.YCN0,^^PCI0.LPCB.EC0.YCN1), end;
into device label BAT0 parent_label H_EC remove_entry;
into device label BAT1 parent_label H_EC remove_entry;
into device label BAT2 parent_label H_EC remove_entry;
into method label PNOT code_regex Notify\s\(\\_SB.PCI0.LPCB.H_EC.BAT0,\s0x81\)\s+Notify\s\(\\_SB.PCI0.LPCB.H_EC.BAT1,\s0x81\)\s+Notify\s\(\\_SB.PCI0.LPCB.H_EC.BAT2,\s0x81\) replaceall_matched begin // BAT0,BAT1,BAT2 on H_EC were dead, end;
into method label PNOT code_regex Notify\s\(\\_SB.PCI0.LPCB.H_EC.BAT0,\s0x80\)\s+Notify\s\(\\_SB.PCI0.LPCB.H_EC.BAT1,\s0x80\)\s+Notify\s\(\\_SB.PCI0.LPCB.H_EC.BAT2,\s0x80\) replaceall_matched begin // BAT0,BAT1,BAT2 on H_EC were dead, end;
into method label _STA parent_label BAT0 replace_content begin Return (0x1F) end;
#B1B2
#B1B3
#B1B4
#RECB
#WECB
into method label B1B2 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B2, 2, NotSerialized)\n
{\n
Return(Or(Arg0, ShiftLeft(Arg1, 8)))\n
}\n
end;
#For 24 bit registers
into method label B1B3 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B3, 3, NotSerialized)\n
{\n
Store(Arg2, Local0)\n
Or(Arg1, ShiftLeft(Local0, 8), Local0)\n
Or(Arg0, ShiftLeft(Local0, 8), Local0)\n
Return(Local0)\n
}\n
end;
into method label B1B4 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B4, 4, NotSerialized)\n
{\n
Store(Arg3, Local0)\n
Or(Arg2, ShiftLeft(Local0, 8), Local0)\n
Or(Arg1, ShiftLeft(Local0, 8), Local0)\n
Or(Arg0, ShiftLeft(Local0, 8), Local0)\n
Return(Local0)\n
}\n
end;
# utility methods to read/write buffers from/to EC
into method label RE1B parent_label H_EC remove_entry;
into method label RECB parent_label H_EC remove_entry;
# Some DSDTs use Mutex objects with non-zero a SyncLevel. Evidently,
# OS X has some difficulty with this part of the ACPI spec, either that
# or the DSDTs are, in fact, codec incorrectly and Windows is ignoring
# it.
# The common result of a non-zero SyncLevel is failure of methods at the
# point of Acquire on the mutext in question. This can result in strange
# behavior, failed battery status, or other issues.
#
# This patch corrects all Mutex objects declared with a non-zero
# SyncLevel to use zero.
#
# 2x as there is some sort of MaciASL bug...
# (code_regex_not seems broken)
#into_all all code_regex_not Mutex\s+\([^,]*,\s+0x00\) code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
#into_all all code_regex_not Mutex\s+\([^,]*,\s+0x00\) code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
# 10x as workaround for MaciASL bug...
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
#Logic bug with charging/discharging status (AC adapter detection)
#Some DSDTs suffer from a logic bug where at the point of 100% capacity (fully charged battery), an incorrect #status is returned from _BST. This mostly affects certain ASUS laptops, but also a few others.
#Here is a patch to correct this problem:
into method label FBST code_regex If\s\(CHGS\s\(Zero\)\)[\s]+\{[\s]+Store\s\(0x02,\sLocal0\)[\s]+\}[\s]+Else[\s]+\{[\s]+Store\s\(One,\sLocal0\)[\s]+\} replaceall_matched begin
If (CHGS (Zero))\n
{\n
Store (0x02, Local0)\n
}\n
Else\n
{\n
Store (Zero, Local0)\n
}
end;
#Fix HP OMEN Laptop Baterry to enabled percentage and discharge time
into method label SMWR code_regex If\s\(LNot\s\(ECOK\)\)\s+\{\s+Return\s\(0xFF\)\s+\} replaceall_matched begin
If (LEqual (ECOK, One))\n
{\n
Return (0xFF)\n
}\n
end;
#Fix Hasee YOUYA Laptop Baterry to enabled percentage and discharge time
into method label SMWR code_regex If\s\(LNot\s\(ECON\)\)\s+\{\s+Return\s\(0xFF\)\s+\} replaceall_matched begin