OpenCore  1.0.4
OpenCore Bootloader
1.0.4
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AppleFeatures.h
Go to the documentation of this file.
1
13#ifndef APPLE_FEATURES_H
14#define APPLE_FEATURES_H
15
16//
17// OEM Firmware Volume Information - Firmware Feature Bits.
18// These bits are exposed via APPLE_SMBIOS_TABLE_TYPE128 FirmwareFeatures,
19// and UEFI variables under gAppleVendorVariableGuid (4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14):
20// UINT32 FirmwareFeatures / FirmwareFeaturesMask.
21// UINT64 ExtendedFirmwareFeatures / ExtendedFirmwareFeaturesMask.
22//
23// nvram -x 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:FirmwareFeatures
24// nvram -x 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:FirmwareFeaturesMask
25// nvram -x 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ExtendedFirmwareFeatures
26// nvram -x 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ExtendedFirmwareFeaturesMask
27//
28// Relevant binaries (besides firmware and boot.efi) can be found with FirmwareFeatures
29// and IORegistry exposed firmware-features:
30// /usr/libexec/diskmanagementd
31// /usr/libexec/kextd
32// /usr/sbin/bless
33// /usr/sbin/kextcache
34// /System/Library/CoreServices/backupd.bundle/Contents/Resources/brtool
35// /System/Library/CoreServices/Software Update.app/Contents/MacOS/Software Update
36// /System/Library/Extensions/AppleACPIPlatform.kext/Contents/MacOS/AppleACPIPlatform
37// /System/Library/PrivateFrameworks/DiskManagement.framework/Versions/A/DiskManagement
38// /System/Library/PrivateFrameworks/FindMyMac.framework/XPCServices/com.apple.HasTRB.xpc/Contents/MacOS/com.apple.HasTRB
39// /System/Library/PrivateFrameworks/StorageKit.framework/Versions/A/Resources/storagekitd
40// /System/Library/Extensions/AppleSMBIOS.kext/Contents/MacOS/AppleSMBIOS
41// /System/Library/PreferencePanes/StartupDisk.prefPane/Contents/MacOS/StartupDisk
42// /System/Library/PrivateFrameworks/Install.framework/Frameworks/DistributionKit.framework/Versions/A/DistributionKit
43// /System/Library/PrivateFrameworks/Install.framework/Versions/A/Install
44// /System/Library/PrivateFrameworks/OSInstaller.framework/Versions/A/OSInstaller
45//
46// NOTE: There is an unconfirmed belief that Thunderbolt also has a bit.
47// NOTE: FirmwareFeatures enabling code is similar in all recent firmware, T2 and not:
48// VOID SetPlatformFeatures (VOID) {
49// UINT64 Mask = 0xFF1FFF3FU; /* Model dependent */
50// UINT64 Features = 0xFC07E136U; /* Model dependent */
51// UINT32 SecurityPolicy;
52// APPLE_PLATFORM_SECURITY_POLICY_PROTOCOL *Policy;
53// if (!EFI_ERROR (gBS->LocateProtocol(&gApplePlatformSecurityPolicyProtocolGuid, NULL, (VOID **) &Policy))
54// && (!EFI_ERROR (Policy->GetSecurityPolicy(Policy, &SecurityPolicy)))) {
55// if (SecurityPolicy & 1) Features |= 0x400U;
56// if (SecurityPolicy & 2) Features |= 0x800U;
57// Features |= 0x1000000U;
58// }
59// Features = ((*(UINT64 *)(0xFFFFFF80) != 0x4E15E2F599858AC6ULL) << 12U) | Features & 0xFFFFFFFFFFFFEFFFULL;
60// if (!EFI_ERROR (gRT->SetVariable(L"FirmwareFeaturesMask", &gAppleVendorVariableGuid, 6, sizeof (UINT32), &Mask)))
61// gRT->SetVariable(L"FirmwareFeatures", &gAppleVendorVariableGuid, 6, sizeof (UINT32), &Features);
62// if ((Features & 0x2000000U)
63// && !EFI_ERROR (gRT->SetVariable(L"ExtendedFirmwareFeaturesMask", &gAppleVendorVariableGuid, 6, sizeof (UINT64), &Mask)))
64// gRT->SetVariable(L"ExtendedFirmwareFeatures", &gAppleVendorVariableGuid, 6, sizeof (UINT64), &Features);
65// }
66//
67
68//
69// Supports CSM module, which allows booting legacy Windows operating systems like Windows 7.
70// See: https://opensource.apple.com/source/bless/bless-166/libbless/EFI/BLSupportsLegacyMode.c.auto.html
71//
72#define FW_FEATURE_SUPPORTS_CSM_LEGACY_MODE 0x00000001U // 0
73//
74// Supports CD/DVD Drive boot via El Torito.
75//
76#define FW_FEATURE_SUPPORTS_CD_DRIVE_BOOT 0x00000002U // 1
77//
78// Supports target disk mode, normally invoked by pressing T key at start.
79// Note, AppleTamperResistantBootProtocol+6 may prohibit this.
80// See: BootPicker.
81//
82#define FW_FEATURE_SUPPORTS_TARGET_DISK_MODE 0x00000004U // 2
83#define FW_FEATURE_UNKNOWN_BIT3 0x00000008U // 3
84//
85// Supports NET boot. Read by StartupDisk.prefPane.
86// FW_FEATURE_SUPPORTS_WIRELESS also implies NET boot support.
87//
88#define FW_FEATURE_SUPPORTS_NET_BOOT 0x00000010U // 4
89//
90// Supports SlingShot recovery embedded into the firmware.
91//
92#define FW_FEATURE_SUPPORTS_SLING_SHOT 0x00000020U // 5
93#define FW_FEATURE_UNKNOWN_BIT6 0x00000040U // 6
94#define FW_FEATURE_UNKNOWN_BIT7 0x00000080U // 7
95//
96// Has Wi-Fi module and supports wireless drivers in the firmware.
97// Found in SlingShot.
98//
99#define FW_FEATURE_SUPPORTS_WIRELESS 0x00000100U // 8
100#define FW_FEATURE_UNKNOWN_BIT9 0x00000200U // 9
101//
102// Bit 0 of the ApplePlatformSecurityPolicy.
103// TODO: Explore, related to ApplePlatformInfoDatabaseProtocol.
104// Set by AppleFirmwareFeaturesProtocol.
105//
106#define FW_FEATURE_PLATFORM_SECURITY_POLICY_01 0x00000400U // 10
107//
108// Bit 1 of the ApplePlatformSecurityPolicy.
109// TODO: Explore, related to AppleTamperResistantBootProtocol.
110// Set by AppleFirmwareFeaturesProtocol.
111//
112#define FW_FEATURE_PLATFORM_SECURITY_POLICY_02 0x00000800U // 11
113//
114// Support Apple Tamper Resistant Boot, which helps FindMyMac functionality.
115// Firmware Locked bit is controlled by the same protocol which determines whether
116// firmware actually gets locked down by SPI registers at DXE start, on EFI-era Macs.
117// Firmware unlock can be triggered by pressing and holding power button at power up on
118// Mac Pro 144.0.0.0.0 firmware. Same protocol is present, but no known way to trigger
119// unlock, on similar era models such as iMac.
120// Not set on Macs with T2 via detected non APPLE_EFI_FIRMWARE_GEN3_ID_MAGIC.
121// See: /System/Library/PrivateFrameworks/FindMyMac.framework/XPCServices/com.apple.HasTRB.xpc/Contents/MacOS/com.apple.HasTRB.
122//
123#define FW_FEATURE_FIRMWARE_LOCKED 0x00001000U // 12
124#define FW_FEATURE_UNKNOWN_BIT13 0x00002000U // 13
125//
126// Supports USB 2.0 in the firmware. Found in AppleACPIPlatform.kext.
127//
128#define FW_FEATURE_SUPPORTS_HIGH_SPEED_USB 0x00004000U // 14
129#define FW_FEATURE_UNKNOWN_BIT15 0x00008000U // 15
130#define FW_FEATURE_UNKNOWN_BIT16 0x00010000U // 16
131//
132// Instructs AppleACPIPlatform.kext not to substitute certain USB ports with other ports.
133// In particular: EHC2-2 -> EHC1-3, EHC2-3 -> EHC1-4.
134//
135#define FW_FEATURE_DISABLE_USB_SUBSTITUTE_WORKAROUND 0x00020000U // 17
136#define FW_FEATURE_UNKNOWN_BIT18 0x00040000U // 18
137//
138// Supports APFS filesystem (via JumpStart or built-in driver).
139// Verified by OSInstaller.framework (apfsSupportedByROM). Either bit would do.
140//
141#define FW_FEATURE_SUPPORTS_APFS 0x00080000U // 19
142//
143// Supports APFS filesystem (unused by by any known Mac Model including Macmini7,1).
144// Verified by OSInstaller.framework (apfsSupportedByROM). Either bit would do.
145// Could be reserved for APFS Fusion Drive support, but unused even on them.
146//
147#define FW_FEATURE_SUPPORTS_APFS_EXTRA 0x00100000U // 20
148#define FW_FEATURE_UNKNOWN_BIT21 0x00200000U // 21
149//
150// Supports Apple Tamper Resistant Boot X. This is supposed to be activation lock.
151// See: /System/Library/CoreServices/Language Chooser.app/Contents/MacOS/Language Chooser
152//
153#define FW_FEATURE_SUPPORTS_TRBX 0x00400000U // 22
154#define FW_FEATURE_UNKNOWN_BIT23 0x00800000U // 23
155//
156// Supports platform security policy.
157// Exposed in UEFI via gApplePlatformSecurityPolicyProtocolGuid GUID.
158// Set by gAppleFirmwareFeaturesProtocolGuid.
159//
160#define FW_FEATURE_SUPPORTS_PLATFORM_SECURITY_POLICY 0x01000000U // 24
161//
162// Supports 64-bit ExtendedFirmwareFeatures/ExtendedFirmwareFeaturesMask variables.
163// Lower 32-bits are same as FirmwareFeatures, and higher 32-bits contain new information.
164//
165#define FW_FEATURE_SUPPORTS_EXTENDED_FEATURES 0x02000000U // 25
166#define FW_FEATURE_UNKNOWN_BIT26 0x04000000U // 26
167#define FW_FEATURE_UNKNOWN_BIT27 0x08000000U // 27
168//
169// Instructs boot.efi not to adjust memory map on MacBookAir4,1 and MacBookAir4,2
170// during hibernate wake.
171//
172#define FW_FEATURE_DISABLE_MBA_S4_WORKAROUND 0x10000000U // 28
173//
174// Supports Windows UEFI boot (Windows 8 and newer).
175// Also known as UEFIWindowsBootCapable variable.
176// DMIsPreBootEnvironmentUEFIWindowsBootCapable
177//
178#define FW_FEATURE_SUPPORTS_UEFI_WINDOWS_BOOT 0x20000000U // 29
179#define FW_FEATURE_UNKNOWN_BIT30 0x40000000U // 30
180//
181// Instructs boot.efi not to adjust memory map based on AcpiGlobalVariable->AcpiBootScriptTable.
182// See: https://github.com/Piker-Alpha/macosxbootloader/blob/1abba11e3b792dd29c2a08c410c122efd1d19e98/src/boot/AcpiUtils.cpp#L152
183//
184#define FW_FEATURE_DISABLE_BOOTSCRIPT_WORKAROUND 0x80000000U // 31
185//
186// Supports large BaseSystem. Checked by patchd. Required by macOS 12.
187//
188#define FW_FEATURE_SUPPORTS_LARGE_BASESYSTEM 0x800000000U // 35
189
190//
191// OEM Platform Feature Information - Platform feature bits
192// These bits are exposed via APPLE_SMBIOS_TABLE_TYPE133 FirmwareFeatures:
193// UINT64 PlatformFeature.
194//
195// Ref: https://github.com/al3xtjames/AppleSystemInfo/blob/master/src/util/dump_features.c
196//
197// Relevant binaries can be found with IORegistry exposed firmware-features
198// and AppleSystemInfo ASI_IsPlatformFeatureEnabled function:
199// /System/Library/Extensions/AppleACPIPlatform.kext/Contents/PlugIns/AppleACPIEC.kext/Contents/MacOS/AppleACPIEC
200// /System/Library/Extensions/AppleSMBIOS.kext/Contents/MacOS/AppleSMBIOS
201// /System/Library/PrivateFrameworks/AppleSystemInfo.framework/Versions/A/AppleSystemInfo
202// /System/Library/PrivateFrameworks/NeutrinoCore.framework/Versions/A/NeutrinoCore
203// /System/Library/PrivateFrameworks/PhotoLibraryPrivate.framework/Versions/A/Frameworks/PAImaging.framework/Versions/A/PAImaging
204// /System/Library/CoreServices/PowerChime.app/Contents/MacOS/PowerChime
205// /System/Library/SystemProfiler/SPMemoryReporter.spreporter/Contents/MacOS/SPMemoryReporter
206//
207
208#define PT_FEATURE_UNKNOWN_BIT0 0x00000001U // 0
209//
210// Has not replaceable system memory (RAM).
211//
212#define PT_FEATURE_HAS_SOLDERED_SYSTEM_MEMORY 0x00000002U // 1
213//
214// Has headless (connector-less) GPU present.
215//
216#define PT_FEATURE_HAS_HEADLESS_GPU 0x00000004U // 2
217//
218// Supports host power management.
219//
220#define PT_FEATURE_SUPPORTS_HOST_PM 0x00000008U // 3
221//
222// Supports Power Chime sound at boot.
223//
224#define PT_FEATURE_SUPPORTS_POWER_CHIME 0x00000010U // 4
225#define PT_FEATURE_UNKNOWN_BIT5 0x00000020U // 5
226#define PT_FEATURE_UNKNOWN_BIT6 0x00000040U // 6
227#define PT_FEATURE_UNKNOWN_BIT7 0x00000080U // 7
228#define PT_FEATURE_UNKNOWN_BIT8 0x00000100U // 8
229#define PT_FEATURE_UNKNOWN_BIT9 0x00000200U // 9
230#define PT_FEATURE_UNKNOWN_BIT10 0x00000400U // 10
231#define PT_FEATURE_UNKNOWN_BIT11 0x00000800U // 11
232#define PT_FEATURE_UNKNOWN_BIT12 0x00001000U // 12
233#define PT_FEATURE_UNKNOWN_BIT13 0x00002000U // 13
234#define PT_FEATURE_UNKNOWN_BIT14 0x00004000U // 14
235#define PT_FEATURE_UNKNOWN_BIT15 0x00008000U // 15
236#define PT_FEATURE_UNKNOWN_BIT16 0x00010000U // 16
237#define PT_FEATURE_UNKNOWN_BIT17 0x00020000U // 17
238#define PT_FEATURE_UNKNOWN_BIT18 0x00040000U // 18
239#define PT_FEATURE_UNKNOWN_BIT19 0x00080000U // 19
240#define PT_FEATURE_UNKNOWN_BIT20 0x00100000U // 20
241#define PT_FEATURE_UNKNOWN_BIT21 0x00200000U // 21
242#define PT_FEATURE_UNKNOWN_BIT22 0x00400000U // 22
243#define PT_FEATURE_UNKNOWN_BIT23 0x00800000U // 23
244#define PT_FEATURE_UNKNOWN_BIT24 0x01000000U // 24
245#define PT_FEATURE_UNKNOWN_BIT25 0x02000000U // 25
246#define PT_FEATURE_UNKNOWN_BIT26 0x04000000U // 26
247#define PT_FEATURE_UNKNOWN_BIT27 0x08000000U // 27
248#define PT_FEATURE_UNKNOWN_BIT28 0x10000000U // 28
249#define PT_FEATURE_UNKNOWN_BIT29 0x20000000U // 29
250#define PT_FEATURE_UNKNOWN_BIT30 0x40000000U // 30
251#define PT_FEATURE_UNKNOWN_BIT31 0x80000000U // 31
252
253//
254// EfiBoot Feature Bits.
255// These bits are not exposed usually and are internal to EfiBoot,
256// but can be used in patches and analysis.
257//
258
259//
260// Safe mode, enabled with -x boot argument or Shift hotkey.
261// Disables EB_FEATURE_ASLR.
262//
263#define EB_FEATURE_SAFE_MODE 0x00000001U
264//
265// Verbose mode, enabled with -v boot argument or Cmd+V hotkey.
266//
267#define EB_FEATURE_VERBOSE 0x00000002U
268#define EB_FEATURE_NETBOOT 0x00000004U
269#define EB_FEATURE_ALT_KERNEL 0x00000008U
270//
271// Single user mode, enabled with -s boot argument or Cmd+S hotkey.
272// Disallowed when Secure Boot is enabled.
273//
274#define EB_FEATURE_SINGLE_USER 0x00000010U
275//
276// Graphics boot (with Apple log).
277// Disabled via missing GOP and -v.
278//
279#define EB_FEATURE_GRAPHICS_MODE 0x00000020U
280#define EB_FEATURE_FIRMWARE_PASSWORD 0x00000040U
281#define EB_FEATURE_DEBUG 0x00000080U
282//
283// Core Storage boot
284//
285#define EB_FEATURE_BOOT_IS_NOT_ROOT 0x00000100U
286//
287// Boot (or wake) with FileVault 2 enabled.
288//
289#define EB_FEATURE_HAS_FILE_VAULT2_CONFIG 0x00000200U
290#define EB_FEATURE_X 0x00000400U
291//
292// Recovery OS boot, triggered via NVRAM recovery-boot-mode as well.
293//
294#define EB_FEATURE_EFI_NVRAM_RECOVERY_BOOT_MODE 0x00000800U
295#define EB_FEATURE_FROM_RECOVER_BOOT_DIRECTORY 0x00001000U
296//
297// Hibernate-wake.
298//
299#define EB_FEATURE_WAKE_FROM_HIBERNATION 0x00002000U
300//
301// Generate random KASLR slide.
302//
303#define EB_FEATURE_KASLR_SLIDE 0x00004000U
304#define EB_FEATURE_SKIP_BOARD_ID_CHECK 0x00008000U
305#define EB_FEATURE_SKIP_PANIC_DIALOG 0x00010000U
306//
307// #[EB.B.MN|BM:+FD]
308//
309#define EB_FEATURE_FD 0x00020000U
310//
311// Well, probably...
312//
313#define EB_FEATURE_APFS_VOLUME_BOOT 0x00080000U
314//
315// Apple Secure Boot enabled configuration (detected via proto & policy).
316// 24B73556-2197-4702-82A8-3E1337DAFBF2 GUID.
317//
318#define EB_FEATURE_HAS_APPLE_SECURE_BOOT 0x00200000U
319//
320// Apple Trusted Boot enabled configuration (detected via proto & policy).
321// Some unfinished(?) variant of Secure Boot found in preview firmware.
322// 24B73556-2197-4702-82A8-3E1337DAFBF3 GUID.
323//
324#define EB_FEATURE_HAS_APPLE_TRUSTED_BOOT 0x01000000U
325
326#endif // APPLE_FEATURES_H