Contribute
Register

[Guide] Using Clover to "hotpatch" ACPI

RehabMan

Moderator
Joined
May 3, 2012
Messages
188,465
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
wow,I work it out.thanks your leading.
Edit:
I'm going patch for discrete graphics, here's something confuse and need your help。
follow "
[Guide] Disabling discrete graphics in dual-GPU laptops
"find out files may contain the relate code to control graphic.
Code:
cuiwenzhis-MBP:disassembly wenzhi$ grep -l Method.*_INI *.dsl
DSDT.dsl
SSDT-15.dsl
SSDT-5.dsl
cuiwenzhis-MBP:disassembly wenzhi$ grep -l Method.*_OFF *.dsl
SSDT-15.dsl
SSDT-3.dsl
SSDT-5.dsl
then search 'Method (_IN' in all of them,all like this:
Code:
All Method (_INI:
in DSDT
Method (_INI, 0, NotSerialized)  // _INI: Initialize
            {
                If (CondRefOf (\_SB.PCI0.XHC.RHUB.INIR))
                {
                    ^RHUB.INIR ()
                }
            }

Method (_INI, 0, NotSerialized)  // _INI: Initialize
            {
                If (LLess (OSYS, 0x07DC))
                {
                    SRXO (GPDI, One)
                }

                Store (GNUM (GPDI), INT1)
                Store (INUM (GPDI), INT2)
                If (LEqual (SDM0, Zero))
                {
                    SHPO (GPDI, One)
                }

                If (LEqual (SDS0, One))
                {
                    Store ("SYNA2393", _HID)
                    Store (0x20, HID2)
                    Return (Zero)
                }
            }

Method (_INI, 0, Serialized)  // _INI: Initialize
        {
            Store (0x07D9, OSYS)
            If (CondRefOf (\_OSI, Local0))
            {
                If (_OSI ("Linux"))
                {
                    Store (0x03E8, OSYS)
                }

                If (_OSI ("Windows 2001"))
                {
                    Store (0x07D1, OSYS)
                }

                If (_OSI ("Windows 2001 SP1"))
                {
                    Store (0x07D1, OSYS)
                }

                If (_OSI ("Windows 2001 SP2"))
                {
                    Store (0x07D2, OSYS)
                }

                If (_OSI ("Windows 2001.1"))
                {
                    Store (0x07D3, OSYS)
                }

                If (_OSI ("Windows 2006"))
                {
                    Store (0x07D6, OSYS)
                }

                If (_OSI ("Windows 2009"))
                {
                    Store (0x07D9, OSYS)
                }

                If (_OSI ("Windows 2012"))
                {
                    Store (0x07DC, OSYS)
                }

                If (_OSI ("Windows 2013"))
                {
                    Store (0x07DD, OSYS)
                }

                If (_OSI ("Windows 2015"))
                {
                    Store (0x07DF, OSYS)
                }
            }

            If (CondRefOf (\_PR.DTSE))
            {
                If (LGreaterEqual (\_PR.DTSE, One))
                {
                    Store (One, \_PR.DSAE)
                }
            }
        }

Method (_INI, 0, NotSerialized)  // _INI: Initialize
                {
                    Store (LTR1, LTRE)
                    Store (PML1, LMSL)
                    Store (PNL1, LNSL)
                    Store (OBF1, OBFF)
                }

Method (_INI, 0, NotSerialized)  // _INI: Initialize
                {
                    Store (NIT1, NITV)
                    Store (NPM1, NPMV)
                    Store (NPC1, NPCV)
                    Store (NL11, NL1V)
                    Store (ND21, ND2V)
                    Store (ND11, ND1V)
                    Store (NLR1, NLRV)
                    Store (NLD1, NLDV)
                    Store (NEA1, NEAV)
                    Store (NEB1, NEBV)
                    Store (NEC1, NECV)
                    Store (NRA1, NRAV)
                    Store (NMB1, NMBV)
                    Store (NMV1, NMVV)
                    Store (NPB1, NPBV)
                    Store (NPV1, NPVV)
                    Store (Zero, NCRN)
                }
            }

in SSDT-5
Method (_INI, 0, NotSerialized)  // _INI: Initialize
        {
            Store (LTRX, LTRS)
            Store (OBFX, OBFS)
        }

Method (_INI, 0, NotSerialized)  // _INI: Initialize
        {
            Store (LTRY, LTRS)
            Store (OBFY, OBFS)
        }

Method (_INI, 0, NotSerialized)  // _INI: Initialize
        {
            Store (LTRZ, LTRS)
            Store (OBFZ, OBFS)
        }

