OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OpenCoreUefi.c
Go to the documentation of this file.
1
15#include <Library/OcMainLib.h>
16
17#include <Guid/AppleVariable.h>
18#include <Guid/OcVariable.h>
19#include <Guid/GlobalVariable.h>
20
21#include <Library/BaseLib.h>
22#include <Library/DevicePathLib.h>
23#include <Library/MemoryAllocationLib.h>
28#include <Library/OcAudioLib.h>
30#include <Library/OcInputLib.h>
31#include <Library/OcApfsLib.h>
37#include <Library/OcCpuLib.h>
46#include <Library/OcMiscLib.h>
47#include <Library/OcMemoryLib.h>
48#include <Library/OcRtcLib.h>
49#include <Library/OcSmcLib.h>
50#include <Library/OcOSInfoLib.h>
52#include <Library/OcPciIoLib.h>
54#include <Library/PrintLib.h>
55#include <Library/UefiBootServicesTableLib.h>
56#include <Library/UefiLib.h>
57#include <Library/UefiRuntimeServicesTableLib.h>
58
59#include <Protocol/DevicePath.h>
60#include <Protocol/GraphicsOutput.h>
61#include <Protocol/Security.h>
62#include <Protocol/Security2.h>
63#include <Protocol/SimplePointer.h>
64
65#define OC_EXIT_BOOT_SERVICES_HANDLER_MAX 5
66
70
71VOID
73 IN EFI_EVENT_NOTIFY Handler,
74 IN VOID *Context
75 )
76{
78 ASSERT (FALSE);
79 return;
80 }
81
85}
86
87VOID
89 IN OC_STORAGE_CONTEXT *Storage,
90 IN OC_GLOBAL_CONFIG *Config,
91 OUT EFI_HANDLE **DriversToConnect OPTIONAL,
92 IN BOOLEAN LoadEarly
93 )
94{
95 EFI_STATUS Status;
96 VOID *Driver;
97 UINT32 DriverSize;
98 UINT32 Index;
99 CHAR16 DriverPath[OC_STORAGE_SAFE_PATH_MAX];
100 EFI_HANDLE ImageHandle;
101 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
102 EFI_HANDLE *DriversToConnectIterator;
103 VOID *DriverBinding;
104 BOOLEAN SkipDriver;
105 OC_UEFI_DRIVER_ENTRY *DriverEntry;
106 CONST CHAR8 *DriverComment;
107 CHAR8 *DriverFileName;
108 CONST CHAR8 *DriverArguments;
109 CONST CHAR8 *UnescapedArguments;
110
111 ASSERT (!LoadEarly || DriversToConnect == NULL);
112
113 DriversToConnectIterator = NULL;
114 if (DriversToConnect != NULL) {
115 *DriversToConnect = NULL;
116 }
117
118 DEBUG ((DEBUG_INFO, "OC: Got %u drivers\n", Config->Uefi.Drivers.Count));
119
120 for (Index = 0; Index < Config->Uefi.Drivers.Count; ++Index) {
121 DriverEntry = Config->Uefi.Drivers.Values[Index];
122 DriverComment = OC_BLOB_GET (&DriverEntry->Comment);
123 DriverFileName = OC_BLOB_GET (&DriverEntry->Path);
124 DriverArguments = OC_BLOB_GET (&DriverEntry->Arguments);
125
126 SkipDriver = ( !DriverEntry->Enabled
127 || (DriverFileName == NULL)
128 || (DriverFileName[0] == '\0')
129 || (LoadEarly != DriverEntry->LoadEarly)
130 );
131
132 //
133 // Avoid showing skipped lines at early load since this can be several
134 // lines and is basically duplicate info; this also avoids too much
135 // traffic in early log, which can be problematic on some machines.
136 //
137 if (!LoadEarly || !SkipDriver) {
138 DEBUG ((
139 DEBUG_INFO,
140 "OC: Driver %a at %u (%a) is %a\n",
141 DriverFileName,
142 Index,
143 DriverComment,
144 SkipDriver ? "skipped!" : "being loaded..."
145 ));
146 }
147
148 //
149 // Skip disabled drivers.
150 //
151 if (SkipDriver) {
152 continue;
153 }
154
155 Status = OcUnicodeSafeSPrint (
156 DriverPath,
157 sizeof (DriverPath),
159 DriverFileName
160 );
161 if (EFI_ERROR (Status)) {
162 DEBUG ((
163 DEBUG_ERROR,
164 "OC: Driver %s%a does not fit path!\n",
166 DriverFileName
167 ));
168 continue;
169 }
170
171 Driver = OcStorageReadFileUnicode (Storage, DriverPath, &DriverSize);
172 if (Driver == NULL) {
173 DEBUG ((
174 DEBUG_ERROR,
175 "OC: Driver %a at %u cannot be found!\n",
176 DriverFileName,
177 Index
178 ));
179 //
180 // TODO: This should cause security violation if configured!
181 //
182 continue;
183 }
184
185 //
186 // TODO: Use AppleLoadedImage!!
187 //
188 ImageHandle = NULL;
189 Status = gBS->LoadImage (
190 FALSE,
192 NULL,
193 Driver,
194 DriverSize,
195 &ImageHandle
196 );
197 if (EFI_ERROR (Status)) {
198 DEBUG ((
199 DEBUG_ERROR,
200 "OC: Driver %a at %u cannot be loaded - %r!\n",
201 DriverFileName,
202 Index,
203 Status
204 ));
205 FreePool (Driver);
206 continue;
207 }
208
209 if ((DriverArguments != NULL) && (DriverArguments[0] != '\0')) {
210 Status = gBS->HandleProtocol (
211 ImageHandle,
213 (VOID **)&LoadedImage
214 );
215 if (EFI_ERROR (Status)) {
216 DEBUG ((
217 DEBUG_ERROR,
218 "OC: Failed to locate loaded image for driver %a at %u - %r!\n",
219 DriverFileName,
220 Index,
221 Status
222 ));
223 gBS->UnloadImage (ImageHandle);
224 FreePool (Driver);
225 continue;
226 }
227
228 UnescapedArguments = XmlUnescapeString (DriverArguments);
229 if (UnescapedArguments == NULL) {
230 DEBUG ((
231 DEBUG_ERROR,
232 "OC: Cannot unescape arguments for driver %a at %u\n",
233 DriverFileName,
234 Index
235 ));
236 gBS->UnloadImage (ImageHandle);
237 FreePool (Driver);
238 continue;
239 }
240
241 if (!OcAppendArgumentsToLoadedImage (LoadedImage, &UnescapedArguments, 1, TRUE)) {
242 DEBUG ((
243 DEBUG_ERROR,
244 "OC: Unable to apply arguments to driver %a at %u - %r!\n",
245 DriverFileName,
246 Index,
247 Status
248 ));
249 gBS->UnloadImage (ImageHandle);
250 FreePool (Driver);
251 FreePool ((CHAR8 *)UnescapedArguments);
252 continue;
253 }
254
255 FreePool ((CHAR8 *)UnescapedArguments);
256 }
257
258 Status = gBS->StartImage (
259 ImageHandle,
260 NULL,
261 NULL
262 );
263
264 if (EFI_ERROR (Status)) {
265 DEBUG ((
266 DEBUG_ERROR,
267 "OC: Driver %a at %u cannot be started - %r!\n",
268 DriverFileName,
269 Index,
270 Status
271 ));
272 gBS->UnloadImage (ImageHandle);
273 }
274
275 if (!EFI_ERROR (Status)) {
276 DEBUG ((
277 DEBUG_INFO,
278 "OC: Driver %a at %u is successfully loaded!\n",
279 DriverFileName,
280 Index
281 ));
282
283 if (DriversToConnect != NULL) {
284 Status = gBS->HandleProtocol (
285 ImageHandle,
287 (VOID **)&DriverBinding
288 );
289
290 if (!EFI_ERROR (Status)) {
291 if (*DriversToConnect == NULL) {
292 //
293 // Allocate enough entries for the drivers to connect.
294 //
295 *DriversToConnect = AllocatePool (
296 (Config->Uefi.Drivers.Count + 1 - Index) * sizeof (**DriversToConnect)
297 );
298
299 if (*DriversToConnect != NULL) {
300 DriversToConnectIterator = *DriversToConnect;
301 } else {
302 DEBUG ((DEBUG_ERROR, "OC: Failed to allocate memory for drivers to connect\n"));
303 FreePool (Driver);
304 return;
305 }
306 }
307
308 *DriversToConnectIterator = ImageHandle;
309 ++DriversToConnectIterator;
310
311 DEBUG ((
312 DEBUG_INFO,
313 "OC: Driver %a at %u needs connection.\n",
314 DriverFileName,
315 Index
316 ));
317 }
318 }
319 }
320
321 FreePool (Driver);
322 }
323
324 //
325 // Driver connection list should be null-terminated.
326 //
327 if (DriversToConnectIterator != NULL) {
328 *DriversToConnectIterator = NULL;
329 }
330}
331
332STATIC
333VOID
334EFIAPI
336 IN EFI_EVENT Event,
337 IN VOID *Context
338 )
339{
340 EFI_STATUS Status;
341 OC_GLOBAL_CONFIG *Config;
342
343 Config = (OC_GLOBAL_CONFIG *)Context;
344
345 //
346 // Printing from ExitBootServices is dangerous, as it may cause
347 // memory reallocation, which can make ExitBootServices fail.
348 // Only do that on error, which is not expected.
349 //
350
351 if (Config->Uefi.Quirks.ReleaseUsbOwnership) {
352 Status = ReleaseUsbOwnership ();
353 if (EFI_ERROR (Status)) {
354 DEBUG ((DEBUG_INFO, "OC: ReleaseUsbOwnership - %r\n", Status));
355 }
356 }
357
358 //
359 // FIXME: This is a very ugly hack for (at least) ASUS Z87-Pro.
360 // This board results in still waiting for root devices due to firmware
361 // performing some timer(?) actions in parallel to ExitBootServices.
362 // Some day we should figure out what exactly happens there.
363 // It is not the first time I face this, check AptioInputFix timer code:
364 // https://github.com/acidanthera/AptioFixPkg/blob/e54c185/Platform/AptioInputFix/Timer/AIT.c#L72-L73
365 // Roughly 5 seconds is good enough.
366 //
367 if (Config->Uefi.Quirks.ExitBootServicesDelay > 0) {
368 gBS->Stall (Config->Uefi.Quirks.ExitBootServicesDelay);
369 }
370}
371
372STATIC
373VOID
375 IN OC_GLOBAL_CONFIG *Config
376 )
377{
378 CONST CHAR8 *AppleEventMode;
379 BOOLEAN InstallAppleEvent;
380 BOOLEAN OverrideAppleEvent;
381
383 Config->Uefi.ProtocolOverrides.AppleAudio,
384 Config->Uefi.Audio.DisconnectHda
385 ) == NULL)
386 {
387 DEBUG ((DEBUG_INFO, "OC: Disabling audio in favour of firmware implementation\n"));
388 }
389
390 if (OcAppleBootPolicyInstallProtocol (Config->Uefi.ProtocolOverrides.AppleBootPolicy) == NULL) {
391 DEBUG ((DEBUG_INFO, "OC: Failed to install boot policy protocol\n"));
392 }
393
394 if (OcDataHubInstallProtocol (Config->Uefi.ProtocolOverrides.DataHub) == NULL) {
395 DEBUG ((DEBUG_INFO, "OC: Failed to install data hub protocol\n"));
396 }
397
398 if (OcDevicePathPropertyInstallProtocol (Config->Uefi.ProtocolOverrides.DeviceProperties) == NULL) {
399 DEBUG ((DEBUG_INFO, "OC: Failed to install device properties protocol\n"));
400 }
401
402 if (OcAppleImageConversionInstallProtocol (Config->Uefi.ProtocolOverrides.AppleImageConversion) == NULL) {
403 DEBUG ((DEBUG_INFO, "OC: Failed to install image conversion protocol\n"));
404 }
405
406 if (OcAppleDebugLogInstallProtocol (Config->Uefi.ProtocolOverrides.AppleDebugLog) == NULL) {
407 DEBUG ((DEBUG_INFO, "OC: Failed to install debug log protocol\n"));
408 }
409
410 if (OcSmcIoInstallProtocol (Config->Uefi.ProtocolOverrides.AppleSmcIo, Config->Misc.Security.AuthRestart) == NULL) {
411 DEBUG ((DEBUG_INFO, "OC: Failed to install smc i/o protocol\n"));
412 }
413
414 if (OcAppleUserInterfaceThemeInstallProtocol (Config->Uefi.ProtocolOverrides.AppleUserInterfaceTheme) == NULL) {
415 DEBUG ((DEBUG_INFO, "OC: Failed to install user interface theme protocol\n"));
416 }
417
418 if (OcUnicodeCollationEngInstallProtocol (Config->Uefi.ProtocolOverrides.UnicodeCollation) == NULL) {
419 DEBUG ((DEBUG_INFO, "OC: Failed to install unicode collation protocol\n"));
420 }
421
422 if (OcHashServicesInstallProtocol (Config->Uefi.ProtocolOverrides.HashServices) == NULL) {
423 DEBUG ((DEBUG_INFO, "OC: Failed to install hash services protocol\n"));
424 }
425
426 if (OcAppleKeyMapInstallProtocols (Config->Uefi.ProtocolOverrides.AppleKeyMap) == NULL) {
427 DEBUG ((DEBUG_INFO, "OC: Failed to install key map protocols\n"));
428 }
429
430 if (OcPciIoInstallProtocol (Config->Uefi.ProtocolOverrides.PciIo) == NULL) {
431 DEBUG ((DEBUG_INFO, "OC: Failed to install cpuio/pcirootbridgeio overrides\n"));
432 }
433
434 InstallAppleEvent = TRUE;
435 OverrideAppleEvent = FALSE;
436
437 AppleEventMode = OC_BLOB_GET (&Config->Uefi.AppleInput.AppleEvent);
438
439 if (AsciiStrCmp (AppleEventMode, "Auto") == 0) {
440 } else if (AsciiStrCmp (AppleEventMode, "OEM") == 0) {
441 InstallAppleEvent = FALSE;
442 } else if (AsciiStrCmp (AppleEventMode, "Builtin") == 0) {
443 OverrideAppleEvent = TRUE;
444 } else {
445 DEBUG ((DEBUG_INFO, "OC: Invalid AppleInput AppleEvent setting %a, using Auto\n", AppleEventMode));
446 }
447
449 InstallAppleEvent,
450 OverrideAppleEvent,
451 Config->Uefi.AppleInput.CustomDelays,
452 Config->Uefi.AppleInput.KeyInitialDelay,
453 Config->Uefi.AppleInput.KeySubsequentDelay,
454 Config->Uefi.AppleInput.GraphicsInputMirroring,
455 Config->Uefi.AppleInput.PointerPollMin,
456 Config->Uefi.AppleInput.PointerPollMax,
457 Config->Uefi.AppleInput.PointerPollMask,
458 Config->Uefi.AppleInput.PointerSpeedDiv,
459 Config->Uefi.AppleInput.PointerSpeedMul,
460 Config->Uefi.AppleInput.PointerDwellClickTimeout,
461 Config->Uefi.AppleInput.PointerDwellDoubleClickTimeout,
462 Config->Uefi.AppleInput.PointerDwellRadius
463 ) == NULL)
464 && InstallAppleEvent)
465 {
466 DEBUG ((DEBUG_INFO, "OC: Failed to install apple event protocol\n"));
467 }
468
469 if (OcFirmwareVolumeInstallProtocol (Config->Uefi.ProtocolOverrides.FirmwareVolume) == NULL) {
470 DEBUG ((DEBUG_INFO, "OC: Failed to install firmware volume protocol\n"));
471 }
472
473 if (OcOSInfoInstallProtocol (Config->Uefi.ProtocolOverrides.OSInfo) == NULL) {
474 DEBUG ((DEBUG_INFO, "OC: Failed to install os info protocol\n"));
475 }
476
477 if (OcAppleRtcRamInstallProtocol (Config->Uefi.ProtocolOverrides.AppleRtcRam) == NULL) {
478 DEBUG ((DEBUG_INFO, "OC: Failed to install rtc ram protocol\n"));
479 }
480
481 if (OcAppleFbInfoInstallProtocol (Config->Uefi.ProtocolOverrides.AppleFramebufferInfo) == NULL) {
482 DEBUG ((DEBUG_INFO, "OC: Failed to install fb info protocol\n"));
483 }
484
485 if (OcAppleEg2InfoInstallProtocol (Config->Uefi.ProtocolOverrides.AppleEg2Info) == NULL) {
486 DEBUG ((DEBUG_INFO, "OC: Failed to install eg2 info protocol\n"));
487 }
488}
489
490STATIC
491VOID
493 IN OC_GLOBAL_CONFIG *Config,
494 IN OC_CPU_INFO *CpuInfo
495 )
496{
497 EFI_STATUS Status;
498 APPLE_SECURE_BOOT_PROTOCOL *SecureBoot;
499 CONST CHAR8 *SecureBootModel;
500 CONST CHAR8 *RealSecureBootModel;
501 CONST CHAR8 *DmgLoading;
502 UINT8 SecureBootPolicy;
503
504 SecureBootModel = OC_BLOB_GET (&Config->Misc.Security.SecureBootModel);
505 if ((AsciiStrCmp (SecureBootModel, OC_SB_MODEL_DEFAULT) == 0) || (SecureBootModel[0] == '\0')) {
506 SecureBootModel = OcGetDefaultSecureBootModel (Config, CpuInfo);
507 }
508
509 RealSecureBootModel = OcAppleImg4GetHardwareModel (SecureBootModel);
510
511 if (AsciiStrCmp (SecureBootModel, OC_SB_MODEL_DISABLED) == 0) {
512 SecureBootPolicy = AppleImg4SbModeDisabled;
513 } else if ( (Config->Misc.Security.ApECID != 0)
514 && ( (RealSecureBootModel == NULL)
515 || (AsciiStrCmp (RealSecureBootModel, OC_SB_MODEL_LEGACY) != 0)))
516 {
517 //
518 // Note, for x86legacy it is always medium policy.
519 //
520 SecureBootPolicy = AppleImg4SbModeFull;
521 } else {
522 SecureBootPolicy = AppleImg4SbModeMedium;
523 }
524
525 //
526 // We blindly trust DMG contents after signature verification
527 // essentially skipping secure boot in this case.
528 // Do not allow enabling one but not the other.
529 //
530 if (SecureBootPolicy != AppleImg4SbModeDisabled) {
531 DmgLoading = OC_BLOB_GET (&Config->Misc.Security.DmgLoading);
532 //
533 // Check against all valid values in case more are added.
534 //
535 if ( (AsciiStrCmp (DmgLoading, "Signed") != 0)
536 && (AsciiStrCmp (DmgLoading, "Disabled") != 0)
537 && (DmgLoading[0] != '\0'))
538 {
539 DEBUG ((DEBUG_ERROR, "OC: Cannot use Secure Boot with Any DmgLoading!\n"));
540 CpuDeadLoop ();
541 return;
542 }
543 }
544
545 DEBUG ((
546 DEBUG_INFO,
547 "OC: Loading Apple Secure Boot with %a (level %u)\n",
548 SecureBootModel,
549 SecureBootPolicy
550 ));
551
552 if (SecureBootPolicy != AppleImg4SbModeDisabled) {
553 if (RealSecureBootModel == NULL) {
554 DEBUG ((DEBUG_ERROR, "OC: Failed to find SB model %a\n", SecureBootModel));
555 return;
556 }
557
558 //
559 // This is what Apple does at least.
560 // I believe no ECID is invalid for macOS 12.
561 //
562 if ( (AsciiStrCmp (RealSecureBootModel, OC_SB_MODEL_LEGACY) == 0)
563 && (Config->Misc.Security.ApECID == 0))
564 {
565 DEBUG ((DEBUG_INFO, "OC: Discovered x86legacy with zero ECID, using system-id\n"));
566 OcGetLegacySecureBootECID (Config, &Config->Misc.Security.ApECID);
567 }
568
569 //
570 // Forcibly disable single user mode in Apple Secure Boot mode.
571 // Previously EfiBoot correctly removed the -s argument from command-line,
572 // but for some reason it does not now.
573 //
574 Config->Booter.Quirks.DisableSingleUser = TRUE;
575
576 Status = OcAppleImg4BootstrapValues (RealSecureBootModel, Config->Misc.Security.ApECID);
577 if (EFI_ERROR (Status)) {
578 DEBUG ((DEBUG_ERROR, "OC: Failed to bootstrap IMG4 NVRAM values - %r\n", Status));
579 return;
580 }
581
582 Status = OcAppleSecureBootBootstrapValues (RealSecureBootModel, Config->Misc.Security.ApECID);
583 if (EFI_ERROR (Status)) {
584 DEBUG ((DEBUG_ERROR, "OC: Failed to bootstrap SB NVRAM values - %r\n", Status));
585 return;
586 }
587 }
588
589 //
590 // Provide protocols even in disabled state.
591 //
592 if (OcAppleImg4VerificationInstallProtocol (Config->Uefi.ProtocolOverrides.AppleImg4Verification) == NULL) {
593 DEBUG ((DEBUG_ERROR, "OC: Failed to install im4m protocol\n"));
594 return;
595 }
596
597 //
598 // TODO: Do we need to make Windows policy configurable?
599 //
601 Config->Uefi.ProtocolOverrides.AppleSecureBoot,
602 SecureBootPolicy,
603 0,
604 FALSE
605 );
606 if (SecureBoot == NULL) {
607 DEBUG ((DEBUG_ERROR, "OC: Failed to install secure boot protocol\n"));
608 }
609}
610
611STATIC
612EFI_STATUS
613EFIAPI
615 IN CONST EFI_SECURITY_ARCH_PROTOCOL *This,
616 IN UINT32 AuthenticationStatus,
617 IN CONST EFI_DEVICE_PATH_PROTOCOL *File
618 )
619{
620 DEBUG ((DEBUG_VERBOSE, "OC: Security V1 %u\n", AuthenticationStatus));
621 return EFI_SUCCESS;
622}
623
624STATIC
625EFI_STATUS
626EFIAPI
628 IN CONST EFI_SECURITY2_ARCH_PROTOCOL *This,
629 IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL,
630 IN VOID *FileBuffer,
631 IN UINTN FileSize,
632 IN BOOLEAN BootPolicy
633 )
634{
635 DEBUG ((DEBUG_VERBOSE, "OC: Security V2 %u\n", BootPolicy));
636 return EFI_SUCCESS;
637}
638
639STATIC
640VOID
642 VOID
643 )
644{
645 EFI_STATUS Status;
646 EFI_SECURITY_ARCH_PROTOCOL *Security;
647 EFI_SECURITY2_ARCH_PROTOCOL *Security2;
648
649 DEBUG ((DEBUG_INFO, "OC: Installing DISABLING secure boot policy overrides\n"));
650
651 Status = gBS->LocateProtocol (
652 &gEfiSecurityArchProtocolGuid,
653 NULL,
654 (VOID **)&Security
655 );
656
657 DEBUG ((DEBUG_INFO, "OC: Security arch protocol - %r\n", Status));
658
659 if (!EFI_ERROR (Status)) {
660 Security->FileAuthenticationState = OcSecurityFileAuthentication;
661 }
662
663 Status = gBS->LocateProtocol (
664 &gEfiSecurity2ArchProtocolGuid,
665 NULL,
666 (VOID **)&Security2
667 );
668
669 DEBUG ((DEBUG_INFO, "OC: Security2 arch protocol - %r\n", Status));
670
671 if (!EFI_ERROR (Status)) {
672 Security2->FileAuthentication = OcSecurity2FileAuthentication;
673 }
674}
675
676VOID
678 IN OC_GLOBAL_CONFIG *Config,
679 IN OC_CPU_INFO *CpuInfo,
680 IN UINT8 *Signature
681 )
682{
683 OC_ABC_SETTINGS AbcSettings;
684 UINT32 Index;
685 UINT32 NextIndex;
686 OC_BOOTER_PATCH_ENTRY *UserPatch;
687 OC_BOOTER_PATCH *Patch;
688
689 ZeroMem (&AbcSettings, sizeof (AbcSettings));
690
691 AbcSettings.AvoidRuntimeDefrag = Config->Booter.Quirks.AvoidRuntimeDefrag;
692 AbcSettings.DevirtualiseMmio = Config->Booter.Quirks.DevirtualiseMmio;
693 AbcSettings.DisableSingleUser = Config->Booter.Quirks.DisableSingleUser;
694 AbcSettings.DisableVariableWrite = Config->Booter.Quirks.DisableVariableWrite;
695 AbcSettings.ProtectSecureBoot = Config->Booter.Quirks.ProtectSecureBoot;
696 AbcSettings.DiscardHibernateMap = Config->Booter.Quirks.DiscardHibernateMap;
697 AbcSettings.AllowRelocationBlock = Config->Booter.Quirks.AllowRelocationBlock;
698 AbcSettings.EnableSafeModeSlide = Config->Booter.Quirks.EnableSafeModeSlide;
699 AbcSettings.EnableWriteUnprotector = Config->Booter.Quirks.EnableWriteUnprotector;
700 AbcSettings.ClearTaskSwitchBit = Config->Booter.Quirks.ClearTaskSwitchBit;
701 AbcSettings.ForceExitBootServices = Config->Booter.Quirks.ForceExitBootServices;
702 AbcSettings.ForceBooterSignature = Config->Booter.Quirks.ForceBooterSignature;
703 CopyMem (AbcSettings.BooterSignature, Signature, sizeof (AbcSettings.BooterSignature));
704 AbcSettings.ProtectMemoryRegions = Config->Booter.Quirks.ProtectMemoryRegions;
705 AbcSettings.ProvideCustomSlide = Config->Booter.Quirks.ProvideCustomSlide;
706 AbcSettings.ProvideMaxSlide = Config->Booter.Quirks.ProvideMaxSlide;
707 AbcSettings.ProtectUefiServices = Config->Booter.Quirks.ProtectUefiServices;
708 AbcSettings.RebuildAppleMemoryMap = Config->Booter.Quirks.RebuildAppleMemoryMap;
709 AbcSettings.ResizeUsePciRbIo = Config->Uefi.Quirks.ResizeUsePciRbIo;
710 AbcSettings.ResizeAppleGpuBars = Config->Booter.Quirks.ResizeAppleGpuBars;
711 AbcSettings.SetupVirtualMap = Config->Booter.Quirks.SetupVirtualMap;
712 AbcSettings.SignalAppleOS = Config->Booter.Quirks.SignalAppleOS;
713 AbcSettings.SyncRuntimePermissions = Config->Booter.Quirks.SyncRuntimePermissions;
714
715 //
716 // Handle MmioWhitelist patches.
717 //
718 if (AbcSettings.DevirtualiseMmio && (Config->Booter.MmioWhitelist.Count > 0)) {
719 AbcSettings.MmioWhitelist = AllocatePool (
720 Config->Booter.MmioWhitelist.Count * sizeof (AbcSettings.MmioWhitelist[0])
721 );
722
723 if (AbcSettings.MmioWhitelist != NULL) {
724 NextIndex = 0;
725 for (Index = 0; Index < Config->Booter.MmioWhitelist.Count; ++Index) {
726 if (Config->Booter.MmioWhitelist.Values[Index]->Enabled) {
727 AbcSettings.MmioWhitelist[NextIndex] = Config->Booter.MmioWhitelist.Values[Index]->Address;
728 ++NextIndex;
729 }
730 }
731
732 AbcSettings.MmioWhitelistSize = NextIndex;
733 } else {
734 DEBUG ((
735 DEBUG_ERROR,
736 "OC: Failed to allocate %u slots for mmio addresses\n",
737 (UINT32)Config->Booter.MmioWhitelist.Count
738 ));
739 }
740 }
741
742 //
743 // Handle customised booter patches.
744 //
745 if (Config->Booter.Patch.Count > 0) {
746 AbcSettings.BooterPatches = AllocateZeroPool (
747 Config->Booter.Patch.Count * sizeof (AbcSettings.BooterPatches[0])
748 );
749
750 if (AbcSettings.BooterPatches != NULL) {
751 NextIndex = 0;
752 for (Index = 0; Index < Config->Booter.Patch.Count; ++Index) {
753 Patch = &AbcSettings.BooterPatches[NextIndex];
754 UserPatch = Config->Booter.Patch.Values[Index];
755
756 if (!UserPatch->Enabled) {
757 continue;
758 }
759
760 //
761 // Ignore patch if:
762 // - There is nothing to replace.
763 // - Find and replace mismatch in size.
764 // - Mask and ReplaceMask mismatch in size when are available.
765 //
766 if ( (UserPatch->Replace.Size == 0)
767 || (UserPatch->Find.Size != UserPatch->Replace.Size)
768 || ((UserPatch->Mask.Size > 0) && (UserPatch->Find.Size != UserPatch->Mask.Size))
769 || ((UserPatch->ReplaceMask.Size > 0) && (UserPatch->Find.Size != UserPatch->ReplaceMask.Size)))
770 {
771 DEBUG ((DEBUG_ERROR, "OC: Booter patch %u is borked\n", Index));
772 continue;
773 }
774
775 //
776 // Also, ignore patch on mismatched architecture.
777 //
778 Patch->Arch = OC_BLOB_GET (&UserPatch->Arch);
779 if ((Patch->Arch[0] != '\0') && (AsciiStrCmp (Patch->Arch, "Any") != 0)) {
780 #if defined (MDE_CPU_X64)
781 if (AsciiStrCmp (Patch->Arch, "x86_64") != 0) {
782 continue;
783 }
784
785 #elif defined (MDE_CPU_IA32)
786 if (AsciiStrCmp (Patch->Arch, "i386") != 0) {
787 continue;
788 }
789
790 #else
791 #error "Unsupported architecture"
792 #endif
793 }
794
795 //
796 // Here we simply receive Identifier from user,
797 // and it will be parsed by the internal patch function.
798 //
799 Patch->Identifier = OC_BLOB_GET (&UserPatch->Identifier);
800
801 Patch->Find = OC_BLOB_GET (&UserPatch->Find);
802 Patch->Replace = OC_BLOB_GET (&UserPatch->Replace);
803
804 Patch->Comment = OC_BLOB_GET (&UserPatch->Comment);
805
806 if (UserPatch->Mask.Size > 0) {
807 Patch->Mask = OC_BLOB_GET (&UserPatch->Mask);
808 }
809
810 if (UserPatch->ReplaceMask.Size > 0) {
811 Patch->ReplaceMask = OC_BLOB_GET (&UserPatch->ReplaceMask);
812 }
813
814 Patch->Size = UserPatch->Replace.Size;
815 Patch->Count = UserPatch->Count;
816 Patch->Skip = UserPatch->Skip;
817 Patch->Limit = UserPatch->Limit;
818
819 ++NextIndex;
820 }
821
822 AbcSettings.BooterPatchesSize = NextIndex;
823 } else {
824 DEBUG ((
825 DEBUG_ERROR,
826 "OC: Failed to allocate %u slots for user booter patches\n",
827 (UINT32)Config->Booter.Patch.Count
828 ));
829 }
830 }
831
834
835 OcAbcInitialize (&AbcSettings, CpuInfo);
836}
837
838VOID
840 IN OC_GLOBAL_CONFIG *Config
841 )
842{
843 EFI_STATUS Status;
844 UINTN Index;
845 EFI_PHYSICAL_ADDRESS ReservedAddress;
846 EFI_MEMORY_TYPE RsvdMemoryType;
847 CHAR8 *RsvdMemoryTypeStr;
848
849 for (Index = 0; Index < Config->Uefi.ReservedMemory.Count; ++Index) {
850 if (!Config->Uefi.ReservedMemory.Values[Index]->Enabled) {
851 continue;
852 }
853
854 if ( ((Config->Uefi.ReservedMemory.Values[Index]->Address & (BASE_4KB - 1)) != 0)
855 || ((Config->Uefi.ReservedMemory.Values[Index]->Size & (BASE_4KB - 1)) != 0))
856 {
857 Status = EFI_INVALID_PARAMETER;
858 } else {
859 RsvdMemoryTypeStr = OC_BLOB_GET (&Config->Uefi.ReservedMemory.Values[Index]->Type);
860
861 Status = OcDescToMemoryType (RsvdMemoryTypeStr, &RsvdMemoryType);
862 if (EFI_ERROR (Status)) {
863 DEBUG ((DEBUG_INFO, "OC: Invalid ReservedMemory Type: %a\n", RsvdMemoryTypeStr));
864 RsvdMemoryType = EfiReservedMemoryType;
865 }
866
867 ReservedAddress = Config->Uefi.ReservedMemory.Values[Index]->Address;
868 Status = gBS->AllocatePages (
869 AllocateAddress,
870 RsvdMemoryType,
871 (UINTN)EFI_SIZE_TO_PAGES (Config->Uefi.ReservedMemory.Values[Index]->Size),
872 &ReservedAddress
873 );
874 }
875
876 DEBUG ((
877 DEBUG_INFO,
878 "OC: Reserving region %Lx of %Lx size - %r\n",
879 Config->Uefi.ReservedMemory.Values[Index]->Address,
880 Config->Uefi.ReservedMemory.Values[Index]->Size,
881 Status
882 ));
883 }
884}
885
886VOID
888 IN OC_STORAGE_CONTEXT *Storage,
889 IN OC_GLOBAL_CONFIG *Config,
890 IN OC_CPU_INFO *CpuInfo,
891 IN UINT8 *Signature
892 )
893{
894 EFI_STATUS Status;
895 EFI_HANDLE *DriversToConnect;
896 EFI_HANDLE *HandleBuffer;
897 UINTN HandleCount;
898 EFI_EVENT Event;
899 BOOLEAN AccelEnabled;
900
901 OcUnloadDrivers (Config);
902
903 OcReinstallProtocols (Config);
904
905 OcImageLoaderInit (Config->Booter.Quirks.ProtectUefiServices, Config->Booter.Quirks.FixupAppleEfiImages);
906
907 OcLoadAppleSecureBoot (Config, CpuInfo);
908
909 OcLoadUefiInputSupport (Config);
910
911 //
912 // Setup Apple bootloader specific UEFI features.
913 //
914 OcLoadBooterUefiSupport (Config, CpuInfo, Signature);
915
916 if (Config->Uefi.Quirks.ActivateHpetSupport) {
918 }
919
920 if (Config->Uefi.Quirks.IgnoreInvalidFlexRatio) {
921 OcCpuCorrectFlexRatio (CpuInfo);
922 }
923
924 if (Config->Uefi.Quirks.EnableVmx) {
925 Status = OcCpuEnableVmx ();
926 DEBUG ((EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO, "OC: Enable VMX - %r\n", Status));
927 }
928
929 if (Config->Uefi.Quirks.TscSyncTimeout > 0) {
930 OcCpuCorrectTscSync (CpuInfo, Config->Uefi.Quirks.TscSyncTimeout);
931 }
932
933 DEBUG ((
934 DEBUG_INFO,
935 "OC: RequestBootVarRouting %d\n",
936 Config->Uefi.Quirks.RequestBootVarRouting
937 ));
938
939 //
940 // Inform platform support whether we want Boot#### routing or not.
941 //
945 sizeof (Config->Uefi.Quirks.RequestBootVarRouting),
946 &Config->Uefi.Quirks.RequestBootVarRouting,
947 NULL
948 );
949
950 if (Config->Uefi.Quirks.UnblockFsConnect) {
952 }
953
954 if (Config->Uefi.Quirks.DisableSecurityPolicy) {
956 }
957
958 OcForgeUefiSupport (Config->Uefi.Quirks.ForgeUefiSupport, FALSE);
959
960 if (Config->Uefi.Quirks.ReloadOptionRoms) {
962 }
963
964 if (Config->Uefi.Quirks.EnableVectorAcceleration) {
965 AccelEnabled = TryEnableAccel ();
966 DEBUG ((DEBUG_INFO, "OC: AVX enabled - %u\n", AccelEnabled));
967 }
968
969 if ( (Config->Uefi.Quirks.ResizeGpuBars >= 0)
970 && (Config->Uefi.Quirks.ResizeGpuBars < PciBarTotal))
971 {
972 DEBUG ((DEBUG_INFO, "OC: Setting GPU BARs to %d\n", Config->Uefi.Quirks.ResizeGpuBars));
973 ResizeGpuBars (Config->Uefi.Quirks.ResizeGpuBars, TRUE, Config->Uefi.Quirks.ResizeUsePciRbIo);
974 }
975
976 OcMiscUefiQuirksLoaded (Config);
977
978 //
979 // Reserve requested memory regions
980 //
981 OcReserveMemory (Config);
982
983 if (Config->Uefi.ConnectDrivers) {
984 OcLoadDrivers (Storage, Config, &DriversToConnect, FALSE);
985 DEBUG ((DEBUG_INFO, "OC: Connecting drivers...\n"));
986 if (DriversToConnect != NULL) {
987 OcRegisterDriversToHighestPriority (DriversToConnect);
988 //
989 // DriversToConnect is not freed as it is owned by OcRegisterDriversToHighestPriority.
990 //
991 }
992
993 if (Config->Uefi.Output.ReconnectGraphicsOnConnect) {
994 DEBUG ((DEBUG_INFO, "OC: Disconnecting graphics drivers...\n"));
996 DEBUG ((DEBUG_INFO, "OC: Disconnecting graphics drivers done...\n"));
997 }
998
1000 DEBUG ((DEBUG_INFO, "OC: Connecting drivers done...\n"));
1001 } else {
1002 OcLoadDrivers (Storage, Config, NULL, FALSE);
1003 }
1004
1005 DEBUG_CODE_BEGIN ();
1006 HandleCount = 0;
1007 HandleBuffer = NULL;
1008 Status = gBS->LocateHandleBuffer (
1009 ByProtocol,
1011 NULL,
1012 &HandleCount,
1013 &HandleBuffer
1014 );
1015 DEBUG ((DEBUG_INFO, "OC: Found %u pointer devices - %r\n", HandleCount, Status));
1016 if (!EFI_ERROR (Status)) {
1017 FreePool (HandleBuffer);
1018 }
1019
1020 DEBUG_CODE_END ();
1021
1022 if (Config->Uefi.Apfs.EnableJumpstart) {
1024 Config->Uefi.Apfs.MinVersion,
1025 Config->Uefi.Apfs.MinDate,
1026 Config->Misc.Security.ScanPolicy,
1027 Config->Uefi.Apfs.GlobalConnect,
1028 Config->Uefi.Quirks.UnblockFsConnect,
1029 Config->Uefi.Apfs.HideVerbose
1030 );
1031
1033 Config->Uefi.Apfs.JumpstartHotPlug
1034 );
1035 }
1036
1037 OcLoadUefiOutputSupport (Storage, Config);
1038
1039 OcLoadUefiAudioSupport (Storage, Config);
1040
1041 gBS->CreateEvent (
1042 EVT_SIGNAL_EXIT_BOOT_SERVICES,
1043 TPL_CALLBACK,
1045 Config,
1046 &Event
1047 );
1048}
@ AppleImg4SbModeFull
@ AppleImg4SbModeMedium
@ AppleImg4SbModeDisabled
UINT8 Signature[8]
Definition BiosId.h:67
EFI_STATUS OcAbcInitialize(IN OC_ABC_SETTINGS *Settings, IN OC_CPU_INFO *CpuInfo)
EFI_STATUS OcApfsConnectDevices(IN BOOLEAN Monitor)
Definition OcApfsLib.c:169
VOID OcApfsConfigure(IN UINT64 MinVersion, IN UINT32 MinDate, IN UINT32 ScanPolicy, IN BOOLEAN GlobalConnect, IN BOOLEAN DisconnectHandles, IN BOOLEAN IgnoreVerbose)
APPLE_BOOT_POLICY_PROTOCOL * OcAppleBootPolicyInstallProtocol(IN BOOLEAN Reinstall)
APPLE_EVENT_PROTOCOL * OcAppleEventInstallProtocol(IN BOOLEAN Install, IN BOOLEAN Reinstall, IN BOOLEAN CustomDelays, IN UINT16 KeyInitialDelay, IN UINT16 KeySubsequentDelay, IN BOOLEAN GraphicsInputMirroring, IN UINT32 PointerPollMin, IN UINT32 PointerPollMax, IN UINT32 PointerPollMask, IN UINT16 PointerSpeedDiv, IN UINT16 PointerSpeedMul, IN UINT16 PointerDwellClickTimeout, IN UINT16 PointerDwellDoubleClickTimeout, IN UINT16 PointerDwellRadius)
APPLE_IMAGE_CONVERSION_PROTOCOL * OcAppleImageConversionInstallProtocol(IN BOOLEAN Reinstall)
CONST CHAR8 * OcAppleImg4GetHardwareModel(IN CONST CHAR8 *ModelRequest)
#define OC_SB_MODEL_DEFAULT
APPLE_IMG4_VERIFICATION_PROTOCOL * OcAppleImg4VerificationInstallProtocol(IN BOOLEAN Reinstall)
EFI_STATUS OcAppleImg4BootstrapValues(IN CONST CHAR8 *Model, IN UINT64 Ecid OPTIONAL)
#define OC_SB_MODEL_DISABLED
#define OC_SB_MODEL_LEGACY
APPLE_KEY_MAP_AGGREGATOR_PROTOCOL * OcAppleKeyMapInstallProtocols(IN BOOLEAN Reinstall)
APPLE_SECURE_BOOT_PROTOCOL * OcAppleSecureBootInstallProtocol(IN BOOLEAN Reinstall, IN UINT8 SbPolicy, IN UINT8 SbWinPolicy OPTIONAL, IN BOOLEAN SbWinPolicyValid)
EFI_STATUS OcAppleSecureBootBootstrapValues(IN CONST CHAR8 *Model, IN UINT64 Ecid OPTIONAL)
EFI_USER_INTERFACE_THEME_PROTOCOL * OcAppleUserInterfaceThemeInstallProtocol(IN BOOLEAN Reinstall)
OC_AUDIO_PROTOCOL * OcAudioInstallProtocols(IN BOOLEAN Reinstall, IN BOOLEAN DisconnectHda)
Definition OcAudioLib.c:80
VOID OcImageLoaderInit(IN CONST BOOLEAN ProtectUefiServices, IN CONST BOOLEAN FixupAppleEfiImages)
BOOLEAN OcAppendArgumentsToLoadedImage(IN OUT EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, IN CONST CHAR8 **Arguments, IN UINT32 ArgumentCount, IN BOOLEAN Replace)
EFI_HANDLE gImageHandle
EFI_BOOT_SERVICES * gBS
APPLE_EG2_INFO_PROTOCOL * OcAppleEg2InfoInstallProtocol(IN BOOLEAN Reinstall)
Definition Eg2Info.c:108
APPLE_FRAMEBUFFER_INFO_PROTOCOL * OcAppleFbInfoInstallProtocol(IN BOOLEAN Reinstall)
EFI_STATUS OcCpuEnableVmx(VOID)
Definition OcCpuLib.c:1256
EFI_STATUS OcCpuCorrectTscSync(IN OC_CPU_INFO *Cpu, IN UINTN Timeout)
Definition OcCpuLib.c:1324
VOID OcCpuCorrectFlexRatio(IN OC_CPU_INFO *Cpu)
Definition OcCpuLib.c:1231
BOOLEAN EFIAPI TryEnableAccel(VOID)
EFI_DATA_HUB_PROTOCOL * OcDataHubInstallProtocol(IN BOOLEAN Reinstall)
EFI_STATUS OcForgeUefiSupport(IN BOOLEAN Forge, IN BOOLEAN Trash)
Definition ForgeUefi.c:81
VOID ActivateHpetSupport(VOID)
@ PciBarTotal
EFI_STATUS ReleaseUsbOwnership(VOID)
EFI_STATUS ResizeGpuBars(IN PCI_BAR_SIZE Size, IN BOOLEAN Increase, IN BOOLEAN UseRbIo)
EFI_STATUS OcReloadOptionRoms(VOID)
EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL * OcDevicePathPropertyInstallProtocol(IN BOOLEAN Reinstall)
VOID OcUnblockUnmountedPartitions(VOID)
VOID OcDisconnectGraphicsDrivers(VOID)
EFI_STATUS OcRegisterDriversToHighestPriority(IN EFI_HANDLE *PriorityDrivers)
EFI_STATUS OcConnectDrivers(VOID)
EFI_FIRMWARE_VOLUME_PROTOCOL * OcFirmwareVolumeInstallProtocol(IN BOOLEAN Reinstall)
EFI_SERVICE_BINDING_PROTOCOL * OcHashServicesInstallProtocol(IN BOOLEAN Reinstall)
APPLE_DEBUG_LOG_PROTOCOL * OcAppleDebugLogInstallProtocol(IN BOOLEAN Reinstall)
Definition OcAppleLog.c:252
#define OPEN_CORE_UEFI_DRIVER_PATH
Definition OcMainLib.h:58
CONST CHAR8 * OcGetDefaultSecureBootModel(IN OC_GLOBAL_CONFIG *Config, IN OC_CPU_INFO *CpuInfo)
VOID OcLoadUefiInputSupport(IN OC_GLOBAL_CONFIG *Config)
VOID OcUnloadDrivers(IN OC_GLOBAL_CONFIG *Config)
VOID OcLoadUefiAudioSupport(IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config)
VOID OcGetLegacySecureBootECID(IN OC_GLOBAL_CONFIG *Config, OUT UINT64 *ApECID)
VOID OcLoadUefiOutputSupport(IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config)
VOID OcMiscUefiQuirksLoaded(IN OC_GLOBAL_CONFIG *Config)
EFI_STATUS OcDescToMemoryType(IN CHAR8 *MemoryTypeDesc, OUT EFI_MEMORY_TYPE *MemoryType)
Definition MemoryMap.c:90
EFI_OS_INFO_PROTOCOL * OcOSInfoInstallProtocol(IN BOOLEAN Reinstall)
EFI_CPU_IO2_PROTOCOL * OcPciIoInstallProtocol(IN BOOLEAN Reinstall)
Definition OcPciIoLib.c:13
APPLE_RTC_RAM_PROTOCOL * OcAppleRtcRamInstallProtocol(IN BOOLEAN Reinstall)
APPLE_SMC_IO_PROTOCOL * OcSmcIoInstallProtocol(IN BOOLEAN Reinstall, IN BOOLEAN AuthRestart)
Definition OcSmcLib.c:595
VOID * OcStorageReadFileUnicode(IN OC_STORAGE_CONTEXT *Context, IN CONST CHAR16 *FilePath, OUT UINT32 *FileSize OPTIONAL)
#define OC_STORAGE_SAFE_PATH_MAX
EFI_STATUS EFIAPI OcUnicodeSafeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
#define OC_BLOB_GET(Blob)
EFI_UNICODE_COLLATION_PROTOCOL * OcUnicodeCollationEngInstallProtocol(IN BOOLEAN Reinstall)
#define OC_BOOT_REDIRECT_VARIABLE_NAME
Definition OcVariable.h:33
EFI_STATUS OcSetSystemVariable(IN CHAR16 *VariableName, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data, IN EFI_GUID *VendorGuid OPTIONAL)
#define OPEN_CORE_INT_NVRAM_ATTR
CONST CHAR8 * XmlUnescapeString(IN CONST CHAR8 *String)
Definition OcXmlLib.c:1687
STATIC VOID EFIAPI OcExitBootServicesHandler(IN EFI_EVENT Event, IN VOID *Context)
STATIC EFI_STATUS EFIAPI OcSecurity2FileAuthentication(IN CONST EFI_SECURITY2_ARCH_PROTOCOL *This, IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL, IN VOID *FileBuffer, IN UINTN FileSize, IN BOOLEAN BootPolicy)
VOID OcLoadDrivers(IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config, OUT EFI_HANDLE **DriversToConnect OPTIONAL, IN BOOLEAN LoadEarly)
VOID OcLoadBooterUefiSupport(IN OC_GLOBAL_CONFIG *Config, IN OC_CPU_INFO *CpuInfo, IN UINT8 *Signature)
VOID OcScheduleExitBootServices(IN EFI_EVENT_NOTIFY Handler, IN VOID *Context)
VOID OcLoadUefiSupport(IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config, IN OC_CPU_INFO *CpuInfo, IN UINT8 *Signature)
STATIC UINTN mOcExitBootServicesIndex
STATIC EFI_STATUS EFIAPI OcSecurityFileAuthentication(IN CONST EFI_SECURITY_ARCH_PROTOCOL *This, IN UINT32 AuthenticationStatus, IN CONST EFI_DEVICE_PATH_PROTOCOL *File)
STATIC VOID OcLoadAppleSecureBoot(IN OC_GLOBAL_CONFIG *Config, IN OC_CPU_INFO *CpuInfo)
STATIC EFI_EVENT_NOTIFY mOcExitBootServicesHandlers[OC_EXIT_BOOT_SERVICES_HANDLER_MAX+1]
#define OC_EXIT_BOOT_SERVICES_HANDLER_MAX
STATIC VOID OcReinstallProtocols(IN OC_GLOBAL_CONFIG *Config)
VOID OcReserveMemory(IN OC_GLOBAL_CONFIG *Config)
STATIC VOID OcInstallPermissiveSecurityPolicy(VOID)
STATIC VOID * mOcExitBootServicesContexts[OC_EXIT_BOOT_SERVICES_HANDLER_MAX]
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_GUID gEfiDriverBindingProtocolGuid
EFI_GUID gEfiSimplePointerProtocolGuid
EFI_GUID gEfiLoadedImageProtocolGuid
#define ASSERT(x)
Definition coder.h:55
EFI_EVENT_NOTIFY * ExitBootServicesHandlers
EFI_PHYSICAL_ADDRESS * MmioWhitelist
UINT8 BooterSignature[SHA1_DIGEST_SIZE]
VOID ** ExitBootServicesHandlerContexts
OC_BOOTER_PATCH * BooterPatches
CONST UINT8 * ReplaceMask