Configuration.tex 124.0 KB
Newer Older
V
vit9696 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
\documentclass[]{article}

\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{upquote}
\usepackage{microtype}
\usepackage[unicode=true]{hyperref}
\usepackage{longtable,booktabs}
\usepackage{footnote}
14
\usepackage{listings}
V
vit9696 已提交
15 16 17 18
\usepackage{parskip}
\usepackage[margin=0.7in]{geometry}
\usepackage{titlesec}
\usepackage[yyyymmdd,hhmmss]{datetime}
V
vit9696 已提交
19
\usepackage{textcomp}
V
vit9696 已提交
20 21 22 23 24 25
\usepackage{tikz}

\usetikzlibrary{trees}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=blue]
\tikzstyle{optional}=[dashed,fill=gray!50]
V
vit9696 已提交
26 27 28

\renewcommand{\dateseparator}{.}

29 30
% Newer LaTeX versions should not add ligatures to listings, but for some reason
% it is not the case for me. As a result select PDF viewers copy wrong data.
V
vit9696 已提交
31 32 33 34 35
\lstdefinestyle{ocbash}{
  language=bash,
  frame=tb,
  columns=fullflexible,
  captionpos=b,
36 37
  basicstyle=\ttfamily\normalsize,
  keepspaces=true,
V
vit9696 已提交
38
  morekeywords={git, make, build, ioreg, grep, nvram, sort, sudo, diskutil, gfxutil, strings, dd, cut},
V
vit9696 已提交
39
  literate =
V
vit9696 已提交
40
    {"}{{\textquotedbl}}1
V
vit9696 已提交
41 42
    {'}{{\textquotesingle}}1
    {-}{{-}}1
V
vit9696 已提交
43 44
    {~}{{\texttildelow}}1
    {*}{{*}}1
45 46
    {fl}{{f{}l}}2
    {fi}{{f{}i}}2
V
vit9696 已提交
47 48 49
    ,
}

V
vit9696 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
\PassOptionsToPackage{hyphens}{url} % url is loaded by hyperref

\makesavenoteenv{long table} % Fix footnotes in tables

% set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother

\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

\newcommand{\sectionbreak}{\clearpage}

\begin{document}

\begin{titlepage}
   \begin{center}
       \vspace*{3.5in}

       \Huge

       \textbf{OpenCore}

       \vspace{0.2in}

V
vit9696 已提交
77
       Reference Manual (0.0.3)
V
vit9696 已提交
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171

       \vspace{0.2in}

        {[}\today{]}

       \normalsize

       \vfill

       Copyright \textcopyright 2018-2019 vit9696

   \end{center}
\end{titlepage}

\tableofcontents

\section{Introduction}\label{introduction}

This document provides information on
\href{https://github.com/acidanthera/OpenCorePkg}{OpenCore} user
configuration file format used to setup the correct functioning of macOS
operating system.

\subsection{Known defects}\label{reported-defects}

For OpenCore issues please refer to
\href{https://github.com/acidanthera/bugtracker}{Acidanthera Bugtracker}.

\section{Generic Terms}\label{generic-terms}

\begin{itemize}
\item
  \texttt{plist} --- Subset of ASCII Property List format written in
  XML, also know as XML plist format version 1. Uniform Type Identifier
  (UTI): \texttt{com.apple.property-list}. Plists consist of
  \texttt{plist\ objects}, which are combined to form a hierarchical
  structure. Due to plist format not being well-defined, all the
  definitions of this document may only be applied after plist is
  considered valid by running \texttt{plutil\ -lint}. External
  references: https://www.apple.com/DTDs/PropertyList-1.0.dtd,
  \texttt{man\ plutil}.
\item
  \texttt{plist\ type} --- plist collections (\texttt{plist\ array},
  \texttt{plist\ dictionary}, \texttt{plist\ key}) and primitives
  (\texttt{plist\ string}, \texttt{plist\ data}, \texttt{plist\ date},
  \texttt{plist\ boolean}, \texttt{plist\ integer},
  \texttt{plist\ real}).
\item
  \texttt{plist\ object} --- definite realisation of
  \texttt{plist\ type}, which may be interpreted as value.
\item
  \texttt{plist\ array} --- array-like collection, conforms to
  \texttt{array}. Consists of zero or more \texttt{plist\ objects}.
\item
  \texttt{plist\ dictionary} --- map-like (associative array)
  collection, conforms to \texttt{dict}. Consists of zero or more
  \texttt{plist\ keys}.
\item
  \texttt{plist\ key} --- contains one \texttt{plist\ object} going by
  the name of \texttt{plist\ key}, conforms to \texttt{key}. Consists of
  printable 7-bit ASCII characters.
\item
  \texttt{plist\ string} --- printable 7-bit ASCII string, conforms to
  \texttt{string}.
\item
  \texttt{plist\ data} --- base64-encoded blob, conforms to
  \texttt{data}.
\item
  \texttt{plist\ date} --- ISO-8601 date, conforms to \texttt{date},
  unsupported.
\item
  \texttt{plist\ boolean} --- logical state object, which is either true
  (1) or false (0), conforms to \texttt{true} and \texttt{false}.
\item
  \texttt{plist\ integer} --- possibly signed integer number in base 10,
  conforms to \texttt{integer}. Fits in 64-bit unsigned integer in two's
  complement representation, unless a smaller signed or unsigned
  integral type is explicitly mentioned in specific
  \texttt{plist\ object} description.
\item
  \texttt{plist\ real} --- floating point number, conforms to
  \texttt{real}, unsupported.
\item
  \texttt{plist\ metadata} --- value cast to data by the implementation.
  Permits passing \texttt{plist\ string}, in which case the result is
  represented by a null-terminated sequence of bytes (aka C string),
  \texttt{plist\ integer}, in which case the result is represented by
  \emph{32-bit} little endian sequence of bytes in two's complement
  representation, \texttt{plist\ boolean}, in which case the value is
  one byte: \texttt{01} for \texttt{true} and \texttt{00} for
  \texttt{false}, and \texttt{plist\ data} itself. All other types or
  larger integers invoke undefined behaviour.
\end{itemize}

172
\section{Overview}\label{configuration-overview}
V
vit9696 已提交
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333

\subsection{Configuration Terms}\label{configuration-terms}

\begin{itemize}
\item
  \texttt{OC\ config} --- OpenCore Configuration file in \texttt{plist}
  format named \texttt{config.plist}. It has to provide extensible way
  to configure OpenCore and is structured to be separated into multiple
  named sections situated in the root \texttt{plist\ dictionary}. These
  sections are permitted to have \texttt{plist\ array} or
  \texttt{plist\ dictionary} types and are described in corresponding
  sections of this document.
\item
  \texttt{valid\ key} --- \texttt{plist\ key} object of
  \texttt{OC\ config} described in this document or its future
  revisions. Besides explicitly described \texttt{valid\ keys}, keys
  starting with \texttt{\#} symbol (e.g. \texttt{\#Hello}) are also
  considered \texttt{valid\ keys} and behave as comments, effectively
  discarding their value, which is still required to be a valid
  \texttt{plist\ object}. All other \texttt{plist\ keys} are not valid,
  and their presence yields to \texttt{undefined\ behaviour}.
\item
  \texttt{valid\ value} --- valid \texttt{plist\ object} of
  \texttt{OC\ config} described in this document that matches all the
  additional requirements in specific \texttt{plist\ object} description
  if any.
\item
  \texttt{invalid\ value} --- valid \texttt{plist\ object} of
  \texttt{OC\ config} described in this document that is of other
  \texttt{plist\ type}, does not conform to additional requirements
  found in specific \texttt{plist\ object} description (e.g.~value
  range), or missing from the corresponding collection.
  \texttt{Invalid\ value} is read with or without an error message as
  any possible value of this \texttt{plist\ object} in an undetermined
  manner (i.e.~the values may not be same across the reboots). Whilst
  reading an \texttt{invalid\ value} is equivalent to reading certain
  defined \texttt{valid\ value}, applying incompatible value to the host
  system may yield to \texttt{undefined\ behaviour}.
\item
  \texttt{optional\ value} --- \texttt{valid\ value} of
  \texttt{OC\ config} described in this document that reads in a certain
  defined manner provided in specific \texttt{plist\ object} description
  (instead of \texttt{invalid\ value}) when not present in
  \texttt{OC\ config}. All other cases of \texttt{invalid\ value} do
  still apply. Unless explicitly marked as \texttt{optional\ value}, any
  other value is required to be present and reads to
  \texttt{invalid\ value} if missing.
\item
  \texttt{fatal\ behaviour} --- behaviour leading to boot termination.
  Implementation must stop the boot process from going any further until
  next host system boot. It is allowed but not required to perform cold
  reboot or show any warning message.
\item
  \texttt{undefined\ behaviour} --- behaviour not prescribed by this
  document. Implementation is allowed to take any measures including but
  not limited to \texttt{fatal\ behaviour}, assuming any states or
  values, or ignoring, unless these measures negatively affect system
  security in general.
\end{itemize}

\subsection{Configuration Processing}\label{configuration-processing}

\texttt{OC\ config} is guaranteed to be processed at least once if it
was found. Depending on OpenCore bootstrapping mechanism multiple
\texttt{OC\ config} files may lead to reading any of them. No
\texttt{OC\ Config} may be present on disk, in which case all the values
read follow the rules of \texttt{invalid\ value} and
\texttt{optional\ value}.

\texttt{OC\ config} has size, nesting, and key amount limitations.
\texttt{OC\ config} size does not exceed \texttt{16\ MBs}.
\texttt{OC\ config} has no more than \texttt{8} nesting levels.
\texttt{OC\ config} has up to \texttt{16384} XML nodes (i.e.~one
\texttt{plist\ dictionary} item is counted as a pair of nodes) within
each \texttt{plist\ object}.

Reading malformed \texttt{OC\ config} file leads to
\texttt{undefined\ behaviour}. Examples of malformed \texttt{OC\ config}
cover at least the following cases:

\begin{itemize}
\tightlist
\item
  files non-conformant to \texttt{plist} DTD
\item
  files with unsupported or non-conformant \texttt{plist\ objects} found
  in this document
\item
  files violating size, nesting, and key amount limitations
\end{itemize}

It is recommended but not required to abort loading malformed
\texttt{OC\ config} and continue as if no \texttt{OC\ config} was
present. For forward compatibility it is recommended but not required
for the implementation to warn about the use of
\texttt{invalid\ values}. Recommended practice of interpreting
\texttt{invalid\ values} is to conform to the following convention where
applicable:

\begin{longtable}[]{@{}ll@{}}
\toprule
Type & Value\tabularnewline
\midrule
\endhead
\texttt{plist\ string} & Empty string
(\texttt{\textless{}string\textgreater{}\textless{}/string\textgreater{}})\tabularnewline
\texttt{plist\ data} & Empty data
(\texttt{\textless{}data\textgreater{}\textless{}/data\textgreater{}})\tabularnewline
\texttt{plist\ integer} & 0
(\texttt{\textless{}integer\textgreater{}0\textless{}/integer\textgreater{}})\tabularnewline
\texttt{plist\ boolean} & False
(\texttt{\textless{}false/\textgreater{}})\tabularnewline
\texttt{plist\ tristate} & False
(\texttt{\textless{}false/\textgreater{}})\tabularnewline
\bottomrule
\end{longtable}

\subsection{Configuration Structure}\label{configuration-structure}

\texttt{OC\ config} is separated into following sections, which are described
in separate sections of this document. By default it is tried to not enable
anything and optionally provide kill switches with \texttt{Enable} property
for \texttt{plist dict} entries. In general the configuration is written
idiomatically to group similar actions in subsections:

\begin{itemize}
\tightlist
\item
  \texttt{Add} provides support for data addition.
\item
  \texttt{Block} provides support for data removal or ignorance.
\item
  \texttt{Patch} provides support for data modification.
\item
  \texttt{Quirks} provides support for specific hacks.
\end{itemize}

Root configuration entries consist of the following:

\begin{itemize}
\tightlist
\item
  \hyperref[acpi]{\texttt{ACPI}}
\item
  \hyperref[devprops]{\texttt{DeviceProperties}}
\item
  \hyperref[kernel]{\texttt{Kernel}}
\item
  \hyperref[misc]{\texttt{Misc}}
\item
  \hyperref[nvram]{\texttt{NVRAM}}
\item
  \hyperref[platforminfo]{\texttt{PlatformInfo}}
\item
  \hyperref[uefi]{\texttt{UEFI}}
\end{itemize}

\emph{Note}: Currently most properties try to have defined values even if not
specified in the configuration for safety reasons. This behaviour should not
be relied upon, and all fields must be properly specified in the configuration.

V
vit9696 已提交
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
\subsection{Directory Structure}\label{directory-structure}

When directory boot is used the directory structure used should follow
the description on \hyperref[fig:DS]{Directory Structure} figure. Available
entries include:

\begin{itemize}
\tightlist
\item
  \texttt{BOOTx64.efi}
  \break
  Initial booter, which loads \texttt{OpenCore.efi} unless it was
  already started as a driver.
\item
  \texttt{ACPI}
  \break
  Directory used for storing supplemental ACPI information
  for \hyperref[acpi]{\texttt{ACPI}} section.
\item
  \texttt{Drivers}
  \break
  Directory used for storing supplemental \texttt{UEFI}
  drivers for \hyperref[uefi]{\texttt{UEFI}} section.
\item
  \texttt{Kexts}
  \break
  Directory used for storing supplemental kernel information
  for \hyperref[kernel]{\texttt{Kernel}} section.
362 363 364 365
\item
  \texttt{Tools}
  \break
  Directory used for storing supplemental tools.
V
vit9696 已提交
366 367 368 369 370
\item
  \texttt{OpenCore.efi}
  \break
  Main booter driver responsible for operating system loading.
\item
V
vit9696 已提交
371
  \texttt{vault.plist}
V
vit9696 已提交
372 373 374 375 376 377 378
  \break
  Hashes for all files potentially loadable by \texttt{OC Config}.
\item
  \texttt{config.plist}
  \break
  \texttt{OC Config}.
\item
V
vit9696 已提交
379
  \texttt{vault.sig}
V
vit9696 已提交
380
  \break
V
vit9696 已提交
381
  Signature for \texttt{vault.plist}.
382 383 384 385 386 387 388 389
\item
  \texttt{nvram.plist}
  \break
  OpenCore variable import file.
\item
  \texttt{opencore.log}
  \break
  OpenCore log file.
V
vit9696 已提交
390 391
\end{itemize}

392
\begin{center}
V
vit9696 已提交
393 394 395 396
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
397 398 399 400
  \node {ESP}
    child { node {EFI}
      child { node {BOOT}
        child { node [selected] {BOOTx64.efi}}
V
vit9696 已提交
401
      }
402
      child [missing] {}
403 404
      child { node {OC}
        child { node {ACPI}
405 406 407
          child { node [optional] {DSDT.aml}}
          child { node [optional] {SSDT-1.aml}}
          child { node [optional] {MYTABLE.aml}}
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
        }
        child [missing] {}
        child [missing] {}
        child [missing] {}
        child { node {Drivers}
          child { node [optional] {MyDriver.efi}}
          child { node [optional] {OtherDriver.efi}}
        }
        child [missing] {}
        child [missing] {}
        child { node {Kexts}
          child { node [optional] {MyKext.kext}}
          child { node [optional] {OtherKext.kext}}
        }
        child [missing] {}
        child [missing] {}
        child { node  {Tools}
          child { node [optional] {Tool.efi}}
        }
        child [missing] {}
        child { node [selected] {OpenCore.efi}}
        child { node [optional] {vault.plist}}
        child { node {config.plist}}
        child { node [optional] {vault.sig}}
432
      }
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
    }
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child { node [optional] {nvram.plist}}
    child { node [optional] {opencore.log}}
  ;
V
vit9696 已提交
456
\end{tikzpicture}
457 458 459 460 461
\break
\label{fig:DS}
Figure 1. Directory Structure
\end{center}

462 463 464 465 466 467 468 469
\subsection{Installation and Upgrade}\label{configuration-install}

To install OpenCore reflect the
\hyperref[configuration-structure]{Configuration Structure} described
in the previous section on a EFI volume of a GPT partition. While
corresponding sections of this document do provide some information
in regards to external resources like ACPI tables, UEFI drivers,
or kernel extensions (kexts), completeness of the matter is out of
V
vit9696 已提交
470 471 472 473
the scope of this document. Information about kernel extensions may
be found in a separate
\href{https://github.com/acidanthera/OpenCorePkg/blob/master/Docs/Kexts.md}{Kext List}
document available in OpenCore repository. Vaulting information is provided in
474 475 476 477 478 479 480 481 482 483 484 485
\hyperref[miscsecurityprops]{Security Properties} section of this document.

\texttt{OC\ config}, just like any property lists can be edited with any
stock textual editor (e.g. nano, vim), but specialised software may provide
better experience. On macOS the preferred GUI application is
\href{https://developer.apple.com/xcode}{Xcode}. For a lightweight
cross-platform and open-source alternative
\href{https://github.com/corpnewt/ProperTree}{ProperTree} editor can be
utilised.

For BIOS booting a third-party UEFI environment provider will have to
be used. \texttt{DuetPkg} is one of the known UEFI environment providers
486
for legacy systems. To run OpenCore on such a legacy system you can install
487
\texttt{DuetPkg} with a dedicated tool:
488
\href{https://github.com/acidanthera/OcSupportPkg/tree/master/Tools/BootInstall}{BootInstall}.
489 490 491 492 493 494

For upgrade purposes refer to \texttt{Differences.pdf} document, providing
the information about the changes affecting the configuration compared
to the previous release, and \texttt{Changelog.md} document, containing
the list of modifications across all published updates.

495 496
\subsection{Contribution}\label{configuration-comp}

V
vit9696 已提交
497 498 499 500 501 502 503
OpenCore can be compiled as an ordinary
\href{https://github.com/tianocore/tianocore.github.io/wiki/EDK-II}{EDK II}.
Since \href{https://github.com/tianocore/tianocore.github.io/wiki/UDK}{UDK}
development was abandoned by TianoCore, OpenCore requires the use of
\href{https://github.com/tianocore/tianocore.github.io/wiki/EDK-II#stable-tags}{EDK II Stable}.
Currently supported EDK II release (potentially with patches enhancing the experience)
is hosted in \href{https://github.com/acidanthera/audk}{acidanthera/audk}.
504 505 506 507 508 509

The only officially supported toolchain is \texttt{XCODE5}. Other toolchains
might work, but are neither supported, nor recommended. Contribution of clean
patches is welcome. Please do follow
\href{https://github.com/tianocore/tianocore.github.io/wiki/Code-Style-C}{EDK II C Codestyle}.

V
vit9696 已提交
510 511 512 513
Required external package dependencies include
\href{https://github.com/acidanthera/OcSupportPkg}{EfiPkg},
\href{https://github.com/acidanthera/OcSupportPkg}{MacInfoPkg}, and
\href{https://github.com/acidanthera/OcSupportPkg}{OcSupportPkg}.
514 515 516

To compile with \texttt{XCODE5}, besides \href{https://developer.apple.com/xcode}{Xcode},
one should also install \href{https://www.nasm.us}{NASM} and
517 518 519
\href{https://github.com/acidanthera/ocbuild/raw/master/external/mtoc-mac64.zip}{MTOC}.
The latest Xcode version is recommended for use despite the toolchain name. Example
command sequence may look as follows:
520

V
vit9696 已提交
521
\begin{lstlisting}[caption=Compilation Commands, label=compile, style=ocbash]
V
vit9696 已提交
522
git clone https://github.com/acidanthera/audk UDK
523 524
cd UDK
git clone https://github.com/acidanthera/EfiPkg
V
vit9696 已提交
525
git clone https://github.com/acidanthera/MacInfoPkg
526 527 528
git clone https://github.com/acidanthera/OcSupportPkg
git clone https://github.com/acidanthera/OpenCorePkg
source edksetup.sh
V
vit9696 已提交
529
make -C BaseTools
530 531 532
build -a X64 -b RELEASE -t XCODE5 -p OpenCorePkg/OpenCorePkg.dsc
\end{lstlisting}

V
vit9696 已提交
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
\texttt{NOOPT} or \texttt{DEBUG} build modes instead of \texttt{RELEASE}
can produce a lot more debug output. With \texttt{NOOPT} source level debugging with
GDB or IDA Pro is also available. For GDB check
\href{https://github.com/acidanthera/OcSupportPkg/tree/master/Debug}{OcSupport Debug}
page. For IDA Pro you will need IDA Pro 7.3 or newer.

For IDE usage Xcode projects are available in the root of the repositories. Another
approach could be \href{https://www.sublimetext.com}{Sublime Text} with
\href{https://niosus.github.io/EasyClangComplete}{EasyClangComplete} plugin.
Add \texttt{.clang\_complete} file with similar content to your UDK root:

\begin{lstlisting}[caption=ECC Configuration, label=eccfile, style=ocbash]
-I/UefiPackages/MdePkg
-I/UefiPackages/MdePkg/Include
-I/UefiPackages/MdePkg/Include/X64
-I/UefiPackages/EfiPkg
-I/UefiPackages/EfiPkg/Include
-I/UefiPackages/EfiPkg/Include/X64
-I/UefiPackages/AptioFixPkg/Include
-I/UefiPackages/AppleSupportPkg/Include
-I/UefiPackages/OpenCorePkg/Include
-I/UefiPackages/OcSupportPkg/Include
555
-I/UefiPackages/MacInfoPkg/Include
V
vit9696 已提交
556
-I/UefiPackages/UefiCpuPkg/Include
V
vit9696 已提交
557 558 559 560 561 562 563 564 565 566 567
-IInclude
-include
/UefiPackages/MdePkg/Include/Uefi.h
-fshort-wchar
-Wall
-Wextra
-Wno-unused-parameter
-Wno-missing-braces
-Wno-missing-field-initializers
-Wno-tautological-compare
-Wno-sign-compare
568
-Wno-varargs
V
vit9696 已提交
569 570
-Wno-unused-const-variable
\end{lstlisting}
V
vit9696 已提交
571

V
vit9696 已提交
572 573 574 575 576 577 578 579
\textbf{Warning}: Tool developers modifying \texttt{config.plist} or any other OpenCore
files must ensure that their tool checks for \texttt{opencore-version} NVRAM variable
(see \hyperref[miscdebugprops]{Debug Properties} section below) and warn the user
if the version listed is unsupported or prerelease. OpenCore configuration may change
across the releases and the tool shall ensure that it carefully follows this document.
Failure to do so may result in this tool to be considered as malware and blocked with
all possible means.

V
vit9696 已提交
580 581 582 583 584 585 586 587 588 589 590 591
\section{ACPI}\label{acpi}

\subsection{Introduction}\label{acpiintro}

ACPI (Advanced Configuration and Power Interface) is an open standard to
discover and configure computer hardware.
\href{https://uefi.org/specifications}{ACPI specification} defines the
standard tables (e.g.~\texttt{DSDT}, \texttt{SSDT}, \texttt{FACS}, \texttt{DMAR})
and various methods (e.g. \texttt{\_DSM}, \texttt{\_PWR}) for implementation.
Modern hardware needs little changes to maintain ACPI compatibility, yet
some of those are provided as a part of OpenCore.

V
vit9696 已提交
592 593 594 595
To compile and disassemble ACPI tables \href{https://github.com/acpica/acpica}{iASL compiler}
can be used developed by \href{https://www.acpica.org}{ACPICA}. GUI front-end to iASL compiler
can be downloaded from \href{https://github.com/acidanthera/MaciASL/releases}{Acidanthera/MaciASL}.

V
vit9696 已提交
596 597 598 599 600 601
\subsection{Properties}\label{acpiprops}

\begin{enumerate}
\item
  \texttt{Add}\\
  \textbf{Type}: \texttt{plist\ array}\\
602
  \textbf{Failsafe}: Empty\\
603
  \textbf{Description}: Load selected tables from \texttt{OC/ACPI}
V
vit9696 已提交
604 605
  directory.

606 607
  Designed to be filled with \texttt{plist\ dict} values, describing each block entry.
  See \hyperref[acpipropsadd]{Add Properties} section below.
V
vit9696 已提交
608 609 610 611

\item
  \texttt{Block}\\
  \textbf{Type}: \texttt{plist\ array}\\
612
  \textbf{Failsafe}: Empty\\
V
vit9696 已提交
613 614 615 616 617 618 619 620
  \textbf{Description}: Remove selected tables from ACPI stack.

  Designed to be filled with \texttt{plist\ dict} values, describing each block entry.
  See \hyperref[acpipropsblock]{Block Properties} section below.

\item
  \texttt{Patch}\\
  \textbf{Type}: \texttt{plist\ array}\\
621
  \textbf{Failsafe}: Empty\\
622 623
  \textbf{Description}: Perform binary patches in ACPI tables before
  table addition or removal.
V
vit9696 已提交
624 625 626 627 628 629 630 631 632 633 634 635

  Designed to be filled with \texttt{plist\ dictionary} values describing each
  patch entry. See \hyperref[acpipropspatch]{Patch Properties} section below.

\item
  \texttt{Quirks}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Apply individual ACPI quirks described
  in \hyperref[acpipropsquirks]{Quirks Properties} section below.

\end{enumerate}

636 637 638 639 640 641
\subsection{Add Properties}\label{acpipropsadd}

\begin{enumerate}
\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
642
  \textbf{Failsafe}: Empty string\\
643 644 645 646 647 648 649
  \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{Enabled}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
650
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
651
  \textbf{Description}: This ACPI table will not be added unless set to
652 653 654 655 656
  \texttt{true}.

\item
  \texttt{Path}\\
  \textbf{Type}: \texttt{plist\ string}\\
657
  \textbf{Failsafe}: Empty string\\
658 659 660 661 662
  \textbf{Description}: File paths meant to be loaded as ACPI tables.
  Example values include \texttt{DSDT.aml}, \texttt{SubDir/SSDT-8.aml},
  \texttt{SSDT-USBX.aml}, etc.

  ACPI table load order follows the item order in the array. All ACPI tables
663
  load from \texttt{OC/ACPI} directory.
664 665 666 667 668 669 670

  \textbf{Note}: All tables but tables with \texttt{DSDT} table identifier
  (determined by parsing data not by filename) insert new tables into ACPI stack.
  \texttt{DSDT}, unlike the rest, performs replacement of DSDT table.

\end{enumerate}

V
vit9696 已提交
671 672 673
\subsection{Block Properties}\label{acpipropsblock}

\begin{enumerate}
674 675 676
\item
  \texttt{All}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
677
  \textbf{Failsafe}: \texttt{false}\\
678 679 680
  \textbf{Description}: If set to \texttt{true}, all ACPI tables matching the
  condition will be dropped. Otherwise only first matched table.

V
vit9696 已提交
681 682 683
\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
684
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
685 686 687 688 689 690 691
  \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{Enabled}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
692
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
693 694 695 696 697 698
  \textbf{Description}: This ACPI table will not be removed unless set to
  \texttt{true}.

\item
  \texttt{OemTableId}\\
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
699
  \textbf{Failsafe}: All zero\\
V
vit9696 已提交
700 701 702 703
  \textbf{Description}: Match table OEM ID to be equal to this value
  unless all zero.

\item
704
  \texttt{TableLength}\\
V
vit9696 已提交
705
  \textbf{Type}: \texttt{plist\ integer}\\
706
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
707 708 709
  \textbf{Description}: Match table size to be equal to this value
  unless \texttt{0}.

710 711 712
\item
  \texttt{TableSignature}\\
  \textbf{Type}: \texttt{plist\ data}, 4 bytes\\
713
  \textbf{Failsafe}: All zero\\
714 715 716
  \textbf{Description}: Match table signature to be equal to this value
  unless all zero.

V
vit9696 已提交
717 718 719 720 721 722 723 724 725
\end{enumerate}

\subsection{Patch Properties}\label{acpipropspatch}

\begin{enumerate}

\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
726
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
727 728 729 730 731 732 733
  \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{Count}\\
  \textbf{Type}: \texttt{plist\ integer}\\
734
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
735 736 737 738 739 740
  \textbf{Description}: Number of patch occurrences to apply. \texttt{0} applies
  the patch to all occurrences found.

\item
  \texttt{Enabled}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
741
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
742 743 744 745 746 747
  \textbf{Description}: This ACPI patch will not be used unless set to
  \texttt{true}.

\item
  \texttt{Find}\\
  \textbf{Type}: \texttt{plist\ data}\\
748
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
749 750 751 752 753
  \textbf{Description}: Data to find. Must equal to \texttt{Replace} in size.

\item
  \texttt{Limit}\\
  \textbf{Type}: \texttt{plist\ integer}\\
754
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
755 756 757 758 759 760
  \textbf{Description}: Maximum number of bytes to search for. Can be set to
  \texttt{0} to look through the whole ACPI table.

\item
  \texttt{Mask}\\
  \textbf{Type}: \texttt{plist\ data}\\
761
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
762 763 764 765 766 767 768 769
  \textbf{Description}: Data bitwise mask used during find comparison.
  Allows fuzzy search by ignoring not masked (set to zero) bits. Can be
  set to empty data to be ignored. Must equal to \texttt{Replace} in size
  otherwise.

\item
  \texttt{OemTableId}\\
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
770
  \textbf{Failsafe}: All zero\\
V
vit9696 已提交
771 772 773 774 775 776
  \textbf{Description}: Match table OEM ID to be equal to this value
  unless all zero.

\item
  \texttt{Replace}\\
  \textbf{Type}: \texttt{plist\ data}\\
777
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
778 779 780 781 782
  \textbf{Description}: Replacement data of one or more bytes.

\item
  \texttt{ReplaceMask}\\
  \textbf{Type}: \texttt{plist\ data}\\
783
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
784 785 786 787 788 789 790 791
  \textbf{Description}: Data bitwise mask used during replacement.
  Allows fuzzy replacement by updating masked (set to non-zero) bits. Can be
  set to empty data to be ignored. Must equal to \texttt{Replace} in size
  otherwise.

\item
  \texttt{Skip}\\
  \textbf{Type}: \texttt{plist\ integer}\\
792
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
793 794 795 796 797 798
  \textbf{Description}: Number of found occurrences to be skipped before replacement
  is done.

\item
  \texttt{TableLength}\\
  \textbf{Type}: \texttt{plist\ integer}\\
799
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
800 801 802 803 804 805
  \textbf{Description}: Match table size to be equal to this value
  unless \texttt{0}.

\item
  \texttt{TableSignature}\\
  \textbf{Type}: \\texttt{plist\ data}, 4 bytes\\
806
  \textbf{Failsafe}: All zero\\
V
vit9696 已提交
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
  \textbf{Description}: Match table signature to be equal to this value
  unless all zero.

\end{enumerate}

In the majority of the cases ACPI patches are not useful and harmful:

\begin{itemize}
\item
  Avoid renaming devices with ACPI patches. This may fail or perform
  improper renaming of unrelated devices (e.g. \texttt{EC} and
  \texttt{EC0}), be unnecessary, or even fail to rename devices in select tables. For
  ACPI consistency it is much safer to rename devices at I/O Registry
  level, as done by
  \href{https://github.com/acidanthera/WhateverGreen}{WhateverGreen}.
\item
  Avoid patching \texttt{\_OSI} to support a higher level of feature sets
  unless absolutely required. Commonly this enables a number of hacks on APTIO
  firmwares, which result in the need to add more patches. Modern firmwares
  generally do not need it at all, and those that do are fine with much
  smaller patches.
\item
  Try to avoid hacky changes like renaming \texttt{\_PWR} or \texttt{\_DSM}
  whenever possible.
\end{itemize}

Several cases, where patching actually does make sense, include:

\begin{itemize}
\item
  Refreshing \texttt{HPET} (or another device) method header to avoid
  compatibility checks by \texttt{\_OSI} on legacy hardware. \texttt{\_STA}
  method with \texttt{if ((OSFL () == Zero)) \{ If (HPTE)  ...  Return (Zero)}
  content may be forced to always return 0xF by replacing
  \texttt{A0 10 93 4F 53 46 4C 00} with \texttt{A4 0A 0F A3 A3 A3 A3 A3}.
\item
  To provide custom method implementation with in an SSDT, for instance,
  to report functional key presses on a laptop, the original method can be replaced
  with a dummy name by patching \texttt{\_Q11} with \texttt{XQ11}.
\end{itemize}

Tianocore \href{https://github.com/tianocore/edk2/blob/UDK2018/MdePkg/Include/IndustryStandard/AcpiAml.h}{AcpiAml.h}
source file may help understanding ACPI opcodes.

\subsection{Quirks Properties}\label{acpipropsquirks}

\begin{enumerate}

\item
  \texttt{FadtEnableReset}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
858
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
859 860 861 862 863 864
  \textbf{Description}: Provide reset register and flag in FADT table to enable
  reboot and shutdown on legacy hardware. Not recommended unless required.

\item
  \texttt{NormalizeHeaders}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
865
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
866 867 868 869 870 871 872 873 874
  \textbf{Description}: Cleanup ACPI header fields to workaround macOS
  ACPI implementation bug causing boot crashes. Reference:
  \href{https://alextjam.es/debugging-appleacpiplatform/}{Debugging
  AppleACPIPlatform on 10.13} by Alex James aka theracermaster. The
  issue is fixed in macOS Mojave (10.14).

\item
  \texttt{RebaseRegions}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
875
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900
  \textbf{Description}: Attempt to heuristically relocate ACPI memory
  regions. Not recommended.

  ACPI tables are often generated dynamically by underlying firmware
  implementation. Among the position-independent code, ACPI tables may
  contain physical addresses of MMIO areas used for device
  configuration, usually grouped in regions (e.g.
  \texttt{OperationRegion}). Changing firmware settings or hardware
  configuration, upgrading or patching the firmware inevitably leads to
  changes in dynamically generated ACPI code, which sometimes lead to
  the shift of the addresses in aforementioned \texttt{OperationRegion}
  constructions.

  For this reason it is very dangerous to apply any kind of
  modifications to ACPI tables. The most reasonable approach is to make
  as few as possible changes to ACPI and try to not replace any tables,
  especially DSDT. When this is not possible, then at least attempt to
  ensure that custom DSDT is based on the most recent DSDT or remove
  writes and reads for the affected areas.

  When nothing else helps this option could be tried to avoid stalls at
  \texttt{PCI\ Configuration\ Begin} phase of macOS booting by
  attempting to fix the ACPI addresses. It does not do magic, and only
  works with most common cases. Do not use unless absolutely required.

901 902 903
\item
  \texttt{ResetHwSig}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
904
  \textbf{Failsafe}: \texttt{false}\\
905 906 907 908 909 910
  \textbf{Description}: Reset \texttt{FACS} table \texttt{HardwareSignature}
  value to \texttt{0}.

  This works around firmwares that fail to maintain hardware signature across
  the reboots and cause issues with waking from hibernation.

911 912 913
\item
  \texttt{ResetLogoStatus}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
914
  \textbf{Failsafe}: \texttt{false}\\
915 916 917 918 919 920
  \textbf{Description}: Reset \texttt{BGRT} table \texttt{Displayed}
  status field to \texttt{false}.

  This works around firmwares that provide \texttt{BGRT} table but
  fail to handle screen updates afterwards.

V
vit9696 已提交
921 922 923 924 925 926 927 928 929 930 931
\end{enumerate}


\section{DeviceProperties}\label{devprops}

\subsection{Introduction}\label{devpropsintro}

Device configuration is provided to macOS with a dedicated buffer,
called \texttt{EfiDevicePropertyDatabase}. This buffer is a serialised
map of DevicePaths to a map of property names and their values.

V
vit9696 已提交
932 933 934 935 936 937 938 939 940 941
Property data can be debugged with
\href{https://github.com/acidanthera/gfxutil}{gfxutil}.
To obtain current property data use the following command in macOS:
\begin{lstlisting}[label=gfxutil, style=ocbash]
ioreg -lw0 -p IODeviceTree -n efi -r -x | grep device-properties |
  sed 's/.*<//;s/>.*//' > /tmp/device-properties.hex &&
  gfxutil /tmp/device-properties.hex /tmp/device-properties.plist &&
  cat /tmp/device-properties.plist
\end{lstlisting}

V
vit9696 已提交
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
\subsection{Properties}\label{devpropsprops}

\begin{enumerate}
\item
  \texttt{Add}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Sets device properties from a map (\texttt{plist\ dict})
  of deivce paths to a map (\texttt{plist\ dict}) of variable names and their values
  in \texttt{plist\ metadata} format. Device paths must be provided in canonic string
  format (e.g. \texttt{PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)}). Properties will only
  be set if not present and not blocked.

  \emph{Note}: Currently properties may only be (formerly) added by the original driver,
  so unless a separate driver was installed, there is no reason to block the variables.

\item
  \texttt{Block}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Removes device properties from a map (\texttt{plist\ dict})
  of deivce paths to an array (\texttt{plist\ array}) of variable names in
  \texttt{plist\ string} format.

\end{enumerate}

\subsection{Common Properties}\label{devpropscommon}

Some known properties include:

\begin{itemize}
\tightlist
\item
  \texttt{device-id}
  \break
  User-specified device identifier used for I/O Kit matching. Has 4 byte data type.
\item
  \texttt{vendor-id}
  \break
  User-specified vendor identifier used for I/O Kit matching. Has 4 byte data type.
\item
  \texttt{AAPL,ig-platform-id}
  \break
  Intel GPU framebuffer identifier used for framebuffer selection on Ivy Bridge and newer.
  Has 4 byte data type.
\item
  \texttt{AAPL,snb-platform-id}
  \break
  Intel GPU framebuffer identifier used for framebuffer selection on Sandy Bridge.
  Has 4 byte data type.
\item
  \texttt{layout-id}
  \break
  Audio layout used for AppleHDA layout selection. Has 4 byte data type.
\end{itemize}


\section{Kernel}\label{kernel}

\subsection{Introduction}\label{kernelintro}

This section allows to apply different kinds of kernelspace modifications on
Apple Kernel (\href{https://opensource.apple.com/source/xnu}{XNU}). The modifications
currently provide driver (kext) injection, kernel and driver patching, and driver
blocking.

\subsection{Properties}\label{kernelprops}

\begin{enumerate}
\item
  \texttt{Add}\\
  \textbf{Type}: \texttt{plist\ array}\\
1012
  \textbf{Failsafe}: Empty\\
V
vit9696 已提交
1013 1014 1015
  \textbf{Description}: Load selected kernel drivers from \texttt{OC/Kexts} directory.

  Designed to be filled with \texttt{plist\ dict} values, describing each driver.
V
vit9696 已提交
1016 1017 1018
  See \hyperref[kernelpropsadd]{Add Properties} section below. Kernel driver load
  order follows the item order in the array, thus the dependencies should be written
  prior to their consumers.
V
vit9696 已提交
1019 1020 1021 1022

\item
  \texttt{Block}\\
  \textbf{Type}: \texttt{plist\ array}\\
1023
  \textbf{Failsafe}: Empty\\
V
vit9696 已提交
1024 1025 1026 1027 1028
  \textbf{Description}: Remove selected kernel drivers from prelinked kernel.

  Designed to be filled with \texttt{plist\ dictionary} values, describing each
  blocked driver. See \hyperref[kernelpropsblock]{Block Properties} section below.

1029 1030 1031 1032 1033 1034
\item
  \texttt{Emulate}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Emulate select hardware in kernelspace via parameters
  described in \hyperref[kernelpropsemu]{Emulate Properties} section below.

V
vit9696 已提交
1035 1036 1037
\item
  \texttt{Patch}\\
  \textbf{Type}: \texttt{plist\ array}\\
1038
  \textbf{Failsafe}: Empty\\
V
vit9696 已提交
1039
  \textbf{Description}: Perform binary patches in kernel and drivers prior to
1040
  driver addition and removal.
V
vit9696 已提交
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056

  Designed to be filled with \texttt{plist\ dictionary} values, describing each
  patch. See \hyperref[kernelpropspatch]{Patch Properties} section below.

\item
  \texttt{Quirks}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Apply individual kernel and driver quirks described
  in \hyperref[kernelpropsquirks]{Quirks Properties} section below.

\end{enumerate}

\subsection{Add Properties}\label{kernelpropsadd}

\begin{enumerate}
\item
1057
  \texttt{BundlePath}\\
V
vit9696 已提交
1058
  \textbf{Type}: \texttt{plist\ string}\\
1059
  \textbf{Failsafe}: Empty string\\
1060 1061
  \textbf{Description}: Kext bundle path (e.g. \texttt{Lilu.kext}
  or \texttt{MyKext.kext/Contents/PlugIns/MySubKext.kext}).
V
vit9696 已提交
1062 1063 1064 1065

\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
1066
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1067 1068 1069 1070 1071 1072 1073
  \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{Enabled}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1074
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1075 1076 1077 1078 1079 1080
  \textbf{Description}: This kernel driver will not be added unless set to
  \texttt{true}.

\item
  \texttt{ExecutablePath}\\
  \textbf{Type}: \texttt{plist\ string}\\
1081
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1082 1083 1084 1085 1086 1087
  \textbf{Description}: Kext executable path relative to bundle
  (e.g. \texttt{Contents/MacOS/Lilu}).

\item
  \texttt{MatchKernel}\\
  \textbf{Type}: \texttt{plist\ string}\\
1088
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1089 1090 1091 1092 1093 1094 1095 1096
  \textbf{Description}: Blocks kernel driver on selected macOS version only.
  The selection happens based on prefix match with the kernel version, i.e.
  \texttt{16.7.0} will match macOS 10.12.6 and \texttt{16.} will match
  any macOS 10.12.x version.

\item
  \texttt{PlistPath}\\
  \textbf{Type}: \texttt{plist\ string}\\
1097
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
  \textbf{Description}: Kext \texttt{Info.plist} path relative to bundle
  (e.g. \texttt{Contents/Info.plist}).

\end{enumerate}

\subsection{Block Properties}\label{kernelpropsblock}

\begin{enumerate}
\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
1109
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1110 1111 1112 1113 1114 1115 1116
  \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{Enabled}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1117
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1118
  \textbf{Description}: This kernel driver will not be blocked unless set to
V
vit9696 已提交
1119 1120 1121 1122 1123
  \texttt{true}.

\item
  \texttt{Identifier}\\
  \textbf{Type}: \texttt{plist\ string}\\
1124
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1125 1126 1127 1128 1129 1130
  \textbf{Description}: Kext bundle identifier
    (e.g. \texttt{com.apple.driver.AppleTyMCEDriver}).

\item
  \texttt{MatchKernel}\\
  \textbf{Type}: \texttt{plist\ string}\\
1131
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1132 1133 1134 1135 1136 1137 1138
  \textbf{Description}: Blocks kernel driver on selected macOS version only.
  The selection happens based on prefix match with the kernel version, i.e.
  \texttt{16.7.0} will match macOS 10.12.6 and \texttt{16.} will match
  any macOS 10.12.x version.

\end{enumerate}

1139 1140 1141 1142 1143 1144
\subsection{Emulate Properties}\label{kernelpropsemu}

\begin{enumerate}
\item
  \texttt{Cpuid1Data}\\
  \textbf{Type}: \texttt{plist\ data}, 32 bytes\\
1145
  \textbf{Failsafe}: All zero\\
1146 1147 1148 1149 1150 1151 1152
  \textbf{Description}: Sequence of \texttt{EAX}, \texttt{EBX}, \texttt{ECX},
  \texttt{EDX} values in Little Endian order to replace \texttt{CPUID (1)}
  call in XNU kernel.

\item
  \texttt{Cpuid1Mask}\\
  \textbf{Type}: \texttt{plist\ data}, 32 bytes\\
1153
  \textbf{Failsafe}: All zero\\
1154 1155 1156 1157 1158 1159
  \textbf{Description}: Bit mask of active bits in \texttt{Cpuid1Data}. When
  each \texttt{Cpuid1Mask} is set to 0, the original CPU bit is used, otherwise
  .

\end{enumerate}

V
vit9696 已提交
1160 1161 1162 1163 1164 1165
\subsection{Patch Properties}\label{kernelpropspatch}

\begin{enumerate}
\item
  \texttt{Base}\\
  \textbf{Type}: \texttt{plist\ string}\\
1166
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1167 1168 1169 1170 1171 1172 1173
  \textbf{Description}: Selects symbol-matched base for patch lookup (or immediate
  replacement) by obtaining the address of provided symbol name. Can be set to
  empty string to be ignored.

\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
1174
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1175 1176 1177 1178 1179 1180 1181
  \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{Count}\\
  \textbf{Type}: \texttt{plist\ integer}\\
1182
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
1183 1184 1185 1186 1187 1188
  \textbf{Description}: Number of patch occurrences to apply. \texttt{0} applies
  the patch to all occurrences found.

\item
  \texttt{Enabled}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1189
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1190 1191 1192 1193 1194 1195
  \textbf{Description}: This kernel patch will not be used unless set to
  \texttt{true}.

\item
  \texttt{Find}\\
  \textbf{Type}: \texttt{plist\ data}\\
1196
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
1197 1198 1199 1200 1201 1202 1203
  \textbf{Description}: Data to find. Can be set to empty for immediate
  replacement at \texttt{Base}. Must equal to \texttt{Replace} in size
  otherwise.

\item
  \texttt{Identifier}\\
  \textbf{Type}: \texttt{plist\ string}\\
1204
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1205 1206 1207 1208 1209 1210
  \textbf{Description}: Kext bundle identifier (e.g. \texttt{com.apple.driver.AppleHDA})
  or \texttt{kernel} for kernel patch.

\item
  \texttt{Limit}\\
  \textbf{Type}: \texttt{plist\ integer}\\
1211
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
1212 1213 1214 1215 1216 1217
  \textbf{Description}: Maximum number of bytes to search for. Can be set to
  \texttt{0} to look through the whole kext or kernel.

\item
  \texttt{Mask}\\
  \textbf{Type}: \texttt{plist\ data}\\
1218
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
1219 1220 1221 1222 1223 1224 1225 1226
  \textbf{Description}: Data bitwise mask used during find comparison.
  Allows fuzzy search by ignoring not masked (set to zero) bits. Can be
  set to empty data to be ignored. Must equal to \texttt{Replace} in size
  otherwise.

\item
  \texttt{MatchKernel}\\
  \textbf{Type}: \texttt{plist\ string}\\
1227
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1228
  \textbf{Description}: Adds kernel driver to selected macOS version only.
V
vit9696 已提交
1229 1230 1231 1232 1233 1234 1235
  The selection happens based on prefix match with the kernel version, i.e.
  \texttt{16.7.0} will match macOS 10.12.6 and \texttt{16.} will match
  any macOS 10.12.x version.

\item
  \texttt{Replace}\\
  \textbf{Type}: \texttt{plist\ data}\\
1236
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
1237 1238 1239 1240 1241
  \textbf{Description}: Replacement data of one or more bytes.

\item
  \texttt{ReplaceMask}\\
  \textbf{Type}: \texttt{plist\ data}\\
1242
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
1243 1244 1245 1246 1247 1248 1249 1250
  \textbf{Description}: Data bitwise mask used during replacement.
  Allows fuzzy replacement by updating masked (set to non-zero) bits. Can be
  set to empty data to be ignored. Must equal to \texttt{Replace} in size
  otherwise.

\item
  \texttt{Skip}\\
  \textbf{Type}: \texttt{plist\ integer}\\
1251
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
1252 1253 1254 1255 1256 1257 1258 1259
  \textbf{Description}: Number of found occurrences to be skipped before replacement
  is done.

\end{enumerate}

\subsection{Quirks Properties}\label{kernelpropsquirks}

\begin{enumerate}
1260

V
vit9696 已提交
1261 1262 1263
\item
  \texttt{AppleCpuPmCfgLock}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1264
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1265 1266 1267 1268 1269 1270 1271 1272 1273
  \textbf{Description}: Disables \texttt{PKG\_CST\_CONFIG\_CONTROL} (\texttt{0xE2})
  MSR modification in AppleIntelCPUPowerManagement.kext, commonly causing early
  kernel panic, when it is locked from writing.

  \emph{Note}: This option should avoided whenever possible. Modern firmwares provide
  \texttt{CFG Lock} setting, disabling which is much cleaner. More details
  about the issue can be found in
  \href{https://github.com/acidanthera/AptioFixPkg#verifymsre2}{VerifyMsrE2} notes.

1274 1275 1276
\item
  \texttt{AppleXcpmCfgLock}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1277
  \textbf{Failsafe}: \texttt{false}\\
1278 1279 1280 1281 1282 1283 1284 1285 1286
  \textbf{Description}: Disables \texttt{PKG\_CST\_CONFIG\_CONTROL} (\texttt{0xE2})
  MSR modification in XNU kernel, commonly causing early kernel panic, when it is
  locked from writing (XCPM power management).

  \emph{Note}: This option should avoided whenever possible. Modern firmwares provide
  \texttt{CFG Lock} setting, disabling which is much cleaner. More details
  about the issue can be found in
  \href{https://github.com/acidanthera/AptioFixPkg#verifymsre2}{VerifyMsrE2} notes.

1287 1288 1289
\item
  \texttt{AppleXcpmExtraMsrs}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1290
  \textbf{Failsafe}: \texttt{false}\\
1291
  \textbf{Description}: Disables multiple MSR access critical for select CPUs,
1292
  which have no native XCPM support.
1293

1294 1295
  This is normally used in conjunction with \texttt{Emulate} section on Haswell-E,
  Broadwell-E, Skylake-X, and similar CPUs. More details on the XCPM patches are outlined in
1296 1297
  \href{https://github.com/acidanthera/bugtracker/issues/365}{acidanthera/bugtracker\#365}.

1298 1299 1300
  \emph{Note}: Additional not provided patches will be required for Ivy Bridge or Pentium
  CPUs. It is recommended to use \texttt{AppleIntelCpuPowerManagement.kext} for the former.

1301 1302 1303
\item
  \texttt{CustomSMBIOSGuid}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1304
  \textbf{Failsafe}: \texttt{false}\\
1305 1306 1307
  \textbf{Description}: Performs GUID patching for \texttt{UpdateSMBIOSMode}
  \texttt{Custom} mode. Usually relevant for Dell laptops.

1308 1309 1310
\item
  \texttt{DisableIoMapper}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1311
  \textbf{Failsafe}: \texttt{false}\\
1312 1313 1314 1315 1316 1317 1318
  \textbf{Description}: Disables \texttt{IOMapper} support in XNU (VT-d),
  which may conflict with the firmware implementation.

  \emph{Note}: This option is a preferred alternative to dropping \texttt{DMAR}
  ACPI table and disabling VT-d in firmware preferences, which does not break
  VT-d support in other systems in case they need it.

V
vit9696 已提交
1319 1320 1321
\item
  \texttt{ExternalDiskIcons}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1322
  \textbf{Failsafe}: \texttt{false}\\
1323
  \textbf{Description}: Apply icon type patches to AppleAHCIPort.kext to force
V
vit9696 已提交
1324 1325 1326 1327 1328
  internal disk icons for all AHCI disks.

  \emph{Note}: This option should avoided whenever possible. Modern firmwares
  usually have compatible AHCI controllers.

1329 1330 1331
\item
  \texttt{LapicKernelPanic}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1332
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1333
  \textbf{Description}: Disables kernel panic on LAPIC interrupts.
1334

1335 1336 1337
\item
  \texttt{PanicNoKextDump}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1338
  \textbf{Failsafe}: \texttt{false}\\
1339 1340 1341
  \textbf{Description}: Prevent kernel from printing kext dump in the panic
  log preventing from observing panic details. Affects 10.13 and above.

V
vit9696 已提交
1342 1343 1344
\item
  \texttt{ThirdPartyTrim}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1345
  \textbf{Failsafe}: \texttt{false}\\
1346
  \textbf{Description}: Patch IOAHCIBlockStorage.kext to force TRIM command support
V
vit9696 已提交
1347 1348 1349 1350 1351 1352 1353 1354 1355
  on AHCI SSDs.

  \emph{Note}: This option should avoided whenever possible. NVMe SSDs are
  compatible without the change. For AHCI SSDs on modern macOS version there
  is a dedicated built-in utility called \texttt{trimforce}.

\item
  \texttt{XhciPortLimit}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1356
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1357 1358 1359 1360 1361 1362 1363
  \textbf{Description}: Patch various kexts (AppleUSBXHCI.kext, AppleUSBXHCIPCI.kext,
  IOUSBHostFamily.kext) to remove USB port count limit of 15 ports.

  \emph{Note}: This option should avoided whenever possible. USB port limit
  is imposed by the amount of used bits in locationID format and there is no
  possible way to workaround this without heavy OS modification. The only
  valid solution is to limit the amount of used ports to 15 (discarding some).
1364
  More details can be found on \href{https://applelife.ru/posts/550233}{AppleLife.ru}.
V
vit9696 已提交
1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376

\end{enumerate}

\section{Misc}\label{misc}

\subsection{Introduction}\label{miscintro}

This section contains miscellaneous configuration entries for OpenCore
behaviour that does not go to any other sections

\subsection{Properties}\label{miscprops}

V
vit9696 已提交
1377
\begin{enumerate}
1378 1379 1380 1381 1382 1383
\item
  \texttt{Boot}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Apply boot configuration described in
  \hyperref[miscbootprops]{Boot Properties} section below.

V
vit9696 已提交
1384 1385 1386 1387 1388 1389
\item
  \texttt{Debug}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Apply debug configuration described in
  \hyperref[miscdebugprops]{Debug Properties} section below.

1390 1391 1392 1393 1394 1395
\item
  \texttt{Security}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Apply security configuration described in
  \hyperref[miscsecurityprops]{Security Properties} section below.

1396 1397 1398 1399
\item
  \texttt{Tools}\\
  \textbf{Type}: \texttt{plist\ array}\\
  \textbf{Description}: Add new entries to boot picker.
1400

1401 1402
  Designed to be filled with \texttt{plist\ dict} values, describing each block entry.
  See \hyperref[misctoolprops]{Tools Properties} section below.
1403

V
vit9696 已提交
1404 1405 1406 1407
  \emph{Note}: Select tools, for example, UEFI Shell or NVRAM cleaning are very
  dangerous and \textbf{MUST NOT} appear in production configurations, especially
  in vaulted ones and protected with secure boot, as they may be used to easily
  bypass secure boot chain.
1408

V
vit9696 已提交
1409 1410
\end{enumerate}

1411 1412 1413 1414
\subsection{Boot Properties}\label{miscbootprops}

\begin{enumerate}

1415 1416 1417
\item
  \texttt{ConsoleMode}\\
  \textbf{Type}: \texttt{plist\ string}\\
1418
  \textbf{Failsafe}: Empty string\\
1419 1420 1421 1422 1423
  \textbf{Description}: Sets console output mode as specified
  with the \texttt{WxH} (e.g. \texttt{80x24}) formatted string.
  Set to empty string not to change console mode. Set to \texttt{Max}
  to try to use largest available console mode.

1424 1425 1426
\item
  \texttt{ConsoleBehaviourOs}\\
  \textbf{Type}: \texttt{plist\ string}\\
1427
  \textbf{Failsafe}: Empty string\\
1428 1429 1430 1431
  \textbf{Description}: Set console control behaviour upon operating system load.

  Console control is a legacy protocol used for switching between text and graphics
  screen output. Some firmwares do not provide it, yet select operating systems
1432
  require its presence, which is what \texttt{ConsoleControl} UEFI protocol is for.
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445

  When console control is available, OpenCore can be made console control aware, and
  and set different modes for the operating system booter (\texttt{ConsoleBehaviourOs}),
  which normally runs in graphics mode, and its own user interface
  (\texttt{ConsoleBehaviourUi}), which normally runs in text mode. Possible
  behaviours, set as values of these options, include:

  \begin{itemize}
  \tightlist
  \item Empty string --- Do not modify console control mode.
  \item \texttt{Text} --- Switch to text mode.
  \item \texttt{Graphics} --- Switch to graphics mode.
  \item \texttt{ForceText} --- Switch to text mode and preserve it
1446
  (requires \texttt{ConsoleControl}).
1447
  \item \texttt{ForceGraphics} --- Switch to graphics mode and preserve it
1448
  (require \texttt{ConsoleControl}).
1449 1450
  \end{itemize}

1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461
  Hints:
  \begin{itemize}
  \tightlist
  \item Unless empty works, firstly try to set
  \texttt{ConsoleBehaviourOs} to \texttt{Graphics} and
  \texttt{ConsoleBehaviourUi} to \texttt{Text}.
  \item On APTIO IV (Haswell and earlier) it is usually enough to have
  \texttt{ConsoleBehaviourOs} set to \texttt{Graphics} and
  \texttt{ConsoleBehaviourUi} set to \texttt{ForceText} to avoid visual glitches.
  \item On APTIO V (Broadwell and newer) \texttt{ConsoleBehaviourOs}
  set to \texttt{ForceGraphics} and \texttt{ConsoleBehaviourUi} set to
1462 1463 1464 1465
  \texttt{ForceText} usually works best.
  \item On Apple firmwares \texttt{ConsoleBehaviourOs}
  set to \texttt{Graphics} and \texttt{ConsoleBehaviourUi} set to
  \texttt{Text} is supposed to work best.
1466
  \end{itemize}
1467 1468 1469 1470 1471 1472 1473

  \emph{Note}: \texttt{IgnoreTextInGraphics} may need to be enabled for select
  firmware implementations.

\item
  \texttt{ConsoleBehaviourUi}\\
  \textbf{Type}: \texttt{plist\ string}\\
1474
  \textbf{Failsafe}: Empty string\\
1475 1476 1477
  \textbf{Description}: Set console control behaviour upon OpenCore user
  interface load. Refer to \texttt{ConsoleBehaviourOs} description for details.

1478 1479 1480
\item
  \texttt{HibernateMode}\\
  \textbf{Type}: \texttt{plist\ string}\\
1481
  \textbf{Failsafe}: \texttt{None}\\
1482 1483 1484 1485 1486 1487 1488 1489 1490 1491
  \textbf{Description}: Hibernation detection mode. The following modes are supported:

  \begin{itemize}
  \tightlist
    \item \texttt{None} --- Avoid hibernation for your own good.
    \item \texttt{Auto} --- Use RTC and NVRAM detection.
    \item \texttt{RTC} --- Use RTC detection.
    \item \texttt{NVRAM} --- Use NVRAM detection.
  \end{itemize}

V
vit9696 已提交
1492 1493 1494
\item
  \texttt{HideSelf}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1495
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1496 1497 1498 1499
  \textbf{Description}: Hides own boot entry from boot picker. This
  may potentially hide other entries, for instance, when another UEFI OS is
  installed on the same volume and driver boot is used.

1500 1501 1502
\item
  \texttt{Resolution}\\
  \textbf{Type}: \texttt{plist\ string}\\
1503
  \textbf{Failsafe}: Empty string\\
1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518
  \textbf{Description}: Sets console output screen resolution.

  \begin{itemize}
  \tightlist
  \item Set to \texttt{WxH@Bpp} (e.g. \texttt{1920x1080@32}) \texttt{WxH}
  (e.g. \texttt{1920x1080}) formatted string to request custom resolution
  from GOP if available.
  \item Set to empty string not to change screen resolution.
  \item Set to \texttt{Max} to try to use largest available screen resolution.
  \end{itemize}

  On HiDPI screens \texttt{APPLE\_VENDOR\_VARIABLE\_GUID} \texttt{UIScale}
  NVRAM variable may need to be set to \texttt{02} to enable HiDPI scaling
  in FileVault 2 UEFI password interface and boot screen logo. Refer to
  \hyperref[nvramvarsrec]{Recommended Variables} section for more details.
1519 1520 1521 1522 1523

  \emph{Note}: This will fail when console handle has no GOP protocol. When
  the firmware does not provide it, it can be added with \texttt{ProvideConsoleGop}
  UEFI quirk set to \texttt{true}.

1524 1525 1526
\item
  \texttt{ShowPicker}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1527
  \textbf{Failsafe}: \texttt{false}\\
1528 1529 1530 1531 1532
  \textbf{Description}: Show simple boot picker to allow boot entry selection.

\item
  \texttt{Timeout}\\
  \textbf{Type}: \texttt{plist\ integer}, 32 bit\\
1533
  \textbf{Failsafe}: \texttt{0}\\
1534 1535 1536
  \textbf{Description}: Timeout in seconds in boot picker before
  automatic booting of the default boot entry.

1537 1538 1539
\item
  \texttt{UsePicker}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1540
  \textbf{Failsafe}: \texttt{false}\\
1541 1542 1543 1544 1545 1546
  \textbf{Description}: Use OpenCore built-in boot picker for boot management.

  \texttt{UsePicker} set to \texttt{false} entirely disables all boot management
  in OpenCore except policy enforcement. In this case a custom user interface may
  utilise \href{https://github.com/acidanthera/OcSupportPkg}{OcSupportPkg}
  \texttt{OcBootManagementLib} to implement a user friendly boot picker oneself.
1547 1548 1549
  Reference example of external graphics interface is provided in
  \href{https://github.com/acidanthera/OcSupportPkg/tree/master/Tests/ExternalUi}{ExternalUi}
  test driver.
1550 1551 1552 1553

  \emph{Note}: By default OpenCore built-in boot picker loads the default discovered
  option, this can be changed by setting \texttt{ShowPicker} to \texttt{true}.

1554 1555
\end{enumerate}

V
vit9696 已提交
1556 1557 1558 1559
\subsection{Debug Properties}\label{miscdebugprops}

\begin{enumerate}

1560 1561 1562
\item
  \texttt{DisableWatchDog}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1563
  \textbf{Failsafe}: \texttt{false}\\
1564 1565 1566 1567
  \textbf{Description}: Select firmwares may not succeed in quickly booting
  the operating system, especially in debug mode, which results in watch dog
  timer aborting the process. This option turns off watch dog timer.

V
vit9696 已提交
1568
\item
V
vit9696 已提交
1569
  \texttt{DisplayDelay}\\
V
vit9696 已提交
1570
  \textbf{Type}: \texttt{plist\ integer}\\
1571
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
1572
  \textbf{Description}: Delay in microseconds performed after
V
vit9696 已提交
1573
  every printed line visible onscreen (i.e. console).
V
vit9696 已提交
1574

1575 1576 1577
\item
  \texttt{DisplayLevel}\\
  \textbf{Type}: \texttt{plist\ integer}, 64 bit\\
1578
  \textbf{Failsafe}: \texttt{0}\\
1579 1580 1581 1582 1583 1584 1585 1586
  \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
1587
    \item \texttt{0x00000002} (bit \texttt{1}) --- \texttt{DEBUG\_WARN} in \texttt{DEBUG},
1588
      \texttt{NOOPT}, \texttt{RELEASE}.
1589
    \item \texttt{0x00000040} (bit \texttt{6}) --- \texttt{DEBUG\_INFO} in \texttt{DEBUG},
1590
      \texttt{NOOPT}.
1591 1592
    \item \texttt{0x00400000} (bit \texttt{22}) --- \texttt{DEBUG\_VERBOSE} in custom builds.
    \item \texttt{0x80000000} (bit \texttt{31}) --- \texttt{DEBUG\_ERROR} in \texttt{DEBUG},
1593 1594 1595
      \texttt{NOOPT}, \texttt{RELEASE}.
  \end{itemize}

V
vit9696 已提交
1596 1597 1598
\item
  \texttt{Target}\\
  \textbf{Type}: \texttt{plist\ integer}\\
1599
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
1600 1601
  \textbf{Description}: A bitmask (sum) of enabled logging targets.
  By default all the logging output is hidden, so this option is
1602 1603 1604
  required to be set when debugging is necessary.

  The following logging targets are supported:
V
vit9696 已提交
1605 1606 1607

  \begin{itemize}
  \tightlist
1608 1609 1610 1611 1612 1613 1614
    \item \texttt{0x01} (bit \texttt{0}) --- Enable logging, otherwise all log is discarded.
    \item \texttt{0x02} (bit \texttt{1}) --- Enable basic console (onscreen) logging.
    \item \texttt{0x04} (bit \texttt{2}) --- Enable logging to Data Hub.
    \item \texttt{0x08} (bit \texttt{3}) --- Enable serial port logging.
    \item \texttt{0x10} (bit \texttt{4}) --- Enable UEFI variable logging.
    \item \texttt{0x20} (bit \texttt{5}) --- Enable non-volatile UEFI variable logging.
    \item \texttt{0x40} (bit \texttt{6}) --- Enable logging to file.
V
vit9696 已提交
1615 1616
  \end{itemize}

1617
  Console logging prints less than all the other variants.
V
vit9696 已提交
1618 1619 1620
  Depending on the build type (\texttt{RELEASE}, \texttt{DEBUG}, or
  \texttt{NOOPT}) different amount of logging may be read (from least to most).

V
vit9696 已提交
1621 1622
  Data Hub log will not log kernel and kext patches. To obtain Data Hub log use
  the following command in macOS:
V
vit9696 已提交
1623
\begin{lstlisting}[label=dhublog, style=ocbash]
V
vit9696 已提交
1624
ioreg -lw0 -p IODeviceTree | grep boot-log | sort | sed 's/.*<\(.*\)>.*/\1/' | xxd -r -p
V
vit9696 已提交
1625 1626
\end{lstlisting}

V
vit9696 已提交
1627 1628 1629 1630
  UEFI variable log does not include some messages and has no performance data. For safety
  reasons log size is limited to 32 kilobytes. Some firmwares may truncate it much earlier
  or drop completely if they have no memory. Using non-volatile flag will write the log to
  NVRAM flash after every printed line. To obtain UEFI variable log use the following command
V
vit9696 已提交
1631 1632
  in macOS:
\begin{lstlisting}[label=nvramlog, style=ocbash]
1633
nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-log |
V
vit9696 已提交
1634 1635 1636
  awk '{gsub(/%0d%0a%00/,"");gsub(/%0d%0a/,"\n")}1'
\end{lstlisting}

1637 1638 1639 1640
  \emph{Warning}: Some firmwares are reported to have broken NVRAM garbage collection.
  This means that they may not be able to always free space after variable deletion.
  Do not use non-volatile NVRAM logging without extra need on such devices.

V
vit9696 已提交
1641 1642
  While OpenCore boot log already contains basic version information with build type and
  date, this data may also be found in NVRAM in \texttt{opencore-version} variable
1643
  even with boot log disabled.
V
vit9696 已提交
1644

V
vit9696 已提交
1645 1646 1647 1648 1649
  File logging will create a file named \texttt{opencore.log} at EFI volume root with
  log contents. Please be warned that some file system drivers present in firmwares are
  not reliable, and may corrupt data when writing files through UEFI. Log is attempted
  to be written in the safest manner, and thus is very slow. Ensure that
  \texttt{DisableWatchDog} is set to \texttt{true} when you use a slow drive.
V
vit9696 已提交
1650 1651

\end{enumerate}
V
vit9696 已提交
1652

1653 1654 1655
\subsection{Security Properties}\label{miscsecurityprops}

\begin{enumerate}
1656 1657 1658 1659

\item
  \texttt{ExposeSensitiveData}\\
  \textbf{Type}: \texttt{plist\ integer}\\
1660
  \textbf{Failsafe}: \texttt{2}\\
1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685
  \textbf{Description}: Sensitive data exposure bitmask (sum) to operating system.

  \begin{itemize}
  \tightlist
    \item \texttt{0x01} --- Expose printable booter path as an UEFI variable.
    \item \texttt{0x02} --- Expose OpenCore version as an UEFI variable.
  \end{itemize}

  Exposed booter path points to OpenCore.efi or its booter depending on the load order.
  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}

  To use booter path for mounting booter volume use the following command in macOS:
\begin{lstlisting}[label=nvrampathmount, style=ocbash]
u=$(nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-path | sed 's/.*GPT,\([^,]*\),.*/\1/'); \
  if [ "$u" != "" ]; then sudo diskutil mount $u ; fi
\end{lstlisting}

  To obtain OpenCore version use the following command in macOS:
\begin{lstlisting}[label=nvramver, style=ocbash]
nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:opencore-version
\end{lstlisting}

1686 1687 1688
\item
  \texttt{HaltLevel}\\
  \textbf{Type}: \texttt{plist\ integer}, 64 bit\\
1689
  \textbf{Failsafe}: \texttt{0x80000000} (\texttt{DEBUG\_ERROR})\\
1690 1691 1692
  \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.
V
vit9696 已提交
1693 1694 1695 1696

\item
  \texttt{RequireSignature}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1697
  \textbf{Failsafe}: \texttt{true}\\
V
vit9696 已提交
1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716
  \textbf{Description}: Require \texttt{vault.sig} signature file for
  \texttt{vault.plist} in \texttt{OC} directory.

  This file should contain a raw 256 byte RSA-2048 signature from SHA-256
  hash of \texttt{vault.plist}. The signature is verified against the public
  key embedded into \texttt{OpenCore.efi}.

  To embed the public key you should do either of the following:

  \begin{itemize}
  \tightlist
  \item Provide public key during the \texttt{OpenCore.efi} compilation in
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Platform/OpenCore/OpenCoreVault.c}{\texttt{OpenCoreVault.c}} file.
  \item Binary patch \texttt{OpenCore.efi} replacing zeroes with the public key
  between \texttt{=BEGIN OC VAULT=} and \texttt{==END OC VAULT==} ASCII markers.
  \end{itemize}

  RSA public key 520 byte format description can be found in Chromium OS documentation.
  To convert public key from X.509 certificate or from PEM file use
1717
  \href{https://github.com/acidanthera/OcSupportPkg/tree/master/Tools/CreateVault}{RsaTool}.
V
vit9696 已提交
1718 1719 1720 1721 1722 1723 1724 1725 1726

  \emph{Note}: \texttt{vault.sig} is used regardless of this option when public key
  is embedded into \texttt{OpenCore.efi}. Setting it to \texttt{true} will only ensure
  configuration sanity, and abort the boot process when public key is not set but
  was supposed to be used for verification.

\item
  \texttt{RequireVault}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1727
  \textbf{Failsafe}: \texttt{true}\\
V
vit9696 已提交
1728 1729 1730 1731 1732 1733 1734
  \textbf{Description}: Require \texttt{vault.plist} file present
  in \texttt{OC} directory.

  This file should contain SHA-256 hashes for all files used by OpenCore.
  Presence of this file is highly recommended to ensure that unintentional
  file modifications (including filesystem corruption) do not happen unnoticed.
  To create this file automatically use
1735
  \href{https://github.com/acidanthera/OcSupportPkg/tree/master/Tools/CreateVault}{\texttt{create\_vault.sh}} script.
V
vit9696 已提交
1736

V
vit9696 已提交
1737 1738 1739
  Regardless of the underlying filesystem, path name and case must match
  between \texttt{config.plist} and \texttt{vault.plist}.

V
vit9696 已提交
1740 1741 1742 1743
  \emph{Note}: \texttt{vault.plist} is tried to be read regardless of the value
  of this option, but setting it to \texttt{true} will ensure configuration
  sanity, and abort the boot process.

V
vit9696 已提交
1744 1745 1746 1747 1748
  The complete set of commands to:

  \begin{itemize}
  \tightlist
  \item Create \texttt{vault.plist}.
V
vit9696 已提交
1749
  \item Create a new RSA key (always do this to avoid loading old configuration).
V
vit9696 已提交
1750
  \item Embed RSA key into \texttt{OpenCore.efi}.
V
vit9696 已提交
1751 1752 1753 1754 1755
  \item Create \texttt{vault.sig}.
  \end{itemize}

  Can look as follows:
\begin{lstlisting}[label=createvault, style=ocbash]
V
vit9696 已提交
1756
cd /Volumes/EFI/EFI/OC
1757 1758
/path/to/create_vault.sh .
/path/to/RsaTool -sign vault.plist vault.sig vault.pub
V
vit9696 已提交
1759 1760 1761
off=$(($(strings -a -t d OpenCore.efi | grep "=BEGIN OC VAULT=" | cut -f1 -d' ')+16))
dd of=OpenCore.efi if=vault.pub bs=1 seek=$off count=520 conv=notrunc
rm vault.pub
V
vit9696 已提交
1762 1763
\end{lstlisting}

V
vit9696 已提交
1764 1765 1766 1767 1768 1769 1770 1771
  \emph{Note}: While it may appear obvious, but you have to use an external
  method to verify \texttt{OpenCore.efi} and \texttt{BOOTx64.efi} for
  secure boot path. For this you are recommended to at least enable UEFI SecureBoot
  with a custom certificate, and sign \texttt{OpenCore.efi} and \texttt{BOOTx64.efi}
  with your custom key. More details on customising secure boot on modern firmwares
  can be found in \href{https://habr.com/post/273497/}{Taming UEFI SecureBoot}
  paper (in Russian).

1772 1773 1774
\item
  \texttt{ScanPolicy}\\
  \textbf{Type}: \texttt{plist\ integer}, 32 bit\\
1775
  \textbf{Failsafe}: \texttt{0xF0103}\\
1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790
  \textbf{Description}: Define operating system detection policy.

  This value allows to prevent scanning (and booting) from untrusted
  source based on a bitmask (sum) of select flags. As it is not possible
  to reliably detect every file system or device type, this feature
  cannot be fully relied upon in open environments, and the additional
  measures are to be applied.

  Third party drivers may introduce additional security (and performance)
  measures following the provided scan policy. Scan policy is exposed
  in \texttt{scan-policy} variable of \texttt{4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102}
  GUID for UEFI Boot Services only.

  \begin{itemize}
  \tightlist
1791
    \item \texttt{0x00000001} (bit \texttt{0}) --- \texttt{OC\_SCAN\_FILE\_SYSTEM\_LOCK}, restricts
1792 1793 1794 1795 1796
    scanning to only known file systems defined as a part of this policy. File system
    drivers may not be aware of this policy, and to avoid mounting of undesired file
    systems it is best not to load its driver. This bit does not affect dmg mounting,
    which may have any file system. Known file systems are prefixed with
    \texttt{OC\_SCAN\_ALLOW\_FS\_}.
1797
    \item \texttt{0x00000002} (bit \texttt{1}) --- \texttt{OC\_SCAN\_DEVICE\_LOCK}, restricts scanning
1798 1799 1800 1801
    to only known device types defined as a part of this policy. This is not always possible
    to detect protocol tunneling, so be aware that on some systems it may be possible for
    e.g. USB HDDs to be recognised as SATA. Cases like this must be reported. Known device
    types are prefixed with \texttt{OC\_SCAN\_ALLOW\_DEVICE\_}.
1802
    \item \texttt{0x00000100} (bit \texttt{8}) --- \texttt{OC\_SCAN\_ALLOW\_FS\_APFS}, allows scanning
1803
    of APFS file system.
1804
    \item \texttt{0x00000200} (bit \texttt{9}) --- \texttt{OC\_SCAN\_ALLOW\_FS\_HFS}, allows scanning
1805 1806 1807
    of HFS file system.
    \item \texttt{0x00000400} (bit \texttt{10}) --- \texttt{OC\_SCAN\_ALLOW\_FS\_ESP}, allows scanning
    of EFI System Partition file system.
1808
    \item \texttt{0x00010000} (bit \texttt{16}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SATA}, allow
1809
    scanning SATA devices.
1810
    \item \texttt{0x00020000} (bit \texttt{17}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SASEX}, allow
1811
    scanning SAS and Mac NVMe devices.
1812
    \item \texttt{0x00040000} (bit \texttt{18}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SCSI}, allow
1813
    scanning SCSI devices.
1814
    \item \texttt{0x00080000} (bit \texttt{19}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_NVME}, allow
1815
    scanning NVMe devices.
1816
    \item \texttt{0x00100000} (bit \texttt{20}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_ATAPI}, allow
1817
    scanning CD/DVD devices.
1818
    \item \texttt{0x00200000} (bit \texttt{21}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_USB}, allow
1819
    scanning USB devices.
1820
    \item \texttt{0x00400000} (bit \texttt{22}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_FIREWIRE}, allow
1821
    scanning FireWire devices.
1822
    \item \texttt{0x00800000} (bit \texttt{23}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SDCARD}, allow
1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840
    scanning card reader devices.
  \end{itemize}

  \emph{Note}: Given the above description, \texttt{0xF0103} value is expected to allow
  scanning of SATA, SAS, SCSI, and NVMe devices with APFS file system, and prevent scanning
  of any devices with HFS or FAT32 file systems in addition to not scanning APFS file systems
  on USB, CD, USB, and FireWire drives. The combination reads as:
  \begin{itemize}
  \tightlist
  \item \texttt{OC\_SCAN\_FILE\_SYSTEM\_LOCK}
  \item \texttt{OC\_SCAN\_DEVICE\_LOCK}
  \item \texttt{OC\_SCAN\_ALLOW\_FS\_APFS}
  \item \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SATA}
  \item \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SASEX}
  \item \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SCSI}
  \item \texttt{OC\_SCAN\_ALLOW\_DEVICE\_NVME}
  \end{itemize}

1841 1842
\end{enumerate}

1843 1844 1845 1846 1847 1848
\subsection{Tools Properties}\label{misctoolprops}

\begin{enumerate}
\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
1849
  \textbf{Failsafe}: Empty string\\
1850 1851 1852 1853
  \textbf{Description}: Arbitrary ASCII string used to provide human readable
  reference for the entry. It is implementation defined whether this value is
  used.

1854 1855 1856
\item
  \texttt{Enabled}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1857
  \textbf{Failsafe}: \texttt{false}\\
1858 1859 1860
  \textbf{Description}: This tool will not be listed unless set to
  \texttt{true}.

1861 1862 1863
\item
  \texttt{Name}\\
  \textbf{Type}: \texttt{plist\ string}\\
1864
  \textbf{Failsafe}: Empty string\\
1865 1866 1867 1868 1869
  \textbf{Description}: Human readable tool name displayed in boot picker.

\item
  \texttt{Path}\\
  \textbf{Type}: \texttt{plist\ string}\\
1870
  \textbf{Failsafe}: Empty string\\
1871 1872 1873 1874 1875 1876
  \textbf{Description}: File path to select UEFI tool relative to \texttt{OC/Tools}
  directory.

\end{enumerate}


V
vit9696 已提交
1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903
\section{NVRAM}\label{nvram}

\subsection{Introduction}\label{nvramintro}

Has \texttt{plist\ dict} type and allows to set volatile UEFI variables
commonly referred as NVRAM variables. Refer to \texttt{man\ nvram} for
more details. macOS extensively uses NVRAM variables for OS --- Bootloader
--- Firmware intercommunication, and thus supplying several NVRAM is
required for proper macOS functioning.

Each NVRAM variable consists of its name, value, attributes (refer to
UEFI specification), and its
\href{https://en.wikipedia.org/wiki/Universally_unique_identifier}{GUID},
representing which `section' NVRAM variable belongs to. macOS uses
several GUIDs, including but not limited to:

\begin{itemize}
\tightlist
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14}
  (\texttt{APPLE\_VENDOR\_VARIABLE\_GUID})
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82}
  (\texttt{APPLE\_BOOT\_VARIABLE\_GUID})
\item
  \texttt{8BE4DF61-93CA-11D2-AA0D-00E098032B8C}
  (\texttt{EFI\_GLOBAL\_VARIABLE\_GUID})
1904 1905 1906
\item
  \texttt{4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102}
  (\texttt{OC\_VENDOR\_VARIABLE\_GUID})
V
vit9696 已提交
1907 1908
\end{itemize}

V
vit9696 已提交
1909 1910 1911 1912 1913 1914 1915
\emph{Note}: Some of the variables may be added by
\hyperref[platforminfonvram]{PlatformNVRAM} or
\hyperref[platforminfogeneric]{Generic} subsections of
\hyperref[platforminfo]{PlatformInfo} section.
Please ensure that variables of this section never collide with them,
as behaviour is undefined otherwise.

V
vit9696 已提交
1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942
\subsection{Properties}\label{nvramprops}

\begin{enumerate}
\item
  \texttt{Add}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Sets NVRAM variables from a map (\texttt{plist\ dict})
  of GUIDs to a map (\texttt{plist\ dict}) of variable names and their values
  in \texttt{plist\ metadata} format. GUIDs must be provided in canonic string
  format in upper or lower case (e.g. \texttt{8BE4DF61-93CA-11D2-AA0D-00E098032B8C}).

  Created variables get \texttt{EFI\_VARIABLE\_BOOTSERVICE\_ACCESS} and
  \texttt{EFI\_VARIABLE\_RUNTIME\_ACCESS} attributes set.
  Variables will only be set if not present and not blocked.
  To overwrite a variable add it to \texttt{Block} section. This approach
  enables to provide default values till the operating system takes the lead.

  \emph{Note}: If \texttt{plist\ key} does not conform to GUID format,
  behaviour is undefined.

\item
  \texttt{Block}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Removes NVRAM variables from a map (\texttt{plist\ dict})
  of GUIDs to an array (\texttt{plist\ array}) of variable names in
  \texttt{plist\ string} format.

1943 1944 1945
\item
  \texttt{LegacyEnable}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1946
  \textbf{Failsafe}: \texttt{false}\\
1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967
  \textbf{Description}: Enables loading of NVRAM variable file named \texttt{nvram.plist}
  from EFI volume root.

  This file must have root \texttt{plist\ dictionary} type and contain two fields:
  \begin{itemize}
  \tightlist
  \item \texttt{Version} --- \texttt{plist\ integer}, file version, must be set to 1.
  \item \texttt{Add} --- \texttt{plist\ dictionary}, equivalent to \texttt{Add} from
  \texttt{config.plist}.
  \end{itemize}

  Variable loading happens prior to \texttt{Block} (and \texttt{Add}) phases, and will not
  overwrite any existing variable. Variables allowed to be set must be specified in
  \texttt{LegacySchema}. Third-party scripts may be used to create \texttt{nvram.plist}
  file. Example can be found in \texttt{Tools}. The use of third-party scripts may
  require \texttt{ExposeSensitiveData} set to \texttt{0x3} to provide \texttt{boot-path}
  variable with OpenCore EFI partition UUID.

  \textbf{WARNING}: This feature is very dangerous as it passes unprotected data to your
  firmware variable services. Use it only when no hardware NVRAM implementation is provided
  by the firmware or it is incompatible.
1968

1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
\item
  \texttt{LegacySchema}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Allows setting select NVRAM variables from a map
  (\texttt{plist\ dict}) of GUIDs to an array (\texttt{plist\ array}) of
  variable names in \texttt{plist\ string} format.

  You can use \texttt{*} value to accept all variables for select GUID.

  \textbf{WARNING}: Choose variables very carefully, as nvram.plist is not vaulted.
  For instance, do not put \texttt{boot-args} or \texttt{csr-active-config}, as
1980
  this can bypass SIP.
1981

V
vit9696 已提交
1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992
\end{enumerate}

To read NVRAM variable value from macOS one could use \texttt{nvram}
by concatenating variable GUID and name separated by \texttt{:} symbol.
For example, \texttt{nvram 7C436110-AB2A-4BBB-A880-FE41995C9F82:boot-args}.

A continuously updated variable list can be found in a corresponding document:
\href{https://docs.google.com/spreadsheets/d/1HTCBwfOBkXsHiK7os3b2CUc6k68axdJYdGl-TyXqLu0}{NVRAM Variables}.

\subsection{Mandatory Variables}\label{nvramvars}

1993 1994 1995 1996 1997 1998
\emph{Warning}: These variables may be added by
\hyperref[platforminfonvram]{PlatformNVRAM} or
\hyperref[platforminfogeneric]{Generic} subsections of
\hyperref[platforminfo]{PlatformInfo} section.
Using \texttt{PlatformInfo} is the recommend way of setting these variables.

V
vit9696 已提交
1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062
The following variables are mandatory for macOS functioning:

\begin{itemize}
\tightlist
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:FirmwareFeatures}
  \break
  32-bit \texttt{FirmwareFeatures}. Present on all Macs to avoid extra parsing of SMBIOS tables
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:FirmwareFeaturesMask}
  \break
  32-bit \texttt{FirmwareFeaturesMask}. Present on all Macs to avoid extra parsing
  of SMBIOS tables.
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:MLB}
  \break
  \texttt{BoardSerialNumber}. Present on newer Macs (2013+ at least) to avoid extra parsing
  of SMBIOS tables, especially in boot.efi.
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ROM}
  \break
  Primary network adapter MAC address or replacement value. Present on newer Macs
  (2013+ at least) to avoid accessing special memory region, especially in boot.efi.
\end{itemize}

\subsection{Recommended Variables}\label{nvramvarsrec}

The following variables are recommended for faster startup or other
improvements:

\begin{itemize}
\tightlist
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:csr-active-config}
  \break
  32-bit System Integrity Protection bitmask. Declared in XNU source code in
  \href{https://opensource.apple.com/source/xnu/xnu-4570.71.2/bsd/sys/csr.h.auto.html}{csr.h}.
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ExtendedFirmwareFeatures}
  \break
  Combined \texttt{FirmwareFeatures} and \texttt{ExtendedFirmwareFeatures}. Present on
  newer Macs to avoid extra parsing of SMBIOS tables
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ExtendedFirmwareFeaturesMask}
  \break
  Combined \texttt{FirmwareFeaturesMask} and \texttt{ExtendedFirmwareFeaturesMask}.
  Present on newer Macs to avoid extra parsing of SMBIOS tables.
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:HW\_BID}
  \break
  Hardware \texttt{BoardProduct} (e.g. \texttt{Mac-35C1E88140C3E6CF}). Not present on
  real Macs, but used to avoid extra parsing of SMBIOS tables, especially in boot.efi.
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:HW\_MLB}
  \break
  Hardware \texttt{BoardSerialNumber}. Override for MLB. Present on newer Macs (2013+ at least).
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:HW\_ROM}
  \break
  Hardware ROM. Override for ROM. Present on newer Macs (2013+ at least).
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:prev-lang:kbd}
  \break
  ASCII string defining default keyboard layout. Format is \texttt{lang-COUNTRY:keyboard},
V
vit9696 已提交
2063 2064
  e.g. \texttt{ru-RU:252} for Russian locale and ABC keyboard. Also accepts short forms:
  \texttt{ru:252} or \texttt{ru:0} (U.S. keyboard, compatible with 10.9). Full decoded
2065
  keyboard list from \texttt{AppleKeyboardLayouts-L.dat} can be found
2066
  \href{https://github.com/acidanthera/OcSupportPkg/tree/master/Tools/AppleKeyboardLayouts}{here}. Using non-latin keyboard on 10.14
V
vit9696 已提交
2067
  will not enable ABC keyboard, unlike previous macOS versions, and is thus not recommended.
V
vit9696 已提交
2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:security-mode}
  \break
  ASCII string defining FireWire security mode. Legacy, can be found in IOFireWireFamily
  source code in
  \href{https://opensource.apple.com/source/IOFireWireFamily/IOFireWireFamily-473/IOFireWireFamily.kmodproj/IOFireWireController.cpp.auto.html}{IOFireWireController.cpp}.
  It is recommended not to set this variable, which may speedup system startup. Setting to
  \texttt{full} is equivalent to not setting the variable and \texttt{none} disables
  FireWire security.
 \item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:UIScale}
  \break
  8-bit integer defining boot.efi user interface scaling. Should be 1 for normal
  screens and 2 for HDPI screens.
\end{itemize}

\subsection{Other Variables}\label{nvramvarsother}

The following variables may be useful for certain configurations or
troubleshooting:

\begin{itemize}
\tightlist
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:boot-args}
  \break
  Kernel arguments, used to pass configuration to Apple kernel and drivers.
  There are many arguments, which may be found by looking for the use of
  \texttt{PE\_parse\_boot\_argn} function in the kernel or driver code.
2097
  Some of the known boot arguments include:
V
vit9696 已提交
2098 2099

  \begin{itemize}
2100 2101 2102 2103 2104 2105 2106 2107 2108 2109
  \item \texttt{acpi\_layer=0xFFFFFFFF}
  \item \texttt{acpi\_level=0xFFFF5F} (implies
    \href{https://github.com/acpica/acpica/blob/master/source/include/acoutput.h}
    {\texttt{ACPI\_ALL\_COMPONENTS}})
  \item \texttt{cpus=VALUE}
  \item \texttt{debug=VALUE}
  \item \texttt{io=VALUE}
  \item \texttt{keepsyms=1}
  \item \texttt{kextlog=VALUE}
  \item \texttt{nvda\_drv=1}
2110
  \item \texttt{lapic\_dont\_panic=1}
2111 2112 2113 2114 2115 2116
  \item \texttt{slide=VALUE}
  \item \texttt{-nehalem\_error\_disable}
  \item \texttt{-no\_compat\_check}
  \item \texttt{-s}
  \item \texttt{-v}
  \item \texttt{-x}
V
vit9696 已提交
2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151
  \end{itemize}

\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:bootercfg}
  \break
  Booter arguments, similar to \texttt{boot-args} but for boot.efi. Accepts a set of
  arguments, which are hexadecimal 64-bit values with or without 0x prefix primarily
  for logging control:
  \begin{itemize}
  \item \texttt{log=VALUE}
    \begin{itemize}
    \item \texttt{1} --- AppleLoggingConOutOrErrSet/AppleLoggingConOutOrErrPrint
    (classical ConOut/StdErr)
    \item \texttt{2} --- AppleLoggingStdErrSet/AppleLoggingStdErrPrint (StdErr or serial?)
    \item \texttt{4} --- AppleLoggingFileSet/AppleLoggingFilePrint (BOOTER.LOG/BOOTER.OLD
    file on EFI partition)
    \end{itemize}
  \item \texttt{debug=VALUE}
  \begin{itemize}
  \item \texttt{1} --- enables print something to BOOTER.LOG (stripped code implies there
  may be a crash)
  \item \texttt{2} --- enables perf logging to /efi/debug-log in the device three
  \item \texttt{4} --- enables timestamp printing for styled printf calls
  \end{itemize}
  \item \texttt{level=VALUE} --- Verbosity level of DEBUG output. Everything but
  \texttt{0x80000000} is stripped from the binary, and this is the default value.
  \item \texttt{kc-read-size=VALUE} --- Chunk size used for buffered I/O from network or
  disk for prelinkedkernel reading and related. Set to 1MB (0x100000) by default, can be
  tuned for faster booting.
\end{itemize}
\item \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:bootercfg-once}
  \break
  Booter arguments override removed after first launch. Otherwise equivalent to \texttt{bootercfg}.
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:fmm-computer-name}
2152 2153
  \break
  Current saved host name. ASCII string.
V
vit9696 已提交
2154 2155
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:nvda\_drv}
2156 2157 2158
  \break
  NVIDIA Web Driver control variable. Takes ASCII digit \texttt{1} or \texttt{0}
  to enable or disable installed driver.
V
vit9696 已提交
2159 2160 2161 2162 2163 2164
\end{itemize}

\section{PlatformInfo}\label{platforminfo}

Platform information is comprised of several identification fields
generated or filled manually to be compatible with macOS services. The
2165 2166
base part of the configuration may be obtained from
\href{https://github.com/acidanthera/MacInfoPkg}{\texttt{MacInfoPkg}}
V
vit9696 已提交
2167 2168 2169 2170 2171 2172 2173 2174 2175
package, which itself generates a set of interfaces based on a database
in \href{https://yaml.org/spec/1.2/spec.html}{YAML} format. These fields
are written to three select destinations:

\begin{itemize}
\tightlist
\item
  \href{https://www.dmtf.org/standards/smbios}{SMBIOS}
\item
2176
  \href{https://github.com/acidanthera/EfiPkg/blob/master/Include/Protocol/DataHub.h}{Data
V
vit9696 已提交
2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191
  Hub}
\item
  NVRAM
\end{itemize}

Most of the fields specify the overrides in SMBIOS, and their field
names conform to EDK2
\href{https://github.com/tianocore/edk2/blob/UDK2018/MdePkg/Include/IndustryStandard/SmBios.h}{SmBios.h}
header file. However, several important fields reside in Data Hub and
NVRAM. Some of the values can be found in more than one field and/or
destination, so there are two ways to control their update process:
manual, where one specifies all the values (the default), and semi-automatic,
where (\texttt{Automatic}) only select values are specified, and later used
for system configuration.

V
vit9696 已提交
2192 2193 2194 2195
To inspect SMBIOS contents \href{http://www.nongnu.org/dmidecode}{dmidecode} utility can
be used. Version with macOS specific enhancements can be downloaded from
\href{https://github.com/acidanthera/dmidecode/releases}{Acidanthera/dmidecode}.

V
vit9696 已提交
2196 2197 2198 2199 2200 2201
\subsection{Properties}\label{platforminfoprops}

\begin{enumerate}
\item
  \texttt{Automatic}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2202
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
2203 2204 2205 2206 2207
  \textbf{Description}: Generate PlatformInfo based on \texttt{Generic}
  section instead of using values from \texttt{DataHub}, \texttt{NVRAM},
  and \texttt{SMBIOS} sections.

  Enabling this option is useful when \texttt{Generic} section is flexible
2208 2209
  enough. When enabled \texttt{SMBIOS}, \texttt{DataHub}, and
  \texttt{PlatformNVRAM} data is unused.
V
vit9696 已提交
2210 2211 2212
\item
  \texttt{UpdateDataHub}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2213
  \textbf{Failsafe}: \texttt{false}\\
2214
  \textbf{Description}: Update Data Hub fields. These fields are read
V
vit9696 已提交
2215 2216 2217 2218 2219
  from \texttt{Generic} or \texttt{DataHub} sections depending on
  \texttt{Automatic} value.
\item
  \texttt{UpdateNVRAM}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2220
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233
  \textbf{Description}: Update NVRAM fields related to platform information.

  These fields are read from \texttt{Generic} or \texttt{PlatformNVRAM} sections
  depending on \texttt{Automatic} value. All the other fields are
  to be specified with \texttt{NVRAM} section.

  If \texttt{UpdateNVRAM} is set to \texttt{false} the aforementioned
  variables can be updated with \hyperref[nvram]{\texttt{NVRAM}}
  section. If \texttt{UpdateNVRAM} is set to \texttt{true} the behaviour is
  undefined when any of the fields are present in \texttt{NVRAM} section.
\item
  \texttt{UpdateSMBIOS}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2234
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
2235 2236 2237 2238 2239 2240
  \textbf{Description}: Update SMBIOS fields. These fields are read from
  \texttt{Generic} or \texttt{SMBIOS} sections depending on
  \texttt{Automatic} value.
\item
  \texttt{UpdateSMBIOSMode}\\
  \textbf{Type}: \texttt{plist\ string}\\
2241
  \textbf{Failsafe}: \texttt{Create}\\
V
vit9696 已提交
2242 2243 2244 2245 2246
  \textbf{Description}: Update SMBIOS fields approach:

  \begin{itemize}
  \tightlist
  \item
2247
    \texttt{TryOverwrite} --- \texttt{Overwrite} if new size is \textless{}= than
V
vit9696 已提交
2248
    the page-aligned original and there are no issues with legacy region
2249
    unlock. \texttt{Create} otherwise. Has issues with some firmwares.
V
vit9696 已提交
2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262
  \item
    \texttt{Create} --- Replace the tables with newly allocated
    EfiReservedMemoryType at AllocateMaxAddress without any fallbacks.
  \item
    \texttt{Overwrite} --- Overwrite existing gEfiSmbiosTableGuid and
    gEfiSmbiosTable3Guid data if it fits new size. Abort with
    unspecified state otherwise.
  \item
    \texttt{Custom} --- Write first SMBIOS table
    (\texttt{gEfiSmbiosTableGuid}) to \texttt{gOcCustomSmbiosTableGuid}
    to workaround firmwares overwriting SMBIOS contents at
    ExitBootServices. Otherwise equivalent to \texttt{Create}. Requires
    patching AppleSmbios.kext and AppleACPIPlatform.kext to read from
2263 2264
    another GUID: \texttt{"EB9D2D31"} - \texttt{"EB9D2D35"} (in ASCII),
    done automatically by \texttt{CustomSMBIOSGuid} quirk.
V
vit9696 已提交
2265 2266 2267 2268
  \end{itemize}
\item
  \texttt{Generic}\\
  \textbf{Type}: \texttt{plist\ dictonary}\\
2269
  \textbf{Optional}: When \texttt{Automatic} is \texttt{false}\\
V
vit9696 已提交
2270 2271 2272 2273 2274
  \textbf{Description}: Update all fields. This section is read only
  when \texttt{Automatic} is active.
\item
  \texttt{DataHub}\\
  \textbf{Type}: \texttt{plist\ dictonary}\\
2275
  \textbf{Optional}: When \texttt{Automatic} is \texttt{true}\\
V
vit9696 已提交
2276 2277 2278 2279 2280
  \textbf{Description}: Update Data Hub fields. This section is read
  only when \texttt{Automatic} is not active.
\item
  \texttt{PlatformNVRAM}\\
  \textbf{Type}: \texttt{plist\ dictonary}\\
2281
  \textbf{Optional}: When \texttt{Automatic} is \texttt{true}\\
V
vit9696 已提交
2282 2283 2284 2285 2286
  \textbf{Description}: Update platform NVRAM fields. This section is
  read only when \texttt{Automatic} is not active.
\item
  \texttt{SMBIOS}\\
  \textbf{Type}: \texttt{plist\ dictonary}\\
2287
  \textbf{Optional}: When \texttt{Automatic} is \texttt{true}\\
V
vit9696 已提交
2288 2289 2290 2291 2292 2293 2294
  \textbf{Description}: Update SMBIOS fields. This section is read only
  when \texttt{Automatic} is not active.
\end{enumerate}

\subsection{Generic Properties}\label{platforminfogeneric}

\begin{enumerate}
2295 2296 2297
\item
  \texttt{SpoofVendor}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2298
  \textbf{Failsafe}: \texttt{false}\\
2299 2300 2301 2302 2303
  \textbf{Description}: Sets SMBIOS vendor fields to \texttt{Acidanthera}.

  It is dangerous to use Apple in SMBIOS vendor fields for reasons given
  in \texttt{SystemManufacturer} description. However, certain firmwares
  may not provide valid values otherwise, which could break some software.
V
vit9696 已提交
2304 2305 2306
\item
  \texttt{SystemProductName}\\
  \textbf{Type}: \texttt{plist\ string}\\
2307
  \textbf{Failsafe}: \texttt{MacPro6,1}\\
V
vit9696 已提交
2308 2309 2310 2311
  \textbf{Description}: Refer to SMBIOS \texttt{SystemProductName}.
\item
  \texttt{SystemSerialNumber}\\
  \textbf{Type}: \texttt{plist\ string}\\
2312
  \textbf{Failsafe}: \texttt{OPENCORE\_SN1}\\
V
vit9696 已提交
2313 2314 2315 2316
  \textbf{Description}: Refer to SMBIOS \texttt{SystemSerialNumber}.
\item
  \texttt{SystemUUID}\\
  \textbf{Type}: \texttt{plist\ string}, GUID\\
2317
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2318 2319 2320 2321
  \textbf{Description}: Refer to SMBIOS \texttt{SystemUUID}.
\item
  \texttt{MLB}\\
  \textbf{Type}: \texttt{plist\ string}\\
2322
  \textbf{Failsafe}: \texttt{OPENCORE\_MLB\_SN11}\\
V
vit9696 已提交
2323 2324 2325 2326
  \textbf{Description}: Refer to SMBIOS \texttt{BoardSerialNumber}.
\item
  \texttt{ROM}\\
  \textbf{Type}: \texttt{plist\ data}, 6 bytes\\
2327
  \textbf{Failsafe}: all zero\\
V
vit9696 已提交
2328 2329
  \textbf{Description}: Refer to
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ROM}.
2330

V
vit9696 已提交
2331 2332 2333 2334 2335 2336 2337 2338
\end{enumerate}

\subsection{DataHub Properties}\label{platforminfodatahub}

\begin{enumerate}
\item
  \texttt{PlatformName}\\
  \textbf{Type}: \texttt{plist\ string}\\
2339
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2340 2341 2342 2343 2344 2345
  \textbf{Description}: Sets \texttt{name} in
  \texttt{gEfiMiscSubClassGuid}. Value found on Macs is
  \texttt{platform} in ASCII.
\item
  \texttt{SystemProductName}\\
  \textbf{Type}: \texttt{plist\ string}\\
2346
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2347 2348 2349 2350 2351 2352
  \textbf{Description}: Sets \texttt{Model} in
  \texttt{gEfiMiscSubClassGuid}. Value found on Macs is equal to SMBIOS
  \texttt{SystemProductName} in Unicode.
\item
  \texttt{SystemSerialNumber}\\
  \textbf{Type}: \texttt{plist\ string}\\
2353
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2354 2355 2356 2357 2358 2359
  \textbf{Description}: Sets \texttt{SystemSerialNumber} in
  \texttt{gEfiMiscSubClassGuid}. Value found on Macs is equal to SMBIOS
  \texttt{SystemSerialNumber} in Unicode.
\item
  \texttt{SystemUUID}\\
  \textbf{Type}: \texttt{plist\ string}, GUID\\
2360
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2361 2362 2363 2364 2365 2366
  \textbf{Description}: Sets \texttt{system-id} in
  \texttt{gEfiMiscSubClassGuid}. Value found on Macs is equal to SMBIOS
  \texttt{SystemUUID}.
\item
  \texttt{BoardProduct}\\
  \textbf{Type}: \texttt{plist\ string}\\
2367
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2368 2369 2370 2371 2372 2373
  \textbf{Description}: Sets \texttt{board-id} in
  \texttt{gEfiMiscSubClassGuid}. Value found on Macs is equal to SMBIOS
  \texttt{BoardProduct} in ASCII.
\item
  \texttt{BoardRevision}\\
  \textbf{Type}: \texttt{plist\ data}, 1 byte\\
2374
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
2375 2376 2377 2378 2379 2380
  \textbf{Description}: Sets \texttt{board-rev} in
  \texttt{gEfiMiscSubClassGuid}. Value found on Macs seems to correspond
  to internal board revision (e.g. \texttt{01}).
\item
  \texttt{StartupPowerEvents}\\
  \textbf{Type}: \texttt{plist\ integer}, 64-bit\\
2381
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434
  \textbf{Description}: Sets \texttt{StartupPowerEvents} in
  \texttt{gEfiMiscSubClassGuid}. Value found on Macs is power management
  state bitmask, normally 0. Known bits read by
  \texttt{X86PlatformPlugin.kext}:

  \begin{itemize}
  \tightlist
  \item
    \texttt{0x00000001} --- Shutdown cause was a \texttt{PWROK} event
    (Same as \texttt{GEN\_PMCON\_2} bit 0)
  \item
    \texttt{0x00000002} --- Shutdown cause was a \texttt{SYS\_PWROK}
    event (Same as \texttt{GEN\_PMCON\_2} bit 1)
  \item
    \texttt{0x00000004} --- Shutdown cause was a \texttt{THRMTRIP\#}
    event (Same as \texttt{GEN\_PMCON\_2} bit 3)
  \item
    \texttt{0x00000008} --- Rebooted due to a SYS\_RESET\# event (Same
    as \texttt{GEN\_PMCON\_2} bit 4)
  \item
    \texttt{0x00000010} --- Power Failure (Same as
    \texttt{GEN\_PMCON\_3} bit 1 \texttt{PWR\_FLR})
  \item
    \texttt{0x00000020} --- Loss of RTC Well Power (Same as
    \texttt{GEN\_PMCON\_3} bit 2 \texttt{RTC\_PWR\_STS})
  \item
    \texttt{0x00000040} --- General Reset Status (Same as
    \texttt{GEN\_PMCON\_3} bit 9 \texttt{GEN\_RST\_STS})
  \item
    \texttt{0xffffff80} --- SUS Well Power Loss (Same as
    \texttt{GEN\_PMCON\_3} bit 14)
  \item
    \texttt{0x00010000} --- Wake cause was a ME Wake event (Same as
    PRSTS bit 0, \texttt{ME\_WAKE\_STS})
  \item
    \texttt{0x00020000} --- Cold Reboot was ME Induced event (Same as
    \texttt{PRSTS} bit 1 \texttt{ME\_HRST\_COLD\_STS})
  \item
    \texttt{0x00040000} --- Warm Reboot was ME Induced event (Same as
    \texttt{PRSTS} bit 2 \texttt{ME\_HRST\_WARM\_STS})
  \item
    \texttt{0x00080000} --- Shutdown was ME Induced event (Same as
    \texttt{PRSTS} bit 3 \texttt{ME\_HOST\_PWRDN})
  \item
    \texttt{0x00100000} --- Global reset ME Wachdog Timer event (Same as
    \texttt{PRSTS} bit 6)
  \item
    \texttt{0x00200000} --- Global reset PowerManagment Wachdog Timer
    event (Same as \texttt{PRSTS} bit 15)
  \end{itemize}
\item
  \texttt{InitialTSC}\\
  \textbf{Type}: \texttt{plist\ integer}, 64-bit\\
2435
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
2436 2437 2438 2439 2440 2441
  \textbf{Description}: Sets \texttt{InitialTSC} in
  \texttt{gEfiProcessorSubClassGuid}. Sets initial TSC value, normally
  0.
\item
  \texttt{FSBFrequency}\\
  \textbf{Type}: \texttt{plist\ integer}, 64-bit\\
2442
  \textbf{Failsafe}: Automatic\\
V
vit9696 已提交
2443 2444 2445 2446 2447
  \textbf{Description}: Sets \texttt{FSBFrequency} in
  \texttt{gEfiProcessorSubClassGuid}. Sets CPU FSB frequency.
\item
  \texttt{ARTFrequency}\\
  \textbf{Type}: \texttt{plist\ integer}, 64-bit\\
2448
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2449 2450 2451 2452 2453
  \textbf{Description}: Sets \texttt{ARTFrequency} in
  \texttt{gEfiProcessorSubClassGuid}. Sets CPU ART frequency, Skylake
  and newer.
\item
  \texttt{DevicePathsSupported}\\
2454
  \textbf{Type}: \texttt{plist\ integer}, 32-bit\\
2455
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2456
  \textbf{Description}: Sets \texttt{DevicePathsSupported} in
2457
  \texttt{gEfiMiscSubClassGuid}. Must be set to \texttt{1} for
2458 2459
  AppleACPIPlatform.kext to append SATA device paths to
  \texttt{Boot\#\#\#\#} and \texttt{efi-boot-device-data} variables.
2460
  Set to \texttt{1} on all modern Macs.
V
vit9696 已提交
2461 2462 2463
\item
  \texttt{SmcRevision}\\
  \textbf{Type}: \texttt{plist\ data}, 6 bytes\\
2464
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2465 2466 2467 2468 2469 2470 2471
  \textbf{Description}: Sets \texttt{REV} in
  \texttt{gEfiMiscSubClassGuid}. Custom property read by
  \texttt{VirtualSMC} or \texttt{FakeSMC} to generate SMC \texttt{REV}
  key.
\item
  \texttt{SmcBranch}\\
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
2472
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2473 2474 2475 2476 2477 2478 2479
  \textbf{Description}: Sets \texttt{RBr} in
  \texttt{gEfiMiscSubClassGuid}. Custom property read by
  \texttt{VirtualSMC} or \texttt{FakeSMC} to generate SMC \texttt{RBr}
  key.
\item
  \texttt{SmcPlatform}\\
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
2480
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492
  \textbf{Description}: Sets \texttt{RPlt} in
  \texttt{gEfiMiscSubClassGuid}. Custom property read by
  \texttt{VirtualSMC} or \texttt{FakeSMC} to generate SMC \texttt{RPlt}
  key.
\end{enumerate}

\subsection{PlatformNVRAM Properties}\label{platforminfonvram}

\begin{enumerate}
\item
  \texttt{BID}\\
  \textbf{Type}: \texttt{plist\ string}\\
2493
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2494 2495 2496 2497 2498 2499
  \textbf{Description}: Specifies the value of NVRAM variable
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:HW\_BID}.

\item
  \texttt{ROM}\\
  \textbf{Type}: \texttt{plist\ data}, 6 bytes\\
2500
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2501
  \textbf{Description}: Specifies the values of NVRAM variables
V
vit9696 已提交
2502 2503 2504 2505 2506 2507
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:HW\_ROM} and
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ROM}.

\item
  \texttt{MLB}\\
  \textbf{Type}: \texttt{plist\ string}\\
2508
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
2509 2510 2511 2512
  \textbf{Description}: Specifies the values of NVRAM variables
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:HW\_MLB} and
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:MLB}.

2513 2514 2515
\item
  \texttt{FirmwareFeatures}\\
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
2516
  \textbf{Failsafe}: Not installed\\
2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527
  \textbf{Description}: This variable comes in pair with \texttt{FirmwareFeaturesMask}.
  Specifies the values of NVRAM variables:
  \begin{itemize}
  \tightlist
  \item \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:FirmwareFeatures}
  \item \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ExtendedFirmwareFeatures}
  \end{itemize}

\item
  \texttt{FirmwareFeaturesMask}\\
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
2528
  \textbf{Failsafe}: Not installed\\
2529 2530 2531 2532 2533 2534 2535 2536
  \textbf{Description}: This variable comes in pair with \texttt{FirmwareFeatures}.
  Specifies the values of NVRAM variables:
  \begin{itemize}
  \tightlist
  \item \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:FirmwareFeaturesMask}
  \item \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ExtendedFirmwareFeaturesMask}
  \end{itemize}

V
vit9696 已提交
2537 2538 2539 2540 2541 2542 2543 2544
\end{enumerate}

\subsection{SMBIOS Properties}\label{platforminfosmbios}

\begin{enumerate}
\item
  \texttt{BIOSVendor}\\
  \textbf{Type}: \texttt{plist\ string}\\
2545
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2546 2547 2548 2549 2550 2551
  \textbf{SMBIOS}: BIOS Information (Type 0) --- Vendor\\
  \textbf{Description}: BIOS Vendor. All rules of
  \texttt{SystemManufacturer} do apply.
\item
  \texttt{BIOSVersion}\\
  \textbf{Type}: \texttt{plist\ string}\\
2552
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581
  \textbf{SMBIOS}: BIOS Information (Type 0) --- BIOS Version\\
  \textbf{Description}: Firmware version. This value gets updated and
  takes part in update delivery configuration and macOS version
  compatibility. This value could look like
  \texttt{MM71.88Z.0234.B00.1809171422} in older firmwares, and is
  described in
  \href{https://github.com/acidanthera/EfiPkg/blob/master/Include/Guid/BiosId.h}{BiosId.h}.
  In newer firmwares it should look like \texttt{236.0.0.0.0} or
  \texttt{220.230.16.0.0\ (iBridge:\ 16.16.2542.0.0,0)}. iBridge version
  is read from \texttt{BridgeOSVersion} variable, and is only present on
  macs with T2.

\begin{verbatim}
Apple ROM Version
 BIOS ID:      MBP151.88Z.F000.B00.1811142212
 Model:        MBP151
 EFI Version:  220.230.16.0.0
 Built by:     root@quinoa
 Date:         Wed Nov 14 22:12:53 2018
 Revision:     220.230.16 (B&I)
 ROM Version:  F000_B00
 Build Type:   Official Build, RELEASE
 Compiler:     Apple LLVM version 10.0.0 (clang-1000.2.42)
 UUID:         E5D1475B-29FF-32BA-8552-682622BA42E1
 UUID:         151B0907-10F9-3271-87CD-4BF5DBECACF5
\end{verbatim}
\item
  \texttt{BIOSReleaseDate}\\
  \textbf{Type}: \texttt{plist\ string}\\
2582
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2583 2584 2585 2586 2587 2588
  \textbf{SMBIOS}: BIOS Information (Type 0) --- BIOS Release Date\\
  \textbf{Description}: Firmware release date. Similar to
  \texttt{BIOSVersion}. May look like \texttt{12/08/2017}.
\item
  \texttt{SystemManufacturer}\\
  \textbf{Type}: \texttt{plist\ string}\\
2589
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2590 2591 2592 2593 2594 2595 2596 2597 2598 2599
  \textbf{SMBIOS}: System Information (Type 1) --- Manufacturer\\
  \textbf{Description}: OEM manufacturer of the particular board. Shall
  not be specified unless strictly required. Should \emph{not} contain
  \texttt{Apple\ Inc.}, as this confuses numerous services present in
  the operating system, such as firmware updates, eficheck, as well as
  kernel extensions developed in Acidanthera, such as Lilu and its
  plugins.
\item
  \texttt{SystemProductName}\\
  \textbf{Type}: \texttt{plist\ string}\\
2600
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616
  \textbf{SMBIOS}: System Information (Type 1), Product Name\\
  \textbf{Description}: Preferred Mac model used to mark the device as
  supported by the operating system. This value must be specified by any
  configuration for later automatic generation of the related values in
  this and other SMBIOS tables and related configuration parameters. If
  \texttt{SystemProductName} is not compatible with the target operating
  system, \texttt{-no\_compat\_check} boot argument may be used as an
  override.

  \emph{Note}: If \texttt{SystemProductName} is unknown, and related
  fields are unspecified, default values should be assumed as being set
  to \texttt{MacPro6,1} data. The list of known products can be found in
  \texttt{MacInfoPkg}.
\item
  \texttt{SystemVersion}\\
  \textbf{Type}: \texttt{plist\ string}\\
2617
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2618 2619 2620 2621 2622 2623
  \textbf{SMBIOS}: System Information (Type 1) --- Version\\
  \textbf{Description}: Product iteration version number. May look like
  \texttt{1.1}.
\item
  \texttt{SystemSerialNumber}\\
  \textbf{Type}: \texttt{plist\ string}\\
2624
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2625 2626 2627 2628 2629 2630 2631
  \textbf{SMBIOS}: System Information (Type 1) --- Serial Number\\
  \textbf{Description}: Product serial number in defined format. Known
  formats are described in
  \href{https://github.com/acidanthera/macserial/blob/master/FORMAT.md}{macserial}.
\item
  \texttt{SystemUUID}\\
  \textbf{Type}: \texttt{plist\ string}, GUID\\
2632
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2633 2634 2635 2636 2637 2638 2639
  \textbf{SMBIOS}: System Information (Type 1) --- UUID\\
  \textbf{Description}: A UUID is an identifier that is designed to be
  unique across both time and space. It requires no central registration
  process.
\item
  \texttt{SystemSKUNumber}\\
  \textbf{Type}: \texttt{plist\ string}\\
2640
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2641 2642 2643 2644 2645 2646 2647
  \textbf{SMBIOS}: System Information (Type 1) --- SKU Number\\
  \textbf{Description}: Mac Board ID (\texttt{board-id}). May look like
  \texttt{Mac-7BA5B2D9E42DDD94} or \texttt{Mac-F221BEC8} in older
  models. Sometimes it can be just empty.
\item
  \texttt{SystemFamily}\\
  \textbf{Type}: \texttt{plist\ string}\\
2648
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2649 2650 2651 2652 2653
  \textbf{SMBIOS}: System Information (Type 1) --- Family\\
  \textbf{Description}: Family name. May look like \texttt{iMac\ Pro}.
\item
  \texttt{BoardManufacturer}\\
  \textbf{Type}: \texttt{plist\ string}\\
2654
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2655 2656 2657 2658 2659 2660 2661
  \textbf{SMBIOS}: Baseboard (or Module) Information (Type 2) -
  Manufacturer\\
  \textbf{Description}: Board manufacturer. All rules of
  \texttt{SystemManufacturer} do apply.
\item
  \texttt{BoardProduct}\\
  \textbf{Type}: \texttt{plist\ string}\\
2662
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2663 2664 2665 2666 2667 2668 2669 2670
  \textbf{SMBIOS}: Baseboard (or Module) Information (Type 2) -
  Product\\
  \textbf{Description}: Mac Board ID (\texttt{board-id}). May look like
  \texttt{Mac-7BA5B2D9E42DDD94} or \texttt{Mac-F221BEC8} in older
  models.
\item
  \texttt{BoardVersion}\\
  \textbf{Type}: \texttt{plist\ string}\\
2671
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2672 2673 2674 2675 2676 2677 2678
  \textbf{SMBIOS}: Baseboard (or Module) Information (Type 2) -
  Version\\
  \textbf{Description}: Board version number. Varies, may match
  \texttt{SystemProductName} or \texttt{SystemProductVersion}.
\item
  \texttt{BoardSerialNumber}\\
  \textbf{Type}: \texttt{plist\ string}\\
2679
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2680 2681 2682 2683 2684 2685 2686 2687
  \textbf{SMBIOS}: Baseboard (or Module) Information (Type 2) --- Serial
  Number\\
  \textbf{Description}: Board serial number in defined format. Known
  formats are described in
  \href{https://github.com/acidanthera/macserial/blob/master/FORMAT.md}{macserial}.
\item
  \texttt{BoardAssetTag}\\
  \textbf{Type}: \texttt{plist\ string}\\
2688
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2689 2690 2691 2692 2693 2694 2695
  \textbf{SMBIOS}: Baseboard (or Module) Information (Type 2) --- Asset
  Tag\\
  \textbf{Description}: Asset tag number. Varies, may be empty or
  \texttt{Type2\ -\ Board\ Asset\ Tag}.
\item
  \texttt{BoardType}\\
  \textbf{Type}: \texttt{plist\ integer}\\
2696
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2697 2698 2699 2700 2701 2702 2703 2704
  \textbf{SMBIOS}: Baseboard (or Module) Information (Type 2) --- Board
  Type\\
  \textbf{Description}: Either \texttt{0xA} (Motherboard (includes
  processor, memory, and I/O) or \texttt{0xB} (Processor/Memory Module),
  refer to Table 15 -- Baseboard: Board Type for more details.
\item
  \texttt{BoardLocationInChassis}\\
  \textbf{Type}: \texttt{plist\ string}\\
2705
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2706 2707 2708 2709 2710 2711 2712
  \textbf{SMBIOS}: Baseboard (or Module) Information (Type 2) --- Location
  in Chassis\\
  \textbf{Description}: Varies, may be empty or
  \texttt{Part\ Component}.
\item
  \texttt{ChassisManufacturer}\\
  \textbf{Type}: \texttt{plist\ string}\\
2713
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2714 2715 2716 2717 2718 2719
  \textbf{SMBIOS}: System Enclosure or Chassis (Type 3) --- Manufacturer\\
  \textbf{Description}: Board manufacturer. All rules of
  \texttt{SystemManufacturer} do apply.
\item
  \texttt{ChassisType}\\
  \textbf{Type}: \texttt{plist\ integer}\\
2720
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2721 2722 2723 2724 2725 2726
  \textbf{SMBIOS}: System Enclosure or Chassis (Type 3) --- Type\\
  \textbf{Description}: Chassis type, refer to Table 17 --- System
  Enclosure or Chassis Types for more details.
\item
  \texttt{ChassisVersion}\\
  \textbf{Type}: \texttt{plist\ string}\\
2727
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2728 2729 2730 2731 2732
  \textbf{SMBIOS}: System Enclosure or Chassis (Type 3) --- Version\\
  \textbf{Description}: Should match \texttt{BoardProduct}.
\item
  \texttt{ChassisSerialNumber}\\
  \textbf{Type}: \texttt{plist\ string}\\
2733
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2734 2735 2736 2737 2738
  \textbf{SMBIOS}: System Enclosure or Chassis (Type 3) --- Version\\
  \textbf{Description}: Should match \texttt{SystemSerialNumber}.
\item
  \texttt{ChassisAssetTag}\\
  \textbf{Type}: \texttt{plist\ string}\\
2739
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2740 2741 2742 2743 2744 2745
  \textbf{SMBIOS}: System Enclosure or Chassis (Type 3) --- Asset Tag
  Number\\
  \textbf{Description}: Chassis type name. Varies, could be empty or
  \texttt{MacBook-Aluminum}.
\item
  \texttt{PlatformFeature}\\
2746
  \textbf{Type}: \texttt{plist\ integer}, 32-bit\\
2747
  \textbf{Failsafe}: \texttt{0xFFFFFFFF}\\
V
vit9696 已提交
2748 2749 2750 2751
  \textbf{SMBIOS}: \texttt{APPLE\_SMBIOS\_TABLE\_TYPE133} -
  \texttt{PlatformFeature}\\
  \textbf{Description}: Platform features bitmask. Refer to
  \href{https://github.com/acidanthera/EfiPkg/blob/master/Include/IndustryStandard/AppleFeatures.h}{AppleFeatures.h}
2752 2753 2754 2755
  for more details. Use \texttt{0xFFFFFFFF} value to not provide this table.
\item
  \texttt{SmcVersion}\\
  \textbf{Type}: \texttt{plist\ data}, 16 bytes\\
2756
  \textbf{Failsafe}: All zero\\
2757 2758 2759
  \textbf{SMBIOS}: \texttt{APPLE\_SMBIOS\_TABLE\_TYPE134} - \texttt{Version}\\
  \textbf{Description}: ASCII string containing SMC version in upper case.
  Missing on T2 based Macs. Ignored when zero.
V
vit9696 已提交
2760 2761
\item
  \texttt{FirmwareFeatures}\\
V
vit9696 已提交
2762
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
2763
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
2764 2765 2766 2767 2768 2769 2770 2771
  \textbf{SMBIOS}: \texttt{APPLE\_SMBIOS\_TABLE\_TYPE128} -
  \texttt{FirmwareFeatures} and \texttt{ExtendedFirmwareFeatures}\\
  \textbf{Description}: 64-bit firmware features bitmask. Refer to
  \href{https://github.com/acidanthera/EfiPkg/blob/master/Include/IndustryStandard/AppleFeatures.h}{AppleFeatures.h}
  for more details. Lower 32 bits match \texttt{FirmwareFeatures}. Upper
  64 bits match \texttt{ExtendedFirmwareFeatures}.
\item
  \texttt{FirmwareFeaturesMask}\\
V
vit9696 已提交
2772
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
2773
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784
  \textbf{SMBIOS}: \texttt{APPLE\_SMBIOS\_TABLE\_TYPE128} -
  \texttt{FirmwareFeaturesMask} and
  \texttt{ExtendedFirmwareFeaturesMask}\\
  \textbf{Description}: Supported bits of extended firmware features
  bitmask. Refer to
  \href{https://github.com/acidanthera/EfiPkg/blob/master/Include/IndustryStandard/AppleFeatures.h}{AppleFeatures.h}
  for more details. Lower 32 bits match \texttt{FirmwareFeaturesMask}.
  Upper 64 bits match \texttt{ExtendedFirmwareFeaturesMask}.
\item
  \texttt{ProcessorType}\\
  \textbf{Type}: \texttt{plist\ integer}, 16-bit\\
2785
  \textbf{Failsafe}: Automatic\\
V
vit9696 已提交
2786 2787 2788 2789 2790 2791
  \textbf{SMBIOS}: \texttt{APPLE\_SMBIOS\_TABLE\_TYPE131} -
  \texttt{ProcessorType}\\
  \textbf{Description}: Combined of Processor Major and Minor types.
\item
  \texttt{MemoryFormFactor}\\
  \textbf{Type}: \texttt{plist\ integer}, 8-bit\\
2792
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804
  \textbf{SMBIOS}: Memory Device (Type 17) --- Form Factor\\
  \textbf{Description}: Memory form factor. On Macs it should be DIMM or
  SODIMM.
\end{enumerate}

\section{UEFI}\label{uefi}

\subsection{Introduction}\label{uefiintro}

\href{https://uefi.org/specifications}{UEFI} (Unified Extensible Firmware Interface)
is a specification that defines a software interface between an operating system and
platform firmware. This section allows to load additional UEFI modules and/or apply
V
vit9696 已提交
2805 2806 2807
tweaks for the onboard firmware. To inspect firmware contents, apply modifications
and perform upgrades \href{https://github.com/LongSoft/UEFITool/releases}{UEFITool}
and supplementary utilities can be used.
V
vit9696 已提交
2808 2809 2810 2811 2812 2813 2814

\subsection{Properties}\label{uefiprops}

\begin{enumerate}
\item
  \texttt{ConnectDrivers}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2815
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
2816 2817 2818 2819 2820 2821 2822 2823 2824
  \textbf{Description}: Perform UEFI controller connection after driver
  loading. This option is useful for loading filesystem drivers, which
  usually follow UEFI driver model, and may not start by themselves.
  While effective, this option is not necessary with e.g. APFS loader
  driver, and may slightly slowdown the boot.

\item
  \texttt{Drivers}\\
  \textbf{Type}: \texttt{plist\ array}\\
2825
  \textbf{Failsafe}: None\\
V
vit9696 已提交
2826 2827 2828 2829 2830 2831 2832 2833
  \textbf{Description}: Load selected drivers from \texttt{OC/Drivers}
  directory.

  Designed to be filled with string filenames meant to be loaded as UEFI
  drivers. Depending on the firmware a different set of drivers may be required.
  Loading an incompatible driver may lead your system to unbootable state or
  even cause permanent firmware damage. Some of the known drivers include:

V
vit9696 已提交
2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853
  \begin{itemize}
  \tightlist
  \item \href{https://github.com/acidanthera/AppleSupportPkg}{\texttt{ApfsDriverLoader}}
  --- APFS file system bootstrap driver adding the support of embedded APFS drivers
  in bootable APFS containers in UEFI firmwares.
  \item \href{https://github.com/acidanthera/AppleSupportPkg}{\texttt{AppleUiSupport}}
  --- Apple-specific user interface support driver. This driver brings the support
  for FileVault 2 GUI, hotkey parsing (shift, cmd+v, etc.), language collation support,
  and certain other features important for normal macOS functioning. For hotkey support
  \texttt{AppleKeyMapAggregator}-compatible driver is required.
  \item \href{https://github.com/acidanthera/AptioFixPkg}{\texttt{AptioInputFix}}
  --- user input driver adding the support of \texttt{AppleKeyMapAggregator} protocols
  on top of different UEFI input protocols. Additionally resolves mouse input issues
  on select firmwares. This is an alternative to \texttt{UsbKbDxe}, which may work
  better or worse depending on the firmware.
  \item \href{https://github.com/acidanthera/AptioFixPkg}{\texttt{AptioMemoryFix}}
  --- a set of quirks for various firmwares. While it primarily targets APTIO
  firmwares, other firmwares may be compatible as well. Among the resolved issues
  are hibernation support, KASLR, Lilu NVRAM security enhancements, NVRAM, and UEFI
  Boot entry preservation.
2854
  \item \href{https://github.com/tianocore/edk2/tree/UDK2018}{\texttt{EmuVariableRuntimeDxe}}
V
vit9696 已提交
2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888
  --- NVRAM emulation driver from \texttt{MdeModulePkg}. NVRAM is supported by most
  modern firmwares. For firmwares with macOS incompatible NVRAM implementation an
  emulated driver may be used. This driver will not preserve NVRAM contents across the
  reboots.
  \item \href{https://github.com/tianocore/edk2/tree/UDK2018}{\texttt{EnglishDxe}}
  --- Unicode collation driver from \texttt{MdeModulePkg}. This driver is a lightweight
  alternative to \texttt{AppleUiSupport}, which contains no Apple-specific code, and
  only provides unicode collation support. The driver is not recommended for use
  on any hardware but few original Macs.
  \item \href{https://github.com/tianocore/edk2/tree/UDK2018}{\texttt{EnhancedFatDxe}}
  --- FAT filesystem driver from \texttt{FatPkg}. This driver is embedded in all
  UEFI firmwares, and cannot be used from OpenCore. It is known that multiple firmwares
  have a bug in their FAT support implementation, which leads to corrupted filesystems
  on write attempt.  Embedding this driver within the firmware may be required in case
  writing to EFI partition is needed during the boot process.
  \item \href{https://github.com/tianocore/edk2/tree/UDK2018}{\texttt{NvmExpressDxe}}
  --- NVMe support driver from \texttt{MdeModulePkg}. This driver is included in most
  firmwares starting with Broadwell generation. For Haswell and earlier embedding it
  within the firmware may be more favourable in case a NVMe SSD drive is installed.
  \item \href{https://github.com/acidanthera/AppleSupportPkg}{\texttt{UsbKbDxe}}
  --- USB keyboard driver adding the support of \texttt{AppleKeyMapAggregator} protocols
  on top of a custom USB keyboard driver implementation. This is an alternative to
  \texttt{AptioInputFix}, which may work better or worse depending on the firmware.
  \item \href{https://github.com/acidanthera/VirtualSMC}{\texttt{VirtualSmc}}
  --- UEFI SMC driver, required for proper FileVault 2 functionality and potentially
  other macOS specifics. An alternative, named \texttt{SMCHelper}, is not compatible
  with \texttt{VirtualSmc} and OpenCore, which is unaware of its specific interfaces.
  In case \texttt{FakeSMC} kernel extension is used, manual NVRAM variable addition
  may be needed and \texttt{VirtualSmc} driver should still be used.
  \item \href{https://github.com/acidanthera/AppleSupportPkg}{\texttt{VBoxHfs}}
  --- HFS file system driver with bless support. This driver is an alternative to
  a closed source \texttt{HFSPlus} driver commonly found in Apple firmwares. While
  it is feature complete, it is approximately 3~times slower and is yet to undergo
  a security audit.
V
vit9696 已提交
2889 2890 2891 2892
  \item \href{https://github.com/tianocore/edk2/tree/UDK2018}{\texttt{XhciDxe}}
  --- XHCI USB controller support driver from \texttt{MdeModulePkg}. This driver is
  included in most firmwares starting with Sandy Bridge generation. For earlier firmwares
  or legacy systems it may be used to support external USB 3.0 PCI cards.
V
vit9696 已提交
2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904
  \end{itemize}

  To compile the drivers from TianoCore UDK use the same command you do normally use
  for OpenCore compilation, but choose a corresponding package:
\begin{lstlisting}[label=compileudk, style=ocbash]
git clone https://github.com/tianocore/edk2 -b UDK2018 UDK
cd UDK
source edksetup.sh
make -C BaseTools
build -a X64 -b RELEASE -t XCODE5 -p FatPkg/FatPkg.dsc
build -a X64 -b RELEASE -t XCODE5 -p MdeModulePkg/MdeModulePkg.dsc
\end{lstlisting}
2905 2906 2907 2908

\item
  \texttt{Protocols}\\
  \textbf{Type}: \texttt{plist\ dict}\\
2909
  \textbf{Failsafe}: None\\
2910 2911 2912
  \textbf{Description}: Force builtin versions of select protocols described
  in \hyperref[uefiprotoprops]{Protocols Properties} section below.

V
vit9696 已提交
2913 2914
  \emph{Note}: all protocol instances are installed prior to driver loading.

V
vit9696 已提交
2915 2916 2917
\item
  \texttt{Quirks}\\
  \textbf{Type}: \texttt{plist\ dict}\\
2918
  \textbf{Failsafe}: None\\
V
vit9696 已提交
2919 2920 2921 2922 2923
  \textbf{Description}: Apply individual firmware quirks described in
  \hyperref[uefiquirkprops]{Quirks Properties} section below.

\end{enumerate}

2924 2925 2926 2927 2928 2929 2930
\subsection{Protocols Properties}\label{uefiprotoprops}

\begin{enumerate}

\item
  \texttt{AppleBootPolicy}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2931
  \textbf{Failsafe}: \texttt{false}\\
2932
  \textbf{Description}: Reinstalls Apple Boot Policy protocol with a builtin
2933 2934
  version. This may be used to ensure APFS compatibility on VMs or legacy Macs.

2935 2936 2937
\item
  \texttt{ConsoleControl}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2938
  \textbf{Failsafe}: \texttt{false}\\
2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949
  \textbf{Description}: Replaces Console Control protocol with a builtin version.

  macOS bootloader requires console control protocol for text output, which some firmwares
  miss. This option is required to be set when the protocol is already available in the
  firmware, and other console control options are used, such as \texttt{IgnoreTextInGraphics},
  \texttt{SanitiseClearScreen}, and sometimes \texttt{ConsoleBehaviourOs} with
  \texttt{ConsoleBehaviourUi}).

\item
  \texttt{DataHub}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2950
  \textbf{Failsafe}: \texttt{false}\\
2951 2952 2953
  \textbf{Description}: Reinstalls Data Hub protocol with a builtin version.
  This will drop all previous properties if the protocol was already installed.

2954 2955 2956
\item
  \texttt{DeviceProperties}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2957
  \textbf{Failsafe}: \texttt{false}\\
2958
  \textbf{Description}: Reinstalls Device Property protocol with a builtin
2959 2960 2961 2962 2963
  version. This will drop all previous properties if it was already installed.
  This may be used to ensure full compatibility on VMs or legacy Macs.

\end{enumerate}

V
vit9696 已提交
2964 2965 2966 2967
\subsection{Quirks Properties}\label{uefiquirkprops}

\begin{enumerate}

2968 2969 2970
\item
  \texttt{ExitBootServicesDelay}\\
  \textbf{Type}: \texttt{plist\ integer}\\
2971
  \textbf{Failsafe}: \texttt{0}\\
2972 2973 2974 2975 2976 2977 2978 2979 2980
  \textbf{Description}: Adds delay in microseconds after \texttt{EXIT\_BOOT\_SERVICES}
  event.

  This is a very ugly quirk to circumvent "Still waiting for root device" message
  on select APTIO IV firmwares, namely ASUS Z87-Pro, when using FileVault 2 in particular.
  It seems that for some reason they execute code in parallel to \texttt{EXIT\_BOOT\_SERVICES},
  which results in SATA controller being inaccessible from macOS. A better approach should be
  found in some future. Expect 3-5 seconds to be enough in case the quirk is needed.

V
vit9696 已提交
2981 2982 2983
\item
  \texttt{IgnoreInvalidFlexRatio}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2984
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
2985 2986 2987 2988 2989 2990 2991
  \textbf{Description}: Select firmwares, namely APTIO IV, may contain invalid values in
  \texttt{MSR\_FLEX\_RATIO} (\texttt{0x194}) MSR register. These values may cause
  macOS boot failure on Intel platforms.

  \emph{Note}: While the option is not supposed to induce harm on unaffected firmwares,
  its usage is not recommended when it is not required.

V
vit9696 已提交
2992 2993 2994
\item
  \texttt{IgnoreTextInGraphics}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2995
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
2996 2997 2998 2999 3000 3001 3002
  \textbf{Description}: Select firmwares output text onscreen in both graphics and
  text mode. This is normally unexpected, because random text may appear over
  graphical images and cause UI corruption. Setting this option to \texttt{true} will
  discard all text output when console control is in mode different from \texttt{Text}.

  \emph{Note}: While the option is not supposed to induce harm on unaffected firmwares,
  its usage is not recommended when it is not required. This option may hide
3003
  onscreen error messages. \texttt{ConsoleControl} may need to be set to
3004
  \texttt{true} for this to work.
V
vit9696 已提交
3005

V
vit9696 已提交
3006 3007 3008
\item
  \texttt{ProvideConsoleGop}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
3009
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
3010 3011 3012 3013 3014 3015 3016
  \textbf{Description}: macOS bootloader requires GOP (Graphics Output Protocol)
  to be present on console handle. This option will install it if missing.

  \emph{Note}: Some drivers, like AptioMemoryFix, may provide equivalent functionality.
  These drivers are not guaranteed to adhere to the same logic, and if a quirk is
  necessary, this option is preferred.

3017 3018 3019
\item
  \texttt{ReleaseUsbOwnership}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
3020
  \textbf{Failsafe}: \texttt{false}\\
3021 3022 3023 3024 3025
  \textbf{Description}: Attempt to detach USB controller ownership from
  the firmware driver. While most firmwares manage to properly do that,
  or at least have an option for, select firmwares do not. As a result,
  operating system may freeze upon boot. Not recommended unless required.

3026 3027 3028
\item
  \texttt{RequestBootVarRouting}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
3029
  \textbf{Failsafe}: \texttt{false}\\
3030 3031 3032 3033 3034 3035 3036 3037
  \textbf{Description}: Request NVRAM driver (or AptioMemoryFix) to redirect
  \texttt{Boot} prefixed variables from \texttt{EFI\_GLOBAL\_VARIABLE\_GUID}
  to \texttt{OC\_VENDOR\_VARIABLE\_GUID}.

  This will set special \texttt{boot-redirect} variable, which a compatible
  driver will abide after booter start. The quirk lets default boot entry
  preservation at times when firmwares delete incompatible boot entries.

3038 3039 3040
\item
  \texttt{SanitiseClearScreen}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
3041
  \textbf{Failsafe}: \texttt{false}\\
3042 3043 3044 3045 3046
  \textbf{Description}: Some firmwares reset screen resolution to a failsafe
  value (like \texttt{1024x768}) on the attempts to clear screen contents
  when large display (e.g. 2K or 4K) is used. This option attempts to apply
  a workaround.

3047
  \emph{Note}: \texttt{ConsoleControl} may need to be set to
3048 3049 3050
  \texttt{true} for this to work. On all known affected systems
  \texttt{ConsoleMode} had to be set to empty string for this to work.

V
vit9696 已提交
3051 3052 3053 3054
\end{enumerate}

\section{Troubleshooting}\label{troubleshooting}

V
vit9696 已提交
3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076
\subsection{Tips and Tricks}\label{troubleshootingtricks}

\begin{enumerate}
\item
  \textbf{How to debug boot failure?}

  Normally it is enough to obtain the actual error message. For this
  ensure that:
  \begin{itemize}
  \tightlist
  \item You have a \texttt{DEBUG} or \texttt{NOOPT} version of OpenCore.
  \item Logging is enabled (\texttt{1}) and shown onscreen (\texttt{2}):
  \texttt{Misc} $\rightarrow$ \texttt{Debug} $\rightarrow$ \texttt{Target}
  $=$ \texttt{3}.
  \item Logged messages from at least \texttt{DEBUG\_ERROR}
  (\texttt{0x80000000}), \texttt{DEBUG\_WARN} (\texttt{0x00000002}), and
  \texttt{DEBUG\_INFO} (\texttt{0x00000040}) levels are visible onscreen:
  \texttt{Misc} $\rightarrow$ \texttt{Debug} $\rightarrow$ \texttt{DisplayLevel}
  $=$ \texttt{0x80000042}.
  \item Critical error messages, like \texttt{DEBUG\_ERROR}, stop booting:
  \texttt{Misc} $\rightarrow$ \texttt{Security}
  $\rightarrow$ \texttt{HaltLevel} $=$ \texttt{0x80000000}.
V
vit9696 已提交
3077 3078 3079
  \item Watch Dog is disabled to prevent automatic reboot:
  \texttt{Uefi} $\rightarrow$ \texttt{Quirks} $\rightarrow$
  \texttt{DisableWatchDog} $=$ \texttt{true}.
V
vit9696 已提交
3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097
  \item Boot Picker (entry selector) is enabled: \texttt{Misc}
  $\rightarrow$ \texttt{Boot} $\rightarrow$ \texttt{ShowPicker} $=$ \texttt{true}.
  \end{itemize}

  If there is no obvious error, check the available hacks in \texttt{Quirks} sections
  one by one.

\item
  \textbf{How to customise boot entries?}

  OpenCore follows standard Apple Bless model and extracts the entry name
  from \texttt{.contentDetails} and \texttt{.disk\_label.contentDetails} files in the
  booter directory if present. These files contain an ASCII string with an entry title,
  which may then be customised by the user.

\item
  \textbf{What is the simplest way to install macOS?}

V
vit9696 已提交
3098 3099 3100 3101
  Copy online recovery image (\texttt{*.dmg} and \texttt{*.chunklist} files)
  to \texttt{com.apple.recovery.boot} directory on a FAT32 partition with OpenCore.
  Load OpenCore Boot Picker and choose the entry, it will have a \texttt{(dmg)} suffix.
  Custom name may be created by providing \texttt{.contentDetails} file.
V
vit9696 已提交
3102

V
vit9696 已提交
3103
  To download recovery online you may use
3104
  \href{https://github.com/acidanthera/OcSupportPkg/tree/master/Tools/Recovery}{Recovery}
V
vit9696 已提交
3105
  tool from \href{https://github.com/acidanthera/OcSupportPkg}{OcSupportPkg}.
V
vit9696 已提交
3106

V
vit9696 已提交
3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117
\item
  \textbf{Can I install Windows?}

  While no official Windows support is provided, 64-bit UEFI Windows installations (Windows 8 and
  above) prepared with Boot Camp are supposed to work in general. Third-party UEFI installations
  as well as systems partially supporting UEFI boot, like Windows 7, might work with
  some extra precautions. Be warned that macOS requires first partition to be EFI System
  Partition, and does not support the default Windows layout.
  Other than that, all the modifications applied (to ACPI, NVRAM, SMBIOS, etc.) are supposed
  to be operating system agnostic, i.e. apply equally regardless of the OS booted.

3118 3119 3120 3121 3122 3123
  Loading Windows from OpenCore may lead to the need of reactivation. To avoid it consider
  leaving SystemUUID field empty, so that the original firmware UUID is used. Be warned,
  on old firmwares it may be invalid, i.e. not random. In case you still have issues,
  consider using HWID or KMS38 license, the nuances of Windows activation are out of the
  scope of this document and can be found online.

3124 3125 3126 3127 3128
  To enable operating system switching and install relevant drivers in the majority of
  cases you will need Windows support software from
  \href{https://support.apple.com/boot-camp}{Boot Camp}. For simplicity of the download
  process or when configuring an already installed Windows version a third-party utility,
  \href{https://github.com/timsutton/brigadier}{Brigadier}, can be used successfully.
V
vit9696 已提交
3129 3130 3131 3132 3133 3134 3135 3136 3137
  Note, that you may have to download and install \href{https://www.7-zip.org}{7-Zip}
  prior to using Brigadier.

  While Windows support software from Boot Camp solves most of compatibility problems,
  sometimes you may have to address some of them manually. To invert mouse wheel scroll
  direction \texttt{FlipFlopWheel} must be set to \texttt{1} as explained on
  \href{https://superuser.com/a/364353}{SuperUser}. Similarly \texttt{RealTimeIsUniversal}
  must be set to \texttt{1} to avoid time desync between Windows and macOS as explained
  on \href{https://superuser.com/q/494432}{SuperUser} (this one is usually not needed).
3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180

\item
  \textbf{Why do I see \texttt{Basic data partition} in Boot Camp Control panel?}

  Boot Camp control panel uses GPT partition table to obtain each boot option name.
  After installing Windows separately you will have to relabel the partition manually.
  This can be done with many tools including open-source
  \href{https://sourceforge.net/projects/gptfdisk}{gdisk} utility. Reference example:

\begin{lstlisting}[caption=Relabeling Windows volume, label=relabel, style=ocbash]
PS C:\gdisk> .\gdisk64.exe \\.\physicaldrive0
GPT fdisk (gdisk) version 1.0.4

Command (? for help): p
Disk \\.\physicaldrive0: 419430400 sectors, 200.0 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): DEC57EB1-B3B5-49B2-95F5-3B8C4D3E4E12
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 419430366
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1023999   499.0 MiB   2700  Basic data partition
   2         1024000         1226751   99.0 MiB    EF00  EFI system partition
   3         1226752         1259519   16.0 MiB    0C01  Microsoft reserved ...
   4         1259520       419428351   199.4 GiB   0700  Basic data partition

Command (? for help): c
Partition number (1-4): 4
Enter name: BOOTCAMP

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to \\.\physicaldrive0.
Disk synchronization succeeded! The computer should now use the new partition table.
The operation has completed successfully.
\end{lstlisting}

V
vit9696 已提交
3181
\end{enumerate}
V
vit9696 已提交
3182 3183

\end{document}