[BOOT] Huge refactor
This commit is contained in:
@@ -17,19 +17,21 @@ Abstract:
|
||||
#include "bootlib.h"
|
||||
|
||||
#define MIN_INPUT_PARAMETERS_SIZE ( \
|
||||
sizeof(BOOT_INPUT_PARAMETERS) + \
|
||||
sizeof(BOOT_APPLICATION_PARAMETERS) + \
|
||||
sizeof(BOOT_MEMORY_INFO) + \
|
||||
sizeof(BOOT_INIT_APPLICATION_ENTRY) + \
|
||||
sizeof(BOOT_FIRMWARE_DATA) + \
|
||||
sizeof(BOOT_RETURN_DATA) \
|
||||
)
|
||||
|
||||
PBOOT_INPUT_PARAMETERS BlpApplicationParameters;
|
||||
BOOT_APPLICATION_ENTRY BlpApplicationEntry;
|
||||
PBOOT_DEVICE BlpBootDevice;
|
||||
PBOOT_APPLICATION_PARAMETERS BlpApplicationParameters;
|
||||
BOOT_LIBRARY_PARAMETERS BlpLibraryParameters;
|
||||
BOOT_APPLICATION_ENTRY BlpApplicationEntry;
|
||||
|
||||
NTSTATUS
|
||||
InitializeLibrary (
|
||||
IN PBOOT_INPUT_PARAMETERS InputParameters,
|
||||
IN PBOOT_APPLICATION_PARAMETERS ApplicationParameters,
|
||||
IN PBOOT_LIBRARY_PARAMETERS LibraryParameters
|
||||
)
|
||||
|
||||
@@ -41,7 +43,7 @@ Routine Description:
|
||||
|
||||
Arguments:
|
||||
|
||||
InputParameters - Pointer to the application's input parameters.
|
||||
ApplicationParameters - Pointer to the application's input parameters.
|
||||
|
||||
LibraryParameters - Pointer to the library parameters.
|
||||
|
||||
@@ -54,23 +56,21 @@ Return Value:
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PBOOT_MEMORY_INFO MemoryInfo;
|
||||
PBOOT_INPUT_APPLICATION_ENTRY ApplicationEntry;
|
||||
PBOOT_INIT_APPLICATION_ENTRY ApplicationEntry;
|
||||
PBOOT_FIRMWARE_DATA FirmwareData;
|
||||
PBOOT_BLOCK_IDENTIFIER BlockDevice;
|
||||
PBOOT_APPLICATION_OPTION Option;
|
||||
|
||||
(VOID)LibraryParameters;
|
||||
|
||||
if (InputParameters == NULL ||
|
||||
InputParameters->Signature != BOOT_INPUT_PARAMETERS_SIGNATURE ||
|
||||
InputParameters->Size < MIN_INPUT_PARAMETERS_SIZE) {
|
||||
if (ApplicationParameters == NULL ||
|
||||
ApplicationParameters->Signature != BOOT_APPLICATION_PARAMETERS_SIGNATURE ||
|
||||
ApplicationParameters->Size < MIN_INPUT_PARAMETERS_SIZE) {
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
MemoryInfo = (PBOOT_MEMORY_INFO)((PUCHAR)InputParameters + InputParameters->MemoryInfoOffset);
|
||||
ApplicationEntry = (PBOOT_INPUT_APPLICATION_ENTRY)((PUCHAR)InputParameters + InputParameters->ApplicationEntryOffset);
|
||||
BlpBootDevice = (PBOOT_DEVICE)((PUCHAR)InputParameters + InputParameters->BootDeviceOffset);
|
||||
FirmwareData = (PBOOT_FIRMWARE_DATA)((PUCHAR)InputParameters + InputParameters->FirmwareDataOffset);
|
||||
MemoryInfo = (PBOOT_MEMORY_INFO)((PUCHAR)ApplicationParameters + ApplicationParameters->MemoryInfoOffset);
|
||||
ApplicationEntry = (PBOOT_INIT_APPLICATION_ENTRY)((PUCHAR)ApplicationParameters + ApplicationParameters->ApplicationEntryOffset);
|
||||
BlpBootDevice = (PBOOT_DEVICE)((PUCHAR)ApplicationParameters + ApplicationParameters->BootDeviceOffset);
|
||||
FirmwareData = (PBOOT_FIRMWARE_DATA)((PUCHAR)ApplicationParameters + ApplicationParameters->FirmwareDataOffset);
|
||||
|
||||
//
|
||||
// Initialize firmware library.
|
||||
@@ -83,24 +83,28 @@ Return Value:
|
||||
}
|
||||
|
||||
ConsolePrint(L"> Alcyone EFI Boot Manager\r\n");
|
||||
ConsolePrintf(L"Image base: %x %x\r\nImage size: %x\r\n", HIDWORD((ULONG_PTR)InputParameters->ImageBase), LODWORD((ULONG_PTR)InputParameters->ImageBase), InputParameters->ImageSize);
|
||||
|
||||
ConsolePrintf(L"Image base: %x %x\r\nImage size: %x\r\n", HIDWORD((ULONG_PTR)ApplicationParameters->ImageBase), LODWORD((ULONG_PTR)ApplicationParameters->ImageBase), ApplicationParameters->ImageSize);
|
||||
DebugPrint(L"Initializing boot library...\r\n");
|
||||
|
||||
if (ApplicationEntry->Signature != BOOT_INPUT_APPLICATION_ENTRY_SIGNATURE) {
|
||||
if (ApplicationEntry->Signature != BOOT_INIT_APPLICATION_ENTRY_SIGNATURE) {
|
||||
DebugPrint(L"InitializeLibrary(): ApplicationEntry Signature is invalid\r\n");
|
||||
return STATUS_INVALID_PARAMETER_9;
|
||||
}
|
||||
|
||||
//
|
||||
// Save input parameters and application entry.
|
||||
// Save library and application parameters.
|
||||
//
|
||||
BlpApplicationParameters = ApplicationParameters;
|
||||
RtlCopyMemory(&BlpLibraryParameters, LibraryParameters, sizeof(BOOT_LIBRARY_PARAMETERS));
|
||||
|
||||
//
|
||||
// Save application entry.
|
||||
//
|
||||
BlpApplicationParameters = InputParameters;
|
||||
BlpApplicationEntry.Attributes = ApplicationEntry->Attributes;
|
||||
RtlCopyMemory(&BlpApplicationEntry.BcdIdentifier, &ApplicationEntry->BcdIdentifier, sizeof(GUID));
|
||||
BlpApplicationEntry.Options = &ApplicationEntry->Options;
|
||||
|
||||
Status = BlpMmInitialize(MemoryInfo, InputParameters->TranslationType, LibraryParameters);
|
||||
Status = BlpMmInitialize(MemoryInfo, ApplicationParameters->TranslationType, LibraryParameters);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
return Status;
|
||||
}
|
||||
@@ -110,7 +114,7 @@ Return Value:
|
||||
|
||||
NTSTATUS
|
||||
BlInitializeLibrary (
|
||||
IN PBOOT_INPUT_PARAMETERS InputParameters,
|
||||
IN PBOOT_APPLICATION_PARAMETERS ApplicationParameters,
|
||||
IN PBOOT_LIBRARY_PARAMETERS LibraryParameters
|
||||
)
|
||||
|
||||
@@ -122,7 +126,7 @@ Routine Description:
|
||||
|
||||
Arguments:
|
||||
|
||||
InputParameters - Pointer to the application's input parameters.
|
||||
ApplicationParameters - Pointer to the application's input parameters.
|
||||
|
||||
LibraryParameters - Pointer to the library parameters.
|
||||
|
||||
@@ -133,7 +137,7 @@ Return Value:
|
||||
--*/
|
||||
|
||||
{
|
||||
return InitializeLibrary(InputParameters, LibraryParameters);
|
||||
return InitializeLibrary(ApplicationParameters, LibraryParameters);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
Reference in New Issue
Block a user