Contribute
Register

[solved] 15" HP 2017 Spectre X360 - KP With High Sierra Installer

Status
Not open for further replies.
The .disable rename seems to work ok for all the versions of clover i've been testing with but point taken.



Ok somehow I've confused myself in the patching process and removed the line that called HGOF from the _OFF method (because HGOF uses EC) and moved it to the _REG method. my big bad ... :banghead: ... I think in the example in your guide the EC code is in the _OFF method which is probably what sent me down that path.

What i should be doing is removing the EC line of code in the HGOF Method and putting that in the _REG method.

So I think what i need to do is rename HGOF to XGOF (which is not used by any of the ACPI files) , inject a new HGOF method without the line of code that uses the EC and move that of code into _REG

Ok i think i got it now ....

Thanks for taking a look and pointing out my mistake.
Appreciate all you do for the community.
Cheers
Jay

I think you've got a better feeling for the patching required...
Summary:
- _INI, if it exists is patched to call _OFF (if _INI does not exist, you simply add it at the same ACPI path as _OFF)
- the execution path of _OFF is analyzed for EC related code
- any EC related code in the _OFF execution path is removed, and executed in _REG instead (when EC is ready, as per ACPI spec)
- the EC related code may appear in _OFF directly, or a method which _OFF calls (directly or indirectly)
- hotpatching methods uses rename/replace pattern as per ACPI hotpatch guide
 
@RehabMan,

Three questions ...

1. Is it just the one line in the HGOF method with the EC that i move to the new _REG method :-

Code:
Store (Zero, \_SB.PCI0.LPCB.EC0.GFXT)

2. How does _REF get called from HGOF as i see no calls to _REF in the rest of HGOF code .. does Sleep call it ?
Code:
        Sleep (0x14)
        Return (Zero)
        }

    }

3. In all previous versions of OSX/MacOS right up to Sierra 10.12.6 I simply called _OFF from _INI and the DGPU powered down. Whats changed in OSX 10.13.X that requires this extra procedure to deal with the EC's in order to power down the DGPU ? Just curious to understand what Apple has done and why ?

Cheers
Jay
 
@RehabMan,

Three questions ...

1. Is it just the one line in the HGOF method with the EC that i move to the new _REG method :-

Code:
Store (Zero, \_SB.PCI0.LPCB.EC0.GFXT)

That's all I saw when I looked at it briefly earlier...

2. How does _REF get called from HGOF as i see no calls to _REF in the rest of HGOF code .. does Sleep call it ?
Code:
        Sleep (0x14)
        Return (Zero)
        }

    }

_REF?

3. In all previous versions of OSX/MacOS right up to Sierra 10.12.6 I simply called _OFF from _INI and the DGPU powered down. Whats changed in OSX 10.13.X that requires this extra procedure to deal with the EC's in order to power down the DGPU ? Just curious to understand what Apple has done and why ?

You were just getting lucky. The code you had was wrong. EC cannot be accessed until the host EC driver is ready, and that is not until _REG is called as per ACPI spec.
 
@RehabMan,

Re Question 2 above ... sorry typo should have been _REG not _REF.

One further question.

I'm currently working on the hotpatch for HGOF and now adding the missing External References .. but have got a bit stuck with the following ..

In the HGOF method is the following :-

Code:
            If (LEqual (RPIX, One))
            {
                Store (LCT1, ELCT)
                Store (SVI1, HVID)
                Store (SDI1, HDID)
                Store (LRE1, LTRE)
                Store (One, LKD1)
            }

MACIASL Compile error = Object does not exist (LCT1)

The first occurrence of LCT1 in SSDT-8 is as follows:-

Code:
OperationRegion (PCA1, SystemMemory, Add (Add (\XBAS, ShiftLeft (SCB1, 0x14)), \EECP), 0x14)
        Field (PCA1, DWordAcc, NoLock, Preserve)
        {
            Offset (0x10),
            LCT1,   16
        }

Do I declare the External Reference for LCT1 as :-

Code:
External (_SB_.PCI0.LCT1, IntObj)    // (from opcode)

Or is it some other type of external object ?

Cheers
Jay
 
@RehabMan,

Re Question 2 above ... sorry typo should have been _REG not _REF.

_REG is called by the ACPI host implementation within AppleACPIPlatform.kext (well, in the case of EC, specifically by AppleACPIEC.kext).

Much like how other reserved methods are called by the ACPI host (_INI, _STA, etc).

One further question.

I'm currently working on the hotpatch for HGOF and now adding the missing External References .. but have got a bit stuck with the following ..

In the HGOF method is the following :-

