Jump to content

Lenovo ThinkPad T420 with UEFI Only


K0gen
 Share

5,282 posts in this topic

Recommended Posts

@tluck I don't know why it didn't work for you. The patch works for me (UEFI boot). Here's what the top of my _WAK method now looks like (based on your slightly older DSDT, not the one you posted today)

    Method (_WAK, 1, NotSerialized)
    {
        \_SI._SST (One)
        If (LOr (LLess (Arg0, One), LGreater (Arg0, 0x05)))
        {
            Store (0x03, Arg0)
        }
        If (LEqual (Arg0, 0x05))
        {
            Return (WAKI)
        }
        Store (Zero, SPS)
        Store (Zero, \_SB.PCI0.LPC.EC.HCMU)
        \_SB.PCI0.LPC.EC.EVNT (One)
        \_SB.PCI0.LPC.EC.HKEY.MHKE (One)
        \_SB.PCI0.LPC.EC.FNST ()
        UCMS (0x0D)
        Store (Zero, LIDB)
        If (LEqual (Arg0, One))
        {
            Store (\_SB.PCI0.LPC.EC.HFNI, FNID)
        }
        If (LEqual (Arg0, 0x03))
        {

Doesn't fix the mute-button-freezes-my-system issue, but it feels like progress :)

 

edit: also works with MBR boot, but the hardware volume buttons are somewhat "unresponsive" almost "sticky" after the wake-from-sleep

Link to comment
Share on other sites

Clover UEFI on T420 Guide

 

Ok ... an update to the DSDT seems to have fixed the speaker after sleep issue!

 

thanks to sot_22 and manwe150...

 

so anyway, I reposted the bundle... sorry for the 22 of you that downloaded the old one ... you may want to pull the updated zip back down.  the difference is the updated the DSDT files.

 

17-Dec-2013 - update (thanks to manwe150)

  • Updated for 10.9.1 - new AppleHDA.kext v2.5.3 patched
  • Updated Clover to b2377
  • More teaks and reversion for the DSDT and config.plist files.
  • DSDT updates to _PTS and _WAK section.
    Fixed - internal speaker works on resume from sleep - has RehabMan's mutex and  _WAK patches.
Link to comment
Share on other sites

@sot_22 et al.

 

I was having some fun with RehabMan's fix and decided to look at the disassembly of AppleACPIPlatform. If you look at the _AcpiLeaveSleepState, you'll see that Apple used to implement a more complete ACPI spec, but deleted some dead code in later versions:

So, to put the system to sleep, instead of calling { _PTS(); _GTS(); _SI._SST() } it just calls { _TTS(); _PTS() }

And, to wake the system, instead of calling { _SI._SST(); _BFS(); _WAK(); _SI._SST() } it calls { _WAK(); _TTS() }

 

_GTS and _BTF are no-ops for lenovo, so that's fine, but we were expecting a call to _SI._SST to set the LED state.

 

I'm not sure why it fails now, but it's a little hard to back out Apple's modifications just looking at the assembly.

 

Oh, and the source code for the old logic can be found online: http://doxygen.reactos.org/d7/d9f/hwsleep_8c_source.html#l00574 (which makes sense when you realize that it was written by Intel), which should making patching it to work again very much easier.

Link to comment
Share on other sites

We should be able to make a patch for this (unless someone already has)?

for example, could replace <<AppleACPIPlatform[0xac62]:  movzbl %al, %edi>>

with <<movq    %rax, -120(%rsp)>> except that the latter requires 5 bytes and the former fits in 3

 

I'm a bit of a rookie when it comes to patching binaries, so I'm not really sure where to go from here.

 

edit: The Arg0 input to the _WAK function is pointing at uninitialized stack space, which is why we want to somehow initialize it with the value in %al or %edi

Link to comment
Share on other sites

@manwe150 - 

 

so it seems on Lenovo, there are just 2 functions _PTS and _WAK.

then i looked on my real mac and i can't find a TTS method. so maybe its one or other? I just found _PTS and _WAK  - non of the other _BF or SST are on the mac

 

so as far a LEDs, i did add a call to _SST in _WAK to reset the LED upon wake.

 

what is your next post about -- you lost me in terms of what that assembly code would fix/do?

i believe the latest fix handles an odd ball arg0 value. the expected values are 1-5. So if it _WAK gets an arg0 number outside of this range, then we set to 3 (which puts into mode for wake from sleep)

 

3= sleep

4= lid sleep

5= shutdown 

 

from my MacBook Pro:

 

i presume ECSS is the sleep state - it stores when going to sleep and sets to 0 upon wak.

GP45 is about ethernet

 

    Method (_PTS, 1, NotSerialized)
    {
        Store (0x00, P80D)
        P8XH (0x00, Arg0)
        Store (Arg0, \_SB.PCI0.LPCB.EC.ECSS)
        Store (0x01, GP22)
        If (OSDW ()) {}
        Else
        {
            Store (0x01, GP45)
        }
    }
 
    Method (_WAK, 1, NotSerialized)
    {
        Store (0x01, UH2D)
        Store (0x01, UH3D)
        Store (0x01, UH4D)
        Store (0x01, UH6D)
        Store (0x01, UH7D)
        P8XH (0x00, 0x00)
        Store (0x00, \_SB.PCI0.LPCB.EC.ECSS)
        If (OSDW ()) {}
        Store (\_SB.PCI0.LPCB.EC.LSTE, LIDS)
        Store (\_SB.PCI0.LPCB.EC.RPWR, PWRS)
        PNOT ()
        Return (Package (0x02)
        {
            0x00, 
            0x00
        })
    }
}
Link to comment
Share on other sites

manwe150 great info from AppleACPIPlatform ,the more you dig the more you understand and sure its fun to know how things works inside out :)

