OpenCore
1.0.4
OpenCore Bootloader
|
#include "BootManagementInternal.h"
#include <Protocol/DevicePath.h>
#include <Protocol/SimpleFileSystem.h>
#include <IndustryStandard/AppleCsrConfig.h>
#include <Guid/AppleVariable.h>
#include <Guid/FileInfo.h>
#include <Guid/GlobalVariable.h>
#include <Guid/Gpt.h>
#include <Guid/OcVariable.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcConsoleLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/OcDevicePathLib.h>
#include <Library/OcFileLib.h>
#include <Library/OcStringLib.h>
#include <Library/OcVariableLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
Go to the source code of this file.
Functions | |
STATIC EFI_DEVICE_PATH_PROTOCOL * | ExpandShortFormBootPath (IN OC_BOOT_CONTEXT *BootContext, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN LazyScan, OUT OC_BOOT_FILESYSTEM **FileSystem, OUT BOOLEAN *IsRoot) |
STATIC INTERNAL_ENTRY_VISIBILITY | ReadEntryVisibility (IN OC_PICKER_CONTEXT *Context, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) |
STATIC VOID | RegisterBootOption (IN OUT OC_BOOT_CONTEXT *BootContext, IN OUT OC_BOOT_FILESYSTEM *FileSystem, IN OC_BOOT_ENTRY *BootEntry) |
STATIC EFI_STATUS | AddBootEntryOnFileSystem (IN OUT OC_BOOT_CONTEXT *BootContext, IN OUT OC_BOOT_FILESYSTEM *FileSystem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN RecoveryPart, IN BOOLEAN Deduplicate) |
STATIC VOID | FreeBootEntry (IN OC_BOOT_ENTRY *BootEntry) |
EFI_STATUS | InternalAddBootEntryFromCustomEntry (IN OUT OC_BOOT_CONTEXT *BootContext, IN OUT OC_BOOT_FILESYSTEM *FileSystem, IN OC_PICKER_ENTRY *CustomEntry, IN BOOLEAN IsBootEntryProtocol) |
STATIC EFI_STATUS | AddBootEntryFromBless (IN OUT OC_BOOT_CONTEXT *BootContext, IN OUT OC_BOOT_FILESYSTEM *FileSystem, IN CONST CHAR16 **PredefinedPaths, IN UINTN NumPredefinedPaths, IN BOOLEAN LazyScan, IN BOOLEAN Deduplicate) |
STATIC EFI_STATUS | AddBootEntryFromSelfRecovery (IN OUT OC_BOOT_CONTEXT *BootContext, IN OUT OC_BOOT_FILESYSTEM *FileSystem) |
STATIC EFI_STATUS | AddBootEntryFromBootOption (IN OUT OC_BOOT_CONTEXT *BootContext, IN UINT16 BootOption, IN BOOLEAN LazyScan, IN OUT OC_BOOT_FILESYSTEM *CustomFileSystem, OUT UINT32 *CustomIndex, OPTIONAL IN EFI_HANDLE *EntryProtocolHandles, IN UINTN EntryProtocolHandleCount, OUT EFI_GUID *EntryProtocolPartuuid, OPTIONAL OUT CHAR16 **EntryProtocolId OPTIONAL) |
STATIC EFI_STATUS | AddFileSystemEntry (IN OUT OC_BOOT_CONTEXT *BootContext, IN EFI_HANDLE FileSystemHandle, OUT OC_BOOT_FILESYSTEM **FileSystemEntry OPTIONAL) |
STATIC OC_BOOT_FILESYSTEM * | CreateFileSystemForCustom (IN OUT CONST OC_BOOT_CONTEXT *BootContext) |
STATIC EFI_STATUS | AddFileSystemEntryForCustom (IN OUT OC_BOOT_CONTEXT *BootContext, IN OUT OC_BOOT_FILESYSTEM *FileSystem, IN UINT32 PrecreatedCustomIndex) |
STATIC VOID | FreeFileSystemEntry (IN OUT OC_BOOT_CONTEXT *BootContext, IN OC_BOOT_FILESYSTEM *FileSystemEntry) |
OC_BOOT_FILESYSTEM * | InternalFileSystemForHandle (IN OC_BOOT_CONTEXT *BootContext, IN EFI_HANDLE FileSystemHandle, IN BOOLEAN LazyScan, OUT BOOLEAN *AlreadySeen OPTIONAL) |
STATIC OC_BOOT_CONTEXT * | BuildFileSystemList (IN OC_PICKER_CONTEXT *Context, IN BOOLEAN Empty) |
VOID | OcFreeBootContext (IN OUT OC_BOOT_CONTEXT *Context) |
EFI_STATUS | OcSetDefaultBootRecovery (IN OUT OC_BOOT_CONTEXT *BootContext) |
OC_BOOT_CONTEXT * | OcScanForBootEntries (IN OC_PICKER_CONTEXT *Context) |
OC_BOOT_CONTEXT * | OcScanForDefaultBootEntry (IN OC_PICKER_CONTEXT *Context, IN BOOLEAN UseBootNextOnly) |
OC_BOOT_ENTRY ** | OcEnumerateEntries (IN OC_BOOT_CONTEXT *BootContext) |
EFI_STATUS | OcLoadBootEntry (IN OC_PICKER_CONTEXT *Context, IN OC_BOOT_ENTRY *BootEntry, IN EFI_HANDLE ParentHandle) |
Copyright (C) 2019-2022, vit9696, mikebeaton. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
Definition in file BootEntryManagement.c.
STATIC EFI_STATUS AddBootEntryFromBless | ( | IN OUT OC_BOOT_CONTEXT * | BootContext, |
IN OUT OC_BOOT_FILESYSTEM * | FileSystem, | ||
IN CONST CHAR16 ** | PredefinedPaths, | ||
IN UINTN | NumPredefinedPaths, | ||
IN BOOLEAN | LazyScan, | ||
IN BOOLEAN | Deduplicate ) |
Create bootable entries from bless policy. This function may create more than one entry, and for APFS it will likely produce a sequence of 'OS, RECOVERY' entry pairs.
[in,out] | BootContext | Context of filesystems. |
[in,out] | FileSystem | Filesystem to scan for bless. |
[in] | PredefinedPaths | The predefined boot file locations to scan. |
[in] | NumPredefinedPaths | The number of elements in PredefinedPaths. |
[in] | LazyScan | Lazy filesystem scanning. |
[in] | Deduplicate | Ensure that duplicated entries are not added. |
EFI_STATUS | for last created option. |
Definition at line 911 of file BootEntryManagement.c.
STATIC EFI_STATUS AddBootEntryFromBootOption | ( | IN OUT OC_BOOT_CONTEXT * | BootContext, |
IN UINT16 | BootOption, | ||
IN BOOLEAN | LazyScan, | ||
IN OUT OC_BOOT_FILESYSTEM * | CustomFileSystem, | ||
OUT UINT32 * | CustomIndex, | ||
OPTIONAL IN EFI_HANDLE * | EntryProtocolHandles, | ||
IN UINTN | EntryProtocolHandleCount, | ||
OUT EFI_GUID * | EntryProtocolPartuuid, | ||
OPTIONAL OUT CHAR16 **EntryProtocolId | OPTIONAL ) |
Create bootable entries from boot options.
[in,out] | BootContext | Context of filesystems. |
[in] | BootOption | Boot option number. |
[in] | LazyScan | Lazy filesystem scanning. |
[in,out] | CustomFileSystem | File system on which to add user defined custom option. If non-NULL still searching for first (normally only) OC custom entry, either user defined or entry protocol. |
[out] | CustomIndex | Index of custom user defined entry, if matched. |
[in] | EntryProtocolHandles | Installed Boot Entry Protocol handles. |
[in] | EntryProtocolHandleCount | Installed Boot Entry Protocol handle count. |
[out] | EntryProtocolPartuuid | Unique partition UUID of parition with entry protocol custom entry, if matched. |
[out] | EntryProtocolId | Id of entry protocol custom entry, if matched. |
EFI_SUCCESS | if at least one option was added. |
Definition at line 1223 of file BootEntryManagement.c.
STATIC EFI_STATUS AddBootEntryFromSelfRecovery | ( | IN OUT OC_BOOT_CONTEXT * | BootContext, |
IN OUT OC_BOOT_FILESYSTEM * | FileSystem ) |
Create bootable entries from recovery files (com.apple.recovery.boot) on the volume.
[in,out] | BootContext | Context of filesystems. |
[in,out] | FileSystem | Filesystem to scan for recovery. |
EFI_SUCCESS | on success. |
Definition at line 1160 of file BootEntryManagement.c.
STATIC EFI_STATUS AddBootEntryOnFileSystem | ( | IN OUT OC_BOOT_CONTEXT * | BootContext, |
IN OUT OC_BOOT_FILESYSTEM * | FileSystem, | ||
IN EFI_DEVICE_PATH_PROTOCOL * | DevicePath, | ||
IN BOOLEAN | RecoveryPart, | ||
IN BOOLEAN | Deduplicate ) |
Create single bootable entry from device path.
[in,out] | BootContext | Context of filesystems. |
[in,out] | FileSystem | Filesystem for creation. |
[in] | DevicePath | Device path of the entry. |
[in] | RecoveryPart | Device path is on recovery partition. |
[in] | Deduplicate | Ensure that duplicated entries are not added. |
EFI_SUCCESS | on success. |
Definition at line 398 of file BootEntryManagement.c.
STATIC EFI_STATUS AddFileSystemEntry | ( | IN OUT OC_BOOT_CONTEXT * | BootContext, |
IN EFI_HANDLE | FileSystemHandle, | ||
OUT OC_BOOT_FILESYSTEM **FileSystemEntry | OPTIONAL ) |
Allocate a new filesystem entry in boot entries in case it can be used according to current ScanPolicy.
[in,out] | BootContext | Context of filesystems. |
[in] | FileSystemHandle | Filesystem handle. |
[in] | FileSystemEntry | Resulting filesystem, optional. |
EFI_SUCCESS | on success. |
Definition at line 1726 of file BootEntryManagement.c.
STATIC EFI_STATUS AddFileSystemEntryForCustom | ( | IN OUT OC_BOOT_CONTEXT * | BootContext, |
IN OUT OC_BOOT_FILESYSTEM * | FileSystem, | ||
IN UINT32 | PrecreatedCustomIndex ) |
Definition at line 1835 of file BootEntryManagement.c.
STATIC OC_BOOT_CONTEXT * BuildFileSystemList | ( | IN OC_PICKER_CONTEXT * | Context, |
IN BOOLEAN | Empty ) |
Definition at line 1944 of file BootEntryManagement.c.
STATIC OC_BOOT_FILESYSTEM * CreateFileSystemForCustom | ( | IN OUT CONST OC_BOOT_CONTEXT * | BootContext | ) |
Definition at line 1804 of file BootEntryManagement.c.
STATIC EFI_DEVICE_PATH_PROTOCOL * ExpandShortFormBootPath | ( | IN OC_BOOT_CONTEXT * | BootContext, |
IN EFI_DEVICE_PATH_PROTOCOL * | DevicePath, | ||
IN BOOLEAN | LazyScan, | ||
OUT OC_BOOT_FILESYSTEM ** | FileSystem, | ||
OUT BOOLEAN * | IsRoot ) |
Definition at line 51 of file BootEntryManagement.c.
STATIC VOID FreeBootEntry | ( | IN OC_BOOT_ENTRY * | BootEntry | ) |
Release boot entry contents allocated from pool.
[in,out] | BootEntry | Located boot entry. |
Definition at line 594 of file BootEntryManagement.c.
STATIC VOID FreeFileSystemEntry | ( | IN OUT OC_BOOT_CONTEXT * | BootContext, |
IN OC_BOOT_FILESYSTEM * | FileSystemEntry ) |
Definition at line 1872 of file BootEntryManagement.c.
EFI_STATUS InternalAddBootEntryFromCustomEntry | ( | IN OUT OC_BOOT_CONTEXT * | BootContext, |
IN OUT OC_BOOT_FILESYSTEM * | FileSystem, | ||
IN OC_PICKER_ENTRY * | CustomEntry, | ||
IN BOOLEAN | IsBootEntryProtocol ) |
Create bootable entry from custom entry.
[in,out] | BootContext | Context of filesystems. |
[in,out] | FileSystem | Filesystem to add custom entry. |
[in] | CustomEntry | Custom entry. |
EFI_SUCCESS | on success. |
Definition at line 642 of file BootEntryManagement.c.
OC_BOOT_FILESYSTEM * InternalFileSystemForHandle | ( | IN OC_BOOT_CONTEXT * | BootContext, |
IN EFI_HANDLE | FileSystemHandle, | ||
IN BOOLEAN | LazyScan, | ||
OUT BOOLEAN *AlreadySeen | OPTIONAL ) |
Finds filesystem for discovered filesystem handle. This solves the problem of checking scan policy multiple times as well as the problem of finding the filesystem to add entries too.
[in] | BootContext | Context of filesystems. |
[in] | FileSystemHandle | Partition handle. |
[in] | LazyScan | Lazy filesystem scanning. |
[out] | AlreadySeen | Set to TRUE if file system was already present in context. |
discovered | filesystem (legit). @retcal NULL when booting is not allowed from this filesystem. |
Definition at line 1894 of file BootEntryManagement.c.
OC_BOOT_ENTRY ** OcEnumerateEntries | ( | IN OC_BOOT_CONTEXT * | BootContext | ) |
Perform boot entry enumeration.
[in] | BootContext | Boot context. |
enumerated | boot entry list allocated from pool. |
Definition at line 2506 of file BootEntryManagement.c.
VOID OcFreeBootContext | ( | IN OUT OC_BOOT_CONTEXT * | Context | ) |
Free boot context.
[in,out] | Context | Boot context to free. |
Definition at line 2000 of file BootEntryManagement.c.
EFI_STATUS OcLoadBootEntry | ( | IN OC_PICKER_CONTEXT * | Context, |
IN OC_BOOT_ENTRY * | BootEntry, | ||
IN EFI_HANDLE | ParentHandle ) |
Load & start boot entry loader image with given options.
[in] | Context | Picker context. |
[in] | BootEntry | Located boot entry. |
[in] | ParentHandle | Parent image handle. |
EFI_SUCCESS | The image was found, started, and ended succesfully. |
Definition at line 2549 of file BootEntryManagement.c.
OC_BOOT_CONTEXT * OcScanForBootEntries | ( | IN OC_PICKER_CONTEXT * | Context | ) |
Scan system for boot entries.
[in] | Context | Picker context. |
boot | context allocated from pool. |
< Index if Tools or Entries item is pre-created
< ID if boot entry protocol item is pre-created
< PARTUUID for pre-created boot entry protocol item
Definition at line 2102 of file BootEntryManagement.c.
OC_BOOT_CONTEXT * OcScanForDefaultBootEntry | ( | IN OC_PICKER_CONTEXT * | Context, |
IN BOOLEAN | UseBootNextOnly ) |
Scan system for first entry to boot. This is likely to return an incomplete list and can even give NULL, when only tools and system entries are present.
[in] | Context | Picker context. |
[in] | UseBootNextOnly | Use only BootNext. |
boot | context allocated from pool. |
Definition at line 2293 of file BootEntryManagement.c.
EFI_STATUS OcSetDefaultBootRecovery | ( | IN OUT OC_BOOT_CONTEXT * | BootContext | ) |
Definition at line 2017 of file BootEntryManagement.c.
STATIC INTERNAL_ENTRY_VISIBILITY ReadEntryVisibility | ( | IN OC_PICKER_CONTEXT * | Context, |
IN EFI_DEVICE_PATH_PROTOCOL * | DevicePath ) |
Check boot entry visibility by device path.
[in] | Context | Picker context. |
[in] | DevicePath | Device path of the entry. |
Definition at line 202 of file BootEntryManagement.c.
STATIC VOID RegisterBootOption | ( | IN OUT OC_BOOT_CONTEXT * | BootContext, |
IN OUT OC_BOOT_FILESYSTEM * | FileSystem, | ||
IN OC_BOOT_ENTRY * | BootEntry ) |
Register bootable entry on the filesystem.
[in,out] | BootContext | Context of filesystems. |
[in,out] | FileSystem | Filesystem for creation. |
[in] | BootEntry | Entry to register. |
Definition at line 310 of file BootEntryManagement.c.