OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcMainLib.h File Reference
#include <Library/BaseOverflowLib.h>
#include <Library/OcAppleKernelLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcConfigurationLib.h>
#include <Library/OcCpuLib.h>
#include <Library/OcCryptoLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcStringLib.h>
#include <Library/OcStorageLib.h>
#include <Protocol/OcBootstrap.h>

Go to the source code of this file.

Macros

#define OPEN_CORE_VERSION   "1.0.4"
 
#define OPEN_CORE_ROOT_PATH   L"EFI\\OC"
 
#define OPEN_CORE_APP_PATH   L"OpenCore.efi"
 
#define OPEN_CORE_CONFIG_PATH   L"config.plist"
 
#define OPEN_CORE_LOG_PREFIX_PATH   L"opencore"
 
#define OPEN_CORE_ACPI_PATH   L"ACPI\\"
 
#define OPEN_CORE_UEFI_DRIVER_PATH   L"Drivers\\"
 
#define OPEN_CORE_KEXT_PATH   L"Kexts\\"
 
#define OPEN_CORE_TOOL_PATH   L"Tools\\"
 

Functions

OC_RSA_PUBLIC_KEYOcGetVaultKey (VOID)
 
VOID OcLoadAcpiSupport (IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config)
 
VOID OcLoadDevPropsSupport (IN OC_GLOBAL_CONFIG *Config)
 
VOID OcLoadDrivers (IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config, OUT EFI_HANDLE **DriversToConnect OPTIONAL, IN BOOLEAN LoadEarly)
 
VOID OcLoadKernelSupport (IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config, IN OC_CPU_INFO *CpuInfo)
 
EFI_STATUS OcKernelApplyQuirk (IN KERNEL_QUIRK_NAME Quirk, IN KERNEL_CACHE_TYPE CacheType, IN UINT32 DarwinVersion, IN OUT VOID *Context, IN OUT PATCHER_CONTEXT *KernelPatcher)
 
VOID OcKernelInjectKexts (IN OC_GLOBAL_CONFIG *Config, IN KERNEL_CACHE_TYPE CacheType, IN VOID *Context, IN UINT32 DarwinVersion, IN BOOLEAN Is32Bit, IN UINT32 LinkedExpansion, IN UINT32 ReservedExeSize)
 
VOID OcKernelApplyPatches (IN OC_GLOBAL_CONFIG *Config, IN OC_CPU_INFO *CpuInfo, IN UINT32 DarwinVersion, IN BOOLEAN Is32Bit, IN KERNEL_CACHE_TYPE CacheType, IN VOID *Context, IN OUT UINT8 *Kernel, IN UINT32 Size)
 
VOID OcKernelBlockKexts (IN OC_GLOBAL_CONFIG *Config, IN UINT32 DarwinVersion, IN BOOLEAN Is32Bit, IN KERNEL_CACHE_TYPE CacheType, IN VOID *Context)
 
EFI_STATUS OcKernelProcessPrelinked (IN OC_GLOBAL_CONFIG *Config, IN UINT32 DarwinVersion, IN BOOLEAN Is32Bit, IN OUT UINT8 *Kernel, IN UINT32 *KernelSize, IN UINT32 AllocatedSize, IN UINT32 LinkedExpansion, IN UINT32 ReservedExeSize)
 
VOID OcUnloadKernelSupport (VOID)
 
VOID OcLoadNvramSupport (IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config)
 
VOID OcGetLegacySecureBootECID (IN OC_GLOBAL_CONFIG *Config, OUT UINT64 *ApECID)
 
CONST CHAR8 * OcGetDefaultSecureBootModel (IN OC_GLOBAL_CONFIG *Config, IN OC_CPU_INFO *CpuInfo)
 
VOID OcLoadPlatformSupport (IN OC_GLOBAL_CONFIG *Config, IN OC_CPU_INFO *CpuInfo)
 
VOID OcLoadUefiSupport (IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config, IN OC_CPU_INFO *CpuInfo, IN UINT8 *Signature)
 
VOID OcLoadUefiInputSupport (IN OC_GLOBAL_CONFIG *Config)
 
