[翻译] (黑苹果)笔记本电脑原生电源管理指南 [Guide] Native Power Management for Laptops

来源:https://www.tonymacx86.com/threads/guide-native-power-management-for-laptops.175801/

Overview 概述

Power Management should be one of the first things implemented when trying to install OS X on a laptop. Because of heat/noise and battery life issues, using NullCPUPowerManagement is not a realistic option on a laptop.

若要尝试在笔记本电脑上安装 OS X, 电源管理 (Power Management) 是必须解决的首要问题之一。由于发热、噪声和电池寿命问题, 在笔记本电脑上使用 NullCPUPowerManagement 不是一个现实的选择。

Fortunately, with Clover, NullCPUPowerManagement is never needed.

幸运的是, 有了 Clover, 可以不再需要 NullCPUPowerManagement。

This guide will assume you started by following my Clover guide for laptops:
https://www.tonymacx86.com/threads/guide-booting-the-os-x-installer-on-laptops-with-clover.148093/

本指南将假设您已经阅读过我的《笔记本电脑 Clover 安装指南》, 并将在其基础上做进一步讲解。

Disable Hibernation 禁用休眠

Be aware that hibernation (suspend to disk or S4 sleep) is not supported on hackintosh.
You should disable it:

请注意, 黑苹果 (hackintosh) 不支持休眠(hibernation) (挂起到磁盘1 或 S4 睡眠), 一旦你完成安装, 就要通过如下命令禁用休眠:

sudo pmset -a hibernatemode 0
sudo rm /var/vm/sleepimage
sudo mkdir /var/vm/sleepimage

Always check your hibernatemode after updates and disable it. System updates tend to re-enable it, although the trick above (making sleepimage a directory) tends to help.

每次系统更新后, 系统都会尝试重新启用休眠, 尽管上面的办法 (将一个目录命名为与睡眠映像的相同的名字) 可能有助于解决这个问题, 但您最好还是重新检查一下系统的休眠模式并重新将其禁用。

And it may be a good idea to disable the other hibernation related options:

禁用与休眠相关的其它选项可能是个好主意:

sudo pmset -a standby 0
sudo pmset -a autopoweroff 0

Custom SSDT.aml using ssdtPRGen.sh 通过 ssdtPRGen.sh 脚本定制 SSDT.aml

Note: If you followed the guide linked above, and you have a Haswell or later CPU, there is nothing for you to do here, as CPU PM is already enabled with the plists provided by the guide. No need for ssdtPRgen.sh generated SSDT.aml with Haswell and later as the required properties are injected by Clover with config.plist/ACPI/SSDT/Generate/PluginType=true.

注: 如果您遵循上面链接给出的指南, 且使用 Haswell 或更高版本的 CPU, 则无需执行本节所述的, 使用 ssdtPRgen.sh 为 Haswell 或更高版本的 CPU生成 SSDT.aml 操作。根据指南里给出的 plists 配置, 通过设置 config.plist/ACPI/SSDT/Generate/PluginType=true , 即可注入启用 CPU PM 所必须的属性。

But for Sandy Bridge and Ivy Bridge, use the ssdtPRGen.sh script by Pike R. Alpha: https://github.com/Piker-Alpha/ssdtPRGen.sh

对于 Sandy Bridge 和 Ivy Bridge, 使用 Pike R. Alpha 制作的 ssdtPRGen.sh 脚本

Instructions for using it are provided in the README.

README 文件提供了使用说明

The generated SSDT.aml should be placed on the EFI partition at /EFI/Clover/ACPI/patched/SSDT.aml.

生成的 SSDT.aml 应放在 EFI 分区的 /EFI/Clover/ACPI/patched/SSDT.aml 上

Based on the current instructions at the README, what follows is a synopsis…

根据目前 README 的说明, 下面简要讲一下:

To prepare, you only need to do the first two commands:

准备开始前, 只需执行前两个命令:

cd ~
curl -o ./ssdtPRGen.sh https://raw.githubusercontent.com/Piker-Alpha/ssdtPRGen.sh/master/ssdtPRGen.sh
chmod +x ./ssdtPRGen.sh

With newer CPUs, you might want to use the beta branch:

对于较新的 CPU, 您可能需要使用测试版分支:

cd ~
curl -o ./ssdtPRGen.sh https://raw.githubusercontent.com/Piker-Alpha/ssdtPRGen.sh/Beta/ssdtPRGen.sh
chmod +x ./ssdtPRGen.sh

Then you can run the script:

即可运行:

./ssdtPRGen.sh

