提交 e2fbb2e1 编写于 作者: V vit9696

OpenCoreUefi: Added memory region reservation support

上级 34b34db8
......@@ -11,6 +11,7 @@ OpenCore Changelog
- Added AppleEvent mouse support in OpenCanopy
- Fixed AppleEvent and OpenCanopy compatibility with OVMF TPL restrictions
- Added mouse drivers to the package as OVMF needs one
- Added memory region reservation support
#### v0.5.7
- Added TimeMachine detection to picker
......
......@@ -4222,6 +4222,15 @@ functioning. Feature highlights:
\textbf{Description}: Apply individual firmware quirks described in
\hyperref[uefiquirkprops]{Quirks Properties} section below.
\item
\texttt{ReservedMemory}\\
\textbf{Type}: \texttt{plist\ array}\\
\textbf{Description}: Designed to be filled with \texttt{plist\ dict} values,
describing memory areas exquisite to particular firmware and hardware functioning,
which should not be used by the operating system. An example of such memory region
could be second 256 MB corrupted by Intel HD 3000 or an area with faulty RAM.
See \hyperref[uefirsvdprops]{ReservedMemory Properties} section below.
\end{enumerate}
\subsection{APFS Properties}\label{uefiapfsprops}
......@@ -4977,6 +4986,42 @@ functioning. Feature highlights:
\end{enumerate}
\subsection{ReservedMemory Properties}\label{uefirsvdprops}
\begin{enumerate}
\item
\texttt{Address}\\
\textbf{Type}: \texttt{plist\ integer}\\
\textbf{Failsafe}: \texttt{0}\\
\textbf{Description}: Start address of the reserved memory region, which should be allocated
as reserved effectively marking the memory of this type inaccessible to the operating system.
The addresses written here must be part of the memory map, have \texttt{EfiConventionalMemory}
type, and page-aligned (4 KBs).
\item
\texttt{Comment}\\
\textbf{Type}: \texttt{plist\ string}\\
\textbf{Failsafe}: Empty string\\
\textbf{Description}: Arbitrary ASCII string used to provide human readable
reference for the entry. It is implementation defined whether this value is
used.
\item
\texttt{Size}\\
\textbf{Type}: \texttt{plist\ integer}\\
\textbf{Failsafe}: \texttt{0}\\
\textbf{Description}: Size of the reserved memory region, must be page-aligned (4 KBs).
\item
\texttt{Enabled}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
\textbf{Description}: This region will not be reserved unless set to \texttt{true}.
\end{enumerate}
\section{Troubleshooting}\label{troubleshooting}
\subsection{Windows support}\label{troubleshootingwin}
......
\documentclass[]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL PreviousConfiguration.tex Tue Apr 7 19:32:13 2020
%DIF ADD ../Configuration.tex Fri Apr 17 09:18:48 2020
%DIF ADD ../Configuration.tex Sat Apr 18 10:27:00 2020
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
......@@ -4291,7 +4291,17 @@ functioning. Feature highlights:
\textbf{Description}: Apply individual firmware quirks described in
\hyperref[uefiquirkprops]{Quirks Properties} section below.
\end{enumerate}
\DIFaddbegin \item
\texttt{\DIFadd{ReservedMemory}}\\
\textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ array}}\\
\textbf{\DIFadd{Description}}\DIFadd{: Designed to be filled with }\texttt{\DIFadd{plist\ dict}} \DIFadd{values,
describing memory areas exquisite to particular firmware and hardware functioning,
which should not be used by the operating system. An example of such memory region
could be second 256 MB corrupted by Intel HD 3000 or an area with faulty RAM.
See }\hyperref[uefirsvdprops]{ReservedMemory Properties} \DIFadd{section below.
}
\DIFaddend \end{enumerate}
\DIFaddbegin \subsection{\DIFadd{APFS Properties}}\label{uefiapfsprops}
......@@ -5056,7 +5066,48 @@ functioning. Feature highlights:
\end{enumerate}
\section{Troubleshooting}\label{troubleshooting}
\DIFaddbegin \subsection{\DIFadd{ReservedMemory Properties}}\label{uefirsvdprops}
\begin{enumerate}
\item
\texttt{\DIFadd{Address}}\\
\textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ integer}}\\
\textbf{\DIFadd{Failsafe}}\DIFadd{: }\texttt{\DIFadd{0}}\\
\textbf{\DIFadd{Description}}\DIFadd{: Start address of the reserved memory region, which should be allocated
as reserved effectively marking the memory of this type inaccessible to the operating system.
}
\DIFadd{The addresses written here must be part of the memory map, have }\texttt{\DIFadd{EfiConventionalMemory}}
\DIFadd{type, and page-aligned (4 KBs).
}
\item
\texttt{\DIFadd{Comment}}\\
\textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ string}}\\
\textbf{\DIFadd{Failsafe}}\DIFadd{: Empty string}\\
\textbf{\DIFadd{Description}}\DIFadd{: Arbitrary ASCII string used to provide human readable
reference for the entry. It is implementation defined whether this value is
used.
}
\item
\texttt{\DIFadd{Size}}\\
\textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ integer}}\\
\textbf{\DIFadd{Failsafe}}\DIFadd{: }\texttt{\DIFadd{0}}\\
\textbf{\DIFadd{Description}}\DIFadd{: Size of the reserved memory region, must be page-aligned (4 KBs).
}
\item
\texttt{\DIFadd{Enabled}}\\
\textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ boolean}}\\
\textbf{\DIFadd{Failsafe}}\DIFadd{: }\texttt{\DIFadd{false}}\\
\textbf{\DIFadd{Description}}\DIFadd{: This region will not be reserved unless set to }\texttt{\DIFadd{true}}\DIFadd{.
}
\end{enumerate}
\DIFaddend \section{Troubleshooting}\label{troubleshooting}
\subsection{Windows support}\label{troubleshootingwin}
......
......@@ -922,6 +922,19 @@
<key>UnblockFsConnect</key>
<false/>
</dict>
<key>ReservedMemory</key>
<array>
<dict>
<key>Address</key>
<integer>268435456</integer>
<key>Size</key>
<integer>268435456</integer>
<key>Comment</key>
<string>HD3000: IGPU memory corruption errata</string>
<key>Enabled</key>
<false/>
</dict>
</array>
</dict>
</dict>
</plist>
......@@ -1025,6 +1025,19 @@
<key>UnblockFsConnect</key>
<false/>
</dict>
<key>ReservedMemory</key>
<array>
<dict>
<key>Address</key>
<integer>268435456</integer>
<key>Size</key>
<integer>268435456</integer>
<key>Comment</key>
<string>HD3000: IGPU memory corruption errata</string>
<key>Enabled</key>
<false/>
</dict>
</array>
</dict>
</dict>
</plist>
......@@ -556,6 +556,20 @@ typedef enum {
_(BOOLEAN , UnblockFsConnect , , FALSE , ())
OC_DECLARE (OC_UEFI_QUIRKS)
///
/// Reserved memory entries adds.
///
#define OC_UEFI_RSVD_ENTRY_FIELDS(_, __) \
_(UINT64 , Address , , 0 , () ) \
_(UINT64 , Size , , 0 , () ) \
_(BOOLEAN , Enabled , , FALSE , () ) \
_(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) )
OC_DECLARE (OC_UEFI_RSVD_ENTRY)
#define OC_UEFI_RSVD_ARRAY_FIELDS(_, __) \
OC_ARRAY (OC_UEFI_RSVD_ENTRY, _, __)
OC_DECLARE (OC_UEFI_RSVD_ARRAY)
///
/// Uefi contains firmware tweaks and extra drivers.
///
......@@ -567,7 +581,8 @@ typedef enum {
_(OC_UEFI_INPUT , Input , , OC_CONSTR2 (OC_UEFI_INPUT, _, __) , OC_DESTR (OC_UEFI_INPUT)) \
_(OC_UEFI_OUTPUT , Output , , OC_CONSTR2 (OC_UEFI_OUTPUT, _, __) , OC_DESTR (OC_UEFI_OUTPUT)) \
_(OC_UEFI_PROTOCOLS , Protocols , , OC_CONSTR2 (OC_UEFI_PROTOCOLS, _, __) , OC_DESTR (OC_UEFI_PROTOCOLS)) \
_(OC_UEFI_QUIRKS , Quirks , , OC_CONSTR2 (OC_UEFI_QUIRKS, _, __) , OC_DESTR (OC_UEFI_QUIRKS))
_(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_DECLARE (OC_UEFI_CONFIG)
/**
......
......@@ -70,6 +70,8 @@ OC_STRUCTORS (OC_UEFI_AUDIO, ())
OC_STRUCTORS (OC_UEFI_INPUT, ())
OC_STRUCTORS (OC_UEFI_OUTPUT, ())
OC_STRUCTORS (OC_UEFI_PROTOCOLS, ())
OC_STRUCTORS (OC_UEFI_RSVD_ENTRY, ())
OC_ARRAY_STRUCTORS (OC_UEFI_RSVD_ARRAY)
OC_STRUCTORS (OC_UEFI_QUIRKS, ())
OC_STRUCTORS (OC_UEFI_CONFIG, ())
......@@ -606,6 +608,19 @@ mUefiOutputSchema[] = {
OC_SCHEMA_STRING_IN ("TextRenderer", OC_GLOBAL_CONFIG, Uefi.Output.TextRenderer),
};
STATIC
OC_SCHEMA
mUefiReservedMemoryEntrySchema[] = {
OC_SCHEMA_INTEGER_IN ("Address", OC_UEFI_RSVD_ENTRY, Address),
OC_SCHEMA_STRING_IN ("Comment", OC_UEFI_RSVD_ENTRY, Comment),
OC_SCHEMA_BOOLEAN_IN ("Enabled", OC_UEFI_RSVD_ENTRY, Enabled),
OC_SCHEMA_INTEGER_IN ("Size", OC_UEFI_RSVD_ENTRY, Address),
};
STATIC
OC_SCHEMA
mUefiReservedMemorySchema = OC_SCHEMA_DICT (NULL, mUefiReservedMemoryEntrySchema);
STATIC
OC_SCHEMA
mUefiConfigurationSchema[] = {
......@@ -616,7 +631,8 @@ mUefiConfigurationSchema[] = {
OC_SCHEMA_DICT ("Input", mUefiInputSchema),
OC_SCHEMA_DICT ("Output", mUefiOutputSchema),
OC_SCHEMA_DICT ("Protocols", mUefiProtocolsSchema),
OC_SCHEMA_DICT ("Quirks", mUefiQuirksSchema)
OC_SCHEMA_DICT ("Quirks", mUefiQuirksSchema),
OC_SCHEMA_ARRAY_IN ("ReservedMemory", OC_GLOBAL_CONFIG, Uefi.ReservedMemory, &mUefiReservedMemorySchema),
};
//
......
......@@ -405,14 +405,15 @@ OcLoadUefiSupport (
IN OC_CPU_INFO *CpuInfo
)
{
EFI_STATUS Status;
EFI_HANDLE *DriversToConnect;
UINTN Index;
UINTN Index2;
UINT16 *BootOrder;
UINTN BootOrderSize;
BOOLEAN BootOrderChanged;
EFI_EVENT Event;
EFI_STATUS Status;
EFI_HANDLE *DriversToConnect;
UINTN Index;
UINTN Index2;
UINT16 *BootOrder;
UINTN BootOrderSize;
BOOLEAN BootOrderChanged;
EFI_EVENT Event;
EFI_PHYSICAL_ADDRESS ReservedAddress;
OcReinstallProtocols (Config);
......@@ -498,6 +499,33 @@ OcLoadUefiSupport (
OcMiscUefiQuirksLoaded (Config);
for (Index = 0; Index < Config->Uefi.ReservedMemory.Count; ++Index) {
if (!Config->Uefi.ReservedMemory.Values[Index]->Enabled) {
continue;
}
if ((Config->Uefi.ReservedMemory.Values[Index]->Address & (BASE_4KB - 1)) != 0
|| (Config->Uefi.ReservedMemory.Values[Index]->Size & (BASE_4KB - 1)) != 0) {
Status = EFI_INVALID_PARAMETER;
} else {
ReservedAddress = Config->Uefi.ReservedMemory.Values[Index]->Address;
Status = gBS->AllocatePages (
AllocateAddress,
EfiReservedMemoryType,
EFI_SIZE_TO_PAGES (Config->Uefi.ReservedMemory.Values[Index]->Size),
&ReservedAddress
);
}
DEBUG ((
DEBUG_INFO,
"OC: Reserving region %Lx of %Lx size - %r\n",
Config->Uefi.ReservedMemory.Values[Index]->Address,
Config->Uefi.ReservedMemory.Values[Index]->Size,
Status
));
}
if (Config->Uefi.ConnectDrivers) {
OcLoadDrivers (Storage, Config, &DriversToConnect);
DEBUG ((DEBUG_INFO, "OC: Connecting drivers...\n"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册