24#include <Library/BaseLib.h>
25#include <Library/BaseMemoryLib.h>
26#include <Library/MemoryAllocationLib.h>
27#include <Library/DevicePathLib.h>
37#include <Library/UefiBootServicesTableLib.h>
38#include <Library/UefiLib.h>
39#include <Library/UefiRuntimeServicesTableLib.h>
57 EFI_PHYSICAL_ADDRESS Address;
60 if ((Type != EfiRuntimeServicesCode) && (Type != EfiRuntimeServicesData)) {
64 if (BootCompat->Settings.SyncRuntimePermissions && (BootCompat->ServiceState.FwRuntime != NULL)) {
68 BootCompat->Settings.SyncRuntimePermissions = FALSE;
70 Status = BootCompat->ServiceState.FwRuntime->GetExecArea (&Address, &Pages);
72 if (!EFI_ERROR (Status)) {
79 BootCompat->Settings.SyncRuntimePermissions = TRUE;
96 IN EFI_HANDLE ImageHandle,
98 IN EFI_EXIT_BOOT_SERVICES ExitBootServices OPTIONAL,
99 IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL
103 EFI_MEMORY_DESCRIPTOR *MemoryMap;
105 UINTN DescriptorSize;
106 UINT32 DescriptorVersion;
108 if (ExitBootServices == NULL) {
109 ExitBootServices =
gBS->ExitBootServices;
112 if (GetMemoryMap == NULL) {
113 GetMemoryMap =
gBS->GetMemoryMap;
119 Status = ExitBootServices (ImageHandle, MapKey);
121 if (EFI_ERROR (Status)) {
137 if (Status == EFI_SUCCESS) {
141 Status = ExitBootServices (ImageHandle, MapKey);
142 if (EFI_ERROR (Status)) {
143 DEBUG ((DEBUG_WARN,
"OCABC: ExitBootServices failed twice - %r\n", Status));
146 DEBUG ((DEBUG_WARN,
"OCABC: Failed to get MapKey for ExitBootServices - %r\n", Status));
147 Status = EFI_INVALID_PARAMETER;
150 if (EFI_ERROR (Status)) {
151 DEBUG ((DEBUG_WARN,
"OCABC: Waiting 10 secs...\n"));
169 IN UINTN MemoryMapSize,
170 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
171 IN UINTN DescriptorSize
176 EFI_MEMORY_DESCRIPTOR *Desc;
200 NumEntries = MemoryMapSize / DescriptorSize;
202 for (Index = 0; Index < NumEntries; ++Index) {
203 if ((Desc->NumberOfPages > 0) && (Desc->Type == EfiBootServicesData)) {
207 if ((PhysicalEnd >= 0x9E000) && (PhysicalEnd < 0xA0000)) {
208 Desc->Type = EfiACPIMemoryNVS;
213 Desc = NEXT_MEMORY_DESCRIPTOR (Desc, DescriptorSize);
225 for (Index = 0; Index < NumEntries; ++Index) {
226 if ((Desc->Type == EfiReservedMemoryType) && ((Desc->Attribute & EFI_MEMORY_RUNTIME) != 0)) {
227 Desc->Type = EfiMemoryMappedIO;
230 Desc = NEXT_MEMORY_DESCRIPTOR (Desc, DescriptorSize);
247 IN UINTN MemoryMapSize,
248 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
249 IN UINTN DescriptorSize
255 EFI_MEMORY_DESCRIPTOR *Desc;
256 CONST EFI_PHYSICAL_ADDRESS *Whitelist;
274 NumEntries = MemoryMapSize / DescriptorSize;
278 DEBUG ((DEBUG_INFO,
"OCABC: MMIO devirt start\n"));
281 for (Index = 0; Index < NumEntries; ++Index) {
282 if ( (Desc->NumberOfPages > 0)
283 && (Desc->Type == EfiMemoryMappedIO)
284 && ((Desc->Attribute & EFI_MEMORY_RUNTIME) != 0))
288 for (Index2 = 0; Index2 < WhitelistSize; ++Index2) {
298 "OCABC: MMIO devirt 0x%Lx (0x%Lx pages, 0x%Lx) skip %d\n",
299 (UINT64)Desc->PhysicalStart,
300 (UINT64)Desc->NumberOfPages,
301 (UINT64)Desc->Attribute,
307 Desc->Attribute &= ~EFI_MEMORY_RUNTIME;
308 PagesSaved += Desc->NumberOfPages;
312 Desc = NEXT_MEMORY_DESCRIPTOR (Desc, DescriptorSize);
318 "OCABC: MMIO devirt end, saved %Lu KB\n",
319 EFI_PAGES_TO_SIZE (PagesSaved) / BASE_1KB
335 IN OUT UINT8 *ImageBase,
342 if (ImageSize < Patch->
Size) {
343 DEBUG ((DEBUG_INFO,
"OCABC: Image size is even smaller than patch size\n"));
347 if ((Patch->Limit > 0) && (Patch->Limit < ImageSize)) {
348 ImageSize = Patch->Limit;
363 if ((ReplaceCount > 0) && (Patch->Count > 0) && (ReplaceCount != Patch->Count)) {
366 "OCABC: Booter patch (%a) performed only %u replacements out of %u\n",
371 }
else if (ReplaceCount == 0) {
374 "OCABC: Failed to apply Booter patch (%a) - not found\n",
378 DEBUG ((DEBUG_INFO,
"OCABC: Booter patch (%a) replace count - %u\n", Patch->Comment, ReplaceCount));
393 IN EFI_HANDLE ImageHandle,
400 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
403 CONST CHAR8 *UserIdentifier;
404 CHAR16 *UserIdentifierUnicode;
406 Status =
gBS->HandleProtocol (
409 (VOID **)&LoadedImage
411 if (EFI_ERROR (Status)) {
412 DEBUG ((DEBUG_ERROR,
"OCABC: Failed to handle LoadedImage protocol - %r\n", Status));
416 for (Index = 0; Index < PatchCount; ++Index) {
417 UserIdentifier = Patches[Index].Identifier;
419 if ((UserIdentifier[0] ==
'\0') || (AsciiStrCmp (UserIdentifier,
"Any") == 0)) {
421 }
else if (AsciiStrCmp (UserIdentifier,
"Apple") == 0) {
425 if (UserIdentifierUnicode == NULL) {
426 DEBUG ((DEBUG_INFO,
"OCABC: Booter patch (%a) for %a is out of memory\n", Patches[Index].Comment, UserIdentifier));
431 FreePool (UserIdentifierUnicode);
436 (UINT8 *)LoadedImage->ImageBase,
437 (UINTN)LoadedImage->ImageSize,
452 IN EFI_ALLOCATE_TYPE Type,
453 IN EFI_MEMORY_TYPE MemoryType,
454 IN UINTN NumberOfPages,
455 IN OUT EFI_PHYSICAL_ADDRESS *Memory
461 BOOLEAN IsCallGateAlloc;
466 if (Memory == NULL) {
467 return EFI_INVALID_PARAMETER;
472 IsCallGateAlloc = FALSE;
476 if ( (Type == AllocateMaxAddress)
477 && (MemoryType == EfiACPIReclaimMemory)
478 && (*Memory == BASE_4GB - 1))
488 && (Type == AllocateMaxAddress)
489 && (MemoryType == EfiLoaderCode)
490 && (*Memory == BASE_4GB - 1)
491 && (NumberOfPages == 1))
493 IsCallGateAlloc = TRUE;
498 && (Type == AllocateAddress)
499 && (MemoryType == EfiLoaderData))
509 Status = EFI_UNSUPPORTED;
512 if (EFI_ERROR (Status)) {
521 DEBUG ((DEBUG_VERBOSE,
"OCABC: AllocPages %u 0x%Lx (%u) - %r\n", Type, *Memory, NumberOfPages, Status));
523 if (!EFI_ERROR (Status)) {
527 if (IsCallGateAlloc) {
533 }
else if (IsPerfAlloc) {
554 IN EFI_PHYSICAL_ADDRESS Memory,
568 if (!EFI_ERROR (Status)) {
584 IN OUT UINTN *MemoryMapSize,
585 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
587 OUT UINTN *DescriptorSize,
588 OUT UINT32 *DescriptorVersion
594 EFI_PHYSICAL_ADDRESS Address;
600 OriginalSize = MemoryMapSize != 0 ? *MemoryMapSize : 0;
614 return EFI_BUFFER_TOO_SMALL;
617 if (EFI_ERROR (Status)) {
628 if (!EFI_ERROR (Status2)) {
634 EfiRuntimeServicesCode,
668 if (EFI_ERROR (Status2) && (Status2 != EFI_UNSUPPORTED)) {
669 DEBUG ((DEBUG_INFO,
"OCABC: Cannot rebuild memory map - %r\n", Status));
702 IN EFI_MEMORY_TYPE PoolType,
718 if (!EFI_ERROR (Status)) {
745 if (!EFI_ERROR (Status)) {
765 IN EFI_DEVICE_PATH_PROTOCOL *EfiBootRtDevicePath OPTIONAL,
766 IN VOID *SourceBuffer OPTIONAL,
768 IN EFI_LOADED_IMAGE_PROTOCOL *EfiBootLoadedImage
773 EFI_DEVICE_PATH_PROTOCOL *EfiBootDevicePath;
774 EFI_DEVICE_PATH_PROTOCOL *DevicePathEnd;
775 UINTN EfiBootRtDevicePathRemSize;
777 EFI_DEVICE_PATH_PROTOCOL *CurrentRtNode;
779 ASSERT (EfiBootLoadedImage != NULL);
781 if ( (EfiBootRtDevicePath == NULL)
782 || (SourceBuffer == NULL)
783 || (EfiBootLoadedImage->FilePath == NULL))
787 "OCABC: Cannot be EfiBootRt (DP %d, Buf %d, EfiBoot FP %d)\n",
788 (EfiBootRtDevicePath == NULL),
789 (SourceBuffer == NULL),
790 (EfiBootLoadedImage->FilePath == NULL)
801 if (EfiBootDevicePath == NULL) {
804 "OCABC: Failed to get EfiBoot DP from handle 0x%llx\n",
805 (UINT64)(UINTN)EfiBootLoadedImage->DeviceHandle
812 "OCABC: Current EfiBoot",
816 EfiBootRtDevicePathRemSize = GetDevicePathSize (EfiBootRtDevicePath);
819 ComponentSize = (UINTN)DevicePathEnd - (UINTN)EfiBootDevicePath;
821 Overflow = BaseOverflowSubUN (
822 EfiBootRtDevicePathRemSize,
824 &EfiBootRtDevicePathRemSize
829 "OCABC: EfiBootRt DP (0x%llx) is shorter than EfiBoot DP (0x%llx)\n",
830 (UINT64)EfiBootRtDevicePathRemSize,
831 (UINT64)ComponentSize
845 if (CmpResult != 0) {
846 DEBUG ((DEBUG_INFO,
"OCABC: EfiBoot DP is not a prefix of EfiBootRt DP\n"));
850 CurrentRtNode = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)EfiBootRtDevicePath + ComponentSize);
853 ComponentSize = (UINTN)DevicePathEnd - (UINTN)EfiBootLoadedImage->FilePath;
855 if (ComponentSize >= EfiBootRtDevicePathRemSize) {
858 "OCABC: EfiBootRt FP (0x%llx) is shorter than EfiBoot FP (0x%llx)\n",
859 (UINT64)EfiBootRtDevicePathRemSize,
860 (UINT64)ComponentSize
867 EfiBootLoadedImage->FilePath,
870 if (CmpResult != 0) {
871 DEBUG ((DEBUG_INFO,
"OCABC: EfiBoot FP is not a prefix of EfiBootRt FP\n"));
875 CurrentRtNode = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)CurrentRtNode + ComponentSize);
880 if ( (DevicePathType (CurrentRtNode) != HARDWARE_DEVICE_PATH)
881 || (DevicePathSubType (CurrentRtNode) != HW_MEMMAP_DP))
885 "OCABC: EfiBootRt FP is not succeeded by a MemMap node\n"
890 MEMMAP_DEVICE_PATH *MemMapNode = (MEMMAP_DEVICE_PATH *)CurrentRtNode;
892 if ( (MemMapNode->StartingAddress != (EFI_PHYSICAL_ADDRESS)(UINTN)SourceBuffer)
893 || (MemMapNode->EndingAddress != (EFI_PHYSICAL_ADDRESS)((UINTN)SourceBuffer + SourceSize)))
897 "OCABC: MemMap [0x%llx, 0x%llx) mismatches EfiBootRt [0x%llx, 0x%llx)\n",
898 MemMapNode->StartingAddress,
899 MemMapNode->EndingAddress,
900 (EFI_PHYSICAL_ADDRESS)(UINTN)SourceBuffer,
901 (EFI_PHYSICAL_ADDRESS)((UINTN)SourceBuffer + SourceSize)
926InternalEfiBootRtGetKcgOffset (
929 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
930 IN VOID *SourceBuffer,
936 EFI_HANDLE EfiBootRtCopyHandle;
939 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
955 if (EFI_ERROR (Status)) {
956 DEBUG ((DEBUG_INFO,
"OCABC: KCG load - %r\n", Status));
964 Status =
gBS->HandleProtocol (
967 (VOID **)&LoadedImage
969 if (EFI_ERROR (Status)) {
970 DEBUG ((DEBUG_INFO,
"OCABC: Handle KCG LoadedImage - %r\n", Status));
971 gBS->UnloadImage (EfiBootRtCopyHandle);
975 ImageBase = (UINTN)LoadedImage->ImageBase;
977 ZeroMem (&EfiBootRtLoadOptions,
sizeof (EfiBootRtLoadOptions));
978 LoadedImage->LoadOptions = &EfiBootRtLoadOptions;
979 LoadedImage->LoadOptionsSize =
sizeof (EfiBootRtLoadOptions);
985 Status = BootCompat->ServicePtrs.StartImage (EfiBootRtCopyHandle, NULL, NULL);
987 gBS->UnloadImage (EfiBootRtCopyHandle);
989 if (EFI_ERROR (Status)) {
990 DEBUG ((DEBUG_INFO,
"OCABC: KCG start - %r\n", Status));
997 Overflow = BaseOverflowSubUN (
1002 Overflow |= BaseOverflowSubUN (
1010 "OCABC: KCG OOB (0x%llx, [0x%llx, 0x%llx)\n",
1013 (UINT64)(ImageBase + SourceSize)
1031 IN BOOLEAN BootPolicy,
1032 IN EFI_HANDLE ParentImageHandle,
1033 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
1034 IN VOID *SourceBuffer OPTIONAL,
1035 IN UINTN SourceSize,
1036 OUT EFI_HANDLE *ImageHandle
1039 BOOLEAN IsEfiBootRt;
1052 IsEfiBootRt = FALSE;
1064 "OCABC: IsEfiBootRt %d (BP %d, Apple %d)\n",
1086 #if defined (MDE_CPU_X64)
1087 EFI_STATUS LoadImageStatus;
1089 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
1101 if (EFI_ERROR (LoadImageStatus)) {
1102 DEBUG ((DEBUG_INFO,
"OCABC: EfiBootRt load - %r\n", LoadImageStatus));
1103 return LoadImageStatus;
1109 KcgOffset = InternalEfiBootRtGetKcgOffset (
1119 "OCABC: Invalid KCG [0x%llx, 0x%llx)\n",
1123 return LoadImageStatus;
1126 Status =
gBS->HandleProtocol (
1129 (VOID **)&LoadedImage
1131 if (EFI_ERROR (Status)) {
1132 DEBUG ((DEBUG_INFO,
"OCABC: Handle EfiBootRt LoadedImage - %r\n", Status));
1133 return LoadImageStatus;
1141 (UINTN)LoadedImage->ImageBase + KcgOffset,
1147 "OCABC: Patched KCG at 0x%llx\n",
1148 (UINTN)LoadedImage->ImageBase + KcgOffset
1151 return LoadImageStatus;
1152 #elif defined (MDE_CPU_IA32)
1156 return EFI_INVALID_PARAMETER;
1168 IN EFI_HANDLE ImageHandle,
1169 OUT UINTN *ExitDataSize,
1170 OUT CHAR16 **ExitData OPTIONAL
1174 EFI_LOADED_IMAGE_PROTOCOL *AppleLoadedImage;
1175 EFI_LOADED_IMAGE_PROTOCOL *LastAppleBootImageTmp;
1190 DEBUG ((DEBUG_INFO,
"OCABC: Recovering trashed GetMemoryMap pointer\n"));
1193 gBS->CalculateCrc32 (
gBS,
gBS->Hdr.HeaderSize, &
gBS->Hdr.CRC32);
1203 if (AppleLoadedImage != NULL) {
1224 Status =
gBS->InstallMultipleProtocolInterfaces (
1230 DEBUG ((DEBUG_INFO,
"OCABC: VMware Mac installed on %p - %r\n", ImageHandle, Status));
1242 ASSERT (AppleLoadedImage->ImageSize <= MAX_UINTN);
1244 (UINT8 *)AppleLoadedImage->ImageBase,
1245 (UINTN)AppleLoadedImage->ImageSize
1261 Status =
gBS->LocateProtocol (
1267 if (!EFI_ERROR (Status)) {
1277 OSInfo->OSName (
"Mac OS X 10.15");
1333 AppleLoadedImage != NULL,
1344 if (AppleLoadedImage != NULL) {
1381 IN EFI_HANDLE ImageHandle,
1443 if (EFI_ERROR (Status)) {
1449 #elif defined (MDE_CPU_X64)
1468 IN UINTN MemoryMapSize,
1469 IN UINTN DescriptorSize,
1470 IN UINT32 DescriptorVersion,
1471 IN EFI_MEMORY_DESCRIPTOR *MemoryMap
1500 IN CHAR16 *VariableName,
1501 IN EFI_GUID *VendorGuid,
1502 OUT UINT32 *Attributes OPTIONAL,
1503 IN OUT UINTN *DataSize,
1541 && (Status == EFI_BUFFER_TOO_SMALL)
1546 DEBUG ((DEBUG_INFO,
"OCABC: Caught successful request for %s\n", VariableName));
1574 Status =
gBS->LocateProtocol (
1580 if (!EFI_ERROR (Status)) {
1585 if (!EFI_ERROR (Status)) {
1596 if (EFI_ERROR (Status)) {
1597 DEBUG ((DEBUG_INFO,
"OCABC: OnSetAddressMap failure - %r\n", Status));
1600 DEBUG ((DEBUG_INFO,
"OCABC: OnGetVariable failure - %r\n", Status));
1605 "OCABC: Incompatible OpenRuntime r%u, require r%u\n",
1606 (UINT32)FwRuntime->Revision,
1613 Status = EFI_UNSUPPORTED;
1619 if (!EFI_ERROR (Status)) {
1633 EFI_TPL OriginalTpl;
1635 ServicePtrs = &BootCompat->ServicePtrs;
1637 OriginalTpl =
gBS->RaiseTPL (TPL_HIGH_LEVEL);
1658 gBS->Hdr.CRC32 = CalculateCrc32 (
gBS,
gBS->Hdr.HeaderSize);
1660 gBS->RestoreTPL (OriginalTpl);
1667 if (BootCompat->ServicePtrs.GetVariable != NULL) {
1671 Status =
gBS->CreateEvent (
1676 &BootCompat->ServiceState.GetVariableEvent
1679 if (!EFI_ERROR (Status)) {
1680 Status =
gBS->RegisterProtocolNotify (
1682 BootCompat->ServiceState.GetVariableEvent,
1686 if (EFI_ERROR (Status)) {
1687 gBS->CloseEvent (BootCompat->ServiceState.GetVariableEvent);
#define APPLE_EFI_BOOT_PERF_VARIABLE_NAME
EFI_GUID gAppleBootVariableGuid
EFI_STATUS EFIAPI AppleMapPrepareKernelStateNew64(IN UINTN SystemTable, IN OUT APPLE_EFI_BOOT_RT_KCG_ARGS *KcgArguments, IN KERNEL_CALL_GATE CallGate)
EFI_STATUS AppleRelocationRelease(IN OUT BOOT_COMPAT_CONTEXT *BootCompat)
#define CALL_GATE_MIN_SIZE
BOOT_COMPAT_CONTEXT * GetBootCompatContext(VOID)
VOID AppleSlideUnlockForSafeMode(IN OUT UINT8 *ImageBase, IN UINTN ImageSize)
VOID AppleMapPrepareBooterState(IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN OUT EFI_LOADED_IMAGE *LoadedImage, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL)
VOID AppleMapPrepareKernelJump32(IN OUT BOOT_COMPAT_CONTEXT *BootCompat)
UINTN EFIAPI AppleMapPrepareKernelStateOld64(IN UINTN Args, IN UINTN EntryPoint, IN KERNEL_CALL_GATE CallGate)
EFI_STATUS AppleMapPrepareMemState(IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN UINTN MemoryMapSize, IN UINTN DescriptorSize, IN UINT32 DescriptorVersion, IN EFI_MEMORY_DESCRIPTOR *MemoryMap)
EFI_STATUS AppleRelocationAllocatePages(IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN EFI_GET_MEMORY_MAP GetMemoryMap, IN EFI_ALLOCATE_PAGES AllocatePages, IN UINTN NumberOfPages, IN OUT EFI_PHYSICAL_ADDRESS *Memory)
VOID AppleMapPrepareKernelJump64(IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN EFI_PHYSICAL_ADDRESS CallGate, IN UINTN HookAddress)
EFI_STATUS AppleSlideGetVariable(IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN EFI_GET_VARIABLE GetVariable, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL, IN OC_MEMORY_FILTER FilterMap OPTIONAL, IN VOID *FilterMapContext OPTIONAL, IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data)
EFI_GUID gEfiOSInfoProtocolGuid
#define EFI_OS_INFO_PROTOCOL_REVISION_NAME
#define EFI_OS_INFO_PROTOCOL_REVISION_VENDOR
#define EFI_OS_INFO_APPLE_VENDOR_NAME
DMG_SIZE_DEVICE_PATH Size
EFI_LOADED_IMAGE_PROTOCOL * OcGetAppleBootLoadedImage(IN EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI OcImageLoaderLoad(IN BOOLEAN BootPolicy, IN EFI_HANDLE ParentImageHandle, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN VOID *SourceBuffer OPTIONAL, IN UINTN SourceSize, OUT EFI_HANDLE *ImageHandle)
BOOLEAN OcIsAppleHibernateWake(VOID)
BOOLEAN OcCheckArgumentFromEnv(IN EFI_LOADED_IMAGE *LoadedImage OPTIONAL, IN EFI_GET_VARIABLE GetVariable OPTIONAL, IN CONST CHAR8 *Argument, IN CONST UINTN ArgumentLength, IN OUT CHAR8 **Value OPTIONAL)
VOID DebugPrintDevicePath(IN UINTN ErrorLevel, IN CONST CHAR8 *Message, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL)
EFI_STATUS ResizeGpuBars(IN PCI_BAR_SIZE Size, IN BOOLEAN Increase, IN BOOLEAN UseRbIo)
EFI_DEVICE_PATH_PROTOCOL * FindDevicePathEndNode(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
BOOLEAN OcDevicePathHasFilePathSuffix(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST CHAR16 *Suffix, IN UINTN SuffixLen)
#define OC_FIRMWARE_RUNTIME_REVISION
EFI_GUID gOcFirmwareRuntimeProtocolGuid
VOID OcAppleDebugLogPerfAllocated(IN OUT VOID *PerfBuffer, IN UINTN PerfBufferSize)
#define AREA_WITHIN_DESCRIPTOR(Desc, Area, AreaSize)
EFI_MEMORY_ATTRIBUTES_TABLE * OcGetMemoryAttributes(OUT EFI_MEMORY_DESCRIPTOR **MemoryAttributesEntry OPTIONAL)
EFI_STATUS OcGetCurrentMemoryMapAlloc(OUT UINTN *MemoryMapSize, OUT EFI_MEMORY_DESCRIPTOR **MemoryMap, OUT UINTN *MapKey, OUT UINTN *DescriptorSize, OUT UINT32 *DescriptorVersion, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL, IN OUT EFI_PHYSICAL_ADDRESS *TopMemory OPTIONAL)
#define LAST_DESCRIPTOR_ADDR(Desc)
EFI_STATUS OcShrinkMemoryMap(IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize)
EFI_STATUS OcRebuildAttributes(IN EFI_PHYSICAL_ADDRESS Address, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL)
VOID OcSortMemoryMap(IN UINTN MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize)
EFI_STATUS OcUpdateDescriptors(IN UINTN MemoryMapSize, IN EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize, IN EFI_PHYSICAL_ADDRESS Address, IN EFI_MEMORY_TYPE Type, IN UINT64 SetAttributes, IN UINT64 DropAttributes)
UINTN OcCountSplitDescriptors(VOID)
EFI_STATUS OcSplitMemoryMapByAttributes(IN UINTN MaxMemoryMapSize, IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize)
#define SECONDS_TO_MICROSECONDS(x)
UINT32 ApplyPatch(IN CONST UINT8 *Pattern, IN CONST UINT8 *PatternMask OPTIONAL, IN CONST UINT32 PatternSize, IN CONST UINT8 *Replace, IN CONST UINT8 *ReplaceMask OPTIONAL, IN UINT8 *Data, IN UINT32 DataSize, IN UINT32 Count, IN UINT32 Skip)
#define L_STR_LEN(String)
CHAR16 * AsciiStrCopyToUnicode(IN CONST CHAR8 *String, IN UINTN Length)
OC_TYPING_BUFFER_ENTRY Buffer[OC_TYPING_BUFFER_SIZE]
#define OC_BOOT_REDIRECT_VARIABLE_NAME
EFI_GUID gOcVendorVariableGuid
STATIC EFI_STATUS EFIAPI OcExitBootServices(IN EFI_HANDLE ImageHandle, IN UINTN MapKey)
STATIC VOID EFIAPI SetGetVariableHookHandler(IN EFI_EVENT Event, IN VOID *Context)
STATIC VOID ProtectMemoryRegions(IN UINTN MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize)
STATIC VOID FixRuntimeAttributes(IN BOOT_COMPAT_CONTEXT *BootCompat, IN UINT32 Type)
STATIC VOID DevirtualiseMmio(IN VOID *Context, IN UINTN MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize)
STATIC VOID ApplyBooterPatch(IN OUT UINT8 *ImageBase, IN UINTN ImageSize, IN OC_BOOTER_PATCH *Patch)
STATIC EFI_STATUS EFIAPI OcAllocatePool(IN EFI_MEMORY_TYPE PoolType, IN UINTN Size, OUT VOID **Buffer)
STATIC EFI_STATUS EFIAPI OcGetMemoryMap(IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, OUT UINTN *MapKey, OUT UINTN *DescriptorSize, OUT UINT32 *DescriptorVersion)
VOID InstallServiceOverrides(IN OUT BOOT_COMPAT_CONTEXT *BootCompat)
STATIC EFI_STATUS EFIAPI OcFreePages(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN Pages)
STATIC BOOLEAN InternalIsEfiBootRt(IN EFI_DEVICE_PATH_PROTOCOL *EfiBootRtDevicePath OPTIONAL, IN VOID *SourceBuffer OPTIONAL, IN UINTN SourceSize, IN EFI_LOADED_IMAGE_PROTOCOL *EfiBootLoadedImage)
STATIC EFI_STATUS EFIAPI OcStartImage(IN EFI_HANDLE ImageHandle, OUT UINTN *ExitDataSize, OUT CHAR16 **ExitData OPTIONAL)
STATIC EFI_STATUS EFIAPI OcLoadImage(IN BOOLEAN BootPolicy, IN EFI_HANDLE ParentImageHandle, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN VOID *SourceBuffer OPTIONAL, IN UINTN SourceSize, OUT EFI_HANDLE *ImageHandle)
STATIC EFI_STATUS EFIAPI OcFreePool(IN VOID *Buffer)
STATIC EFI_STATUS EFIAPI OcSetVirtualAddressMap(IN UINTN MemoryMapSize, IN UINTN DescriptorSize, IN UINT32 DescriptorVersion, IN EFI_MEMORY_DESCRIPTOR *MemoryMap)
STATIC EFI_STATUS EFIAPI OcGetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data)
STATIC EFI_STATUS EFIAPI OcAllocatePages(IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN NumberOfPages, IN OUT EFI_PHYSICAL_ADDRESS *Memory)
STATIC VOID ApplyBooterPatches(IN EFI_HANDLE ImageHandle, IN BOOLEAN IsApple, IN OC_BOOTER_PATCH *Patches, IN UINT32 PatchCount)
STATIC EFI_STATUS ForceExitBootServices(IN EFI_HANDLE ImageHandle, IN UINTN MapKey, IN EFI_EXIT_BOOT_SERVICES ExitBootServices OPTIONAL, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_GUID gEfiLoadedImageProtocolGuid
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
EFI_GUID gVMwareMacProtocolGuid
APPLE_EFI_BOOT_RT_KCG KernelCallGate
SERVICES_OVERRIDE_STATE ServiceState
UEFI_SERVICES_POINTERS ServicePtrs
BOOLEAN ProtectSecureBoot
BOOLEAN ProtectUefiServices
EFI_EVENT_NOTIFY * ExitBootServicesHandlers
BOOLEAN ForceExitBootServices
BOOLEAN RebuildAppleMemoryMap
BOOLEAN DisableVariableWrite
BOOLEAN ProvideCustomSlide
BOOLEAN AllowRelocationBlock
BOOLEAN ClearTaskSwitchBit
BOOLEAN EnableSafeModeSlide
VOID ** ExitBootServicesHandlerContexts
BOOLEAN EnableWriteUnprotector
OC_BOOTER_PATCH * BooterPatches
BOOLEAN SyncRuntimePermissions
BOOLEAN ProtectMemoryRegions
OC_FWRT_GET_CURRENT_CONFIG GetCurrent
OC_FWRT_GET_EXEC_AREA GetExecArea
OC_FWRT_ON_SET_ADDRESS_MAP OnSetAddressMap
OC_FWRT_SET_MAIN_CONFIG SetMain
BOOLEAN BootVariableRedirect
BOOLEAN ProtectSecureBoot
BOOLEAN ClearTaskSwitchBit
BOOLEAN RestrictedVariables
EFI_LOADED_IMAGE_PROTOCOL * LastAppleBootImage
OC_FIRMWARE_RUNTIME_PROTOCOL * FwRuntime
UINTN AppleBootNestedCount
BOOLEAN AppleHibernateWake
BOOLEAN AwaitingPerfAlloc
EFI_PHYSICAL_ADDRESS OldKernelCallGate
UINTN MemoryMapDescriptorSize
EFI_EXIT_BOOT_SERVICES ExitBootServices
EFI_IMAGE_START StartImage
EFI_ALLOCATE_POOL AllocatePool
EFI_ALLOCATE_PAGES AllocatePages
EFI_GET_VARIABLE GetVariable
EFI_GET_MEMORY_MAP GetMemoryMap