VOID OcLoadUefiOutputSupport (IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config)
 
VOID OcLoadUefiAudioSupport (IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config)
 
VOID OcScheduleExitBootServices (IN EFI_EVENT_NOTIFY Handler, IN VOID *Context)
 
CONST CHAR8 * OcMiscGetVersionString (VOID)
 
EFI_STATUS OcMiscEarlyInit (IN OC_STORAGE_CONTEXT *Storage, OUT OC_GLOBAL_CONFIG *Config, IN OC_RSA_PUBLIC_KEY *VaultKey OPTIONAL)
 
VOID OcMiscMiddleInit (IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config, IN CONST CHAR16 *RootPath, IN EFI_DEVICE_PATH_PROTOCOL *LoadPath, IN EFI_HANDLE StorageHandle, OUT UINT8 *Signature OPTIONAL)
 
EFI_STATUS OcMiscLateInit (IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config)
 
VOID OcMiscLoadSystemReport (IN OC_GLOBAL_CONFIG *Config, IN EFI_HANDLE LoadHandle OPTIONAL)
 
VOID OcMiscBoot (IN OC_STORAGE_CONTEXT *Storage, IN OC_GLOBAL_CONFIG *Config, IN OC_PRIVILEGE_CONTEXT *Privilege OPTIONAL, IN OC_IMAGE_START StartImage, IN BOOLEAN CustomBootGuid, IN EFI_HANDLE LoadHandle)
 
VOID OcMiscUefiQuirksLoaded (IN OC_GLOBAL_CONFIG *Config)
 
BOOLEAN OcPlatformIs64BitSupported (IN UINT32 KernelVersion)
 
VOID OcUnloadDrivers (IN OC_GLOBAL_CONFIG *Config)
 
EFI_STATUS OcDriverInfoDump (IN EFI_FILE_PROTOCOL *Root)
 

Detailed Description

Copyright (C) 2021, vit9696. All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file OcMainLib.h.

Macro Definition Documentation

◆ OPEN_CORE_ACPI_PATH

#define OPEN_CORE_ACPI_PATH   L"ACPI\\"

Definition at line 56 of file OcMainLib.h.

◆ OPEN_CORE_APP_PATH

#define OPEN_CORE_APP_PATH   L"OpenCore.efi"

Definition at line 50 of file OcMainLib.h.

◆ OPEN_CORE_CONFIG_PATH

#define OPEN_CORE_CONFIG_PATH   L"config.plist"

Definition at line 52 of file OcMainLib.h.

◆ OPEN_CORE_KEXT_PATH

#define OPEN_CORE_KEXT_PATH   L"Kexts\\"

Definition at line 60 of file OcMainLib.h.

◆ OPEN_CORE_LOG_PREFIX_PATH

#define OPEN_CORE_LOG_PREFIX_PATH   L"opencore"

Definition at line 54 of file OcMainLib.h.

◆ OPEN_CORE_ROOT_PATH

#define OPEN_CORE_ROOT_PATH   L"EFI\\OC"

OpenCore build type reported to log and NVRAM.

Definition at line 48 of file OcMainLib.h.

◆ OPEN_CORE_TOOL_PATH

#define OPEN_CORE_TOOL_PATH   L"Tools\\"

Definition at line 62 of file OcMainLib.h.

◆ OPEN_CORE_UEFI_DRIVER_PATH

#define OPEN_CORE_UEFI_DRIVER_PATH   L"Drivers\\"

Definition at line 58 of file OcMainLib.h.

◆ OPEN_CORE_VERSION

#define OPEN_CORE_VERSION   "1.0.4"

OpenCore version reported to log and NVRAM. OPEN_CORE_VERSION must follow X.Y.Z format, where X.Y.Z are single digits.

Definition at line 33 of file OcMainLib.h.

Function Documentation

◆ OcDriverInfoDump()

EFI_STATUS OcDriverInfoDump ( IN EFI_FILE_PROTOCOL * Root)

Dump loaded image driver info to the specified directory.

Parameters
[in]RootDirectory to write CPU data.
Return values
EFI_SUCCESSon success.

