[翻譯] (黑蘋果)筆記本電腦原生電源管理指南 [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 ↩︎

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