diff --git a/reactos/boot/environ/CMakeLists.txt b/reactos/boot/environ/CMakeLists.txt index bdac762caaa..a88f65cfcaf 100644 --- a/reactos/boot/environ/CMakeLists.txt +++ b/reactos/boot/environ/CMakeLists.txt @@ -72,5 +72,5 @@ endif() add_dependencies(bootmgfw asm bugcodes) -add_cd_file(TARGET bootmgfw FILE ${_bootmgfw_output_file} DESTINATION loader NO_CAB FOR bootcd regtest) +add_cd_file(TARGET bootmgfw FILE ${_bootmgfw_output_file} DESTINATION efi/boot NO_CAB FOR bootcd regtest NAME_ON_CD bootia32.efi) diff --git a/reactos/boot/environ/app/bootmgr/bootmgr.c b/reactos/boot/environ/app/bootmgr/bootmgr.c index 60888bc691e..b948d53ea0f 100644 --- a/reactos/boot/environ/app/bootmgr/bootmgr.c +++ b/reactos/boot/environ/app/bootmgr/bootmgr.c @@ -10,6 +10,11 @@ #include "bootmgr.h" +/* DATA VARIABLES ************************************************************/ + +ULONGLONG ApplicationStartTime; +ULONGLONG PostTime; + /* FUNCTIONS *****************************************************************/ /*++ @@ -33,8 +38,23 @@ BmMain ( NTSTATUS Status; BL_LIBRARY_PARAMETERS LibraryParameters; + EarlyPrint(L"ReactOS UEFI Boot Manager Initializing...\n"); + + /* Save the start/end-of-POST time */ + ApplicationStartTime = __rdtsc(); + PostTime = ApplicationStartTime; + + /* Setup the boot library parameters for this application */ + BlSetupDefaultParameters(&LibraryParameters); + LibraryParameters.TranslationType = BlNone; + LibraryParameters.LibraryFlags = 0x400 | 0x8; + LibraryParameters.MinimumAllocationCount = 16; + LibraryParameters.MinimumHeapSize = 512 * 1024; + + /* Initialize the boot library */ Status = BlInitializeLibrary(BootParameters, &LibraryParameters); + EarlyPrint(L"ReactOS UEFI Boot Manager Exiting: %lx\n", Status); return Status; } diff --git a/reactos/boot/environ/app/bootmgr/efiemu.c b/reactos/boot/environ/app/bootmgr/efiemu.c index 1ca8189e472..35f48f8dcf2 100644 --- a/reactos/boot/environ/app/bootmgr/efiemu.c +++ b/reactos/boot/environ/app/bootmgr/efiemu.c @@ -244,7 +244,7 @@ EfiInitpConvertEfiFilePath ( /* Get the length of the file path string, avoiding overflow */ StringLength = DevicePathNodeLength(FilePath) - FIELD_OFFSET(FILEPATH_DEVICE_PATH, PathName); - if (StringLength < FIELD_OFFSET(FILEPATH_DEVICE_PATH, PathName)) + if (StringLength < (ULONG)FIELD_OFFSET(FILEPATH_DEVICE_PATH, PathName)) { Status = STATUS_INTEGER_OVERFLOW; goto Quickie; @@ -285,7 +285,7 @@ EfiInitpConvertEfiFilePath ( if (PathString == StringEntry->String) { /* Then this option is empty */ - Option->Failed = TRUE; + Option->Empty = TRUE; } /* Set the final size of the option */ @@ -668,6 +668,7 @@ EfiInitpCreateApplicationEntry ( RemainingSize = MaximumLength; if (RemainingSize < sizeof(BL_APPLICATION_ENTRY)) { + EarlyPrint(L"Remaining size too small!\n"); Status = STATUS_INVALID_PARAMETER; goto Quickie; } @@ -711,7 +712,8 @@ EfiInitpCreateApplicationEntry ( if (!NT_SUCCESS(Status)) { /* We failed, so mark the option as such and return an empty one */ - Entry->BcdData.Failed = TRUE; + EarlyPrint(L"Failed to convert device path: %lx\n", Status); + Entry->BcdData.Empty = TRUE; TotalOptionSize = sizeof(BL_BCD_OPTION); goto Quickie; } @@ -732,6 +734,7 @@ EfiInitpCreateApplicationEntry ( { /* lol */ Status = STATUS_NOT_IMPLEMENTED; + EarlyPrint(L"UDP Boot not supported!\n"); } else { @@ -745,6 +748,7 @@ EfiInitpCreateApplicationEntry ( /* Bail out on failure */ if (!NT_SUCCESS(Status)) { + EarlyPrint(L"Failed to convert file path: %lx\n", Status); goto Quickie; } @@ -783,6 +787,7 @@ EfiInitpCreateApplicationEntry ( RemainingSize); if (!NT_SUCCESS(Status)) { + EarlyPrint(L"Failed to convert OS device path: %lx\n", Status); goto Quickie; } @@ -809,6 +814,7 @@ EfiInitpCreateApplicationEntry ( RemainingSize); if (!NT_SUCCESS(Status)) { + EarlyPrint(L"Failed to convert OS file path: %lx\n", Status); goto Quickie; } @@ -895,8 +901,7 @@ EfiInitCreateInputParametersEx ( (VOID**)&LoadedImage); if (Status != EFI_SUCCESS) { - SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, - L"Loaded image failed\n"); + EarlyPrint(L"Loaded image failed: %lx\n", Status); return NULL; } @@ -905,13 +910,12 @@ EfiInitCreateInputParametersEx ( EfiInitScratch.ImageSize = (ULONG)LoadedImage->ImageSize; /* Now grab our device path protocol, so we can convert the path later on */ - Status = BootServices->HandleProtocol(ImageHandle, + Status = BootServices->HandleProtocol(LoadedImage->DeviceHandle, &EfiDevicePathProtocol, (VOID**)&DevicePath); if (Status != EFI_SUCCESS) { - SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, - L"Device path failed\n"); + EarlyPrint(L"Device Path failed: %lx\n", Status); return NULL; } @@ -1011,6 +1015,7 @@ EfiInitCreateInputParametersEx ( * *--*/ EFI_STATUS +EFIAPI EfiEntry ( _In_ EFI_HANDLE ImageHandle, _In_ EFI_SYSTEM_TABLE *SystemTable @@ -1018,22 +1023,22 @@ EfiEntry ( { NTSTATUS Status; PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters; + extern EFI_SYSTEM_TABLE *g_SystemTable; /* Temporary debugging string */ - SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, L"Hello from EFI\n"); + g_SystemTable = SystemTable; /* 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"); + EarlyPrint(L"EFI Input Conversion failed\n"); Status = STATUS_INVALID_PARAMETER; } diff --git a/reactos/boot/environ/include/bl.h b/reactos/boot/environ/include/bl.h index d982e895723..bf61e0a8cdf 100644 --- a/reactos/boot/environ/include/bl.h +++ b/reactos/boot/environ/include/bl.h @@ -27,6 +27,9 @@ #include #include +VOID +EarlyPrint(_In_ PWCHAR Format, ...); + /* DEFINES *******************************************************************/ #define BL_APPLICATION_FLAG_CONVERTED_FROM_EFI 0x01 @@ -160,6 +163,7 @@ typedef struct _BL_LIBRARY_PARAMETERS ULONG HeapAllocationAttributes; PWCHAR ApplicationBaseDirectory; ULONG DescriptorCount; + PWCHAR FontBaseDirectory; } BL_LIBRARY_PARAMETERS, *PBL_LIBRARY_PARAMETERS; /* This should eventually go into a more public header */ @@ -243,7 +247,7 @@ typedef struct _BL_BCD_OPTION ULONG DataSize; ULONG ListOffset; ULONG NextEntryOffset; - ULONG Failed; + ULONG Empty; } BL_BCD_OPTION, *PBL_BCD_OPTION; typedef struct _BL_APPLICATION_ENTRY @@ -354,6 +358,30 @@ typedef struct _BL_ARCH_CONTEXT ULONG ContextFlags; } BL_ARCH_CONTEXT, *PBL_ARCH_CONTEXT; +/* INLINE ROUTINES ***********************************************************/ + +FORCEINLINE +VOID +BlSetupDefaultParameters ( + _Out_ PBL_LIBRARY_PARAMETERS LibraryParameters + ) +{ + BL_LIBRARY_PARAMETERS DefaultParameters = + { + 0x20, + BlVirtual, + 1024, + 2 * 1024 * 1024, + 0, + NULL, + 0, + NULL + }; + + /* Copy the defaults */ + RtlCopyMemory(LibraryParameters, &DefaultParameters, sizeof(*LibraryParameters)); +} + /* INITIALIZATION ROUTINES ***************************************************/ NTSTATUS diff --git a/reactos/boot/environ/lib/bootlib.c b/reactos/boot/environ/lib/bootlib.c index 7efb04e91ae..da676ffb9a4 100644 --- a/reactos/boot/environ/lib/bootlib.c +++ b/reactos/boot/environ/lib/bootlib.c @@ -24,6 +24,28 @@ BL_TRANSLATION_TYPE MmTranslationType; /* FUNCTIONS *****************************************************************/ +/* HACKKKYYY */ +EFI_SYSTEM_TABLE* g_SystemTable; + +VOID +EarlyPrint(_In_ PWCHAR Format, ...) +{ + WCHAR buffer[1024]; + va_list args; + + va_start(args, Format); + + vswprintf(buffer, Format, args); + + g_SystemTable->ConOut->OutputString(g_SystemTable->ConOut, L"\r"); + g_SystemTable->ConOut->OutputString(g_SystemTable->ConOut, buffer); + + g_SystemTable->BootServices->Stall(1000000); + + va_end(args); +} +/* END HACKKKYYY */ + /*++ * @name InitializeLibrary * @@ -57,7 +79,8 @@ InitializeLibrary ( (BootAppParameters->Signature[1] != BOOT_APPLICATION_SIGNATURE_2) || (BootAppParameters->Size < sizeof(*BootAppParameters))) { - return STATUS_INVALID_PARAMETER; + Status = STATUS_INVALID_PARAMETER; + goto Quickie; } /* Get sub-structures */ @@ -78,6 +101,7 @@ InitializeLibrary ( if (strncmp(AppEntry->Signature, BL_APP_ENTRY_SIGNATURE, 7)) { Status = STATUS_INVALID_PARAMETER_9; + goto Quickie; } /* Read parameters */ @@ -101,9 +125,11 @@ InitializeLibrary ( goto Quickie; } + EarlyPrint(L"TODO!\n"); Status = STATUS_NOT_IMPLEMENTED; Quickie: + EarlyPrint(L"Exiting init: %lx\n", Status); return Status; }