OpenCore  1.0.4
OpenCore Bootloader
1.0.4
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
DefaultEntryChoice.c File Reference
#include <Uefi.h>
#include <Library/OcMainLib.h>
#include "BootManagementInternal.h"
#include <Guid/AppleFile.h>
#include <Guid/AppleVariable.h>
#include <Guid/GlobalVariable.h>
#include <Guid/Gpt.h>
#include <Guid/OcVariable.h>
#include <Protocol/DevicePath.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/OcFirmwareRuntime.h>
#include <Protocol/SimpleFileSystem.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PrintLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/OcDevicePathLib.h>
#include <Library/OcFileLib.h>
#include <Library/OcStringLib.h>
#include <Library/OcVariableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>

Go to the source code of this file.

Functions

CONST OC_CUSTOM_BOOT_DEVICE_PATHInternalGetOcCustomDevPath (IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
 
CONST OC_ENTRY_PROTOCOL_DEVICE_PATHInternalGetOcEntryProtocolDevPath (IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
 
EFI_DEVICE_PATH_PROTOCOL * InternalGetBootOptionPath (IN EFI_LOAD_OPTION *LoadOption, IN UINTN LoadOptionSize)
 
VOID InternalDebugBootEnvironment (IN CONST UINT16 *BootOrder, IN EFI_GUID *BootGuid, IN UINTN BootOrderCount)
 
STATIC BOOLEAN InternalMatchBootEntryByDevicePath (IN OUT OC_BOOT_ENTRY *BootEntry, IN EFI_DEVICE_PATH_PROTOCOL *UefiDevicePath, IN EFI_DEVICE_PATH_PROTOCOL *UefiRemainingDevicePath, IN UINTN UefiDevicePathSize, IN BOOLEAN IsBootNext)
 
STATIC BOOLEAN InternalMatchCustomBootEntryByDevicePath (IN OUT OC_BOOT_ENTRY *BootEntry, IN CONST OC_CUSTOM_BOOT_DEVICE_PATH *DevicePath)
 
STATIC BOOLEAN InternalMatchEntryProtocolEntryByDevicePath (IN OUT OC_BOOT_ENTRY *BootEntry, IN CONST OC_ENTRY_PROTOCOL_DEVICE_PATH *DevicePath)
 
STATIC VOID InternalClearNextVariables (IN EFI_GUID *BootVariableGuid, IN BOOLEAN ClearApplePayload)
 
STATIC BOOLEAN InternalHasFirmwareUpdateAsNext (IN EFI_GUID *BootVariableGuid)
 
BOOLEAN InternalIsAppleLegacyLoadApp (IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
 
UINT16 * OcGetBootOrder (IN EFI_GUID *BootVariableGuid, IN BOOLEAN WithBootNext, OUT UINTN *BootOrderCount, OUT BOOLEAN *Deduplicated OPTIONAL, OUT BOOLEAN *HasBootNext OPTIONAL, IN BOOLEAN UseBootNextOnly)
 
UINT16 * InternalGetBootOrderForBooting (IN EFI_GUID *BootVariableGuid, IN BOOLEAN BlacklistAppleUpdate, OUT UINTN *BootOrderCount, IN BOOLEAN UseBootNextOnly)
 
EFI_STATUS OcSetDefaultBootEntry (IN OC_PICKER_CONTEXT *Context, IN OC_BOOT_ENTRY *Entry)
 
EFI_LOAD_OPTION * InternalGetBoostrapOptionData (OUT UINTN *LoadOptionSize, OUT UINT16 *BootOption, OUT EFI_DEVICE_PATH_PROTOCOL **LoadPath, IN UINT16 *BootOptions, IN UINTN NumBootOptions, IN CONST CHAR16 *MatchSuffix, IN UINTN MatchSuffixLen)
 
STATIC EFI_STATUS InternalRegisterBootstrapBootOption (IN CONST CHAR16 *OptionName, IN EFI_HANDLE DeviceHandle, IN CONST CHAR16 *FilePath, IN BOOLEAN ShortForm, IN CONST CHAR16 *MatchSuffix, IN UINTN MatchSuffixLen)
 
EFI_STATUS OcRegisterBootstrapBootOption (IN CONST CHAR16 *OptionName, IN EFI_HANDLE DeviceHandle, IN CONST CHAR16 *FilePath, IN BOOLEAN ShortForm, IN CONST CHAR16 *MatchSuffix, IN UINTN MatchSuffixLen)
 
EFI_STATUS InternalLoadBootEntry (IN OC_PICKER_CONTEXT *Context, IN OC_BOOT_ENTRY *BootEntry, IN EFI_HANDLE ParentHandle, OUT EFI_HANDLE *EntryHandle, OUT INTERNAL_DMG_LOAD_CONTEXT *DmgLoadContext, OUT VOID **CustomFreeContext)
 

Variables

STATIC CONST OC_CUSTOM_BOOT_DEVICE_PATH_DECL mOcCustomBootDevPathTemplate
 
STATIC CONST OC_ENTRY_PROTOCOL_DEVICE_PATH_DECL mOcEntryProtocolDevPathTemplate
 

Detailed Description

Copyright (C) 2019-2021, vit9696, mikebeaton. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause

Definition in file DefaultEntryChoice.c.

Function Documentation

◆ InternalClearNextVariables()

STATIC VOID InternalClearNextVariables ( IN EFI_GUID * BootVariableGuid,
IN BOOLEAN ClearApplePayload )

Definition at line 409 of file DefaultEntryChoice.c.

◆ InternalDebugBootEnvironment()

VOID InternalDebugBootEnvironment ( IN CONST UINT16 * BootOrder,
IN EFI_GUID * BootGuid,
IN UINTN BootOrderCount )

Definition at line 186 of file DefaultEntryChoice.c.

◆ InternalGetBoostrapOptionData()

EFI_LOAD_OPTION * InternalGetBoostrapOptionData ( OUT UINTN * LoadOptionSize,
OUT UINT16 * BootOption,
OUT EFI_DEVICE_PATH_PROTOCOL ** LoadPath,
IN UINT16 * BootOptions,
IN UINTN NumBootOptions,
IN CONST CHAR16 * MatchSuffix,
IN UINTN MatchSuffixLen )

Definition at line 1188 of file DefaultEntryChoice.c.

◆ InternalGetBootOptionPath()

EFI_DEVICE_PATH_PROTOCOL * InternalGetBootOptionPath ( IN EFI_LOAD_OPTION * LoadOption,
IN UINTN LoadOptionSize )

Definition at line 141 of file DefaultEntryChoice.c.

◆ InternalGetBootOrderForBooting()

UINT16 * InternalGetBootOrderForBooting ( IN EFI_GUID * BootVariableGuid,
IN BOOLEAN BlacklistAppleUpdate,
OUT UINTN * BootOrderCount,
IN BOOLEAN UseBootNextOnly )

Definition at line 721 of file DefaultEntryChoice.c.

◆ InternalGetOcCustomDevPath()

CONST OC_CUSTOM_BOOT_DEVICE_PATH * InternalGetOcCustomDevPath ( IN CONST EFI_DEVICE_PATH_PROTOCOL * DevicePath)

Determines whether DevicePath is an OpenCore custom boot entry.

Returns
The OpenCore custom boot entry, or NULL.

Definition at line 75 of file DefaultEntryChoice.c.

◆ InternalGetOcEntryProtocolDevPath()

CONST OC_ENTRY_PROTOCOL_DEVICE_PATH * InternalGetOcEntryProtocolDevPath ( IN CONST EFI_DEVICE_PATH_PROTOCOL * DevicePath)

Determines whether DevicePath is a Boot Entry Protocol custom boot entry.

Returns
The Boot Entry Protocol custom boot entry, or NULL.

Definition at line 108 of file DefaultEntryChoice.c.

◆ InternalHasFirmwareUpdateAsNext()

STATIC BOOLEAN InternalHasFirmwareUpdateAsNext ( IN EFI_GUID * BootVariableGuid)

Definition at line 497 of file DefaultEntryChoice.c.

◆ InternalIsAppleLegacyLoadApp()

BOOLEAN InternalIsAppleLegacyLoadApp ( IN CONST EFI_DEVICE_PATH_PROTOCOL * DevicePath)

Definition at line 552 of file DefaultEntryChoice.c.

◆ InternalLoadBootEntry()

EFI_STATUS InternalLoadBootEntry ( IN OC_PICKER_CONTEXT * Context,
IN OC_BOOT_ENTRY * BootEntry,
IN EFI_HANDLE ParentHandle,
OUT EFI_HANDLE * EntryHandle,
OUT INTERNAL_DMG_LOAD_CONTEXT * DmgLoadContext,
OUT VOID ** CustomFreeContext )

Definition at line 1527 of file DefaultEntryChoice.c.

◆ InternalMatchBootEntryByDevicePath()

STATIC BOOLEAN InternalMatchBootEntryByDevicePath ( IN OUT OC_BOOT_ENTRY * BootEntry,
IN EFI_DEVICE_PATH_PROTOCOL * UefiDevicePath,
IN EFI_DEVICE_PATH_PROTOCOL * UefiRemainingDevicePath,
IN UINTN UefiDevicePathSize,
IN BOOLEAN IsBootNext )

Definition at line 287 of file DefaultEntryChoice.c.

◆ InternalMatchCustomBootEntryByDevicePath()

STATIC BOOLEAN InternalMatchCustomBootEntryByDevicePath ( IN OUT OC_BOOT_ENTRY * BootEntry,
IN CONST OC_CUSTOM_BOOT_DEVICE_PATH * DevicePath )

Definition at line 362 of file DefaultEntryChoice.c.

◆ InternalMatchEntryProtocolEntryByDevicePath()

STATIC BOOLEAN InternalMatchEntryProtocolEntryByDevicePath ( IN OUT OC_BOOT_ENTRY * BootEntry,
IN CONST OC_ENTRY_PROTOCOL_DEVICE_PATH * DevicePath )

Definition at line 383 of file DefaultEntryChoice.c.

◆ InternalRegisterBootstrapBootOption()

STATIC EFI_STATUS InternalRegisterBootstrapBootOption ( IN CONST CHAR16 * OptionName,
IN EFI_HANDLE DeviceHandle,
IN CONST CHAR16 * FilePath,
IN BOOLEAN ShortForm,
IN CONST CHAR16 * MatchSuffix,
IN UINTN MatchSuffixLen )

Definition at line 1248 of file DefaultEntryChoice.c.

◆ OcGetBootOrder()

UINT16 * OcGetBootOrder ( IN EFI_GUID * BootVariableGuid,
IN BOOLEAN WithBootNext,
OUT UINTN * BootOrderCount,
OUT BOOLEAN *Deduplicated OPTIONAL,
OUT BOOLEAN *HasBootNext OPTIONAL,
IN BOOLEAN UseBootNextOnly )

Obtain BootOrder entry list.

Parameters
[in]BootVariableGuidGUID namespace for boot entries.
[in]WithBootNextAdd BootNext as the first option if available.
[out]BootOrderCountNumber of entries in boot order.
[out]DeduplicatedWhether the list was changed during deduplication, optional.
[out]HasBootNextWhether the list starts with BootNext, optional
[in]UseBootNextOnlyReturn list containing BootNext entry only
Return values
bootorder entry list allocated from pool or NULL.

Definition at line 578 of file DefaultEntryChoice.c.

◆ OcRegisterBootstrapBootOption()

EFI_STATUS OcRegisterBootstrapBootOption ( IN CONST CHAR16 * OptionName,
IN EFI_HANDLE DeviceHandle,
IN CONST CHAR16 * FilePath,
IN BOOLEAN ShortForm,
IN CONST CHAR16 * MatchSuffix,
IN UINTN MatchSuffixLen )

Register top-most priority boot option. MatchSuffix allows for fuzzy replacement of the option, i.e. when a new option replaces an old one with a matching suffix but a different prefix.

Parameters
[in]OptionNameOption name to create.
[in]DeviceHandleDevice handle of the file system.
[in]FilePathBootloader path.
[in]ShortFormWhether the Device Path should be written in short-form.
[in]MatchSuffixThe file Device Path suffix of a matching option.
[in]MatchSuffixLenThe length, in characters, of MatchSuffix.
Return values
EFI_SUCCESSon success.

Definition at line 1498 of file DefaultEntryChoice.c.

◆ OcSetDefaultBootEntry()

EFI_STATUS OcSetDefaultBootEntry ( IN OC_PICKER_CONTEXT * Context,
IN OC_BOOT_ENTRY * Entry )

Set default entry to passed entry.

Parameters
[in]ContextPicker context.
[in,out]EntryEntry to make default.
Return values
EFI_SUCCESSon success.

Definition at line 772 of file DefaultEntryChoice.c.

Variable Documentation

◆ mOcCustomBootDevPathTemplate

STATIC CONST OC_CUSTOM_BOOT_DEVICE_PATH_DECL mOcCustomBootDevPathTemplate
Initial value:
= {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{ sizeof (VENDOR_DEVICE_PATH), 0 }
},
},
{
MEDIA_DEVICE_PATH,
MEDIA_FILEPATH_DP,
{ SIZE_OF_FILEPATH_DEVICE_PATH, 0 }
}
}
#define OC_CUSTOM_BOOT_DEVICE_PATH_GUID

Template for OpenCore custom boot entry DevicePath.

Definition at line 38 of file DefaultEntryChoice.c.

◆ mOcEntryProtocolDevPathTemplate

STATIC CONST OC_ENTRY_PROTOCOL_DEVICE_PATH_DECL mOcEntryProtocolDevPathTemplate
Initial value:
= {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{ sizeof (VENDOR_DEVICE_PATH) + sizeof (EFI_GUID), 0 }
},
},
EFI_PART_TYPE_UNUSED_GUID,
{
MEDIA_DEVICE_PATH,
MEDIA_FILEPATH_DP,
{ SIZE_OF_FILEPATH_DEVICE_PATH, 0 }
}
}
#define OC_ENTRY_PROTOCOL_DEVICE_PATH_GUID

Template for Boot Entry Protocol custom boot entry DevicePath.

Definition at line 57 of file DefaultEntryChoice.c.