For some Ivy Bridge CPUs, you may need to use the “-w 2” or “-w 3” (non-beta branch, “-c 2” or “-c 3” for the beta branch).

对于某些 Ivy Bridge CPU, 可能需要使用 “-w 2” 或 “-w 3” (非 Beta 分支, Beta 分支使用"-c 2" 或 “-c 3”)

Note: If you have a CPU currently unsupported by the script (the Beta branch has more comprehensive data, so this is less likely with the Beta), you may have to provide the data for it.

注: 如果您的 CPU 不被当前脚本支持 (Beta 分支具有更全面的数据, 因此Beta 分支不支持的可能性较小), 则可能需要手动为脚本提供数据。

For example, using i7-4710HQ as a template for i7-4720HQ ():

如, 使用 i7-4710HQ 作为 i7-4720HQ 的模板:

./ssdtPRGen.sh -p 'i7-4710HQ' -f 2600 -turbo 3600

Please note that you typically would NOT use ssdtPRgen.sh with this CPU as config.plist/ACPI/SSDT/Generate/PluginType=true is enough for Haswell and later.

注意, config.plist/ACPI/SSDT/Generate/PluginType=true 设置适用于 Hashwell 及更高版本CPU, 此时, 通常无需使用 ssdtPRgen.sh。

By providing the name ‘i7-4710HQ’ (similar enough to i7-4720HQ), and overrides for the non-turbo and turbo frequencies, the script is successful. Eventually, it would not be necessary, provided the script is updated with the new CPUs.

脚本通过提供的名称: “i7-4710HQ” (类似于 i7-4720HQ), 并设置覆盖睿频和非睿频的频率参数值, 即可成功生成所需的文件。另外, 如果更新的脚本包含了新的 CPU 数据, 则无需提供前述的参数。

When it asks if you want to copy to /Extra just respond ‘n’. Same for opening ssdt.dsl… respond ‘n’.

当它问你是否要复制到 /Extra 或打开 ssdt.dsl 文件, 都只需输入 “n”

The results are at ~/Library/ssdtPRGen/SSDT.aml.

生成结果存放于 ~/Library/ssdtPRGen/SSDT.aml

Assuming your EFI partition is mounted at /Volumes/EFI, copy that file to EFI partition, /EFI/Clover/ACPI/patched/SSDT.aml

假设您的 EFI 分区挂载在 /Volumes/EFI 上, 将 SSDT.aml 文件复制到 EFI 分区, /EFI/Clover/ACPI/patched/ 下

cd ~
cp ~/Library/ssdtPRGen/ssdt.aml /Volumes/EFI/EFI/Clover/ACPI/patched/SSDT.aml

Testing PM 测试电源管理

After installing the custom SSDT, you should reboot and test it. Use AppleIntelInfo.kext to test it.

安装自定义 SSDT 后, 应重新启动并使用 appleltelinfo. kext 对其进行测试

Download AppleIntelInfo.kext from here: http://www.tonymacx86.com/attachments/appleintelinfo-kext-zip.196205/?temp_hash=0002086c90d343986436cd5b87e253ff

在这里下载 AppleIntelInfo.kext

DO NOT install the kext to /L/E or /S/L/E.

切勿将该kext文件安装到 /L/E 或 /S/L/E 下

Extract the kext from the ZIP, then copy it where it can be loaded:

从 ZIP 中提取 kext, 然后将其复制到可以加载的位置

cd ~/Downloads
sudo mkdir /kexts
sudo cp -R AppleIntelInfo.kext /kexts

Now load it:

现在来加载它:

sudo kextutil /kexts/AppleIntelInfo.kext

Now use your computer to do a variety of tasks, benchmarks, etc.

现在使用您的计算机来执行各种任务、基准性能测试等。

You can look at the AppleIntelInfo.kext results:

可以通过下面的代码看到 AppleIntelInfo.kext 的输出结果:

# view with page control
sudo cat /tmp/AppleIntelInfo.dat|more

Or make a copy of the file that you can load in TextEdit:

或生成一个能在 TextEdit 里面查看的文件:

# create copy of it
sudo cp /tmp/AppleIntelInfo.dat AppleIntelInfo.txt
# open in TextEdit
open AppleIntelInfo.txt

In addition, for Ivy Bridge and later (eg. Ivy, Haswell, Broadwell, Skylake, KabyLake, etc), you should run IORegistryExplorer and verify that X86PlatformPlugin is loading under the CPU0 node.

此外, Ivy Bridge 及其后面版本的 CPU (如 Ivy, Haswell, Broadwell, Skylake, KabyLake 等), 应运行 IORegistryExplorer, 检查 CPU0 节点下是否加载了 X86PlatformPlugin。

