提交 6f91e974 编写于 作者: V vit9696

OpenCore: Connect HaltLevel, DisplayLevel, ExposeBootPath Misc preferences

上级 661ad65c
......@@ -94,7 +94,8 @@ LoadOpenCore (
STATIC
VOID
StartOpenCore (
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem,
IN EFI_HANDLE LoadHandle
)
{
EFI_STATUS Status;
......@@ -112,7 +113,17 @@ StartOpenCore (
return;
}
Bootstrap->ReRun (Bootstrap, FileSystem);
if (Bootstrap->Revision != OC_BOOTSTRAP_PROTOCOL_REVISION) {
DEBUG ((
DEBUG_ERROR,
"BS: Unsupported bootstrap protocol %u vs %u\n",
Bootstrap->Revision,
OC_BOOTSTRAP_PROTOCOL_REVISION
));
return;
}
Bootstrap->ReRun (Bootstrap, FileSystem, LoadHandle);
}
EFI_STATUS
......@@ -168,7 +179,7 @@ UefiMain (
//
DEBUG ((DEBUG_INFO, "BS: Trying to start loaded OpenCore image...\n"));
StartOpenCore (FileSystem);
StartOpenCore (FileSystem, LoadedImage->FilePath);
DEBUG ((DEBUG_INFO, "BS: Trying to load OpenCore image...\n"));
Status = LoadOpenCore (FileSystem, ImageHandle, &OcImageHandle);
......@@ -177,7 +188,7 @@ UefiMain (
return EFI_NOT_FOUND;
}
StartOpenCore (FileSystem);
StartOpenCore (FileSystem, LoadedImage->FilePath);
DEBUG ((DEBUG_ERROR, "BS: Failed to start OpenCore image...\n"));
return EFI_NOT_FOUND;
......
......@@ -485,7 +485,7 @@ Add \texttt{.clang\_complete} file with similar content to your UDK root:
-Wno-missing-field-initializers
-Wno-tautological-compare
-Wno-sign-compare
-Wno-varargs
-Wno-varargs
-Wno-unused-const-variable
\end{lstlisting}
......@@ -1165,6 +1165,13 @@ behaviour that does not go to any other sections
\textbf{Description}: Apply debug configuration described in
\hyperref[miscdebugprops]{Debug Properties} section below.
\item
\texttt{Security}\\
\textbf{Type}: \texttt{plist\ dict}\\
\textbf{Description}: Apply security configuration described in
\hyperref[miscsecurityprops]{Security Properties} section below.
\end{enumerate}
\subsection{Debug Properties}\label{miscdebugprops}
......@@ -1179,37 +1186,72 @@ behaviour that does not go to any other sections
every printed line of visible logging output like console,
Data Hub, or serial port.
\item
\texttt{DisplayLevel}\\
\textbf{Type}: \texttt{plist\ integer}, 64 bit\\
\textbf{Default value}: \texttt{0}\\
\textbf{Description}: EDK II debug level bitmask (sum) showed onscreen.
Unless \texttt{Target} enables console (onscreen) printing,
onscreen debug output will not be visible. The following levels
are supported (discover more in
\href{https://github.com/tianocore/edk2/blob/UDK2018/MdePkg/Include/Library/DebugLib.h}{DebugLib.h}):
\begin{itemize}
\tightlist
\item \texttt{0x00000002} --- \texttt{DEBUG\_WARN} in \texttt{DEBUG},
\texttt{NOOPT}, \texttt{RELEASE}.
\item \texttt{0x00000040} --- \texttt{DEBUG\_INFO} in \texttt{DEBUG},
\texttt{NOOPT}.
\item \texttt{0x00400000} --- \texttt{DEBUG\_VERBOSE} in custom builds.
\item \texttt{0x80000000} --- \texttt{DEBUG\_ERROR} in \texttt{DEBUG},
\texttt{NOOPT}, \texttt{RELEASE}.
\end{itemize}
\item
\texttt{ExposeBootPath}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Default value}: \texttt{false}\\
\textbf{Description}: Expose printable booter path to OpenCore.efi or its booter
(depending on the load order) as an UEFI variable.
To obtain booter path use the following command in macOS:
\begin{lstlisting}[label=nvrampath, style=ocbash]
nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-path
\end{lstlisting}
\item
\texttt{Target}\\
\textbf{Type}: \texttt{plist\ integer}\\
\textbf{Default value}: \texttt{0}\\
\textbf{Description}: A bitmask (sum) of enabled logging targets.
By default all the logging output is hidden, so this option is
required to be set when debugging is necessary. The following
logging targets are supported:
required to be set when debugging is necessary.
The following logging targets are supported:
\begin{itemize}
\tightlist
\item \texttt{ 1} --- Enable logging, otherwise all log is discarded.
\item \texttt{ 2} --- Enable basic console (onscreen) logging.
\item \texttt{ 4} --- Enable logging to Data Hub.
\item \texttt{ 8} --- Enable serial port logging.
\item \texttt{16} --- Enable UEFI variable logging.
\item \texttt{32} --- Enable non-volatile UEFI variable logging.
\item \texttt{64} --- Enable logging to file.
\item \texttt{0x01} --- Enable logging, otherwise all log is discarded.
\item \texttt{0x02} --- Enable basic console (onscreen) logging.
\item \texttt{0x04} --- Enable logging to Data Hub.
\item \texttt{0x08} --- Enable serial port logging.
\item \texttt{0x10} --- Enable UEFI variable logging.
\item \texttt{0x20} --- Enable non-volatile UEFI variable logging.
\item \texttt{0x40} --- Enable logging to file.
\end{itemize}
\emph{Note}: Console logging prints less than all the other variants.
Console logging prints less than all the other variants.
Depending on the build type (\texttt{RELEASE}, \texttt{DEBUG}, or
\texttt{NOOPT}) different amount of logging may be read (from least to most).
\emph{Note}: To obtain Data Hub log use the following command
To obtain Data Hub log use the following command
in macOS:
\begin{lstlisting}[label=dhublog, style=ocbash]
ioreg -lw0 -p IODeviceTree | grep boot-log | sort | sed 's/.*<\(.*\)>.*/\1/' | xxd -r -p
\end{lstlisting}
\emph{Note}: UEFI variable log may get truncated on some firmwares.
UEFI variable log may get truncated on some firmwares.
Using non-volatile flag will write the log to NVRAM flash after every
printed line. To obtain UEFI variable log use the following command
in macOS:
......@@ -1222,6 +1264,18 @@ nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-log | \
\end{enumerate}
\subsection{Security Properties}\label{miscsecurityprops}
\begin{enumerate}
\item
\texttt{HaltLevel}\\
\textbf{Type}: \texttt{plist\ integer}, 64 bit\\
\textbf{Default value}: \texttt{0x80000000} (\texttt{DEBUG\_ERROR})\\
\textbf{Description}: EDK II debug level bitmask (sum) causing CPU to
halt (stop execution) after obtaining a message of \texttt{HaltLevel}.
Possible values match \texttt{DisplayLevel} values.
\end{enumerate}
\section{NVRAM}\label{nvram}
\subsection{Introduction}\label{nvramintro}
......
......@@ -435,9 +435,18 @@
<dict>
<key>Delay</key>
<integer>0</integer>
<key>DisplayLevel</key>
<integer>2147483650</integer>
<key>ExposeBootPath</key>
<false/>
<key>Target</key>
<integer>7</integer>
</dict>
<key>Security</key>
<dict>
<key>HaltLevel</key>
<integer>2147483648</integer>
</dict>
</dict>
<key>NVRAM</key>
<dict>
......@@ -534,7 +543,7 @@
<key>BIOSVersion</key>
<string>142.0.0.0.0</string>
<key>BIOSReleaseDate</key>
<string>02/14/19</string>
<string>02/14/2019</string>
<key>SystemManufacturer</key>
<string></string>
<key>SystemProductName</key>
......
......@@ -31,6 +31,8 @@
#define OPEN_CORE_KEXT_PATH L"Kexts\\"
#define OPEN_CORE_NVRAM_ATTR (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
/**
Load ACPI compatibility support like custom tables.
......
......@@ -28,7 +28,7 @@
///
/// OC_BOOTSTRAP_PROTOCOL revision
///
#define OC_BOOTSTRAP_PROTOCOL_REVISION 1
#define OC_BOOTSTRAP_PROTOCOL_REVISION 2
///
/// Forward declaration of OC_BOOTSTRAP_PROTOCOL structure.
......@@ -40,12 +40,14 @@ typedef struct OC_BOOTSTRAP_PROTOCOL_ OC_BOOTSTRAP_PROTOCOL;
@param[in] This This protocol.
@param[in] FileSystem File system to bootstrap in.
@param[in] LoadPath EFI device path to loaded image.
**/
typedef
VOID
(EFIAPI *OC_BOOTSTRAP_RERUN) (
IN OC_BOOTSTRAP_PROTOCOL *This,
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem,
IN EFI_DEVICE_PATH_PROTOCOL *LoadPath OPTIONAL
);
///
......
......@@ -15,6 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <OpenCore.h>
#include <Uefi.h>
#include <Guid/OcLogVariable.h>
#include <Protocol/DevicePath.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/OcBootstrap.h>
......@@ -28,6 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/OcCpuLib.h>
#include <Library/OcDevicePathLib.h>
#include <Library/OcStorageLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
......@@ -140,16 +143,59 @@ OcStartImage (
return Status;
}
STATIC
VOID
OcStoreLoadPath (
IN EFI_DEVICE_PATH_PROTOCOL *LoadPath OPTIONAL
)
{
EFI_STATUS Status;
CHAR16 *DevicePath;
CHAR8 OutPath[256];
if (LoadPath != NULL) {
DevicePath = ConvertDevicePathToText (LoadPath, FALSE, FALSE);
if (DevicePath != NULL) {
AsciiSPrint (OutPath, sizeof (OutPath), "%s", DevicePath);
FreePool (DevicePath);
} else {
LoadPath = NULL;
}
}
if (LoadPath == NULL) {
AsciiSPrint (OutPath, sizeof (OutPath), "Unknown");
}
Status = gRT->SetVariable (
OC_LOG_VARIABLE_PATH,
&gOcLogVariableGuid,
OPEN_CORE_NVRAM_ATTR,
AsciiStrSize (OutPath),
OutPath
);
DEBUG ((
EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
"OC: Setting NVRAM %g:%a = %a - %r\n",
&gOcLogVariableGuid,
OC_LOG_VARIABLE_PATH,
OutPath,
Status
));
}
STATIC
VOID
OcMain (
IN OC_STORAGE_CONTEXT *Storage
IN OC_STORAGE_CONTEXT *Storage,
IN EFI_DEVICE_PATH_PROTOCOL *LoadPath OPTIONAL
)
{
EFI_STATUS Status;
CHAR8 *Config;
UINT32 ConfigSize;
OC_CPU_INFO CpuInfo;
EFI_STATUS Status;
CHAR8 *Config;
UINT32 ConfigSize;
OC_CPU_INFO CpuInfo;
Config = OcStorageReadFileUnicode (
Storage,
......@@ -172,9 +218,15 @@ OcMain (
OcConfigureLogProtocol (
mOpenCoreConfiguration.Misc.Debug.Target,
mOpenCoreConfiguration.Misc.Debug.Delay
mOpenCoreConfiguration.Misc.Debug.Delay,
(UINTN) mOpenCoreConfiguration.Misc.Debug.DisplayLevel,
(UINTN) mOpenCoreConfiguration.Misc.Security.HaltLevel
);
if (mOpenCoreConfiguration.Misc.Debug.ExposeBootPath) {
OcStoreLoadPath (LoadPath);
}
OcCpuScanProcessor (&CpuInfo);
OcLoadUefiSupport (Storage, &mOpenCoreConfiguration, &CpuInfo);
OcLoadPlatformSupport (&mOpenCoreConfiguration, &CpuInfo);
......@@ -206,7 +258,8 @@ VOID
EFIAPI
OcBootstrapRerun (
IN OC_BOOTSTRAP_PROTOCOL *This,
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem,
IN EFI_DEVICE_PATH_PROTOCOL *LoadPath OPTIONAL
)
{
EFI_STATUS Status;
......@@ -229,7 +282,7 @@ OcBootstrapRerun (
return;
}
OcMain (&mOpenCoreStorage);
OcMain (&mOpenCoreStorage, LoadPath);
OcStorageFree (&mOpenCoreStorage);
}
......@@ -317,7 +370,7 @@ UefiMain (
// Return success in either case to let rerun work afterwards.
//
if (FileSystem != NULL) {
mOpenCoreBootStrap.ReRun (&mOpenCoreBootStrap, FileSystem);
mOpenCoreBootStrap.ReRun (&mOpenCoreBootStrap, FileSystem, LoadedImage->FilePath);
DEBUG ((DEBUG_ERROR, "OC: Failed to boot\n"));
} else {
DEBUG ((DEBUG_ERROR, "OC: Failed to locate file system\n"));
......
......@@ -51,6 +51,9 @@
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[Guids]
gOcLogVariableGuid
[Protocols]
gEfiDevicePathProtocolGuid ## CONSUMES
gEfiDevicePathProtocolGuid ## CONSUMES
......
......@@ -23,10 +23,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
STATIC
CONST UINT32
mDefaultAttributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
VOID
OcLoadNvramSupport (
IN OC_GLOBAL_CONFIG *Config
......@@ -131,7 +127,7 @@ OcLoadNvramSupport (
Status = gRT->SetVariable (
UnicodeVariableName,
&VariableGuid,
mDefaultAttributes,
OPEN_CORE_NVRAM_ATTR,
VariableSize,
VariableData
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册