Skip to content

Commit

Permalink
Merge branch 'acidanthera:master' into YamingNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
wy414012 authored Oct 8, 2024
2 parents f779558 + 22171e0 commit 3f9acce
Show file tree
Hide file tree
Showing 22 changed files with 738 additions and 73 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ OpenCore Changelog
- Updated builtin firmware versions for SMBIOS and the rest
- Enabled `XcpmExtraMsrs MSR_MISC_PWR_MGMT` patch back on macOS 12+
- Fixed `XcpmExtraMsrs MSR_MISC_PWR_MGMT` patch on macOS 15
- Added `UEFI` `Unload` option to unload existing firmware drivers
- Fixed boot device selection with VirtIO disk drives used for macOS installations

#### v1.0.1
- Updated code and added progress bar to macrecovery, thx @soyeonswife63
Expand Down
2 changes: 1 addition & 1 deletion Docs/Configuration.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cb57ec4e948616df3786174e681fd99a
4583046ddf64fb25320ad4825734d911
Binary file modified Docs/Configuration.pdf
Binary file not shown.
34 changes: 34 additions & 0 deletions Docs/Configuration.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7564,6 +7564,40 @@ \subsection{Properties}\label{uefiprops}
could be the second 256 MB corrupted by the Intel HD 3000 or an area with faulty RAM.
Refer to the \hyperref[uefirsvdprops]{ReservedMemory Properties} section below for details.

\item
\texttt{Unload}\\
\textbf{Type}: \texttt{plist\ array}\\
\textbf{Failsafe}: Empty\\
\textbf{Description}: Unload specified firmware drivers.

To be filled with \texttt{plist\ string} entries containing
the names of firmware drivers to unload before loading the
\texttt{Drivers} section.
This setting is typically only required if a user-provided driver is a variant of
an existing system firmware driver, and if the new driver would detect itself
as partially loaded, or otherwise fail to operate correctly, if the old
driver is not unloaded first.

\textbf{Warning}: Unloading system firmware drivers is usually not required
and not recommended. Poorly written drivers may crash when
unloaded, or cause subsequent crashes (e.g by allowing themselves to be
unloaded even though they have active dependencies). However standard UEFI
network stack drivers should unload cleanly.

\emph{Note 1}: See \texttt{SysReport/Drivers/DriverImageNames.txt} for the
list of drivers which this option can attempt to unload.
The relevant name is the driver component name. Drivers are only listed if they
implement \texttt{DriverBindingProtocol} and \texttt{LoadedImageProtocol},
and have an available component name.

\emph{Note 2}: The NVRAM \texttt{Lang} and \texttt{PlatformLang} variables
are ignored when determining the driver component names recognised by this
option, and listed in the \texttt{SysReport} file. This is in order to make
unloading images stable across changes in these variables.
The UEFI Shell \texttt{dh} command takes account of these variables,
so in some circumstances may display different driver component names from
those listed for this option, unless these variables are cleared.

\end{enumerate}

\subsection{APFS Properties}\label{uefiapfsprops}
Expand Down
Binary file modified Docs/Differences/Differences.pdf
Binary file not shown.
43 changes: 41 additions & 2 deletions Docs/Differences/Differences.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
\documentclass[]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL PreviousConfiguration.tex Tue Sep 3 09:18:54 2024
%DIF ADD ../Configuration.tex Wed Oct 2 22:40:01 2024
%DIF ADD ../Configuration.tex Sun Oct 6 08:32:59 2024

\usepackage{lmodern}
\usepackage{amssymb,amsmath}
Expand Down Expand Up @@ -7633,7 +7633,46 @@ \subsection{Properties}\label{uefiprops}
describing memory areas exclusive to specific firmware and hardware functioning,
which should not be used by the operating system. Examples of such memory regions
could be the second 256 MB corrupted by the Intel HD 3000 or an area with faulty RAM.
Refer to the \hyperref[uefirsvdprops]{ReservedMemory Properties} section below for details.
Refer to the \hyperref[uefirsvdprops]{ReservedMemory Properties} section below for details\DIFaddbegin \DIFadd{.
}