More information on Native PM is available here: http://www.tonymacx86.com/mountain-lion-desktop-support/86807-ml-native-ivy-bridge-cpu-gpu-power-management.html

有关原生 PM 的更多信息, 请参见此处

For Mavericks specific information, read here: http://www.tonymacx86.com/mavericks-desktop-support/128926-mavericks-native-cpu-igpu-power-management.html

有关 Mavericks 的具体信息, 请阅读此处

Also, read here:
https://www.tonymacx86.com/threads/macos-native-cpu-igpu-power-management.222982/

另外, 请阅读此处

Checklist 检查对照表

Here is a quick Ivy/Sandy/Haswell+ Power Management checklist.

下面是一个 Ivy/Sandy/Haswell + 电源管理(Power Management) 快速检查对照表:

  • SSDT.aml at EFI/Clover/ACPI/patched (Sandy/Ivy only)
  • config.plist/KernelAndKextPatches/AppleIntelCPUPM=true (pre-Haswell)
  • config.plist/KernelAndKextPatches/KernelPm=true (Haswell+)
  • config.plist/KernelAndKextPatches/KernelLapic=true (for those with Local APIC panic)
  • appropriate System Definition (SMBIOS) for your CPU (config.plist/SMBIOS)
  • no rollbacks of AppleACPIPlatform.kext
  • no NullCPUPowerManagement.kext (usually implies patched AppleIntelCPUPowerManagement)
  • Processor objects declared in Scope (_SB) or Scope (_PR) in DSDT (pretty rare not to have them in OEM DSDT)
  • Verify that the generated SSDT injects into the same scope as Processor declarations in DSDT (usually _PR)
  • SSDT.aml at EFI/Clover/ACPI/patched (仅限于 Sandy/Ivy)

  • config.plist/KernelAndKextPatches/AppleIntelCPUPM=true ( Haswell之前版本的 CPU )

  • config.plist/KernelAndKextPatches/KernelPm=true (Haswell及其以后的版本)

  • config.plist/KernelAndKextPatches/KernelLapic=true (用于存在本地 APIC panic)

  • 与本机 CPU 相匹配的系统定义 (config.plist/SMBIOS)

  • AppleACPIPlatform.kext 没有回滚

  • 不需要 NullCPUPowerManagement.kext (如果需要, 通常意味着还要对 AppleIntelCPUPowerManagement 进行补丁)

  • 在 DSDT 中的 _SB 或 _PR 范围内存在处理器对象(Processor objects)的声明 (非常罕见的情况下, OEM DSDT 中会没有这些东西)

  • 验证生成的 SSDT 注入内容是否与 DSDT 中的处理器对象在同一范围 (通常为 _PR)

AppleACPIPlatform and EmbeddedControl AppleACPIPlatform 和嵌入式控制

Note: For Sandy Bridge PM, it is possible to run a rollback of AppleACPIPlatform.kext but it is discouraged. Watch out for battery manager packages that include a rolled back AppleACPIPlatform.kext.

注: 对于 Sandy Bridge 的电源管理, 可以运行 AppleACPIPlatform.kext 的回滚2, 但不鼓励这样做。小心包含了 AppleACPIPlatform.kext 回滚的电池管理器包。

Note: Running stock AppleACPIPlatform.kext means any DSDT methods that manipulate EC (EmbeddedControl) registers larger than 8-bits will not work and will cause the method to fail. These methods must be patched. Access to such registers is common in DSDT battery methods. Some patches are provided at my laptop DSDT patch repository at: https://github.com/RehabMan/Laptop-DSDT-Patch

注: 运行内置的 AppleACPIPlatform.kext 意味着对位宽大于8位的 EC (嵌入式控制) 寄存器进行操作的 DSDT 方法都将失效, 且导致该操作失败。这些方法必须进行修补。在 DSDT 有关电池的方法中, 访问此类寄存器很常见。我的笔记本电脑 DSDT 补丁存储库提供了一些补丁

Note on laptops with AMD Radeon 内置 AMD Radeon 的笔记本需要注意

It is sometimes necessary to drop the MCFG table (use config.plist/ACPI/DropTables).

有时需要删除 MCFG 表 (通过 config.plist/ACPI/DropTables )

Note on older CPUs 旧型号CPU需要注意

For CPUs older than Sandy Bridge, use config.plist/Generate=true instead of custom SSDT.aml. Since that option causes Clover to generate replacement CPU SSDTs, you will also need to drop the OEM CPU related SSDTs. Usually that means setting config.plist/ACPI/SSDT/DropOem=true, although you may be able to drop the individual tables with DropTables.

