/** @file
BDS library definition, include the file and data structure
;******************************************************************************
;* Copyright (c) 2012 - 2021, Insyde Software Corp. All Rights Reserved.
;*
;* You may not reproduce, distribute, publish, display, perform, modify, adapt,
;* transmit, broadcast, present, recite, release, license or otherwise exploit
;* any part of this publication in any form, by any means, without the prior
;* written permission of Insyde Software Corporation.
;*
;******************************************************************************
Copyright (c) 2004 - 2011, Intel Corporation. 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 _INTERNAL_BDS_LIB_H_
#define _INTERNAL_BDS_LIB_H_
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "PerformanceTokens.h"
#include "String.h"
#include "Checkpoint.h"
#include
#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
#if defined (MDE_CPU_EBC)
//
// Uefi specification only defines the default boot file name for IA32, X64
// and IPF processor, so need define boot file name for EBC architecture here.
//
#define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
#else
#error "Can not determine the default boot file name for unknown processor type!"
#endif
#endif
#if defined (MDE_CPU_IA32)
#define ARCHITECTURE_NAME L"ia32"
#elif defined (MDE_CPU_X64)
#define ARCHITECTURE_NAME L"x64"
#elif defined (MDE_CPU_ARM)
#define ARCHITECTURE_NAME L"arm"
#elif defined (MDE_CPU_AARCH64)
#define ARCHITECTURE_NAME L"aarch64"
#else
#error Unknown Processor Type
#endif
typedef struct {
CHAR16 *FilePathString;
CHAR16 *Description;
}BDS_GENERAL_UEFI_BOOT_OS;
#define RESOURCE_SECTION_RESOURCE_TYPE_VERSION 16
#define VS_FIXEDFILEINFO_SIGNATURE 0xFEEF04BD
#define MICROSOFT_OS_VERSION_WINDOWS_8 0x00060002
typedef struct {
UINT32 Signature;
UINT32 StrucVersion;
UINT32 FileVersionMS;
UINT32 FileVersionLS;
UINT32 ProductVersionMS;
UINT32 ProductVersionLS;
UINT32 FileFlagsMask;
UINT32 FileFlags;
UINT32 FileOS;
UINT32 FileType;
UINT32 FileSubtype;
UINT32 FileDateMS;
UINT32 FileDateLS;
} VS_FIXEDFILEINFO;
#define SHELL_OPTIONAL_DATA_SIZE 6
typedef enum {
NonRemovableHdd,
UsbHdd,
MaxMediaType
} BDS_MEDIA_TYPE;
#define ATTR_REMOVABLE_DEV BIT0
#define ATTR_UNREMOVABLE_DEV BIT1
#define ATTR_ALL ((UINT32) (-1))
typedef struct {
UINTN DevicePathType;
EFI_STRING_ID StringToken;
UINTN DeviceNum;
UINT32 Attribute;
} DEVICE_TYPE_INFORMATION;
typedef struct _BDS_USB_SHORT_FORM_INFO {
LIST_ENTRY Link;
EFI_DEVICE_PATH_PROTOCOL *FileSysDevPath;
UINTN UsbIoRemaindingDevPathOffset;
USB_WWID_DEVICE_PATH *UsbWwid;
} GENERIC_BDS_LIB_USB_SHORT_FORM_INFO;
typedef struct _GENERIC_BDS_LIB_GLOBAL_DATA {
BOOLEAN EnumBootDevice;
BOOLEAN EnableBootOrderHook;
BOOLEAN UefiFastBootEnabled;
BOOLEAN ResetReminderFeatureSwitch;
BOOLEAN ResetRequired;
UINTN PreviousHandlesNum;
EFI_HANDLE *PreviousHandles;
LIST_ENTRY UsbShortFormInfoList;
} GENERIC_BDS_LIB_GLOBAL_DATA;
/**
Allocates a block of memory and writes performance data of booting into it.
OS can processing these record.
**/
VOID
WriteBootToOsPerformanceData (
VOID
);
/**
Get the headers (dos, image, optional header) from an image
@param[in] Device SimpleFileSystem device handle
@param[in] FileName File name for the image
@param[out] DosHeader Pointer to dos header
@param[out] Hdr The buffer in which to return the PE32, PE32+, or TE header.
@retval EFI_SUCCESS Successfully get the machine type.
@retval EFI_NOT_FOUND The file is not found.
@retval EFI_LOAD_ERROR File is not a valid image file.
**/
EFI_STATUS
EFIAPI
BdsLibGetImageHeader (
IN EFI_HANDLE Device,
IN CHAR16 *FileName,
OUT EFI_IMAGE_DOS_HEADER *DosHeader,
OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
);
/**
This routine adjust the memory information for different memory type and
save them into the variables for next boot.
**/
VOID
EFIAPI
BdsSetMemoryTypeInformationVariable (
IN EFI_EVENT Event,
IN VOID *Context
);
/**
Validate the EFI Boot#### or Driver#### variable (VendorGuid/Name)
@param[in] Variable Boot#### variable data.
@param[in] VariableSize Returns the size of the EFI variable that was read
@retval TRUE The variable data is correct.
@retval FALSE The variable data is corrupted.
**/
BOOLEAN
ValidateOption (
IN UINT8 *Variable,
IN UINTN VariableSize
);
EFI_STATUS
BdsLibOpenFileFromDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINT64 OpenMode,
IN UINT64 Attributes,
OUT EFI_FILE_HANDLE *NewHandle
);
EFI_STATUS
VgaHandleSelect (
IN EFI_DEVICE_PATH_PROTOCOL *VgaDevicePath,
OUT EFI_HANDLE **SelectedHandle
);
VOID
UpdateBvdtToHii (
IN EFI_HII_HANDLE HiiHandle
);
EFI_STATUS
SetBbsPriority (
IN EFI_LEGACY_BIOS_PROTOCOL *LegacyBios,
IN BDS_COMMON_OPTION *Option
);
EFI_STATUS
BdsLibUpdateOptionVar (
IN CHAR16 *OptionName,
IN UINT32 Attribute,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN CHAR16 *Description,
IN UINT8 *OptionalData, OPTIONAL
IN UINT32 OptionalDataSize
);
EFI_STATUS
GetUnnecessaryEfiBootOption (
IN UINT16 *BootOrder,
IN UINT16 BootOrderCount,
IN UINTN BootOrderIndex,
IN OUT UINTN *EfiOsCreatedIndex,
IN OUT UINTN *BiosCreatedIndex
);
BOOLEAN
IsOnBoardPciDevice (
IN UINT32 Bus,
IN UINT32 Device,
IN UINT32 Function
);
/**
Set target HDD in boot list as connected.
**/
VOID
SetTargetHddConnected (
VOID
);
/**
Set all boot options in boot list as connected.
**/
VOID
SetAllBootOptionsConnected (
VOID
);
BOOLEAN
IsEfiDevice (
IN UINT16 BootOptionNum
);
EFI_STATUS
AdjustBootOrder (
IN BOOLEAN EfiDeviceFirst,
IN UINTN DeviceCount,
IN OUT UINT16 *BootOrder
);
BOOLEAN
IsOptionNumInOrderArray (
IN UINT16 *OrderArray,
IN UINTN OrderCount,
IN UINT16 OptionNum
);
EFI_STATUS
GetIndexInOrderArray (
IN UINT16 *OrderArray,
IN UINTN OrderCount,
IN UINT16 OptionNum,
OUT UINTN *OrderIndex
);
EFI_STATUS
BdsLibDeleteOptionFromHandle (
IN EFI_HANDLE Handle
);
BOOLEAN
IsOpromStorageDev (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN OPROM_STORAGE_DEVICE_INFO *OpromStorageDev,
IN UINTN OpromStorageDevCount
);
EFI_STATUS
TriggerCpBootDeviceEnumCheckBootOption (
IN CHAR16 *VariableName,
IN EFI_GUID *VariableGuid,
IN OUT BOOLEAN *Invalid
);
UINTN
GetDevicePathSizeEx (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINTN MaxSize
);
extern H2O_BDS_SERVICES_PROTOCOL *gBdsServices;
extern GENERIC_BDS_LIB_GLOBAL_DATA *mGenericBdsLibGlobalData;
#endif // _BDS_LIB_H_