Contribute
Register

T440P Fixes to do before proceeding with the Guide

Status
Not open for further replies.
Implement both patches.
I created the two patches (both expected to be needed) based on existing Thinkpad data I had at hand.
Yes, after i added the #2 Patch now on his IOREG i see IGPU instead of VID (Solved)
Separate topic really. You would need ACPI files/ioreg from a machine that has discrete graphics.
the #2 patch vid to igpu fixed Brightness.
A user with the machine must go through the SSDT/UsbInjectAll guide).
Actually he is doing fine in terms of providing data but i think i found the reason why his Bluetooth & Camera "not all the ports" are not getting injected into XHC and why the Port Limit Patch looked like it didn't properly work.
Instead of HS01,HS03,HS09 etc they are named as HSP1,HSP2,HSP9 etc. which lead to USBInjectall.kext & Port Limit patch to not work, am i correct ?
Should make a change to devices HSP1-HSPE to HS01-HS0E etc example:

Comment: Change HSP to HS0
Find: 08 48 53 50
Replace: 08 48 53 30
 
Instead of HS01,HS03,HS09 etc they are named as HSP1,HSP2,HSP9 etc.

USBInjectAll.kext always uses HSxx for HS ports on XHC.
If you see something else there, it likely means USBInjectAll.kext is not installed correctly.
 
USBInjectAll.kext always uses HSxx for HS ports on XHC.
If you see something else there, it likely means USBInjectAll.kext is not installed correctly.
Ok rehabman,
USB Problems already fixed and the only thing left to do is port Battery Patch and LED Blink fix into Hotpatch.
I started to create a T440P-Battery SSDT while comparing it with your u430.
Im done already with the 8-bit & the 32-bit field.
But the problem is im stuck with the 128-bit field
for example on your u430 Diffmerge shot i see this:
u430 Diffmerge.png


While on the Diffmerge of T440p i see this:

T440p.png


i see that he added BMNX,128.//SBMN,128

But now this is where im stuck at.
Can you please land an eye into my SSDT and take a look at the diffmerge of T440P with and without the static battery patch so you can give me a clarification/hint on what to do next with the 128-bit fields.

Here is the static patch that is already present on your MaciASL Repo:
Code:
#Maintained by: RehabMan for: Laptop Patches
#battery_Lenovo-T440p.txt

# created by yekki 2014-09-18
# cleanup/finished by RehabMan 2014-09-18

# works for:
#  Lenovo T440p
#  Lenovo E540
#  Lenovo E440

# Note: This DSDT requires "Fix Mutex with non-zero SyncLevel"

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 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;

into device label EC code_regex HWAK,\s+16, replace_matched begin HWK0,8,HWK1,8, end;
into method label _L1D code_regex \(\\_SB\.PCI0\.LPC\.EC\.HWAK, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC.EC.HWK0,\\_SB.PCI0.LPC.EC.HWK1), end;

into device label EC code_regex SBRC,\s+16, replace_matched begin BR00,8,BR01,8, end;
into device label EC code_regex SBFC,\s+16, replace_matched begin BF00,8,BF01,8, end;
into device label EC code_regex SBAC,\s+16, replace_matched begin BA00,8,BA01,8, end;
into device label EC code_regex SBVO,\s+16, replace_matched begin BV00,8,BV01,8, end;
into device label EC code_regex SBBM,\s+16, replace_matched begin BB00,8,BB01,8, end;
into device label EC code_regex SBDC,\s+16, replace_matched begin BD00,8,BD01,8, end;
into device label EC code_regex SBDV,\s+16, replace_matched begin SB00,8,SB01,8, end;
into device label EC code_regex SBSN,\s+16 replace_matched begin BS00,8,BS01,8 end;