对于早于 Sandy Bridge 的 CPU, 请使用 config.plist/Generate=true, 而不是自定义 SSDT.aml。由于该选项会使 Clover 生成替代的 CPU SSDT, 因此您还需要删除与 OEM CPU 相关的 SSDT. 通常这意味着虽然有可能通过 Droptable 设置丢弃特定的表, 仍要启用 config.plist/ACPI/SSDT/DropOem=true 这个设置。

Notes on DropOem=true 关于 DropOem=true 的说明

With older hardware you may need to drop OEM CPU related SSDTs (as mentioned above). Although you can drop individual tables with config.plist/ACPI/DropTables, it is easiest to drop all with config.plist/ACPI/SSDT/DropOem=true.

对于较旧的硬件, 您可能需要删除与 OEM CPU 相关的 SSDT (如上所述)。虽然您可以使用 config.plist/ACPI/DropTables 删除单个表, 但最简单的方法是使用 config.plist/ACPI/SSDT/DropOem=true 设置将它们全部删除。

With modern hardware (Haswell and later), the system almost always works better if you retain all the SSDTs. The newer systems may even have trouble booting if you eliminate them.

使用现代硬件 (Hasswell 及更高版本), 如果您保留所有 SSDT, 系统几乎总是能更好地工作。如果您删除了 SSDT, 较新的系统甚至可能无法启动。

As a result, don’t use DropOem=true unless you have to. It is needed on certain computers Sandy Bridge and older.

综上, 若非必要(搭载 Sandy Bridge 或更老的 CPU 型号的计算机), 则不要使用 DropOem=true 设置。

More information regarding DropOem is available in the ACPI patching guide:https://www.tonymacx86.com/threads/guide-patching-laptop-dsdt-ssdts.152573/

有关 DropOem 的更多信息, 请参见ACPI 修补指南

XCPM only (not so experimental anymore,… it is proven to work) 仅 XCPM (不再是那么实验性的…它被证明是有效的)

If you have a computer with Haswell or later (eg. Haswell, Broadwell, Skylake, KabyLake, etc), you can use a simpler method that does not involve ssdtPRgen.sh. Since power management is in the kernel (XCPM), it appears the custom tables generated by ssdtPRgen.sh are not needed. But we still need X86PlatformPlugin to load.

如果你有一台搭载 Haswell 或更新型号 CPU 的电脑 (如 Haswell, Broadwell, Skylake, KabyLake 等), 你可以使用一个不涉及 ssdtPRgen.sh 的更简单的方法。由于电源管理在内核 (XCPM) 中, 因此似乎不需要 ssdtPRgen.sh 生成的自定义表。但我们仍然需要加载 X86PlatformPlugin。

In order to do that we only need an SSDT that will inject the “plugin-type” property (“plugin-type”=1). The SSDT is available in my hotpatch repo here: https://github.com/RehabMan/OS-X-Clover-Laptop-Config (hotpatch/SSDT-XCPM.dsl).

为了做到这一点, 我们只需要一个能够注入 “plugin-type” 属性的 SSDT (“plugin-type”=1)。这样的 SSDT可在我的 hotpatch 存储库中找到.

Direct link: https://raw.githubusercontent.com/RehabMan/OS-X-Clover-Laptop-Config/master/hotpatch/SSDT-XCPM.dsl

直接链接

The contents of it are simple:

里面的内容很简单:

// Inject plugin-type=1 on _PR.CPU0
// This is experimental to see how only injecting plugin-type with native CPU PM SSDTs
// works on various platforms.
//
// Results: OK on Haswell+, not so good on Ivy
DefinitionBlock("", "SSDT", 2, "hack", "PluginType", 0)
{
    External(\_PR.CPU0, DeviceObj)
    Method (\_PR.CPU0._DSM, 4)
    {
        If (!Arg2) { Return (Buffer() { 0x03 } ) }
        Return (Package()
        {
            "plugin-type", 1
        })
    }
}
//EOF

To use it, compile it as AML in MaciASL, then copy to your EFI/Clover/ACPI/patched.

若要使用它, 请用 MaciASL 将其编译为 AML 文件, 然后把它复制到 EFI/Clover/ACPI/patched

For example, in Terminal (assuming you have iasl installed):

例如, 在终端中 (假设您已安装 iasl):

