[BOOTMGFW]

Nothing to see here. I hope this doesn't break the build.

svn path=/trunk/; revision=68992
This commit is contained in:
Alex Ionescu 2015-09-04 14:16:56 +00:00
parent cf68c63f61
commit 286f63072a
30 changed files with 6725 additions and 1 deletions

View file

@ -46,3 +46,5 @@ add_custom_target(hybridcd
add_subdirectory(freeldr)
add_subdirectory(bootdata)
add_subdirectory(environ)

0
reactos/boot/bcd/.gitignore vendored Normal file
View file

0
reactos/boot/bgfx/.gitignore vendored Normal file
View file

View file

@ -130,7 +130,7 @@ Cabinet=reactos.cab
[SetupData]
DefaultPath = \ReactOS
OsLoadOptions = "/NOGUIBOOT /NODEBUG"
DbgOsLoadOptions = "/NOGUIBOOT /KDSERIAL /DEBUGPORT=COM1 /FIRSTCHANCE"
DbgOsLoadOptions = "/NOGUIBOOT /KDSERIAL /DEBUGPORT=COM1 /FIRSTCHANCE /redirect=com2 /redirectbaudrate=115200"
;DbgOsLoadOptions = "/SOS /DEBUGPORT=SCREEN"
;DbgOsLoadOptions = "/NOGUIBOOT /DEBUGPORT=BOCHS"

View file

@ -0,0 +1,61 @@
include_directories(BEFORE include)
include_directories(BEFORE include/efi)
include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
include_directories(${REACTOS_SOURCE_DIR}/lib/cmlib)
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/libs)
add_definitions(-D_NTHAL_ -D_BLDR_ -D_NTSYSTEM_)
list(APPEND BOOTMGR_COMMON_SOURCE
app/bootmgr/bootmgr.h
lib/bootlib.c
lib/misc/util.c)
if(ARCH STREQUAL "i386")
list(APPEND BOOTMGR_COMMON_ASM_SOURCE
#lib/arch/i386/foo.asm
)
list(APPEND BOOTMGR_COMMON_SOURCE
#lib/arch/i386/foo.c
)
elseif(ARCH STREQUAL "amd64")
list(APPEND BOOTMGR_COMMON_ASM_SOURCE
#lib/arch/amd64/foo.asm
)
list(APPEND BOOTMGR_COMMON_SOURCE
#lib/arch/amd64/foo.c
)
else()
#TBD
endif()
add_asm_files(bootmgr_common_asm ${BOOTMGR_COMMON_ASM_SOURCE})
add_library(bootmgr_common ${BOOTMGR_COMMON_SOURCE} ${bootmgr_common_asm})
add_pch(bootmgr_common app/bootmgr/bootmgr.h BOOTMGR_COMMON_SOURCE)
#add_dependencies(bootmgr_common bugcodes)
list(APPEND BOOTMGR_BASE_SOURCE
app/bootmgr/efiemu.c
app/bootmgr/bootmgr.c
)
add_executable(bootmgfw ${BOOTMGR_BASE_SOURCE})
set_target_properties(bootmgfw PROPERTIES SUFFIX ".efi")
if(MSVC)
add_target_link_flags(bootmgfw "/ignore:4078 /ignore:4254 /DRIVER /FIXED")
else()
add_target_link_flags(bootmgfw "-Wl,--strip-all,--exclude-all-symbols")
endif()
set_image_base(bootmgfw 0x10000)
set_subsystem(bootmgfw 10)
set_entrypoint(bootmgfw EfiEntry)
target_link_libraries(bootmgfw bootmgr_common cportlib cmlib rtl libcntpr)
add_dependencies(bootmgfw asm)
add_cd_file(TARGET bootmgfw FILE ${_bootmgfw_output_file} DESTINATION loader NO_CAB FOR bootcd regtest)

View file

@ -0,0 +1,40 @@
/*
* COPYRIGHT: See COPYING.ARM in the top level directory
* PROJECT: ReactOS UEFI Boot Manager
* FILE: boot/environ/app/bootmgr.c
* PURPOSE: Boot Manager Entrypoint
* PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "bootmgr.h"
/* FUNCTIONS *****************************************************************/
/*++
* @name BmMain
*
* The BmMain function implements the Windows Boot Application entrypoint for
* the Boot Manager.
*
* @param BootParameters
* Pointer to the Boot Application Parameter Block.
*
* @return NT_SUCCESS if the image was loaded correctly, relevant error code
* otherwise.
*
*--*/
NTSTATUS
BmMain (
_In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters
)
{
NTSTATUS Status;
BL_LIBRARY_PARAMETERS LibraryParameters;
Status = BlInitializeLibrary(BootParameters, &LibraryParameters);
return Status;
}

View file

@ -0,0 +1,35 @@
/*
* COPYRIGHT: See COPYING.ARM in the top level directory
* PROJECT: ReactOS UEFI Boot Manager
* FILE: boot/environ/app/bootmgr.h
* PURPOSE: Main Boot Manager Header
* PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
*/
#ifndef _BOOTMGR_H
#define _BOOTMGR_H
/* INCLUDES ******************************************************************/
/* C Headers */
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
/* NT Base Headers */
#include <ntifs.h>
/* UEFI Headers */
#include <Uefi.h>
/* Boot Library Headers */
#include <bl.h>
/* FUNCTIONS *****************************************************************/
NTSTATUS
BmMain (
_In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters
);
#endif

View file

@ -0,0 +1,89 @@
/*
* COPYRIGHT: See COPYING.ARM in the top level directory
* PROJECT: ReactOS UEFI Boot Manager
* FILE: boot/environ/app/efiemu.c
* PURPOSE: UEFI Entrypoint for Boot Manager
* PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "bootmgr.h"
/* FUNCTIONS *****************************************************************/
/*++
* @name EfiInitCreateInputParametersEx
*
* The EfiInitCreateInputParametersEx routine converts UEFI entrypoint
* parameters to the ones expected by Windows Boot Applications
*
* @param ImageHandle
* UEFI Image Handle for the current loaded application.
*
* @param SystemTable
* Pointer to the UEFI System Table.
*
* @return A PBOOT_APPLICATION_PARAMETER_BLOCK structure containing the data
* from UEFI, translated to the Boot Library-compatible format.
*
*--*/
PBOOT_APPLICATION_PARAMETER_BLOCK
EfiInitCreateInputParametersEx (
_In_ EFI_HANDLE ImageHandle,
_In_ EFI_SYSTEM_TABLE *SystemTable
)
{
DBG_UNREFERENCED_PARAMETER(ImageHandle);
DBG_UNREFERENCED_PARAMETER(SystemTable);
/* Not yet implemented */
return NULL;
}
/*++
* @name EfiEntry
*
* The EfiEntry routine implements the UEFI entrypoint for the application.
*
* @param ImageHandle
* UEFI Image Handle for the current loaded application.
*
* @param SystemTable
* Pointer to the UEFI System Table.
*
* @return EFI_SUCCESS if the image was loaded correctly, relevant error code
* otherwise.
*
*--*/
EFI_STATUS
EfiEntry (
_In_ EFI_HANDLE ImageHandle,
_In_ EFI_SYSTEM_TABLE *SystemTable
)
{
NTSTATUS Status;
PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters;
/* Temporary debugging string */
SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, L"Hello from EFI\n");
/* Convert EFI parameters to Windows Boot Application parameters */
BootParameters = EfiInitCreateInputParametersEx(ImageHandle, SystemTable);
if (BootParameters != NULL)
{
/* Conversion was good -- call the Boot Manager Entrypoint */
SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, L"EFI input OK!\n");
Status = BmMain(BootParameters);
}
else
{
/* Conversion failed, bail out */
SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, L"EFI input failed\n");
Status = STATUS_INVALID_PARAMETER;
}
/* Convert the NT status code to an EFI code */
return EfiGetEfiStatusCode(Status);
}

View file