fortunately with the dsdt edits we can make fixes and not rely on binary patching but its good to know for something that can't be done otherwise

 

tluck good you found the problem for speaker , i knew it that won't be that hard cause lenovo thinkpads have similar hardware and you said that you have a macbook pro?

 

i want to ask something about performance ...

 

I'm using an external 1680x1050 monitor with x220 (hd3000) and while the launchpad animations are smooth and fast in internal display, on external when the pages have too many icons becomes a little laggy , on all other occasions the animations are smooth 

 

BUT the response and speed feel of the os and programs is a little slower than when using the internal display, in windows the external display is as fast as the internal with no lags whatsoever.

 

*note that i'm using the external only on both win and osx with closed laptop lid for more speed from HD 3000.

 

for example the same program in windows is running with less cpu usage than the same program in osx and the fan kicks in faster in hackintosh , i tried two program examples for music, the ableton live and reason 7 demo , with the same song playing in windows i have less cpu usage and the system responds faster than macos and i thought it would be the other way around! have you notice any of this windows is performing faster with less cpu usage than macos?

 

and last i made these changes in my dsdt for os detection and hpet :

 

in    Scope (_SB)

    {
        Method (_INI, 0, NotSerialized)

 

i change windows 2006 with that :

 

                If (LOr (_OSI ("Darwin"), _OSI ("Windows 2006")))
                {
                    Store (One, WNTF)
                    Store (One, WXPF)
                    Store (Zero, WSPV)
                    Store (One, WVIS)
                }
 
 
and in Device (HPET)
 
                    Method (_STA, 0, NotSerialized)
                    {
                        If (LAnd (WNTF, LNot (WXPF)))
                        {
                            Return (Zero)
                        }
                        Else
                        {
                            Return (0x0F)
                        }
 
                        Return (Zero)
                    }
 
with that as your dsdt :  
 
                  Method (_STA, 0, NotSerialized)
                    {
                        Return (0x0F)
                    }
 

 

are these changes valid or enough for detection to work?

 

----------

 

i want to make the hackintosh fast responsive like windows and maybe that can be done with dsdt edits of that sort (acpi, hpet and better power management)

thanks all for info and sharing knowledge

 

note : right now everything works with my dsdt no problem whatsoever but to be usable for running and some heavy program other than surfing the web etc the power managment must be good like windows . maybe i search it too much but i'd like to have a same specs macbook side by side running a heavy cpu program and not notice difference in speed/feel ...

by the way the geekbench 3 score is alright :

 

[32bit]

Single-Core Score   2539

Multi-Core Score    5097

 

_______

 

edit : ok i did it that way now for os checks 

 

Insert the following right underneath the block that has all the operating system names checks and above the line If (LGreaterEqual (_REV, 0x02)).

Code:
Store (One, WNTF)
Store (One, WXPF)
Store (0x02, WSPV)
Store (One, WVIS)
Link to comment
Share on other sites

@sot_22

 

thanks for your input - right now the laptop has never run better! booting from MBR clover is very stable. sleep/wake also as good as it ever has been. on 10.8.x i had random success on sleep/wake with external disks attached.  as far as  i know the OS flags turn on/off various methods and values depending on which OS is running when they such the DSDT out of BIOS. which OSX, we provide a DSDT essentially with XP flags. i turn on H8DR which has slightly different but equivalent code paths the DSDT.

 

i am no expert here .. but here is my 2cents ... as far as performance, yeah i am not sure there is any tuning other than playing with P states. i find that a hand-made SSDT gives me a bit more juice - goes to 31x and 32x (turbo) than what clover will generate for the P-state timings. but i am no expert in this area. i tried a few tests running geek bench and xbench (just the gfx tests) on both my LCD alone and then on my 1920x1200 HP monitor (alone.) results were very similar with the LCD slightly averaging a tad higher  but not significant. the results for my box is 6650+/- 30  - LCD ran 6680 - HP ran around 6630. but there was an overlapping range.  xbench for pure gfx tests ran exactly the same aggregate of 255 for (quartx, OpenGL an GUI) on either display. 

 

my fans run at around 3500 rpm with little or no load - i.e. right now typing in web browser. and running at lowest speed 8x. i hardly ever run native windows (i run win 7 64bit via Fusion for some of video/multimedia apps that only run on PC etc). so i don't have any apples-apples comparisons.

 

@manwe150 -- thanks again for your invaluable review and insight! hope all is well in your part of the world for the upcoming holidays. 

Link to comment
Share on other sites

@sot_22 my hackintosh seems faster than my windows (plus better battery life and smoother graphics). right now my fan is running at min speed (2000rpm) while I browse the web. I think that Mac has slightly higher RAM requirements to get the most out of your CPU (I have 8GB).

 

@tluck I was investigating the problem further. Especially the claim "So if it _WAK gets an arg0 number outside of this range". In some respects we want to always set Arg0 to 3, since there are no conditions under which the new AppleACPIPlatform will call us with the correct number. However, inserting the missing instruction into the assembly turns out to be very difficult.

Link to comment
Share on other sites

@manwe150 - well i patched the _WAK method to handle bogus arg0 values based on RehabMans info ... sleep is working fine now, right? UEFI is still has random issues...

 

 
# In 10.8.5 and perhaps later versions of OS X, DSDT method _WAK
# called after resuming from S3 suspend (Sleep, or suspend to RAM),
# is called with garbage in Arg0, where it should be a value
# representing the sleep state being left (1-5).
#
# This causes problems for code in DSDT _WAK method which expects
# and checks against Arg0==3 for wake from sleep to turn on various
# devices or restore internal state to a working state.
#
# This patch adds code at the very beginning of the method to
# force an an out-of-range Arg0 to 3.
#
 
into method label _WAK code_regex ([\s\S]*) replace_matched
begin
If (LOr(LLess(Arg0,1),LGreater(Arg0,5))) { Store(3,Arg0) }\n
Link to comment
Share on other sites

tluck and Manwe150 thanks for feedback and yes benchmarks turn out alright and my fan is running at 2000rpm while not pushing the cpu (i keep in mind that x220 has smaller chassis than t420 so it might gets hotter while running intensive programs), the little slow down is happening only with external display on 1680x1050, if i lower the resolution its fast like thinkpad's lcd , anyway the battery life  is connected with the power settings everyone uses and with lenovo power manager you have more settings than macos and yes the laptop runs super with all these dsdt edits we made all this time! 

 

[ maybe the cause of this is that the display is connected with displayport to dvi adapter (i dont have a DP monitor to try it) ]

 

but i'll try clover bootloader again to see if there is a difference cause from what i remember when i changed CPU FSBFreq from 99MHz to 100MHz (i didnt find a way to change that on chameleon (bus=25 defaults to 99Mhz) ) the launchpad animation lag with many icons was fixed on external display and "about this mac" on menu bar says : Processor 2.5 Ghz istead 2.49 Ghz).

 

*i installed clover (T420_UEFI_Clover-b2377-10.8.5_10.9.1-17-Dec-2013) to my usb stick (with my dsdt and config) and boots ok , just to inform i dont have the mute button bug , the button works alright after sleep and before like with chameleon.

 

and for fun i found a bug which remains from 10.8 if anyone wants to try (try it with a mouse to not wear the laptop buttons  :) )

 