Definition at line 328 of file OpenCoreUefiUnloadDrivers.c.

◆ OcGetDefaultSecureBootModel()

CONST CHAR8 * OcGetDefaultSecureBootModel ( IN OC_GLOBAL_CONFIG * Config,
IN OC_CPU_INFO * CpuInfo )

Obtain default Secure Boot hardware model.

Parameters
[in]ConfigConfiguration.
[in]CpuInfoCPU information.
Returns
Apple Secure Boot model.

Definition at line 958 of file OpenCorePlatform.c.

◆ OcGetLegacySecureBootECID()

VOID OcGetLegacySecureBootECID ( IN OC_GLOBAL_CONFIG * Config,
OUT UINT64 * ApECID )

Obtain Legacy Secure Boot ECID (system-id).

Parameters
[in]ConfigConfiguration.
[out]ApECIDLegacy Secure Boot ECID.

Definition at line 873 of file OpenCorePlatform.c.

◆ OcGetVaultKey()

OC_RSA_PUBLIC_KEY * OcGetVaultKey ( VOID )

Obtain cryptographic key if it was installed.

Parameters
[in]Bootstrapbootstrap protocol.
Returns
public key or NULL.

Definition at line 37 of file OpenCoreVault.c.

◆ OcKernelApplyPatches()

VOID OcKernelApplyPatches ( IN OC_GLOBAL_CONFIG * Config,
IN OC_CPU_INFO * CpuInfo,
IN UINT32 DarwinVersion,
IN BOOLEAN Is32Bit,
IN KERNEL_CACHE_TYPE CacheType,
IN VOID * Context,
IN OUT UINT8 * Kernel,
IN UINT32 Size )

Apply kernel patch.

Definition at line 76 of file OpenCoreKernelPatch.c.

◆ OcKernelApplyQuirk()

EFI_STATUS OcKernelApplyQuirk ( IN KERNEL_QUIRK_NAME Quirk,
IN KERNEL_CACHE_TYPE CacheType,
IN UINT32 DarwinVersion,
IN OUT VOID * Context,
IN OUT PATCHER_CONTEXT * KernelPatcher )

Apply kernel quirk.

Definition at line 33 of file OpenCoreKernelPatch.c.

◆ OcKernelBlockKexts()

VOID OcKernelBlockKexts ( IN OC_GLOBAL_CONFIG * Config,
IN UINT32 DarwinVersion,
IN BOOLEAN Is32Bit,
IN KERNEL_CACHE_TYPE CacheType,
IN VOID * Context )

Apply kernel block patch.

Definition at line 393 of file OpenCoreKernelPatch.c.

◆ OcKernelInjectKexts()

VOID OcKernelInjectKexts ( IN OC_GLOBAL_CONFIG * Config,
IN KERNEL_CACHE_TYPE CacheType,
IN VOID * Context,
IN UINT32 DarwinVersion,
IN BOOLEAN Is32Bit,
IN UINT32 LinkedExpansion,
IN UINT32 ReservedExeSize )

Inject kexts.

Definition at line 685 of file OpenCoreKernel.c.

◆ OcKernelProcessPrelinked()

EFI_STATUS OcKernelProcessPrelinked ( IN OC_GLOBAL_CONFIG * Config,
IN UINT32 DarwinVersion,
IN BOOLEAN Is32Bit,
IN OUT UINT8 * Kernel,
IN UINT32 * KernelSize,
IN UINT32 AllocatedSize,
IN UINT32 LinkedExpansion,
IN UINT32 ReservedExeSize )

Process prelinked.

Definition at line 767 of file OpenCoreKernel.c.

◆ OcLoadAcpiSupport()

VOID OcLoadAcpiSupport ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_GLOBAL_CONFIG * Config )

Load ACPI compatibility support like custom tables.

Parameters
[in]StorageOpenCore storage.
[in]ConfigOpenCore configuration.

Definition at line 212 of file OpenCoreAcpi.c.

◆ OcLoadDevPropsSupport()

VOID OcLoadDevPropsSupport ( IN OC_GLOBAL_CONFIG * Config)

Load device properties compatibility support.

Parameters
[in]ConfigOpenCore configuration.