# download SSDT-XCPM.dsl and compile it as SSDT-XCPM.aml
curl -o ./SSDT-XCPM.dsl https://raw.githubusercontent.com/RehabMan/OS-X-Clover-Laptop-Config/master/hotpatch/SSDT-XCPM.dsl
iasl SSDT-XCPM.dsl
# not valid to use both SSDT.aml and SSDT-XCPM.aml, so remove it
rm /Volumes/EFI/EFI/Clover/ACPI/patched/SSDT.aml
cp SSDT-XCPM.aml /Volumes/EFI/EFI/Clover/ACPI/patched/SSDT-XCPM.aml

For those using my fork of Clover (https://github.com/RehabMan/Clover), you can simply set config.plist/ACPI/SSDT/Generate/PluginType=true), as shown here:

如果您使用的是我创建的 Clover 分支, 则只需像下图一样简单设置 config.plist/ACPI/SSDT/Generate/PluginType=true, 即可使用。
PluginType=true

Testing and verification is the same was when using SSDT.aml generated from ssdtPRgen.sh.

测试和验证方法与使用 ssdtPRgen.sh 生成的 SSDT.aml 相同

The config.plist/ACPI/SSDT/Generate/PluginType=true setting is already set on all applicable plists as linked from my Clover laptop guide: https://www.tonymacx86.com/threads/guide-booting-the-os-x-installer-on-laptops-with-clover.148093/

通过 config.plist/ACPI/SSDT/Generate/PluginType=true, 会像 我的 《Clover 笔记本安装指南》里面的 plists 一样, 设置好全部恰当的值

Experimental option for Skylake/Kaby Lake (and later): HWP Skylake/Kaby Lake及更高版本的实验选项: HWP

In Skylake CPUs, Intel introduced a new power management technology: SpeedShift (aka. SST, aka. HWP).

在 Skylake CPU 中, 英特尔推出了一种新的电源管理技术: SpeedShift (又名 SST 或 HWP)。

With HWP enabled, the CPU handles pstate management by itself instead of requiring the OS to do it. The CPU itself will automatically shift to higher and lower pstates depending on CPU demand.

启用 HWP 后, CPU 将自行管理 pstate , 而不是要求操作系统执行此操作。根据 CPU 需求, 它会自动在更高或更低的 pstate 状态之间切换。

In order to use HWP, use an SMBIOS that is enabled for HWP… currently MacBook9,1, MacBookPro13,x (and now MacBookPro14,x, MacBookPro15,x). Also, since HWP tends to cause the xcpm_idle to be invoked, make sure the xcpm_idle patch (courtesy of PikeRAlpha) is enabled. It is default in all current plists provided by my Clover laptop guide. If you’re using older than current plists, you may have to copy the patch into your config.plist/KernelAndKextPatches/KernelToPatch section.

要使用 HWP, 请使用启用了 HWP 的 SMBIOS…目前为 MacBook9,1, MacBookPro13,x (现为 MacBookPro14,x, MacBookPro15,x)。此外, 由于 HWP 会调用 xcpm_idle, 请确保启用了 xcpm_idle 补丁 (由 PikeRAlpha 提供)。在我的《Clover 笔记本电脑指南》里提供的 plist 里是默认启用的。如果您使用的 plists 比当前的 plists要旧, 则可能需要将补丁复制到 config.plist/KernelAndKextPatches/KernelToPatch 小节中。

You can also enable HWP for other SMBIOS by creating a patched resources injector for X86PlatformPlugin.kext (or by patching the kext itself). But that is a subject for another day.

您也可以为 X86PlatformPlugin.kext (或对 kext 本身进行补丁) 创建注入补丁资源, 这样其他型号的 SMBIOS 也可以启用 HWP, 这个主题将在以后进行讨论。

Note: You still need SSDT.aml from ssdtPRgen.sh or SSDT-XCPM.aml as discussed earlier.

注: 如前所述, 您仍然需要 ssdtPRgen.sh 生成的 SSDT.aml 或 SSDT-XCPM.aml。

Problem Reporting 报告问题

Be precise about the nature of the problem.

报告问题时, 请详细而准确地描述问题及其现象

Read FAQ, “Problem Reporting”. Carefully. Attach all requested files/output.
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
Use the gen_debug.sh tool mentioned in the FAQ, that way it is less likely you’ll omit something.

仔细阅读 FAQ “报告问题” 部分并附上必要的文件和输出内容
通过 FAQ 提及的 gen_debug.sh 工具, 这样你就不太可能忽略一些东西

Last edited: Oct 10, 2018

最后更新时间:2018年10月10日


  1. 挂起到磁盘: 系统将内存及显存中的所有数据存储于硬盘中,而后自动关机。当下一次开机时,系统会自动恢复当初的工作状态。 ↩︎

  2. 表示在高版本的系统上使用低版本系统的 AppleACPIPlatform.kext ↩︎

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章