if you go with the mouse pointer to top left corner where the notification icon is on menu bar , at the icon and moving to edge start pressing/hitting the left mouse button like you playing

arcade game (very fast clicking) and after some time and a lot of notification window trys to expand and hides again as you clicking fast it gets stuck closed and it only returns if you log out and log in again  :D (it happens every time if you insist clicking...have patience lol, a video would be more revealing for sure but you'll have missed all the fun ...)

Link to comment
Share on other sites

@sot_22 

 

yeah there used be some issues with Clover and bus/clock speed but now it seems to compute/determine the right speeds for my i5-2520M. however, it does not seem to compute P-States for this cpu as well as the hand-rolled SSDT verleihnix created some time ago. so i took my laptop out the dock - removed the PCI USB3 card and other external disks and it the fan runs at 1971 RPM now.

Link to comment
Share on other sites

it seems that macos is a little picky for what hardware you connect , it must be designed/tested with proper drivers for mac or else you get incompatibility issues/high cpu usage...

 

i have this "laggy animation launchpad when many icons are in pages on external display" with chameleon too, but there is no setting to change there... now i did some testing with clover and the best setting for me is to put in config.plist :

 
<key>CPU</key>
<dict>
<key>BusSpeedkHz</key>
<string>99800</string>
        </dict>
 
with this bus speed the animation is smooth now ,
i made the changes for shutdown fix in my dsdt,
install latest rehabman fakesmc (i had slice 3.3.1) 
and tell clover not to generate P & C states 
now the thermal management changed , the fan starts more slow than before and general the behaviour is different, i think it works better , i'll stay with clover for now and see
 
the only thing that bothers me a little is that with clover even with the shutdown fixes in _PTS _WAK sometimes it doesnt shutdown completely (led on).
 
we have the same processor, i didn't look to verleihnix ssdt i'll look , for now i created a new one with script ssdtPRGen http://www22.zippyshare.com/v/82564900/file.html
 
and this is new dsdt for x220 users with fixes for shutdown / fan readings etc http://www75.zippyshare.com/v/14170159/file.html
 
excuse me if i hijack the thread with x220! this thread got big by the way and i think its the best thread for thinkpads 
Link to comment
Share on other sites

@sot_22 - the verleihnix ssdt.aml for the i5-2520M is in my zip bundle. i used have to override bus speed to get the clock to stay on course as clover was calculating really high values. so i would set to 99700. if your box works for you at 99800 then good you will run a bit faster! keep an eye on your clock. for me, clover is now computing and using these speeds (from cloverEFI boot.log):

 
9:654  0:000  Finally: Bus=99676kHz CPU=2491MHz
 

i believe the shutdown issues to be a random UEFI issue as it does not happen when i boot with chameleon or CloverEFI (MBR). i never really saw any difference in shutdowns will all the _PTR "fixes". i pulled them out now. speaker seems to work better! btw, my laptop is running a lot cooler now that i blew a huge pile of dust out the fan! 

Link to comment
Share on other sites

xmm just before now ... i put "mac" to sleep and stuck with the fan spinning! and i'm booting clover from a small fat partition with the mac partition to be mbr... with all the fixes ... just now i remembered why i was mad at clover :) , it seems to work for 20 times and then when you are like alright now i got it right it gets on you hard! , you happen to know how one can change that value of Bus in khz in chameleon ? ;) maybe another time lenovo will get uefi right but for now it seems unstable again

 

and in console when stuck :

 

12/19/13 21:51:48.593 WindowServer[95]: device_generate_desktop_screenshot: authw 0x0(0), shield 0x7fbc7b6e6f10(2001)

12/19/13 21:51:48.630 WindowServer[95]: device_generate_lock_screen_screenshot: authw 0x0(0), shield 0x7fbc7b6e6f10(2001)
 
Link to comment
Share on other sites

@sot_22

 

The entire disk or usb is either mbr or gpt. Sounds like your clover partition is on a gpt disk and such means uefi boot? To boot cloverefi the disk or usb will boot just like chameleon. Format a usb as mbr. And make it fat32. When you boot you should see it flash the word boot0. Anyway just checking to make sure how you are booting clover.

Link to comment
Share on other sites

Tettone thanks that's the latest version of the script 

 

tluck my partition is fat32 everything is alright i have not done anything wrong, just x220 lenovo uefi with clover does not go to well... i've spend many hours tweaking etc the last time and for what i see with x220 or with my dsdt clover has problems with sleep/shutdown that was the case then and from what i see now , i just dont want buggy uefi to mess with sleep/shutdown functions and to lose again days of tweaking without changing something because when one thing work and dont work random you can't fix it! (or its very very difficult) , the best would be if it wont work at all ... so i'll have it on my little fat32 partition for testing because its easy to boot chameleon (which is installed on main mac partition) just by switching inside bios the boot mode "Legacy only" or" Both-(Boot UEFI first)"

 

*tluck you boot cloverefi with Legacy setting on bios? if you can boot with that setting then i must install clover on main mac partition to try that (maybe the setting uefi on bios i have makes clover unstable)

i'll try that now

 

**** i think that was the problem... i was booting UEFI mbr and not BIOS mbr ... now it should be ok!

Link to comment
Share on other sites

Well i understand and agree with your frustration. i have made mention of these problems in my Guide and recommend CloverEFI/MBR boot.  i really like Clover - what we don't like is the Lenovo UEFI+OSX.

 

so what i do is boot from a Cruizer Fit USB instead of boot from my HD. because the BIOS tries to be clever. if the DISK is GPT then it will use EFI. if the DISK has an MBR then it looks in it to boot. without going into details here ...

 

And to keep it simple, my first disk is GPT with a PMBR (vs MBR) Note: apple Disk Utility wants to make it MBR when you add NTFS. but thats another story.

 

Anyway, to get all the benefits of Clover,  i find this workaround for UEFI and OSX to get around all the UEFI problems. it takes about 1 second longer to boot and i use a USB slot but thats ok with me.

 

there are probably other ways to get MBR/CloverEFI working off the main HD ... this is just the way i chose to do it.

 

My main HD can also boot Clover in UEFI

My main HD can also boot Windows in UEFI

 

the EFI/Clover folder from the ESP is duplicated onto the USB. I just set boot from USB as first choice in BIOS. here is my layout:

 

X is my USB.

Disk1 is my backup of Disk0

 

 

$ diskutil list

/dev/disk0

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *750.2 GB   disk0

   1:                        EFI EFI                     209.7 MB   disk0s1

   2:                  Apple_HFS OSX+                    697.7 GB   disk0s2

   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

   4:       Microsoft Basic Data C                       51.5 GB    disk0s4

/dev/disk1

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *500.1 GB   disk1

   1:                        EFI EFI                     209.7 MB   disk1s1

   2:                  Apple_HFS MyTimeMachine           228.0 GB   disk1s2

   3:                  Apple_HFS OSX                     20.1 GB    disk1s3

   4:       Microsoft Basic Data H-Backup                200.0 GB   disk1s4

   5:       Microsoft Basic Data C-                      51.5 GB    disk1s5

/dev/disk2

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:     FDisk_partition_scheme                        *16.0 GB    disk2

   1:             Windows_FAT_32 X                       16.0 GB    disk2s1

 

 

$ sudo gpt -r show disk0

       start        size  index  contents

           0           1         PMBR

           1           1         Pri GPT header

           2          32         Pri GPT table

          34           6         

          40      409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B

      409640  1362786480      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC

  1363196120     1269544      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC

  1364465664   100681728      4  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7

  1465147392        1743         

  1465149135          32         Sec GPT table

  1465149167           1         Sec GPT header

Link to comment
Share on other sites

That's a good workaround , i had GPT and then with all this lenovo uefi got back to MBR so now i dont want to reinstall windows 7 again :) maybe the next time .

 

my partitions now are :

 

/dev/disk0

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:     FDisk_partition_scheme                        *128.0 GB   disk0

   1:                 DOS_FAT_32 FAT                     418.4 MB   disk0s1

   2:                  Apple_HFS mac                     81.5 GB    disk0s2

   3:               Windows_NTFS System Reserved         104.9 MB   disk0s3

   4:               Windows_NTFS                         46.1 GB    disk0s4

/dev/disk1

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:     FDisk_partition_scheme                        *2.0 GB     disk1

   1:             Windows_FAT_32 NO NAME                 2.0 GB     disk1s1

 

/dev/disk1 is the usb (i install it on usb to try so ok i can make it permanent later)

 

and yes with ssd its a little tight in there...

 

it was nice to remember again all this stuff :) by the way clover detects 3 memory slots instead of 2 at About this Mac ... 

 

