Contribute
Register

[Guide] How to patch DSDT for working battery status

Please test with the "Lenovo y580" patch already in the repo. I believe it is equivalent to your patch.

It seems that it does the same things with other methods...the registers where it act are the same...
 
It seems that it does the same things with other methods...the registers where it act are the same...

Not strange. Just different. The patch was created before I wrote the RECB/WECB methods.
 
You need to patch each case correctly. Work on them one one at a time. Make sure you run through the example DSDT first.

The error indicates you're trying to access and identifier that doesn't exist.

Ok, now I've solved this problem, battery status appeared, but shows 0%. In process of patching I've noticed, that this patch:
Code:
into device label H_EC code_regex (BDN0,)\s+(56) replace_matched begin BDNX,%2,//%1%2 end;
into device label H_EC code_regex (BDN1,)\s+(56) replace_matched begin BDNY,%2,//%1%2 end;
into device label H_EC code_regex (BCT0,)\s+(128) replace_matched begin BCTX,%2,//%1%2 end;
into device label H_EC code_regex (BCT1,)\s+(128) replace_matched begin BCTY,%2,//%1%2 end;
doesn't provide me DSDT code which looks like this one:
Code:
Field (ECF2, ByteAcc, Lock, Preserve)
   {
            Offset (0x10), 
       BDN0,   56,     //!!0x10
            Offset (0x18), 
       BME0,   8, 
            Offset (0x20), 
       BMN0,   32,     //0x20
       BMN2,   8,     //0x24
       BMN4,   88,    //0x25
       BCT0,   128,     //!! 0x30
       BDN1,   56,     //!! 0x40
            Offset (0x48), 
       BME1,   8, 
            Offset (0x50), 
       BMN1,   32,     //0x50
       BMN3,   8,     //0x54
       BMN5,   88,     //0x55
       BCT1,   128,     //!!0x60
My code after that patch looks like:
Code:
Field (ECF2, ByteAcc, Lock, Preserve)
   {
            Offset (0x10), 
       BDNX,   56,     //[FONT=Verdana]BDN0,   56[/FONT]

            Offset (0x18), 
       BME0,   8, 
            Offset (0x20), 
       BMN0,   32,     //0x20
       BMN2,   8,     //0x24
       BMN4,   88,    //0x25
       BCTX,   128,     //[FONT=Verdana]BCT0,   128[/FONT]

       BDNY,   56,     //[FONT=Verdana]BDN1,   56[/FONT]

            Offset (0x48), 
       BME1,   8, 
            Offset (0x50), 
       BMN1,   32,     //0x50
       BMN3,   8,     //0x54
       BMN5,   88,     //0x55
       BCTY,   128,     //[FONT=Verdana]BCT1,   128[/FONT]
What's wrong with that?

And what shall I do with registers, which are placed like
Code:
Store (Arg3, SMW0)

Should I fix them like this?
Code:
Store (Arg3, [COLOR=#3E3E3E][FONT=Courier]B1B2([/FONT][/COLOR][COLOR=#000000][FONT=Helvetica]MW0[/FONT][/COLOR][COLOR=#3E3E3E][FONT=Courier]0,[/FONT][/COLOR][COLOR=#000000][FONT=Helvetica]MW0[/FONT][/COLOR][COLOR=#3E3E3E][FONT=Courier]1)[/FONT][/COLOR])

Are that problems the reason of 0% showing?
Native DSDT and patch are attached.
 

Attachments

  • Battery patch.txt
    11.2 KB · Views: 108
  • dsdt-origin.aml
    55 KB · Views: 95
Ok, now I've solved this problem, battery status appeared, but shows 0%. In process of patching I've noticed, that this patch:
Code:
into device label H_EC code_regex (BDN0,)\s+(56) replace_matched begin BDNX,%2,//%1%2 end;
into device label H_EC code_regex (BDN1,)\s+(56) replace_matched begin BDNY,%2,//%1%2 end;
into device label H_EC code_regex (BCT0,)\s+(128) replace_matched begin BCTX,%2,//%1%2 end;
into device label H_EC code_regex (BCT1,)\s+(128) replace_matched begin BCTY,%2,//%1%2 end;
doesn't provide me DSDT code which looks like this one:
Code:
Field (ECF2, ByteAcc, Lock, Preserve)
   {
            Offset (0x10), 
       BDN0,   56,     //!!0x10
            Offset (0x18), 
       BME0,   8, 
            Offset (0x20), 
       BMN0,   32,     //0x20
       BMN2,   8,     //0x24
       BMN4,   88,    //0x25
       BCT0,   128,     //!! 0x30
       BDN1,   56,     //!! 0x40
            Offset (0x48), 
       BME1,   8, 
            Offset (0x50), 
       BMN1,   32,     //0x50
       BMN3,   8,     //0x54
       BMN5,   88,     //0x55
       BCT1,   128,     //!!0x60
My code after that patch looks like:
Code:
Field (ECF2, ByteAcc, Lock, Preserve)
   {
            Offset (0x10), 
       BDNX,   56,     //[FONT=Verdana]BDN0,   56[/FONT]

            Offset (0x18), 
       BME0,   8, 
            Offset (0x20), 
       BMN0,   32,     //0x20
       BMN2,   8,     //0x24
       BMN4,   88,    //0x25
       BCTX,   128,     //[FONT=Verdana]BCT0,   128[/FONT]

       BDNY,   56,     //[FONT=Verdana]BDN1,   56[/FONT]

            Offset (0x48), 
       BME1,   8, 
            Offset (0x50), 
       BMN1,   32,     //0x50
       BMN3,   8,     //0x54
       BMN5,   88,     //0x55
       BCTY,   128,     //[FONT=Verdana]BCT1,   128[/FONT]
What's wrong with that?

Nothing wrong that I see.

And what shall I do with registers, which are placed like
Code:
Store (Arg3, SMW0)

Should I fix them like this?
Code:
Store (Arg3, [COLOR=#3E3E3E][FONT=Courier]B1B2([/FONT][/COLOR][COLOR=#000000][FONT=Helvetica]MW0[/FONT][/COLOR][COLOR=#3E3E3E][FONT=Courier]0,[/FONT][/COLOR][COLOR=#000000][FONT=Helvetica]MW0[/FONT][/COLOR][COLOR=#3E3E3E][FONT=Courier]1)[/FONT][/COLOR])

No.

Assuming SMW0 is 16-bit, it needs to be changed into separate Store ops.

Code:
Store(Arg3, MW00)
Store(ShiftRight(Arg3,8), MW01)

Are that problems the reason of 0% showing?

DSDT must be completely patched with all multi-byte EC access eliminated.

You can't do the job half way and expect it to work...
 
How lucky am I?! Installed the battery kext and it works without edits. Lenovo L430 for anyone interested.

Thank you so much RehabMan, if it wasn't for you Laptop Mackintosh would be a no go area

What is the output of:
Code:
kextstat|grep -y acpiplat

Just checking...
 
Hello, RehabMan!

I feel lucky becouse my DSDT only has one EmbeddedControl and it only has 8bit ones but the battery status not works so what the heck can i do?

Here is the embeddedcontrol. And i add the vanilla dsdt as an attachment.
OperationRegion (ECOR, EmbeddedControl, 0x00, 0xFF)
Field (ECOR, ByteAcc, Lock, Preserve)
{
EC00, 8,
EC01, 8,
EC02, 8,
EC03, 8,
EC04, 8,
EC05, 8,
EC06, 8,
EC07, 8,
EC08, 8,
EC09, 8,
EC10, 8,
EC11, 8,
EC12, 8,
EC13, 8,
EC14, 8,
EC15, 8,
EC16, 8,
EC17, 8,
EC18, 8,
EC19, 8,
EC20, 8,
EC21, 8,
EC22, 8,
EC23, 8,
EC24, 8,
EC25, 8,
EC26, 8,
EC27, 8,
EC28, 8,
EC29, 8,
EC30, 8,
EC31, 8,
EC32, 8,
EC33, 8,
EC34, 8,
EC35, 8,
EC36, 8,
EC37, 8,
EC38, 8,
EC39, 8,
EC40, 8,
EC41, 8,
EC42, 8,
EC43, 8,
EC44, 8,
EC45, 8,
EC46, 8,
EC47, 8,
EC48, 8,
EC49, 8
}
 

Attachments

  • DSDT.rar
    23.9 KB · Views: 52
Hello, RehabMan!

I feel lucky becouse my DSDT only has one EmbeddedControl and it only has 8bit ones but the battery status not works so what the heck can i do?

...

Did you install ACPIBatteryManager.kext? Did you apply "Fix Mutex with non-zero SyncLevel" (because your DSDT has them).
 
Thanks! Installed kext and applied the patch and my battery status works just fine but i just wondered if is there a way to make this work without the kext?
 
Back
Top