\item
\texttt{\DIFadd{Unload}}\\
\textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ array}}\\
\textbf{\DIFadd{Failsafe}}\DIFadd{: Empty}\\
\textbf{\DIFadd{Description}}\DIFadd{: Unload specified firmware drivers.
}

\DIFadd{To be filled with }\texttt{\DIFadd{plist\ string}} \DIFadd{entries containing
the names of firmware drivers to unload before loading the
}\texttt{\DIFadd{Drivers}} \DIFadd{section.
This setting is typically only required if a user-provided driver is a variant of
an existing system firmware driver, and if the new driver would detect itself
as partially loaded, or otherwise fail to operate correctly, if the old
driver is not unloaded first.
}

\textbf{\DIFadd{Warning}}\DIFadd{: Unloading system firmware drivers is usually not required
and not recommended. Poorly written drivers may crash when
unloaded, or cause subsequent crashes (e.g by allowing themselves to be
unloaded even though they have active dependencies). However standard UEFI
network stack drivers should unload cleanly.
}

\emph{\DIFadd{Note 1}}\DIFadd{: See }\texttt{\DIFadd{SysReport/Drivers/DriverImageNames.txt}} \DIFadd{for the
list of drivers which this option can attempt to unload.
The relevant name is the driver component name. Drivers are only listed if they
implement }\texttt{\DIFadd{DriverBindingProtocol}} \DIFadd{and }\texttt{\DIFadd{LoadedImageProtocol}}\DIFadd{,
and have an available component name.
}

\emph{\DIFadd{Note 2}}\DIFadd{: The NVRAM }\texttt{\DIFadd{Lang}} \DIFadd{and }\texttt{\DIFadd{PlatformLang}} \DIFadd{variables
are ignored when determining the driver component names recognised by this
option, and listed in the }\texttt{\DIFadd{SysReport}} \DIFadd{file. This is in order to make
unloading images stable across changes in these variables.
The UEFI Shell }\texttt{\DIFadd{dh}} \DIFadd{command takes account of these variables,
so in some circumstances may display different driver component names from
those listed for this option, unless these variables are cleared}\DIFaddend .

\end{enumerate}

Expand Down
Binary file modified Docs/Errata/Errata.pdf
Binary file not shown.
4 changes: 3 additions & 1 deletion Docs/Sample.plist
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
<key>EnableWriteUnprotector</key>
<true/>
<key>FixupAppleEfiImages</key>
<false/>
<true/>
<key>ForceBooterSignature</key>
<false/>
<key>ForceExitBootServices</key>
Expand Down Expand Up @@ -2051,6 +2051,8 @@
<string>RuntimeCode</string>
</dict>
</array>
<key>Unload</key>
<array/>
</dict>
</dict>
</plist>
4 changes: 3 additions & 1 deletion Docs/SampleCustom.plist
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
<key>EnableWriteUnprotector</key>
<true/>
<key>FixupAppleEfiImages</key>
<false/>
<true/>
<key>ForceBooterSignature</key>
<false/>
<key>ForceExitBootServices</key>
Expand Down Expand Up @@ -2419,6 +2419,8 @@
<string>RuntimeCode</string>
</dict>
</array>
<key>Unload</key>
<array/>
</dict>
</dict>
</plist>
30 changes: 15 additions & 15 deletions Include/Acidanthera/Library/OcBootManagementLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ typedef UINT32 OC_BOOT_ENTRY_TYPE;
#define OC_BOOT_EXTERNAL_OS BIT6
#define OC_BOOT_EXTERNAL_TOOL BIT7
#define OC_BOOT_SYSTEM BIT8
#define OC_BOOT_EXTERNAL_SYSTEM BIT9
#define OC_BOOT_UNMANAGED BIT9

