DSDT/SSDT/ROM提取编译实现笔记本电脑电池显示

从开始接触黑苹果开始,一直很想学习DSDT编译,上网爬了很多的帖子,这些帖子都不是从零开始的教程,导致自己像看天书一样,连门都摸不到,今天我以我自己笔记本电脑HP Zbook 15 G3的DSDT为列,从提取DSDT/SSDT/ROM开始,来为大家演示从零开始编译DSDT修复笔记本电脑电量显示的问题。

视频教程请移步




—————————————————————————————————————————————

windows环境提取DSDT/SSDT/ROM

1.提取DSDT
打开aida64.exe——工具——ACPI浏览器——Save DSDT——选择保存位置保存,把保存好的acpi_dsdt.bin命名为DSDT.aml。
2.提取SSDT
打开aida64.exe——工具——ACPI浏览器——Save Table——前面是SSDT开头的都要保存。保存时候文件名为SSDT.aml/SSDT-1.aml/SSDT-2.aml/SSDT-3.aml/一次类推,保存类型为ALL files(*.*)。

3.显卡rom提取
打开aida64.exe——查看——状态栏——右键状态栏——Video Debug——Video BISO Debug——文件名称随意.rom就可以。保存类型为ALL files(*.*)

Mac环境下编译

一、准备工作
1.桌面新建一个acpi文件,把DSDT/SSDT拷贝进去。
2.新建“访达”窗口——前往——前往文件夹——/usr/bin/,把iasl编译器拷贝进去
3.反编译,打开终端输入:cd Desktop/acpi回车
再输入iasl -da -dl *.aml回车
反编译成功得到文件的dsl文件
4.用MaciASL.app打开DSDT.aml,编译时注意用5.0以上编译器编译!
5.DSDT.aml打开后第一件事情不是直接修改,而是排除错误
6.点击编译,红色的是错误,要把它排除,黄色的是警告,警告请忽略!

二、除错
我的点编译以后错误有两个(每个人的可能错误不一样,其他的自己百度找解决方案吧)

错误一 syntax error, unexpected PARSEOP_INTEGER
错误解决方案
找到错误上方 0x1F,在0x1F前面//注释就好
注释前0x1F
注释后// 0x1F

错误二syntax error, unexpected PARSEOP_ARG0
错误解决方案
找到错误行上方如下代码并注释
注释前
Arg0
Arg1
Arg2
Arg3
注释后如下
/*Arg0
Arg1
Arg2
Arg3*/

三、开始编译拆分16位字段
无错误后Ctrl+A全选,Ctrl+F搜索**EmbeddedControl。
我的是OperationRegion (ECRM, EmbeddedControl, Zero, 0xFF)
每个DSDT可能会显示不一样,大致一样,只要EmbeddedControl前面的部分是EC开头的就对了!把EmbeddedControl下面16位32位的拆分。

下面是我找到要拆分16位的字段。太多了没列出来完,但是后面的补丁是全部都有的。
#CPWR, 16,
#CVLT, 16,
#CCUR, 16,
#BDC, 16,
#BFC, 16,
#BRTE, 16,
#BME, 16,
#BDV, 16,
#BCV1, 16,
#BATE, 16,
#BPR, 16,
#BCR, 16,
#BRC, 16,
#BCC, 16,
#BPV, 16,
#BCV2, 16,
#BCV3, 16,
#BCV4, 16,
#BATF, 16,
#MAXC, 16,
#BSTS, 16,
#BSN, 16,
#BDAT, 16,
#CBT, 16,
……
拆分我们用到如下补丁
into device label EC0 code_regex CPWR,\s+16, replace_matched begin DC00,8,DC01,8, end;
DC00,DC01不能重复,可自己随意!CPWR是你要拆分16位前面的字符

补丁使用方式,使用补丁是需要注意修改为你自己的字段!

into device label EC0 code_regex CPWR,\s+16, replace_matched begin DCOO,8,DCPP,8, end;

into device label EC0 code_regex CVLT,\s+16, replace_matched begin DCKK,8,DCFF,8, end;

into device label EC0 code_regex CVLT,\s+16, replace_matched begin DC04,8,DC03,8, end;

into device label EC0 code_regex CCUR,\s+16, replace_matched begin DC06,8,DC05,8, end;

into device label EC0 code_regex SCWT,\s+16, replace_matched begin DC02,8,DC07,8, end;

into device label EC0 code_regex WKTR,\s+16, replace_matched begin DC08,8,DC09,8, end;