into method label GBST code_regex \(SBRC, replaceall_matched begin (B1B2(BR00,BR01), end;
into method label GBIF code_regex \(SBFC, replaceall_matched begin (B1B2(BF00,BF01), end;
into method label GBST code_regex \(SBAC, replaceall_matched begin (B1B2(BA00,BA01), end;
into method label GBST code_regex \(SBVO, replaceall_matched begin (B1B2(BV00,BV01), end;
into method label GBIF code_regex \(SBBM, replaceall_matched begin (B1B2(BB00,BB01), end;
into method label GBIF code_regex \(SBDC, replaceall_matched begin (B1B2(BD00,BD01), end;
into method label GBIT code_regex \(SBDV, replaceall_matched begin (B1B2(SB00,SB01), end;
into method label GBIT code_regex \(SBSN, replaceall_matched begin (B1B2(BS00,BS01), end;
into method label GBIF code_regex \(SBSN, replaceall_matched begin (B1B2(BS00,BS01), end;
into method label GBIF code_regex \(SBDV\) replaceall_matched begin (B1B2(SB00,SB01)) end;
into method label GBIF code_regex SBDV, replaceall_matched begin B1B2(SB00,SB01), end;

into device label EC code_regex SBCH,\s+32 replace_matched begin SH00,8,SH01,8,SH02,8,SH03,8 end;
into method label GBIF code_regex \(SBCH, replaceall_matched begin (B1B4(SH00,SH01,SH02,SH03), end;

into device label EC code_regex (SBMN,)\s+(128) replace_matched begin BMNX,%2,//%1%2 end;
into device label EC code_regex (SBDN,)\s+(128) replace_matched begin BDNX,%2,//%1%2 end;

into method label RE1B parent_label EC remove_entry;
into method label RECB parent_label EC remove_entry;
into device label EC insert
begin
Method (RE1B, 1, NotSerialized)\n
// Arg0 - offset in bytes from zero-based EC\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 GBIF code_regex \(SBMN, replaceall_matched begin (RECB(0xA0,128), end;
into method label GBIF code_regex \(SBDN, replaceall_matched begin (RECB(0xA0,128), end;
 

Attachments

  • T440P_Battery(in progress).dsl
    863 bytes · Views: 98
  • DSDT_Battery.dsl
    569 KB · Views: 109
  • DSDT_Origin.dsl
    567.4 KB · Views: 101
Ok rehabman,
USB Problems already fixed and the only thing left to do is port Battery Patch and LED Blink fix into Hotpatch.
I started to create a T440P-Battery SSDT while comparing it with your u430.
Im done already with the 8-bit & the 32-bit field.
But the problem is im stuck with the 128-bit field
for example on your u430 Diffmerge shot i see this:View attachment 276273

While on the Diffmerge of T440p i see this:

View attachment 276274

i see that he added BMNX,128.//SBMN,128

But now this is where im stuck at.

This is just a difference between old (used in my u430) and new methods for dealing with 64-bit and larger fields.
Old method was to break it into separately named fields.
New method is to eliminate the field entirely (so we can find accesses via compiler errors) and use RECB/WECB to read/write it.

Can you please land an eye into my SSDT and take a look at the diffmerge of T440P with and without the static battery patch so you can give me a clarification/hint on what to do next with the 128-bit fields.

Use RECB/WECB.
Since those methods use offsets, there is no need to declare any fields in the EC.
 
This is just a difference between old (used in my u430) and new methods for dealing with 64-bit and larger fields.
Old method was to break it into separately named fields.
New method is to eliminate the field entirely (so we can find accesses via compiler errors) and use RECB/WECB to read/write it.



Use RECB/WECB.
Since those methods use offsets, there is no need to declare any fields in the EC.
Ok i did add the mentioned methods, is there anything else necessary to add, the problem is that it's hard for me to find a hotpatch completed laptop (especially thinkPad), People still keep going for static patch...
Also "just a suggestion": it will be nice to add an example of battery hotpatch into : [Guide] Using Clover to "hotpatch" ACPI
it will help beginners a lot into this which (im aware that hotpatch is for advanced users).
I personally managed to workout everything else without much struggle, except the battery status which i didn't need on my laptops (lack of experience) + not enough examples on how to implement it.

What is the next step that i should take,added the Read/Write methods and also added external declarations (if they are correct/needed).

Here are the files:
 

Attachments

  • DSDT_Origin.dsl
    567.4 KB · Views: 83
  • T440P_Battery(in progress).dsl
    2.7 KB · Views: 88
  • DSDT_Battery.dsl
    569 KB · Views: 116
Also "just a suggestion": it will be nice to add an example of battery hotpatch into : [Guide] Using Clover to "hotpatch" ACPI

Yes... I started one, but have not had any time to finish.

I personally managed to workout everything else without much struggle, except the battery status which i didn't need on my laptops (lack of experience) + not enough examples on how to implement it.

Basic idea is this:
- use "Rename/Replace" pattern to replace the battery methods with patched methods.
- create a separate EC "overlay" that has all the patched EC fields required (at the correct offsets)
- use External to reach EC fields or other identifiers that didn't need patching

Looking at your file, it looks like you still need to copy/paste the patched methods into the file.
Then it is just a matter of resolving the errors.
Then building the patch(es) to rename native methods (so the methods in the SSDT can take over).
 
Last edited:
Looking at your file, it looks like you still need to copy/paste the patched methods into the file.
If im correct i think the DSDT only contains these 2 methods that have patching (refering from Diffmerge)
Are you also refering to these ?
Code:
Method (GBIF, 3, NotSerialized)
                    {
                        Acquire (BATM, 0xFFFF)
                        If (Arg2)
                        {
                            Or (Arg0, 0x01, HIID)
                            Store (B1B2(BB00,BB01), Local7)
                            ShiftRight (Local7, 0x0F, Local7)
                            XOr (Local7, 0x01, Index (Arg1, 0x00))
                            Store (Arg0, HIID)
                            If (Local7)
                            {
                                Multiply (B1B2(BF00,BF01), 0x0A, Local1)
                            }
                            Else
                            {
                                Store (B1B2(BF00,BF01), Local1)
                            }

                            Store (Local1, Index (Arg1, 0x02))
                            Or (Arg0, 0x02, HIID)
                            If (Local7)
                            {
                                Multiply (B1B2(BD00,BD01), 0x0A, Local0)
                            }
                            Else
                            {
                                Store (B1B2(BD00,BD01), Local0)
                            }

                            Store (Local0, Index (Arg1, 0x01))
                            Divide (Local1, 0x14, Local2, Index (Arg1, 0x05))
                            If (Local7)
                            {
                                Store (0xC8, Index (Arg1, 0x06))
                            }
                            ElseIf (B1B2(SB00,SB01))
                            {
                                Divide (0x00030D40, B1B2(SB00,SB01), Local2, Index (Arg1, 0x06))
                            }
                            Else
                            {
                                Store (0x00, Index (Arg1, 0x06))
                            }

                            Store (B1B2(SB00,SB01), Index (Arg1, 0x04))
                            Store (B1B2(BS00,BS01), Local0)
                            Name (SERN, Buffer (0x06)
                            {
                                "     "
                            })
                            Store (0x04, Local2)
                            While (Local0)
                            {
                                Divide (Local0, 0x0A, Local1, Local0)
                                Add (Local1, 0x30, Index (SERN, Local2))
                                Decrement (Local2)
                            }

                            Store (SERN, Index (Arg1, 0x0A))
                            Or (Arg0, 0x06, HIID)
                            Store (RECB(0xA0,128), Index (Arg1, 0x09))
                            Or (Arg0, 0x04, HIID)
                            Name (BTYP, Buffer (0x05)
                            {
                                 0x00, 0x00, 0x00, 0x00, 0x00                  
                            })
                            Store (B1B4(SH00,SH01,SH02,SH03), BTYP)
                            Store (BTYP, Index (Arg1, 0x0B))
                            Or (Arg0, 0x05, HIID)
                            Store (RECB(0xA0,128), Index (Arg1, 0x0C))
                        }
                        Else
                        {
                            Store (0xFFFFFFFF, Index (Arg1, 0x01))
                            Store (0x00, Index (Arg1, 0x05))
                            Store (0x00, Index (Arg1, 0x06))
                            Store (0xFFFFFFFF, Index (Arg1, 0x02))
                        }

                        Release (BATM)
                        Return (Arg1)

                    Method (GBST, 4, NotSerialized)
                    {
                        Acquire (BATM, 0xFFFF)
                        If (And (Arg1, 0x20))
                        {
                            Store (0x02, Local0)
                        }
                        ElseIf (And (Arg1, 0x40))
                        {
                            Store (0x01, Local0)
                        }
                        Else
                        {
                            Store (0x00, Local0)
                        }

                        If (And (Arg1, 0x07)) {}
                        Else
                        {
                            Or (Local0, 0x04, Local0)
                        }

                        If (LEqual (And (Arg1, 0x07), 0x07))
                        {
                            Store (0x04, Local0)
                            Store (0x00, Local1)
                            Store (0x00, Local2)
                            Store (0x00, Local3)
                        }
                        Else
                        {
                            Store (Arg0, HIID)
                            Store (B1B2(BV00,BV01), Local3)
                            If (Arg2)
                            {
                                Multiply (B1B2(BR00,BR01), 0x0A, Local2)
                            }
                            Else
                            {
                                Store (B1B2(BR00,BR01), Local2)
                            }

                            Store (B1B2(BA00,BA01), Local1)
                            If (LGreaterEqual (Local1, 0x8000))
                            {
                                If (And (Local0, 0x01))
                                {
                                    Subtract (0x00010000, Local1, Local1)
                                }
                                Else
                                {
                                    Store (0x00, Local1)
                                }
                            }
                            ElseIf (LNot (And (Local0, 0x02)))
                            {
                                Store (0x00, Local1)
                            }

                            If (Arg2)
                            {
                                Multiply (Local3, Local1, Local1)
                                Divide (Local1, 0x03E8, Local7, Local1)
                            }
                        }

                        Store (Local0, Index (Arg3, 0x00))
                        Store (Local1, Index (Arg3, 0x01))
                        Store (Local2, Index (Arg3, 0x02))
                        Store (Local3, Index (Arg3, 0x03))
                        Release (BATM)
                        Return (Arg3)
                    }

                    }

After pasting them into the Custom SSDT that im building i have to rename them on config.plist:
- Method GBST to XBST (no other such name found on DSDT so i think it wont cause any interference with something else)
- Rename GBIF to XBIF

After that a lot of errors are showing up which i will need some help to fix them.
- Object does not exist (HIID)
- Object does not exist (BATM)


i did add those two methods, but now i will need some help on fixing errors, Here are the new file +(the diffmerge dsdts "origin & static Patched")
Also can you confirm if the External declarations are needed for each FieldUnitObject or we only need the for those two methods above ?
 

Attachments

  • T440P_Battery(in progress).dsl
    6.8 KB · Views: 101
  • DSDT_Battery.dsl
    569 KB · Views: 96
  • DSDT_Origin.dsl
    567.4 KB · Views: 96
If im correct i think the DSDT only contains these 2 methods that have patching (refering from Diffmerge)

That's what I see... just those two methods different (it is quite minimal).

Are you also refering to these ?

I don't know what you mean by "also" in this context.
Only GBIF and GBST seem to be patched.

After pasting them into the Custom SSDT that im building i have to rename them on config.plist:
- Method GBST to XBST (no other such name found on DSDT so i think it wont cause any interference with something else)
- Rename GBIF to XBIF

Make sure you enclose them such that they are in the same scope as the original methods.

After that a lot of errors are showing up which i will need some help to fix them.
- Object does not exist (HIID)
- Object does not exist (BATM)

Use External to reach identifiers that are defined outside the SSDT.
 
Make sure you enclose them such that they are in the same scope as the original methods.
Will need more hints/example here, not sure what you mean, you mean the way i rename or ... ?
Use External to reach identifiers that are defined outside the SSDT.
After adding Externals all errors seems to be fixed,i only have 1 warning about Method Local7 not being used.

Here is the updated SSDT, what is the next required step ?
 

Attachments

  • DSDT_Origin.dsl
    567.4 KB · Views: 112
  • DSDT_Battery.dsl
    569 KB · Views: 122
  • T440P_Battery(in progress).dsl
    6.5 KB · Views: 91
Will need more hints/example here, not sure what you mean, you mean the way i rename or ... ?

Look at the Probook or U430 repos. You will see how the methods are declared such that they are injected into the correct scope.

Here is the updated SSDT, what is the next required step ?

You have GBIF and GBST in root scope, yet originally they were in _SB.PCI0.LPCB.EC.
Same goes for the EmbeddedControl region/etc.
Don't forget about patching the Mutexes with non-zero SyncLevel.
 
Status
Not open for further replies.
Back
Top