[BOOT] Execution contexts and more refactoring
This commit is contained in:
@@ -25,6 +25,12 @@ Abstract:
|
||||
#define PAGE_SHIFT EFI_PAGE_SHIFT
|
||||
#endif /* _EFI */
|
||||
|
||||
//
|
||||
// Address translation types.
|
||||
//
|
||||
#define TRANSLATION_TYPE_NONE 0
|
||||
#define TRANSLATION_TYPE_MAX 1
|
||||
|
||||
//
|
||||
// Set machine type.
|
||||
//
|
||||
@@ -34,11 +40,48 @@ Abstract:
|
||||
#define BOOT_MACHINE_TYPE IMAGE_FILE_MACHINE_I386
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
typedef struct __attribute__((packed)) {
|
||||
USHORT Limit;
|
||||
ULONG_PTR Base;
|
||||
} DESCRIPTOR_TABLE_REGISTER, *PDESCRIPTOR_TABLE_REGISTER;
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
DESCRIPTOR_TABLE_REGISTER Gdt;
|
||||
DESCRIPTOR_TABLE_REGISTER Idt;
|
||||
USHORT LdtSelector;
|
||||
USHORT CS, DS, ES, FS, GS, SS;
|
||||
} DESCRIPTOR_TABLE_CONTEXT, *PDESCRIPTOR_TABLE_CONTEXT;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Address translation types.
|
||||
// Firmware platform flags.
|
||||
//
|
||||
#define TRANSLATION_TYPE_NONE 0
|
||||
#define TRANSLATION_TYPE_MAX 1
|
||||
|
||||
#define FIRMWARE_FLAG_EXECUTION_CONTEXT_SUPPORTED 0x00100000
|
||||
|
||||
//
|
||||
// Execution contexts represent the current state
|
||||
// of the processor/system.
|
||||
//
|
||||
|
||||
typedef enum {
|
||||
ExecutionContextApplication,
|
||||
ExecutionContextFirmware,
|
||||
ExecutionContextMax
|
||||
} EXECUTION_CONTEXT_TYPE;
|
||||
|
||||
#define EXECUTION_CONTEXT_INTERRUPTS_ENABLED 0x02
|
||||
#define EXECUTION_CONTEXT_PAGING_ENABLED 0x04
|
||||
|
||||
typedef struct {
|
||||
EXECUTION_CONTEXT_TYPE Type;
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
ULONG_PTR Cr3;
|
||||
#endif
|
||||
ULONG Flags;
|
||||
DESCRIPTOR_TABLE_CONTEXT DescriptorTableContext;
|
||||
} EXECUTION_CONTEXT, *PEXECUTION_CONTEXT;
|
||||
|
||||
//
|
||||
// Application entry option.
|
||||
@@ -181,6 +224,11 @@ typedef struct {
|
||||
ULONG Reserved;
|
||||
EFI_HANDLE ImageHandle;
|
||||
EFI_SYSTEM_TABLE *SystemTable;
|
||||
ULONG Reserved2;
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
ULONG_PTR Cr3;
|
||||
#endif
|
||||
DESCRIPTOR_TABLE_CONTEXT DescriptorTableContext;
|
||||
} BOOT_FIRMWARE_DATA, *PBOOT_FIRMWARE_DATA;
|
||||
|
||||
#define BOOT_RETURN_DATA_VERSION 1
|
||||
@@ -191,28 +239,6 @@ typedef struct {
|
||||
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.
|
||||
@@ -376,17 +402,6 @@ typedef struct {
|
||||
BOOT_DEVICE Device;
|
||||
} BCDE_DEVICE, *PBCDE_DEVICE;
|
||||
|
||||
VOID
|
||||
ConsolePrint (
|
||||
IN PWSTR String
|
||||
);
|
||||
|
||||
VOID
|
||||
ConsolePrintf (
|
||||
IN PWSTR Format,
|
||||
...
|
||||
);
|
||||
|
||||
//
|
||||
// Enable/disable debug printing.
|
||||
//
|
||||
@@ -398,11 +413,38 @@ ConsolePrintf (
|
||||
#define DebugPrintf(Format, ...)
|
||||
#endif
|
||||
|
||||
extern PEXECUTION_CONTEXT CurrentExecutionContext;
|
||||
|
||||
VOID
|
||||
ConsolePrint (
|
||||
IN PWSTR String
|
||||
);
|
||||
|
||||
VOID
|
||||
ConsolePrintf (
|
||||
IN PWSTR Format,
|
||||
...
|
||||
);
|
||||
|
||||
VOID
|
||||
BlpArchGetDescriptorTableContext (
|
||||
PDESCRIPTOR_TABLE_CONTEXT Context
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
BlArchIsFiveLevelPagingActive (
|
||||
);
|
||||
|
||||
VOID
|
||||
BlpArchSwitchContext (
|
||||
IN EXECUTION_CONTEXT_TYPE Type
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
BlpArchInitialize (
|
||||
IN ULONG Stage
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
BlpFwInitialize (
|
||||
IN ULONG Stage,
|
||||
|
@@ -70,6 +70,14 @@ MmMdRemoveRegionFromMdlEx (
|
||||
OUT PMEMORY_DESCRIPTOR_LIST Unused
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
MmMdRemoveRegionFromMdl (
|
||||
IN PMEMORY_DESCRIPTOR_LIST Mdl,
|
||||
IN ULONGLONG RemoveStart,
|
||||
IN ULONGLONG PageCount,
|
||||
IN ULONG Flags
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
MmMdFreeDescriptor (
|
||||
IN PMEMORY_DESCRIPTOR Descriptor
|
||||
|
Reference in New Issue
Block a user