Contribute
Register

[Guide] Using Clover to "hotpatch" ACPI

FixWAK is a workaround for bug present only older OS X.
The bug is not present in 10.13.x. In fact, it was fixed in Yosemite (or maybe earlier).
From my static patch "Fix WAK v1":
Code:
# Note regarding Yosemite:
#  At least in Yosemite 10.10.2, this bug appears to be fixed.
#  I didn't notice/verify on other versions of Yosemite
#




Syntax related patches do not apply to hotpatch. Because we are not re-compiling native code...
Rename patches are covered with config.plist/ACPI/DSDT/Patches.
FixMutex is covered with config.plist/ACPI/DSDT/Fixes/FixMutex.
Add MCHC is not needed.
IRQ/RTC/HPET/etc have Clover fixes (ACPI/DSDT/Fixes).
SMBUS too.
Disabling DGPU is covered in post #1.
OS Check Fix is covered in post #1 (_OSI->XOSI + SSDT-XOSI.aml)


Thanks @RehabMan for the help, I have removed addMCHC, removed SSDT-SMBUS and add FixSBus on config.plist. I also added SSDTs: ESEL, XSEL, and XWAK. Just a question, why is the rename for these ssdts end in 08? when I try to check with terminal the converted value shoud be 2C? but when I try to use 2C its not working. can you enlighten me on this?
 

Attachments

  • Screen Shot 2018-01-10 at 12.34.28 PM.png
    Screen Shot 2018-01-10 at 12.34.28 PM.png
    109.4 KB · Views: 179
Thanks @RehabMan for the help, I have removed addMCHC, removed SSDT-SMBUS and add FixSBus on config.plist. I also added SSDTs: ESEL, XSEL, and XWAK.

ESEL/XSEL/XWAK SSDTs require matching patches in config.plist.
They can be used to correct problems with USB after sleep/wake.
Don't use them if not needed.

Just a question, why is the rename for these ssdts end in 08? when I try to check with terminal the converted value shoud be 2C? but when I try to use 2C its not working. can you enlighten me on this?

Why are you adding a ","?
 
ESEL/XSEL/XWAK SSDTs require matching patches in config.plist.
They can be used to correct problems with USB after sleep/wake.
Don't use them if not needed

Yes I do have matching patches that I get from config.plist your repo. They can cause problems if added and i don't have problems with USB after sleep/wake? Ill review this one

Why are you adding a ","?

That was my first try, because disassembled DSDT Method for ESEL/XSEL/XWAK looks like
Code:
 Method (XSEL, 0, Serialized)
            {
                If (LOr (LEqual (XHCI, 0x02), LEqual (XHCI, 0x03)))
                {
                    Store (One, ^^LPCB.XUSB)
                    Store (One, XRST)
                    Store (Zero, Local0)
                    And (PR3, 0xFFFFFFC0, Local0)
                    Or (Local0, PR3M, PR3)
                    Store (Zero, Local0)
                    And (PR2, 0xFFFF8000, Local0)
                    Or (Local0, PR2M, PR2)
                }
            }
thats why I tried to find replace "XSEL," :banghead: I have also checked this one with hexfiend and I have same result "285853454C2C" but this is not and Im confused why your find is like "285853454C08" and your find/replace is working :lol:
 

Attachments

  • Screen Shot 2018-01-11 at 8.26.12 AM.png
    Screen Shot 2018-01-11 at 8.26.12 AM.png
    69.7 KB · Views: 167
Yes I do have matching patches that I get from config.plist your repo. They can cause problems if added and i don't have problems with USB after sleep/wake? Ill review this one

Don't implement patches that you don't need.

That was my first try, because disassembled DSDT Method for ESEL/XSEL/XWAK looks like
Code:
 Method (XSEL, 0, Serialized)

The Name is XSEL. The ',' is a delimiter.
You should probably read the ACPI spec.[/quote]
 
Yes I do have matching patches that I get from config.plist your repo. They can cause problems if added and i don't have problems with USB after sleep/wake? Ill review this one



That was my first try, because disassembled DSDT Method for ESEL/XSEL/XWAK looks like
Code:
 Method (XSEL, 0, Serialized)
            {
                If (LOr (LEqual (XHCI, 0x02), LEqual (XHCI, 0x03)))
                {
                    Store (One, ^^LPCB.XUSB)
                    Store (One, XRST)
                    Store (Zero, Local0)
                    And (PR3, 0xFFFFFFC0, Local0)
                    Or (Local0, PR3M, PR3)
                    Store (Zero, Local0)
                    And (PR2, 0xFFFF8000, Local0)
                    Or (Local0, PR2M, PR2)
                }
            }