Definition at line 31 of file OpenCoreDevProps.c.

◆ OcLoadDrivers()

VOID OcLoadDrivers ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_GLOBAL_CONFIG * Config,
OUT EFI_HANDLE **DriversToConnect OPTIONAL,
IN BOOLEAN LoadEarly )

Load drivers.

Parameters
[in]StorageOpenCore storage.
[in]ConfigOpenCore configuration.
[in]DriversToConnectDrivers which require later connection.
[in]LoadEarlyIf TRUE load any early phase drivers, otherwise load normal phase.

Definition at line 88 of file OpenCoreUefi.c.

◆ OcLoadKernelSupport()

VOID OcLoadKernelSupport ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_GLOBAL_CONFIG * Config,
IN OC_CPU_INFO * CpuInfo )

Load Kernel compatibility support like kexts.

Parameters
[in]StorageOpenCore storage.
[in]ConfigOpenCore configuration.
[in]CpuInfoCPU information.

Definition at line 1530 of file OpenCoreKernel.c.

◆ OcLoadNvramSupport()

VOID OcLoadNvramSupport ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_GLOBAL_CONFIG * Config )

Load NVRAM compatibility support.

Parameters
[in]StorageOpenCore storage.
[in]ConfigOpenCore configuration.

Definition at line 207 of file OpenCoreNvram.c.

◆ OcLoadPlatformSupport()

VOID OcLoadPlatformSupport ( IN OC_GLOBAL_CONFIG * Config,
IN OC_CPU_INFO * CpuInfo )

Load platform compatibility support like DataHub or SMBIOS.

Parameters
[in]ConfigOpenCore configuration.
[in]CpuInfoCPU information.

Definition at line 757 of file OpenCorePlatform.c.

◆ OcLoadUefiAudioSupport()

VOID OcLoadUefiAudioSupport ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_GLOBAL_CONFIG * Config )

Load UEFI audio compatibility support.

Parameters
[in]StorageOpenCore storage.
[out]ConfigOpenCore configuration.

Definition at line 268 of file OpenCoreUefiAudio.c.

◆ OcLoadUefiInputSupport()

VOID OcLoadUefiInputSupport ( IN OC_GLOBAL_CONFIG * Config)

Load UEFI input compatibility support.

Parameters
[out]ConfigOpenCore configuration.

Definition at line 104 of file OpenCoreUefiInOut.c.

◆ OcLoadUefiOutputSupport()

VOID OcLoadUefiOutputSupport ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_GLOBAL_CONFIG * Config )

Load UEFI output compatibility support.

Parameters
[in]StorageOpenCore storage.
[out]ConfigOpenCore configuration.

Definition at line 184 of file OpenCoreUefiInOut.c.

◆ OcLoadUefiSupport()

VOID OcLoadUefiSupport ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_GLOBAL_CONFIG * Config,
IN OC_CPU_INFO * CpuInfo,
IN UINT8 * Signature )

Load UEFI compatibility support like drivers.

Parameters
[in]StorageOpenCore storage.
[in]ConfigOpenCore configuration.
[in]CpuInfoCPU information.
[out]SignatureOpenCore SHA-1 booter signature, all zero when unavailable.

Definition at line 887 of file OpenCoreUefi.c.

◆ OcMiscBoot()

VOID OcMiscBoot ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_GLOBAL_CONFIG * Config,
IN OC_PRIVILEGE_CONTEXT *Privilege OPTIONAL,
IN OC_IMAGE_START StartImage,
IN BOOLEAN CustomBootGuid,
IN EFI_HANDLE LoadHandle )

Load late miscellaneous support like boot screen config.

Parameters
[in]StorageOpenCore storage.
[in]ConfigOpenCore configuration.
[in]PrivilegeOpenCore privilege context.
[in]StartImageImage starting routine used.
[in]LoadHandleOpenCore loading handle.
[in]CustomBootGuidUse custom (gOcVendorVariableGuid) for Boot#### variables.

< Always true for entries

Definition at line 798 of file OpenCoreMisc.c.

◆ OcMiscEarlyInit()

