Author: ion
Date: Sun Sep 6 03:02:56 2015
New Revision: 69043
URL:
http://svn.reactos.org/svn/reactos?rev=69043&view=rev
Log:
[BOOTMGFW]:
- Use the right settings to make our CD UEFI compatible. The Internet says this is
supposed to be 10000x harder, but it seems to work fine, at least in Virtual Box.
- Implement an EarlyPrint routine for early debugging/testing.
- Using the above, fix a bunch of stupid bugs. The previously committed code now seems to
work (so far).
Modified:
trunk/reactos/boot/environ/CMakeLists.txt
trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
trunk/reactos/boot/environ/app/bootmgr/efiemu.c
trunk/reactos/boot/environ/include/bl.h
trunk/reactos/boot/environ/lib/bootlib.c
Modified: trunk/reactos/boot/environ/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/CMakeLists.tx…
==============================================================================
--- trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] Sun Sep 6 03:02:56 2015
@@ -72,5 +72,5 @@
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)
Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/b…
==============================================================================
--- trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] Sun Sep 6 03:02:56
2015
@@ -9,6 +9,11 @@
/* INCLUDES ******************************************************************/
#include "bootmgr.h"
+
+/* DATA VARIABLES ************************************************************/
+
+ULONGLONG ApplicationStartTime;
+ULONGLONG PostTime;
/* FUNCTIONS *****************************************************************/
@@ -33,8 +38,23 @@
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;
}
Modified: trunk/reactos/boot/environ/app/bootmgr/efiemu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/e…
==============================================================================
--- trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] Sun Sep 6 03:02:56 2015
@@ -244,7 +244,7 @@
/* 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 @@
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 @@
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 @@
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 @@
{
/* lol */
Status = STATUS_NOT_IMPLEMENTED;
+ EarlyPrint(L"UDP Boot not supported!\n");
}
else
{
@@ -745,6 +748,7 @@
/* Bail out on failure */
if (!NT_SUCCESS(Status))
{
+ EarlyPrint(L"Failed to convert file path: %lx\n", Status);
goto Quickie;
}
@@ -783,6 +787,7 @@
RemainingSize);
if (!NT_SUCCESS(Status))
{
+ EarlyPrint(L"Failed to convert OS device path: %lx\n",
Status);
goto Quickie;
}
@@ -809,6 +814,7 @@
RemainingSize);
if (!NT_SUCCESS(Status))
{
+ EarlyPrint(L"Failed to convert OS file path: %lx\n", Status);
goto Quickie;
}
@@ -895,8 +901,7 @@
(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 @@
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 @@
*
*--*/
EFI_STATUS
+EFIAPI
EfiEntry (
_In_ EFI_HANDLE ImageHandle,
_In_ EFI_SYSTEM_TABLE *SystemTable
@@ -1018,22 +1023,22 @@
{
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;
}
Modified: trunk/reactos/boot/environ/include/bl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
==============================================================================
--- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Sun Sep 6 03:02:56 2015
@@ -26,6 +26,9 @@
#include <Uefi.h>
#include <DevicePath.h>
#include <LoadedImage.h>
+
+VOID
+EarlyPrint(_In_ PWCHAR Format, ...);
/* DEFINES *******************************************************************/
@@ -160,6 +163,7 @@
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 @@
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 @@
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
Modified: trunk/reactos/boot/environ/lib/bootlib.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/bootlib.c…
==============================================================================
--- trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] Sun Sep 6 03:02:56 2015
@@ -23,6 +23,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 @@
(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 @@
if (strncmp(AppEntry->Signature, BL_APP_ENTRY_SIGNATURE, 7))
{
Status = STATUS_INVALID_PARAMETER_9;
+ goto Quickie;
}
/* Read parameters */
@@ -101,9 +125,11 @@
goto Quickie;
}
+ EarlyPrint(L"TODO!\n");
Status = STATUS_NOT_IMPLEMENTED;
Quickie:
+ EarlyPrint(L"Exiting init: %lx\n", Status);
return Status;
}