@ -0,0 +1,57 @@
/*
* COPYRIGHT: See COPYING.ARM in the top level directory
* PROJECT: ReactOS UEFI Boot Library
* FILE: boot/environ/include/bl.h
* PURPOSE: Main Boot Library Header
* PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
*/
#ifndef _BL_H
#define _BL_H
/* DATA STRUCTURES ***********************************************************/
typedef struct _BL_LIBRARY_PARAMETERS
{
ULONG LibraryFlags;
ULONG TranslationType;
ULONG MinimumAllocationCount;
ULONG MinimumHeapSize;
ULONG HeapAllocationAttributes;
PWCHAR ApplicationBaseDirectory;
ULONG DescriptorCount;
} BL_LIBRARY_PARAMETERS, *PBL_LIBRARY_PARAMETERS;
/* This should eventually go into a more public header */
typedef struct _BOOT_APPLICATION_PARAMETER_BLOCK
{
ULONG Signature[2];
ULONG Version;
ULONG Size;
ULONG ImageType;
ULONG MemoryTranslationType;
ULONGLONG ImageBase;
ULONG ImageSize;
ULONG MemorySettingsOffset;
ULONG AppEntryOffset;
ULONG BootDeviceOffset;
ULONG FirmwareParametersOffset;
ULONG FlagOffset;
} BOOT_APPLICATION_PARAMETER_BLOCK, *PBOOT_APPLICATION_PARAMETER_BLOCK;
/* INITIALIZATION ROUTINES ***************************************************/
NTSTATUS
BlInitializeLibrary(
_In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootAppParameters,
_In_ PBL_LIBRARY_PARAMETERS LibraryParameters
);
/* UTILITY ROUTINES **********************************************************/
EFI_STATUS
EfiGetEfiStatusCode(
_In_ NTSTATUS Status
);
#endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,88 @@
/** @file
UEFI 2.0 Loaded image protocol definition.
Every EFI driver and application is passed an image handle when it is loaded.
This image handle will contain a Loaded Image Protocol.
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
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 __LOADED_IMAGE_PROTOCOL_H__
#define __LOADED_IMAGE_PROTOCOL_H__
#define EFI_LOADED_IMAGE_PROTOCOL_GUID \
{ \
0x5B1B31A1, 0x9562, 0x11d2, { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \
}
#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \
{ \
0xbc62157e, 0x3e33, 0x4fec, { 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf } \
}
///
/// Protocol GUID defined in EFI1.1.
///
#define LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE_PROTOCOL_GUID
///
/// EFI_SYSTEM_TABLE & EFI_IMAGE_UNLOAD are defined in EfiApi.h
///
#define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000
///
/// Revision defined in EFI1.1.
///
#define EFI_LOADED_IMAGE_INFORMATION_REVISION EFI_LOADED_IMAGE_PROTOCOL_REVISION
///
/// Can be used on any image handle to obtain information about the loaded image.
///
typedef struct {
UINT32 Revision; ///< Defines the revision of the EFI_LOADED_IMAGE_PROTOCOL structure.
///< All future revisions will be backward compatible to the current revision.
EFI_HANDLE ParentHandle; ///< Parent image's image handle. NULL if the image is loaded directly from
///< the firmware's boot manager.
EFI_SYSTEM_TABLE *SystemTable; ///< the image's EFI system table pointer.
//
// Source location of image
//
EFI_HANDLE DeviceHandle; ///< The device handle that the EFI Image was loaded from.
EFI_DEVICE_PATH_PROTOCOL *FilePath; ///< A pointer to the file path portion specific to DeviceHandle
///< that the EFI Image was loaded from.
VOID *Reserved; ///< Reserved. DO NOT USE.
//
// Images load options
//
UINT32 LoadOptionsSize;///< The size in bytes of LoadOptions.
VOID *LoadOptions; ///< A pointer to the image's binary load options.
//
// Location of where image was loaded
//
VOID *ImageBase; ///< The base address at which the image was loaded.
UINT64 ImageSize; ///< The size in bytes of the loaded image.
EFI_MEMORY_TYPE ImageCodeType; ///< The memory type that the code sections were loaded as.
EFI_MEMORY_TYPE ImageDataType; ///< The memory type that the data sections were loaded as.
EFI_IMAGE_UNLOAD Unload;
} EFI_LOADED_IMAGE_PROTOCOL;
//
// For backward-compatible with EFI1.1.
//
typedef EFI_LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE;
extern EFI_GUID gEfiLoadedImageProtocolGuid;
extern EFI_GUID gEfiLoadedImageDevicePathProtocolGuid;
#endif

View file

@ -0,0 +1,282 @@
/** @file
Processor or Compiler specific defines and types for IA-32 architecture.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that 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 __PROCESSOR_BIND_H__
#define __PROCESSOR_BIND_H__
///
/// Define the processor type so other code can make processor based choices.
///
#define MDE_CPU_IA32
//
// Make sure we are using the correct packing rules per EFI specification
//
#if !defined(__GNUC__)
#pragma pack()
#endif
#if defined(__INTEL_COMPILER)
//
// Disable ICC's remark #869: "Parameter" was never referenced warning.
// This is legal ANSI C code so we disable the remark that is turned on with -Wall
//
#pragma warning ( disable : 869 )
//
// Disable ICC's remark #1418: external function definition with no prior declaration.
// This is legal ANSI C code so we disable the remark that is turned on with /W4
//
#pragma warning ( disable : 1418 )
//
// Disable ICC's remark #1419: external declaration in primary source file
// This is legal ANSI C code so we disable the remark that is turned on with /W4
//
#pragma warning ( disable : 1419 )
//
// Disable ICC's remark #593: "Variable" was set but never used.
// This is legal ANSI C code so we disable the remark that is turned on with /W4
//
#pragma warning ( disable : 593 )
#endif
#if defined(_MSC_EXTENSIONS)
//
// Disable warning that make it impossible to compile at /W4
// This only works for Microsoft* tools
//
//
// Disabling bitfield type checking warnings.
//
#pragma warning ( disable : 4214 )
//
// Disabling the unreferenced formal parameter warnings.
//
#pragma warning ( disable : 4100 )
//
// Disable slightly different base types warning as CHAR8 * can not be set
// to a constant string.
//
#pragma warning ( disable : 4057 )
//
// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
//
#pragma warning ( disable : 4127 )
//
// This warning is caused by functions defined but not used. For precompiled header only.
//
#pragma warning ( disable : 4505 )
//
// This warning is caused by empty (after preprocessing) source file. For precompiled header only.
//
#pragma warning ( disable : 4206 )
#endif
#if defined(_MSC_EXTENSIONS)
//
// use Microsoft C complier dependent integer width types
//
///
/// 8-byte unsigned value.
///
typedef unsigned __int64 UINT64;
///
/// 8-byte signed value.
///
typedef __int64 INT64;
///
/// 4-byte unsigned value.
///
typedef unsigned __int32 UINT32;
///
/// 4-byte signed value.
///
typedef __int32 INT32;
///
/// 2-byte unsigned value.
///
typedef unsigned short UINT16;
///
/// 2-byte Character. Unless otherwise specified all strings are stored in the
/// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
///
typedef unsigned short CHAR16;
///
/// 2-byte signed value.
///
typedef short INT16;
///
/// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
/// values are undefined.
///
typedef unsigned char BOOLEAN;
///
/// 1-byte unsigned value.
///
typedef unsigned char UINT8;
///
/// 1-byte Character.
///
typedef char CHAR8;
///
/// 1-byte signed value.
///
typedef char INT8;
#else
///
/// 8-byte unsigned value.
///
typedef unsigned long long UINT64;
///
/// 8-byte signed value.
///
typedef signed long long INT64;
///
/// 4-byte unsigned value.
///
typedef unsigned int UINT32;
///
/// 4-byte signed value.
///
typedef signed int INT32;
///
/// 2-byte unsigned value.
///
typedef unsigned short UINT16;
///
/// 2-byte Character. Unless otherwise specified all strings are stored in the
/// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
///
typedef unsigned short CHAR16;
///
/// 2-byte signed value.
///
typedef signed short INT16;
///
/// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
/// values are undefined.
///
typedef unsigned char BOOLEAN;
///
/// 1-byte unsigned value.
///
typedef unsigned char UINT8;
///
/// 1-byte Character
///
typedef signed char CHAR8;
///
/// 1-byte signed value
///
typedef signed char INT8;
#endif
///
/// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions;
/// 8 bytes on supported 64-bit processor instructions.)
///
typedef UINT32 UINTN;
///
/// Signed value of native width. (4 bytes on supported 32-bit processor instructions;
/// 8 bytes on supported 64-bit processor instructions.)
///
typedef INT32 INTN;
//
// Processor specific defines
//
///
/// A value of native width with the highest bit set.
///
#define MAX_BIT 0x80000000
///
/// A value of native width with the two highest bits set.
///
#define MAX_2_BITS 0xC0000000
///
/// Maximum legal IA-32 address.
///
#define MAX_ADDRESS 0xFFFFFFFF
///
/// The stack alignment required for IA-32.
///
#define CPU_STACK_ALIGNMENT sizeof(UINTN)
//
// Modifier to ensure that all protocol member functions and EFI intrinsics
// use the correct C calling convention. All protocol member functions and
// EFI intrinsics are required to modify their member functions with EFIAPI.
//
#ifdef EFIAPI
///
/// If EFIAPI is already defined, then we use that definition.
///
#elif defined(_MSC_EXTENSIONS)
///
/// Microsoft* compiler specific method for EFIAPI calling convention.
///
#define EFIAPI __cdecl
#elif defined(__GNUC__)
///
/// GCC specific method for EFIAPI calling convention.
///
#define EFIAPI __attribute__((cdecl))
#else
///
/// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
/// is the standard.
///
#define EFIAPI
#endif
#if defined(__GNUC__)
///
/// For GNU assembly code, .global or .globl can declare global symbols.
/// Define this macro to unify the usage.
///
#define ASM_GLOBAL .globl
#endif
/**
Return the pointer to the first instruction of a function given a function pointer.
On IA-32 CPU architectures, these two pointer values are the same,
so the implementation of this macro is very simple.
@param FunctionPointer A pointer to a function.
@return The pointer to the first instruction of a function given a function pointer.
**/
#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
#endif