and the laggy launchpad animation is back ... bios mbr/uefi have something to do with this ,maybe some timing issue who knows .

Link to comment
Share on other sites

Intel Core i5-2540M @ 2.59 GHz


GenuineIntel Family 6 Model 42 Stepping 7


 


Section Description Score Geekbench Score Geekbench 2.4.0 Pro for Mac OS X x86 (64-bit)


5745 Mac OS X 10.8.5 (Build 12F45)


5780 Mac OS X 10.9.1 (Build 13B42)


 


Section Description Score Geekbench Score Geekbench 3.1.3 Pro for Mac OS X x86


(64-bit) 2041/4493 Mac OS X 10.8.5 (Build 12F45)


(32-bit)1887/4140 Mac OS X 10.8.5 (Build 12F45)


 


HD are difference a surely have a consequence on these results


Link to comment
Share on other sites

after i read some pages of this thread i decided to boot clover uefi again and put in dsdt timewalker75a "_PTS ,SLPE shutdown fix" which i try for the first time (without removing the TPM stuff) , for now it works so far , i'll see how that goes,

without this fix the led stays on and x220 doesn't turn off property in uefi mode (in legacy it works ok)

and Manwe150 post has useful info              #751              for on the fly patching :)

 

*** timewalker75a fix dont work for me too just had a random sleep hang ....

