Jump to content
MaLd0n

HibernationFixup - Providing a sync between RTC and NVRAM

Recommended Posts

  • Administrators

An open source kernel extension providing a sync between RTC variables and NVRAM. By design the mach kernel encrypts hibernate sleepimage and writes the encryption key to variable "IOHibernateRTCVariables" in the system registry (PMRootDomain). Somehow this value has to be written into RTC (or SMC) in order the boot.efi could read it. But in case if you have to limit your RTC memory to 1 bank (128 bytes), it doesn't work: there are no any variables in SMC/NVRAM/RTC (actually FakeSMC).

Fortunately, boot.efi can read key "IOHibernateRTCVariables" from NVRAM! This kext detects entering into "hibernate" power state, reads variable IOHibernateRTCVariables from the system registry and writes it to NVRAM.

Link HERE

Features

Enables 'native' hibernation on PC's with hardware NVRAM on 10.10.5 and later. 'Native' means hibernation with encryption (standard hibernate modes 3 & 25)

Enables dumping NVRAM to file /nvram.plist before hibernation or panic

Boot-args

-hbfx-dump-nvram saves NVRAM to a file nvram.plist before hibernation and after kernel panic (with panic info)

-hbfx-disable-patch-pci disables patching of IOPCIFamily (this patch helps to avoid hang & black screen after resume (restoreMachineState won't be called for all devices)

hbfx-patch-pci=XHC,IMEI,IGPU allows to specify explicit device list (and restoreMachineState won't be called only for these devices). Also supports values none, false, off.

-hbfxdbg turns on debugging output

-hbfxbeta enables loading on unsupported osx

-hbfxoff disables kext loading

hbfx-ahbm=abhm_value controls auto-hibernation feature, where abhm_value is an arithmetic sum of respective values below:

EnableAutoHibernation = 1: If this flag is set, system will hibernate instead of regular sleep (flags below can be used to limit this behavior)

WhenLidIsClosed = 2: Auto hibernation can happen when lid is closed (if bit is not set - no matter which status lid has)

WhenExternalPowerIsDisconnected = 4: Auto hibernation can happen when external power is disconnected (if bit is not set - no matter whether it is connected)

WhenBatteryIsNotCharging = 8: Auto hibernation can happen when battery is not charging (if bit is not set - no matter whether it is charging)

WhenBatteryIsAtWarnLevel = 16: Auto hibernation can happen when battery is at warning level (macOS and battery kext are responsible for this level)

WhenBatteryAtCriticalLevel = 32: Auto hibernation can happen when battery is at critical level (macOS and battery kext are responsible for this level)

DoNotOverrideWakeUpTime = 64: Do not alter next wake up time, macOS is fully responsible for sleep maintenance dark wakes

DisableStimulusDarkWakeActivityTickle = 128: Disable power event kStimulusDarkWakeActivityTickle in kernel, so this event cannot trigger a switching from dark wake to full wake

When when IOPMPowerSource cannot detect warning or critical battery level (it happens on hackintosh), next 4 bits can be used to specify minimal capacity percent remaining value when hibernation will be forced:

RemainCapacityBit1 = 256 (1)

RemainCapacityBit2 = 512 (2)

RemainCapacityBit3 = 1024 (4)

RemainCapacityBit4 = 2048 (8)

Specified minimal capacity will be also used to put macOS into sleep/hibernate state (when the remaining capacity is less than it). 4 bits can be used to specify the battery levels from 1 to 15. Bits RemainCapacityBit1-RemainCapacityBit4 are 1,2,4,8 in percentage, so for example if you want to have 10 percent level to be the point where the laptop goes into sleep/hibernation, you would add Bits RemainCapacityBit4 and RemainCapacityBit2 which would be 2048+512=2560 (8+2=10 percent) in hbfx-ahbm. Bit EnableAutoHibernation defines a final state (sleep or hibernate).

NVRAM options

The following options can be stored in NVRAM (GUID = E09B9297-7928-4440-9AAB-D1F8536FBF0A), they can be used instead of respective boot-args

hbfx-dump-nvram - type Boolean

hbfx-disable-patch-pci - type Boolean

hbfx-patch-pci=XHC,IMEI,IGPU,none,false,off - type String

hbfx-ahbm - type Number

Dependencies

Lilu

Credits

Apple for macOS

vit9696 for Lilu.kext and great help in implementing some features

lvs1974 for writing the software and maintaining it

 

-Donations-

PayPal HERE - Stripe HERE - Ko-Fi HERE - BuyMeaCoffee HERE - Mercado Livre HERE

Skrill danielnmaldonado@gmail.com - BTC 33HeGCuCSh4tUBqdYkQqKpSDa1E7WeAJQ3 - BNB 0x10D1d656eCa00bD521f9b4A43B83098B8142e115 - USDT BSC BEP20 0xb57cfdfa371fad1981910f0e8332409ab99f74d9 - USDT TRC20 TUR6Z9AVS4AYzqPnULoHrfFvppRbhXmNbZ - KASPA kaspa:qpxzufgfj8p6r0krg58yzvs0009h2mwqgvcawa0xc2pth7sgzpv56j4f6dtvk - PicPay @danielnmaldonado - PiX @danielnmaldonado@gmail.com

Premium Users HERE - Problems with Paypal HERE

xcd5u2Y.png

Sign up for a Bybit account and claim exclusive rewards HERE

New ways to earn money with Linkvertise HERE

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.





×
  • Create New...