View file

@ -0,0 +1,134 @@
/** @file
Simple Text Input protocol from the UEFI 2.0 specification.
Abstraction of a very simple input device like a keyboard or serial
terminal.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
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 __SIMPLE_TEXT_IN_PROTOCOL_H__
#define __SIMPLE_TEXT_IN_PROTOCOL_H__
#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
{ \
0x387477c1, 0x69c7, 0x11d2, { 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
}
typedef struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
///
/// Protocol GUID name defined in EFI1.1.
///
#define SIMPLE_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID
///
/// Protocol name in EFI1.1 for backward-compatible.
///
typedef struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL SIMPLE_INPUT_INTERFACE;
///
/// The keystroke information for the key that was pressed.
///
typedef struct {
UINT16 ScanCode;
CHAR16 UnicodeChar;
} EFI_INPUT_KEY;
//
// Required unicode control chars
//
#define CHAR_NULL 0x0000
#define CHAR_BACKSPACE 0x0008
#define CHAR_TAB 0x0009
#define CHAR_LINEFEED 0x000A
#define CHAR_CARRIAGE_RETURN 0x000D
//
// EFI Scan codes
//
#define SCAN_NULL 0x0000
#define SCAN_UP 0x0001
#define SCAN_DOWN 0x0002
#define SCAN_RIGHT 0x0003
#define SCAN_LEFT 0x0004
#define SCAN_HOME 0x0005
#define SCAN_END 0x0006
#define SCAN_INSERT 0x0007
#define SCAN_DELETE 0x0008
#define SCAN_PAGE_UP 0x0009
#define SCAN_PAGE_DOWN 0x000A
#define SCAN_F1 0x000B
#define SCAN_F2 0x000C
#define SCAN_F3 0x000D
#define SCAN_F4 0x000E
#define SCAN_F5 0x000F
#define SCAN_F6 0x0010
#define SCAN_F7 0x0011
#define SCAN_F8 0x0012
#define SCAN_F9 0x0013
#define SCAN_F10 0x0014
#define SCAN_ESC 0x0017
/**
Reset the input device and optionally run diagnostics
@param This Protocol instance pointer.
@param ExtendedVerification Driver may perform diagnostics on reset.
@retval EFI_SUCCESS The device was reset.
@retval EFI_DEVICE_ERROR The device is not functioning properly and could not be reset.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_INPUT_RESET)(
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
);
/**
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existence of a keystroke via WaitForEvent () call.
@param This Protocol instance pointer.
@param Key A pointer to a buffer that is filled in with the keystroke
information for the key that was pressed.
@retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data available.
@retval EFI_DEVICE_ERROR The keystroke information was not returned due to
hardware errors.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_INPUT_READ_KEY)(
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
OUT EFI_INPUT_KEY *Key
);
///
/// The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device.
/// It is the minimum required protocol for ConsoleIn.
///
struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL {
EFI_INPUT_RESET Reset;
EFI_INPUT_READ_KEY ReadKeyStroke;
///
/// Event to use with WaitForEvent() to wait for a key to be available
///
EFI_EVENT WaitForKey;
};
extern EFI_GUID gEfiSimpleTextInProtocolGuid;
#endif

View file

@ -0,0 +1,325 @@
/** @file
Simple Text Input Ex protocol from the UEFI 2.0 specification.
This protocol defines an extension to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
which exposes much more state and modifier information from the input device,
also allows one to register a notification for a particular keystroke.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
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 __SIMPLE_TEXT_IN_EX_H__
#define __SIMPLE_TEXT_IN_EX_H__
#include <SimpleTextIn.h>
#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
{0xdd9e7534, 0x7762, 0x4698, { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } }
typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;
/**
The Reset() function resets the input device hardware. As part
of initialization process, the firmware/device will make a quick
but reasonable attempt to verify that the device is functioning.
If the ExtendedVerification flag is TRUE the firmware may take
an extended amount of time to verify the device is operating on
reset. Otherwise the reset operation is to occur as quickly as
possible. The hardware verification process is not defined by
this specification and is left up to the platform firmware or
driver to implement.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param ExtendedVerification Indicates that the driver may
perform a more exhaustive
verification operation of the
device during reset.
@retval EFI_SUCCESS The device was reset.
@retval EFI_DEVICE_ERROR The device is not functioning
correctly and could not be reset.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_INPUT_RESET_EX)(
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
);
///
/// EFI_KEY_TOGGLE_STATE. The toggle states are defined.
/// They are: EFI_TOGGLE_STATE_VALID, EFI_SCROLL_LOCK_ACTIVE
/// EFI_NUM_LOCK_ACTIVE, EFI_CAPS_LOCK_ACTIVE
///
typedef UINT8 EFI_KEY_TOGGLE_STATE;
typedef struct _EFI_KEY_STATE {
///
/// Reflects the currently pressed shift
/// modifiers for the input device. The
/// returned value is valid only if the high
/// order bit has been set.
///
UINT32 KeyShiftState;
///
/// Reflects the current internal state of
/// various toggled attributes. The returned
/// value is valid only if the high order
/// bit has been set.
///
EFI_KEY_TOGGLE_STATE KeyToggleState;
} EFI_KEY_STATE;
typedef struct {
///
/// The EFI scan code and Unicode value returned from the input device.
///
EFI_INPUT_KEY Key;
///
/// The current state of various toggled attributes as well as input modifier values.
///
EFI_KEY_STATE KeyState;
} EFI_KEY_DATA;
//
// Any Shift or Toggle State that is valid should have
// high order bit set.
//
// Shift state
//
#define EFI_SHIFT_STATE_VALID 0x80000000
#define EFI_RIGHT_SHIFT_PRESSED 0x00000001
#define EFI_LEFT_SHIFT_PRESSED 0x00000002
#define EFI_RIGHT_CONTROL_PRESSED 0x00000004
#define EFI_LEFT_CONTROL_PRESSED 0x00000008
#define EFI_RIGHT_ALT_PRESSED 0x00000010
#define EFI_LEFT_ALT_PRESSED 0x00000020
#define EFI_RIGHT_LOGO_PRESSED 0x00000040
#define EFI_LEFT_LOGO_PRESSED 0x00000080
#define EFI_MENU_KEY_PRESSED 0x00000100
#define EFI_SYS_REQ_PRESSED 0x00000200
//
// Toggle state
//
#define EFI_TOGGLE_STATE_VALID 0x80
#define EFI_KEY_STATE_EXPOSED 0x40
#define EFI_SCROLL_LOCK_ACTIVE 0x01
#define EFI_NUM_LOCK_ACTIVE 0x02
#define EFI_CAPS_LOCK_ACTIVE 0x04
//
// EFI Scan codes
//
#define SCAN_F11 0x0015
#define SCAN_F12 0x0016
#define SCAN_PAUSE 0x0048
#define SCAN_F13 0x0068
#define SCAN_F14 0x0069
#define SCAN_F15 0x006A
#define SCAN_F16 0x006B
#define SCAN_F17 0x006C
#define SCAN_F18 0x006D
#define SCAN_F19 0x006E
#define SCAN_F20 0x006F
#define SCAN_F21 0x0070
#define SCAN_F22 0x0071
#define SCAN_F23 0x0072
#define SCAN_F24 0x0073
#define SCAN_MUTE 0x007F
#define SCAN_VOLUME_UP 0x0080
#define SCAN_VOLUME_DOWN 0x0081
#define SCAN_BRIGHTNESS_UP 0x0100
#define SCAN_BRIGHTNESS_DOWN 0x0101
#define SCAN_SUSPEND 0x0102
#define SCAN_HIBERNATE 0x0103
#define SCAN_TOGGLE_DISPLAY 0x0104
#define SCAN_RECOVERY 0x0105
#define SCAN_EJECT 0x0106
/**
The function reads the next keystroke from the input device. If
there is no pending keystroke the function returns
EFI_NOT_READY. If there is a pending keystroke, then
KeyData.Key.ScanCode is the EFI scan code defined in Error!
Reference source not found. The KeyData.Key.UnicodeChar is the
actual printable character or is zero if the key does not
represent a printable character (control key, function key,
etc.). The KeyData.KeyState is shift state for the character
reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode .
When interpreting the data from this function, it should be
noted that if a class of printable characters that are
normally adjusted by shift modifiers (e.g. Shift Key + "f"
key) would be presented solely as a KeyData.Key.UnicodeChar
without the associated shift state. So in the previous example
of a Shift Key + "f" key being pressed, the only pertinent
data returned would be KeyData.Key.UnicodeChar with the value
of "F". This of course would not typically be the case for
non-printable characters such as the pressing of the Right
Shift Key + F10 key since the corresponding returned data
would be reflected both in the KeyData.KeyState.KeyShiftState
and KeyData.Key.ScanCode values. UEFI drivers which implement
the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return
KeyData.Key and KeyData.KeyState values. These drivers must
always return the most current state of
KeyData.KeyState.KeyShiftState and
KeyData.KeyState.KeyToggleState. It should also be noted that
certain input devices may not be able to produce shift or toggle
state information, and in those cases the high order bit in the
respective Toggle and Shift state fields should not be active.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param KeyData A pointer to a buffer that is filled in with
the keystroke state data for the key that was
pressed.
@retval EFI_SUCCESS The keystroke information was
returned.
@retval EFI_NOT_READY There was no keystroke data available.
EFI_DEVICE_ERROR The keystroke
information was not returned due to
hardware errors.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_INPUT_READ_KEY_EX)(
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
OUT EFI_KEY_DATA *KeyData
);
/**
The SetState() function allows the input device hardware to
have state settings adjusted.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to
set the state for the input device.
@retval EFI_SUCCESS The device state was set appropriately.
@retval EFI_DEVICE_ERROR The device is not functioning
correctly and could not have the
setting adjusted.
@retval EFI_UNSUPPORTED The device does not support the
ability to have its state set.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_SET_STATE)(
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
);
///
/// The function will be called when the key sequence is typed specified by KeyData.
///
typedef
EFI_STATUS
(EFIAPI *EFI_KEY_NOTIFY_FUNCTION)(
IN EFI_KEY_DATA *KeyData
);
/**
The RegisterKeystrokeNotify() function registers a function
which will be called when a specified keystroke will occur.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param KeyData A pointer to a buffer that is filled in with
the keystroke information for the key that was
pressed.
@param KeyNotificationFunction Points to the function to be
called when the key sequence
is typed specified by KeyData.
@param NotifyHandle Points to the unique handle assigned to
the registered notification.
@retval EFI_SUCCESS The device state was set
appropriately.
@retval EFI_OUT_OF_RESOURCES Unable to allocate necessary
data structures.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY)(
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN EFI_KEY_DATA *KeyData,
IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
OUT EFI_HANDLE *NotifyHandle
);
/**
The UnregisterKeystrokeNotify() function removes the
notification which was previously registered.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param NotificationHandle The handle of the notification
function being unregistered.
@retval EFI_SUCCESS The device state was set appropriately.
@retval EFI_INVALID_PARAMETER The NotificationHandle is
invalid.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY)(
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN EFI_HANDLE NotificationHandle
);
///
/// The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn
/// device. It is an extension to the Simple Text Input protocol
/// which allows a variety of extended shift state information to be
/// returned.
///
struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL{
EFI_INPUT_RESET_EX Reset;
EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx;
///
/// Event to use with WaitForEvent() to wait for a key to be available.
///
EFI_EVENT WaitForKeyEx;
EFI_SET_STATE SetState;
EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify;
EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify;
};
extern EFI_GUID gEfiSimpleTextInputExProtocolGuid;
#endif

View file

@ -0,0 +1,404 @@
/** @file
Simple Text Out protocol from the UEFI 2.0 specification.
Abstraction of a very simple text based output device like VGA text mode or
a serial terminal. The Simple Text Out protocol instance can represent
a single hardware device or a virtual device that is an aggregation
of multiple physical devices.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that 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 __SIMPLE_TEXT_OUT_H__
#define __SIMPLE_TEXT_OUT_H__
#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
{ \
0x387477c2, 0x69c7, 0x11d2, { 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
}
///
/// Protocol GUID defined in EFI1.1.
///
#define SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID
typedef struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
///
/// Backward-compatible with EFI1.1.
///
typedef EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SIMPLE_TEXT_OUTPUT_INTERFACE;
//
// Define's for required EFI Unicode Box Draw characters
//
#define BOXDRAW_HORIZONTAL 0x2500
#define BOXDRAW_VERTICAL 0x2502
#define BOXDRAW_DOWN_RIGHT 0x250c
#define BOXDRAW_DOWN_LEFT 0x2510
#define BOXDRAW_UP_RIGHT 0x2514
#define BOXDRAW_UP_LEFT 0x2518
#define BOXDRAW_VERTICAL_RIGHT 0x251c
#define BOXDRAW_VERTICAL_LEFT 0x2524
#define BOXDRAW_DOWN_HORIZONTAL 0x252c
#define BOXDRAW_UP_HORIZONTAL 0x2534
#define BOXDRAW_VERTICAL_HORIZONTAL 0x253c
#define BOXDRAW_DOUBLE_HORIZONTAL 0x2550
#define BOXDRAW_DOUBLE_VERTICAL 0x2551
#define BOXDRAW_DOWN_RIGHT_DOUBLE 0x2552
#define BOXDRAW_DOWN_DOUBLE_RIGHT 0x2553
#define BOXDRAW_DOUBLE_DOWN_RIGHT 0x2554
#define BOXDRAW_DOWN_LEFT_DOUBLE 0x2555
#define BOXDRAW_DOWN_DOUBLE_LEFT 0x2556
#define BOXDRAW_DOUBLE_DOWN_LEFT 0x2557
#define BOXDRAW_UP_RIGHT_DOUBLE 0x2558
#define BOXDRAW_UP_DOUBLE_RIGHT 0x2559
#define BOXDRAW_DOUBLE_UP_RIGHT 0x255a
#define BOXDRAW_UP_LEFT_DOUBLE 0x255b
#define BOXDRAW_UP_DOUBLE_LEFT 0x255c
#define BOXDRAW_DOUBLE_UP_LEFT 0x255d
#define BOXDRAW_VERTICAL_RIGHT_DOUBLE 0x255e
#define BOXDRAW_VERTICAL_DOUBLE_RIGHT 0x255f
#define BOXDRAW_DOUBLE_VERTICAL_RIGHT 0x2560
#define BOXDRAW_VERTICAL_LEFT_DOUBLE 0x2561
#define BOXDRAW_VERTICAL_DOUBLE_LEFT 0x2562
#define BOXDRAW_DOUBLE_VERTICAL_LEFT 0x2563
#define BOXDRAW_DOWN_HORIZONTAL_DOUBLE 0x2564
#define BOXDRAW_DOWN_DOUBLE_HORIZONTAL 0x2565
#define BOXDRAW_DOUBLE_DOWN_HORIZONTAL 0x2566
#define BOXDRAW_UP_HORIZONTAL_DOUBLE 0x2567
#define BOXDRAW_UP_DOUBLE_HORIZONTAL 0x2568
#define BOXDRAW_DOUBLE_UP_HORIZONTAL 0x2569
#define BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE 0x256a
#define BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL 0x256b
#define BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL 0x256c
//
// EFI Required Block Elements Code Chart
//
#define BLOCKELEMENT_FULL_BLOCK 0x2588
#define BLOCKELEMENT_LIGHT_SHADE 0x2591
//
// EFI Required Geometric Shapes Code Chart
//
#define GEOMETRICSHAPE_UP_TRIANGLE 0x25b2
#define GEOMETRICSHAPE_RIGHT_TRIANGLE 0x25ba
#define GEOMETRICSHAPE_DOWN_TRIANGLE 0x25bc
#define GEOMETRICSHAPE_LEFT_TRIANGLE 0x25c4
//
// EFI Required Arrow shapes
//
#define ARROW_LEFT 0x2190
#define ARROW_UP 0x2191
#define ARROW_RIGHT 0x2192
#define ARROW_DOWN 0x2193
//
// EFI Console Colours
//
#define EFI_BLACK 0x00
#define EFI_BLUE 0x01
#define EFI_GREEN 0x02
#define EFI_CYAN (EFI_BLUE | EFI_GREEN)
#define EFI_RED 0x04
#define EFI_MAGENTA (EFI_BLUE | EFI_RED)
#define EFI_BROWN (EFI_GREEN | EFI_RED)
#define EFI_LIGHTGRAY (EFI_BLUE | EFI_GREEN | EFI_RED)
#define EFI_BRIGHT 0x08
#define EFI_DARKGRAY (EFI_BRIGHT)
#define EFI_LIGHTBLUE (EFI_BLUE | EFI_BRIGHT)
#define EFI_LIGHTGREEN (EFI_GREEN | EFI_BRIGHT)
#define EFI_LIGHTCYAN (EFI_CYAN | EFI_BRIGHT)
#define EFI_LIGHTRED (EFI_RED | EFI_BRIGHT)
#define EFI_LIGHTMAGENTA (EFI_MAGENTA | EFI_BRIGHT)
#define EFI_YELLOW (EFI_BROWN | EFI_BRIGHT)
#define EFI_WHITE (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT)
#define EFI_TEXT_ATTR(f, b) ((f) | ((b) << 4))
#define EFI_BACKGROUND_BLACK 0x00
#define EFI_BACKGROUND_BLUE 0x10
#define EFI_BACKGROUND_GREEN 0x20
#define EFI_BACKGROUND_CYAN (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN)
#define EFI_BACKGROUND_RED 0x40
#define EFI_BACKGROUND_MAGENTA (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED)
#define EFI_BACKGROUND_BROWN (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
#define EFI_BACKGROUND_LIGHTGRAY (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
//
// We currently define attributes from 0 - 7F for color manipulations
// To internally handle the local display characteristics for a particular character,
// Bit 7 signifies the local glyph representation for a character. If turned on, glyphs will be
// pulled from the wide glyph database and will display locally as a wide character (16 X 19 versus 8 X 19)
// If bit 7 is off, the narrow glyph database will be used. This does NOT affect information that is sent to
// non-local displays, such as serial or LAN consoles.
//
#define EFI_WIDE_ATTRIBUTE 0x80
/**
Reset the text output device hardware and optionaly run diagnostics
@param This The protocol instance pointer.
@param ExtendedVerification Driver may perform more exhaustive verfication
operation of the device during reset.
@retval EFI_SUCCESS The text output device was reset.
@retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
could not be reset.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_TEXT_RESET)(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
);
/**
Write a string to the output device.
@param This The protocol instance pointer.
@param String The NULL-terminated string to be displayed on the output
device(s). All output devices must also support the Unicode
drawing character codes defined in this file.
@retval EFI_SUCCESS The string was output to the device.
@retval EFI_DEVICE_ERROR The device reported an error while attempting to output
the text.
@retval EFI_UNSUPPORTED The output device's mode is not currently in a
defined text mode.
@retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
characters in the string could not be
rendered and were skipped.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_TEXT_STRING)(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *String
);
/**
Verifies that all characters in a string can be output to the
target device.
@param This The protocol instance pointer.
@param String The NULL-terminated string to be examined for the output
device(s).
@retval EFI_SUCCESS The device(s) are capable of rendering the output string.
@retval EFI_UNSUPPORTED Some of the characters in the string cannot be
rendered by one or more of the output devices mapped
by the EFI handle.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_TEXT_TEST_STRING)(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *String
);
/**
Returns information for an available text mode that the output device(s)
supports.
@param This The protocol instance pointer.
@param ModeNumber The mode number to return information on.
@param Columns Returns the geometry of the text output device for the
requested ModeNumber.
@param Rows Returns the geometry of the text output device for the
requested ModeNumber.
@retval EFI_SUCCESS The requested mode information was returned.
@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
@retval EFI_UNSUPPORTED The mode number was not valid.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_TEXT_QUERY_MODE)(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber,
OUT UINTN *Columns,
OUT UINTN *Rows
);
/**
Sets the output device(s) to a specified mode.
@param This The protocol instance pointer.
@param ModeNumber The mode number to set.
@retval EFI_SUCCESS The requested text mode was set.
@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
@retval EFI_UNSUPPORTED The mode number was not valid.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_TEXT_SET_MODE)(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber
);
/**
Sets the background and foreground colors for the OutputString () and
ClearScreen () functions.
@param This The protocol instance pointer.
@param Attribute The attribute to set. Bits 0..3 are the foreground color, and
bits 4..6 are the background color. All other bits are undefined
and must be zero. The valid Attributes are defined in this file.
@retval EFI_SUCCESS The attribute was set.
@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
@retval EFI_UNSUPPORTED The attribute requested is not defined.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_TEXT_SET_ATTRIBUTE)(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Attribute
);
/**
Clears the output device(s) display to the currently selected background
color.
@param This The protocol instance pointer.
@retval EFI_SUCCESS The operation completed successfully.
@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
@retval EFI_UNSUPPORTED The output device is not in a valid text mode.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_TEXT_CLEAR_SCREEN)(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
);
/**
Sets the current coordinates of the cursor position
@param This The protocol instance pointer.
@param Column The position to set the cursor to. Must be greater than or
equal to zero and less than the number of columns and rows
by QueryMode ().
@param Row The position to set the cursor to. Must be greater than or
equal to zero and less than the number of columns and rows
by QueryMode ().
@retval EFI_SUCCESS The operation completed successfully.
@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
@retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
cursor position is invalid for the current mode.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION)(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Column,
IN UINTN Row
);
/**
Makes the cursor visible or invisible
@param This The protocol instance pointer.
@param Visible If TRUE, the cursor is set to be visible. If FALSE, the cursor is
set to be invisible.
@retval EFI_SUCCESS The operation completed successfully.
@retval EFI_DEVICE_ERROR The device had an error and could not complete the
request, or the device does not support changing
the cursor mode.
@retval EFI_UNSUPPORTED The output device is not in a valid text mode.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_TEXT_ENABLE_CURSOR)(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN Visible
);
/**
@par Data Structure Description:
Mode Structure pointed to by Simple Text Out protocol.
**/
typedef struct {
///
/// The number of modes supported by QueryMode () and SetMode ().
///
INT32 MaxMode;
//
// current settings
//
///
/// The text mode of the output device(s).
///
INT32 Mode;
///
/// The current character output attribute.
///
INT32 Attribute;
///
/// The cursor's column.
///
INT32 CursorColumn;
///
/// The cursor's row.
///
INT32 CursorRow;
///
/// The cursor is currently visbile or not.
///
BOOLEAN CursorVisible;
} EFI_SIMPLE_TEXT_OUTPUT_MODE;
///
/// The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
/// It is the minimum required protocol for any handle supplied as the ConsoleOut
/// or StandardError device. In addition, the minimum supported text mode of such
/// devices is at least 80 x 25 characters.
///
struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL {
EFI_TEXT_RESET Reset;
EFI_TEXT_STRING OutputString;
EFI_TEXT_TEST_STRING TestString;
EFI_TEXT_QUERY_MODE QueryMode;
EFI_TEXT_SET_MODE SetMode;
EFI_TEXT_SET_ATTRIBUTE SetAttribute;
EFI_TEXT_CLEAR_SCREEN ClearScreen;
EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition;
EFI_TEXT_ENABLE_CURSOR EnableCursor;
///
/// Pointer to SIMPLE_TEXT_OUTPUT_MODE data.
///
EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
};
extern EFI_GUID gEfiSimpleTextOutProtocolGuid;
#endif

