OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcAppleBootPolicyLib.h File Reference

Go to the source code of this file.

Functions

APPLE_BOOT_POLICY_PROTOCOLOcAppleBootPolicyInstallProtocol (IN BOOLEAN Reinstall)
 
EFI_STATUS OcGetBooterFromPredefinedPathList (IN EFI_HANDLE Device, IN EFI_FILE_PROTOCOL *Root, IN CONST CHAR16 **PredefinedPaths, IN UINTN NumPredefinedPaths, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath OPTIONAL, IN CHAR16 *Prefix OPTIONAL)
 
EFI_STATUS OcBootPolicyGetBootFile (IN EFI_HANDLE Device, IN CONST CHAR16 **PredefinedPaths, IN UINTN NumPredefinedPaths, IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath)
 
EFI_STATUS OcBootPolicyGetBootFileEx (IN EFI_HANDLE Device, IN CONST CHAR16 **PredefinedPaths, IN UINTN NumPredefinedPaths, OUT EFI_DEVICE_PATH_PROTOCOL **FilePath)
 
EFI_STATUS OcBootPolicyDevicePathToDirPath (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT CHAR16 **BootPathName, OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **FileSystem)
 
EFI_STATUS OcBootPolicyDevicePathToFilePath (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT CHAR16 **BootPathName)
 
EFI_STATUS OcBootPolicyGetApfsRecoveryFilePath (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST CHAR16 *PathName, IN CONST CHAR16 **PredefinedPaths, IN UINTN NumPredefinedPaths, OUT CHAR16 **FullPathName, OUT EFI_FILE_PROTOCOL **Root, OUT EFI_HANDLE *DeviceHandle)
 
EFI_STATUS OcBootPolicyGetAllApfsRecoveryFilePath (IN EFI_HANDLE Handle OPTIONAL, OUT VOID **Volumes, OUT UINTN *NumberOfEntries)
 

Variables

CONST CHAR16 * gAppleBootPolicyPredefinedPaths []
 
CONST UINTN gAppleBootPolicyNumPredefinedPaths
 
CONST UINTN gAppleBootPolicyCoreNumPredefinedPaths
 

Detailed Description

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

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 OcAppleBootPolicyLib.h.

Function Documentation

◆ OcAppleBootPolicyInstallProtocol()

APPLE_BOOT_POLICY_PROTOCOL * OcAppleBootPolicyInstallProtocol ( IN BOOLEAN Reinstall)

Install and initialise Apple Boot policy protocol.

Parameters
[in]ReinstallOverwrite installed protocol.
Return values
installedor located protocol or NULL.

Definition at line 1716 of file OcAppleBootPolicyLib.c.

◆ OcBootPolicyDevicePathToDirPath()

EFI_STATUS OcBootPolicyDevicePathToDirPath ( IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
OUT CHAR16 ** BootPathName,
OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL ** FileSystem )

Retrieves folder and file system associated with DevicePath.

Parameters
[in]DevicePathThe device path to describe.
[out]BootPathNameA pointer into which the folder portion of DevicePath is returned. When EFI_SUCCESS is returned, caller is responsible for freeing this pool memory.
[out]FileSystemA pointer into which the simple file system for the folder is returned.
Return values
EFI_SUCCESSThe operation has been completed successfully.
otherDevicePath is not a valid file path.

Definition at line 1088 of file OcAppleBootPolicyLib.c.

◆ OcBootPolicyDevicePathToFilePath()

EFI_STATUS OcBootPolicyDevicePathToFilePath ( IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
OUT CHAR16 ** BootPathName )

Retrieves file path associated with DevicePath.

Parameters
[in]DevicePathThe device path to describe.
[out]BootPathNameA pointer into which the file path for DevicePath is returned. When EFI_SUCCESS is returned, caller is responsible for freeing this pool memory.
Return values
EFI_SUCCESSThe operation has been completed successfully.
otherDevicePath is not a valid file path.

Definition at line 1127 of file OcAppleBootPolicyLib.c.

◆ OcBootPolicyGetAllApfsRecoveryFilePath()

EFI_STATUS OcBootPolicyGetAllApfsRecoveryFilePath ( IN EFI_HANDLE Handle OPTIONAL,
OUT VOID ** Volumes,
OUT UINTN * NumberOfEntries )

Definition at line 1471 of file OcAppleBootPolicyLib.c.

◆ OcBootPolicyGetApfsRecoveryFilePath()

EFI_STATUS OcBootPolicyGetApfsRecoveryFilePath ( IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
IN CONST CHAR16 * PathName,
IN CONST CHAR16 ** PredefinedPaths,
IN UINTN NumPredefinedPaths,
OUT CHAR16 ** FullPathName,
OUT EFI_FILE_PROTOCOL ** Root,
OUT EFI_HANDLE * DeviceHandle )

Retrieves path info for the APFS Recovery volume associated with the APFS volume given by DevicePath.

Parameters
[in]DevicePathThe device path to the APFS recovery volume.
[in]PathNameThe file path to open.
[in]PredefinedPathsAn array of file paths to scan for if no file was blessed.
[in]NumPredefinedPathsThe number of paths in PredefinedPaths.
[out]FullPathNameA pointer into which the full file path for DevicePath and PathName is returned.
[out]RootA pointer into which the opened Recovery volume root protocol is returned.
[out]DeviceHandleA pointer into which the device handle of DevicePath is returned.
Return values
EFI_SUCCESSThe operation has been completed successfully.
EFI_NOT_FOUNDThe file path could not be found.
otherAn unexpected error has occured.

