OpenCorePkg/Include/Library/OcAppleBootPolicyLib.h

162 lines
4.9 KiB
C
Executable File

/** @file
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.
**/
#ifndef OC_APPLE_BOOT_POLICY_LIB_H
#define OC_APPLE_BOOT_POLICY_LIB_H
#include <Protocol/AppleBootPolicy.h>
/**
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval EFI_ALREADY_STARTED The protocol has already been installed.
**/
EFI_STATUS
OcAppleBootPolicyInstallProtocol (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Discovered boot entry.
Note, inner resources must be freed with OcResetBootEntry.
**/
typedef struct OC_BOOT_ENTRY_ {
//
// Device path to booter or its directory.
//
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
//
// Obtained human visible name.
//
CHAR16 *Name;
//
// Obtained boot path directory.
//
CHAR16 *PathName;
//
// Should try booting from first dmg found in DevicePath.
//
BOOLEAN IsFolder;
//
// Heuristical value signalising about recovery os.
//
BOOLEAN IsRecovery;
} OC_BOOT_ENTRY;
/**
Describe boot entry contents by setting fields other than DevicePath.
@param[in] BootPolicy Apple Boot Policy Protocol.
@param[in] BootEntry Located boot entry.
@retval EFI_SUCCESS The entry point is described successfully.
**/
EFI_STATUS
OcDescribeBootEntry (
IN APPLE_BOOT_POLICY_PROTOCOL *BootPolicy,
IN OUT OC_BOOT_ENTRY *BootEntry
);
/**
Release boot entry contents allocated from pool.
@param[in,out] BootEntry Located boot entry.
**/
VOID
OcResetBootEntry (
IN OUT OC_BOOT_ENTRY *BootEntry
);
/**
Release boot entries.
@param[in,out] BootEntry Located boot entry array from pool.
@param[in] Count Boot entry count.
**/
VOID
OcFreeBootEntries (
IN OUT OC_BOOT_ENTRY *BootEntries,
IN UINTN Count
);
/**
Fill boot entry from device handle.
@param[in] BootPolicy Apple Boot Policy Protocol.
@param[in] Mode Lookup mode.
@param[in] Handle Device handle (with EfiSimpleFileSystem protocol).
@param[out] BootEntry Resulting boot entry.
@param[out] AlternateBootEntry Resulting alternate boot entry (e.g. recovery).
@retval 0 no entries were filled.
@retval 1 boot entry was filled.
@retval 2 boot entry and alternate entry were filled.
**/
UINTN
OcFillBootEntry (
IN APPLE_BOOT_POLICY_PROTOCOL *BootPolicy,
IN UINT32 Mode,
IN EFI_HANDLE Handle,
OUT OC_BOOT_ENTRY *BootEntry,
OUT OC_BOOT_ENTRY *AlternateBootEntry OPTIONAL
);
/**
Scan system for boot entries.
@param[in] BootPolicy Apple Boot Policy Protocol.
@param[in] Mode Lookup mode.
@param[out] BootEntries List of boot entries (allocated from pool).
@param[out] Count Number of boot entries.
@param[out] AllocCount Number of allocated boot entries.
@param[in] Describe Automatically fill description fields
@retval EFI_SUCCESS Executed successfully and found entries.
**/
EFI_STATUS
OcScanForBootEntries (
IN APPLE_BOOT_POLICY_PROTOCOL *BootPolicy,
IN UINT32 Mode,
OUT OC_BOOT_ENTRY **BootEntries,
OUT UINTN *Count,
OUT UINTN *AllocCount OPTIONAL,
IN BOOLEAN Describe
);
/**
Show simple boot entry selection menu and return chosen entry.
@param[in] BootEntries Described list of entries.
@param[in] Count Positive number of boot entries.
@param[in] DefaultEntry Default boot entry (DefaultEntry < Count).
@param[in] TimeOutSeconds Default entry selection timeout (pass 0 to ignore).
@param[in] ChosenBootEntry Chosen boot entry from BootEntries on success.
@retval EFI_SUCCESS Executed successfully and picked up an entry.
@retval EFI_ABORTED When the user chose to by pressing Esc or 0.
**/
EFI_STATUS
OcShowSimpleBootMenu (
IN OC_BOOT_ENTRY *BootEntries,
IN UINTN Count,
IN UINTN DefaultEntry,
IN UINTN TimeOutSeconds,
OUT OC_BOOT_ENTRY **ChosenBootEntry
);
#endif // OC_APPLE_BOOT_POLICY_LIB_H