提交 6439b435 编写于 作者: V vit9696

OpenCoreUefi: Support MTRR cache policy in direct fb

上级 a2e07526
......@@ -5,6 +5,7 @@ OpenCore Changelog
- Added TimeMachine detection to picker
- Added early preview version of BootLiquor
- Fixed FS discovery on NVMe with legacy drivers
- Added DirectGopCacheMode option for FB cache policy
#### v0.5.6
- Various improvements to builtin text renderer
......
......@@ -847,6 +847,8 @@
<true/>
<key>DirectGopRendering</key>
<false/>
<key>DirectGopCacheMode</key>
<integer>-1</integer>
<key>ReconnectOnResChange</key>
<false/>
<key>ReplaceTabWithSpace</key>
......
......@@ -950,6 +950,8 @@
<true/>
<key>DirectGopRendering</key>
<false/>
<key>DirectGopCacheMode</key>
<integer>-1</integer>
<key>ReconnectOnResChange</key>
<false/>
<key>ReplaceTabWithSpace</key>
......
......@@ -498,6 +498,7 @@ typedef enum {
_(OC_STRING , ConsoleMode , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING)) \
_(OC_STRING , Resolution , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING)) \
_(OC_STRING , TextRenderer , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING)) \
_(INT32 , DirectGopCacheMode , , -1 , ()) \
_(BOOLEAN , IgnoreTextInGraphics , , FALSE , ()) \
_(BOOLEAN , ClearScreenOnModeSwitch , , FALSE , ()) \
_(BOOLEAN , ProvideConsoleGop , , FALSE , ()) \
......
......@@ -144,10 +144,14 @@ OcReconnectConsole (
/**
Use direct GOP renderer for console.
@param[in] CacheType Caching type, e.g. CacheWriteCombining or -1 to disable.
@retval EFI_SUCCESS on success.
**/
EFI_STATUS
OcUseDirectGop (
VOID
IN INT32 CacheType
);
/**
......
......@@ -578,6 +578,7 @@ OC_SCHEMA
mUefiOutputSchema[] = {
OC_SCHEMA_BOOLEAN_IN ("ClearScreenOnModeSwitch",OC_GLOBAL_CONFIG, Uefi.Output.ClearScreenOnModeSwitch),
OC_SCHEMA_STRING_IN ("ConsoleMode", OC_GLOBAL_CONFIG, Uefi.Output.ConsoleMode),
OC_SCHEMA_INTEGER_IN ("DirectGopCacheMode", OC_GLOBAL_CONFIG, Uefi.Output.DirectGopCacheMode),
OC_SCHEMA_BOOLEAN_IN ("DirectGopRendering", OC_GLOBAL_CONFIG, Uefi.Output.DirectGopRendering),
OC_SCHEMA_BOOLEAN_IN ("IgnoreTextInGraphics", OC_GLOBAL_CONFIG, Uefi.Output.IgnoreTextInGraphics),
OC_SCHEMA_BOOLEAN_IN ("ProvideConsoleGop", OC_GLOBAL_CONFIG, Uefi.Output.ProvideConsoleGop),
......
......@@ -23,6 +23,7 @@
#include <Library/DebugLib.h>
#include <Library/FrameBufferBltLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/MtrrLib.h>
#include <Library/OcConsoleLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcGuardLib.h>
......@@ -45,6 +46,10 @@ STATIC
EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE
mOriginalGopSetMode;
STATIC
INT32
mCachePolicy;
STATIC
EFI_STATUS
EFIAPI
......@@ -260,6 +265,14 @@ DirectGopSetMode (
return EFI_DEVICE_ERROR;
}
if (mCachePolicy >= 0) {
MtrrSetMemoryAttribute (
This->Mode->FrameBufferBase,
This->Mode->FrameBufferSize,
mCachePolicy
);
}
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
......@@ -354,7 +367,7 @@ OcReconnectConsole (
EFI_STATUS
OcUseDirectGop (
VOID
IN INT32 CacheType
)
{
EFI_STATUS Status;
......@@ -384,5 +397,26 @@ OcUseDirectGop (
mOriginalGopSetMode = Gop->SetMode;
Gop->SetMode = DirectGopSetMode;
Gop->Blt = DirectGopBlt;
mCachePolicy = -1;
if (CacheType >= 0) {
Status = MtrrSetMemoryAttribute (
Gop->Mode->FrameBufferBase,
Gop->Mode->FrameBufferSize,
CacheType
);
DEBUG ((
DEBUG_INFO,
"OCC: FB (%Lx, %Lx) MTRR (%x) - %r\n",
(UINT64) Gop->Mode->FrameBufferBase,
(UINT64) Gop->Mode->FrameBufferSize,
CacheType,
Status
));
if (!EFI_ERROR (Status)) {
mCachePolicy = CacheType;
}
}
return EFI_SUCCESS;
}
......@@ -52,11 +52,13 @@
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OpenCorePkg/OpenCorePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
BaseLib
BaseMemoryLib
DebugLib
FrameBufferBltLib
MtrrLib
UefiBootServicesTableLib
UefiRuntimeServicesTableLib
......@@ -237,7 +237,7 @@ OcLoadUefiOutputSupport (
}
if (Config->Uefi.Output.DirectGopRendering) {
OcUseDirectGop ();
OcUseDirectGop (Config->Uefi.Output.DirectGopCacheMode);
}
if (Config->Uefi.Output.ReconnectOnResChange) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册