Definition at line 1227 of file OcAppleBootPolicyLib.c.

◆ OcBootPolicyGetBootFile()

EFI_STATUS OcBootPolicyGetBootFile ( IN EFI_HANDLE Device,
IN CONST CHAR16 ** PredefinedPaths,
IN UINTN NumPredefinedPaths,
IN OUT EFI_DEVICE_PATH_PROTOCOL ** FilePath )

Locates the bootable file of the given volume. Prefered are the values blessed, though if unavailable, hard-coded names are being verified and used if existing.

The blessed paths are to be determined by the HFS Driver via EFI_FILE_PROTOCOL.GetInfo(). The related identifier definitions are to be found in AppleBless.h.

Parameters
[in]DeviceThe device's Handle to perform the search on.
[in]PredefinedPathsAn array of file paths to scan for if no file was blessed.
[in]NumPredefinedPathsThe number of paths in PredefinedPaths.
[out]FilePathA pointer to the device path pointer to set to the file path of the boot file.
Return values
EFI_NOT_FOUNDA bootable file could not be found on the given volume.
EFI_OUT_OF_RESOURCESThe memory necessary to complete the operation could not be allocated.
EFI_SUCCESSThe operation completed successfully and the BootFilePath Buffer has been filled.
otherThe status of an operation used to complete this operation is returned.

Definition at line 876 of file OcAppleBootPolicyLib.c.

◆ OcBootPolicyGetBootFileEx()

EFI_STATUS OcBootPolicyGetBootFileEx ( IN EFI_HANDLE Device,
IN CONST CHAR16 ** PredefinedPaths,
IN UINTN NumPredefinedPaths,
OUT EFI_DEVICE_PATH_PROTOCOL ** FilePath )

Please refer to OcBootPolicyGetBootFile. This function extends the functionality by supporting the APFS Preboot scheme.

Parameters
[in]DeviceThe device's Handle to perform the search on.
[in]PredefinedPathsAn array of file paths to scan for if no file was blessed.
[in]NumPredefinedPathsThe number of paths in PredefinedPaths.
[out]FilePathA pointer to the device path pointer to set to the file path of the boot file.
Return values
EFI_NOT_FOUNDA bootable file could not be found on the given volume.
EFI_OUT_OF_RESOURCESThe memory necessary to complete the operation could not be allocated.
EFI_SUCCESSThe operation completed successfully and the BootFilePath Buffer has been filled.
otherThe status of an operation used to complete this operation is returned.

Definition at line 950 of file OcAppleBootPolicyLib.c.

◆ OcGetBooterFromPredefinedPathList()

EFI_STATUS OcGetBooterFromPredefinedPathList ( IN EFI_HANDLE Device,
IN EFI_FILE_PROTOCOL * Root,
IN CONST CHAR16 ** PredefinedPaths,
IN UINTN NumPredefinedPaths,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath OPTIONAL,
IN CHAR16 *Prefix OPTIONAL )

Definition at line 364 of file OcAppleBootPolicyLib.c.

Variable Documentation

◆ gAppleBootPolicyCoreNumPredefinedPaths

CONST UINTN gAppleBootPolicyCoreNumPredefinedPaths
extern

Core Apple Boot Policy predefined booter paths.

Definition at line 83 of file OcAppleBootPolicyLib.c.

◆ gAppleBootPolicyNumPredefinedPaths

CONST UINTN gAppleBootPolicyNumPredefinedPaths
extern

All Apple Boot Policy predefined booter paths.

Definition at line 80 of file OcAppleBootPolicyLib.c.

◆ gAppleBootPolicyPredefinedPaths

CONST CHAR16* gAppleBootPolicyPredefinedPaths[]
extern

An array of file paths to search for in case no file is blessed. On Apple Macs this list includes:

  1. APPLE_BOOTER_DEFAULT_FILE_NAME – \System\Library\CoreServices\boot.efi
  2. APPLE_REMOVABLE_MEDIA_FILE_NAME – \EFI\APPLE\X64\BOOT.EFI
  3. EFI_REMOVABLE_MEDIA_FILE_NAME – \EFI\BOOT\BOOTX64.EFI
  4. APPLE_BOOTER_ROOT_FILE_NAME – \boot.efi

Since in real world only 1st and 3rd entries are used, we do not include 2nd and 4th until further notice. However, we do include a custom entry for Windows, for the reason OpenCore, unlike Apple EFI, may override BOOTx64.efi, and this is not the case for Apple EFI. So we end up with:

  1. APPLE_BOOTER_DEFAULT_FILE_NAME – \System\Library\CoreServices\boot.efi
  2. MS_BOOTER_DEFAULT_FILE_NAME – \EFI\Microsoft\Boot\bootmgfw.efi
  3. EFI_REMOVABLE_MEDIA_FILE_NAME – \EFI\BOOT\BOOTX64.EFI

This resolves a problem when Windows installer does not replace our BOOTx64.efi file with Windows file and then NVRAM reset or Boot Camp software reboot to macOS results in the removal of the Windows boot entry from NVRAM making Windows disappear from the list of OpenCore entries without BlessOverride.

Linux and related entries are not present here, because they have fine working software for boot management and do not use BOOTx64.efi in the first place.

Definition at line 74 of file OcAppleBootPolicyLib.c.