Link to comment
Share on other sites

@sot_22 - yeah i used to have these fixes in _PTS (SLPE bit thing) in the DSDT. However, recently I removed them as they did not seem to make any difference. with UEFI, sometimes shutdown would actually shut it all the way down with or without the "fixes". but then sometimes it didn't. with CloverEFI/MBR i don't have these at problems at all - 99.9%. in the last week with 10.9.1, I tested both UEFI and MBR without SLPE in the _PTS , it shuts down fine. i only did a few sleep tests and no difference too. and thanks for reminding me - i need to add Manwe150's trim fix to the general bundle! 

 

@tettone - your performance seems a bit low? i just ran geekbench v3 and got pretty much what is expected...

since Geekbench v3 is calibrated to 2500 for a i5-2520 (3.2 mhz) - which is what i have. since you have an i5-2540 (3.3 Mhz) you should ~ 3.3/3.2 faster! The HD should not matter as these are CPU benchmarks. I tested on a regular SATA and my hybrid - no difference.

 

I ran the test 3 times in 32-bit mode (free mode):

 

1core/2core

2503/5056

2499/5064

2504/5070

 

then if i use the P states from clover vs ssdt.aml i get a bit slower numbers - will need to investigate this further

 

2382/5065

2383/5067

2385/5054

Link to comment
Share on other sites

 Share

×
×
  • Create New...