diff --git a/Changelog.md b/Changelog.md index 9bffe5f60ec3c277f19c85f9eb3cfba4528208d5..6e155b474b4770a5841a2e67ab09ad3a9981b716 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ OpenCore Changelog ================== #### v0.7.6 - Fixed stack canary support when compiling with GCC +- Added automatic scaling factor detection #### v0.7.5 - Revised OpenLinuxBoot documentation diff --git a/Docs/Configuration.pdf b/Docs/Configuration.pdf index c92a5e21a99166b129f82a70f64889f882ff326a..87a0efe7aec7d6cdc428d1ca4ef1aa5c53a99c75 100644 Binary files a/Docs/Configuration.pdf and b/Docs/Configuration.pdf differ diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex index 64141e60778ab78e140e5d456b09e662b1b6d9d3..423a48ed75797498384d5e05584c771817609f1c 100755 --- a/Docs/Configuration.tex +++ b/Docs/Configuration.tex @@ -7366,6 +7366,21 @@ with the boot menu. On all known affected systems, \texttt{ConsoleMode} must be set to an empty string for this option to work. +\item + \texttt{UIScale}\\ + \textbf{Type}: \texttt{plist\ integer}, 8 bit\\ + \textbf{Failsafe}: \texttt{-1}\\ + \textbf{Description}: User interface scaling factor. + + Corresponds to \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:UIScale} variable. + \begin{itemize} + \tightlist + \item \texttt{1} --- 1x scaling, corresponds to normal displays. + \item \texttt{2} --- 2x scaling, corresponds to HiDPI displays. + \item \texttt{-1} --- leaves the current variable unchanged. + \item \texttt{0} --- automatically chooses scaling based on the current resolution. + \end{itemize} + \item \texttt{UgaPassThrough}\\ \textbf{Type}: \texttt{plist\ boolean}\\ diff --git a/Docs/Differences/Differences.pdf b/Docs/Differences/Differences.pdf index 0b203b8ca90feb396db4956e2ec1b8881a545f42..72c08bbcae43325b6777fb38116f5dab77bc24a2 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 443ac06e64a881f37b22d59275f2943bab7932d7..eddd5e06c914a607f7cdd4d609bc5c9160645b01 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 Tue Nov 2 10:35:43 2021 -%DIF ADD ../Configuration.tex Tue Nov 2 10:37:48 2021 +%DIF DEL PreviousConfiguration.tex Wed Nov 3 14:16:04 2021 +%DIF ADD ../Configuration.tex Thu Nov 4 18:02:19 2021 \usepackage{lmodern} \usepackage{amssymb,amsmath} @@ -7425,6 +7425,24 @@ with the boot menu. \emph{Note}: This option only applies to the \texttt{System} renderer. On all known affected systems, \texttt{ConsoleMode} must be set to an empty string for this option to work. +\DIFaddbegin + +\item + \texttt{\DIFadd{UIScale}}\\ + \textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ integer}}\DIFadd{, 8 bit}\\ + \textbf{\DIFadd{Failsafe}}\DIFadd{: }\texttt{\DIFadd{-1}}\\ + \textbf{\DIFadd{Description}}\DIFadd{: User interface scaling factor. +} + + \DIFadd{Corresponds to }\texttt{\DIFadd{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:UIScale}} \DIFadd{variable. + }\begin{itemize} + \tightlist + \item \texttt{\DIFadd{1}} \DIFadd{--- 1x scaling, corresponds to normal displays. + }\item \texttt{\DIFadd{2}} \DIFadd{--- 2x scaling, corresponds to HiDPI displays. + }\item \texttt{\DIFadd{-1}} \DIFadd{--- leaves the current variable unchanged. + }\item \texttt{\DIFadd{0}} \DIFadd{--- automatically chooses scaling based on the current resolution. + }\end{itemize} +\DIFaddend \item \texttt{UgaPassThrough}\\ diff --git a/Docs/Errata/Errata.pdf b/Docs/Errata/Errata.pdf index 5f4da0baded5c086838645e8dc8dc8abe4a8ad24..596be1812fdcd72324413f832dc8d3f4fc4a6f59 100644 Binary files a/Docs/Errata/Errata.pdf and b/Docs/Errata/Errata.pdf differ diff --git a/Docs/Sample.plist b/Docs/Sample.plist index 8a652dafb1f3282b08c8f29cd87a4ba551685392..d0461cc3904ce6e9be46193bfae87795aa92c4d0 100644 --- a/Docs/Sample.plist +++ b/Docs/Sample.plist @@ -1132,8 +1132,6 @@ DefaultBackgroundColor AAAAAA== - UIScale - AQ== 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102 @@ -1160,7 +1158,6 @@ 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14 - UIScale DefaultBackgroundColor 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102 @@ -1513,6 +1510,8 @@ TextRenderer BuiltinGraphics + UIScale + 0 UgaPassThrough diff --git a/Docs/SampleCustom.plist b/Docs/SampleCustom.plist index d5a1b62456f87108378afd5195d75aba5bb17c31..ca8fb6e918b5b9733dd40da99fc38d47d8c2a0e3 100644 --- a/Docs/SampleCustom.plist +++ b/Docs/SampleCustom.plist @@ -1132,8 +1132,6 @@ DefaultBackgroundColor AAAAAA== - UIScale - AQ== 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102 @@ -1158,7 +1156,6 @@ 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14 - UIScale DefaultBackgroundColor 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102 @@ -1851,6 +1848,8 @@ TextRenderer BuiltinGraphics + UIScale + 0 UgaPassThrough diff --git a/Include/Acidanthera/Library/OcConfigurationLib.h b/Include/Acidanthera/Library/OcConfigurationLib.h index 0cdca2f043dbc31a359829991fc5e0009ed25da2..bfcf8345a487b96170c8f62829475c598110b0e7 100644 --- a/Include/Acidanthera/Library/OcConfigurationLib.h +++ b/Include/Acidanthera/Library/OcConfigurationLib.h @@ -651,6 +651,7 @@ typedef enum { _(BOOLEAN , ReplaceTabWithSpace , , FALSE , ()) \ _(BOOLEAN , ReconnectOnResChange , , FALSE , ()) \ _(BOOLEAN , SanitiseClearScreen , , FALSE , ()) \ + _(INT8 , UIScale , , -1 , ()) \ _(BOOLEAN , UgaPassThrough , , FALSE , ()) \ _(BOOLEAN , DirectGopRendering , , FALSE , ()) \ _(BOOLEAN , ForceResolution , , FALSE , ()) diff --git a/Include/Acidanthera/Library/OcVariableLib.h b/Include/Acidanthera/Library/OcVariableLib.h index 33ece30d08720dc33673cab83f807aa9a627d9ab..80d513d2cf273b4ad0e9b1980b785795ddccb6fb 100644 --- a/Include/Acidanthera/Library/OcVariableLib.h +++ b/Include/Acidanthera/Library/OcVariableLib.h @@ -40,6 +40,7 @@ OcVariableInit ( EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated). @param[in] Data The contents for the variable. + @param[in] VendorGuid Variable GUID, defaults to gOcVendorVariableGuid if NULL. @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as defined by the Attributes. @@ -57,10 +58,11 @@ OcVariableInit ( **/ EFI_STATUS OcSetSystemVariable ( - IN CHAR16 *VariableName, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data + IN CHAR16 *VariableName, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data, + IN EFI_GUID *VendorGuid OPTIONAL ); #endif // OC_VARIABLE_LIB_H diff --git a/Library/OcConfigurationLib/OcConfigurationLib.c b/Library/OcConfigurationLib/OcConfigurationLib.c index 69538fc2434d85ef18856d478fa13f1168742465..766f9dd8b783e1e33d3787c8d91a44904058cbd4 100644 --- a/Library/OcConfigurationLib/OcConfigurationLib.c +++ b/Library/OcConfigurationLib/OcConfigurationLib.c @@ -786,6 +786,7 @@ mUefiOutputSchema[] = { OC_SCHEMA_STRING_IN ("Resolution", OC_GLOBAL_CONFIG, Uefi.Output.Resolution), OC_SCHEMA_BOOLEAN_IN ("SanitiseClearScreen", OC_GLOBAL_CONFIG, Uefi.Output.SanitiseClearScreen), OC_SCHEMA_STRING_IN ("TextRenderer", OC_GLOBAL_CONFIG, Uefi.Output.TextRenderer), + OC_SCHEMA_INTEGER_IN ("UIScale", OC_GLOBAL_CONFIG, Uefi.Output.UIScale), OC_SCHEMA_BOOLEAN_IN ("UgaPassThrough", OC_GLOBAL_CONFIG, Uefi.Output.UgaPassThrough), }; diff --git a/Library/OcMainLib/OpenCoreMisc.c b/Library/OcMainLib/OpenCoreMisc.c index caf200038735633ba8ff031e32072709c64c159a..a8eefc6fcbce55429eb301307ad45f1e8d985323 100644 --- a/Library/OcMainLib/OpenCoreMisc.c +++ b/Library/OcMainLib/OpenCoreMisc.c @@ -69,7 +69,8 @@ OcStoreLoadPath ( OC_LOG_VARIABLE_PATH, OPEN_CORE_NVRAM_ATTR, AsciiStrSize (OutPath), - OutPath + OutPath, + NULL ); DEBUG (( @@ -659,7 +660,8 @@ OcMiscMiddleInit ( OC_BOOT_PROTECT_VARIABLE_NAME, OPEN_CORE_INT_NVRAM_ATTR, sizeof (BootProtectFlag), - &BootProtectFlag + &BootProtectFlag, + NULL ); } @@ -981,6 +983,7 @@ OcMiscUefiQuirksLoaded ( OC_SCAN_POLICY_VARIABLE_NAME, OPEN_CORE_INT_NVRAM_ATTR, sizeof (Config->Misc.Security.ScanPolicy), - &Config->Misc.Security.ScanPolicy + &Config->Misc.Security.ScanPolicy, + NULL ); } diff --git a/Library/OcMainLib/OpenCoreNvram.c b/Library/OcMainLib/OpenCoreNvram.c index a185bbd9ce127cd09182fcd117e675b48f22c673..a03455904c0137cfe1342a3643c212f0be6a1b6f 100644 --- a/Library/OcMainLib/OpenCoreNvram.c +++ b/Library/OcMainLib/OpenCoreNvram.c @@ -91,14 +91,16 @@ OcReportVersion ( OC_VERSION_VARIABLE_NAME, OPEN_CORE_NVRAM_ATTR, AsciiStrLen (Version), - (VOID *) Version + (VOID *) Version, + NULL ); } else { OcSetSystemVariable ( OC_VERSION_VARIABLE_NAME, OPEN_CORE_NVRAM_ATTR, L_STR_LEN ("UNK-000-0000-00-00"), - "UNK-000-0000-00-00" + "UNK-000-0000-00-00", + NULL ); } } diff --git a/Library/OcMainLib/OpenCoreUefi.c b/Library/OcMainLib/OpenCoreUefi.c index b0d4596c0b9763bddc4e6e934cd3a57bd67110fe..6bbe93ea3f7f7448a2b0eb8119fe2a28720eef88 100644 --- a/Library/OcMainLib/OpenCoreUefi.c +++ b/Library/OcMainLib/OpenCoreUefi.c @@ -858,7 +858,8 @@ OcLoadUefiSupport ( OC_BOOT_REDIRECT_VARIABLE_NAME, OPEN_CORE_INT_NVRAM_ATTR, sizeof (Config->Uefi.Quirks.RequestBootVarRouting), - &Config->Uefi.Quirks.RequestBootVarRouting + &Config->Uefi.Quirks.RequestBootVarRouting, + NULL ); if (Config->Uefi.Quirks.UnblockFsConnect) { diff --git a/Library/OcMainLib/OpenCoreUefiInOut.c b/Library/OcMainLib/OpenCoreUefiInOut.c index c4f1af10122692893ee084ac31260f9739c8f5ae..6be7f9b7a5d332d53b828e59725c2ac39eb9faa7 100644 --- a/Library/OcMainLib/OpenCoreUefiInOut.c +++ b/Library/OcMainLib/OpenCoreUefiInOut.c @@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include #include #include @@ -40,6 +41,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include @@ -182,14 +184,16 @@ OcLoadUefiOutputSupport ( IN OC_GLOBAL_CONFIG *Config ) { - EFI_STATUS Status; - CONST CHAR8 *AsciiRenderer; - CONST CHAR8 *GopPassThrough; - OC_CONSOLE_RENDERER Renderer; - UINT32 Width; - UINT32 Height; - UINT32 Bpp; - BOOLEAN SetMax; + EFI_STATUS Status; + CONST CHAR8 *AsciiRenderer; + CONST CHAR8 *GopPassThrough; + EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; + OC_CONSOLE_RENDERER Renderer; + UINT32 Width; + UINT32 Height; + UINT32 Bpp; + BOOLEAN SetMax; + UINT8 UIScale; GopPassThrough = OC_BLOB_GET (&Config->Uefi.Output.GopPassThrough); if (AsciiStrCmp (GopPassThrough, "Enabled") == 0) { @@ -273,6 +277,40 @@ OcLoadUefiOutputSupport ( } } + if (Config->Uefi.Output.UIScale >= 0 && Config->Uefi.Output.UIScale <= 2) { + if (Config->Uefi.Output.UIScale == 0) { + Status = gBS->HandleProtocol ( + gST->ConsoleOutHandle, + &gEfiGraphicsOutputProtocolGuid, + (VOID **) &Gop + ); + if (!EFI_ERROR (Status)) { + UIScale = (UINT64) Gop->Mode->Info->HorizontalResolution + * Gop->Mode->Info->VerticalResolution >= 4000000 ? 2 : 1; + DEBUG (( + DEBUG_INFO, + "OC: Selected UIScale %d based on %ux%u resolution\n", + UIScale, + Gop->Mode->Info->HorizontalResolution, + Gop->Mode->Info->VerticalResolution + )); + } else { + UIScale = 1; + } + } else { + UIScale = (UINT8) Config->Uefi.Output.UIScale; + } + + Status = OcSetSystemVariable ( + APPLE_UI_SCALE_VARIABLE_NAME, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + sizeof (UIScale), + &UIScale, + &gAppleVendorVariableGuid + ); + DEBUG ((DEBUG_INFO, "OC: Setting UIScale to %d - %r\n", UIScale, Status)); + } + AsciiRenderer = OC_BLOB_GET (&Config->Uefi.Output.TextRenderer); if (AsciiRenderer[0] == '\0' || AsciiStrCmp (AsciiRenderer, "BuiltinGraphics") == 0) { diff --git a/Library/OcSmbiosLib/SmbiosPatch.c b/Library/OcSmbiosLib/SmbiosPatch.c index ca575d0f11f4a52da0e87000eeee54c974e03eeb..bad7cce188823306efd569d139376d93c9fe9f3f 100755 --- a/Library/OcSmbiosLib/SmbiosPatch.c +++ b/Library/OcSmbiosLib/SmbiosPatch.c @@ -2348,7 +2348,8 @@ OcSmbiosExtractOemInfo ( OC_OEM_PRODUCT_VARIABLE_NAME, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, AsciiStrLen (SmProductName), - (VOID *) SmProductName + (VOID *) SmProductName, + NULL ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_INFO, "OCSMB: Cannot write OEM product\n")); @@ -2360,7 +2361,8 @@ OcSmbiosExtractOemInfo ( OC_OEM_VENDOR_VARIABLE_NAME, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, AsciiStrLen (SmManufacturer), - (VOID *) SmManufacturer + (VOID *) SmManufacturer, + NULL ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_INFO, "OCSMB: Cannot write OEM board manufacturer - %r\n", Status)); @@ -2370,7 +2372,8 @@ OcSmbiosExtractOemInfo ( OC_OEM_BOARD_VARIABLE_NAME, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, AsciiStrLen (SmBoard), - (VOID *) SmBoard + (VOID *) SmBoard, + NULL ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_INFO, "OCSMB: Cannot write OEM board - %r\n", Status)); diff --git a/Library/OcSmcLib/OcSmcLib.c b/Library/OcSmcLib/OcSmcLib.c index 9f62d33639052c538f0ad96bf5db2ecc80aa0f38..d755fd3057e45eda99527b283fb2640bb93172b0 100644 --- a/Library/OcSmcLib/OcSmcLib.c +++ b/Library/OcSmcLib/OcSmcLib.c @@ -575,7 +575,8 @@ ExportStatusKey ( VIRTUALSMC_STATUS_KEY, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, sizeof (StatusBuffer), - StatusBuffer + StatusBuffer, + NULL ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_INFO, "OCSMC: Failed to create status - %r\n", Status)); diff --git a/Library/OcVariableLib/OcVariableLib.c b/Library/OcVariableLib/OcVariableLib.c index a3382df34b97ad162aa73f665be46b4f3638613c..205c8c735068612fad3a3929b48ac8b45d7d5d84 100644 --- a/Library/OcVariableLib/OcVariableLib.c +++ b/Library/OcVariableLib/OcVariableLib.c @@ -33,10 +33,11 @@ OcVariableInit ( EFI_STATUS OcSetSystemVariable ( - IN CHAR16 *VariableName, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data + IN CHAR16 *VariableName, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data, + IN EFI_GUID *VendorGuid OPTIONAL ) { EFI_STATUS Status; @@ -47,6 +48,10 @@ OcSetSystemVariable ( UINT8 StackBuffer[256]; + if (VendorGuid == NULL) { + VendorGuid = &gOcVendorVariableGuid; + } + DEBUG_CODE_BEGIN (); ASSERT (mDebugInitialized); DEBUG_CODE_END (); @@ -68,7 +73,7 @@ OcSetSystemVariable ( Status = gRT->GetVariable ( VariableName, - &gOcVendorVariableGuid, + VendorGuid, NULL, &OldDataSize, OldData @@ -81,7 +86,7 @@ OcSetSystemVariable ( if (OldData != NULL) { Status = gRT->GetVariable ( VariableName, - &gOcVendorVariableGuid, + VendorGuid, NULL, &OldDataSize, OldData @@ -123,7 +128,7 @@ OcSetSystemVariable ( return gRT->SetVariable ( VariableName, - &gOcVendorVariableGuid, + VendorGuid, Attributes, DataSize, Data