diff --git a/Docs/Configuration.pdf b/Docs/Configuration.pdf index 7d516ef0..9c1b936c 100644 Binary files a/Docs/Configuration.pdf and b/Docs/Configuration.pdf differ diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex index 61b1a578..9ec38288 100755 --- a/Docs/Configuration.tex +++ b/Docs/Configuration.tex @@ -6782,7 +6782,9 @@ functioning. Feature highlights: there is an obvious benefit as it may result in issues such as slower scrolling. This renderer fully supports \texttt{AppleEg2Info} protocol and will provide - screen rotation for all EFI applications. + screen rotation for all EFI applications. In order to provide seamless rotation + compatibility with \texttt{EfiBoot}, builtin \texttt{AppleFramebufferInfo} should + also be used, i.e. it may need to be overridden on Mac EFI. \item \texttt{GopPassThrough}\\ diff --git a/Docs/Differences/Differences.pdf b/Docs/Differences/Differences.pdf index c3e0b89c..797f7f95 100644 Binary files a/Docs/Differences/Differences.pdf and b/Docs/Differences/Differences.pdf differ diff --git a/Docs/Differences/Differences.tex b/Docs/Differences/Differences.tex index aa640b10..53ed016e 100644 --- a/Docs/Differences/Differences.tex +++ b/Docs/Differences/Differences.tex @@ -1,7 +1,7 @@ \documentclass[]{article} %DIF LATEXDIFF DIFFERENCE FILE %DIF DEL PreviousConfiguration.tex Fri May 7 10:26:40 2021 -%DIF ADD ../Configuration.tex Sun May 9 00:12:30 2021 +%DIF ADD ../Configuration.tex Sun May 9 02:38:36 2021 \usepackage{lmodern} \usepackage{amssymb,amsmath} @@ -6842,7 +6842,9 @@ functioning. Feature highlights: there is an obvious benefit as it may result in issues such as slower scrolling. \DIFaddbegin \DIFadd{This renderer fully supports }\texttt{\DIFadd{AppleEg2Info}} \DIFadd{protocol and will provide - screen rotation for all EFI applications. + screen rotation for all EFI applications. In order to provide seamless rotation + compatibility with }\texttt{\DIFadd{EfiBoot}}\DIFadd{, builtin }\texttt{\DIFadd{AppleFramebufferInfo}} \DIFadd{should + also be used, i.e. it may need to be overridden on Mac EFI. } \DIFaddend \item diff --git a/Docs/Errata/Errata.pdf b/Docs/Errata/Errata.pdf index 5db19cf2..1cb7d2e2 100644 Binary files a/Docs/Errata/Errata.pdf and b/Docs/Errata/Errata.pdf differ diff --git a/Library/OcConsoleLib/ConsoleGop.c b/Library/OcConsoleLib/ConsoleGop.c index 6d081982..e7d668c8 100644 --- a/Library/OcConsoleLib/ConsoleGop.c +++ b/Library/OcConsoleLib/ConsoleGop.c @@ -194,13 +194,24 @@ STATIC VOID SwitchMode ( IN OUT EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Source + IN BOOLEAN UseCustom ) { + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Source; + ASSERT (This != NULL); ASSERT (This->Mode != NULL); ASSERT (This->Mode->Info != NULL); - ASSERT (Source != NULL); + + if (UseCustom) { + Source = &mGop.CustomModeInfo; + This->Mode->FrameBufferBase = 0; + This->Mode->FrameBufferSize = 0; + } else { + Source = &mGop.OriginalModeInfo; + This->Mode->FrameBufferBase = mGop.OriginalFrameBufferBase; + This->Mode->FrameBufferSize = mGop.OriginalFrameBufferSize; + } This->Mode->Info->VerticalResolution = Source->VerticalResolution; This->Mode->Info->HorizontalResolution = Source->HorizontalResolution; @@ -233,6 +244,14 @@ RotateMode ( This->Mode->Info->PixelsPerScanLine = This->Mode->Info->HorizontalResolution; } + mGop.OriginalFrameBufferBase = This->Mode->FrameBufferBase; + mGop.OriginalFrameBufferSize = This->Mode->FrameBufferSize; + + if (Rotation != 0) { + This->Mode->FrameBufferBase = 0; + This->Mode->FrameBufferSize = 0; + } + CopyMem (&mGop.CustomModeInfo, This->Mode->Info, sizeof (mGop.CustomModeInfo)); } @@ -309,11 +328,11 @@ DirectGopSetMode ( // // Protect from mishandling of rotated info. // - SwitchMode (This, &mGop.OriginalModeInfo); + SwitchMode (This, FALSE); Status = mGop.OriginalGopSetMode (This, ModeNumber); if (EFI_ERROR (Status)) { - SwitchMode (This, &mGop.CustomModeInfo); + SwitchMode (This, TRUE); mGop.FramebufferContext = Original; gBS->RestoreTPL (OldTpl); return Status; @@ -326,7 +345,7 @@ DirectGopSetMode ( RotateMode (This, mGop.Rotation); mGop.FramebufferContext = DirectGopFromTarget ( - This->Mode->FrameBufferBase, + mGop.OriginalFrameBufferBase, &mGop.OriginalModeInfo, &mGop.FramebufferContextPageCount ); @@ -360,10 +379,10 @@ DirectQueryMode ( EFI_STATUS Status; UINT32 HorizontalResolution; - SwitchMode (This, &mGop.OriginalModeInfo); + SwitchMode (This, FALSE); Status = mGop.OriginalGopQueryMode (This, ModeNumber, SizeOfInfo, Info); if (EFI_ERROR (Status)) { - SwitchMode (This, &mGop.CustomModeInfo); + SwitchMode (This, TRUE); return Status; } @@ -523,7 +542,7 @@ OcUseDirectGop ( RotateMode (Gop, mGop.Rotation); mGop.FramebufferContext = DirectGopFromTarget ( - Gop->Mode->FrameBufferBase, + mGop.OriginalFrameBufferBase, &mGop.OriginalModeInfo, &mGop.FramebufferContextPageCount ); @@ -562,3 +581,15 @@ OcUseDirectGop ( return EFI_SUCCESS; } + +CONST CONSOLE_GOP_CONTEXT * +InternalGetDirectGopContext ( + VOID + ) +{ + if (mGop.Rotation != 0 && mGop.OriginalGopSetMode != NULL) { + return &mGop; + } + + return NULL; +} diff --git a/Library/OcConsoleLib/ConsoleGopInternal.h b/Library/OcConsoleLib/ConsoleGopInternal.h index 2d4cf31f..60148036 100644 --- a/Library/OcConsoleLib/ConsoleGopInternal.h +++ b/Library/OcConsoleLib/ConsoleGopInternal.h @@ -56,9 +56,22 @@ typedef struct CONSOLE_GOP_CONTEXT { /// EFI_GRAPHICS_OUTPUT_MODE_INFORMATION OriginalModeInfo; /// + /// Original (not rotated) linear frame buffer. + /// + EFI_PHYSICAL_ADDRESS OriginalFrameBufferBase; + /// + /// Original (not rotated) linear frame buffer size. + /// + UINTN OriginalFrameBufferSize; + /// /// Ours (rotated) mode informaation. /// EFI_GRAPHICS_OUTPUT_MODE_INFORMATION CustomModeInfo; } CONSOLE_GOP_CONTEXT; +CONST CONSOLE_GOP_CONTEXT * +InternalGetDirectGopContext ( + VOID + ); + #endif // CONSOLE_GOP_INTERNAL_H diff --git a/Library/OcConsoleLib/FramebufferInfo.c b/Library/OcConsoleLib/FramebufferInfo.c index 92ebd2ec..2369b069 100644 --- a/Library/OcConsoleLib/FramebufferInfo.c +++ b/Library/OcConsoleLib/FramebufferInfo.c @@ -13,6 +13,7 @@ **/ #include "OcConsoleLibInternal.h" +#include "ConsoleGopInternal.h" #include #include @@ -41,6 +42,7 @@ AppleFramebufferGetInfo ( EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; + CONST CONSOLE_GOP_CONTEXT *DirectConsole; if (This == NULL || FramebufferBase == NULL @@ -52,6 +54,17 @@ AppleFramebufferGetInfo ( return EFI_INVALID_PARAMETER; } + DirectConsole = InternalGetDirectGopContext (); + if (DirectConsole != NULL) { + *FramebufferBase = DirectConsole->OriginalFrameBufferBase; + *FramebufferSize = (UINT32) DirectConsole->OriginalFrameBufferSize; + *ScreenRowBytes = (UINT32) (DirectConsole->OriginalModeInfo.PixelsPerScanLine * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); + *ScreenWidth = DirectConsole->CustomModeInfo.HorizontalResolution; + *ScreenHeight = DirectConsole->CustomModeInfo.VerticalResolution; + *ScreenDepth = DEFAULT_COLOUR_DEPTH; + return EFI_SUCCESS; + } + Status = gBS->HandleProtocol ( gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, diff --git a/Library/OcConsoleLib/OcConsoleLib.inf b/Library/OcConsoleLib/OcConsoleLib.inf index 74c08ae8..44e3337b 100644 --- a/Library/OcConsoleLib/OcConsoleLib.inf +++ b/Library/OcConsoleLib/OcConsoleLib.inf @@ -29,6 +29,7 @@ [Guids] gAppleVendorVariableGuid + gAppleBootVariableGuid [Protocols] gAppleFramebufferInfoProtocolGuid