into device label EC0 code_regex S5TR,\s+16, replace_matched begin DCMQ,8,DCMW,8, end;

into device label EC0 code_regex BDC,\s+16, replace_matched begin DCME,8,DCMR,8, end;

替换后点击编译出错了。然后会用到下面的代码。
注意看BDC,16
DCME,8,DCMR,8,

错误提示 Object does not exist (BDC_)用下面的补丁,注意看需要修改的字段

into method label GBTI code_regex \(BDC, replaceall_matched begin (B1B2(DCME,DCMR), end;

错误提示 Object does not exist (B1B2)
直接用这个就好

into method label B1B2 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B2, 2, NotSerialized)\n
{\n
Return(Or(Arg0, ShiftLeft(Arg1, 8)))\n
}\n
end;

继续
into device label EC0 code_regex BFC,\s+16, replace_matched begin DCMT,8,DCMY,8, end;

into method label BTIF code_regex \(BFC, replaceall_matched begin (B1B2(DCMT,DCMY), end;

into method label GBTI code_regex \(BFC, replaceall_matched begin (B1B2(DCMT,DCMY), end;

into method label ITLB code_regex \(BFC, replaceall_matched begin (B1B2(DCMT,DCMY), end;

into device label EC0 code_regex BRTE,\s+16, replace_matched begin DCMU,8,DCMI,8, end;

into method label GBTI code_regex \(BRTE, replaceall_matched begin (B1B2(DCMU,DCMI), end;

into device label EC0 code_regex BME,\s+16, replace_matched begin DCMO,8,DCMP,8, end;

into method label GBTI code_regex \(BME, replaceall_matched begin (B1B2(DCMO,DCMP), end;

into device label EC0 code_regex BDV,\s+16, replace_matched begin DCMD,8,DCMF,8, end;

into method label BTIF code_regex \(BDV, replaceall_matched begin (B1B2(DCMD,DCMF), end;

into method label GBTI code_regex \(BDV, replaceall_matched begin (B1B2(DCMD,DCMF), end;

into device label EC0 code_regex BCV1,\s+16, replace_matched begin DCMG,8,DCMH,8, end;

into method label GBTI code_regex \(BCV1, replaceall_matched begin (B1B2(DCMG,DCMH), end;

into device label EC0 code_regex BATE,\s+16, replace_matched begin DCMJ,8,DCMK,8, end;

into method label GBTI code_regex \(BATE, replaceall_matched begin (B1B2(DCMJ,DCMK), end;

into device label EC0 code_regex BPR,\s+16, replace_matched begin DCML,8,DCMZ,8, end;

into method label BTST code_regex \(BPR, replaceall_matched begin (B1B2(DCML,DCMZ), end;

into method label GBTI code_regex \(BPR, replaceall_matched begin (B1B2(DCML,DCMZ), end;

into device label EC0 code_regex BCR,\s+16, replace_matched begin DCMX,8,DCMC,8, end;

into method label GBTI code_regex \(BCR, replaceall_matched begin (B1B2(DCMX,DCMC), end;

into device label EC0 code_regex BRC,\s+16, replace_matched begin DCMV,8,DCMB,8, end;

into method label BTST code_regex \(BRC, replaceall_matched begin (B1B2(DCMX,DCMC), end;

into method label GBTI code_regex \(BRC, replaceall_matched begin (B1B2(DCMX,DCMC), end;

into device label EC0 code_regex BCC,\s+16, replace_matched begin DCMN,8,DCMM,8, end;

into method label GBTI code_regex \(BCC, replaceall_matched begin (B1B2(DCMN,DCMM), end;

into device label EC0 code_regex BPV,\s+16, replace_matched begin DCAQ,8,DCAW,8, end;

into method label BTST code_regex \(BPV, replaceall_matched begin (B1B2(DCMQ,DCMW), end;

into method label GBTI code_regex \(BPV, replaceall_matched begin (B1B2(DCMQ,DCMW), end;

into device label EC0 code_regex BCV2,\s+16, replace_matched begin DCAE,8,DCAR,8, end;

into method label GBTI code_regex \(BCV2, replaceall_matched begin (B1B2(DCME,DCMR), end;

into device label EC0 code_regex BCV3,\s+16, replace_matched begin DCAT,8,DCAY,8, end;

into method label GBTI code_regex \(BCV3, replaceall_matched begin (B1B2(DCMT,DCMY), end;

into device label EC0 code_regex BCV4,\s+16, replace_matched begin DCAU,8,DCAI,8, end;

into device label EC0 code_regex BCW,\s+16, replace_matched begin DCAA,8,DCAS,8, end;

into device label EC0 code_regex BCL,\s+16, replace_matched begin DCAD,8,DCAF,8, end;

into device label EC0 code_regex BATF,\s+16, replace_matched begin QQQQ,8,WWWW,8, end;

into method label GBTI code_regex \(BATF, replaceall_matched begin (B1B2(QQQQ,WWWW), end;

into device label EC0 code_regex MAXC,\s+16, replace_matched begin AXC0,8,AXC1,8, end;

into method label GBTC code_regex \(MAXC, replaceall_matched begin (B1B2(AXC0,AXC1), end;

用上面的补丁打了以后还提示Object does not exist (MAXC)错误,点击错误进去看发现错误行里都有Store,这里需要注意,我用了如下补丁。

into method label SBTC code_regex Store\s\(Zero,\sMAXC\) replaceall_matched begin Store(ShiftRight(Zero,8),\\_SB.PCI0.LPCB.EC0.AXC1)\nStore(Zero, \\_SB.PCI0.LPCB.EC0.AXC0) end;

into method label SBTC code_regex Store\s\(0xFA,\sMAXC\) replaceall_matched begin Store(ShiftRight(0xFA,8),\\_SB.PCI0.LPCB.EC0.AXC1)\nStore(0xFA, \\_SB.PCI0.LPCB.EC0.AXC0) end;

into device label EC0 code_regex BSTS,\s+16, replace_matched begin DCAJ,8,DCAK,8, end;

into method label GBTI code_regex \(BSTS, replaceall_matched begin (B1B2(DCAJ,DCAK), end;

into device label EC0 code_regex BSN,\s+16, replace_matched begin DCAL,8,DCAZ,8, end;

into method label BTIF code_regex \(BSN, replaceall_matched begin (B1B2(DCAL,DCAZ), end;

into method label GBTI code_regex \(BSN, replaceall_matched begin (B1B2(DCAL,DCAZ), end;

into device label EC0 code_regex BDAT,\s+16, replace_matched begin DCAX,8,DCAC,8, end;

into method label GBTI code_regex \(BDAT, replaceall_matched begin (B1B2(DCAX,DCAC), end;

into method label BTIF code_regex \(BDAT, replaceall_matched begin (B1B2(DCAX,DCAC), end;

这里比较特殊的出错了,提示为Store (GBSS (B1B2(DCAL,DCAZ), BDAT), BTSN)我用了如下补丁

into method label GBTI code_regex BDAT\), replaceall_matched begin B1B2(DCAX, DCAC)), end;

into device label EC0 code_regex CCBQ,\s+16, replace_matched begin DCAV,8,DCAB,8, end;

into device label EC0 code_regex CBT,\s+16, replace_matched begin DCAN,8,DCAM,8, end;

into method label GBTI code_regex \(CBT, replaceall_matched begin (B1B2(DCAN,DCAM), end;

到此,16的补丁就全部拆解完成了

四、开始拆分32位的
32-bit registers
into device label EC0 code_regex PMCD,\s+32 replace_matched begin TY00,8,TY01,8,TY02,8,TY03,8 end;

如果出错就用如下补丁
fix 32-bit methods
into method label GBTI code_regex \(BTY0, replaceall_matched begin (B1B4(TY00,TY01,TY02,TY03), end;

我的32位就只有一个并且没有出错!

五、我的还用了电池显示修复的补丁,下面代码不用修改,直接打进去。
#Fix Battery 0% Status
# 10x as workaround for MaciASL bug...
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;

六、使用总结
如果你是修改你自己的电池补丁,一定要注意看修改的字节!修改好以后另存为下图

保存好以后得到DSDT.aml文件,直接拷贝到EFI-CLOVER-ACPI-patched,重启电脑就好!

所需文件下载地址

 

  iasl 26-26.png  下载地址: https://pan.baidu.com/s/1ww9lLXcu06VrY3ZJ56Wfnw
  提取件码:wi71
  AIDA64 26-26.png  下载地址: https://pan.baidu.com/s/1ugUmy7B42s_WL_Lxkb5UFQ
  提取件码:k2ak
  MaciASL.app 26-26.png  下载地址: https://pan.baidu.com/s/1nZCJlNiMUofTiaEyNtZkpA
  提取件码:h2q1
  原始DSDT_SSDT_ROM-修改好的DSDT-笔记 26-26.png  下载地址: https://pan.baidu.com/s/1sQGna9us2g6ocQqKzOkS9g
  提取件码:84wd