[BOOT] Huge refactor
This commit is contained in:
@@ -17,7 +17,243 @@ Abstract:
|
||||
#define _BOOTLIB_H
|
||||
|
||||
#include <nt.h>
|
||||
#include "bootmgr.h"
|
||||
|
||||
#if defined(_EFI)
|
||||
#include "efi.h"
|
||||
|
||||
#define PAGE_SIZE EFI_PAGE_SIZE
|
||||
#define PAGE_SHIFT EFI_PAGE_SHIFT
|
||||
#endif /* _EFI */
|
||||
|
||||
//
|
||||
// Set machine type.
|
||||
//
|
||||
#if defined(__x86_64__)
|
||||
#define BOOT_MACHINE_TYPE IMAGE_FILE_MACHINE_AMD64
|
||||
#elif defined(__i386__)
|
||||
#define BOOT_MACHINE_TYPE IMAGE_FILE_MACHINE_I386
|
||||
#endif
|
||||
|
||||
//
|
||||
// Address translation types.
|
||||
//
|
||||
#define TRANSLATION_TYPE_NONE 0
|
||||
#define TRANSLATION_TYPE_MAX 1
|
||||
|
||||
//
|
||||
// Application entry option.
|
||||
// Used to represent options passed to a boot
|
||||
// application by whatever started it.
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
ULONG Type;
|
||||
ULONG DataOffset;
|
||||
ULONG DataSize;
|
||||
ULONG OtherOptionsOffset;
|
||||
ULONG NextOptionOffset;
|
||||
BOOLEAN IsInvalid;
|
||||
UCHAR Reserved[3];
|
||||
} BOOT_ENTRY_OPTION, *PBOOT_ENTRY_OPTION;
|
||||
|
||||
//
|
||||
// Application entry.
|
||||
// Used for any boot environment application,
|
||||
// including the boot manager itself.
|
||||
//
|
||||
|
||||
#define BOOT_APPLICATION_ENTRY_NO_BCD_IDENTIFIER 0x01
|
||||
|
||||
typedef struct {
|
||||
ULONG Attributes;
|
||||
GUID BcdIdentifier;
|
||||
PBOOT_ENTRY_OPTION Options;
|
||||
} BOOT_APPLICATION_ENTRY, *PBOOT_APPLICATION_ENTRY;
|
||||
|
||||
//
|
||||
// Initial application entry.
|
||||
// Special form of BOOT_APPLICATION_ENTRY used
|
||||
// when firmware first loads the boot manager.
|
||||
//
|
||||
|
||||
#define BOOT_INIT_APPLICATION_ENTRY_SIGNATURE 0x544e4550415442 /* "BTAPENT" */
|
||||
|
||||
typedef struct {
|
||||
ULONGLONG Signature;
|
||||
ULONG Attributes;
|
||||
GUID BcdIdentifier;
|
||||
UCHAR Reserved[16];
|
||||
BOOT_ENTRY_OPTION Options;
|
||||
} BOOT_INIT_APPLICATION_ENTRY, *PBOOT_INIT_APPLICATION_ENTRY;
|
||||
|
||||
typedef ULONG MEMORY_TYPE;
|
||||
|
||||
//
|
||||
// Memory type classes.
|
||||
//
|
||||
#define MEMORY_CLASS_APPLICATION 0xD
|
||||
#define MEMORY_CLASS_LIBRARY 0xE
|
||||
#define MEMORY_CLASS_SYSTEM 0xF
|
||||
|
||||
//
|
||||
// Memory types.
|
||||
//
|
||||
#define MEMORY_TYPE_BOOT_APPLICATION 0xD0000002
|
||||
#define MEMORY_TYPE_BOOT_APPLICATION_2 0xD0000013
|
||||
#define MEMORY_TYPE_FREE 0xF0000001
|
||||
#define MEMORY_TYPE_UNUSABLE 0xF0000002
|
||||
#define MEMORY_TYPE_RESERVED 0xF0000003
|
||||
#define MEMORY_TYPE_BOOT_SERVICES 0xF0000004
|
||||
#define MEMORY_TYPE_FREE_ZEROED 0xF0000005
|
||||
#define MEMORY_TYPE_RUNTIME_SERVICES_CODE 0xF0000006
|
||||
#define MEMORY_TYPE_PERSISTENT 0xF0000007
|
||||
#define MEMORY_TYPE_ACPI_RECLAIM 0xF0000008
|
||||
#define MEMORY_TYPE_ACPI_NVS 0xF0000009
|
||||
#define MEMORY_TYPE_MMIO 0xF000000A
|
||||
#define MEMORY_TYPE_MMIO_PORT_SPACE 0xF000000B
|
||||
#define MEMORY_TYPE_PAL_CODE 0xF000000C
|
||||
#define MEMORY_TYPE_RUNTIME_SERVICES_DATA 0xF000000E
|
||||
|
||||
//
|
||||
// Memory caching attributes.
|
||||
//
|
||||
#define MEMORY_ATTRIBUTE_UC 0x00000001
|
||||
#define MEMORY_ATTRIBUTE_WC 0x00000002
|
||||
#define MEMORY_ATTRIBUTE_WT 0x00000004
|
||||
#define MEMORY_ATTRIBUTE_WB 0x00000008
|
||||
#define MEMORY_ATTRIBUTE_UCE 0x00000010
|
||||
|
||||
//
|
||||
// Memory protection attributes.
|
||||
//
|
||||
#define MEMORY_ATTRIBUTE_WP 0x00000100
|
||||
#define MEMORY_ATTRIBUTE_RP 0x00000200
|
||||
#define MEMORY_ATTRIBUTE_XP 0x00000400
|
||||
|
||||
//
|
||||
// Memory location attributes.
|
||||
//
|
||||
#define MEMORY_ATTRIBUTE_BELOW_1MIB 0x00080000
|
||||
|
||||
//
|
||||
// Memory runtime mapping attributes.
|
||||
//
|
||||
#define MEMORY_ATTRIBUTE_RUNTIME 0x01000000
|
||||
|
||||
typedef struct {
|
||||
LIST_ENTRY ListEntry;
|
||||
|
||||
ULONGLONG FirstPage;
|
||||
ULONGLONG MappedFirstPage;
|
||||
ULONG PageCount;
|
||||
|
||||
ULONG Attributes;
|
||||
MEMORY_TYPE Type;
|
||||
} MEMORY_DESCRIPTOR, *PMEMORY_DESCRIPTOR;
|
||||
|
||||
typedef enum {
|
||||
MDL_TYPE_PHYSICAL,
|
||||
MDL_TYPE_VIRTUAL
|
||||
} MEMORY_DESCRIPTOR_LIST_TYPE;
|
||||
|
||||
typedef struct {
|
||||
LIST_ENTRY ListEntry;
|
||||
|
||||
PLIST_ENTRY Head;
|
||||
PLIST_ENTRY Current;
|
||||
MEMORY_DESCRIPTOR_LIST_TYPE Type;
|
||||
} MEMORY_DESCRIPTOR_LIST, *PMEMORY_DESCRIPTOR_LIST;
|
||||
|
||||
#define BOOT_MEMORY_INFO_VERSION 1
|
||||
|
||||
typedef struct {
|
||||
ULONG Version;
|
||||
ULONG MdlOffset;
|
||||
ULONG DescriptorCount;
|
||||
ULONG DescriptorSize;
|
||||
ULONG FirstPageOffset;
|
||||
} BOOT_MEMORY_INFO, *PBOOT_MEMORY_INFO;
|
||||
|
||||
#define BOOT_FIRMWARE_DATA_VERSION 2
|
||||
|
||||
typedef struct {
|
||||
ULONG Version;
|
||||
ULONG Reserved;
|
||||
EFI_HANDLE ImageHandle;
|
||||
EFI_SYSTEM_TABLE *SystemTable;
|
||||
} BOOT_FIRMWARE_DATA, *PBOOT_FIRMWARE_DATA;
|
||||
|
||||
#define BOOT_RETURN_DATA_VERSION 1
|
||||
|
||||
typedef struct {
|
||||
ULONG Version;
|
||||
NTSTATUS Status;
|
||||
ULONG Flags;
|
||||
} BOOT_RETURN_DATA, *PBOOT_RETURN_DATA;
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
typedef struct __attribute__((packed)) {
|
||||
USHORT Limit;
|
||||
ULONG_PTR Base;
|
||||
} DESCRIPTOR_TABLE_REGISTER, *PDESCRIPTOR_TABLE_REGISTER;
|
||||
|
||||
typedef struct {
|
||||
DESCRIPTOR_TABLE_REGISTER Gdt;
|
||||
DESCRIPTOR_TABLE_REGISTER Idt;
|
||||
USHORT LdtSelector;
|
||||
USHORT CS, DS, ES, FS, GS, SS;
|
||||
} DESCRIPTOR_TABLE_CONTEXT, *PDESCRIPTOR_TABLE_CONTEXT;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
ULONG Reserved;
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
ULONG_PTR CR3;
|
||||
#endif
|
||||
DESCRIPTOR_TABLE_CONTEXT DescriptorTableContext;
|
||||
} BOOT_PLATFORM_DATA, *PBOOT_PLATFORM_DATA;
|
||||
|
||||
//
|
||||
// Firmware-independent application parameters.
|
||||
// Passed to any boot application's entry point.
|
||||
//
|
||||
|
||||
#define BOOT_APPLICATION_PARAMETERS_SIGNATURE 0x50504120544f4f42 /* "BOOT APP" */
|
||||
#define BOOT_APPLICATION_PARAMETERS_VERSION 2
|
||||
|
||||
typedef struct {
|
||||
ULONGLONG Signature;
|
||||
ULONG Version;
|
||||
ULONG Size;
|
||||
|
||||
//
|
||||
// Machine information.
|
||||
//
|
||||
ULONG MachineType;
|
||||
ULONG TranslationType;
|
||||
|
||||
//
|
||||
// Image information.
|
||||
//
|
||||
PVOID ImageBase;
|
||||
ULONG ImageSize;
|
||||
|
||||
//
|
||||
// Offsets to ancillary structures.
|
||||
//
|
||||
ULONG MemoryInfoOffset;
|
||||
ULONG ApplicationEntryOffset;
|
||||
ULONG BootDeviceOffset;
|
||||
ULONG FirmwareDataOffset;
|
||||
ULONG ReturnDataOffset;
|
||||
ULONG PlatformDataOffset;
|
||||
} BOOT_APPLICATION_PARAMETERS, *PBOOT_APPLICATION_PARAMETERS;
|
||||
|
||||
//
|
||||
// Library parameters.
|
||||
// Specifies how the boot library should be
|
||||
// set up.
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
ULONG Flags;
|
||||
@@ -25,6 +261,121 @@ typedef struct {
|
||||
ULONG MinimumPageAllocation;
|
||||
} BOOT_LIBRARY_PARAMETERS, *PBOOT_LIBRARY_PARAMETERS;
|
||||
|
||||
typedef struct {
|
||||
LARGE_INTEGER ImageBase;
|
||||
ULONG ImageSize;
|
||||
ULONG ImageOffset;
|
||||
} BOOT_RAMDISK_IDENTIFIER, *PBOOT_RAMDISK_IDENTIFIER;
|
||||
|
||||
#define BOOT_HARDDRIVE_PARTITION_TYPE_GPT 0x00
|
||||
#define BOOT_HARDDRIVE_PARTITION_TYPE_MBR 0x01
|
||||
#define BOOT_HARDDRIVE_PARTITION_TYPE_RAW 0x02
|
||||
|
||||
typedef struct {
|
||||
ULONG PartitionType;
|
||||
|
||||
union {
|
||||
struct {
|
||||
ULONG Signature;
|
||||
} Mbr;
|
||||
|
||||
struct {
|
||||
GUID Signature;
|
||||
} Gpt;
|
||||
|
||||
struct {
|
||||
ULONG DriveNumber;
|
||||
} Raw;
|
||||
};
|
||||
} BOOT_HARDDRIVE_IDENTIFIER, *PBOOT_HARDDRIVE_IDENTIFIER;
|
||||
|
||||
typedef struct {
|
||||
ULONG DriveNumber;
|
||||
} BOOT_CDROM_IDENTIFIER, *PBOOT_CDROM_IDENTIFIER;
|
||||
|
||||
#define BOOT_BLOCK_DEVICE_TYPE_HARDDRIVE 0x00
|
||||
#define BOOT_BLOCK_DEVICE_TYPE_CDROM 0x02
|
||||
#define BOOT_BLOCK_DEVICE_TYPE_RAMDISK 0x03
|
||||
|
||||
typedef struct {
|
||||
ULONG Type;
|
||||
|
||||
union {
|
||||
BOOT_RAMDISK_IDENTIFIER Ramdisk;
|
||||
BOOT_HARDDRIVE_IDENTIFIER Harddrive;
|
||||
BOOT_CDROM_IDENTIFIER Cdrom;
|
||||
};
|
||||
} BOOT_BLOCK_IDENTIFIER, *PBOOT_BLOCK_IDENTIFIER;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
ULONG PartitionNumber;
|
||||
} Mbr;
|
||||
|
||||
struct {
|
||||
GUID PartitionIdentifier;
|
||||
} Gpt;
|
||||
|
||||
struct {
|
||||
ULONG BootEntry;
|
||||
} ElTorito;
|
||||
};
|
||||
|
||||
BOOT_BLOCK_IDENTIFIER Parent;
|
||||
} BOOT_PARTITION_IDENTIFIER, *PBOOT_PARTITION_IDENTIFIER;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
PVOID PartitionOffset;
|
||||
} Mbr;
|
||||
|
||||
struct {
|
||||
GUID PartitionIdentifier;
|
||||
} Gpt;
|
||||
|
||||
struct {
|
||||
ULONG BootEntry;
|
||||
} ElTorito;
|
||||
};
|
||||
|
||||
BOOT_BLOCK_IDENTIFIER Parent;
|
||||
} BOOT_PARTITION_IDENTIFIER_EX, *PBOOT_PARTITION_IDENTIFIER_EX;
|
||||
|
||||
#define BOOT_DEVICE_TYPE_BLOCK 0x00
|
||||
#define BOOT_DEVICE_TYPE_PARTITION 0x02
|
||||
#define BOOT_DEVICE_TYPE_PARTITION_EX 0x06
|
||||
|
||||
#define BOOT_DEVICE_ATTRIBUTE_NO_PARENT_SIGNATURE 0x04
|
||||
|
||||
typedef struct {
|
||||
ULONG Type;
|
||||
ULONG Attributes;
|
||||
ULONG Size;
|
||||
ULONG Pad;
|
||||
|
||||
union {
|
||||
BOOT_BLOCK_IDENTIFIER Block;
|
||||
BOOT_PARTITION_IDENTIFIER Partition;
|
||||
BOOT_PARTITION_IDENTIFIER_EX PartitionEx;
|
||||
};
|
||||
} BOOT_DEVICE, *PBOOT_DEVICE;
|
||||
|
||||
typedef ULONG BCDE_DATA_TYPE;
|
||||
|
||||
#define BCDE_DATA_FORMAT_MASK 0x0F000000
|
||||
|
||||
#define BCDE_DATA_FORMAT_DEVICE 0x1
|
||||
|
||||
#define BCDE_DATA_TYPE_APPLICATION_DEVICE 0x11000001
|
||||
#define BCDE_DATA_TYPE_APPLICATION_PATH 0x22000002
|
||||
|
||||
typedef struct {
|
||||
GUID Options;
|
||||
BOOT_DEVICE Device;
|
||||
} BCDE_DEVICE, *PBCDE_DEVICE;
|
||||
|
||||
VOID
|
||||
ConsolePrint (
|
||||
IN PWSTR String
|
||||
@@ -39,7 +390,7 @@ ConsolePrintf (
|
||||
//
|
||||
// Enable/disable debug printing.
|
||||
//
|
||||
#ifdef _DEBUG
|
||||
#if defined(_DEBUG)
|
||||
#define DebugPrint(String) ConsolePrint(String)
|
||||
#define DebugPrintf(Format, ...) ConsolePrintf(Format, __VA_ARGS__)
|
||||
#else
|
||||
@@ -47,14 +398,9 @@ ConsolePrintf (
|
||||
#define DebugPrintf(Format, ...)
|
||||
#endif
|
||||
|
||||
ULONG
|
||||
BlGetBootOptionSize (
|
||||
IN PBOOT_APPLICATION_OPTION Option
|
||||
);
|
||||
|
||||
ULONG
|
||||
BlGetBootOptionListSize (
|
||||
IN PBOOT_APPLICATION_OPTION Options
|
||||
VOID
|
||||
BlpArchGetDescriptorTableContext (
|
||||
PDESCRIPTOR_TABLE_CONTEXT Context
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
@@ -75,9 +421,19 @@ BlpMmInitialize (
|
||||
IN PBOOT_LIBRARY_PARAMETERS LibraryParameters
|
||||
);
|
||||
|
||||
ULONG
|
||||
BlGetBootOptionSize (
|
||||
IN PBOOT_ENTRY_OPTION Option
|
||||
);
|
||||
|
||||
ULONG
|
||||
BlGetBootOptionListSize (
|
||||
IN PBOOT_ENTRY_OPTION Options
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
BlInitializeLibrary (
|
||||
IN PBOOT_INPUT_PARAMETERS InputParameters,
|
||||
IN PBOOT_APPLICATION_PARAMETERS ApplicationParameters,
|
||||
IN PBOOT_LIBRARY_PARAMETERS LibraryParameters
|
||||
);
|
||||
|
||||
|
@@ -16,311 +16,16 @@ Abstract:
|
||||
#ifndef _BOOTMGR_H
|
||||
#define _BOOTMGR_H
|
||||
|
||||
#include <nt.h>
|
||||
#include "efi.h"
|
||||
|
||||
//
|
||||
// Set machine type.
|
||||
//
|
||||
#if defined(__x86_64__)
|
||||
#define BOOT_MACHINE_TYPE IMAGE_FILE_MACHINE_AMD64
|
||||
#elif defined(__i386__)
|
||||
#define BOOT_MACHINE_TYPE IMAGE_FILE_MACHINE_I386
|
||||
#endif
|
||||
|
||||
//
|
||||
// Use EFI page size.
|
||||
//
|
||||
#define PAGE_SIZE EFI_PAGE_SIZE
|
||||
#define PAGE_SHIFT EFI_PAGE_SHIFT
|
||||
|
||||
//
|
||||
// Address translation types.
|
||||
//
|
||||
#define BOOT_TRANSLATION_TYPE_NONE 0
|
||||
#define BOOT_TRANSLATION_TYPE_MAX 1
|
||||
|
||||
#define BOOT_INPUT_PARAMETERS_SIGNATURE 0x50504120544f4f42 /* "BOOT APP" */
|
||||
#define BOOT_INPUT_PARAMETERS_VERSION 2
|
||||
|
||||
typedef struct {
|
||||
ULONGLONG Signature;
|
||||
ULONG Version;
|
||||
ULONG Size;
|
||||
|
||||
//
|
||||
// Machine information.
|
||||
//
|
||||
ULONG MachineType;
|
||||
ULONG TranslationType;
|
||||
|
||||
//
|
||||
// Image information.
|
||||
//
|
||||
PVOID ImageBase;
|
||||
ULONG ImageSize;
|
||||
|
||||
//
|
||||
// Offsets to ancillary structures.
|
||||
//
|
||||
ULONG MemoryInfoOffset;
|
||||
ULONG ApplicationEntryOffset;
|
||||
ULONG BootDeviceOffset;
|
||||
ULONG FirmwareDataOffset;
|
||||
ULONG ReturnDataOffset;
|
||||
ULONG PlatformDataOffset;
|
||||
} BOOT_INPUT_PARAMETERS, *PBOOT_INPUT_PARAMETERS;
|
||||
|
||||
typedef struct {
|
||||
ULONG Type;
|
||||
ULONG DataOffset;
|
||||
ULONG DataSize;
|
||||
ULONG OtherOptionsOffset;
|
||||
ULONG NextOptionOffset;
|
||||
BOOLEAN IsInvalid;
|
||||
UCHAR Unknown[3];
|
||||
} BOOT_APPLICATION_OPTION, *PBOOT_APPLICATION_OPTION;
|
||||
|
||||
#define BOOT_INPUT_APPLICATION_ENTRY_SIGNATURE 0x544e4550415442 /* "BTAPENT" */
|
||||
|
||||
#define BOOT_INPUT_APPLICATION_ENTRY_NO_BCD_IDENTIFIER 0x01
|
||||
|
||||
typedef struct {
|
||||
ULONGLONG Signature;
|
||||
ULONG Attributes;
|
||||
GUID BcdIdentifier;
|
||||
UCHAR Unknown[16];
|
||||
BOOT_APPLICATION_OPTION Options;
|
||||
} BOOT_INPUT_APPLICATION_ENTRY, *PBOOT_INPUT_APPLICATION_ENTRY;
|
||||
|
||||
typedef struct {
|
||||
ULONG Attributes;
|
||||
GUID BcdIdentifier;
|
||||
PBOOT_APPLICATION_OPTION Options;
|
||||
} BOOT_APPLICATION_ENTRY, *PBOOT_APPLICATION_ENTRY;
|
||||
|
||||
#define BOOT_MEMORY_INFO_VERSION 1
|
||||
|
||||
typedef struct {
|
||||
ULONG Version;
|
||||
ULONG MdlOffset;
|
||||
ULONG DescriptorCount;
|
||||
ULONG DescriptorSize;
|
||||
ULONG FirstPageOffset;
|
||||
} BOOT_MEMORY_INFO, *PBOOT_MEMORY_INFO;
|
||||
|
||||
//
|
||||
// Memory descriptor caching attributes.
|
||||
//
|
||||
#define MEMORY_ATTRIBUTE_UC 0x0000000000000001
|
||||
#define MEMORY_ATTRIBUTE_WC 0x0000000000000002
|
||||
#define MEMORY_ATTRIBUTE_WT 0x0000000000000004
|
||||
#define MEMORY_ATTRIBUTE_WB 0x0000000000000008
|
||||
#define MEMORY_ATTRIBUTE_UCE 0x0000000000000010
|
||||
|
||||
//
|
||||
// Memory descriptor protection attributes.
|
||||
//
|
||||
#define MEMORY_ATTRIBUTE_WP 0x000000000000100
|
||||
#define MEMORY_ATTRIBUTE_RP 0x000000000000200
|
||||
#define MEMORY_ATTRIBUTE_XP 0x000000000000400
|
||||
|
||||
//
|
||||
// Memory descriptor location attributes.
|
||||
//
|
||||
#define MEMORY_ATTRIBUTE_BELOW_1MIB 0x80000
|
||||
|
||||
//
|
||||
// Memory descriptor runtime mapping attributes.
|
||||
//
|
||||
#define MEMORY_ATTRIBUTE_RUNTIME 0x1000000
|
||||
|
||||
#define MEMORY_CLASS_APPLICATION 0xD
|
||||
#define MEMORY_CLASS_LIBRARY 0xE
|
||||
#define MEMORY_CLASS_SYSTEM 0xF
|
||||
|
||||
#define MEMORY_TYPE_BOOT_APPLICATION 0xD0000002
|
||||
#define MEMORY_TYPE_BOOT_APPLICATION_2 0xD0000013
|
||||
#define MEMORY_TYPE_FREE 0xF0000001
|
||||
#define MEMORY_TYPE_UNUSABLE 0xF0000002
|
||||
#define MEMORY_TYPE_RESERVED 0xF0000003
|
||||
#define MEMORY_TYPE_BOOT_SERVICES 0xF0000004
|
||||
#define MEMORY_TYPE_FREE_ZEROED 0xF0000005
|
||||
#define MEMORY_TYPE_RUNTIME_SERVICES_CODE 0xF0000006
|
||||
#define MEMORY_TYPE_PERSISTENT 0xF0000007
|
||||
#define MEMORY_TYPE_ACPI_RECLAIM 0xF0000008
|
||||
#define MEMORY_TYPE_ACPI_NVS 0xF0000009
|
||||
#define MEMORY_TYPE_MMIO 0xF000000A
|
||||
#define MEMORY_TYPE_MMIO_PORT_SPACE 0xF000000B
|
||||
#define MEMORY_TYPE_PAL_CODE 0xF000000C
|
||||
#define MEMORY_TYPE_RUNTIME_SERVICES_DATA 0xF000000E
|
||||
|
||||
typedef ULONG MEMORY_TYPE;
|
||||
|
||||
typedef struct {
|
||||
LIST_ENTRY ListEntry;
|
||||
|
||||
ULONGLONG FirstPage;
|
||||
ULONGLONG MappedFirstPage;
|
||||
ULONG PageCount;
|
||||
|
||||
ULONG Attributes;
|
||||
MEMORY_TYPE Type;
|
||||
} MEMORY_DESCRIPTOR, *PMEMORY_DESCRIPTOR;
|
||||
|
||||
typedef enum {
|
||||
MDL_TYPE_PHYSICAL,
|
||||
MDL_TYPE_VIRTUAL
|
||||
} MEMORY_DESCRIPTOR_LIST_TYPE;
|
||||
|
||||
typedef struct {
|
||||
LIST_ENTRY ListEntry;
|
||||
|
||||
PLIST_ENTRY Head;
|
||||
PLIST_ENTRY Current;
|
||||
MEMORY_DESCRIPTOR_LIST_TYPE Type;
|
||||
} MEMORY_DESCRIPTOR_LIST, *PMEMORY_DESCRIPTOR_LIST;
|
||||
|
||||
#define BOOT_FIRMWARE_DATA_VERSION 2
|
||||
|
||||
typedef struct {
|
||||
ULONG Version;
|
||||
ULONG Reserved;
|
||||
EFI_HANDLE ImageHandle;
|
||||
EFI_SYSTEM_TABLE *SystemTable;
|
||||
} BOOT_FIRMWARE_DATA, *PBOOT_FIRMWARE_DATA;
|
||||
|
||||
#define BOOT_RETURN_DATA_VERSION 1
|
||||
|
||||
typedef struct {
|
||||
ULONG Version;
|
||||
NTSTATUS Status;
|
||||
ULONG Flags;
|
||||
} BOOT_RETURN_DATA, *PBOOT_RETURN_DATA;
|
||||
|
||||
typedef struct {
|
||||
LARGE_INTEGER ImageBase;
|
||||
ULONG ImageSize;
|
||||
ULONG ImageOffset;
|
||||
} BOOT_RAMDISK_IDENTIFIER, *PBOOT_RAMDISK_IDENTIFIER;
|
||||
|
||||
#define BOOT_HARDDRIVE_PARTITION_TYPE_GPT 0x00
|
||||
#define BOOT_HARDDRIVE_PARTITION_TYPE_MBR 0x01
|
||||
#define BOOT_HARDDRIVE_PARTITION_TYPE_RAW 0x02
|
||||
|
||||
typedef struct {
|
||||
ULONG PartitionType;
|
||||
|
||||
union {
|
||||
struct {
|
||||
ULONG Signature;
|
||||
} Mbr;
|
||||
|
||||
struct {
|
||||
GUID Signature;
|
||||
} Gpt;
|
||||
|
||||
struct {
|
||||
ULONG DriveNumber;
|
||||
} Raw;
|
||||
};
|
||||
} BOOT_HARDDRIVE_IDENTIFIER, *PBOOT_HARDDRIVE_IDENTIFIER;
|
||||
|
||||
typedef struct {
|
||||
ULONG DriveNumber;
|
||||
} BOOT_CDROM_IDENTIFIER, *PBOOT_CDROM_IDENTIFIER;
|
||||
|
||||
#define BOOT_BLOCK_DEVICE_TYPE_HARDDRIVE 0x00
|
||||
#define BOOT_BLOCK_DEVICE_TYPE_CDROM 0x02
|
||||
#define BOOT_BLOCK_DEVICE_TYPE_RAMDISK 0x03
|
||||
|
||||
typedef struct {
|
||||
ULONG Type;
|
||||
|
||||
union {
|
||||
BOOT_RAMDISK_IDENTIFIER Ramdisk;
|
||||
BOOT_HARDDRIVE_IDENTIFIER Harddrive;
|
||||
BOOT_CDROM_IDENTIFIER Cdrom;
|
||||
};
|
||||
} BOOT_BLOCK_IDENTIFIER, *PBOOT_BLOCK_IDENTIFIER;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
ULONG PartitionNumber;
|
||||
} Mbr;
|
||||
|
||||
struct {
|
||||
GUID PartitionIdentifier;
|
||||
} Gpt;
|
||||
|
||||
struct {
|
||||
ULONG BootEntry;
|
||||
} ElTorito;
|
||||
};
|
||||
|
||||
BOOT_BLOCK_IDENTIFIER Parent;
|
||||
} BOOT_PARTITION_IDENTIFIER, *PBOOT_PARTITION_IDENTIFIER;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
PVOID PartitionOffset;
|
||||
} Mbr;
|
||||
|
||||
struct {
|
||||
GUID PartitionIdentifier;
|
||||
} Gpt;
|
||||
|
||||
struct {
|
||||
ULONG BootEntry;
|
||||
} ElTorito;
|
||||
};
|
||||
|
||||
BOOT_BLOCK_IDENTIFIER Parent;
|
||||
} BOOT_PARTITION_IDENTIFIER_EX, *PBOOT_PARTITION_IDENTIFIER_EX;
|
||||
|
||||
#define BOOT_DEVICE_TYPE_BLOCK 0x00
|
||||
#define BOOT_DEVICE_TYPE_PARTITION 0x02
|
||||
#define BOOT_DEVICE_TYPE_PARTITION_EX 0x06
|
||||
|
||||
#define BOOT_DEVICE_ATTRIBUTE_NO_PARENT_SIGNATURE 0x04
|
||||
|
||||
typedef struct {
|
||||
ULONG Type;
|
||||
ULONG Attributes;
|
||||
ULONG Size;
|
||||
ULONG Pad;
|
||||
|
||||
union {
|
||||
BOOT_BLOCK_IDENTIFIER Block;
|
||||
BOOT_PARTITION_IDENTIFIER Partition;
|
||||
BOOT_PARTITION_IDENTIFIER_EX PartitionEx;
|
||||
};
|
||||
} BOOT_DEVICE, *PBOOT_DEVICE;
|
||||
|
||||
#define BCDE_DATA_FORMAT_MASK 0x0F000000
|
||||
|
||||
#define BCDE_DATA_FORMAT_DEVICE 1
|
||||
|
||||
typedef enum {
|
||||
BCDE_DATA_TYPE_APPLICATION_DEVICE = 0x11000001,
|
||||
BCDE_DATA_TYPE_APPLICATION_PATH = 0x22000002
|
||||
} BCDE_DATA_TYPE;
|
||||
|
||||
typedef struct {
|
||||
GUID OtherOptions;
|
||||
BOOT_DEVICE Device;
|
||||
} BCDE_DEVICE, *PBCDE_DEVICE;
|
||||
#include "bootlib.h"
|
||||
|
||||
NTSTATUS
|
||||
BmOpenDataStore (
|
||||
IN OUT PHANDLE DataStore
|
||||
IN OUT PHANDLE Handle
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
BmMain (
|
||||
IN PBOOT_INPUT_PARAMETERS InputParameters
|
||||
IN PBOOT_APPLICATION_PARAMETERS ApplicationParameters
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -16,10 +16,17 @@ Abstract:
|
||||
#ifndef _EFILIB_H
|
||||
#define _EFILIB_H
|
||||
|
||||
#include "bootmgr.h"
|
||||
#include "bootlib.h"
|
||||
#include "efi.h"
|
||||
|
||||
PBOOT_INPUT_PARAMETERS
|
||||
PBOOT_APPLICATION_PARAMETERS
|
||||
EfiInitCreateInputParametersEx (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable,
|
||||
IN ULONG Flags
|
||||
);
|
||||
|
||||
PBOOT_APPLICATION_PARAMETERS
|
||||
EfiInitCreateInputParameters (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
|
Reference in New Issue
Block a user