Code:
            If (LEqual (RPIX, One))
            {
                Store (LCT1, ELCT)
                Store (SVI1, HVID)
                Store (SDI1, HDID)
                Store (LRE1, LTRE)
                Store (One, LKD1)
            }

MACIASL Compile error = Object does not exist (LCT1)

The first occurrence of LCT1 in SSDT-8 is as follows:-

Code:
OperationRegion (PCA1, SystemMemory, Add (Add (\XBAS, ShiftLeft (SCB1, 0x14)), \EECP), 0x14)
        Field (PCA1, DWordAcc, NoLock, Preserve)
        {
            Offset (0x10),
            LCT1,   16
        }

Do I declare the External Reference for LCT1 as :-

Code:
External (_SB_.PCI0.LCT1, IntObj)    // (from opcode)

Or is it some other type of external object ?

Cheers
Jay

According to your native ACPI (SSDT-8), LCT1 is a FieldUnitObj in scope _SB.PCI0, so:
External(_SB.PCI0.LCT1, FieldUnitObj)
 
I figured it was something else other than MethodObj, IniObj, DeviceObj but I wasn't sure.
Thank you for the guidance

Jay
 
@RehabMan ,

Almost ready with new DGPU Hotpatch this is what i've got :-

Code:
DefinitionBlock("", "SSDT", 2, "hack", "D-GPU", 0)
{
//  External Refs for _INI Method
    External(_SB.PCI0.RP01.PEGP, DeviceObj)
    External(_SB.PCI0.RP01.PEGP.XINI, MethodObj)
    External(_SB.PCI0.RP01.PEGP._OFF, MethodObj)
   
//  External Refs for _REG Method   
    External(_SB.PCI0.LPCB.EC0, DeviceObj)
    External(_SB.PCI0.LPCB.EC0.XREG, MethodObj)
    External(_SB.PCI0.LPCB.EC0.GFXT, FieldUnitObj)

//  External Refs for HGOF Method

    External (_SB_.PCI0, DeviceObj)   
    External (_SB_.PCI0.RPIX, IntObj)   
    External (_SB_.PCI0.CCHK, MethodObj) 
    External (_SB_.PCI0.SGPO, MethodObj)   
    External (_SB.PCI0.LCT1, FieldUnitObj)
    External (_SB_.PCI0.ELCT, IntObj)   
    External (_SB.PCI0.SVI1, FieldUnitObj)
    External (_SB_.PCI0.HVID, IntObj) 
    External (_SB.PCI0.SDI1, FieldUnitObj)
    External (_SB_.PCI0.HDID, IntObj) 
    External (_SB.PCI0.LRE1, FieldUnitObj)
    External (_SB.PCI0.LKD1, FieldUnitObj)
    External (_SB.PCI0.LCT9, FieldUnitObj)
    External (_SB.PCI0.SVI9, FieldUnitObj)
    External (_SB.PCI0.SDI9, FieldUnitObj)
    External (_SB.PCI0.LRE9, FieldUnitObj)
    External (_SB.PCI0.LKD9, FieldUnitObj)
    External (_SB.PCI0.LKS1, FieldUnitObj)
    External (_SB.PCI0.LKS9, FieldUnitObj)
    External (_SB.PCI0.HRG0, FieldUnitObj) 
    External (_SB.PCI0.PWE0, FieldUnitObj)
    External (_SB.PCI0.PWA0, FieldUnitObj) 
    External (_SB.PCI0.PWG0, FieldUnitObj) 
    External (_SB.PCI0.HRA0, FieldUnitObj) 
    External (_SB.PCI0.HRE0, FieldUnitObj) 
    External (_SB.PCI0.SGGP, FieldUnitObj)   
    External (_SB.PCI0.LTRE, FieldUnitObj)


    Scope(_SB.PCI0)
    {
    Method (HGOF, 1, Serialized)
        {
            If (LNotEqual (SGGP, One))
            {
                Return (Zero)
            }

            Store (Arg0, RPIX)
            If (LEqual (CCHK (Zero, RPIX), Zero))
            {
                Return (Zero)
            }

            If (LEqual (RPIX, One))
            {
                Store (LCT1, ELCT)
                Store (SVI1, HVID)
                Store (SDI1, HDID)
                Store (LRE1, LTRE)
                Store (One, LKD1)
            }
            ElseIf (LEqual (RPIX, 0x09))
            {
                Store (LCT9, ELCT)
                Store (SVI9, HVID)
                Store (SDI9, HDID)
                Store (LRE9, LTRE)
                Store (One, LKD9)
            }

            If (LEqual (RPIX, One))
            {
                While (LNotEqual (LKS1, Zero))
                {
                    Sleep (One)
                }
            }
            ElseIf (LEqual (RPIX, 0x09))
            {
                While (LNotEqual (LKS9, Zero))
                {
                    Sleep (One)
                }
            }

            SGPO (HRE0, HRG0, HRA0, One)
            SGPO (PWE0, PWG0, PWA0, Zero)
//          Store (Zero, \_SB.PCI0.LPCB.EC0.GFXT).  <---- Move to _REG
            Sleep (0x14)
            Return (Zero)
        }

    }

   
    Scope(_SB.PCI0.RP01.PEGP)
    {
        Method(_INI)
        {
            XINI() // call original _INI, now renamed XINI
            _OFF() // call (patched) _OFF
        }
    }
   
   
   
    Scope(_SB.PCI0.LPCB.EC0)
    {
        OperationRegion(RME3, EmbeddedControl, 0x00, 0xFF)
        Method(_REG, 2)
        {
            XREG(Arg0, Arg1) // call original _REG, now renamed XREG
            If (3 == Arg0 && 1 == Arg1) // EC ready?
            {
            Store (Zero, \_SB.PCI0.LPCB.EC0.GFXT)   // EC code from HGOF Method
            }
        }
    }
}

