Author: ion
Date: Mon Sep 7 06:00:37 2015
New Revision: 69078
URL:
http://svn.reactos.org/svn/reactos?rev=69078&view=rev
Log:
[BOOTMGFW]
- Fix text console bugs. It works now both when already at 80x25, as well as when using
UEFI Shell to switch to 100x31 first. Tested with Virtual Box.
Modified:
trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
trunk/reactos/boot/environ/lib/bootlib.c
trunk/reactos/boot/environ/lib/mm/heapalloc.c
trunk/reactos/boot/environ/lib/mm/pagealloc.c
trunk/reactos/boot/environ/lib/platform/display.c
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] Mon Sep 7 06:00:37
2015
@@ -55,6 +55,7 @@
Status = BlInitializeLibrary(BootParameters, &LibraryParameters);
EarlyPrint(L"ReactOS UEFI Boot Manager Exiting: %lx\n", Status);
+ EfiStall(3000000);
return Status;
}
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] Mon Sep 7 06:00:37 2015
@@ -347,7 +347,6 @@
Status = STATUS_SUCCESS;
Quickie:
- EarlyPrint(L"Exiting init: %lx\n", Status);
return Status;
}
Modified: trunk/reactos/boot/environ/lib/mm/heapalloc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/heapal…
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/heapalloc.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/mm/heapalloc.c [iso-8859-1] Mon Sep 7 06:00:37 2015
@@ -537,7 +537,6 @@
{
/* The heap is ready! */
HapInitializationStatus = 1;
- EarlyPrint(L"Heap Allocator Initialized!\n");
Status = STATUS_SUCCESS;
}
Modified: trunk/reactos/boot/environ/lib/mm/pagealloc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/pageal…
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/pagealloc.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/mm/pagealloc.c [iso-8859-1] Mon Sep 7 06:00:37 2015
@@ -560,7 +560,6 @@
if (NT_SUCCESS(Status))
{
/* The Page Allocator has initialized */
- EarlyPrint(L"Page Allocator initialized\n");
PapInitializationStatus = TRUE;
Status = STATUS_SUCCESS;
}
Modified: trunk/reactos/boot/environ/lib/platform/display.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/platform/…
==============================================================================
--- trunk/reactos/boot/environ/lib/platform/display.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/platform/display.c [iso-8859-1] Mon Sep 7 06:00:37
2015
@@ -147,7 +147,7 @@
BL_DISPLAY_MODE ConsoleTextResolutionList[1] =
{
- {80, 31, 80}
+ {80, 25, 80}
};
NTSTATUS
@@ -231,14 +231,15 @@
while (List != ListEnd)
{
/* Does this resolution match? */
- if ((Mode->HRes != List->HRes) || (Mode->VRes != List->VRes))
- {
- /* Try another one*/
- List++;
- }
-
- /* Yep -- we got a match */
- return TRUE;
+ if ((Mode->HRes == List->HRes) && (Mode->VRes ==
List->VRes))
+ {
+ /* Yep -- we got a match */
+ return TRUE;
+
+ }
+
+ /* Try another one*/
+ List++;
}
/* No matches were found */
@@ -250,6 +251,7 @@
_In_ UINT32 Attributes
)
{
+ /* Read the foreground color attribute and convert to CGA color index */
switch (Attributes & 0x0F)
{
case EFI_BLACK:
@@ -293,6 +295,7 @@
_In_ UINT32 Attributes
)
{
+ /* Read the background color attribute and convert to CGA color index */
switch (Attributes & 0xF0)
{
case EFI_BACKGROUND_MAGENTA:
@@ -301,8 +304,8 @@
return Brown;
case EFI_BACKGROUND_LIGHTGRAY:
return White;
+ case EFI_BACKGROUND_BLACK:
default:
- case EFI_BACKGROUND_BLACK:
return Black;
case EFI_BACKGROUND_RED:
return Red;
@@ -320,6 +323,7 @@
_In_ BL_COLOR Color
)
{
+ /* Convert the CGA color index into an EFI background attribute */
switch (Color)
{
case Blue:
@@ -355,6 +359,7 @@
_In_ BL_COLOR Color
)
{
+ /* Convert the CGA color index into an EFI foreground attribute */
switch (Color)
{
case Black:
@@ -433,43 +438,49 @@
ULONG FgColor, BgColor, Attribute, XPos, YPos, TextHeight, TextWidth;
BOOLEAN Visible;
- Status = STATUS_SUCCESS;
-
+ /* Check if foreground state is being set */
if (Mask & 1)
{
+ /* Check if there's a difference from current */
FgColor = State->FgColor;
-
if (TextConsole->State.FgColor != FgColor)
{
- if (FgColor >= 16)
+ /* Ignore invalid color */
+ if (FgColor > White)
{
return STATUS_INVALID_PARAMETER;
}
- Attribute = ConsoleEfiTextGetAttribute(TextConsole->State.BgColor,
FgColor);
+ /* Convert from NT/CGA format to EFI, and then set the attribute */
+ Attribute = ConsoleEfiTextGetAttribute(TextConsole->State.BgColor,
+ FgColor);
Status = EfiConOutSetAttribute(TextConsole->Protocol, Attribute);
-
-
if (!NT_SUCCESS(Status))
{
return Status;
}
+ /* Update cached state */
TextConsole->State.FgColor = FgColor;
}
}
+ /* Check if background state is being set */
if (Mask & 2)
{
+ /* Check if there's a difference from current */
BgColor = State->BgColor;
if (TextConsole->State.BgColor != BgColor)
{
- if (BgColor >= 16)
+ /* Ignore invalid color */
+ if (BgColor > White)
{
return STATUS_INVALID_PARAMETER;
}
- Attribute = ConsoleEfiTextGetAttribute(BgColor,
TextConsole->State.FgColor);
+ /* Convert from NT/CGA format to EFI, and then set the attribute */
+ Attribute = ConsoleEfiTextGetAttribute(BgColor,
+ TextConsole->State.FgColor);
Status = EfiConOutSetAttribute(TextConsole->Protocol, Attribute);
if (!NT_SUCCESS(Status))
@@ -477,53 +488,63 @@
return Status;
}
+ /* Update cached state */
TextConsole->State.BgColor = BgColor;
}
}
+ /* Check if position state is being set */
if (Mask & 4)
{
+ /* Check if there's a difference from current */
XPos = State->XPos;
YPos = State->YPos;
-
- if ((TextConsole->State.XPos != XPos) || (TextConsole->State.YPos !=
YPos))
- {
+ if ((TextConsole->State.XPos != XPos) ||
+ (TextConsole->State.YPos != YPos))
+ {
+ /* Set the new cursor position */
BlDisplayGetTextCellResolution(&TextWidth, &TextHeight);
Status = EfiConOutSetCursorPosition(TextConsole->Protocol,
XPos/ TextWidth,
YPos / TextHeight);
-
if (!NT_SUCCESS(Status))
{
return Status;
}
+ /* Update cached state */
TextConsole->State.XPos = XPos;
TextConsole->State.YPos = YPos;
}
}
+ /* Check if cursor state is being set */
if (Mask & 8)
{
+ /* Check if there's a difference from current */
Visible = State->CursorVisible;
if (TextConsole->State.CursorVisible != Visible)
{
+ /* Ignore invalid state */
if (Visible >= 3)
{
return STATUS_INVALID_PARAMETER;
}
+ /* Set the new cursor state */
Status = EfiConOutEnableCursor(TextConsole->Protocol, Visible);
if (!NT_SUCCESS(Status))
{
return Status;
}
+ /* Update cached status */
TextConsole->State.CursorVisible = Visible;
}
}
- return Status;
+ /* Return success */
+ return STATUS_SUCCESS;
}
NTSTATUS
@@ -560,6 +581,7 @@
}
/* Scan all the EFI modes */
+ EarlyPrint(L"Scanning through %d modes\n", MaxMode);
for (MaxQueriedMode = 0, Mode = 0; Mode < MaxMode; Mode++)
{
/* Query information on this mode */
@@ -570,10 +592,11 @@
&VRes)))
{
/* This mode was succesfully queried. Save the data */
+ EarlyPrint(L"EFI Firmware Supported Mode %d is H: %d V: %d\n",
Mode, HRes, VRes);
ModeEntry->HRes = HRes;
ModeEntry->VRes = VRes;
ModeEntry->HRes2 = HRes;
- MaxQueriedMode = Mode;
+ MaxQueriedMode = Mode + 1;
}
}
@@ -582,10 +605,11 @@
{
/* Loop all the UEFI queried modes */
SupportedModeEntry = &SupportedModes[i];
- for (MatchingMode = 0; MatchingMode < MaxQueriedMode; MatchingMode)
+ for (MatchingMode = 0; MatchingMode < MaxQueriedMode; MatchingMode++)
{
/* Check if the UEFI mode is compatible with our supported mode */
ModeEntry = &ModeList[MatchingMode];
+ EarlyPrint(L"H1: %d V1: %d - H2: %d - V2: %d\n",
ModeEntry->HRes, ModeEntry->VRes, SupportedModeEntry->HRes,
SupportedModeEntry->VRes);
if ((ModeEntry->HRes == SupportedModeEntry->HRes) &&
(ModeEntry->VRes == SupportedModeEntry->VRes))
{
@@ -655,16 +679,19 @@
if (!ConsolepFindResolution(&DisplayMode, ConsoleTextResolutionList, 1))
{
/* It isn't -- find a matching EFI mode for what we need */
+ EarlyPrint(L"In incorrect mode, scanning for right one\n");
Status = ConsoleEfiTextFindModeFromAllowed(EfiConOut,
ConsoleTextResolutionList,
1,
&Mode);
if (!NT_SUCCESS(Status))
{
+ EarlyPrint(L"Failed to find mode: %lx\n", Status);
return Status;
}
/* Set the new EFI mode */
+ EarlyPrint(L"Setting new mode: %d\n", Mode);
Status = EfiConOutSetMode(EfiConOut, Mode);
if (!NT_SUCCESS(Status))
{
@@ -773,7 +800,7 @@
VOID
)
{
- EarlyPrint(L"Disabling graphics\n");
+ //EarlyPrint(L"Disabling graphics\n");
return TRUE;
}
@@ -796,6 +823,7 @@
Status = ConsoleFirmwareTextOpen(TextConsole);
if (!NT_SUCCESS(Status))
{
+ EarlyPrint(L"Failed to activate console: %lx\n", Status);
return Status;
}
}
@@ -815,6 +843,7 @@
if (!NT_SUCCESS(Status))
{
/* We failed, back down */
+ EarlyPrint(L"Failed to set console state: %lx\n", Status);
ConsoleFirmwareTextClose(TextConsole);
return Status;
}
@@ -850,11 +879,11 @@
InitializeListHead(&BfiFontFileListHead);
/* Allocate the font rectangle */
- BfiGraphicsRectangle = BlMmAllocateHeap(0x5A);
- if (!BfiGraphicsRectangle)
- {
- return STATUS_NO_MEMORY;
- }
+ // BfiGraphicsRectangle = BlMmAllocateHeap(0x5A);
+ //if (!BfiGraphicsRectangle)
+ //{
+ //return STATUS_NO_MEMORY;
+ //}
/* Display re-initialization not yet handled */
if (LibraryParameters.LibraryFlags & BL_LIBRARY_FLAG_REINITIALIZE_ALL)