diff --git a/reactos/boot/CMakeLists.txt b/reactos/boot/CMakeLists.txt index 99ac824eb39..a1bb5c50e53 100644 --- a/reactos/boot/CMakeLists.txt +++ b/reactos/boot/CMakeLists.txt @@ -46,3 +46,5 @@ add_custom_target(hybridcd add_subdirectory(freeldr) add_subdirectory(bootdata) +add_subdirectory(environ) + diff --git a/reactos/boot/bcd/.gitignore b/reactos/boot/bcd/.gitignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/reactos/boot/bgfx/.gitignore b/reactos/boot/bgfx/.gitignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/reactos/boot/bootdata/txtsetup.sif b/reactos/boot/bootdata/txtsetup.sif index 8c475f1483b..b9ae9fca314 100644 --- a/reactos/boot/bootdata/txtsetup.sif +++ b/reactos/boot/bootdata/txtsetup.sif @@ -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" diff --git a/reactos/boot/environ/CMakeLists.txt b/reactos/boot/environ/CMakeLists.txt new file mode 100644 index 00000000000..241f4ca8645 --- /dev/null +++ b/reactos/boot/environ/CMakeLists.txt @@ -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) + diff --git a/reactos/boot/environ/app/bootmgr/bootmgr.c b/reactos/boot/environ/app/bootmgr/bootmgr.c new file mode 100644 index 00000000000..60888bc691e --- /dev/null +++ b/reactos/boot/environ/app/bootmgr/bootmgr.c @@ -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; +} + diff --git a/reactos/boot/environ/app/bootmgr/bootmgr.h b/reactos/boot/environ/app/bootmgr/bootmgr.h new file mode 100644 index 00000000000..13d5bcd06a6 --- /dev/null +++ b/reactos/boot/environ/app/bootmgr/bootmgr.h @@ -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 +#include +#include + +/* NT Base Headers */ +#include + +/* UEFI Headers */ +#include + +/* Boot Library Headers */ +#include + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +BmMain ( + _In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters + ); + +#endif diff --git a/reactos/boot/environ/app/bootmgr/efiemu.c b/reactos/boot/environ/app/bootmgr/efiemu.c new file mode 100644 index 00000000000..8d36dd39637 --- /dev/null +++ b/reactos/boot/environ/app/bootmgr/efiemu.c @@ -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); +} + diff --git a/reactos/boot/environ/include/bl.h b/reactos/boot/environ/include/bl.h new file mode 100644 index 00000000000..60426a9cfe9 --- /dev/null +++ b/reactos/boot/environ/include/bl.h @@ -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 diff --git a/reactos/boot/environ/include/efi/Base.h b/reactos/boot/environ/include/efi/Base.h new file mode 100644 index 00000000000..802df977aa0 --- /dev/null +++ b/reactos/boot/environ/include/efi/Base.h @@ -0,0 +1,1005 @@ +/** @file +Root include file for Mde Package Base type modules + +This is the include file for any module of type base. Base modules only use +types defined via this include file and can be ported easily to any +environment. There are a set of base libraries in the Mde Package that can +be used to implement base modules. + +Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+Portions copyright (c) 2008 - 2009, Apple Inc. 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 __BASE_H__ +#define __BASE_H__ + +// +// Include processor specific binding +// +#include + +/** +Verifies the storage size of a given data type. + +This macro generates a divide by zero error or a zero size array declaration in +the preprocessor if the size is incorrect. These are declared as "extern" so +the space for these arrays will not be in the modules. + +@param TYPE The date type to determine the size of. +@param Size The expected size for the TYPE. + +**/ +#define VERIFY_SIZE_OF(TYPE, Size) extern UINT8 _VerifySizeof##TYPE[(sizeof(TYPE) == (Size)) / (sizeof(TYPE) == (Size))] + +// +// Verify that ProcessorBind.h produced UEFI Data Types that are compliant with +// Section 2.3.1 of the UEFI 2.3 Specification. +// +VERIFY_SIZE_OF(BOOLEAN, 1); +VERIFY_SIZE_OF(INT8, 1); +VERIFY_SIZE_OF(UINT8, 1); +VERIFY_SIZE_OF(INT16, 2); +VERIFY_SIZE_OF(UINT16, 2); +VERIFY_SIZE_OF(INT32, 4); +VERIFY_SIZE_OF(UINT32, 4); +VERIFY_SIZE_OF(INT64, 8); +VERIFY_SIZE_OF(UINT64, 8); +VERIFY_SIZE_OF(CHAR8, 1); +VERIFY_SIZE_OF(CHAR16, 2); + +// +// The Microsoft* C compiler can removed references to unreferenced data items +// if the /OPT:REF linker option is used. We defined a macro as this is a +// a non standard extension +// +#if defined(_MSC_EXTENSIONS) && !defined (MDE_CPU_EBC) +/// +/// Remove global variable from the linked image if there are no references to +/// it after all compiler and linker optimizations have been performed. +/// +/// +#define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany) +#else +/// +/// Remove the global variable from the linked image if there are no references +/// to it after all compiler and linker optimizations have been performed. +/// +/// +#define GLOBAL_REMOVE_IF_UNREFERENCED +#endif + +// +// For symbol name in GNU assembly code, an extra "_" is necessary +// +#if defined(__GNUC__) +/// +/// Private worker functions for ASM_PFX() +/// +#define _CONCATENATE(a, b) __CONCATENATE(a, b) +#define __CONCATENATE(a, b) a ## b + +/// +/// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the prefix +/// on symbols in assembly language. +/// +#define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name) +#endif + +#if __APPLE__ +// +// Apple extension that is used by the linker to optimize code size +// with assembly functions. Put at the end of your .S files +// +#define ASM_FUNCTION_REMOVE_IF_UNREFERENCED .subsections_via_symbols +#else +#define ASM_FUNCTION_REMOVE_IF_UNREFERENCED +#endif + +#ifdef __CC_ARM +// +// Older RVCT ARM compilers don't fully support #pragma pack and require __packed +// as a prefix for the structure. +// +#define PACKED __packed +#else +#define PACKED +#endif + +#if 0 +/// +/// 128 bit buffer containing a unique identifier value. +/// Unless otherwise specified, aligned on a 64 bit boundary. +/// +typedef struct { + UINT32 Data1; + UINT16 Data2; + UINT16 Data3; + UINT8 Data4[8]; +} GUID; + +// +// 8-bytes unsigned value that represents a physical system address. +// +typedef UINT64 PHYSICAL_ADDRESS; + +/// +/// LIST_ENTRY structure definition. +/// +typedef struct _LIST_ENTRY LIST_ENTRY; + +/// +/// _LIST_ENTRY structure definition. +/// +struct _LIST_ENTRY { + LIST_ENTRY *ForwardLink; + LIST_ENTRY *BackLink; +}; + +// +// Modifiers to abstract standard types to aid in debug of problems +// + +/// +/// Datum is read-only. +/// +#define CONST const + +/// +/// Datum is scoped to the current file or function. +/// +#define STATIC static + +/// +/// Undeclared type. +/// +#define VOID void + +// +// Modifiers for Data Types used to self document code. +// This concept is borrowed for UEFI specification. +// + +/// +/// Datum is passed to the function. +/// +#define IN + +/// +/// Datum is returned from the function. +/// +#define OUT + +/// +/// Passing the datum to the function is optional, and a NULL +/// is passed if the value is not supplied. +/// +#define OPTIONAL + +// +// UEFI specification claims 1 and 0. We are concerned about the +// complier portability so we did it this way. +// + +/// +/// Boolean true value. UEFI Specification defines this value to be 1, +/// but this form is more portable. +/// +#define TRUE ((BOOLEAN)(1==1)) + +/// +/// Boolean false value. UEFI Specification defines this value to be 0, +/// but this form is more portable. +/// +#define FALSE ((BOOLEAN)(0==1)) + +/// +/// NULL pointer (VOID *) +/// +#define NULL ((VOID *) 0) +#endif + +#define BIT0 0x00000001 +#define BIT1 0x00000002 +#define BIT2 0x00000004 +#define BIT3 0x00000008 +#define BIT4 0x00000010 +#define BIT5 0x00000020 +#define BIT6 0x00000040 +#define BIT7 0x00000080 +#define BIT8 0x00000100 +#define BIT9 0x00000200 +#define BIT10 0x00000400 +#define BIT11 0x00000800 +#define BIT12 0x00001000 +#define BIT13 0x00002000 +#define BIT14 0x00004000 +#define BIT15 0x00008000 +#define BIT16 0x00010000 +#define BIT17 0x00020000 +#define BIT18 0x00040000 +#define BIT19 0x00080000 +#define BIT20 0x00100000 +#define BIT21 0x00200000 +#define BIT22 0x00400000 +#define BIT23 0x00800000 +#define BIT24 0x01000000 +#define BIT25 0x02000000 +#define BIT26 0x04000000 +#define BIT27 0x08000000 +#define BIT28 0x10000000 +#define BIT29 0x20000000 +#define BIT30 0x40000000 +#define BIT31 0x80000000 +#define BIT32 0x0000000100000000ULL +#define BIT33 0x0000000200000000ULL +#define BIT34 0x0000000400000000ULL +#define BIT35 0x0000000800000000ULL +#define BIT36 0x0000001000000000ULL +#define BIT37 0x0000002000000000ULL +#define BIT38 0x0000004000000000ULL +#define BIT39 0x0000008000000000ULL +#define BIT40 0x0000010000000000ULL +#define BIT41 0x0000020000000000ULL +#define BIT42 0x0000040000000000ULL +#define BIT43 0x0000080000000000ULL +#define BIT44 0x0000100000000000ULL +#define BIT45 0x0000200000000000ULL +#define BIT46 0x0000400000000000ULL +#define BIT47 0x0000800000000000ULL +#define BIT48 0x0001000000000000ULL +#define BIT49 0x0002000000000000ULL +#define BIT50 0x0004000000000000ULL +#define BIT51 0x0008000000000000ULL +#define BIT52 0x0010000000000000ULL +#define BIT53 0x0020000000000000ULL +#define BIT54 0x0040000000000000ULL +#define BIT55 0x0080000000000000ULL +#define BIT56 0x0100000000000000ULL +#define BIT57 0x0200000000000000ULL +#define BIT58 0x0400000000000000ULL +#define BIT59 0x0800000000000000ULL +#define BIT60 0x1000000000000000ULL +#define BIT61 0x2000000000000000ULL +#define BIT62 0x4000000000000000ULL +#define BIT63 0x8000000000000000ULL + +#define SIZE_1KB 0x00000400 +#define SIZE_2KB 0x00000800 +#define SIZE_4KB 0x00001000 +#define SIZE_8KB 0x00002000 +#define SIZE_16KB 0x00004000 +#define SIZE_32KB 0x00008000 +#define SIZE_64KB 0x00010000 +#define SIZE_128KB 0x00020000 +#define SIZE_256KB 0x00040000 +#define SIZE_512KB 0x00080000 +#define SIZE_1MB 0x00100000 +#define SIZE_2MB 0x00200000 +#define SIZE_4MB 0x00400000 +#define SIZE_8MB 0x00800000 +#define SIZE_16MB 0x01000000 +#define SIZE_32MB 0x02000000 +#define SIZE_64MB 0x04000000 +#define SIZE_128MB 0x08000000 +#define SIZE_256MB 0x10000000 +#define SIZE_512MB 0x20000000 +#define SIZE_1GB 0x40000000 +#define SIZE_2GB 0x80000000 +#define SIZE_4GB 0x0000000100000000ULL +#define SIZE_8GB 0x0000000200000000ULL +#define SIZE_16GB 0x0000000400000000ULL +#define SIZE_32GB 0x0000000800000000ULL +#define SIZE_64GB 0x0000001000000000ULL +#define SIZE_128GB 0x0000002000000000ULL +#define SIZE_256GB 0x0000004000000000ULL +#define SIZE_512GB 0x0000008000000000ULL +#define SIZE_1TB 0x0000010000000000ULL +#define SIZE_2TB 0x0000020000000000ULL +#define SIZE_4TB 0x0000040000000000ULL +#define SIZE_8TB 0x0000080000000000ULL +#define SIZE_16TB 0x0000100000000000ULL +#define SIZE_32TB 0x0000200000000000ULL +#define SIZE_64TB 0x0000400000000000ULL +#define SIZE_128TB 0x0000800000000000ULL +#define SIZE_256TB 0x0001000000000000ULL +#define SIZE_512TB 0x0002000000000000ULL +#define SIZE_1PB 0x0004000000000000ULL +#define SIZE_2PB 0x0008000000000000ULL +#define SIZE_4PB 0x0010000000000000ULL +#define SIZE_8PB 0x0020000000000000ULL +#define SIZE_16PB 0x0040000000000000ULL +#define SIZE_32PB 0x0080000000000000ULL +#define SIZE_64PB 0x0100000000000000ULL +#define SIZE_128PB 0x0200000000000000ULL +#define SIZE_256PB 0x0400000000000000ULL +#define SIZE_512PB 0x0800000000000000ULL +#define SIZE_1EB 0x1000000000000000ULL +#define SIZE_2EB 0x2000000000000000ULL +#define SIZE_4EB 0x4000000000000000ULL +#define SIZE_8EB 0x8000000000000000ULL + +#define BASE_1KB 0x00000400 +#define BASE_2KB 0x00000800 +#define BASE_4KB 0x00001000 +#define BASE_8KB 0x00002000 +#define BASE_16KB 0x00004000 +#define BASE_32KB 0x00008000 +#define BASE_64KB 0x00010000 +#define BASE_128KB 0x00020000 +#define BASE_256KB 0x00040000 +#define BASE_512KB 0x00080000 +#define BASE_1MB 0x00100000 +#define BASE_2MB 0x00200000 +#define BASE_4MB 0x00400000 +#define BASE_8MB 0x00800000 +#define BASE_16MB 0x01000000 +#define BASE_32MB 0x02000000 +#define BASE_64MB 0x04000000 +#define BASE_128MB 0x08000000 +#define BASE_256MB 0x10000000 +#define BASE_512MB 0x20000000 +#define BASE_1GB 0x40000000 +#define BASE_2GB 0x80000000 +#define BASE_4GB 0x0000000100000000ULL +#define BASE_8GB 0x0000000200000000ULL +#define BASE_16GB 0x0000000400000000ULL +#define BASE_32GB 0x0000000800000000ULL +#define BASE_64GB 0x0000001000000000ULL +#define BASE_128GB 0x0000002000000000ULL +#define BASE_256GB 0x0000004000000000ULL +#define BASE_512GB 0x0000008000000000ULL +#define BASE_1TB 0x0000010000000000ULL +#define BASE_2TB 0x0000020000000000ULL +#define BASE_4TB 0x0000040000000000ULL +#define BASE_8TB 0x0000080000000000ULL +#define BASE_16TB 0x0000100000000000ULL +#define BASE_32TB 0x0000200000000000ULL +#define BASE_64TB 0x0000400000000000ULL +#define BASE_128TB 0x0000800000000000ULL +#define BASE_256TB 0x0001000000000000ULL +#define BASE_512TB 0x0002000000000000ULL +#define BASE_1PB 0x0004000000000000ULL +#define BASE_2PB 0x0008000000000000ULL +#define BASE_4PB 0x0010000000000000ULL +#define BASE_8PB 0x0020000000000000ULL +#define BASE_16PB 0x0040000000000000ULL +#define BASE_32PB 0x0080000000000000ULL +#define BASE_64PB 0x0100000000000000ULL +#define BASE_128PB 0x0200000000000000ULL +#define BASE_256PB 0x0400000000000000ULL +#define BASE_512PB 0x0800000000000000ULL +#define BASE_1EB 0x1000000000000000ULL +#define BASE_2EB 0x2000000000000000ULL +#define BASE_4EB 0x4000000000000000ULL +#define BASE_8EB 0x8000000000000000ULL + +// +// Support for variable length argument lists using the ANSI standard. +// +// Since we are using the ANSI standard we used the standard naming and +// did not follow the coding convention +// +// VA_LIST - typedef for argument list. +// VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use. +// VA_END (VA_LIST Marker) - Clear Marker +// VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argument from +// the ... list. You must know the size and pass it in this macro. +// VA_COPY (VA_LIST Dest, VA_LIST Start) - Initialize Dest as a copy of Start. +// +// example: +// +// UINTN +// ExampleVarArg ( +// IN UINTN NumberOfArgs, +// ... +// ) +// { +// VA_LIST Marker; +// UINTN Index; +// UINTN Result; +// +// // +// // Initialize the Marker +// // +// VA_START (Marker, NumberOfArgs); +// for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) { +// // +// // The ... list is a series of UINTN values, so average them up. +// // +// Result += VA_ARG (Marker, UINTN); +// } +// +// VA_END (Marker); +// return Result +// } +// + +/** +Return the size of argument that has been aligned to sizeof (UINTN). + +@param n The parameter size to be aligned. + +@return The aligned size. +**/ +#define _INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1)) + +#if defined(__CC_ARM) +// +// RVCT ARM variable argument list support. +// + +/// +/// Variable used to traverse the list of arguments. This type can vary by +/// implementation and could be an array or structure. +/// +#ifdef __APCS_ADSABI +typedef int *va_list[1]; +#define VA_LIST va_list +#else +typedef struct __va_list { void *__ap; } va_list; +#define VA_LIST va_list +#endif + +#define VA_START(Marker, Parameter) __va_start(Marker, Parameter) + +#define VA_ARG(Marker, TYPE) __va_arg(Marker, TYPE) + +#define VA_END(Marker) ((void)0) + +#define VA_COPY(Dest, Start) __va_copy (Dest, Start) + +#elif defined(__GNUC__) && !defined(NO_BUILTIN_VA_FUNCS) +// +// Use GCC built-in macros for variable argument lists. +// + +/// +/// Variable used to traverse the list of arguments. This type can vary by +/// implementation and could be an array or structure. +/// +typedef __builtin_va_list VA_LIST; + +#define VA_START(Marker, Parameter) __builtin_va_start (Marker, Parameter) + +#define VA_ARG(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE))) + +#define VA_END(Marker) __builtin_va_end (Marker) + +#define VA_COPY(Dest, Start) __builtin_va_copy (Dest, Start) + +#else +/// +/// Variable used to traverse the list of arguments. This type can vary by +/// implementation and could be an array or structure. +/// +typedef CHAR8 *VA_LIST; + +/** +Retrieves a pointer to the beginning of a variable argument list, based on +the name of the parameter that immediately precedes the variable argument list. + +This function initializes Marker to point to the beginning of the variable +argument list that immediately follows Parameter. The method for computing the +pointer to the next argument in the argument list is CPU-specific following the +EFIAPI ABI. + +@param Marker The VA_LIST used to traverse the list of arguments. +@param Parameter The name of the parameter that immediately precedes +the variable argument list. + +@return A pointer to the beginning of a variable argument list. + +**/ +#define VA_START(Marker, Parameter) (Marker = (VA_LIST) ((UINTN) & (Parameter) + _INT_SIZE_OF (Parameter))) + +/** +Returns an argument of a specified type from a variable argument list and updates +the pointer to the variable argument list to point to the next argument. + +This function returns an argument of the type specified by TYPE from the beginning +of the variable argument list specified by Marker. Marker is then updated to point +to the next argument in the variable argument list. The method for computing the +pointer to the next argument in the argument list is CPU-specific following the EFIAPI ABI. + +@param Marker VA_LIST used to traverse the list of arguments. +@param TYPE The type of argument to retrieve from the beginning +of the variable argument list. + +@return An argument of the type specified by TYPE. + +**/ +#define VA_ARG(Marker, TYPE) (*(TYPE *) ((Marker += _INT_SIZE_OF (TYPE)) - _INT_SIZE_OF (TYPE))) + +/** +Terminates the use of a variable argument list. + +This function initializes Marker so it can no longer be used with VA_ARG(). +After this macro is used, the only way to access the variable argument list is +by using VA_START() again. + +@param Marker VA_LIST used to traverse the list of arguments. + +**/ +#define VA_END(Marker) (Marker = (VA_LIST) 0) + +/** +Initializes a VA_LIST as a copy of an existing VA_LIST. + +This macro initializes Dest as a copy of Start, as if the VA_START macro had been applied to Dest +followed by the same sequence of uses of the VA_ARG macro as had previously been used to reach +the present state of Start. + +@param Dest VA_LIST used to traverse the list of arguments. +@param Start VA_LIST used to traverse the list of arguments. + +**/ +#define VA_COPY(Dest, Start) ((void)((Dest) = (Start))) + +#endif + +/// +/// Pointer to the start of a variable argument list stored in a memory buffer. Same as UINT8 *. +/// +typedef UINTN *BASE_LIST; + +/** +Returns the size of a data type in sizeof(UINTN) units rounded up to the nearest UINTN boundary. + +@param TYPE The date type to determine the size of. + +@return The size of TYPE in sizeof (UINTN) units rounded up to the nearest UINTN boundary. +**/ +#define _BASE_INT_SIZE_OF(TYPE) ((sizeof (TYPE) + sizeof (UINTN) - 1) / sizeof (UINTN)) + +/** +Returns an argument of a specified type from a variable argument list and updates +the pointer to the variable argument list to point to the next argument. + +This function returns an argument of the type specified by TYPE from the beginning +of the variable argument list specified by Marker. Marker is then updated to point +to the next argument in the variable argument list. The method for computing the +pointer to the next argument in the argument list is CPU specific following the EFIAPI ABI. + +@param Marker The pointer to the beginning of a variable argument list. +@param TYPE The type of argument to retrieve from the beginning +of the variable argument list. + +@return An argument of the type specified by TYPE. + +**/ +#define BASE_ARG(Marker, TYPE) (*(TYPE *) ((Marker += _BASE_INT_SIZE_OF (TYPE)) - _BASE_INT_SIZE_OF (TYPE))) + +/** +The macro that returns the byte offset of a field in a data structure. + +This function returns the offset, in bytes, of field specified by Field from the +beginning of the data structure specified by TYPE. If TYPE does not contain Field, +the module will not compile. + +@param TYPE The name of the data structure that contains the field specified by Field. +@param Field The name of the field in the data structure. + +@return Offset, in bytes, of field. + +**/ +#ifdef __GNUC__ +#if __GNUC__ >= 4 +#define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field)) +#endif +#endif + +#ifndef OFFSET_OF +#define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field)) +#endif + +/** +Macro that returns a pointer to the data structure that contains a specified field of +that data structure. This is a lightweight method to hide information by placing a +public data structure inside a larger private data structure and using a pointer to +the public data structure to retrieve a pointer to the private data structure. + +This function computes the offset, in bytes, of field specified by Field from the beginning +of the data structure specified by TYPE. This offset is subtracted from Record, and is +used to return a pointer to a data structure of the type specified by TYPE. If the data type +specified by TYPE does not contain the field specified by Field, then the module will not compile. + +@param Record Pointer to the field specified by Field within a data structure of type TYPE. +@param TYPE The name of the data structure type to return. This data structure must +contain the field specified by Field. +@param Field The name of the field in the data structure specified by TYPE to which Record points. + +@return A pointer to the structure from one of it's elements. + +**/ +#define BASE_CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field))) + +/** +Rounds a value up to the next boundary using a specified alignment. + +This function rounds Value up to the next boundary using the specified Alignment. +This aligned value is returned. + +@param Value The value to round up. +@param Alignment The alignment boundary used to return the aligned value. + +@return A value up to the next boundary. + +**/ +#define ALIGN_VALUE(Value, Alignment) ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1))) + +/** +Adjust a pointer by adding the minimum offset required for it to be aligned on +a specified alignment boundary. + +This function rounds the pointer specified by Pointer to the next alignment boundary +specified by Alignment. The pointer to the aligned address is returned. + +@param Pointer The pointer to round up. +@param Alignment The alignment boundary to use to return an aligned pointer. + +@return Pointer to the aligned address. + +**/ +#define ALIGN_POINTER(Pointer, Alignment) ((VOID *) (ALIGN_VALUE ((UINTN)(Pointer), (Alignment)))) + +/** +Rounds a value up to the next natural boundary for the current CPU. +This is 4-bytes for 32-bit CPUs and 8-bytes for 64-bit CPUs. + +This function rounds the value specified by Value up to the next natural boundary for the +current CPU. This rounded value is returned. + +@param Value The value to round up. + +@return Rounded value specified by Value. + +**/ +#define ALIGN_VARIABLE(Value) ALIGN_VALUE ((Value), sizeof (UINTN)) + + +/** +Return the maximum of two operands. + +This macro returns the maximum of two operand specified by a and b. +Both a and b must be the same numerical types, signed or unsigned. + +@param a The first operand with any numerical type. +@param b The second operand. Can be any numerical type as long as is +the same type as a. + +@return Maximum of two operands. + +**/ +#define MAX(a, b) \ + (((a) > (b)) ? (a) : (b)) + +/** +Return the minimum of two operands. + +This macro returns the minimal of two operand specified by a and b. +Both a and b must be the same numerical types, signed or unsigned. + +@param a The first operand with any numerical type. +@param b The second operand. It should be the same any numerical type with a. + +@return Minimum of two operands. + +**/ +#define MIN(a, b) \ + (((a) < (b)) ? (a) : (b)) + +/** +Return the absolute value of a signed operand. + +This macro returns the absolute value of the signed operand specified by a. + +@param a The signed operand. + +@return The absolute value of the signed operand. + +**/ +#define ABS(a) \ + (((a) < 0) ? (-(a)) : (a)) + +// +// Status codes common to all execution phases +// +typedef UINTN RETURN_STATUS; + +/** +Produces a RETURN_STATUS code with the highest bit set. + +@param StatusCode The status code value to convert into a warning code. +StatusCode must be in the range 0x00000000..0x7FFFFFFF. + +@return The value specified by StatusCode with the highest bit set. + +**/ +#define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusCode))) + +/** +Produces a RETURN_STATUS code with the highest bit clear. + +@param StatusCode The status code value to convert into a warning code. +StatusCode must be in the range 0x00000000..0x7FFFFFFF. + +@return The value specified by StatusCode with the highest bit clear. + +**/ +#define ENCODE_WARNING(StatusCode) ((RETURN_STATUS)(StatusCode)) + +/** +Returns TRUE if a specified RETURN_STATUS code is an error code. + +This function returns TRUE if StatusCode has the high bit set. Otherwise, FALSE is returned. + +@param StatusCode The status code value to evaluate. + +@retval TRUE The high bit of StatusCode is set. +@retval FALSE The high bit of StatusCode is clear. + +**/ +#define RETURN_ERROR(StatusCode) (((INTN)(RETURN_STATUS)(StatusCode)) < 0) + +/// +/// The operation completed successfully. +/// +#define RETURN_SUCCESS 0 + +/// +/// The image failed to load. +/// +#define RETURN_LOAD_ERROR ENCODE_ERROR (1) + +/// +/// The parameter was incorrect. +/// +#define RETURN_INVALID_PARAMETER ENCODE_ERROR (2) + +/// +/// The operation is not supported. +/// +#define RETURN_UNSUPPORTED ENCODE_ERROR (3) + +/// +/// The buffer was not the proper size for the request. +/// +#define RETURN_BAD_BUFFER_SIZE ENCODE_ERROR (4) + +/// +/// The buffer was not large enough to hold the requested data. +/// The required buffer size is returned in the appropriate +/// parameter when this error occurs. +/// +#define RETURN_BUFFER_TOO_SMALL ENCODE_ERROR (5) + +/// +/// There is no data pending upon return. +/// +#define RETURN_NOT_READY ENCODE_ERROR (6) + +/// +/// The physical device reported an error while attempting the +/// operation. +/// +#define RETURN_DEVICE_ERROR ENCODE_ERROR (7) + +/// +/// The device can not be written to. +/// +#define RETURN_WRITE_PROTECTED ENCODE_ERROR (8) + +/// +/// The resource has run out. +/// +#define RETURN_OUT_OF_RESOURCES ENCODE_ERROR (9) + +/// +/// An inconsistency was detected on the file system causing the +/// operation to fail. +/// +#define RETURN_VOLUME_CORRUPTED ENCODE_ERROR (10) + +/// +/// There is no more space on the file system. +/// +#define RETURN_VOLUME_FULL ENCODE_ERROR (11) + +/// +/// The device does not contain any medium to perform the +/// operation. +/// +#define RETURN_NO_MEDIA ENCODE_ERROR (12) + +/// +/// The medium in the device has changed since the last +/// access. +/// +#define RETURN_MEDIA_CHANGED ENCODE_ERROR (13) + +/// +/// The item was not found. +/// +#define RETURN_NOT_FOUND ENCODE_ERROR (14) + +/// +/// Access was denied. +/// +#define RETURN_ACCESS_DENIED ENCODE_ERROR (15) + +/// +/// The server was not found or did not respond to the request. +/// +#define RETURN_NO_RESPONSE ENCODE_ERROR (16) + +/// +/// A mapping to the device does not exist. +/// +#define RETURN_NO_MAPPING ENCODE_ERROR (17) + +/// +/// A timeout time expired. +/// +#define RETURN_TIMEOUT ENCODE_ERROR (18) + +/// +/// The protocol has not been started. +/// +#define RETURN_NOT_STARTED ENCODE_ERROR (19) + +/// +/// The protocol has already been started. +/// +#define RETURN_ALREADY_STARTED ENCODE_ERROR (20) + +/// +/// The operation was aborted. +/// +#define RETURN_ABORTED ENCODE_ERROR (21) + +/// +/// An ICMP error occurred during the network operation. +/// +#define RETURN_ICMP_ERROR ENCODE_ERROR (22) + +/// +/// A TFTP error occurred during the network operation. +/// +#define RETURN_TFTP_ERROR ENCODE_ERROR (23) + +/// +/// A protocol error occurred during the network operation. +/// +#define RETURN_PROTOCOL_ERROR ENCODE_ERROR (24) + +/// +/// A function encountered an internal version that was +/// incompatible with a version requested by the caller. +/// +#define RETURN_INCOMPATIBLE_VERSION ENCODE_ERROR (25) + +/// +/// The function was not performed due to a security violation. +/// +#define RETURN_SECURITY_VIOLATION ENCODE_ERROR (26) + +/// +/// A CRC error was detected. +/// +#define RETURN_CRC_ERROR ENCODE_ERROR (27) + +/// +/// The beginning or end of media was reached. +/// +#define RETURN_END_OF_MEDIA ENCODE_ERROR (28) + +/// +/// The end of the file was reached. +/// +#define RETURN_END_OF_FILE ENCODE_ERROR (31) + +/// +/// The language specified was invalid. +/// +#define RETURN_INVALID_LANGUAGE ENCODE_ERROR (32) + +/// +/// The security status of the data is unknown or compromised +/// and the data must be updated or replaced to restore a valid +/// security status. +/// +#define RETURN_COMPROMISED_DATA ENCODE_ERROR (33) + +/// +/// The string contained one or more characters that +/// the device could not render and were skipped. +/// +#define RETURN_WARN_UNKNOWN_GLYPH ENCODE_WARNING (1) + +/// +/// The handle was closed, but the file was not deleted. +/// +#define RETURN_WARN_DELETE_FAILURE ENCODE_WARNING (2) + +/// +/// The handle was closed, but the data to the file was not +/// flushed properly. +/// +#define RETURN_WARN_WRITE_FAILURE ENCODE_WARNING (3) + +/// +/// The resulting buffer was too small, and the data was +/// truncated to the buffer size. +/// +#define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4) + +/// +/// The data has not been updated within the timeframe set by +/// local policy for this type of data. +/// +#define RETURN_WARN_STALE_DATA ENCODE_WARNING (5) + +/** +Returns a 16-bit signature built from 2 ASCII characters. + +This macro returns a 16-bit value built from the two ASCII characters specified +by A and B. + +@param A The first ASCII character. +@param B The second ASCII character. + +@return A 16-bit value built from the two ASCII characters specified by A and B. + +**/ +#define SIGNATURE_16(A, B) ((A) | (B << 8)) + +/** +Returns a 32-bit signature built from 4 ASCII characters. + +This macro returns a 32-bit value built from the four ASCII characters specified +by A, B, C, and D. + +@param A The first ASCII character. +@param B The second ASCII character. +@param C The third ASCII character. +@param D The fourth ASCII character. + +@return A 32-bit value built from the two ASCII characters specified by A, B, +C and D. + +**/ +#define SIGNATURE_32(A, B, C, D) (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16)) + +/** +Returns a 64-bit signature built from 8 ASCII characters. + +This macro returns a 64-bit value built from the eight ASCII characters specified +by A, B, C, D, E, F, G,and H. + +@param A The first ASCII character. +@param B The second ASCII character. +@param C The third ASCII character. +@param D The fourth ASCII character. +@param E The fifth ASCII character. +@param F The sixth ASCII character. +@param G The seventh ASCII character. +@param H The eighth ASCII character. + +@return A 64-bit value built from the two ASCII characters specified by A, B, +C, D, E, F, G and H. + +**/ +#define SIGNATURE_64(A, B, C, D, E, F, G, H) \ + (SIGNATURE_32(A, B, C, D) | ((UINT64) (SIGNATURE_32(E, F, G, H)) << 32)) + +#endif + diff --git a/reactos/boot/environ/include/efi/DevicePath.h b/reactos/boot/environ/include/efi/DevicePath.h new file mode 100644 index 00000000000..dd77f42e07f --- /dev/null +++ b/reactos/boot/environ/include/efi/DevicePath.h @@ -0,0 +1,1217 @@ +/** @file +The device path protocol as defined in UEFI 2.0. + +The device path represents a programmatic path to a device, +from a software point of view. The path must persist from boot to boot, so +it can not contain things like PCI bus numbers that change from boot to boot. + +Copyright (c) 2006 - 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 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 __EFI_DEVICE_PATH_PROTOCOL_H__ +#define __EFI_DEVICE_PATH_PROTOCOL_H__ + +//#include + +/// +/// Device Path protocol. +/// +#define EFI_DEVICE_PATH_PROTOCOL_GUID \ + { \ + 0x9576e91, 0x6d3f, 0x11d2, { 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ + } + +/// +/// Device Path guid definition for backward-compatible with EFI1.1. +/// +#define DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH_PROTOCOL_GUID + +#pragma pack(1) + +/** +This protocol can be used on any device handle to obtain generic path/location +information concerning the physical device or logical device. If the handle does +not logically map to a physical device, the handle may not necessarily support +the device path protocol. The device path describes the location of the device +the handle is for. The size of the Device Path can be determined from the structures +that make up the Device Path. +**/ +typedef struct { + UINT8 Type; ///< 0x01 Hardware Device Path. + ///< 0x02 ACPI Device Path. + ///< 0x03 Messaging Device Path. + ///< 0x04 Media Device Path. + ///< 0x05 BIOS Boot Specification Device Path. + ///< 0x7F End of Hardware Device Path. + + UINT8 SubType; ///< Varies by Type + ///< 0xFF End Entire Device Path, or + ///< 0x01 End This Instance of a Device Path and start a new + ///< Device Path. + + UINT8 Length[2]; ///< Specific Device Path data. Type and Sub-Type define + ///< type of data. Size of data is included in Length. + +} EFI_DEVICE_PATH_PROTOCOL; + +/// +/// Device Path protocol definition for backward-compatible with EFI1.1. +/// +typedef EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH; + +/// +/// Hardware Device Paths. +/// +#define HARDWARE_DEVICE_PATH 0x01 + +/// +/// PCI Device Path SubType. +/// +#define HW_PCI_DP 0x01 + +/// +/// PCI Device Path. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// PCI Function Number. + /// + UINT8 Function; + /// + /// PCI Device Number. + /// + UINT8 Device; +} PCI_DEVICE_PATH; + +/// +/// PCCARD Device Path SubType. +/// +#define HW_PCCARD_DP 0x02 + +/// +/// PCCARD Device Path. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Function Number (0 = First Function). + /// + UINT8 FunctionNumber; +} PCCARD_DEVICE_PATH; + +/// +/// Memory Mapped Device Path SubType. +/// +#define HW_MEMMAP_DP 0x03 + +/// +/// Memory Mapped Device Path. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// EFI_MEMORY_TYPE + /// + UINT32 MemoryType; + /// + /// Starting Memory Address. + /// + EFI_PHYSICAL_ADDRESS StartingAddress; + /// + /// Ending Memory Address. + /// + EFI_PHYSICAL_ADDRESS EndingAddress; +} MEMMAP_DEVICE_PATH; + +/// +/// Hardware Vendor Device Path SubType. +/// +#define HW_VENDOR_DP 0x04 + +/// +/// The Vendor Device Path allows the creation of vendor-defined Device Paths. A vendor must +/// allocate a Vendor GUID for a Device Path. The Vendor GUID can then be used to define the +/// contents on the n bytes that follow in the Vendor Device Path node. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Vendor-assigned GUID that defines the data that follows. + /// + EFI_GUID Guid; + /// + /// Vendor-defined variable size data. + /// +} VENDOR_DEVICE_PATH; + +/// +/// Controller Device Path SubType. +/// +#define HW_CONTROLLER_DP 0x05 + +/// +/// Controller Device Path. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Controller number. + /// + UINT32 ControllerNumber; +} CONTROLLER_DEVICE_PATH; + +/// +/// ACPI Device Paths. +/// +#define ACPI_DEVICE_PATH 0x02 + +/// +/// ACPI Device Path SubType. +/// +#define ACPI_DP 0x01 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Device's PnP hardware ID stored in a numeric 32-bit + /// compressed EISA-type ID. This value must match the + /// corresponding _HID in the ACPI name space. + /// + UINT32 HID; + /// + /// Unique ID that is required by ACPI if two devices have the + /// same _HID. This value must also match the corresponding + /// _UID/_HID pair in the ACPI name space. Only the 32-bit + /// numeric value type of _UID is supported. Thus, strings must + /// not be used for the _UID in the ACPI name space. + /// + UINT32 UID; +} ACPI_HID_DEVICE_PATH; + +/// +/// Expanded ACPI Device Path SubType. +/// +#define ACPI_EXTENDED_DP 0x02 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Device's PnP hardware ID stored in a numeric 32-bit + /// compressed EISA-type ID. This value must match the + /// corresponding _HID in the ACPI name space. + /// + UINT32 HID; + /// + /// Unique ID that is required by ACPI if two devices have the + /// same _HID. This value must also match the corresponding + /// _UID/_HID pair in the ACPI name space. + /// + UINT32 UID; + /// + /// Device's compatible PnP hardware ID stored in a numeric + /// 32-bit compressed EISA-type ID. This value must match at + /// least one of the compatible device IDs returned by the + /// corresponding _CID in the ACPI name space. + /// + UINT32 CID; + /// + /// Optional variable length _HIDSTR. + /// Optional variable length _UIDSTR. + /// Optional variable length _CIDSTR. + /// +} ACPI_EXTENDED_HID_DEVICE_PATH; + +// +// EISA ID Macro +// EISA ID Definition 32-bits +// bits[15:0] - three character compressed ASCII EISA ID. +// bits[31:16] - binary number +// Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z' +// +#define PNP_EISA_ID_CONST 0x41d0 +#define EISA_ID(_Name, _Num) ((UINT32)((_Name) | (_Num) << 16)) +#define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId))) +#define EFI_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId))) + +#define PNP_EISA_ID_MASK 0xffff +#define EISA_ID_TO_NUM(_Id) ((_Id) >> 16) + +/// +/// ACPI _ADR Device Path SubType. +/// +#define ACPI_ADR_DP 0x03 + +/// +/// The _ADR device path is used to contain video output device attributes to support the Graphics +/// Output Protocol. The device path can contain multiple _ADR entries if multiple video output +/// devices are displaying the same output. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// _ADR value. For video output devices the value of this + /// field comes from Table B-2 of the ACPI 3.0 specification. At + /// least one _ADR value is required. + /// + UINT32 ADR; + // + // This device path may optionally contain more than one _ADR entry. + // +} ACPI_ADR_DEVICE_PATH; + +#define ACPI_ADR_DISPLAY_TYPE_OTHER 0 +#define ACPI_ADR_DISPLAY_TYPE_VGA 1 +#define ACPI_ADR_DISPLAY_TYPE_TV 2 +#define ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL 3 +#define ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL 4 + +#define ACPI_DISPLAY_ADR(_DeviceIdScheme, _HeadId, _NonVgaOutput, _BiosCanDetect, _VendorInfo, _Type, _Port, _Index) \ + ((UINT32) ((((_DeviceIdScheme) & 0x1) << 31) | \ + (((_HeadId) & 0x7) << 18) | \ + (((_NonVgaOutput) & 0x1) << 17) | \ + (((_BiosCanDetect) & 0x1) << 16) | \ + (((_VendorInfo) & 0xf) << 12) | \ + (((_Type) & 0xf) << 8) | \ + (((_Port) & 0xf) << 4) | \ + ((_Index) & 0xf))) + +/// +/// Messaging Device Paths. +/// This Device Path is used to describe the connection of devices outside the resource domain of the +/// system. This Device Path can describe physical messaging information like SCSI ID, or abstract +/// information like networking protocol IP addresses. +/// +#define MESSAGING_DEVICE_PATH 0x03 + +/// +/// ATAPI Device Path SubType +/// +#define MSG_ATAPI_DP 0x01 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Set to zero for primary, or one for secondary. + /// + UINT8 PrimarySecondary; + /// + /// Set to zero for master, or one for slave mode. + /// + UINT8 SlaveMaster; + /// + /// Logical Unit Number. + /// + UINT16 Lun; +} ATAPI_DEVICE_PATH; + +/// +/// SCSI Device Path SubType. +/// +#define MSG_SCSI_DP 0x02 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Target ID on the SCSI bus (PUN). + /// + UINT16 Pun; + /// + /// Logical Unit Number (LUN). + /// + UINT16 Lun; +} SCSI_DEVICE_PATH; + +/// +/// Fibre Channel SubType. +/// +#define MSG_FIBRECHANNEL_DP 0x03 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Reserved for the future. + /// + UINT32 Reserved; + /// + /// Fibre Channel World Wide Number. + /// + UINT64 WWN; + /// + /// Fibre Channel Logical Unit Number. + /// + UINT64 Lun; +} FIBRECHANNEL_DEVICE_PATH; + +/// +/// Fibre Channel Ex SubType. +/// +#define MSG_FIBRECHANNELEX_DP 0x15 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Reserved for the future. + /// + UINT32 Reserved; + /// + /// 8 byte array containing Fibre Channel End Device Port Name. + /// + UINT8 WWN[8]; + /// + /// 8 byte array containing Fibre Channel Logical Unit Number. + /// + UINT8 Lun[8]; +} FIBRECHANNELEX_DEVICE_PATH; + +/// +/// 1394 Device Path SubType +/// +#define MSG_1394_DP 0x04 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Reserved for the future. + /// + UINT32 Reserved; + /// + /// 1394 Global Unique ID (GUID). + /// + UINT64 Guid; +} F1394_DEVICE_PATH; + +/// +/// USB Device Path SubType. +/// +#define MSG_USB_DP 0x05 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// USB Parent Port Number. + /// + UINT8 ParentPortNumber; + /// + /// USB Interface Number. + /// + UINT8 InterfaceNumber; +} USB_DEVICE_PATH; + +/// +/// USB Class Device Path SubType. +/// +#define MSG_USB_CLASS_DP 0x0f +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Vendor ID assigned by USB-IF. A value of 0xFFFF will + /// match any Vendor ID. + /// + UINT16 VendorId; + /// + /// Product ID assigned by USB-IF. A value of 0xFFFF will + /// match any Product ID. + /// + UINT16 ProductId; + /// + /// The class code assigned by the USB-IF. A value of 0xFF + /// will match any class code. + /// + UINT8 DeviceClass; + /// + /// The subclass code assigned by the USB-IF. A value of + /// 0xFF will match any subclass code. + /// + UINT8 DeviceSubClass; + /// + /// The protocol code assigned by the USB-IF. A value of + /// 0xFF will match any protocol code. + /// + UINT8 DeviceProtocol; +} USB_CLASS_DEVICE_PATH; + +/// +/// USB WWID Device Path SubType. +/// +#define MSG_USB_WWID_DP 0x10 + +/// +/// This device path describes a USB device using its serial number. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// USB interface number. + /// + UINT16 InterfaceNumber; + /// + /// USB vendor id of the device. + /// + UINT16 VendorId; + /// + /// USB product id of the device. + /// + UINT16 ProductId; + /// + /// Last 64-or-fewer UTF-16 characters of the USB + /// serial number. The length of the string is + /// determined by the Length field less the offset of the + /// Serial Number field (10) + /// + /// CHAR16 SerialNumber[...]; +} USB_WWID_DEVICE_PATH; + +/// +/// Device Logical Unit SubType. +/// +#define MSG_DEVICE_LOGICAL_UNIT_DP 0x11 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Logical Unit Number for the interface. + /// + UINT8 Lun; +} DEVICE_LOGICAL_UNIT_DEVICE_PATH; + +/// +/// SATA Device Path SubType. +/// +#define MSG_SATA_DP 0x12 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// The HBA port number that facilitates the connection to the + /// device or a port multiplier. The value 0xFFFF is reserved. + /// + UINT16 HBAPortNumber; + /// + /// The Port multiplier port number that facilitates the connection + /// to the device. Bit 15 should be set if the device is directly + /// connected to the HBA. + /// + UINT16 PortMultiplierPortNumber; + /// + /// Logical Unit Number. + /// + UINT16 Lun; +} SATA_DEVICE_PATH; + +/// +/// Flag for if the device is directly connected to the HBA. +/// +#define SATA_HBA_DIRECT_CONNECT_FLAG 0x8000 + +/// +/// I2O Device Path SubType. +/// +#define MSG_I2O_DP 0x06 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Target ID (TID) for a device. + /// + UINT32 Tid; +} I2O_DEVICE_PATH; + +/// +/// MAC Address Device Path SubType. +/// +#define MSG_MAC_ADDR_DP 0x0b +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// The MAC address for a network interface padded with 0s. + /// + EFI_MAC_ADDRESS MacAddress; + /// + /// Network interface type(i.e. 802.3, FDDI). + /// + UINT8 IfType; +} MAC_ADDR_DEVICE_PATH; + +/// +/// IPv4 Device Path SubType +/// +#define MSG_IPv4_DP 0x0c +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// The local IPv4 address. + /// + EFI_IPv4_ADDRESS LocalIpAddress; + /// + /// The remote IPv4 address. + /// + EFI_IPv4_ADDRESS RemoteIpAddress; + /// + /// The local port number. + /// + UINT16 LocalPort; + /// + /// The remote port number. + /// + UINT16 RemotePort; + /// + /// The network protocol(i.e. UDP, TCP). + /// + UINT16 Protocol; + /// + /// 0x00 - The Source IP Address was assigned though DHCP. + /// 0x01 - The Source IP Address is statically bound. + /// + BOOLEAN StaticIpAddress; + /// + /// The gateway IP address + /// + EFI_IPv4_ADDRESS GatewayIpAddress; + /// + /// The subnet mask + /// + EFI_IPv4_ADDRESS SubnetMask; +} IPv4_DEVICE_PATH; + +/// +/// IPv6 Device Path SubType. +/// +#define MSG_IPv6_DP 0x0d +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// The local IPv6 address. + /// + EFI_IPv6_ADDRESS LocalIpAddress; + /// + /// The remote IPv6 address. + /// + EFI_IPv6_ADDRESS RemoteIpAddress; + /// + /// The local port number. + /// + UINT16 LocalPort; + /// + /// The remote port number. + /// + UINT16 RemotePort; + /// + /// The network protocol(i.e. UDP, TCP). + /// + UINT16 Protocol; + /// + /// 0x00 - The Local IP Address was manually configured. + /// 0x01 - The Local IP Address is assigned through IPv6 + /// stateless auto-configuration. + /// 0x02 - The Local IP Address is assigned through IPv6 + /// stateful configuration. + /// + UINT8 IpAddressOrigin; + /// + /// The prefix length + /// + UINT8 PrefixLength; + /// + /// The gateway IP address + /// + EFI_IPv6_ADDRESS GatewayIpAddress; +} IPv6_DEVICE_PATH; + +/// +/// InfiniBand Device Path SubType. +/// +#define MSG_INFINIBAND_DP 0x09 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Flags to help identify/manage InfiniBand device path elements: + /// Bit 0 - IOC/Service (0b = IOC, 1b = Service). + /// Bit 1 - Extend Boot Environment. + /// Bit 2 - Console Protocol. + /// Bit 3 - Storage Protocol. + /// Bit 4 - Network Protocol. + /// All other bits are reserved. + /// + UINT32 ResourceFlags; + /// + /// 128-bit Global Identifier for remote fabric port. + /// + UINT8 PortGid[16]; + /// + /// 64-bit unique identifier to remote IOC or server process. + /// Interpretation of field specified by Resource Flags (bit 0). + /// + UINT64 ServiceId; + /// + /// 64-bit persistent ID of remote IOC port. + /// + UINT64 TargetPortId; + /// + /// 64-bit persistent ID of remote device. + /// + UINT64 DeviceId; +} INFINIBAND_DEVICE_PATH; + +#define INFINIBAND_RESOURCE_FLAG_IOC_SERVICE 0x01 +#define INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT 0x02 +#define INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL 0x04 +#define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL 0x08 +#define INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL 0x10 + +/// +/// UART Device Path SubType. +/// +#define MSG_UART_DP 0x0e +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Reserved. + /// + UINT32 Reserved; + /// + /// The baud rate setting for the UART style device. A value of 0 + /// means that the device's default baud rate will be used. + /// + UINT64 BaudRate; + /// + /// The number of data bits for the UART style device. A value + /// of 0 means that the device's default number of data bits will be used. + /// + UINT8 DataBits; + /// + /// The parity setting for the UART style device. + /// Parity 0x00 - Default Parity. + /// Parity 0x01 - No Parity. + /// Parity 0x02 - Even Parity. + /// Parity 0x03 - Odd Parity. + /// Parity 0x04 - Mark Parity. + /// Parity 0x05 - Space Parity. + /// + UINT8 Parity; + /// + /// The number of stop bits for the UART style device. + /// Stop Bits 0x00 - Default Stop Bits. + /// Stop Bits 0x01 - 1 Stop Bit. + /// Stop Bits 0x02 - 1.5 Stop Bits. + /// Stop Bits 0x03 - 2 Stop Bits. + /// + UINT8 StopBits; +} UART_DEVICE_PATH; + +// +// Use VENDOR_DEVICE_PATH struct +// +#define MSG_VENDOR_DP 0x0a +typedef VENDOR_DEVICE_PATH VENDOR_DEFINED_DEVICE_PATH; + +#define DEVICE_PATH_MESSAGING_PC_ANSI EFI_PC_ANSI_GUID +#define DEVICE_PATH_MESSAGING_VT_100 EFI_VT_100_GUID +#define DEVICE_PATH_MESSAGING_VT_100_PLUS EFI_VT_100_PLUS_GUID +#define DEVICE_PATH_MESSAGING_VT_UTF8 EFI_VT_UTF8_GUID + +/// +/// A new device path node is defined to declare flow control characteristics. +/// UART Flow Control Messaging Device Path +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL GUID. + /// + EFI_GUID Guid; + /// + /// Bitmap of supported flow control types. + /// Bit 0 set indicates hardware flow control. + /// Bit 1 set indicates Xon/Xoff flow control. + /// All other bits are reserved and are clear. + /// + UINT32 FlowControlMap; +} UART_FLOW_CONTROL_DEVICE_PATH; + +#define UART_FLOW_CONTROL_HARDWARE 0x00000001 +#define UART_FLOW_CONTROL_XON_XOFF 0x00000010 + +#define DEVICE_PATH_MESSAGING_SAS EFI_SAS_DEVICE_PATH_GUID +/// +/// Serial Attached SCSI (SAS) Device Path. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// DEVICE_PATH_MESSAGING_SAS GUID. + /// + EFI_GUID Guid; + /// + /// Reserved for future use. + /// + UINT32 Reserved; + /// + /// SAS Address for Serial Attached SCSI Target. + /// + UINT64 SasAddress; + /// + /// SAS Logical Unit Number. + /// + UINT64 Lun; + /// + /// More Information about the device and its interconnect. + /// + UINT16 DeviceTopology; + /// + /// Relative Target Port (RTP). + /// + UINT16 RelativeTargetPort; +} SAS_DEVICE_PATH; + +/// +/// Serial Attached SCSI (SAS) Ex Device Path SubType +/// +#define MSG_SASEX_DP 0x16 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// 8-byte array of the SAS Address for Serial Attached SCSI Target Port. + /// + UINT8 SasAddress[8]; + /// + /// 8-byte array of the SAS Logical Unit Number. + /// + UINT8 Lun[8]; + /// + /// More Information about the device and its interconnect. + /// + UINT16 DeviceTopology; + /// + /// Relative Target Port (RTP). + /// + UINT16 RelativeTargetPort; +} SASEX_DEVICE_PATH; + +/// +/// iSCSI Device Path SubType +/// +#define MSG_ISCSI_DP 0x13 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Network Protocol (0 = TCP, 1+ = reserved). + /// + UINT16 NetworkProtocol; + /// + /// iSCSI Login Options. + /// + UINT16 LoginOption; + /// + /// iSCSI Logical Unit Number. + /// + UINT64 Lun; + /// + /// iSCSI Target Portal group tag the initiator intends + /// to establish a session with. + /// + UINT16 TargetPortalGroupTag; + /// + /// iSCSI NodeTarget Name. The length of the name + /// is determined by subtracting the offset of this field from Length. + /// + /// CHAR8 iSCSI Target Name. +} ISCSI_DEVICE_PATH; + +#define ISCSI_LOGIN_OPTION_NO_HEADER_DIGEST 0x0000 +#define ISCSI_LOGIN_OPTION_HEADER_DIGEST_USING_CRC32C 0x0002 +#define ISCSI_LOGIN_OPTION_NO_DATA_DIGEST 0x0000 +#define ISCSI_LOGIN_OPTION_DATA_DIGEST_USING_CRC32C 0x0008 +#define ISCSI_LOGIN_OPTION_AUTHMETHOD_CHAP 0x0000 +#define ISCSI_LOGIN_OPTION_AUTHMETHOD_NON 0x1000 +#define ISCSI_LOGIN_OPTION_CHAP_BI 0x0000 +#define ISCSI_LOGIN_OPTION_CHAP_UNI 0x2000 + +/// +/// VLAN Device Path SubType. +/// +#define MSG_VLAN_DP 0x14 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// VLAN identifier (0-4094). + /// + UINT16 VlanId; +} VLAN_DEVICE_PATH; + +// +// Media Device Path +// +#define MEDIA_DEVICE_PATH 0x04 + +/// +/// Hard Drive Media Device Path SubType. +/// +#define MEDIA_HARDDRIVE_DP 0x01 + +/// +/// The Hard Drive Media Device Path is used to represent a partition on a hard drive. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Describes the entry in a partition table, starting with entry 1. + /// Partition number zero represents the entire device. Valid + /// partition numbers for a MBR partition are [1, 4]. Valid + /// partition numbers for a GPT partition are [1, NumberOfPartitionEntries]. + /// + UINT32 PartitionNumber; + /// + /// Starting LBA of the partition on the hard drive. + /// + UINT64 PartitionStart; + /// + /// Size of the partition in units of Logical Blocks. + /// + UINT64 PartitionSize; + /// + /// Signature unique to this partition: + /// If SignatureType is 0, this field has to be initialized with 16 zeros. + /// If SignatureType is 1, the MBR signature is stored in the first 4 bytes of this field. + /// The other 12 bytes are initialized with zeros. + /// If SignatureType is 2, this field contains a 16 byte signature. + /// + UINT8 Signature[16]; + /// + /// Partition Format: (Unused values reserved). + /// 0x01 - PC-AT compatible legacy MBR. + /// 0x02 - GUID Partition Table. + /// + UINT8 MBRType; + /// + /// Type of Disk Signature: (Unused values reserved). + /// 0x00 - No Disk Signature. + /// 0x01 - 32-bit signature from address 0x1b8 of the type 0x01 MBR. + /// 0x02 - GUID signature. + /// + UINT8 SignatureType; +} HARDDRIVE_DEVICE_PATH; + +#define MBR_TYPE_PCAT 0x01 +#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02 + +#define NO_DISK_SIGNATURE 0x00 +#define SIGNATURE_TYPE_MBR 0x01 +#define SIGNATURE_TYPE_GUID 0x02 + +/// +/// CD-ROM Media Device Path SubType. +/// +#define MEDIA_CDROM_DP 0x02 + +/// +/// The CD-ROM Media Device Path is used to define a system partition that exists on a CD-ROM. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Boot Entry number from the Boot Catalog. The Initial/Default entry is defined as zero. + /// + UINT32 BootEntry; + /// + /// Starting RBA of the partition on the medium. CD-ROMs use Relative logical Block Addressing. + /// + UINT64 PartitionStart; + /// + /// Size of the partition in units of Blocks, also called Sectors. + /// + UINT64 PartitionSize; +} CDROM_DEVICE_PATH; + +// +// Use VENDOR_DEVICE_PATH struct +// +#define MEDIA_VENDOR_DP 0x03 ///< Media vendor device path subtype. + +/// +/// File Path Media Device Path SubType +/// +#define MEDIA_FILEPATH_DP 0x04 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// A NULL-terminated Path string including directory and file names. + /// + CHAR16 PathName[1]; +} FILEPATH_DEVICE_PATH; + +#define SIZE_OF_FILEPATH_DEVICE_PATH OFFSET_OF(FILEPATH_DEVICE_PATH,PathName) + +/// +/// Media Protocol Device Path SubType. +/// +#define MEDIA_PROTOCOL_DP 0x05 + +/// +/// The Media Protocol Device Path is used to denote the protocol that is being +/// used in a device path at the location of the path specified. +/// Many protocols are inherent to the style of device path. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// The ID of the protocol. + /// + EFI_GUID Protocol; +} MEDIA_PROTOCOL_DEVICE_PATH; + +/// +/// PIWG Firmware File SubType. +/// +#define MEDIA_PIWG_FW_FILE_DP 0x06 + +/// +/// This device path is used by systems implementing the UEFI PI Specification 1.0 to describe a firmware file. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Firmware file name + /// + EFI_GUID FvFileName; +} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH; + +/// +/// PIWG Firmware Volume Device Path SubType. +/// +#define MEDIA_PIWG_FW_VOL_DP 0x07 + +/// +/// This device path is used by systems implementing the UEFI PI Specification 1.0 to describe a firmware volume. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Firmware volume name. + /// + EFI_GUID FvName; +} MEDIA_FW_VOL_DEVICE_PATH; + +/// +/// Media relative offset range device path. +/// +#define MEDIA_RELATIVE_OFFSET_RANGE_DP 0x08 + +/// +/// Used to describe the offset range of media relative. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Reserved; + UINT64 StartingOffset; + UINT64 EndingOffset; +} MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH; + +/// +/// BIOS Boot Specification Device Path. +/// +#define BBS_DEVICE_PATH 0x05 + +/// +/// BIOS Boot Specification Device Path SubType. +/// +#define BBS_BBS_DP 0x01 + +/// +/// This Device Path is used to describe the booting of non-EFI-aware operating systems. +/// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Device Type as defined by the BIOS Boot Specification. + /// + UINT16 DeviceType; + /// + /// Status Flags as defined by the BIOS Boot Specification. + /// + UINT16 StatusFlag; + /// + /// Null-terminated ASCII string that describes the boot device to a user. + /// + CHAR8 String[1]; +} BBS_BBS_DEVICE_PATH; + +// +// DeviceType definitions - from BBS specification +// +#define BBS_TYPE_FLOPPY 0x01 +#define BBS_TYPE_HARDDRIVE 0x02 +#define BBS_TYPE_CDROM 0x03 +#define BBS_TYPE_PCMCIA 0x04 +#define BBS_TYPE_USB 0x05 +#define BBS_TYPE_EMBEDDED_NETWORK 0x06 +#define BBS_TYPE_BEV 0x80 +#define BBS_TYPE_UNKNOWN 0xFF + + +/// +/// Union of all possible Device Paths and pointers to Device Paths. +/// +typedef union { + EFI_DEVICE_PATH_PROTOCOL DevPath; + PCI_DEVICE_PATH Pci; + PCCARD_DEVICE_PATH PcCard; + MEMMAP_DEVICE_PATH MemMap; + VENDOR_DEVICE_PATH Vendor; + + CONTROLLER_DEVICE_PATH Controller; + ACPI_HID_DEVICE_PATH Acpi; + ACPI_EXTENDED_HID_DEVICE_PATH ExtendedAcpi; + ACPI_ADR_DEVICE_PATH AcpiAdr; + + ATAPI_DEVICE_PATH Atapi; + SCSI_DEVICE_PATH Scsi; + ISCSI_DEVICE_PATH Iscsi; + FIBRECHANNEL_DEVICE_PATH FibreChannel; + FIBRECHANNELEX_DEVICE_PATH FibreChannelEx; + + F1394_DEVICE_PATH F1394; + USB_DEVICE_PATH Usb; + SATA_DEVICE_PATH Sata; + USB_CLASS_DEVICE_PATH UsbClass; + USB_WWID_DEVICE_PATH UsbWwid; + DEVICE_LOGICAL_UNIT_DEVICE_PATH LogicUnit; + I2O_DEVICE_PATH I2O; + MAC_ADDR_DEVICE_PATH MacAddr; + IPv4_DEVICE_PATH Ipv4; + IPv6_DEVICE_PATH Ipv6; + VLAN_DEVICE_PATH Vlan; + INFINIBAND_DEVICE_PATH InfiniBand; + UART_DEVICE_PATH Uart; + UART_FLOW_CONTROL_DEVICE_PATH UartFlowControl; + SAS_DEVICE_PATH Sas; + SASEX_DEVICE_PATH SasEx; + HARDDRIVE_DEVICE_PATH HardDrive; + CDROM_DEVICE_PATH CD; + + FILEPATH_DEVICE_PATH FilePath; + MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol; + + MEDIA_FW_VOL_DEVICE_PATH FirmwareVolume; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FirmwareFile; + MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH Offset; + + BBS_BBS_DEVICE_PATH Bbs; +} EFI_DEV_PATH; + + + +typedef union { + EFI_DEVICE_PATH_PROTOCOL *DevPath; + PCI_DEVICE_PATH *Pci; + PCCARD_DEVICE_PATH *PcCard; + MEMMAP_DEVICE_PATH *MemMap; + VENDOR_DEVICE_PATH *Vendor; + + CONTROLLER_DEVICE_PATH *Controller; + ACPI_HID_DEVICE_PATH *Acpi; + ACPI_EXTENDED_HID_DEVICE_PATH *ExtendedAcpi; + ACPI_ADR_DEVICE_PATH *AcpiAdr; + + ATAPI_DEVICE_PATH *Atapi; + SCSI_DEVICE_PATH *Scsi; + ISCSI_DEVICE_PATH *Iscsi; + FIBRECHANNEL_DEVICE_PATH *FibreChannel; + FIBRECHANNELEX_DEVICE_PATH *FibreChannelEx; + + F1394_DEVICE_PATH *F1394; + USB_DEVICE_PATH *Usb; + SATA_DEVICE_PATH *Sata; + USB_CLASS_DEVICE_PATH *UsbClass; + USB_WWID_DEVICE_PATH *UsbWwid; + DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicUnit; + I2O_DEVICE_PATH *I2O; + MAC_ADDR_DEVICE_PATH *MacAddr; + IPv4_DEVICE_PATH *Ipv4; + IPv6_DEVICE_PATH *Ipv6; + VLAN_DEVICE_PATH *Vlan; + INFINIBAND_DEVICE_PATH *InfiniBand; + UART_DEVICE_PATH *Uart; + UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl; + SAS_DEVICE_PATH *Sas; + SASEX_DEVICE_PATH *SasEx; + HARDDRIVE_DEVICE_PATH *HardDrive; + CDROM_DEVICE_PATH *CD; + + FILEPATH_DEVICE_PATH *FilePath; + MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol; + + MEDIA_FW_VOL_DEVICE_PATH *FirmwareVolume; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FirmwareFile; + MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset; + + BBS_BBS_DEVICE_PATH *Bbs; + UINT8 *Raw; +} EFI_DEV_PATH_PTR; + +#pragma pack() + +#define END_DEVICE_PATH_TYPE 0x7f +#define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xFF +#define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01 + +extern EFI_GUID gEfiDevicePathProtocolGuid; + +FORCEINLINE +UINT8 +DevicePathType ( + _In_ PVOID Node + ) +{ + //ASSERT(Node != NULL); + return ((EFI_DEVICE_PATH_PROTOCOL *) (Node))->Type; +} + +FORCEINLINE +UINT8 +DevicePathSubType ( + _In_ PVOID Node + ) +{ + //ASSERT(Node != NULL); + return ((EFI_DEVICE_PATH_PROTOCOL *) (Node))->SubType; +} + +FORCEINLINE +UINTN +DevicePathNodeLength ( + _In_ PVOID Node + ) +{ + //ASSERT(Node != NULL); + return *((UINT16 *) &((EFI_DEVICE_PATH_PROTOCOL *) (Node))->Length[0]); +} + +FORCEINLINE +EFI_DEVICE_PATH_PROTOCOL* +NextDevicePathNode ( + _In_ PVOID Node + ) +{ + //ASSERT(Node != NULL); + return (EFI_DEVICE_PATH_PROTOCOL *) ((UINT8 *) (Node) + DevicePathNodeLength(Node)); +} + +FORCEINLINE +BOOLEAN +IsDevicePathEndType ( + _In_ PVOID Node + ) +{ + //ASSERT(Node != NULL); + return (BOOLEAN) (DevicePathType(Node) == END_DEVICE_PATH_TYPE); +} + +FORCEINLINE +BOOLEAN +IsDevicePathEnd( + _In_ PVOID Node + ) +{ + //ASSERT(Node != NULL); + return (BOOLEAN) (IsDevicePathEndType(Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE); +} + +#endif diff --git a/reactos/boot/environ/include/efi/LoadedImage.h b/reactos/boot/environ/include/efi/LoadedImage.h new file mode 100644 index 00000000000..adb4a0b00a5 --- /dev/null +++ b/reactos/boot/environ/include/efi/LoadedImage.h @@ -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.
+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 diff --git a/reactos/boot/environ/include/efi/ProcessorBind.h b/reactos/boot/environ/include/efi/ProcessorBind.h new file mode 100644 index 00000000000..bab3e210ccf --- /dev/null +++ b/reactos/boot/environ/include/efi/ProcessorBind.h @@ -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.
+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 + diff --git a/reactos/boot/environ/include/efi/SimpleTextIn.h b/reactos/boot/environ/include/efi/SimpleTextIn.h new file mode 100644 index 00000000000..c71eb06546d --- /dev/null +++ b/reactos/boot/environ/include/efi/SimpleTextIn.h @@ -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.
+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 diff --git a/reactos/boot/environ/include/efi/SimpleTextInEx.h b/reactos/boot/environ/include/efi/SimpleTextInEx.h new file mode 100644 index 00000000000..2657786422b --- /dev/null +++ b/reactos/boot/environ/include/efi/SimpleTextInEx.h @@ -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.
+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 + +#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 + diff --git a/reactos/boot/environ/include/efi/SimpleTextOut.h b/reactos/boot/environ/include/efi/SimpleTextOut.h new file mode 100644 index 00000000000..730ddbc7133 --- /dev/null +++ b/reactos/boot/environ/include/efi/SimpleTextOut.h @@ -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.
+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 diff --git a/reactos/boot/environ/include/efi/Uefi.h b/reactos/boot/environ/include/efi/Uefi.h new file mode 100644 index 00000000000..a5029db3f42 --- /dev/null +++ b/reactos/boot/environ/include/efi/Uefi.h @@ -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.
+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 +#include + +#endif + diff --git a/reactos/boot/environ/include/efi/UefiBaseType.h b/reactos/boot/environ/include/efi/UefiBaseType.h new file mode 100644 index 00000000000..c960d85f842 --- /dev/null +++ b/reactos/boot/environ/include/efi/UefiBaseType.h @@ -0,0 +1,287 @@ +/** @file +Defines data types and constants introduced in UEFI. + +Copyright (c) 2006 - 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 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 + +// +// 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 diff --git a/reactos/boot/environ/include/efi/UefiMultiPhase.h b/reactos/boot/environ/include/efi/UefiMultiPhase.h new file mode 100644 index 00000000000..65355b0ca34 --- /dev/null +++ b/reactos/boot/environ/include/efi/UefiMultiPhase.h @@ -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.
+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 +/// +/// 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 \ No newline at end of file diff --git a/reactos/boot/environ/include/efi/UefiSpec.h b/reactos/boot/environ/include/efi/UefiSpec.h new file mode 100644 index 00000000000..f7cbb8ba6bd --- /dev/null +++ b/reactos/boot/environ/include/efi/UefiSpec.h @@ -0,0 +1,2100 @@ +/** @file +Include file that supports UEFI. + +This include file must contain things defined in the UEFI 2.3 specification. +If a code construct is defined in the UEFI 2.3 specification it must be included +by this include file. + +Copyright (c) 2006 - 2012, 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 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_SPEC_H__ +#define __UEFI_SPEC_H__ + +#include + +#include +#include +#include +#include + +/// +/// Enumeration of EFI memory allocation types. +/// +typedef enum { + /// + /// Allocate any available range of pages that satisfies the request. + /// + AllocateAnyPages, + /// + /// Allocate any available range of pages whose uppermost address is less than + /// or equal to a specified maximum address. + /// + AllocateMaxAddress, + /// + /// Allocate pages at a specified address. + /// + AllocateAddress, + /// + /// Maximum enumeration value that may be used for bounds checking. + /// + MaxAllocateType +} EFI_ALLOCATE_TYPE; + +// +// Bit definitions for EFI_TIME.Daylight +// +#define EFI_TIME_ADJUST_DAYLIGHT 0x01 +#define EFI_TIME_IN_DAYLIGHT 0x02 + +/// +/// Value definition for EFI_TIME.TimeZone. +/// +#define EFI_UNSPECIFIED_TIMEZONE 0x07FF + +// +// Memory cacheability attributes +// +#define EFI_MEMORY_UC 0x0000000000000001ULL +#define EFI_MEMORY_WC 0x0000000000000002ULL +#define EFI_MEMORY_WT 0x0000000000000004ULL +#define EFI_MEMORY_WB 0x0000000000000008ULL +#define EFI_MEMORY_UCE 0x0000000000000010ULL +// +// Physical memory protection attributes +// +#define EFI_MEMORY_WP 0x0000000000001000ULL +#define EFI_MEMORY_RP 0x0000000000002000ULL +#define EFI_MEMORY_XP 0x0000000000004000ULL +// +// Runtime memory attribute +// +#define EFI_MEMORY_RUNTIME 0x8000000000000000ULL + +/// +/// Memory descriptor version number. +/// +#define EFI_MEMORY_DESCRIPTOR_VERSION 1 + +/// +/// Definition of an EFI memory descriptor. +/// +typedef struct { + /// + /// Type of the memory region. See EFI_MEMORY_TYPE. + /// + UINT32 Type; + /// + /// Physical address of the first byte of the memory region. Must aligned + /// on a 4 KB boundary. + /// + EFI_PHYSICAL_ADDRESS PhysicalStart; + /// + /// Virtual address of the first byte of the memory region. Must aligned + /// on a 4 KB boundary. + /// + EFI_VIRTUAL_ADDRESS VirtualStart; + /// + /// Number of 4KB pages in the memory region. + /// + UINT64 NumberOfPages; + /// + /// Attributes of the memory region that describe the bit mask of capabilities + /// for that memory region, and not necessarily the current settings for that + /// memory region. + /// + UINT64 Attribute; +} EFI_MEMORY_DESCRIPTOR; + +/** +Allocates memory pages from the system. + +@param Type The type of allocation to perform. +@param MemoryType The type of memory to allocate. +@param Pages The number of contiguous 4 KB pages to allocate. +@param Memory The pointer to a physical address. On input, the way in which the address is +used depends on the value of Type. + +@retval EFI_SUCCESS The requested pages were allocated. +@retval EFI_INVALID_PARAMETER 1) Type is not AllocateAnyPages or +AllocateMaxAddress or AllocateAddress. +2) MemoryType is in the range +3) Memory is NULL. +EfiMaxMemoryType..0x7FFFFFFF. +@retval EFI_OUT_OF_RESOURCES The pages could not be allocated. +@retval EFI_NOT_FOUND The requested pages could not be found. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_ALLOCATE_PAGES)( +IN EFI_ALLOCATE_TYPE Type, +IN EFI_MEMORY_TYPE MemoryType, +IN UINTN Pages, +IN OUT EFI_PHYSICAL_ADDRESS *Memory +); + +/** +Frees memory pages. + +@param Memory The base physical address of the pages to be freed. +@param Pages The number of contiguous 4 KB pages to free. + +@retval EFI_SUCCESS The requested pages were freed. +@retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid. +@retval EFI_NOT_FOUND The requested memory pages were not allocated with +AllocatePages(). + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_FREE_PAGES)( +IN EFI_PHYSICAL_ADDRESS Memory, +IN UINTN Pages +); + +/** +Returns the current memory map. + +@param MemoryMapSize A pointer to the size, in bytes, of the MemoryMap buffer. +On input, this is the size of the buffer allocated by the caller. +On output, it is the size of the buffer returned by the firmware if +the buffer was large enough, or the size of the buffer needed to contain +the map if the buffer was too small. +@param MemoryMap A pointer to the buffer in which firmware places the current memory +map. +@param MapKey A pointer to the location in which firmware returns the key for the +current memory map. +@param DescriptorSize A pointer to the location in which firmware returns the size, in bytes, of +an individual EFI_MEMORY_DESCRIPTOR. +@param DescriptorVersion A pointer to the location in which firmware returns the version number +associated with the EFI_MEMORY_DESCRIPTOR. + +@retval EFI_SUCCESS The memory map was returned in the MemoryMap buffer. +@retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current buffer size +needed to hold the memory map is returned in MemoryMapSize. +@retval EFI_INVALID_PARAMETER 1) MemoryMapSize is NULL. +2) The MemoryMap buffer is not too small and MemoryMap is +NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_GET_MEMORY_MAP)( +IN OUT UINTN *MemoryMapSize, +IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, +OUT UINTN *MapKey, +OUT UINTN *DescriptorSize, +OUT UINT32 *DescriptorVersion +); + +/** +Allocates pool memory. + +@param PoolType The type of pool to allocate. +@param Size The number of bytes to allocate from the pool. +@param Buffer A pointer to a pointer to the allocated buffer if the call succeeds; +undefined otherwise. + +@retval EFI_SUCCESS The requested number of bytes was allocated. +@retval EFI_OUT_OF_RESOURCES The pool requested could not be allocated. +@retval EFI_INVALID_PARAMETER PoolType was invalid or Buffer is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_ALLOCATE_POOL)( +IN EFI_MEMORY_TYPE PoolType, +IN UINTN Size, +OUT VOID **Buffer +); + +/** +Returns pool memory to the system. + +@param Buffer The pointer to the buffer to free. + +@retval EFI_SUCCESS The memory was returned to the system. +@retval EFI_INVALID_PARAMETER Buffer was invalid. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_FREE_POOL)( +IN VOID *Buffer +); + +/** +Changes the runtime addressing mode of EFI firmware from physical to virtual. + +@param MemoryMapSize The size in bytes of VirtualMap. +@param DescriptorSize The size in bytes of an entry in the VirtualMap. +@param DescriptorVersion The version of the structure entries in VirtualMap. +@param VirtualMap An array of memory descriptors which contain new virtual +address mapping information for all runtime ranges. + +@retval EFI_SUCCESS The virtual address map has been applied. +@retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in +virtual address mapped mode. +@retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is invalid. +@retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory +map that requires a mapping. +@retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found +in the memory map. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP)( +IN UINTN MemoryMapSize, +IN UINTN DescriptorSize, +IN UINT32 DescriptorVersion, +IN EFI_MEMORY_DESCRIPTOR *VirtualMap +); + +/** +Connects one or more drivers to a controller. + +@param ControllerHandle The handle of the controller to which driver(s) are to be connected. +@param DriverImageHandle A pointer to an ordered list handles that support the +EFI_DRIVER_BINDING_PROTOCOL. +@param RemainingDevicePath A pointer to the device path that specifies a child of the +controller specified by ControllerHandle. +@param Recursive If TRUE, then ConnectController() is called recursively +until the entire tree of controllers below the controller specified +by ControllerHandle have been created. If FALSE, then +the tree of controllers is only expanded one level. + +@retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle. +2) No drivers were connected to ControllerHandle, but +RemainingDevicePath is not NULL, and it is an End Device +Path Node. +@retval EFI_INVALID_PARAMETER ControllerHandle is NULL. +@retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances +present in the system. +2) No drivers were connected to ControllerHandle. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_CONNECT_CONTROLLER)( +IN EFI_HANDLE ControllerHandle, +IN EFI_HANDLE *DriverImageHandle, OPTIONAL +IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath, OPTIONAL +IN BOOLEAN Recursive +); + +/** +Disconnects one or more drivers from a controller. + +@param ControllerHandle The handle of the controller from which driver(s) are to be disconnected. +@param DriverImageHandle The driver to disconnect from ControllerHandle. +If DriverImageHandle is NULL, then all the drivers currently managing +ControllerHandle are disconnected from ControllerHandle. +@param ChildHandle The handle of the child to destroy. +If ChildHandle is NULL, then all the children of ControllerHandle are +destroyed before the drivers are disconnected from ControllerHandle. + +@retval EFI_SUCCESS 1) One or more drivers were disconnected from the controller. +2) On entry, no drivers are managing ControllerHandle. +3) DriverImageHandle is not NULL, and on entry +DriverImageHandle is not managing ControllerHandle. +@retval EFI_INVALID_PARAMETER 1) ControllerHandle is NULL. +2) DriverImageHandle is not NULL, and it is not a valid EFI_HANDLE. +3) ChildHandle is not NULL, and it is not a valid EFI_HANDLE. +4) DriverImageHandle does not support the EFI_DRIVER_BINDING_PROTOCOL. +@retval EFI_OUT_OF_RESOURCES There are not enough resources available to disconnect any drivers from +ControllerHandle. +@retval EFI_DEVICE_ERROR The controller could not be disconnected because of a device error. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_DISCONNECT_CONTROLLER)( +IN EFI_HANDLE ControllerHandle, +IN EFI_HANDLE DriverImageHandle, OPTIONAL +IN EFI_HANDLE ChildHandle OPTIONAL +); + + + +// +// ConvertPointer DebugDisposition type. +// +#define EFI_OPTIONAL_PTR 0x00000001 + +/** +Determines the new virtual address that is to be used on subsequent memory accesses. + +@param DebugDisposition Supplies type information for the pointer being converted. +@param Address A pointer to a pointer that is to be fixed to be the value needed +for the new virtual address mappings being applied. + +@retval EFI_SUCCESS The pointer pointed to by Address was modified. +@retval EFI_INVALID_PARAMETER 1) Address is NULL. +2) *Address is NULL and DebugDisposition does +not have the EFI_OPTIONAL_PTR bit set. +@retval EFI_NOT_FOUND The pointer pointed to by Address was not found to be part +of the current memory map. This is normally fatal. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_CONVERT_POINTER)( +IN UINTN DebugDisposition, +IN OUT VOID **Address +); + + +// +// These types can be ORed together as needed - for example, +// EVT_TIMER might be Ored with EVT_NOTIFY_WAIT or +// EVT_NOTIFY_SIGNAL. +// +#define EVT_TIMER 0x80000000 +#define EVT_RUNTIME 0x40000000 +#define EVT_NOTIFY_WAIT 0x00000100 +#define EVT_NOTIFY_SIGNAL 0x00000200 + +#define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201 +#define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202 + +// +// The event's NotifyContext pointer points to a runtime memory +// address. +// The event is deprecated in UEFI2.0 and later specifications. +// +#define EVT_RUNTIME_CONTEXT 0x20000000 + + +/** +Invoke a notification event + +@param Event Event whose notification function is being invoked. +@param Context The pointer to the notification function's context, +which is implementation-dependent. + +**/ +typedef +VOID +(EFIAPI *EFI_EVENT_NOTIFY)( +IN EFI_EVENT Event, +IN VOID *Context +); + +/** +Creates an event. + +@param Type The type of event to create and its mode and attributes. +@param NotifyTpl The task priority level of event notifications, if needed. +@param NotifyFunction The pointer to the event's notification function, if any. +@param NotifyContext The pointer to the notification function's context; corresponds to parameter +Context in the notification function. +@param Event The pointer to the newly created event if the call succeeds; undefined +otherwise. + +@retval EFI_SUCCESS The event structure was created. +@retval EFI_INVALID_PARAMETER One or more parameters are invalid. +@retval EFI_OUT_OF_RESOURCES The event could not be allocated. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_CREATE_EVENT)( +IN UINT32 Type, +IN EFI_TPL NotifyTpl, +IN EFI_EVENT_NOTIFY NotifyFunction, +IN VOID *NotifyContext, +OUT EFI_EVENT *Event +); + +/** +Creates an event in a group. + +@param Type The type of event to create and its mode and attributes. +@param NotifyTpl The task priority level of event notifications,if needed. +@param NotifyFunction The pointer to the event's notification function, if any. +@param NotifyContext The pointer to the notification function's context; corresponds to parameter +Context in the notification function. +@param EventGroup The pointer to the unique identifier of the group to which this event belongs. +If this is NULL, then the function behaves as if the parameters were passed +to CreateEvent. +@param Event The pointer to the newly created event if the call succeeds; undefined +otherwise. + +@retval EFI_SUCCESS The event structure was created. +@retval EFI_INVALID_PARAMETER One or more parameters are invalid. +@retval EFI_OUT_OF_RESOURCES The event could not be allocated. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_CREATE_EVENT_EX)( +IN UINT32 Type, +IN EFI_TPL NotifyTpl, +IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, +IN CONST VOID *NotifyContext OPTIONAL, +IN CONST EFI_GUID *EventGroup OPTIONAL, +OUT EFI_EVENT *Event +); + +/// +/// Timer delay types +/// +typedef enum { + /// + /// An event's timer settings is to be cancelled and not trigger time is to be set/ + /// + TimerCancel, + /// + /// An event is to be signalled periodically at a specified interval from the current time. + /// + TimerPeriodic, + /// + /// An event is to be signalled once at a specified interval from the current time. + /// + TimerRelative +} EFI_TIMER_DELAY; + +/** +Sets the type of timer and the trigger time for a timer event. + +@param Event The timer event that is to be signaled at the specified time. +@param Type The type of time that is specified in TriggerTime. +@param TriggerTime The number of 100ns units until the timer expires. +A TriggerTime of 0 is legal. +If Type is TimerRelative and TriggerTime is 0, then the timer +event will be signaled on the next timer tick. +If Type is TimerPeriodic and TriggerTime is 0, then the timer +event will be signaled on every timer tick. + +@retval EFI_SUCCESS The event has been set to be signaled at the requested time. +@retval EFI_INVALID_PARAMETER Event or Type is not valid. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SET_TIMER)( +IN EFI_EVENT Event, +IN EFI_TIMER_DELAY Type, +IN UINT64 TriggerTime +); + +/** +Signals an event. + +@param Event The event to signal. + +@retval EFI_SUCCESS The event has been signaled. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SIGNAL_EVENT)( +IN EFI_EVENT Event +); + +/** +Stops execution until an event is signaled. + +@param NumberOfEvents The number of events in the Event array. +@param Event An array of EFI_EVENT. +@param Index The pointer to the index of the event which satisfied the wait condition. + +@retval EFI_SUCCESS The event indicated by Index was signaled. +@retval EFI_INVALID_PARAMETER 1) NumberOfEvents is 0. +2) The event indicated by Index is of type +EVT_NOTIFY_SIGNAL. +@retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_WAIT_FOR_EVENT)( +IN UINTN NumberOfEvents, +IN EFI_EVENT *Event, +OUT UINTN *Index +); + +/** +Closes an event. + +@param Event The event to close. + +@retval EFI_SUCCESS The event has been closed. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_CLOSE_EVENT)( +IN EFI_EVENT Event +); + +/** +Checks whether an event is in the signaled state. + +@param Event The event to check. + +@retval EFI_SUCCESS The event is in the signaled state. +@retval EFI_NOT_READY The event is not in the signaled state. +@retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_CHECK_EVENT)( +IN EFI_EVENT Event +); + + +// +// Task priority level +// +#define TPL_APPLICATION 4 +#define TPL_CALLBACK 8 +#define TPL_NOTIFY 16 +#define TPL_HIGH_LEVEL 31 + + +/** +Raises a task's priority level and returns its previous level. + +@param NewTpl The new task priority level. + +@return Previous task priority level + +**/ +typedef +EFI_TPL +(EFIAPI *EFI_RAISE_TPL)( +IN EFI_TPL NewTpl +); + +/** +Restores a task's priority level to its previous value. + +@param OldTpl The previous task priority level to restore. + +**/ +typedef +VOID +(EFIAPI *EFI_RESTORE_TPL)( +IN EFI_TPL OldTpl +); + +/** +Returns the value of a variable. + +@param VariableName A Null-terminated string that is the name of the vendor's +variable. +@param VendorGuid A unique identifier for the vendor. +@param Attributes If not NULL, a pointer to the memory location to return the +attributes bitmask for the variable. +@param DataSize On input, the size in bytes of the return Data buffer. +On output the size of data returned in Data. +@param Data The buffer to return the contents of the variable. + +@retval EFI_SUCCESS The function completed successfully. +@retval EFI_NOT_FOUND The variable was not found. +@retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. +@retval EFI_INVALID_PARAMETER VariableName is NULL. +@retval EFI_INVALID_PARAMETER VendorGuid is NULL. +@retval EFI_INVALID_PARAMETER DataSize is NULL. +@retval EFI_INVALID_PARAMETER The DataSize is not too small and Data is NULL. +@retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error. +@retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_GET_VARIABLE)( +IN CHAR16 *VariableName, +IN EFI_GUID *VendorGuid, +OUT UINT32 *Attributes, OPTIONAL +IN OUT UINTN *DataSize, +OUT VOID *Data +); + +/** +Enumerates the current variable names. + +@param VariableNameSize The size of the VariableName buffer. +@param VariableName On input, supplies the last VariableName that was returned +by GetNextVariableName(). On output, returns the Nullterminated +string of the current variable. +@param VendorGuid On input, supplies the last VendorGuid that was returned by +GetNextVariableName(). On output, returns the +VendorGuid of the current variable. + +@retval EFI_SUCCESS The function completed successfully. +@retval EFI_NOT_FOUND The next variable was not found. +@retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result. +@retval EFI_INVALID_PARAMETER VariableNameSize is NULL. +@retval EFI_INVALID_PARAMETER VariableName is NULL. +@retval EFI_INVALID_PARAMETER VendorGuid is NULL. +@retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_GET_NEXT_VARIABLE_NAME)( +IN OUT UINTN *VariableNameSize, +IN OUT CHAR16 *VariableName, +IN OUT EFI_GUID *VendorGuid +); + +/** +Sets the value of a variable. + +@param VariableName A Null-terminated string that is the name of the vendor's variable. +Each VariableName is unique for each VendorGuid. VariableName must +contain 1 or more characters. If VariableName is an empty string, +then EFI_INVALID_PARAMETER is returned. +@param VendorGuid A unique identifier for the vendor. +@param Attributes Attributes bitmask to set for the variable. +@param DataSize The size in bytes of the Data buffer. A size of zero causes the +variable to be deleted. +@param Data The contents for the variable. + +@retval EFI_SUCCESS The firmware has successfully stored the variable and its data as +defined by the Attributes. +@retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied, or the +DataSize exceeds the maximum allowed. +@retval EFI_INVALID_PARAMETER VariableName is an empty string. +@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data. +@retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error. +@retval EFI_WRITE_PROTECTED The variable in question is read-only. +@retval EFI_WRITE_PROTECTED The variable in question cannot be deleted. +@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS +set but the AuthInfo does NOT pass the validation check carried out +by the firmware. +@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SET_VARIABLE)( +IN CHAR16 *VariableName, +IN EFI_GUID *VendorGuid, +IN UINT32 Attributes, +IN UINTN DataSize, +IN VOID *Data +); + + +/// +/// This provides the capabilities of the +/// real time clock device as exposed through the EFI interfaces. +/// +typedef struct { + /// + /// Provides the reporting resolution of the real-time clock device in + /// counts per second. For a normal PC-AT CMOS RTC device, this + /// value would be 1 Hz, or 1, to indicate that the device only reports + /// the time to the resolution of 1 second. + /// + UINT32 Resolution; + /// + /// Provides the timekeeping accuracy of the real-time clock in an + /// error rate of 1E-6 parts per million. For a clock with an accuracy + /// of 50 parts per million, the value in this field would be + /// 50,000,000. + /// + UINT32 Accuracy; + /// + /// A TRUE indicates that a time set operation clears the device's + /// time below the Resolution reporting level. A FALSE + /// indicates that the state below the Resolution level of the + /// device is not cleared when the time is set. Normal PC-AT CMOS + /// RTC devices set this value to FALSE. + /// + BOOLEAN SetsToZero; +} EFI_TIME_CAPABILITIES; + +/** +Returns the current time and date information, and the time-keeping capabilities +of the hardware platform. + +@param Time A pointer to storage to receive a snapshot of the current time. +@param Capabilities An optional pointer to a buffer to receive the real time clock +device's capabilities. + +@retval EFI_SUCCESS The operation completed successfully. +@retval EFI_INVALID_PARAMETER Time is NULL. +@retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_GET_TIME)( +OUT EFI_TIME *Time, +OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL +); + +/** +Sets the current local time and date information. + +@param Time A pointer to the current time. + +@retval EFI_SUCCESS The operation completed successfully. +@retval EFI_INVALID_PARAMETER A time field is out of range. +@retval EFI_DEVICE_ERROR The time could not be set due due to hardware error. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SET_TIME)( +IN EFI_TIME *Time +); + +/** +Returns the current wakeup alarm clock setting. + +@param Enabled Indicates if the alarm is currently enabled or disabled. +@param Pending Indicates if the alarm signal is pending and requires acknowledgement. +@param Time The current alarm setting. + +@retval EFI_SUCCESS The alarm settings were returned. +@retval EFI_INVALID_PARAMETER Enabled is NULL. +@retval EFI_INVALID_PARAMETER Pending is NULL. +@retval EFI_INVALID_PARAMETER Time is NULL. +@retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error. +@retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_GET_WAKEUP_TIME)( +OUT BOOLEAN *Enabled, +OUT BOOLEAN *Pending, +OUT EFI_TIME *Time +); + +/** +Sets the system wakeup alarm clock time. + +@param Enabled Enable or disable the wakeup alarm. +@param Time If Enable is TRUE, the time to set the wakeup alarm for. +If Enable is FALSE, then this parameter is optional, and may be NULL. + +@retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If +Enable is FALSE, then the wakeup alarm was disabled. +@retval EFI_INVALID_PARAMETER A time field is out of range. +@retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error. +@retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SET_WAKEUP_TIME)( +IN BOOLEAN Enable, +IN EFI_TIME *Time OPTIONAL +); + +/** +Loads an EFI image into memory. + +@param BootPolicy If TRUE, indicates that the request originates from the boot +manager, and that the boot manager is attempting to load +FilePath as a boot selection. Ignored if SourceBuffer is +not NULL. +@param ParentImageHandle The caller's image handle. +@param DevicePath The DeviceHandle specific file path from which the image is +loaded. +@param SourceBuffer If not NULL, a pointer to the memory location containing a copy +of the image to be loaded. +@param SourceSize The size in bytes of SourceBuffer. Ignored if SourceBuffer is NULL. +@param ImageHandle The pointer to the returned image handle that is created when the +image is successfully loaded. + +@retval EFI_SUCCESS Image was loaded into memory correctly. +@retval EFI_NOT_FOUND Both SourceBuffer and DevicePath are NULL. +@retval EFI_INVALID_PARAMETER One or more parametes are invalid. +@retval EFI_UNSUPPORTED The image type is not supported. +@retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient resources. +@retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not +understood. +@retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error. +@retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the +image from being loaded. NULL is returned in *ImageHandle. +@retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a +valid EFI_LOADED_IMAGE_PROTOCOL. However, the current +platform policy specifies that the image should not be started. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IMAGE_LOAD)( +IN BOOLEAN BootPolicy, +IN EFI_HANDLE ParentImageHandle, +IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, +IN VOID *SourceBuffer OPTIONAL, +IN UINTN SourceSize, +OUT EFI_HANDLE *ImageHandle +); + +/** +Transfers control to a loaded image's entry point. + +@param ImageHandle Handle of image to be started. +@param ExitDataSize The pointer to the size, in bytes, of ExitData. +@param ExitData The pointer to a pointer to a data buffer that includes a Null-terminated +string, optionally followed by additional binary data. + +@retval EFI_INVALID_PARAMETER ImageHandle is either an invalid image handle or the image +has already been initialized with StartImage. +@return Exit code from image + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IMAGE_START)( +IN EFI_HANDLE ImageHandle, +OUT UINTN *ExitDataSize, +OUT CHAR16 **ExitData OPTIONAL +); + +/** +Terminates a loaded EFI image and returns control to boot services. + +@param ImageHandle Handle that identifies the image. This parameter is passed to the +image on entry. +@param ExitStatus The image's exit code. +@param ExitDataSize The size, in bytes, of ExitData. Ignored if ExitStatus is EFI_SUCCESS. +@param ExitData The pointer to a data buffer that includes a Null-terminated string, +optionally followed by additional binary data. The string is a +description that the caller may use to further indicate the reason +for the image's exit. ExitData is only valid if ExitStatus +is something other than EFI_SUCCESS. The ExitData buffer +must be allocated by calling AllocatePool(). + +@retval EFI_SUCCESS The image specified by ImageHandle was unloaded. +@retval EFI_INVALID_PARAMETER The image specified by ImageHandle has been loaded and +started with LoadImage() and StartImage(), but the +image is not the currently executing image. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_EXIT)( +IN EFI_HANDLE ImageHandle, +IN EFI_STATUS ExitStatus, +IN UINTN ExitDataSize, +IN CHAR16 *ExitData OPTIONAL +); + +/** +Unloads an image. + +@param ImageHandle Handle that identifies the image to be unloaded. + +@retval EFI_SUCCESS The image has been unloaded. +@retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IMAGE_UNLOAD)( +IN EFI_HANDLE ImageHandle +); + +/** +Terminates all boot services. + +@param ImageHandle Handle that identifies the exiting image. +@param MapKey Key to the latest memory map. + +@retval EFI_SUCCESS Boot services have been terminated. +@retval EFI_INVALID_PARAMETER MapKey is incorrect. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_EXIT_BOOT_SERVICES)( +IN EFI_HANDLE ImageHandle, +IN UINTN MapKey +); + +/** +Induces a fine-grained stall. + +@param Microseconds The number of microseconds to stall execution. + +@retval EFI_SUCCESS Execution was stalled at least the requested number of +Microseconds. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_STALL)( +IN UINTN Microseconds +); + +/** +Sets the system's watchdog timer. + +@param Timeout The number of seconds to set the watchdog timer to. +@param WatchdogCode The numeric code to log on a watchdog timer timeout event. +@param DataSize The size, in bytes, of WatchdogData. +@param WatchdogData A data buffer that includes a Null-terminated string, optionally +followed by additional binary data. + +@retval EFI_SUCCESS The timeout has been set. +@retval EFI_INVALID_PARAMETER The supplied WatchdogCode is invalid. +@retval EFI_UNSUPPORTED The system does not have a watchdog timer. +@retval EFI_DEVICE_ERROR The watchdog timer could not be programmed due to a hardware +error. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SET_WATCHDOG_TIMER)( +IN UINTN Timeout, +IN UINT64 WatchdogCode, +IN UINTN DataSize, +IN CHAR16 *WatchdogData OPTIONAL +); + +/// +/// Enumeration of reset types. +/// +typedef enum { + /// + /// Used to induce a system-wide reset. This sets all circuitry within the + /// system to its initial state. This type of reset is asynchronous to system + /// operation and operates withgout regard to cycle boundaries. EfiColdReset + /// is tantamount to a system power cycle. + /// + EfiResetCold, + /// + /// Used to induce a system-wide initialization. The processors are set to their + /// initial state, and pending cycles are not corrupted. If the system does + /// not support this reset type, then an EfiResetCold must be performed. + /// + EfiResetWarm, + /// + /// Used to induce an entry into a power state equivalent to the ACPI G2/S5 or G3 + /// state. If the system does not support this reset type, then when the system + /// is rebooted, it should exhibit the EfiResetCold attributes. + /// + EfiResetShutdown +} EFI_RESET_TYPE; + +/** +Resets the entire platform. + +@param ResetType The type of reset to perform. +@param ResetStatus The status code for the reset. +@param DataSize The size, in bytes, of WatchdogData. +@param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or +EfiResetShutdown the data buffer starts with a Null-terminated +string, optionally followed by additional binary data. + +**/ +typedef +VOID +(EFIAPI *EFI_RESET_SYSTEM)( +IN EFI_RESET_TYPE ResetType, +IN EFI_STATUS ResetStatus, +IN UINTN DataSize, +IN VOID *ResetData OPTIONAL +); + +/** +Returns a monotonically increasing count for the platform. + +@param Count The pointer to returned value. + +@retval EFI_SUCCESS The next monotonic count was returned. +@retval EFI_INVALID_PARAMETER Count is NULL. +@retval EFI_DEVICE_ERROR The device is not functioning properly. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT)( +OUT UINT64 *Count +); + +/** +Returns the next high 32 bits of the platform's monotonic counter. + +@param HighCount The pointer to returned value. + +@retval EFI_SUCCESS The next high monotonic count was returned. +@retval EFI_INVALID_PARAMETER HighCount is NULL. +@retval EFI_DEVICE_ERROR The device is not functioning properly. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT)( +OUT UINT32 *HighCount +); + +/** +Computes and returns a 32-bit CRC for a data buffer. + +@param Data A pointer to the buffer on which the 32-bit CRC is to be computed. +@param DataSize The number of bytes in the buffer Data. +@param Crc32 The 32-bit CRC that was computed for the data buffer specified by Data +and DataSize. + +@retval EFI_SUCCESS The 32-bit CRC was computed for the data buffer and returned in +Crc32. +@retval EFI_INVALID_PARAMETER Data is NULL. +@retval EFI_INVALID_PARAMETER Crc32 is NULL. +@retval EFI_INVALID_PARAMETER DataSize is 0. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_CALCULATE_CRC32)( +IN VOID *Data, +IN UINTN DataSize, +OUT UINT32 *Crc32 +); + +/** +Copies the contents of one buffer to another buffer. + +@param Destination The pointer to the destination buffer of the memory copy. +@param Source The pointer to the source buffer of the memory copy. +@param Length Number of bytes to copy from Source to Destination. + +**/ +typedef +VOID +(EFIAPI *EFI_COPY_MEM)( +IN VOID *Destination, +IN VOID *Source, +IN UINTN Length +); + +/** +The SetMem() function fills a buffer with a specified value. + +@param Buffer The pointer to the buffer to fill. +@param Size Number of bytes in Buffer to fill. +@param Value Value to fill Buffer with. + +**/ +typedef +VOID +(EFIAPI *EFI_SET_MEM)( +IN VOID *Buffer, +IN UINTN Size, +IN UINT8 Value +); + +/// +/// Enumeration of EFI Interface Types +/// +typedef enum { + /// + /// Indicates that the supplied protocol interface is supplied in native form. + /// + EFI_NATIVE_INTERFACE +} EFI_INTERFACE_TYPE; + +/** +Installs a protocol interface on a device handle. If the handle does not exist, it is created and added +to the list of handles in the system. InstallMultipleProtocolInterfaces() performs +more error checking than InstallProtocolInterface(), so it is recommended that +InstallMultipleProtocolInterfaces() be used in place of +InstallProtocolInterface() + +@param Handle A pointer to the EFI_HANDLE on which the interface is to be installed. +@param Protocol The numeric ID of the protocol interface. +@param InterfaceType Indicates whether Interface is supplied in native form. +@param Interface A pointer to the protocol interface. + +@retval EFI_SUCCESS The protocol interface was installed. +@retval EFI_OUT_OF_RESOURCES Space for a new handle could not be allocated. +@retval EFI_INVALID_PARAMETER Handle is NULL. +@retval EFI_INVALID_PARAMETER Protocol is NULL. +@retval EFI_INVALID_PARAMETER InterfaceType is not EFI_NATIVE_INTERFACE. +@retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE)( +IN OUT EFI_HANDLE *Handle, +IN EFI_GUID *Protocol, +IN EFI_INTERFACE_TYPE InterfaceType, +IN VOID *Interface +); + +/** +Installs one or more protocol interfaces into the boot services environment. + +@param Handle The handle to install the new protocol interfaces on, or NULL if a new +handle is to be allocated. +@param ... A variable argument list containing pairs of protocol GUIDs and protocol +interfaces. + +@retval EFI_SUCCESS All the protocol interface was installed. +@retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols. +@retval EFI_ALREADY_STARTED A Device Path Protocol instance was passed in that is already present in +the handle database. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES)( +IN OUT EFI_HANDLE *Handle, +... +); + +/** +Reinstalls a protocol interface on a device handle. + +@param Handle Handle on which the interface is to be reinstalled. +@param Protocol The numeric ID of the interface. +@param OldInterface A pointer to the old interface. NULL can be used if a structure is not +associated with Protocol. +@param NewInterface A pointer to the new interface. + +@retval EFI_SUCCESS The protocol interface was reinstalled. +@retval EFI_NOT_FOUND The OldInterface on the handle was not found. +@retval EFI_ACCESS_DENIED The protocol interface could not be reinstalled, +because OldInterface is still being used by a +driver that will not release it. +@retval EFI_INVALID_PARAMETER Handle is NULL. +@retval EFI_INVALID_PARAMETER Protocol is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE)( +IN EFI_HANDLE Handle, +IN EFI_GUID *Protocol, +IN VOID *OldInterface, +IN VOID *NewInterface +); + +/** +Removes a protocol interface from a device handle. It is recommended that +UninstallMultipleProtocolInterfaces() be used in place of +UninstallProtocolInterface(). + +@param Handle The handle on which the interface was installed. +@param Protocol The numeric ID of the interface. +@param Interface A pointer to the interface. + +@retval EFI_SUCCESS The interface was removed. +@retval EFI_NOT_FOUND The interface was not found. +@retval EFI_ACCESS_DENIED The interface was not removed because the interface +is still being used by a driver. +@retval EFI_INVALID_PARAMETER Handle is NULL. +@retval EFI_INVALID_PARAMETER Protocol is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE)( +IN EFI_HANDLE Handle, +IN EFI_GUID *Protocol, +IN VOID *Interface +); + +/** +Removes one or more protocol interfaces into the boot services environment. + +@param Handle The handle to remove the protocol interfaces from. +@param ... A variable argument list containing pairs of protocol GUIDs and +protocol interfaces. + +@retval EFI_SUCCESS All the protocol interfaces were removed. +@retval EFI_INVALID_PARAMETER One of the protocol interfaces was not previously installed on Handle. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES)( +IN EFI_HANDLE Handle, +... +); + +/** +Queries a handle to determine if it supports a specified protocol. + +@param Handle The handle being queried. +@param Protocol The published unique identifier of the protocol. +@param Interface Supplies the address where a pointer to the corresponding Protocol +Interface is returned. + +@retval EFI_SUCCESS The interface information for the specified protocol was returned. +@retval EFI_UNSUPPORTED The device does not support the specified protocol. +@retval EFI_INVALID_PARAMETER Handle is NULL. +@retval EFI_INVALID_PARAMETER Protocol is NULL. +@retval EFI_INVALID_PARAMETER Interface is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HANDLE_PROTOCOL)( +IN EFI_HANDLE Handle, +IN EFI_GUID *Protocol, +OUT VOID **Interface +); + +#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 +#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 +#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 +#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 +#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 +#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 + +/** +Queries a handle to determine if it supports a specified protocol. If the protocol is supported by the +handle, it opens the protocol on behalf of the calling agent. + +@param Handle The handle for the protocol interface that is being opened. +@param Protocol The published unique identifier of the protocol. +@param Interface Supplies the address where a pointer to the corresponding Protocol +Interface is returned. +@param AgentHandle The handle of the agent that is opening the protocol interface +specified by Protocol and Interface. +@param ControllerHandle If the agent that is opening a protocol is a driver that follows the +UEFI Driver Model, then this parameter is the controller handle +that requires the protocol interface. If the agent does not follow +the UEFI Driver Model, then this parameter is optional and may +be NULL. +@param Attributes The open mode of the protocol interface specified by Handle +and Protocol. + +@retval EFI_SUCCESS An item was added to the open list for the protocol interface, and the +protocol interface was returned in Interface. +@retval EFI_UNSUPPORTED Handle does not support Protocol. +@retval EFI_INVALID_PARAMETER One or more parameters are invalid. +@retval EFI_ACCESS_DENIED Required attributes can't be supported in current environment. +@retval EFI_ALREADY_STARTED Item on the open list already has requierd attributes whose agent +handle is the same as AgentHandle. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_OPEN_PROTOCOL)( +IN EFI_HANDLE Handle, +IN EFI_GUID *Protocol, +OUT VOID **Interface, OPTIONAL +IN EFI_HANDLE AgentHandle, +IN EFI_HANDLE ControllerHandle, +IN UINT32 Attributes +); + + +/** +Closes a protocol on a handle that was opened using OpenProtocol(). + +@param Handle The handle for the protocol interface that was previously opened +with OpenProtocol(), and is now being closed. +@param Protocol The published unique identifier of the protocol. +@param AgentHandle The handle of the agent that is closing the protocol interface. +@param ControllerHandle If the agent that opened a protocol is a driver that follows the +UEFI Driver Model, then this parameter is the controller handle +that required the protocol interface. + +@retval EFI_SUCCESS The protocol instance was closed. +@retval EFI_INVALID_PARAMETER 1) Handle is NULL. +2) AgentHandle is NULL. +3) ControllerHandle is not NULL and ControllerHandle is not a valid EFI_HANDLE. +4) Protocol is NULL. +@retval EFI_NOT_FOUND 1) Handle does not support the protocol specified by Protocol. +2) The protocol interface specified by Handle and Protocol is not +currently open by AgentHandle and ControllerHandle. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_CLOSE_PROTOCOL)( +IN EFI_HANDLE Handle, +IN EFI_GUID *Protocol, +IN EFI_HANDLE AgentHandle, +IN EFI_HANDLE ControllerHandle +); + +/// +/// EFI Oprn Protocol Information Entry +/// +typedef struct { + EFI_HANDLE AgentHandle; + EFI_HANDLE ControllerHandle; + UINT32 Attributes; + UINT32 OpenCount; +} EFI_OPEN_PROTOCOL_INFORMATION_ENTRY; + +/** +Retrieves the list of agents that currently have a protocol interface opened. + +@param Handle The handle for the protocol interface that is being queried. +@param Protocol The published unique identifier of the protocol. +@param EntryBuffer A pointer to a buffer of open protocol information in the form of +EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures. +@param EntryCount A pointer to the number of entries in EntryBuffer. + +@retval EFI_SUCCESS The open protocol information was returned in EntryBuffer, and the +number of entries was returned EntryCount. +@retval EFI_OUT_OF_RESOURCES There are not enough resources available to allocate EntryBuffer. +@retval EFI_NOT_FOUND Handle does not support the protocol specified by Protocol. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION)( +IN EFI_HANDLE Handle, +IN EFI_GUID *Protocol, +OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer, +OUT UINTN *EntryCount +); + +/** +Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated +from pool. + +@param Handle The handle from which to retrieve the list of protocol interface +GUIDs. +@param ProtocolBuffer A pointer to the list of protocol interface GUID pointers that are +installed on Handle. +@param ProtocolBufferCount A pointer to the number of GUID pointers present in +ProtocolBuffer. + +@retval EFI_SUCCESS The list of protocol interface GUIDs installed on Handle was returned in +ProtocolBuffer. The number of protocol interface GUIDs was +returned in ProtocolBufferCount. +@retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the results. +@retval EFI_INVALID_PARAMETER Handle is NULL. +@retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE. +@retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL. +@retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_PROTOCOLS_PER_HANDLE)( +IN EFI_HANDLE Handle, +OUT EFI_GUID ***ProtocolBuffer, +OUT UINTN *ProtocolBufferCount +); + +/** +Creates an event that is to be signaled whenever an interface is installed for a specified protocol. + +@param Protocol The numeric ID of the protocol for which the event is to be registered. +@param Event Event that is to be signaled whenever a protocol interface is registered +for Protocol. +@param Registration A pointer to a memory location to receive the registration value. + +@retval EFI_SUCCESS The notification event has been registered. +@retval EFI_OUT_OF_RESOURCES Space for the notification event could not be allocated. +@retval EFI_INVALID_PARAMETER Protocol is NULL. +@retval EFI_INVALID_PARAMETER Event is NULL. +@retval EFI_INVALID_PARAMETER Registration is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY)( +IN EFI_GUID *Protocol, +IN EFI_EVENT Event, +OUT VOID **Registration +); + +/// +/// Enumeration of EFI Locate Search Types +/// +typedef enum { + /// + /// Retrieve all the handles in the handle database. + /// + AllHandles, + /// + /// Retrieve the next handle fron a RegisterProtocolNotify() event. + /// + ByRegisterNotify, + /// + /// Retrieve the set of handles from the handle database that support a + /// specified protocol. + /// + ByProtocol +} EFI_LOCATE_SEARCH_TYPE; + +/** +Returns an array of handles that support a specified protocol. + +@param SearchType Specifies which handle(s) are to be returned. +@param Protocol Specifies the protocol to search by. +@param SearchKey Specifies the search key. +@param BufferSize On input, the size in bytes of Buffer. On output, the size in bytes of +the array returned in Buffer (if the buffer was large enough) or the +size, in bytes, of the buffer needed to obtain the array (if the buffer was +not large enough). +@param Buffer The buffer in which the array is returned. + +@retval EFI_SUCCESS The array of handles was returned. +@retval EFI_NOT_FOUND No handles match the search. +@retval EFI_BUFFER_TOO_SMALL The BufferSize is too small for the result. +@retval EFI_INVALID_PARAMETER SearchType is not a member of EFI_LOCATE_SEARCH_TYPE. +@retval EFI_INVALID_PARAMETER SearchType is ByRegisterNotify and SearchKey is NULL. +@retval EFI_INVALID_PARAMETER SearchType is ByProtocol and Protocol is NULL. +@retval EFI_INVALID_PARAMETER One or more matches are found and BufferSize is NULL. +@retval EFI_INVALID_PARAMETER BufferSize is large enough for the result and Buffer is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_LOCATE_HANDLE)( +IN EFI_LOCATE_SEARCH_TYPE SearchType, +IN EFI_GUID *Protocol, OPTIONAL +IN VOID *SearchKey, OPTIONAL +IN OUT UINTN *BufferSize, +OUT EFI_HANDLE *Buffer +); + +/** +Locates the handle to a device on the device path that supports the specified protocol. + +@param Protocol Specifies the protocol to search for. +@param DevicePath On input, a pointer to a pointer to the device path. On output, the device +path pointer is modified to point to the remaining part of the device +path. +@param Device A pointer to the returned device handle. + +@retval EFI_SUCCESS The resulting handle was returned. +@retval EFI_NOT_FOUND No handles match the search. +@retval EFI_INVALID_PARAMETER Protocol is NULL. +@retval EFI_INVALID_PARAMETER DevicePath is NULL. +@retval EFI_INVALID_PARAMETER A handle matched the search and Device is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_LOCATE_DEVICE_PATH)( +IN EFI_GUID *Protocol, +IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, +OUT EFI_HANDLE *Device +); + +/** +Adds, updates, or removes a configuration table entry from the EFI System Table. + +@param Guid A pointer to the GUID for the entry to add, update, or remove. +@param Table A pointer to the configuration table for the entry to add, update, or +remove. May be NULL. + +@retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed. +@retval EFI_NOT_FOUND An attempt was made to delete a nonexistent entry. +@retval EFI_INVALID_PARAMETER Guid is NULL. +@retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE)( +IN EFI_GUID *Guid, +IN VOID *Table +); + +/** +Returns an array of handles that support the requested protocol in a buffer allocated from pool. + +@param SearchType Specifies which handle(s) are to be returned. +@param Protocol Provides the protocol to search by. +This parameter is only valid for a SearchType of ByProtocol. +@param SearchKey Supplies the search key depending on the SearchType. +@param NoHandles The number of handles returned in Buffer. +@param Buffer A pointer to the buffer to return the requested array of handles that +support Protocol. + +@retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of +handles in Buffer was returned in NoHandles. +@retval EFI_NOT_FOUND No handles match the search. +@retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results. +@retval EFI_INVALID_PARAMETER NoHandles is NULL. +@retval EFI_INVALID_PARAMETER Buffer is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_LOCATE_HANDLE_BUFFER)( +IN EFI_LOCATE_SEARCH_TYPE SearchType, +IN EFI_GUID *Protocol, OPTIONAL +IN VOID *SearchKey, OPTIONAL +IN OUT UINTN *NoHandles, +OUT EFI_HANDLE **Buffer +); + +/** +Returns the first protocol instance that matches the given protocol. + +@param Protocol Provides the protocol to search for. +@param Registration Optional registration key returned from +RegisterProtocolNotify(). +@param Interface On return, a pointer to the first interface that matches Protocol and +Registration. + +@retval EFI_SUCCESS A protocol instance matching Protocol was found and returned in +Interface. +@retval EFI_NOT_FOUND No protocol instances were found that match Protocol and +Registration. +@retval EFI_INVALID_PARAMETER Interface is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_LOCATE_PROTOCOL)( +IN EFI_GUID *Protocol, +IN VOID *Registration, OPTIONAL +OUT VOID **Interface +); + +/// +/// EFI Capsule Block Descriptor +/// +typedef struct { + /// + /// Length in bytes of the data pointed to by DataBlock/ContinuationPointer. + /// + UINT64 Length; + union { + /// + /// Physical address of the data block. This member of the union is + /// used if Length is not equal to zero. + /// + EFI_PHYSICAL_ADDRESS DataBlock; + /// + /// Physical address of another block of + /// EFI_CAPSULE_BLOCK_DESCRIPTOR structures. This + /// member of the union is used if Length is equal to zero. If + /// ContinuationPointer is zero this entry represents the end of the list. + /// + EFI_PHYSICAL_ADDRESS ContinuationPointer; + } Union; +} EFI_CAPSULE_BLOCK_DESCRIPTOR; + +/// +/// EFI Capsule Header. +/// +typedef struct { + /// + /// A GUID that defines the contents of a capsule. + /// + EFI_GUID CapsuleGuid; + /// + /// The size of the capsule header. This may be larger than the size of + /// the EFI_CAPSULE_HEADER since CapsuleGuid may imply + /// extended header entries + /// + UINT32 HeaderSize; + /// + /// Bit-mapped list describing the capsule attributes. The Flag values + /// of 0x0000 - 0xFFFF are defined by CapsuleGuid. Flag values + /// of 0x10000 - 0xFFFFFFFF are defined by this specification + /// + UINT32 Flags; + /// + /// Size in bytes of the capsule. + /// + UINT32 CapsuleImageSize; +} EFI_CAPSULE_HEADER; + +/// +/// The EFI System Table entry must point to an array of capsules +/// that contain the same CapsuleGuid value. The array must be +/// prefixed by a UINT32 that represents the size of the array of capsules. +/// +typedef struct { + /// + /// the size of the array of capsules. + /// + UINT32 CapsuleArrayNumber; + /// + /// Point to an array of capsules that contain the same CapsuleGuid value. + /// + VOID* CapsulePtr[1]; +} EFI_CAPSULE_TABLE; + +#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 +#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 +#define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 + +/** +Passes capsules to the firmware with both virtual and physical mapping. Depending on the intended +consumption, the firmware may process the capsule immediately. If the payload should persist +across a system reset, the reset value returned from EFI_QueryCapsuleCapabilities must +be passed into ResetSystem() and will cause the capsule to be processed by the firmware as +part of the reset process. + +@param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules +being passed into update capsule. +@param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in +CaspuleHeaderArray. +@param ScatterGatherList Physical pointer to a set of +EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the +location in physical memory of a set of capsules. + +@retval EFI_SUCCESS Valid capsule was passed. If +CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the +capsule has been successfully processed by the firmware. +@retval EFI_INVALID_PARAMETER CapsuleSize is NULL, or an incompatible set of flags were +set in the capsule header. +@retval EFI_INVALID_PARAMETER CapsuleCount is 0. +@retval EFI_DEVICE_ERROR The capsule update was started, but failed due to a device error. +@retval EFI_UNSUPPORTED The capsule type is not supported on this platform. +@retval EFI_OUT_OF_RESOURCES There were insufficient resources to process the capsule. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_UPDATE_CAPSULE)( +IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, +IN UINTN CapsuleCount, +IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL +); + +/** +Returns if the capsule can be supported via UpdateCapsule(). + +@param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules +being passed into update capsule. +@param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in +CaspuleHeaderArray. +@param MaxiumCapsuleSize On output the maximum size that UpdateCapsule() can +support as an argument to UpdateCapsule() via +CapsuleHeaderArray and ScatterGatherList. +@param ResetType Returns the type of reset required for the capsule update. + +@retval EFI_SUCCESS Valid answer returned. +@retval EFI_UNSUPPORTED The capsule type is not supported on this platform, and +MaximumCapsuleSize and ResetType are undefined. +@retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL. +@retval EFI_OUT_OF_RESOURCES There were insufficient resources to process the query request. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES)( +IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, +IN UINTN CapsuleCount, +OUT UINT64 *MaximumCapsuleSize, +OUT EFI_RESET_TYPE *ResetType +); + +/** +Returns information about the EFI variables. + +@param Attributes Attributes bitmask to specify the type of variables on +which to return information. +@param MaximumVariableStorageSize On output the maximum size of the storage space +available for the EFI variables associated with the +attributes specified. +@param RemainingVariableStorageSize Returns the remaining size of the storage space +available for the EFI variables associated with the +attributes specified. +@param MaximumVariableSize Returns the maximum size of the individual EFI +variables associated with the attributes specified. + +@retval EFI_SUCCESS Valid answer returned. +@retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied +@retval EFI_UNSUPPORTED The attribute is not supported on this platform, and the +MaximumVariableStorageSize, +RemainingVariableStorageSize, MaximumVariableSize +are undefined. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_QUERY_VARIABLE_INFO)( +IN UINT32 Attributes, +OUT UINT64 *MaximumVariableStorageSize, +OUT UINT64 *RemainingVariableStorageSize, +OUT UINT64 *MaximumVariableSize +); + + +// +// EFI Runtime Services Table +// +#define EFI_SYSTEM_TABLE_SIGNATURE SIGNATURE_64 ('I','B','I',' ','S','Y','S','T') +#define EFI_2_31_SYSTEM_TABLE_REVISION ((2 << 16) | (31)) +#define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30)) +#define EFI_2_20_SYSTEM_TABLE_REVISION ((2 << 16) | (20)) +#define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | (10)) +#define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | (00)) +#define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | (10)) +#define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | (02)) +#define EFI_SYSTEM_TABLE_REVISION EFI_2_31_SYSTEM_TABLE_REVISION + +#define EFI_RUNTIME_SERVICES_SIGNATURE SIGNATURE_64 ('R','U','N','T','S','E','R','V') +#define EFI_RUNTIME_SERVICES_REVISION EFI_2_31_SYSTEM_TABLE_REVISION + +/// +/// EFI Runtime Services Table. +/// +typedef struct { + /// + /// The table header for the EFI Runtime Services Table. + /// + EFI_TABLE_HEADER Hdr; + + // + // Time Services + // + EFI_GET_TIME GetTime; + EFI_SET_TIME SetTime; + EFI_GET_WAKEUP_TIME GetWakeupTime; + EFI_SET_WAKEUP_TIME SetWakeupTime; + + // + // Virtual Memory Services + // + EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap; + EFI_CONVERT_POINTER ConvertPointer; + + // + // Variable Services + // + EFI_GET_VARIABLE GetVariable; + EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName; + EFI_SET_VARIABLE SetVariable; + + // + // Miscellaneous Services + // + EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount; + EFI_RESET_SYSTEM ResetSystem; + + // + // UEFI 2.0 Capsule Services + // + EFI_UPDATE_CAPSULE UpdateCapsule; + EFI_QUERY_CAPSULE_CAPABILITIES QueryCapsuleCapabilities; + + // + // Miscellaneous UEFI 2.0 Service + // + EFI_QUERY_VARIABLE_INFO QueryVariableInfo; +} EFI_RUNTIME_SERVICES; + + +#define EFI_BOOT_SERVICES_SIGNATURE SIGNATURE_64 ('B','O','O','T','S','E','R','V') +#define EFI_BOOT_SERVICES_REVISION EFI_2_31_SYSTEM_TABLE_REVISION + +/// +/// EFI Boot Services Table. +/// +typedef struct { + /// + /// The table header for the EFI Boot Services Table. + /// + EFI_TABLE_HEADER Hdr; + + // + // Task Priority Services + // + EFI_RAISE_TPL RaiseTPL; + EFI_RESTORE_TPL RestoreTPL; + + // + // Memory Services + // + EFI_ALLOCATE_PAGES AllocatePages; + EFI_FREE_PAGES FreePages; + EFI_GET_MEMORY_MAP GetMemoryMap; + EFI_ALLOCATE_POOL AllocatePool; + EFI_FREE_POOL FreePool; + + // + // Event & Timer Services + // + EFI_CREATE_EVENT CreateEvent; + EFI_SET_TIMER SetTimer; + EFI_WAIT_FOR_EVENT WaitForEvent; + EFI_SIGNAL_EVENT SignalEvent; + EFI_CLOSE_EVENT CloseEvent; + EFI_CHECK_EVENT CheckEvent; + + // + // Protocol Handler Services + // + EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface; + EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface; + EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface; + EFI_HANDLE_PROTOCOL HandleProtocol; + VOID *Reserved; + EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify; + EFI_LOCATE_HANDLE LocateHandle; + EFI_LOCATE_DEVICE_PATH LocateDevicePath; + EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable; + + // + // Image Services + // + EFI_IMAGE_LOAD LoadImage; + EFI_IMAGE_START StartImage; + EFI_EXIT Exit; + EFI_IMAGE_UNLOAD UnloadImage; + EFI_EXIT_BOOT_SERVICES ExitBootServices; + + // + // Miscellaneous Services + // + EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; + EFI_STALL Stall; + EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; + + // + // DriverSupport Services + // + EFI_CONNECT_CONTROLLER ConnectController; + EFI_DISCONNECT_CONTROLLER DisconnectController; + + // + // Open and Close Protocol Services + // + EFI_OPEN_PROTOCOL OpenProtocol; + EFI_CLOSE_PROTOCOL CloseProtocol; + EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation; + + // + // Library Services + // + EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle; + EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer; + EFI_LOCATE_PROTOCOL LocateProtocol; + EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces; + EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces; + + // + // 32-bit CRC Services + // + EFI_CALCULATE_CRC32 CalculateCrc32; + + // + // Miscellaneous Services + // + EFI_COPY_MEM CopyMem; + EFI_SET_MEM SetMem; + EFI_CREATE_EVENT_EX CreateEventEx; +} EFI_BOOT_SERVICES; + +/// +/// Contains a set of GUID/pointer pairs comprised of the ConfigurationTable field in the +/// EFI System Table. +/// +typedef struct { + /// + /// The 128-bit GUID value that uniquely identifies the system configuration table. + /// + EFI_GUID VendorGuid; + /// + /// A pointer to the table associated with VendorGuid. + /// + VOID *VendorTable; +} EFI_CONFIGURATION_TABLE; + +/// +/// EFI System Table +/// +typedef struct { + /// + /// The table header for the EFI System Table. + /// + EFI_TABLE_HEADER Hdr; + /// + /// A pointer to a null terminated string that identifies the vendor + /// that produces the system firmware for the platform. + /// + CHAR16 *FirmwareVendor; + /// + /// A firmware vendor specific value that identifies the revision + /// of the system firmware for the platform. + /// + UINT32 FirmwareRevision; + /// + /// The handle for the active console input device. This handle must support + /// EFI_SIMPLE_TEXT_INPUT_PROTOCOL and EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL. + /// + EFI_HANDLE ConsoleInHandle; + /// + /// A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that is + /// associated with ConsoleInHandle. + /// + EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn; + /// + /// The handle for the active console output device. + /// + EFI_HANDLE ConsoleOutHandle; + /// + /// A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface + /// that is associated with ConsoleOutHandle. + /// + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut; + /// + /// The handle for the active standard error console device. + /// This handle must support the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. + /// + EFI_HANDLE StandardErrorHandle; + /// + /// A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface + /// that is associated with StandardErrorHandle. + /// + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *StdErr; + /// + /// A pointer to the EFI Runtime Services Table. + /// + EFI_RUNTIME_SERVICES *RuntimeServices; + /// + /// A pointer to the EFI Boot Services Table. + /// + EFI_BOOT_SERVICES *BootServices; + /// + /// The number of system configuration tables in the buffer ConfigurationTable. + /// + UINTN NumberOfTableEntries; + /// + /// A pointer to the system configuration tables. + /// The number of entries in the table is NumberOfTableEntries. + /// + EFI_CONFIGURATION_TABLE *ConfigurationTable; +} EFI_SYSTEM_TABLE; + +/** +This is the declaration of an EFI image entry point. This entry point is +the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including +both device drivers and bus drivers. + +@param ImageHandle The firmware allocated handle for the UEFI image. +@param SystemTable A pointer to the EFI System Table. + +@retval EFI_SUCCESS The operation completed successfully. +@retval Others An unexpected error occurred. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IMAGE_ENTRY_POINT)( +IN EFI_HANDLE ImageHandle, +IN EFI_SYSTEM_TABLE *SystemTable +); + +// +// EFI Load Options Attributes +// +#define LOAD_OPTION_ACTIVE 0x00000001 +#define LOAD_OPTION_FORCE_RECONNECT 0x00000002 +#define LOAD_OPTION_HIDDEN 0x00000008 +#define LOAD_OPTION_CATEGORY 0x00001F00 + +#define LOAD_OPTION_CATEGORY_BOOT 0x00000000 +#define LOAD_OPTION_CATEGORY_APP 0x00000100 + +#define EFI_BOOT_OPTION_SUPPORT_KEY 0x00000001 +#define EFI_BOOT_OPTION_SUPPORT_APP 0x00000002 +#define EFI_BOOT_OPTION_SUPPORT_COUNT 0x00000300 + +/// +/// EFI Boot Key Data +/// +typedef union { + struct { + /// + /// Indicates the revision of the EFI_KEY_OPTION structure. This revision level should be 0. + /// + UINT32 Revision : 8; + /// + /// Either the left or right Shift keys must be pressed (1) or must not be pressed (0). + /// + UINT32 ShiftPressed : 1; + /// + /// Either the left or right Control keys must be pressed (1) or must not be pressed (0). + /// + UINT32 ControlPressed : 1; + /// + /// Either the left or right Alt keys must be pressed (1) or must not be pressed (0). + /// + UINT32 AltPressed : 1; + /// + /// Either the left or right Logo keys must be pressed (1) or must not be pressed (0). + /// + UINT32 LogoPressed : 1; + /// + /// The Menu key must be pressed (1) or must not be pressed (0). + /// + UINT32 MenuPressed : 1; + /// + /// The SysReq key must be pressed (1) or must not be pressed (0). + /// + UINT32 SysReqPressed : 1; + UINT32 Reserved : 16; + /// + /// Specifies the actual number of entries in EFI_KEY_OPTION.Keys, from 0-3. If + /// zero, then only the shift state is considered. If more than one, then the boot option will + /// only be launched if all of the specified keys are pressed with the same shift state. + /// + UINT32 InputKeyCount : 2; + } Options; + UINT32 PackedValue; +} EFI_BOOT_KEY_DATA; + +/// +/// EFI Key Option. +/// +typedef struct { + /// + /// Specifies options about how the key will be processed. + /// + EFI_BOOT_KEY_DATA KeyData; + /// + /// The CRC-32 which should match the CRC-32 of the entire EFI_LOAD_OPTION to + /// which BootOption refers. If the CRC-32s do not match this value, then this key + /// option is ignored. + /// + UINT32 BootOptionCrc; + /// + /// The Boot#### option which will be invoked if this key is pressed and the boot option + /// is active (LOAD_OPTION_ACTIVE is set). + /// + UINT16 BootOption; + /// + /// The key codes to compare against those returned by the + /// EFI_SIMPLE_TEXT_INPUT and EFI_SIMPLE_TEXT_INPUT_EX protocols. + /// The number of key codes (0-3) is specified by the EFI_KEY_CODE_COUNT field in KeyOptions. + /// + //EFI_INPUT_KEY Keys[]; +} EFI_KEY_OPTION; + +// +// EFI File location to boot from on removable media devices +// +#define EFI_REMOVABLE_MEDIA_FILE_NAME_IA32 L"\\EFI\\BOOT\\BOOTIA32.EFI" +#define EFI_REMOVABLE_MEDIA_FILE_NAME_IA64 L"\\EFI\\BOOT\\BOOTIA64.EFI" +#define EFI_REMOVABLE_MEDIA_FILE_NAME_X64 L"\\EFI\\BOOT\\BOOTX64.EFI" +#define EFI_REMOVABLE_MEDIA_FILE_NAME_ARM L"\\EFI\\BOOT\\BOOTARM.EFI" + +#if defined (MDE_CPU_IA32) +#define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_IA32 +#elif defined (MDE_CPU_IPF) +#define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_IA64 +#elif defined (MDE_CPU_X64) +#define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_X64 +#elif defined (MDE_CPU_EBC) +#elif defined (MDE_CPU_ARM) +#define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_ARM +#else +#error Unknown Processor Type +#endif + +//#include +//#include +//#include + +#endif \ No newline at end of file diff --git a/reactos/boot/environ/include/efi/WinCertificate.h b/reactos/boot/environ/include/efi/WinCertificate.h new file mode 100644 index 00000000000..7a1f42276c6 --- /dev/null +++ b/reactos/boot/environ/include/efi/WinCertificate.h @@ -0,0 +1,128 @@ +/** @file +GUID for UEFI WIN_CERTIFICATE structure. + +Copyright (c) 2006 - 2010, 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. + +@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 diff --git a/reactos/boot/environ/lib/arch/.gitignore b/reactos/boot/environ/lib/arch/.gitignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/reactos/boot/environ/lib/bd/.gitignore b/reactos/boot/environ/lib/bd/.gitignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/reactos/boot/environ/lib/bootlib.c b/reactos/boot/environ/lib/bootlib.c new file mode 100644 index 00000000000..7da2dbe4d1c --- /dev/null +++ b/reactos/boot/environ/lib/bootlib.c @@ -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; +} + diff --git a/reactos/boot/environ/lib/firmware/.gitignore b/reactos/boot/environ/lib/firmware/.gitignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/reactos/boot/environ/lib/io/.gitignore b/reactos/boot/environ/lib/io/.gitignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/reactos/boot/environ/lib/mc/.gitignore b/reactos/boot/environ/lib/mc/.gitignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/reactos/boot/environ/lib/misc/util.c b/reactos/boot/environ/lib/misc/util.c new file mode 100644 index 00000000000..c7d0c40277d --- /dev/null +++ b/reactos/boot/environ/lib/misc/util.c @@ -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; + } +} + diff --git a/reactos/boot/environ/lib/mm/foo.c b/reactos/boot/environ/lib/mm/foo.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/reactos/boot/environ/lib/platform/.gitignore b/reactos/boot/environ/lib/platform/.gitignore new file mode 100644 index 00000000000..e69de29bb2d