/**
Picker mode.
Expand Down Expand Up @@ -200,21 +200,21 @@ EFI_STATUS
);

/**
Action to perform as part of executing an external boot system boot entry.
Action to perform as part of executing an unmanaged boot entry.
**/
typedef
EFI_STATUS
(*OC_BOOT_EXTERNAL_SYSTEM_ACTION) (
(*OC_BOOT_UNMANAGED_ACTION) (
IN OUT OC_PICKER_CONTEXT *PickerContext,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);

/**
Gets Device Path for external boot system boot entry.
Get Device Path for unmanaged boot entry.
**/
typedef
EFI_STATUS
(*OC_BOOT_EXTERNAL_SYSTEM_GET_DP) (
(*OC_BOOT_UNMANAGED_GET_FINAL_DP) (
IN OUT OC_PICKER_CONTEXT *PickerContext,
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
Expand All @@ -238,13 +238,13 @@ typedef struct OC_BOOT_ENTRY_ {
//
OC_BOOT_SYSTEM_ACTION SystemAction;
//
// Action to perform on execution. Only valid for external boot system entries.
// Action to perform on execution. Only valid for unmanaged boot entries.
//
OC_BOOT_EXTERNAL_SYSTEM_ACTION ExternalSystemAction;
OC_BOOT_UNMANAGED_ACTION UnmanagedBootAction;
//
// Gets Device Path for external boot system boot entry. Only valid for external boot system entries.
// Get final Device Path for boot entry. Only valid for unmanaged boot entries.
//
OC_BOOT_EXTERNAL_SYSTEM_GET_DP ExternalSystemGetDevicePath;
OC_BOOT_UNMANAGED_GET_FINAL_DP UnmanagedBootGetFinalDevicePath;
//
// Id under which to save entry as default.
//
Expand Down Expand Up @@ -642,17 +642,17 @@ typedef struct {
//
CHAR8 *AudioBaseType;
//
// External boot system action. Boot Entry Protocol only. Optional.
// Unmanaged boot action. Boot Entry Protocol unmanaged boot entries only.
//
OC_BOOT_EXTERNAL_SYSTEM_ACTION ExternalSystemAction;
OC_BOOT_UNMANAGED_ACTION UnmanagedBootAction;
//
// Gets Device Path for external boot system boot entry. Boot Entry Protocol only. Optional.
// Get final Device Path for unmanaged boot entry. Boot Entry Protocol unmanaged boot entries only.
//
OC_BOOT_EXTERNAL_SYSTEM_GET_DP ExternalSystemGetDevicePath;
OC_BOOT_UNMANAGED_GET_FINAL_DP UnmanagedBootGetFinalDevicePath;
//
// External boot system Device Path. Boot Entry Protocol only. Optional.
// Unmanaged boot Device Path. Boot Entry Protocol unmanaged boot entries only.
//
EFI_DEVICE_PATH_PROTOCOL *ExternalSystemDevicePath;
EFI_DEVICE_PATH_PROTOCOL *UnmanagedBootDevicePath;
//
// Whether this entry should be labeled as external to the system. Boot Entry Protocol only. Optional.
//
Expand Down
10 changes: 9 additions & 1 deletion Include/Acidanthera/Library/OcConfigurationLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,13 @@ OC_DECLARE (OC_PLATFORM_CONFIG)
Uefi section
**/

///
/// Array of driver names to unload.
///
#define OC_UEFI_UNLOAD_ARRAY_FIELDS(_, __) \
OC_ARRAY (OC_STRING, _, __)
OC_DECLARE (OC_UEFI_UNLOAD_ARRAY)

///
/// Drivers is an ordered array of drivers to load.
///
Expand Down Expand Up @@ -782,7 +789,8 @@ OC_DECLARE (OC_UEFI_RSVD_ARRAY)
_(OC_UEFI_OUTPUT , Output , , OC_CONSTR2 (OC_UEFI_OUTPUT, _, __) , OC_DESTR (OC_UEFI_OUTPUT)) \
_(OC_UEFI_PROTOCOL_OVERRIDES , ProtocolOverrides , , OC_CONSTR2 (OC_UEFI_PROTOCOL_OVERRIDES, _, __) , OC_DESTR (OC_UEFI_PROTOCOL_OVERRIDES)) \
_(OC_UEFI_QUIRKS , Quirks , , OC_CONSTR2 (OC_UEFI_QUIRKS, _, __) , OC_DESTR (OC_UEFI_QUIRKS)) \
_(OC_UEFI_RSVD_ARRAY , ReservedMemory , , OC_CONSTR2 (OC_UEFI_RSVD_ARRAY, _, __) , OC_DESTR (OC_UEFI_RSVD_ARRAY))
_(OC_UEFI_RSVD_ARRAY , ReservedMemory , , OC_CONSTR2 (OC_UEFI_RSVD_ARRAY, _, __) , OC_DESTR (OC_UEFI_RSVD_ARRAY)) \
_(OC_UEFI_UNLOAD_ARRAY , Unload , , OC_CONSTR2 (OC_UEFI_UNLOAD_ARRAY, _, __) , OC_DESTR (OC_UEFI_UNLOAD_ARRAY))
OC_DECLARE (OC_UEFI_CONFIG)

/**
Expand Down
5 changes: 4 additions & 1 deletion Include/Acidanthera/Library/OcDevicePathLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ typedef struct {
restore DevicePathNode's original content in
the case of failure.
On success, data may need to be freed.
@param[in] ValidDevice A device handle pointing to previous valid
device path if any.
@retval -1 DevicePathNode could not be fixed.
@retval 0 DevicePathNode was not modified and may be valid.
Expand All @@ -313,7 +315,8 @@ INTN
OcFixAppleBootDevicePathNode (
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
OUT APPLE_BOOT_DP_PATCH_CONTEXT *RestoreContext OPTIONAL
OUT APPLE_BOOT_DP_PATCH_CONTEXT *RestoreContext OPTIONAL,
IN EFI_HANDLE ValidDevice OPTIONAL
);

/**
Expand Down
22 changes: 22 additions & 0 deletions Include/Acidanthera/Library/OcMainLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,26 @@ OcPlatformIs64BitSupported (
IN UINT32 KernelVersion
);

/**
Unload loaded images by name.
@param[in] Config OpenCore configuration.
**/
VOID
OcUnloadDrivers (
IN OC_GLOBAL_CONFIG *Config
);

/**
Dump loaded image driver info to the specified directory.
@param[in] Root Directory to write CPU data.
@retval EFI_SUCCESS on success.
**/
EFI_STATUS
OcDriverInfoDump (
IN EFI_FILE_PROTOCOL *Root
);

#endif // OC_MAIN_LIB
31 changes: 16 additions & 15 deletions Library/OcBootManagementLib/BootEntryManagement.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ InternalAddBootEntryFromCustomEntry (
return EFI_OUT_OF_RESOURCES;
}

if (!CustomEntry->ExternalSystemAction && !CustomEntry->SystemAction) {
if (!CustomEntry->UnmanagedBootAction && !CustomEntry->SystemAction) {
ASSERT (CustomEntry->Path != NULL);
PathName = AsciiStrCopyToUnicode (CustomEntry->Path, 0);
if (PathName == NULL) {
Expand All @@ -715,19 +715,19 @@ InternalAddBootEntryFromCustomEntry (
DEBUG_INFO,
"OCB: Adding custom entry %s (%a|B:%d) -> %a\n",
BootEntry->Name,
CustomEntry->ExternalSystemAction != NULL ? "ext-action" : (CustomEntry->SystemAction != NULL ? "action" : (CustomEntry->Tool ? "tool" : "os")),
CustomEntry->UnmanagedBootAction != NULL ? "unmanaged" : (CustomEntry->SystemAction != NULL ? "action" : (CustomEntry->Tool ? "tool" : "os")),
IsBootEntryProtocol,
CustomEntry->Path
));

if (CustomEntry->ExternalSystemAction) {
BootEntry->Type = OC_BOOT_EXTERNAL_SYSTEM;
BootEntry->ExternalSystemAction = CustomEntry->ExternalSystemAction;
BootEntry->ExternalSystemGetDevicePath = CustomEntry->ExternalSystemGetDevicePath;
BootEntry->AudioBasePath = CustomEntry->AudioBasePath;
BootEntry->AudioBaseType = CustomEntry->AudioBaseType;
BootEntry->IsExternal = CustomEntry->External;
BootEntry->DevicePath = DuplicateDevicePath (CustomEntry->ExternalSystemDevicePath);
if (CustomEntry->UnmanagedBootAction) {
BootEntry->Type = OC_BOOT_UNMANAGED;
BootEntry->UnmanagedBootAction = CustomEntry->UnmanagedBootAction;
BootEntry->UnmanagedBootGetFinalDevicePath = CustomEntry->UnmanagedBootGetFinalDevicePath;
BootEntry->AudioBasePath = CustomEntry->AudioBasePath;
BootEntry->AudioBaseType = CustomEntry->AudioBaseType;
BootEntry->IsExternal = CustomEntry->External;
BootEntry->DevicePath = DuplicateDevicePath (CustomEntry->UnmanagedBootDevicePath);

if (BootEntry->DevicePath == NULL) {
FreeBootEntry (BootEntry);
Expand Down Expand Up @@ -843,7 +843,7 @@ InternalAddBootEntryFromCustomEntry (
BootEntry->ExposeDevicePath = CustomEntry->RealPath;
BootEntry->FullNvramAccess = CustomEntry->FullNvramAccess;

if ((BootEntry->ExternalSystemAction != NULL) || (BootEntry->SystemAction != NULL)) {
if ((BootEntry->UnmanagedBootAction != NULL) || (BootEntry->SystemAction != NULL)) {
ASSERT (CustomEntry->Arguments == NULL);
} else {
ASSERT (CustomEntry->Arguments != NULL);
Expand All @@ -861,7 +861,7 @@ InternalAddBootEntryFromCustomEntry (

BootEntry->IsCustom = TRUE;
BootEntry->IsBootEntryProtocol = IsBootEntryProtocol;
if (IsBootEntryProtocol && (BootEntry->ExternalSystemAction == NULL) && (BootEntry->SystemAction == NULL)) {
if (IsBootEntryProtocol && (BootEntry->UnmanagedBootAction == NULL) && (BootEntry->SystemAction == NULL)) {
PartitionEntry = OcGetGptPartitionEntry (FileSystem->Handle);
if (PartitionEntry == NULL) {
CopyGuid (&BootEntry->UniquePartitionGUID, &gEfiPartTypeUnusedGuid);
Expand Down Expand Up @@ -1459,6 +1459,7 @@ AddBootEntryFromBootOption (
NumPatchedNodes = OcFixAppleBootDevicePathNode (
&DevicePath,
&RemainingDevicePath,
NULL,
NULL
);
} while (NumPatchedNodes > 0);
Expand Down Expand Up @@ -2511,9 +2512,9 @@ OcLoadBootEntry (
EFI_HANDLE EntryHandle;
INTERNAL_DMG_LOAD_CONTEXT DmgLoadContext;

if ((BootEntry->Type & OC_BOOT_EXTERNAL_SYSTEM) != 0) {
ASSERT (BootEntry->ExternalSystemAction != NULL);
return BootEntry->ExternalSystemAction (Context, BootEntry->DevicePath);
if ((BootEntry->Type & OC_BOOT_UNMANAGED) != 0) {
ASSERT (BootEntry->UnmanagedBootAction != NULL);
return BootEntry->UnmanagedBootAction (Context, BootEntry->DevicePath);
}

if ((BootEntry->Type & OC_BOOT_SYSTEM) != 0) {
Expand Down
Loading

0 comments on commit 3f9acce

Please sign in to comment.