135 lines
2.4 KiB
C
135 lines
2.4 KiB
C
/*++
|
|
|
|
Copyright (c) 2024, Quinn Stephens.
|
|
Provided under the BSD 3-Clause license.
|
|
|
|
Module Name:
|
|
|
|
bootmgr.h
|
|
|
|
Abstract:
|
|
|
|
Boot manager definitions.
|
|
|
|
--*/
|
|
|
|
#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
|
|
|
|
//
|
|
// No address translation.
|
|
//
|
|
#define BOOT_TRANSLATION_TYPE 0
|
|
|
|
//
|
|
// Use EFI page size.
|
|
//
|
|
#define PAGE_SIZE EFI_PAGE_SIZE
|
|
#define PAGE_SHIFT EFI_PAGE_SHIFT
|
|
|
|
#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;
|
|
|
|
#define BOOT_APPLICATION_ENTRY_SIGNATURE 0x544e4550415442 /* "BTAPENT" */
|
|
|
|
#define BOOT_APPLICATION_ENTRY_BCD_IDENTIFIER_NOT_SET 0x01
|
|
|
|
typedef struct {
|
|
ULONGLONG Signature;
|
|
ULONG Attributes;
|
|
GUID BcdIdentifier;
|
|
} BOOT_APPLICATION_ENTRY, *PBOOT_APPLICATION_ENTRY;
|
|
|
|
#define BOOT_MEMORY_INFO_VERSION 1
|
|
|
|
typedef struct {
|
|
ULONG Version;
|
|
ULONG MdlOffset;
|
|
ULONG DescriptorCount;
|
|
ULONG DescriptorSize;
|
|
ULONG BasePageOffset;
|
|
} BOOT_MEMORY_INFO, *PBOOT_MEMORY_INFO;
|
|
|
|
#define MEMORY_ATTRIBUTE_CACHE_WB 0x08
|
|
|
|
#define MEMORY_TYPE_BOOT_APPLICATION 0xd0000002
|
|
|
|
typedef struct {
|
|
LIST_ENTRY ListEntry;
|
|
|
|
ULONGLONG BasePage;
|
|
ULONG Pages;
|
|
|
|
ULONG Attributes;
|
|
ULONG Type;
|
|
} BOOT_MEMORY_DESCRIPTOR, *PBOOT_MEMORY_DESCRIPTOR;
|
|
|
|
#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 {
|
|
ULONG Size;
|
|
} BOOT_DEVICE, *PBOOT_DEVICE;
|
|
|
|
NTSTATUS
|
|
BmMain (
|
|
IN PBOOT_INPUT_PARAMETERS InputParameters
|
|
);
|
|
|
|
#endif
|