2011-06-11 13:58:23 +02:00
|
|
|
/** @file
|
|
|
|
*
|
2013-03-12 01:42:59 +01:00
|
|
|
* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
|
2011-06-11 13:58:23 +02:00
|
|
|
*
|
|
|
|
* 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 _BDSINTERNAL_H_
|
|
|
|
#define _BDSINTERNAL_H_
|
|
|
|
|
|
|
|
#include <PiDxe.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/BdsLib.h>
|
|
|
|
#include <Library/BdsUnixLib.h>
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/DevicePathLib.h>
|
|
|
|
#include <Library/UefiLib.h>
|
|
|
|
#include <Library/PrintLib.h>
|
|
|
|
#include <Library/PcdLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
|
|
|
|
|
|
|
#include <Protocol/DevicePathFromText.h>
|
|
|
|
#include <Protocol/DevicePathToText.h>
|
|
|
|
|
|
|
|
#include <Guid/GlobalVariable.h>
|
|
|
|
|
|
|
|
#define BOOT_DEVICE_DESCRIPTION_MAX 100
|
|
|
|
#define BOOT_DEVICE_FILEPATH_MAX 100
|
2011-08-18 15:21:14 +02:00
|
|
|
#define BOOT_DEVICE_OPTION_MAX 300
|
2012-02-28 18:31:17 +01:00
|
|
|
#define BOOT_DEVICE_ADDRESS_MAX (sizeof(L"0x0000000000000000"))
|
2011-06-11 13:58:23 +02:00
|
|
|
|
2011-09-09 12:51:13 +02:00
|
|
|
#define ARM_BDS_OPTIONAL_DATA_SIGNATURE SIGNATURE_32('a', 'b', 'o', 'd')
|
|
|
|
|
|
|
|
#define IS_ARM_BDS_BOOTENTRY(ptr) (ReadUnaligned32 ((CONST UINT32*)&((ARM_BDS_LOADER_OPTIONAL_DATA*)((ptr)->OptionalData))->Header.Signature) == ARM_BDS_OPTIONAL_DATA_SIGNATURE)
|
|
|
|
|
2011-09-23 00:53:54 +02:00
|
|
|
#define UPDATE_BOOT_ENTRY L"Update entry: "
|
|
|
|
#define DELETE_BOOT_ENTRY L"Delete entry: "
|
|
|
|
|
2011-06-11 13:58:23 +02:00
|
|
|
typedef enum {
|
|
|
|
BDS_LOADER_EFI_APPLICATION = 0,
|
|
|
|
BDS_LOADER_KERNEL_LINUX_ATAG,
|
|
|
|
BDS_LOADER_KERNEL_LINUX_FDT,
|
2011-09-09 12:51:13 +02:00
|
|
|
} ARM_BDS_LOADER_TYPE;
|
2011-06-11 13:58:23 +02:00
|
|
|
|
2011-09-09 12:51:13 +02:00
|
|
|
typedef struct {
|
|
|
|
UINT16 CmdLineSize;
|
|
|
|
UINT16 InitrdSize;
|
2013-03-12 01:42:59 +01:00
|
|
|
|
2011-09-09 12:51:13 +02:00
|
|
|
// These following fields have variable length and are packed:
|
|
|
|
//CHAR8 *CmdLine;
|
|
|
|
//EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;
|
|
|
|
} ARM_BDS_LINUX_ARGUMENTS;
|
2011-08-18 15:21:14 +02:00
|
|
|
|
|
|
|
typedef union {
|
2011-09-09 12:51:13 +02:00
|
|
|
ARM_BDS_LINUX_ARGUMENTS LinuxArguments;
|
|
|
|
} ARM_BDS_LOADER_ARGUMENTS;
|
2011-08-18 15:21:14 +02:00
|
|
|
|
2011-06-11 13:58:23 +02:00
|
|
|
typedef struct {
|
2011-09-09 12:51:13 +02:00
|
|
|
UINT32 Signature;
|
|
|
|
ARM_BDS_LOADER_TYPE LoaderType;
|
|
|
|
} ARM_BDS_LOADER_OPTIONAL_DATA_HEADER;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ARM_BDS_LOADER_OPTIONAL_DATA_HEADER Header;
|
|
|
|
ARM_BDS_LOADER_ARGUMENTS Arguments;
|
|
|
|
} ARM_BDS_LOADER_OPTIONAL_DATA;
|
2011-06-11 13:58:23 +02:00
|
|
|
|
2011-09-09 12:52:31 +02:00
|
|
|
typedef struct {
|
|
|
|
LIST_ENTRY Link;
|
|
|
|
BDS_LOAD_OPTION* BdsLoadOption;
|
|
|
|
} BDS_LOAD_OPTION_ENTRY;
|
|
|
|
|
2011-06-11 13:58:23 +02:00
|
|
|
typedef enum {
|
|
|
|
BDS_DEVICE_FILESYSTEM = 0,
|
|
|
|
BDS_DEVICE_MEMMAP,
|
|
|
|
BDS_DEVICE_PXE,
|
|
|
|
BDS_DEVICE_TFTP,
|
|
|
|
BDS_DEVICE_MAX
|
|
|
|
} BDS_SUPPORTED_DEVICE_TYPE;
|
|
|
|
|
|
|
|
typedef struct {
|
2011-11-02 00:31:02 +01:00
|
|
|
LIST_ENTRY Link;
|
|
|
|
CHAR16 Description[BOOT_DEVICE_DESCRIPTION_MAX];
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL* DevicePathProtocol;
|
2011-06-11 13:58:23 +02:00
|
|
|
struct _BDS_LOAD_OPTION_SUPPORT* Support;
|
|
|
|
} BDS_SUPPORTED_DEVICE;
|
|
|
|
|
|
|
|
#define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)
|
|
|
|
|
|
|
|
typedef struct _BDS_LOAD_OPTION_SUPPORT {
|
|
|
|
BDS_SUPPORTED_DEVICE_TYPE Type;
|
|
|
|
EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);
|
2011-11-02 00:43:37 +01:00
|
|
|
BOOLEAN (*IsSupported)(IN EFI_DEVICE_PATH *DevicePath);
|
2013-03-12 02:03:23 +01:00
|
|
|
EFI_STATUS (*CreateDevicePathNode)(IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);
|
2011-11-02 00:43:37 +01:00
|
|
|
EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);
|
2011-06-11 13:58:23 +02:00
|
|
|
} BDS_LOAD_OPTION_SUPPORT;
|
|
|
|
|
2011-09-09 12:52:31 +02:00
|
|
|
#define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
|
|
|
|
#define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption
|
2011-06-11 13:58:23 +02:00
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BootDeviceListSupportedInit (
|
|
|
|
IN OUT LIST_ENTRY *SupportedDeviceList
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BootDeviceListSupportedFree (
|
2011-08-18 15:21:14 +02:00
|
|
|
IN LIST_ENTRY *SupportedDeviceList,
|
|
|
|
IN BDS_SUPPORTED_DEVICE *Except
|
2011-06-11 13:58:23 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BootDeviceGetDeviceSupport (
|
2011-11-02 00:43:37 +01:00
|
|
|
IN EFI_DEVICE_PATH *DevicePath,
|
|
|
|
OUT BDS_LOAD_OPTION_SUPPORT **DeviceSupport
|
2011-06-11 13:58:23 +02:00
|
|
|
);
|
|
|
|
|
2011-09-09 12:49:54 +02:00
|
|
|
EFI_STATUS
|
|
|
|
GetHIInputStr (
|
|
|
|
IN OUT CHAR16 *CmdLine,
|
|
|
|
IN UINTN MaxCmdLine
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EditHIInputStr (
|
|
|
|
IN OUT CHAR16 *CmdLine,
|
|
|
|
IN UINTN MaxCmdLine
|
|
|
|
);
|
|
|
|
|
2011-06-11 13:58:23 +02:00
|
|
|
EFI_STATUS
|
|
|
|
GetHIInputAscii (
|
|
|
|
IN OUT CHAR8 *CmdLine,
|
|
|
|
IN UINTN MaxCmdLine
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EditHIInputAscii (
|
|
|
|
IN OUT CHAR8 *CmdLine,
|
|
|
|
IN UINTN MaxCmdLine
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
GetHIInputInteger (
|
|
|
|
IN OUT UINTN *Integer
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
GetHIInputIP (
|
|
|
|
OUT EFI_IP_ADDRESS *Ip
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
GetHIInputBoolean (
|
|
|
|
OUT BOOLEAN *Value
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
HasFilePathEfiExtension (
|
|
|
|
IN CHAR16* FilePath
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_DEVICE_PATH*
|
|
|
|
GetLastDevicePathNode (
|
|
|
|
IN EFI_DEVICE_PATH* DevicePath
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BdsStartBootOption (
|
|
|
|
IN CHAR16* BootOption
|
|
|
|
);
|
|
|
|
|
2011-09-09 12:51:13 +02:00
|
|
|
UINTN
|
|
|
|
GetUnalignedDevicePathSize (
|
|
|
|
IN EFI_DEVICE_PATH* DevicePath
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_DEVICE_PATH*
|
|
|
|
GetAlignedDevicePath (
|
|
|
|
IN EFI_DEVICE_PATH* DevicePath
|
|
|
|
);
|
|
|
|
|
2011-06-11 13:58:23 +02:00
|
|
|
EFI_STATUS
|
|
|
|
GenerateDeviceDescriptionName (
|
|
|
|
IN EFI_HANDLE Handle,
|
|
|
|
IN OUT CHAR16* Description
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BootOptionList (
|
|
|
|
IN OUT LIST_ENTRY *BootOptionList
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BootOptionParseLoadOption (
|
|
|
|
IN EFI_LOAD_OPTION EfiLoadOption,
|
|
|
|
IN UINTN EfiLoadOptionSize,
|
|
|
|
OUT BDS_LOAD_OPTION **BdsLoadOption
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BootOptionStart (
|
|
|
|
IN BDS_LOAD_OPTION *BootOption
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BootOptionCreate (
|
2011-09-09 12:51:13 +02:00
|
|
|
IN UINT32 Attributes,
|
|
|
|
IN CHAR16* BootDescription,
|
2011-06-11 13:58:23 +02:00
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
|
2011-09-09 12:51:13 +02:00
|
|
|
IN ARM_BDS_LOADER_TYPE BootType,
|
|
|
|
IN ARM_BDS_LOADER_ARGUMENTS* BootArguments,
|
|
|
|
OUT BDS_LOAD_OPTION** BdsLoadOption
|
2011-06-11 13:58:23 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BootOptionUpdate (
|
2011-09-09 12:51:13 +02:00
|
|
|
IN BDS_LOAD_OPTION* BdsLoadOption,
|
|
|
|
IN UINT32 Attributes,
|
|
|
|
IN CHAR16* BootDescription,
|
2011-06-11 13:58:23 +02:00
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
|
2011-09-09 12:51:13 +02:00
|
|
|
IN ARM_BDS_LOADER_TYPE BootType,
|
|
|
|
IN ARM_BDS_LOADER_ARGUMENTS* BootArguments
|
2011-06-11 13:58:23 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BootOptionDelete (
|
|
|
|
IN BDS_LOAD_OPTION *BootOption
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
BootMenuMain (
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif /* _BDSINTERNAL_H_ */
|