View file

@ -0,0 +1,27 @@
/** @file
Root include file for Mde Package UEFI, UEFI_APPLICATION type modules.
This is the include file for any module of type UEFI and UEFI_APPLICATION. Uefi modules only use
types defined via this include file and can be ported easily to any
environment.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that 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 __PI_UEFI_H__
#define __PI_UEFI_H__
#include <UefiBaseType.h>
#include <UefiSpec.h>
#endif

View file

@ -0,0 +1,287 @@
/** @file
Defines data types and constants introduced in UEFI.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that 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 __UEFI_BASETYPE_H__
#define __UEFI_BASETYPE_H__
#include <Base.h>
//
// Basic data type definitions introduced in UEFI.
//
///
/// 128-bit buffer containing a unique identifier value.
///
typedef GUID EFI_GUID;
///
/// Function return status for EFI API.
///
typedef RETURN_STATUS EFI_STATUS;
///
/// A collection of related interfaces.
///
typedef VOID *EFI_HANDLE;
///
/// Handle to an event structure.
///
typedef VOID *EFI_EVENT;
///
/// Task priority level.
///
typedef UINTN EFI_TPL;
///
/// Logical block address.
///
typedef UINT64 EFI_LBA;
///
/// 64-bit physical memory address.
///
typedef UINT64 EFI_PHYSICAL_ADDRESS;
///
/// 64-bit virtual memory address.
///
typedef UINT64 EFI_VIRTUAL_ADDRESS;
///
/// EFI Time Abstraction:
/// Year: 1900 - 9999
/// Month: 1 - 12
/// Day: 1 - 31
/// Hour: 0 - 23
/// Minute: 0 - 59
/// Second: 0 - 59
/// Nanosecond: 0 - 999,999,999
/// TimeZone: -1440 to 1440 or 2047
///
typedef struct {
UINT16 Year;
UINT8 Month;
UINT8 Day;
UINT8 Hour;
UINT8 Minute;
UINT8 Second;
UINT8 Pad1;
UINT32 Nanosecond;
INT16 TimeZone;
UINT8 Daylight;
UINT8 Pad2;
} EFI_TIME;
///
/// 4-byte buffer. An IPv4 internet protocol address.
///
typedef struct {
UINT8 Addr[4];
} EFI_IPv4_ADDRESS;
///
/// 16-byte buffer. An IPv6 internet protocol address.
///
typedef struct {
UINT8 Addr[16];
} EFI_IPv6_ADDRESS;
///
/// 32-byte buffer containing a network Media Access Control address.
///
typedef struct {
UINT8 Addr[32];
} EFI_MAC_ADDRESS;
///
/// 16-byte buffer aligned on a 4-byte boundary.
/// An IPv4 or IPv6 internet protocol address.
///
typedef union {
UINT32 Addr[4];
EFI_IPv4_ADDRESS v4;
EFI_IPv6_ADDRESS v6;
} EFI_IP_ADDRESS;
///
/// Enumeration of EFI_STATUS.
///@{
#define EFI_SUCCESS RETURN_SUCCESS
#define EFI_LOAD_ERROR RETURN_LOAD_ERROR
#define EFI_INVALID_PARAMETER RETURN_INVALID_PARAMETER
#define EFI_UNSUPPORTED RETURN_UNSUPPORTED
#define EFI_BAD_BUFFER_SIZE RETURN_BAD_BUFFER_SIZE
#define EFI_BUFFER_TOO_SMALL RETURN_BUFFER_TOO_SMALL
#define EFI_NOT_READY RETURN_NOT_READY
#define EFI_DEVICE_ERROR RETURN_DEVICE_ERROR
#define EFI_WRITE_PROTECTED RETURN_WRITE_PROTECTED
#define EFI_OUT_OF_RESOURCES RETURN_OUT_OF_RESOURCES
#define EFI_VOLUME_CORRUPTED RETURN_VOLUME_CORRUPTED
#define EFI_VOLUME_FULL RETURN_VOLUME_FULL
#define EFI_NO_MEDIA RETURN_NO_MEDIA
#define EFI_MEDIA_CHANGED RETURN_MEDIA_CHANGED
#define EFI_NOT_FOUND RETURN_NOT_FOUND
#define EFI_ACCESS_DENIED RETURN_ACCESS_DENIED
#define EFI_NO_RESPONSE RETURN_NO_RESPONSE
#define EFI_NO_MAPPING RETURN_NO_MAPPING
#define EFI_TIMEOUT RETURN_TIMEOUT
#define EFI_NOT_STARTED RETURN_NOT_STARTED
#define EFI_ALREADY_STARTED RETURN_ALREADY_STARTED
#define EFI_ABORTED RETURN_ABORTED
#define EFI_ICMP_ERROR RETURN_ICMP_ERROR
#define EFI_TFTP_ERROR RETURN_TFTP_ERROR
#define EFI_PROTOCOL_ERROR RETURN_PROTOCOL_ERROR
#define EFI_INCOMPATIBLE_VERSION RETURN_INCOMPATIBLE_VERSION
#define EFI_SECURITY_VIOLATION RETURN_SECURITY_VIOLATION
#define EFI_CRC_ERROR RETURN_CRC_ERROR
#define EFI_END_OF_MEDIA RETURN_END_OF_MEDIA
#define EFI_END_OF_FILE RETURN_END_OF_FILE
#define EFI_INVALID_LANGUAGE RETURN_INVALID_LANGUAGE
#define EFI_COMPROMISED_DATA RETURN_COMPROMISED_DATA
#define EFI_WARN_UNKNOWN_GLYPH RETURN_WARN_UNKNOWN_GLYPH
#define EFI_WARN_DELETE_FAILURE RETURN_WARN_DELETE_FAILURE
#define EFI_WARN_WRITE_FAILURE RETURN_WARN_WRITE_FAILURE
#define EFI_WARN_BUFFER_TOO_SMALL RETURN_WARN_BUFFER_TOO_SMALL
#define EFI_WARN_STALE_DATA RETURN_WARN_STALE_DATA
///@}
///
/// Define macro to encode the status code.
///
#define EFIERR(_a) ENCODE_ERROR(_a)
#define EFI_ERROR(A) RETURN_ERROR(A)
///
/// ICMP error definitions
///@{
#define EFI_NETWORK_UNREACHABLE EFIERR(100)
#define EFI_HOST_UNREACHABLE EFIERR(101)
#define EFI_PROTOCOL_UNREACHABLE EFIERR(102)
#define EFI_PORT_UNREACHABLE EFIERR(103)
///@}
///
/// Tcp connection status definitions
///@{
#define EFI_CONNECTION_FIN EFIERR(104)
#define EFI_CONNECTION_RESET EFIERR(105)
#define EFI_CONNECTION_REFUSED EFIERR(106)
///@}
//
// The EFI memory allocation functions work in units of EFI_PAGEs that are
// 4KB. This should in no way be confused with the page size of the processor.
// An EFI_PAGE is just the quanta of memory in EFI.
//
#define EFI_PAGE_SIZE SIZE_4KB
#define EFI_PAGE_MASK 0xFFF
#define EFI_PAGE_SHIFT 12
/**
Macro that converts a size, in bytes, to a number of EFI_PAGESs.
@param Size A size in bytes. This parameter is assumed to be type UINTN.
Passing in a parameter that is larger than UINTN may produce
unexpected results.
@return The number of EFI_PAGESs associated with the number of bytes specified
by Size.
**/
#define EFI_SIZE_TO_PAGES(Size) (((Size) >> EFI_PAGE_SHIFT) + (((Size) & EFI_PAGE_MASK) ? 1 : 0))
/**
Macro that converts a number of EFI_PAGEs to a size in bytes.
@param Pages The number of EFI_PAGES. This parameter is assumed to be
type UINTN. Passing in a parameter that is larger than
UINTN may produce unexpected results.
@return The number of bytes associated with the number of EFI_PAGEs specified
by Pages.
**/
#define EFI_PAGES_TO_SIZE(Pages) ((Pages) << EFI_PAGE_SHIFT)
///
/// PE32+ Machine type for IA32 UEFI images.
///
#define EFI_IMAGE_MACHINE_IA32 0x014C
///
/// PE32+ Machine type for IA64 UEFI images.
///
#define EFI_IMAGE_MACHINE_IA64 0x0200
///
/// PE32+ Machine type for EBC UEFI images.
///
#define EFI_IMAGE_MACHINE_EBC 0x0EBC
///
/// PE32+ Machine type for X64 UEFI images.
///
#define EFI_IMAGE_MACHINE_X64 0x8664
///
/// PE32+ Machine type for ARM mixed ARM and Thumb/Thumb2 images.
///
#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2
#if defined (MDE_CPU_IA32)
#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
(((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_X64)
#elif defined (MDE_CPU_IPF)
#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
(((Machine) == EFI_IMAGE_MACHINE_IA64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
#elif defined (MDE_CPU_X64)
#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
(((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_IA32)
#elif defined (MDE_CPU_ARM)
#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
(((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED)
#elif defined (MDE_CPU_EBC)
///
/// This is just to make sure you can cross compile with the EBC compiler.
/// It does not make sense to have a PE loader coded in EBC.
///
#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)
#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
#else
#error Unknown Processor Type
#endif
#endif

View file

@ -0,0 +1,193 @@
/** @file
This includes some definitions introduced in UEFI that will be used in both PEI and DXE phases.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that 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 __UEFI_MULTIPHASE_H__
#define __UEFI_MULTIPHASE_H__
#include <WinCertificate.h>
///
/// Enumeration of memory types introduced in UEFI.
///
typedef enum {
///
/// Not used.
///
EfiReservedMemoryType,
///
/// The code portions of a loaded application.
/// (Note that UEFI OS loaders are UEFI applications.)
///
EfiLoaderCode,
///
/// The data portions of a loaded application and the default data allocation
/// type used by an application to allocate pool memory.
///
EfiLoaderData,
///
/// The code portions of a loaded Boot Services Driver.
///
EfiBootServicesCode,
///
/// The data portions of a loaded Boot Serves Driver, and the default data
/// allocation type used by a Boot Services Driver to allocate pool memory.
///
EfiBootServicesData,
///
/// The code portions of a loaded Runtime Services Driver.
///
EfiRuntimeServicesCode,
///
/// The data portions of a loaded Runtime Services Driver and the default
/// data allocation type used by a Runtime Services Driver to allocate pool memory.
///
EfiRuntimeServicesData,
///
/// Free (unallocated) memory.
///
EfiConventionalMemory,
///
/// Memory in which errors have been detected.
///
EfiUnusableMemory,
///
/// Memory that holds the ACPI tables.
///
EfiACPIReclaimMemory,
///
/// Address space reserved for use by the firmware.
///
EfiACPIMemoryNVS,
///
/// Used by system firmware to request that a memory-mapped IO region
/// be mapped by the OS to a virtual address so it can be accessed by EFI runtime services.
///
EfiMemoryMappedIO,
///
/// System memory-mapped IO region that is used to translate memory
/// cycles to IO cycles by the processor.
///
EfiMemoryMappedIOPortSpace,
///
/// Address space reserved by the firmware for code that is part of the processor.
///
EfiPalCode,
EfiMaxMemoryType
} EFI_MEMORY_TYPE;
///
/// Data structure that precedes all of the standard EFI table types.
///
typedef struct {
///
/// A 64-bit signature that identifies the type of table that follows.
/// Unique signatures have been generated for the EFI System Table,
/// the EFI Boot Services Table, and the EFI Runtime Services Table.
///
UINT64 Signature;
///
/// The revision of the EFI Specification to which this table
/// conforms. The upper 16 bits of this field contain the major
/// revision value, and the lower 16 bits contain the minor revision
/// value. The minor revision values are limited to the range of 00..99.
///
UINT32 Revision;
///
/// The size, in bytes, of the entire table including the EFI_TABLE_HEADER.
///
UINT32 HeaderSize;
///
/// The 32-bit CRC for the entire table. This value is computed by
/// setting this field to 0, and computing the 32-bit CRC for HeaderSize bytes.
///
UINT32 CRC32;
///
/// Reserved field that must be set to 0.
///
UINT32 Reserved;
} EFI_TABLE_HEADER;
///
/// Attributes of variable.
///
#define EFI_VARIABLE_NON_VOLATILE 0x00000001
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
///
/// This attribute is identified by the mnemonic 'HR'
/// elsewhere in this specification.
///
#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008
///
/// Attributes of Authenticated Variable
///
#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010
#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020
#define EFI_VARIABLE_APPEND_WRITE 0x00000040
///
/// AuthInfo is a WIN_CERTIFICATE using the wCertificateType
/// WIN_CERTIFICATE_UEFI_GUID and the CertType
/// EFI_CERT_TYPE_RSA2048_SHA256_GUID. If the attribute specifies
/// authenticated access, then the Data buffer should begin with an
/// authentication descriptor prior to the data payload and DataSize
/// should reflect the the data.and descriptor size. The caller
/// shall digest the Monotonic Count value and the associated data
/// for the variable update using the SHA-256 1-way hash algorithm.
/// The ensuing the 32-byte digest will be signed using the private
/// key associated w/ the public/private 2048-bit RSA key-pair. The
/// WIN_CERTIFICATE shall be used to describe the signature of the
/// Variable data *Data. In addition, the signature will also
/// include the MonotonicCount value to guard against replay attacks.
///
typedef struct {
///
/// Included in the signature of
/// AuthInfo.Used to ensure freshness/no
/// replay. Incremented during each
/// "Write" access.
///
UINT64 MonotonicCount;
///
/// Provides the authorization for the variable
/// access. It is a signature across the
/// variable data and the Monotonic Count
/// value. Caller uses Private key that is
/// associated with a public key that has been
/// provisioned via the key exchange.
///
WIN_CERTIFICATE_UEFI_GUID AuthInfo;
} EFI_VARIABLE_AUTHENTICATION;
///
/// When the attribute EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS is
/// set, then the Data buffer shall begin with an instance of a complete (and serialized)
/// EFI_VARIABLE_AUTHENTICATION_2 descriptor. The descriptor shall be followed by the new
/// variable value and DataSize shall reflect the combined size of the descriptor and the new
/// variable value. The authentication descriptor is not part of the variable data and is not
/// returned by subsequent calls to GetVariable().
///
typedef struct {
///
/// For the TimeStamp value, components Pad1, Nanosecond, TimeZone, Daylight and
/// Pad2 shall be set to 0. This means that the time shall always be expressed in GMT.
///
EFI_TIME TimeStamp;
///
/// Only a CertType of EFI_CERT_TYPE_PKCS7_GUID is accepted.
///
WIN_CERTIFICATE_UEFI_GUID AuthInfo;
} EFI_VARIABLE_AUTHENTICATION_2;
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,128 @@
/** @file
GUID for UEFI WIN_CERTIFICATE structure.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
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.
@par Revision Reference:
GUID defined in UEFI 2.0 spec.
**/
#ifndef __EFI_WIN_CERTIFICATE_H__
#define __EFI_WIN_CERTIFICATE_H__
//
// _WIN_CERTIFICATE.wCertificateType
//
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002
#define WIN_CERT_TYPE_EFI_PKCS115 0x0EF0
#define WIN_CERT_TYPE_EFI_GUID 0x0EF1
///
/// The WIN_CERTIFICATE structure is part of the PE/COFF specification.
///
typedef struct {
///
/// The length of the entire certificate,
/// including the length of the header, in bytes.
///
UINT32 dwLength;
///
/// The revision level of the WIN_CERTIFICATE
/// structure. The current revision level is 0x0200.
///
UINT16 wRevision;
///
/// The certificate type. See WIN_CERT_TYPE_xxx for the UEFI
/// certificate types. The UEFI specification reserves the range of
/// certificate type values from 0x0EF0 to 0x0EFF.
///
UINT16 wCertificateType;
///
/// The following is the actual certificate. The format of
/// the certificate depends on wCertificateType.
///
/// UINT8 bCertificate[ANYSIZE_ARRAY];
///
} WIN_CERTIFICATE;
///
/// WIN_CERTIFICATE_UEFI_GUID.CertType
///
#define EFI_CERT_TYPE_RSA2048_SHA256_GUID \
{0xa7717414, 0xc616, 0x4977, { 0x94, 0x20, 0x84, 0x47, 0x12, 0xa7, 0x35, 0xbf } }
///
/// WIN_CERTIFICATE_UEFI_GUID.CertData
///
typedef struct {
EFI_GUID HashType;
UINT8 PublicKey[256];
UINT8 Signature[256];
} EFI_CERT_BLOCK_RSA_2048_SHA256;
///
/// Certificate which encapsulates a GUID-specific digital signature
///
typedef struct {
///
/// This is the standard WIN_CERTIFICATE header, where
/// wCertificateType is set to WIN_CERT_TYPE_UEFI_GUID.
///
WIN_CERTIFICATE Hdr;
///
/// This is the unique id which determines the
/// format of the CertData. .
///
EFI_GUID CertType;
///
/// The following is the certificate data. The format of
/// the data is determined by the CertType.
/// If CertType is EFI_CERT_TYPE_RSA2048_SHA256_GUID,
/// the CertData will be EFI_CERT_BLOCK_RSA_2048_SHA256 structure.
///
UINT8 CertData[1];
} WIN_CERTIFICATE_UEFI_GUID;
///
/// Certificate which encapsulates the RSASSA_PKCS1-v1_5 digital signature.
///
/// The WIN_CERTIFICATE_UEFI_PKCS1_15 structure is derived from
/// WIN_CERTIFICATE and encapsulate the information needed to
/// implement the RSASSA-PKCS1-v1_5 digital signature algorithm as
/// specified in RFC2437.
///
typedef struct {
///
/// This is the standard WIN_CERTIFICATE header, where
/// wCertificateType is set to WIN_CERT_TYPE_UEFI_PKCS1_15.
///
WIN_CERTIFICATE Hdr;
///
/// This is the hashing algorithm which was performed on the
/// UEFI executable when creating the digital signature.
///
EFI_GUID HashAlgorithm;
///
/// The following is the actual digital signature. The
/// size of the signature is the same size as the key
/// (1024-bit key is 128 bytes) and can be determined by
/// subtracting the length of the other parts of this header
/// from the total length of the certificate as found in
/// Hdr.dwLength.
///
/// UINT8 Signature[];
///
} WIN_CERTIFICATE_EFI_PKCS1_15;
extern EFI_GUID gEfiCertTypeRsa2048Sha256Guid;
#endif

View file

View file

View file

@ -0,0 +1,102 @@
/*
* COPYRIGHT: See COPYING.ARM in the top level directory
* PROJECT: ReactOS UEFI Boot Library
* FILE: boot/environ/lib/bootlib.c
* PURPOSE: Boot Library Initialization
* PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "bl.h"
/* DATA VARIABLES ************************************************************/
BL_LIBRARY_PARAMETERS BlpLibraryParameters;
/* FUNCTIONS *****************************************************************/
/*++
* @name InitializeLibrary
*
* The InitializeLibrary function initializes the Boot Library.
*
* @param BootParameters
* Pointer to the Boot Application Parameter Block.
*
* @param LibraryParameters
* Pointer to the Boot Library Parameters.
*
* @return NT_SUCCESS if the boot library was loaded correctly, relevant error
* otherwise.
*
*--*/
NTSTATUS
InitializeLibrary (
_In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootAppParameters,
_In_ PBL_LIBRARY_PARAMETERS LibraryParameters
)
{
DBG_UNREFERENCED_PARAMETER(BootAppParameters);
DBG_UNREFERENCED_PARAMETER(LibraryParameters);
return STATUS_NOT_IMPLEMENTED;
}
/*++
* @name BlInitializeLibrary
*
* The BlInitializeLibrary function initializes, or re-initializes, the
* Boot Library.
*
* @param BootParameters
* Pointer to the Boot Application Parameter Block.
*
* @param LibraryParameters
* Pointer to the Boot Library Parameters.
*
* @return NT_SUCCESS if the boot library was loaded correctly, relevant error
* otherwise.
*
*--*/
NTSTATUS
BlInitializeLibrary(
_In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootAppParameters,
_In_ PBL_LIBRARY_PARAMETERS LibraryParameters
)
{
NTSTATUS Status;
/* Are we re-initializing the library? */
if (LibraryParameters->LibraryFlags & 2)
{
/* From scratch? */
BlpLibraryParameters = *LibraryParameters;
if (LibraryParameters->LibraryFlags & 4)
{
#if 0
/* Initialize all the core modules again */
BlpSiInitialize(1);
BlBdInitialize();
BlMmRemoveBadMemory();
BlpMmInitializeConstraints();
/* Redraw the graphics console as needed */
BlpDisplayInitialize(LibraryParameters->LibraryFlags);
BlpResourceInitialize();
#endif
}
/* Nothing to do, we're done */
Status = STATUS_SUCCESS;
}
else
{
/* Nope, this is first time initialization */
Status = InitializeLibrary(BootAppParameters, LibraryParameters);
}
/* Return initialization status */
return Status;
}

View file

View file

View file

View file

@ -0,0 +1,148 @@
/*
* COPYRIGHT: See COPYING.ARM in the top level directory
* PROJECT: ReactOS UEFI Boot Library
* FILE: boot/environ/lib/bootlib.c
* PURPOSE: Boot Library Initialization
* PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "bl.h"
/* FUNCTIONS *****************************************************************/
/*++
* @name EfiGetEfiStatusCode
*
* The EfiGetEfiStatusCode routine converts an NT Status to an EFI status.
*
* @param Status
* NT Status code to be converted.
*
* @remark Only certain, specific NT status codes are converted to EFI codes.
*
* @return The corresponding EFI Status code, EFI_NO_MAPPING otherwise.
*
*--*/
EFI_STATUS
EfiGetEfiStatusCode(
_In_ NTSTATUS Status
)
{
switch (Status)
{
case STATUS_NOT_SUPPORTED:
return EFI_UNSUPPORTED;
case STATUS_DISK_FULL:
return EFI_VOLUME_FULL;
case STATUS_INSUFFICIENT_RESOURCES:
return EFI_OUT_OF_RESOURCES;
case STATUS_MEDIA_WRITE_PROTECTED:
return EFI_WRITE_PROTECTED;
case STATUS_DEVICE_NOT_READY:
return EFI_NOT_STARTED;
case STATUS_DEVICE_ALREADY_ATTACHED:
return EFI_ALREADY_STARTED;
case STATUS_MEDIA_CHANGED:
return EFI_MEDIA_CHANGED;
case STATUS_INVALID_PARAMETER:
return EFI_INVALID_PARAMETER;
case STATUS_ACCESS_DENIED:
return EFI_ACCESS_DENIED;
case STATUS_BUFFER_TOO_SMALL:
return EFI_BUFFER_TOO_SMALL;
case STATUS_DISK_CORRUPT_ERROR:
return EFI_VOLUME_CORRUPTED;
case STATUS_REQUEST_ABORTED:
return EFI_ABORTED;
case STATUS_NO_MEDIA:
return EFI_NO_MEDIA;
case STATUS_IO_DEVICE_ERROR:
return EFI_DEVICE_ERROR;
case STATUS_INVALID_BUFFER_SIZE:
return EFI_BAD_BUFFER_SIZE;
case STATUS_NOT_FOUND:
return EFI_NOT_FOUND;
case STATUS_DRIVER_UNABLE_TO_LOAD:
return EFI_LOAD_ERROR;
case STATUS_NO_MATCH:
return EFI_NO_MAPPING;
case STATUS_SUCCESS:
return EFI_SUCCESS;
case STATUS_TIMEOUT:
return EFI_TIMEOUT;
default:
return EFI_NO_MAPPING;
}
}
/*++
* @name EfiGetNtStatusCode
*
* The EfiGetNtStatusCode routine converts an EFI Status to an NT status.
*
* @param EfiStatus
* EFI Status code to be converted.
*
* @remark Only certain, specific EFI status codes are converted to NT codes.
*
* @return The corresponding NT Status code, STATUS_UNSUCCESSFUL otherwise.
*
*--*/
NTSTATUS
EfiGetNtStatusCode (
_In_ EFI_STATUS EfiStatus
)
{
switch (EfiStatus)
{
case EFI_NOT_READY:
case EFI_NOT_FOUND:
return STATUS_NOT_FOUND;
case EFI_NO_MEDIA:
return STATUS_NO_MEDIA;
case EFI_MEDIA_CHANGED:
return STATUS_MEDIA_CHANGED;
case EFI_ACCESS_DENIED:
case EFI_SECURITY_VIOLATION:
return STATUS_ACCESS_DENIED;
case EFI_TIMEOUT:
case EFI_NO_RESPONSE:
return STATUS_TIMEOUT;
case EFI_NO_MAPPING:
return STATUS_NO_MATCH;
case EFI_NOT_STARTED:
return STATUS_DEVICE_NOT_READY;
case EFI_ALREADY_STARTED:
return STATUS_DEVICE_ALREADY_ATTACHED;
case EFI_ABORTED:
return STATUS_REQUEST_ABORTED;
case EFI_VOLUME_FULL:
return STATUS_DISK_FULL;
case EFI_DEVICE_ERROR:
return STATUS_IO_DEVICE_ERROR;
case EFI_WRITE_PROTECTED:
return STATUS_MEDIA_WRITE_PROTECTED;
/* @FIXME: ReactOS Headers don't yet have this */
//case EFI_OUT_OF_RESOURCES:
//return STATUS_INSUFFICIENT_NVRAM_RESOURCES;
case EFI_VOLUME_CORRUPTED:
return STATUS_DISK_CORRUPT_ERROR;
case EFI_BUFFER_TOO_SMALL:
return STATUS_BUFFER_TOO_SMALL;
case EFI_SUCCESS:
return STATUS_SUCCESS;
case EFI_LOAD_ERROR:
return STATUS_DRIVER_UNABLE_TO_LOAD;
case EFI_INVALID_PARAMETER:
return STATUS_INVALID_PARAMETER;
case EFI_UNSUPPORTED:
return STATUS_NOT_SUPPORTED;
case EFI_BAD_BUFFER_SIZE:
return STATUS_INVALID_BUFFER_SIZE;
default:
return STATUS_UNSUCCESSFUL;
}
}

View file

View file