EFI_STATUS OcMiscEarlyInit ( IN OC_STORAGE_CONTEXT * Storage,
OUT OC_GLOBAL_CONFIG * Config,
IN OC_RSA_PUBLIC_KEY *VaultKey OPTIONAL )

Load early miscellaneous support like configuration.

Parameters
[in]StorageOpenCore storage.
[out]ConfigOpenCore configuration.
[in]VaultKeyVault key.
Return values
EFI_SUCCESSwhen allowed to continue.

< Should be unreachable.

< Should be unreachable.

< Should be unreachable.

< Should be unreachable.

< Should be unreachable.

Definition at line 439 of file OpenCoreMisc.c.

◆ OcMiscGetVersionString()

CONST CHAR8 * OcMiscGetVersionString ( VOID )

Get human readable version string.

Return values
null-terminated7-bit ASCII version string.

Force the assertions in case we forget about them.

Definition at line 372 of file OpenCoreMisc.c.

◆ OcMiscLateInit()

EFI_STATUS OcMiscLateInit ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_GLOBAL_CONFIG * Config )

Load late miscellaneous support like Apple hibernation or panic saving.

Parameters
[in]StorageOpenCore storage.
[in]ConfigOpenCore configuration.
Return values
EFI_SUCCESSon success, informational.

Definition at line 743 of file OpenCoreMisc.c.

◆ OcMiscLoadSystemReport()

VOID OcMiscLoadSystemReport ( IN OC_GLOBAL_CONFIG * Config,
IN EFI_HANDLE LoadHandle OPTIONAL )

Load system report.

Parameters
[in]LoadHandleOpenCore loading handle.
Return values
EFI_SUCCESSon success, informational.

Definition at line 787 of file OpenCoreMisc.c.

◆ OcMiscMiddleInit()

VOID OcMiscMiddleInit ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_GLOBAL_CONFIG * Config,
IN CONST CHAR16 * RootPath,
IN EFI_DEVICE_PATH_PROTOCOL * LoadPath,
IN EFI_HANDLE StorageHandle,
OUT UINT8 *Signature OPTIONAL )

Load middle miscellaneous support like device path.

Parameters
[in]StorageOpenCore storage.
[in]ConfigOpenCore configuration.
[in]RootPathRoot load path (e.g. path to OC directory).
[in]LoadPathOpenCore loading device path (absolute).
[in]StorageHandleOpenCore storage loading handle (e.g. FS handle).
[out]SignatureOpenCore SHA-1 booter signature, optional.
Return values
EFI_SUCCESSon success, informational.

Definition at line 639 of file OpenCoreMisc.c.

◆ OcMiscUefiQuirksLoaded()

VOID OcMiscUefiQuirksLoaded ( IN OC_GLOBAL_CONFIG * Config)

Load miscellaneous support after UEFI quirks.

Parameters
[in]ConfigOpenCore configuration.

Definition at line 1053 of file OpenCoreMisc.c.

◆ OcPlatformIs64BitSupported()

BOOLEAN OcPlatformIs64BitSupported ( IN UINT32 KernelVersion)

Determine platform support for 64-bit kernel mode based on kernel version.

Parameters
[in]KernelVersionKernel version.

Definition at line 1022 of file OpenCorePlatform.c.

◆ OcScheduleExitBootServices()

VOID OcScheduleExitBootServices ( IN EFI_EVENT_NOTIFY Handler,
IN VOID * Context )

Schedule Exit Boot Services event in TPL_APPLICATION mode.

Parameters
[in]HandlerHandler function to invoke.
[in]ContextHandler function context.

Definition at line 72 of file OpenCoreUefi.c.

◆ OcUnloadDrivers()

VOID OcUnloadDrivers ( IN OC_GLOBAL_CONFIG * Config)

Unload loaded images by name.

Parameters
[in]ConfigOpenCore configuration.

Definition at line 263 of file OpenCoreUefiUnloadDrivers.c.

◆ OcUnloadKernelSupport()

VOID OcUnloadKernelSupport ( VOID )

Cleanup Kernel compatibility support on failure.

Definition at line 1581 of file OpenCoreKernel.c.