in SSDT-15
Scope (\_SB.PCI0.GFX0)
    {
        Method (_INI, 0, NotSerialized)  // _INI: Initialize
        {
            Store (DID1, Index (TLPK, Zero))
            Store (DID2, Index (TLPK, 0x02))
            Store (DID3, Index (TLPK, 0x04))
            Store (DID4, Index (TLPK, 0x06))
            Store (DID5, Index (TLPK, 0x08))
            Store (DID6, Index (TLPK, 0x0A))
            Store (DID7, Index (TLPK, 0x0C))
            Store (DID2, Index (TLPK, 0x0E))
            Store (DID1, Index (TLPK, 0x0F))
            Store (DID2, Index (TLPK, 0x11))
            Store (DID3, Index (TLPK, 0x12))
            Store (DID2, Index (TLPK, 0x14))
            Store (DID4, Index (TLPK, 0x15))
            Store (DID2, Index (TLPK, 0x17))
            Store (DID5, Index (TLPK, 0x18))
            Store (DID2, Index (TLPK, 0x1A))
            Store (DID6, Index (TLPK, 0x1B))
            Store (DID2, Index (TLPK, 0x1D))
            Store (DID7, Index (TLPK, 0x1E))
        }
….
}
only this look like about some device, but seems not a graphics? thank again.
Code:
Method (_INI, 0, NotSerialized)  // _INI: Initialize
            {
                If (CondRefOf (\_SB.PCI0.XHC.RHUB.INIR))
                {
                    ^RHUB.INIR ()
                }
            }

_OFF is in SSDT-15. It calls PGOF in SSDT-5. No EC references in either.
ACPI path is _SB.PCI0.PEG0.PEGP.
There is no _INI at that path, so you simply add one in SSDT-15 (just add _INI method that calls _OFF before _OFF).
 
Joined
Dec 11, 2016
Messages
151
Motherboard
Dell Inspiron 7559-1.0.1-Clover
CPU
i5-6300HQ
Graphics
HD 530 GTX 960M,1920x1080
Mac
  1. MacBook Pro
Mobile Phone
  1. iOS
_OFF is in SSDT-15. It calls PGOF in SSDT-5. No EC references in either.
ACPI path is _SB.PCI0.PEG0.PEGP.
There is no _INI at that path, so you simply add one in SSDT-15 (just add _INI method that calls _OFF before _OFF).
Thanks very much,Sloved it.
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
188,465
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Thanks very much,Sloved it.

Of course, that is the static patch method. This is the hotpatch thread.

With hotpatch, you simply add an SSDT:
Code:
DefinitionBlock ("", "SSDT", 2, "hack", "disable", 0)
{
    External(_SB.PCI0.PEG0.PEGP._OFF, MethodObj)
    Method(_SB.PCI0.PEG0.PEGP._INI) { _OFF() }
}
 
Joined
Dec 11, 2016
Messages
151
Motherboard
Dell Inspiron 7559-1.0.1-Clover
CPU
i5-6300HQ
Graphics
HD 530 GTX 960M,1920x1080
Mac
  1. MacBook Pro
Mobile Phone
  1. iOS
Of course, that is the static patch method. This is the hotpatch thread.

With hotpatch, you simply add an SSDT:
Code:
DefinitionBlock ("", "SSDT", 2, "hack", "disable", 0)
{
    External(_SB.PCI0.PEG0.PEGP._OFF, MethodObj)
    Method(_SB.PCI0.PEG0.PEGP._INI) { _OFF() }
}
Thanks.with your help to slove the trouble cause by _INI.I modify ssdt-disable_DUGP.dsl from you as hotpatch method.It work fine.
 
Joined
Nov 10, 2011
Messages
1,457
Motherboard
GA-H77N-WIFI F4
CPU
i7-3770
Graphics
HD 4000
Mobile Phone
  1. Android
I've started to hotpatch the DSDT for my board (H77N-WiFi), using the PJALM patches as a template. I'm having difficulties with one of them. There is a device in the stock DSDT:
Code:
Device (_SB.PCI0.DOCK)
    {
        Name (_HID, "ABCDEFGH")  // _HID: Hardware ID
        Name (_CID, EisaId ("PNP0C15"))  // _CID: Compatible ID
        Name (_UID, 0x02)  // _UID: Unique ID
        Method (_STA, 0, NotSerialized)  // _STA: Status
        {
            Return (Zero)
        }
    }
