diff --git a/Changelog.md b/Changelog.md index 78d854e9..d46319e6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ OpenCore Changelog #### v0.6.2 - Updated builtin firmware versions for SMBIOS and the rest - Added `ProcessorType` option to `Generic` allowing custom CPU names +- Fixed `UnblockFsConnect` option not working with APFS JumpStart #### v0.6.1 - Improved recognition of early pressed hotkeys, thx @varahash diff --git a/Docs/Configuration.pdf b/Docs/Configuration.pdf index 988fdaa9..d4610534 100644 Binary files a/Docs/Configuration.pdf and b/Docs/Configuration.pdf differ diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex index 7253152e..e1105bf0 100755 --- a/Docs/Configuration.tex +++ b/Docs/Configuration.tex @@ -3167,9 +3167,9 @@ nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-log | \item \texttt{OCCL} --- OcAppleChunkListLib \item \texttt{OCCPU} --- OcCpuLib \item \texttt{OCC} --- OcConsoleLib + \item \texttt{OCDC} --- OcDriverConnectionLib \item \texttt{OCDH} --- OcDataHubLib \item \texttt{OCDI} --- OcAppleDiskImageLib - \item \texttt{OCFSQ} --- OcFileLib, UnblockFs quirk \item \texttt{OCFS} --- OcFileLib \item \texttt{OCFV} --- OcFirmwareVolumeLib \item \texttt{OCHS} --- OcHashServicesLib diff --git a/Docs/Differences/Differences.pdf b/Docs/Differences/Differences.pdf index c07be00b..cdec0a48 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 656d6cba..e8d80ea1 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 Thu Sep 10 18:48:52 2020 -%DIF ADD ../Configuration.tex Thu Sep 10 18:56:58 2020 +%DIF DEL PreviousConfiguration.tex Tue Sep 8 21:12:21 2020 +%DIF ADD ../Configuration.tex Fri Sep 11 14:02:33 2020 \usepackage{lmodern} \usepackage{amssymb,amsmath} @@ -3227,10 +3227,14 @@ nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-log | \item \texttt{OCCL} --- OcAppleChunkListLib \item \texttt{OCCPU} --- OcCpuLib \item \texttt{OCC} --- OcConsoleLib - \item \texttt{OCDH} --- OcDataHubLib + \item \DIFaddbegin \texttt{\DIFadd{OCDC}} \DIFadd{--- OcDriverConnectionLib + }\item \DIFaddend \texttt{OCDH} --- OcDataHubLib \item \texttt{OCDI} --- OcAppleDiskImageLib - \item \texttt{OCFSQ} --- OcFileLib, UnblockFs quirk - \item \texttt{OCFS} --- OcFileLib + \item \DIFdelbegin \texttt{\DIFdel{OCFSQ}} %DIFAUXCMD +\DIFdel{--- OcFileLib, UnblockFs quirk + }%DIFDELCMD < \item %%% +\item%DIFAUXCMD +\DIFdelend \texttt{OCFS} --- OcFileLib \item \texttt{OCFV} --- OcFirmwareVolumeLib \item \texttt{OCHS} --- OcHashServicesLib \item \texttt{OCI4} --- OcAppleImg4Lib diff --git a/Docs/Errata/Errata.pdf b/Docs/Errata/Errata.pdf index ef5ef0d5..89c89c1f 100644 Binary files a/Docs/Errata/Errata.pdf and b/Docs/Errata/Errata.pdf differ diff --git a/Include/Acidanthera/Library/OcApfsLib.h b/Include/Acidanthera/Library/OcApfsLib.h index 6fe34191..49b95bff 100644 --- a/Include/Acidanthera/Library/OcApfsLib.h +++ b/Include/Acidanthera/Library/OcApfsLib.h @@ -54,11 +54,12 @@ /** Configure APFS driver loading for subsequent connections. - @param[in] MinVersion Minimal allowed APFS driver version to load. - @param[in] MinDate Minimal allowed APFS driver date to load. - @param[in] ScanPolicy OpenCore scan policy. - @param[in] GlobalConnect Perform global device connection for APFS. - @param[in] IgnoreVerbose Avoid APFS driver verbose output. + @param[in] MinVersion Minimal allowed APFS driver version to load. + @param[in] MinDate Minimal allowed APFS driver date to load. + @param[in] ScanPolicy OpenCore scan policy. + @param[in] GlobalConnect Perform global device connection for APFS. + @param[in] DisconnectHandles Perform handle disconnection prior to connection. + @param[in] IgnoreVerbose Avoid APFS driver verbose output. **/ VOID OcApfsConfigure ( @@ -66,6 +67,7 @@ OcApfsConfigure ( IN UINT32 MinDate, IN UINT32 ScanPolicy, IN BOOLEAN GlobalConnect, + IN BOOLEAN DisconnectHandles, IN BOOLEAN IgnoreVerbose ); diff --git a/Include/Acidanthera/Library/OcDriverConnectionLib.h b/Include/Acidanthera/Library/OcDriverConnectionLib.h index 3101538d..812b4231 100644 --- a/Include/Acidanthera/Library/OcDriverConnectionLib.h +++ b/Include/Acidanthera/Library/OcDriverConnectionLib.h @@ -29,8 +29,31 @@ OcRegisterDriversToHighestPriority ( IN EFI_HANDLE *PriorityDrivers ); +/** + Unblocks all partition handles without a File System protocol attached from + driver connection, if applicable. +**/ +VOID +OcUnblockUnmountedPartitions ( + VOID + ); + +/** + Disconnect effectively all drivers attached at handle. + + @param[in] Controller Handle to disconnect the drivers from. + + @retval EFI_SUCCESS on success. +**/ +EFI_STATUS +OcDisconnectDriversOnHandle ( + IN EFI_HANDLE Controller + ); + /** Connect effectively all drivers to effectively all handles. + + @retval EFI_SUCCESS on success. **/ EFI_STATUS OcConnectDrivers ( diff --git a/Include/Acidanthera/Library/OcFileLib.h b/Include/Acidanthera/Library/OcFileLib.h index 598930ec..d9b2a300 100755 --- a/Include/Acidanthera/Library/OcFileLib.h +++ b/Include/Acidanthera/Library/OcFileLib.h @@ -469,15 +469,6 @@ OcGetGptPartitionEntry ( IN EFI_HANDLE FsHandle ); -/** - Unblocks all partition handles without a File System protocol attached from - driver connection, if applicable. -**/ -VOID -OcUnblockUnmountedPartitions ( - VOID - ); - /** Creates a device path for a firmware file. diff --git a/Library/OcApfsLib/OcApfsConnect.c b/Library/OcApfsLib/OcApfsConnect.c index 5c246992..39cc1008 100644 --- a/Library/OcApfsLib/OcApfsConnect.c +++ b/Library/OcApfsLib/OcApfsConnect.c @@ -37,6 +37,7 @@ STATIC UINT32 mApfsMinimalDate = OC_APFS_DATE_DEFAULT; STATIC UINT32 mOcScanPolicy; STATIC BOOLEAN mIgnoreVerbose; STATIC BOOLEAN mGlobalConnect; +STATIC BOOLEAN mDisconnectHandles; STATIC EFI_SYSTEM_TABLE *mNullSystemTable; // @@ -353,11 +354,22 @@ ApfsStartDriver ( DEBUG (( DEBUG_INFO, - "OCJS: Connecting %a APFS driver on handle %p\n", + "OCJS: Connecting %a%a APFS driver on handle %p\n", mGlobalConnect ? "globally" : "normally", + mDisconnectHandles ? " with disconnection" : "", PrivateData->LocationInfo.ControllerHandle )); + if (mDisconnectHandles) { + // + // Unblock handles as some firmwares like that on HP EliteBook 840 G2 + // may automatically lock all volumes without filesystem drivers upon + // any attempt to connect them. + // REF: https://github.com/acidanthera/bugtracker/issues/1128 + // + OcDisconnectDriversOnHandle (PrivateData->LocationInfo.ControllerHandle); + } + if (mGlobalConnect) { // // Connect all devices when implicitly requested. This is a workaround @@ -434,6 +446,7 @@ OcApfsConfigure ( IN UINT32 MinDate, IN UINT32 ScanPolicy, IN BOOLEAN GlobalConnect, + IN BOOLEAN DisconnectHandles, IN BOOLEAN IgnoreVerbose ) { @@ -456,9 +469,10 @@ OcApfsConfigure ( mApfsMinimalDate = MinDate; } - mOcScanPolicy = ScanPolicy; - mIgnoreVerbose = IgnoreVerbose; - mGlobalConnect = GlobalConnect; + mOcScanPolicy = ScanPolicy; + mIgnoreVerbose = IgnoreVerbose; + mGlobalConnect = GlobalConnect; + mDisconnectHandles = DisconnectHandles; } EFI_STATUS diff --git a/Library/OcFileLib/FsConnectQuirk.c b/Library/OcDriverConnectionLib/DriverDisconnection.c similarity index 53% rename from Library/OcFileLib/FsConnectQuirk.c rename to Library/OcDriverConnectionLib/DriverDisconnection.c index 0c827d20..6289f434 100644 --- a/Library/OcFileLib/FsConnectQuirk.c +++ b/Library/OcDriverConnectionLib/DriverDisconnection.c @@ -17,13 +17,55 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include #include -/** - Unblocks all partition handles without a File System protocol attached from - driver connection, if applicable. +EFI_STATUS +OcDisconnectDriversOnHandle ( + IN EFI_HANDLE Controller + ) +{ + EFI_STATUS Status; + UINTN NumBlockIoInfo; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *BlockIoInfos; + UINTN BlockIoInfoIndex; + + // + // Disconnect any blocking drivers if applicable. + // + Status = gBS->OpenProtocolInformation ( + Controller, + &gEfiBlockIoProtocolGuid, + &BlockIoInfos, + &NumBlockIoInfo + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "OCDC: Attached drivers could not been retrieved\n")); + return Status; + } + + for (BlockIoInfoIndex = 0; BlockIoInfoIndex < NumBlockIoInfo; ++BlockIoInfoIndex) { + if ((BlockIoInfos[BlockIoInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) { + Status = gBS->DisconnectController ( + Controller, + BlockIoInfos[BlockIoInfoIndex].AgentHandle, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_INFO, + "OCDC: Failed to unblock handle %p - %r\n", + Controller, + Status + )); + } + } + } + + FreePool (BlockIoInfos); + return EFI_SUCCESS; +} -**/ VOID OcUnblockUnmountedPartitions ( VOID @@ -38,23 +80,20 @@ OcUnblockUnmountedPartitions ( EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem; EFI_BLOCK_IO_PROTOCOL *BlockIo; - UINTN NumBlockIoInfo; - EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *BlockIoInfos; - UINTN BlockIoInfoIndex; // // For all Block I/O handles, check whether it is a partition. If it is and // does not have a File System protocol attached, ensure it does not have a // blocking driver attached which prevents the connection of a FS driver. // Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiBlockIoProtocolGuid, - NULL, - &NumHandles, - &Handles - ); + ByProtocol, + &gEfiBlockIoProtocolGuid, + NULL, + &NumHandles, + &Handles + ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "OCFSQ: Could not locate DiskIo handles\n")); + DEBUG ((DEBUG_INFO, "OCDC: Could not locate DiskIo handles\n")); return; } @@ -63,10 +102,10 @@ OcUnblockUnmountedPartitions ( // Skip the current handle if a File System driver is already attached. // Status = gBS->HandleProtocol ( - Handles[HandleIndex], - &gEfiSimpleFileSystemProtocolGuid, - (VOID **) &FileSystem - ); + Handles[HandleIndex], + &gEfiSimpleFileSystemProtocolGuid, + (VOID **) &FileSystem + ); if (!EFI_ERROR (Status)) { continue; } @@ -74,46 +113,15 @@ OcUnblockUnmountedPartitions ( // Ensure the current handle describes a partition. // Status = gBS->HandleProtocol ( - Handles[HandleIndex], - &gEfiBlockIoProtocolGuid, - (VOID **) &BlockIo - ); + Handles[HandleIndex], + &gEfiBlockIoProtocolGuid, + (VOID **) &BlockIo + ); if (EFI_ERROR (Status) || !BlockIo->Media->LogicalPartition) { continue; } - // - // Disconnect any blocking drivers if applicable. - // - Status = gBS->OpenProtocolInformation ( - Handles[HandleIndex], - &gEfiBlockIoProtocolGuid, - &BlockIoInfos, - &NumBlockIoInfo - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "OCFSQ: Attached drivers could not been retrieved\n")); - continue; - } - for (BlockIoInfoIndex = 0; BlockIoInfoIndex < NumBlockIoInfo; ++BlockIoInfoIndex) { - if ((BlockIoInfos[BlockIoInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) { - Status = gBS->DisconnectController ( - Handles[HandleIndex], - BlockIoInfos[BlockIoInfoIndex].AgentHandle, - NULL - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_INFO, - "OCFSQ: Failed to unblock handle %p - %r\n", - Handles[HandleIndex], - Status - )); - } - } - } - - FreePool (BlockIoInfos); + OcDisconnectDriversOnHandle (Handles[HandleIndex]); } FreePool (Handles); diff --git a/Library/OcDriverConnectionLib/OcDriverConnectionLib.inf b/Library/OcDriverConnectionLib/OcDriverConnectionLib.inf index 0dd451ea..461a81ea 100644 --- a/Library/OcDriverConnectionLib/OcDriverConnectionLib.inf +++ b/Library/OcDriverConnectionLib/OcDriverConnectionLib.inf @@ -30,6 +30,7 @@ [Sources] OcDriverConnectionLib.c + DriverDisconnection.c [Packages] MdePkg/MdePkg.dec @@ -37,6 +38,10 @@ [Protocols] gEfiPlatformDriverOverrideProtocolGuid + gEfiDevicePathProtocolGuid + gEfiBlockIo2ProtocolGuid + gEfiBlockIoProtocolGuid + gEfiSimpleFileSystemProtocolGuid [LibraryClasses] DebugLib diff --git a/Library/OcFileLib/OcFileLib.inf b/Library/OcFileLib/OcFileLib.inf index 0f141f28..2bd51cd9 100755 --- a/Library/OcFileLib/OcFileLib.inf +++ b/Library/OcFileLib/OcFileLib.inf @@ -35,7 +35,6 @@ ReadFile.c GptPartitionEntry.c FirmwareFile.c - FsConnectQuirk.c [Packages] OpenCorePkg/OpenCorePkg.dec diff --git a/Platform/OpenCore/OpenCoreUefi.c b/Platform/OpenCore/OpenCoreUefi.c index dbd65fbf..5f53341b 100644 --- a/Platform/OpenCore/OpenCoreUefi.c +++ b/Platform/OpenCore/OpenCoreUefi.c @@ -632,6 +632,7 @@ OcLoadUefiSupport ( Config->Uefi.Apfs.MinDate, Config->Misc.Security.ScanPolicy, Config->Uefi.Apfs.GlobalConnect, + Config->Uefi.Quirks.UnblockFsConnect, Config->Uefi.Apfs.HideVerbose );