Just got to do the binary patch for HGOF .... Then ready to test, would Appreciate if you could give my code a look over and let me know if you spot anything wrong. The code compiles ok.

Cheers
Jay
 
Last edited:
@RehabMan ,

Almost ready with new DGPU Hotpatch this is what i've got :-

Code:
DefinitionBlock("", "SSDT", 2, "hack", "D-GPU", 0)
{
//  External Refs for _INI Method
    External(_SB.PCI0.RP01.PEGP, DeviceObj)
    External(_SB.PCI0.RP01.PEGP.XINI, MethodObj)
    External(_SB.PCI0.RP01.PEGP._OFF, MethodObj)
 
//  External Refs for _REG Method 
    External(_SB.PCI0.LPCB.EC0, DeviceObj)
    External(_SB.PCI0.LPCB.EC0.XREG, MethodObj)
    External(_SB.PCI0.LPCB.EC0.GFXT, IntObj)

//  External Refs for HGOF Method

    External (_SB_.PCI0, DeviceObj) 
    External (_SB_.PCI0.RPIX, IntObj) 
    External (_SB_.PCI0.CCHK, MethodObj)
    External (_SB_.PCI0.SGPO, MethodObj) 
    External (_SB.PCI0.LCT1, FieldUnitObj)
    External (_SB_.PCI0.ELCT, IntObj) 
    External (_SB.PCI0.SVI1, FieldUnitObj)
    External (_SB_.PCI0.HVID, IntObj)
    External (_SB.PCI0.SDI1, FieldUnitObj)
    External (_SB_.PCI0.HDID, IntObj)
    External (_SB.PCI0.LRE1, FieldUnitObj)
    External (_SB.PCI0.LKD1, FieldUnitObj)
    External (_SB.PCI0.LCT9, FieldUnitObj)
    External (_SB.PCI0.SVI9, FieldUnitObj)
    External (_SB.PCI0.SDI9, FieldUnitObj)
    External (_SB.PCI0.LRE9, FieldUnitObj)
    External (_SB.PCI0.LKD9, FieldUnitObj)
    External (_SB.PCI0.LKS1, FieldUnitObj)
    External (_SB.PCI0.LKS9, FieldUnitObj)
    External (_SB.PCI0.HRG0, FieldUnitObj)
    External (_SB.PCI0.PWE0, FieldUnitObj)
    External (_SB.PCI0.PWA0, FieldUnitObj)
    External (_SB.PCI0.PWG0, FieldUnitObj)
    External (_SB.PCI0.HRA0, FieldUnitObj)
    External (_SB.PCI0.HRE0, FieldUnitObj)
    External (_SB.PCI0.SGGP, FieldUnitObj) 
    External (_SB.PCI0.LTRE, FieldUnitObj)


    Scope(_SB.PCI0)
    {
    Method (HGOF, 1, Serialized)
        {
            If (LNotEqual (SGGP, One))
            {
                Return (Zero)
            }

            Store (Arg0, RPIX)
            If (LEqual (CCHK (Zero, RPIX), Zero))
            {
                Return (Zero)
            }

            If (LEqual (RPIX, One))
            {
                Store (LCT1, ELCT)
                Store (SVI1, HVID)
                Store (SDI1, HDID)
                Store (LRE1, LTRE)
                Store (One, LKD1)
            }
            ElseIf (LEqual (RPIX, 0x09))
            {
                Store (LCT9, ELCT)
                Store (SVI9, HVID)
                Store (SDI9, HDID)
                Store (LRE9, LTRE)
                Store (One, LKD9)
            }

            If (LEqual (RPIX, One))
            {
                While (LNotEqual (LKS1, Zero))
                {
                    Sleep (One)
                }
            }
            ElseIf (LEqual (RPIX, 0x09))
            {
                While (LNotEqual (LKS9, Zero))
                {
                    Sleep (One)
                }
            }

            SGPO (HRE0, HRG0, HRA0, One)
            SGPO (PWE0, PWG0, PWA0, Zero)
//          Store (Zero, \_SB.PCI0.LPCB.EC0.GFXT)       <---- Move to _REG
            Sleep (0x14)
            Return (Zero)
        }

    }

 
    Scope(_SB.PCI0.RP01.PEGP)
    {
        Method(_INI)
        {
            XINI() // call original _INI, now renamed XINI
            _OFF() // call (patched) _OFF
        }
    }
 
 
 
    Scope(_SB.PCI0.LPCB.EC0)
    {
        OperationRegion(RME3, EmbeddedControl, 0x00, 0xFF)
        Method(_REG, 2)
        {
            XREG(Arg0, Arg1) // call original _REG, now renamed XREG
            If (3 == Arg0 && 1 == Arg1) // EC ready?
            {
            Store (Zero, \_SB.PCI0.LPCB.EC0.GFXT)   // EC code from HGOF Method
            }
        }
    }
}

