mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OcApfsLib: Disconnect the drives we connect to with UnblockFsConnect
closes acidanthera/bugtracker#1128
This commit is contained in:
parent
0d8cbe07f9
commit
d3cf117c86
@ -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
|
||||
|
||||
Binary file not shown.
@ -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
|
||||
|
||||
Binary file not shown.
@ -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
|
||||
|
||||
Binary file not shown.
@ -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
|
||||
);
|
||||
|
||||
|
||||
@ -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 (
|
||||
|
||||
@ -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.
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -17,13 +17,55 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/OcDriverConnectionLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
|
||||
/**
|
||||
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);
|
||||
@ -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
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
ReadFile.c
|
||||
GptPartitionEntry.c
|
||||
FirmwareFile.c
|
||||
FsConnectQuirk.c
|
||||
|
||||
[Packages]
|
||||
OpenCorePkg/OpenCorePkg.dec
|
||||
|
||||
@ -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
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user