thats why I tried to find replace "XSEL," :banghead: I have also checked this one with hexfiend and I have same result "285853454C2C" but this is not and Im confused why your find is like "285853454C08" and your find/replace is working :lol:
If you could set XHCI Mode in BIOS to Auto or Smart Auto, you probably wouldn’t need to patch XSEL.

The XHCI Mode is determined by 'XHCI' value which is a FieldUnitObj. By experiment, I found that the value of 'XHCI' will be 0x02 if XHCI Mode is set to Auto and 0x03 if it’s set to Smart Auto. Personally, I decided to rename the original 'XHCI' to XHCX and provided a replacement IntObj 'XHCI' with a value of 0x03 so that the code in DSDT will act as if the XHCI mode in BIOS is set to Smart Auto. This eliminated the need of patching XSEL.
 
If you could set XHCI Mode in BIOS to Auto or Smart Auto, you probably wouldn’t need to patch XSEL.

The XHCI Mode is determined by 'XHCI' value which is a FieldUnitObj. By experiment, I found that the value of 'XHCI' will be 0x02 if XHCI Mode is set to Auto and 0x03 if it’s set to Smart Auto. Personally, I decided to rename the original 'XHCI' to XHCX and provided a replacement IntObj 'XHCI' with a value of 0x03 so that the code in DSDT will act as if the XHCI mode in BIOS is set to Smart Auto. This eliminated the need of patching XSEL.

I dont have the XHCI mode in my BIOS, what I have is AHCI and some USB options only. How can I determine if this one is needed?:


IMG_0126.JPG IMG_0127.JPG
 
The Name is XSEL. The ',' is a delimiter.
You should probably read the ACPI spec.

Thanks for your time, I am now reviewing ACPI spec and will look for my answers :)
 
I dont have the XHCI mode in my BIOS, what I have is AHCI and some USB options only. How can I determine if this one is needed?:


View attachment 305178 View attachment 305179
XHCI is NOT AHCI.

You might want to check how I fixed my issue provided you have the same issue as mine (which is non-working USB after wake).

Rename 'XHCI, 8' to 'XHCX, 8'. In config.plist/ACPI/DSDT/Patches:

Comment: Change XHCI to XHCX
Find: <58484349 08>
Rep: <58484358 08>

And add this SSDT-XHCI.aml to your Clover/ACPI/patched.
 

Attachments

  • SSDT-XHCI.aml
    43 bytes · Views: 182
Last edited:
May I have 3 External application should be how to define?
Excuse me, I have 3 External application should be how to define? Use the patch as follows:
into_all all code_regex (\s+Zero){2,} removeall_matched;
into device label EC0 code_regex B0C3,\s+16 replace_matched begin XC30, 8, XC31, 8 end;
into_all method label _BIX code_regex \(\^\^LPCB.EC0.B0C3, replaceall_matched begin (B1B2 (^^LPCB.EC0.XC30, ^^LPCB.EC0.XC31), end;
into_all method label _BIF code_regex Store\s\(\^\^LPCB.EC0.BIF9\s\(\),\sIndex\s\(PBIF,\s0x09\)\) replaceall_matched begin \ end;
into method label B1B2 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B2, 2, NotSerialized) { Return (Or (Arg0, ShiftLeft (Arg1, 8))) }\n
end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
 

Attachments

  • batt.dsl
    8.1 KB · Views: 105
  • DSDT-origin.dsl
    744.6 KB · Views: 132
Hello community!
Can someone tell me how could I find out the find and replace value if I need to hot-patch a complex method that has too many references. Like, some EC method.

Suppose, there is some method XYZ that returns one. I want it to return zero. (note that I can't rename and write the whole method as it will take hell lot of time and is very boring TBH.)

I know that I can open the vanilla untouched, uncompiled DSDT and search for the hex value (using xxd) of whatever string I want to replace.

But, my vanilla DSDT has errors and I can't just edit that particular value and save the file. If I fix the errors and then recompile. It becomes a mess. Changed offsets and values.

What I want to know is, is there a way by which I could directly edit the file and save it without errors? So that I can use diff of hex values to find out proper find and replace values for CLOVER hotpatch?
Regards
 
Back
Top