Just got to do the binary patch for HGOF .... Then ready to test, would Appreciate if you could give my code a look over and let me know if you spot anything wrong. The code compiles ok.

Cheers
Jay

the comment "// call (patched) _OFF" is inaccurate. There is no "patched" _OFF since it requires no patches.

As far as your external declares, _SB is the same as _SB_ (read ACPI spec for details on name padding to 4 chars).
Probably best to stay consistent and use _SB

I didn't double check all the External paths for accuracy.
 
@RehabMan,

the comment "// call (patched) _OFF" is inaccurate. There is no "patched" _OFF since it requires no patches.

Yup i did catch that .. just a left over from the cut and paste from your guide.

I went through and double checked all of the External Reference Types and they are all Correct.
I created a Clover binary patch to rename HGOF -> XGOF and it was injected by Clover ok (in boot log) along with XINI and XREG patches, however ... The DGPU still did not power down ... additionally the battery monitor disappeared and the system would no longer sleep ???

I went through the code again, made all ACPI paths begin with _SB like you suggested but it still did not work .. I'm guessing that the battery code also uses the _REG and there is an issue with the _REG redirect.

So I went back to basics , I disabled the renames, removed SSDT-DGPU and manually patched _REG in the DSDT and HGOF in SSDT-8 and used my original SSDT-DGPU-Disable hot patch created from your old DGPU disable guide :-

Code:
DefinitionBlock ("", "SSDT", 2, "hack", "D-DGPU", 0x00000000)
{
    External (_SB_.PCI0.RP01.PEGP._OFF, MethodObj)    // 0 Arguments (from opcode)

    Device (RMD1)
    {
        Name (_HID, "RMD10000")  // _HID: Hardware ID
        Method (_INI, 0, NotSerialized)  // _INI: Initialize
        {
            If (CondRefOf (\_SB.PCI0.RP01.PEGP._OFF))
            {
                \_SB.PCI0.RP01.PEGP._OFF ()
            }
        }
    }
}

Rebooted ... no KP and no DGPU so I know the basic principle of the technique works ... finally some progress.

I've run out of time to work on this any more this week, but i will go back and try and get the hot patch working in the near future. Thank you for all your help on this .... its actually pretty basic once you boil it down.

I've attached the Final hotpatch source if you could take a quick look and see if you can spot anything i'd appreciate it.

One question though ... since HGOF resides in the ACPI path _SB.PCI0 ...i declared the Externals with that prefix included eg:-

Code:
External (_SB.PCI0.PWE0, FieldUnitObj)

However upon examining the aml in Clover/ACPI/Patched i could see that isal/MakiASL adds additional UnKnowen External Ref's:-

Code:
External (PWE0, UnkowenObj)  //  Warning ... blha blha blha

So in this instance what is correct, with or without the full path, my guess is that both are correct as long as the code is in the correct scope but i could be wrong.

Cheers
Jay

EDIT: 29-06-2018 Removed depreciated PR Files
 
Last edited:
I've attached the Final hotpatch source if you could take a quick look and see if you can spot anything i'd appreciate it.

To debug it, I would need to see PR files.
 
Status
Not open for further replies.
Back
Top