• Stars
    star
    371
  • Rank 115,103 (Top 3 %)
  • Language
    C++
  • License
    BSD 3-Clause "New...
  • Created over 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Lilu plugin intended to fix hibernation compatibility issues

HibernationFixup

Build Status Scan Status

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.

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

Credits

More Repositories

1

OpenCorePkg

OpenCore bootloader
C
13,029
star
2

Lilu

Arbitrary kext and process patching on macOS
C
3,585
star
3

AppleALC

Native macOS HD audio for not officially supported codecs
C++
3,439
star
4

WhateverGreen

Various patches necessary for certain ATI/AMD/Intel/Nvidia GPUs
C++
3,236
star
5

VirtualSMC

SMC emulator layer
C++
1,664
star
6

BrcmPatchRAM

C++
1,037
star
7

MaciASL

ACPI editing IDE for macOS
Objective-C
749
star
8

OcBinaryData

733
star
9

NVMeFix

C++
685
star
10

AirportBrcmFixup

An open source kernel extension providing a set of patches required for non-native Airport Broadcom Wi-Fi cards.
C++
643
star
11

MacHyperVSupport

Hyper-V integration support for macOS
C++
620
star
12

AppleSupportPkg

AppleSupportPkg - contains UEFI drivers for Apple environment support
559
star
13

CPUFriend

Dynamic macOS CPU power management data injection
C++
535
star
14

VoodooPS2

C++
513
star
15

IntelMausi

Intel Ethernet LAN driver for macOS
C
390
star
16

bugtracker

Acidanthera Bugtracker
375
star
17

FeatureUnlock

Add Sidecar support to unsupported models
C++
362
star
18

gfxutil

Device Properties conversion tool
C
274
star
19

MacInfoPkg

Mac Platform Information
249
star
20

RestrictEvents

C++
249
star
21

CpuTscSync

It is a Lilu plugin, combining functionality of VoodooTSCSync and disabling xcpm_urgency if TSC is not in sync. It should solve kernel panics after wake.
C++
171
star
22

MacKernelSDK

macOS kernel SDK targeting various XNU versions
C
167
star
23

AptioFixPkg

AptioFixPkg drivers to workaround macOS compatibility with APTIO UEFI FW
161
star
24

Shiki

Protected video playback support and hardware video acceleration on various hardware.
152
star
25

VoodooInput

Generic Multitouch Handler kernel extension for macOS
C++
151
star
26

BrightnessKeys

Handler for brightness keys without DSDT patches
C++
132
star
27

RTCMemoryFixup

open source kernel extension providing a way to emulate some offsets in your CMOS (RTC) memory
C++
97
star
28

macserial

Decode mac serial number
96
star
29

CryptexFixup

Various patches to install Rosetta Cryptex
C++
88
star
30

BT4LEContinuityFixup

72
star
31

OcSupportPkg

OpenCore common libraries
71
star
32

IOJones

Realtime I/O Registry viewer
60
star
33

DebugEnhancer

A Lilu plugin intended to enable debug output in the macOS kernel
C++
58
star
34

audk

Acidanthera UEFI Development Kit based on EDK II edk2-stable202405
C
57
star
35

dmidecode

dmidecode version with macOS specific improvements
C
40
star
36

ocbuild

Shell
39
star
37

EmeraldSDHC

SD host controller support for macOS
C++
39
star
38

OpenCoreShell

Patched UDK Shell adopted for wide firmware range
38
star
39

EfiPkg

38
star
40

UEFIGraphicsFB

UEFI framebuffer driver for macOS
C++
28
star
41

mac-efi-firmware

C
24
star
42

CpuTopologySync

Rebuild asymmetric CPU topology on macOS.
23
star
43

DuetPkg

Duet UEFI firmware emulator
15
star
44

ocmtoc

C
7
star
45

OcLegacyPkg

Legacy OpenCorePkg repository left for historical purposes
7
star