that is being patched like this:
Code:
    Device (_SB.PCI0.DOCK)
    {
        Name (_HID, EisaId ("PNP0C15"))  // _HID: Hardware ID
        Name (_CID, EisaId ("PNP0C15"))  // _CID: Compatible ID
        Name (_UID, 0x02)  // _UID: Unique ID
        Method (_STA, 0, NotSerialized)  // _STA: Status
        {
            Return (Zero)
        }
    }
It seems that won't be simple code value patching as the patched name has bigger hex lenght than the original one. Any suggestions? Maybe if I just rename it to something like "ROCK" and inject the corrected device with SSDT in the same scope?
Attached the stock DSDT and SSDT tables and the patched DSDT.
 

Attachments

  • DSDT.dsl
    327.9 KB · Views: 156
  • DSDT_patched.dsl
    335.3 KB · Views: 129
  • SSDT-0.dsl
    6.5 KB · Views: 162
  • SSDT-1.dsl
    17.8 KB · Views: 138
  • SSDT-2.dsl
    15.1 KB · Views: 131
Last edited:

RehabMan

Moderator
Joined
May 3, 2012
Messages
188,465
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
I've started to hotpatch the DSDT for my board (H77N-WiFi), using the PJALM patches as a template. I'm having difficulties with one of them. There is a device in the stock DSDT:
Code:
Device (_SB.PCI0.DOCK)
    {
        Name (_HID, "ABCDEFGH")  // _HID: Hardware ID
        Name (_CID, EisaId ("PNP0C15"))  // _CID: Compatible ID
        Name (_UID, 0x02)  // _UID: Unique ID
        Method (_STA, 0, NotSerialized)  // _STA: Status
        {
            Return (Zero)
        }
    }
that is being patched like this:
Code:
    Device (_SB.PCI0.DOCK)
    {
        Name (_HID, EisaId ("PNP0C15"))  // _HID: Hardware ID
        Name (_CID, EisaId ("PNP0C15"))  // _CID: Compatible ID
        Name (_UID, 0x02)  // _UID: Unique ID
        Method (_STA, 0, NotSerialized)  // _STA: Status
        {
            Return (Zero)
        }
    }
It seems that won't be simple code value patching as the patched name has bigger hex lenght than the original one. Any suggestions? Maybe if I just rename it to something like "ROCK" and inject the corrected device with SSDT in the same scope?
Attached the stock DSDT and SSDT tables and the patched DSDT.

No need to patch it. Ignore.
 
Joined
Nov 10, 2011
Messages
1,457
Motherboard
GA-H77N-WIFI F4
CPU
i7-3770
Graphics
HD 4000
Mobile Phone
  1. Android
So, it's cosmetic patch in order the DSDT to be compiled without errors...
How about line 2335?
Code:
CreateDWordField (BUF0, \_SB.PCI0._Y0F._LEN, MSLN)  // _LEN: Length
is patched to
Code:
CreateQWordField (BUF0, \_SB.PCI0._Y0F._LEN, MSLN)  // _LEN: Length
Should I ignore that too?
 
Last edited:

RehabMan

Moderator
Joined
May 3, 2012
Messages
188,465
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
So, it's cosmetic patch in order the DSDT to be compiled without errors...
How about line 2335?
Code:
CreateDWordField (BUF0, \_SB.PCI0._Y0F._LEN, MSLN)  // _LEN: Length
is patched to
Code:
CreateQWordField (BUF0, \_SB.PCI0._Y0F._LEN, MSLN)  // _LEN: Length
Should I ignore that too?

Yup.
 
Joined
Nov 10, 2011
Messages
1,457
Motherboard
GA-H77N-WIFI F4
CPU
i7-3770
Graphics
HD 4000
Mobile Phone
  1. Android
Ok, last one: how about patching the following methods:
\UXDV
\RRIO
\_SB.PCI0.GFX0._DOD
from NotSerialized to Serialized?

Also several Names like CRS1 to CRS4 and their lenght, changed from 0x00 to 0x01 (code value patching)?
 
Last edited:

RehabMan

Moderator
Joined
May 3, 2012
Messages
188,465
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Ok, last one: how about patching the following methods:
\UXDV
\RRIO
\_SB.PCI0.GFX0._DOD
from NotSerialized to Serialized?

Also several Names like CRS1 to CRS4 and their lenght, changed from 0x00 to 0x01 (code value patching)?

All such patches are not necessary.

With hotpatch, you're concerned only with functional patches. Patches to correct warnings/errors/etc are generally not needed (and were not really needed in the first place).
 
Top