Configuration.tex 254.1 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}
15
\usepackage{mathtools}
V
vit9696 已提交
16 17 18 19
\usepackage{parskip}
\usepackage[margin=0.7in]{geometry}
\usepackage{titlesec}
\usepackage[yyyymmdd,hhmmss]{datetime}
V
vit9696 已提交
20
\usepackage{textcomp}
V
vit9696 已提交
21 22 23 24 25 26
\usepackage{tikz}

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

\renewcommand{\dateseparator}{.}

30 31 32 33 34 35 36 37
\makeatletter
\newcommand*{\bdiv}{%
  \nonscript\mskip-\medmuskip\mkern5mu%
  \mathbin{\operator@font div}\penalty900\mkern5mu%
  \nonscript\mskip-\medmuskip
}
\makeatother

38 39
% 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 已提交
40 41 42 43 44
\lstdefinestyle{ocbash}{
  language=bash,
  frame=tb,
  columns=fullflexible,
  captionpos=b,
45 46
  basicstyle=\ttfamily\normalsize,
  keepspaces=true,
47
  morekeywords={git, make, build, ioreg, grep, nvram, sort, sudo, diskutil, gfxutil, strings, dd, cut, python},
V
vit9696 已提交
48
  literate =
V
vit9696 已提交
49
    {"}{{\textquotedbl}}1
V
vit9696 已提交
50 51
    {'}{{\textquotesingle}}1
    {-}{{-}}1
V
vit9696 已提交
52 53
    {~}{{\texttildelow}}1
    {*}{{*}}1
54 55
    {fl}{{f{}l}}2
    {fi}{{f{}i}}2
V
vit9696 已提交
56 57 58
    ,
}

V
vit9696 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
\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}
V
vit9696 已提交
78
       \vspace*{2.0in}
V
vit9696 已提交
79 80 81

       \Huge

V
vit9696 已提交
82 83 84 85 86 87
       \IfFileExists{Logos/Logo.pdf}
         {\includegraphics[width=160pt, height=160pt]{Logos/Logo.pdf}}
         {\includegraphics[width=160pt, height=160pt]{../Logos/Logo.pdf}}

       \sffamily

V
vit9696 已提交
88 89 90 91
       \textbf{OpenCore}

       \vspace{0.2in}

A
Andrey1970AppleLife 已提交
92
       Reference Manual (0.6.1)
V
vit9696 已提交
93 94 95 96 97 98 99 100 101

       \vspace{0.2in}

        {[}\today{]}

       \normalsize

       \vfill

V
vit9696 已提交
102 103
       \rmfamily

A
Andrey1970AppleLife 已提交
104
       Copyright \textcopyright 2018-2020 vit9696
V
vit9696 已提交
105 106 107 108 109 110 111 112 113 114 115

   \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
V
vit9696 已提交
116 117 118 119
operating system. It is to be read as the official clarification of expected
OpenCore behaviour. All deviations, if found in published OpenCore releases,
shall be considered documentation or implementation bugs, and are requested to be
reported through \href{https://github.com/acidanthera/bugtracker}{Acidanthera Bugtracker}.
V
vit9696 已提交
120 121
Errata sheet is available in
\href{https://github.com/acidanthera/OpenCorePkg/blob/master/Docs/Errata/Errata.pdf}{OpenCorePkg repository}.
V
vit9696 已提交
122 123

This document is structured as a specification, and is not meant to provide a step by
V
vit9696 已提交
124 125 126 127 128 129
step algorithm for configuring end-user board support package (BSP). The intended audience
of the document are programmers and engineers with basic understanding of macOS internals
and UEFI functioning. For these reasons this document is available exclusively in English,
and all other sources or translations of this document are unofficial and may
contain errors.

V
vit9696 已提交
130
Third-party articles, utilities, books, and alike may be more useful for a wider audience as
V
vit9696 已提交
131 132 133
they could provide guide-like material. However, they are prone to their authors' preferences,
tastes, this document misinterpretation, and essential obsolescence.
In case you use these sources, for example, \href{https://dortania.github.io}{Dortania}'s
V
vit9696 已提交
134
\href{https://dortania.github.io/OpenCore-Install-Guide}{OpenCore Install Guide}
V
vit9696 已提交
135 136 137 138 139
and \href{https://dortania.github.io/getting-started}{related material},
please ensure to follow this document for every made decision and judge its consequences.

Be warned that regardless of the sources used you are required to fully understand every
dedicated OpenCore configuration option and concept prior to reporting any issues in
V
vit9696 已提交
140 141
\href{https://github.com/acidanthera/bugtracker}{Acidanthera Bugtracker}.

V
vit9696 已提交
142
\subsection{Generic Terms}\label{generic-terms}
V
vit9696 已提交
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 172 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

\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}

V
vit9696 已提交
208
\section{Configuration}\label{configuration-overview}
V
vit9696 已提交
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 334 335 336

\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
337 338 339
  \texttt{Add} provides support for data addition. Existing data will
  not be overridden, and needs to be handled separately with
  \texttt{Delete} if necessary.
V
vit9696 已提交
340
\item
341
  \texttt{Delete} provides support for data removal.
V
vit9696 已提交
342 343 344 345 346 347 348 349 350 351 352 353
\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}}
354 355
\item
  \hyperref[booter]{\texttt{Booter}}
V
vit9696 已提交
356 357 358 359 360 361 362 363 364 365 366 367 368 369
\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}

370
It is possible to perform basic validation of the configuration by using
371
\texttt{ocvalidate} utility. Please note, that \texttt{ocvalidate}
372 373 374
must match the used OpenCore release and may not be able to detect all
configuration flaws present in the file.

V
vit9696 已提交
375 376 377 378
\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 已提交
379
\section{Setup}\label{setup-overview}
V
vit9696 已提交
380

V
vit9696 已提交
381
\subsection{Directory Structure}\label{directory-structure}
V
vit9696 已提交
382

383
\begin{center}
V
vit9696 已提交
384
\begin{tikzpicture}[%
385 386
  grow via three points={one child at (0.5,-0.6) and
  two children at (0.5,-0.6) and (0.5,-1.2)},
V
vit9696 已提交
387
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
388 389 390 391
  \node {ESP}
    child { node {EFI}
      child { node {BOOT}
        child { node [selected] {BOOTx64.efi}}
V
vit9696 已提交
392
      }
393
      child [missing] {}
394 395
      child { node {OC}
        child { node {ACPI}
396 397 398
          child { node [optional] {DSDT.aml}}
          child { node [optional] {SSDT-1.aml}}
          child { node [optional] {MYTABLE.aml}}
399 400 401 402
        }
        child [missing] {}
        child [missing] {}
        child [missing] {}
A
Andrey1970AppleLife 已提交
403 404 405 406
        child { node {Bootstrap}
          child { node [selected] {Bootstrap.efi}}
        }
        child [missing] {}
407 408 409 410 411 412 413 414 415 416 417 418
        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] {}
419 420
        child { node [optional] {Resources}
          child { node [optional] {Audio}}
A
Andrey1970AppleLife 已提交
421 422 423
          child { node [optional] {Font}}
          child { node [optional] {Image}}
          child { node [optional] {Label}}
424 425
        }
        child [missing] {}
A
Andrey1970AppleLife 已提交
426 427 428
        child [missing] {}
        child [missing] {}
        child [missing] {}
429 430 431 432 433 434
        child { node  {Tools}
          child { node [optional] {Tool.efi}}
        }
        child [missing] {}
        child { node [selected] {OpenCore.efi}}
        child { node {config.plist}}
A
Andrey1970AppleLife 已提交
435
        child { node [optional] {vault.plist}}
436
        child { node [optional] {vault.sig}}
437
      }
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
    }
    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] {}
458 459
    child [missing] {}
    child [missing] {}
A
Andrey1970AppleLife 已提交
460 461 462 463 464
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
    child [missing] {}
V
vit9696 已提交
465
    child { node [optional] {boot}}
466
    child { node [optional] {nvram.plist}}
467
    child { node [optional] {opencore-YYYY-MM-DD-HHMMSS.txt}}
A
Andrey1970AppleLife 已提交
468
    child { node [optional] {panic-YYYY-MM-DD-HHMMSS.txt}}
A
Andrey1970AppleLife 已提交
469
    child { node [optional] {SysReport}}
470
  ;
V
vit9696 已提交
471
\end{tikzpicture}
472 473 474 475 476
\break
\label{fig:DS}
Figure 1. Directory Structure
\end{center}

V
vit9696 已提交
477 478 479 480 481 482 483
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
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
  \texttt{BOOTx64.efi} and \texttt{Bootstrap.efi} \\
  Initial bootstrap loaders, which loads \texttt{OpenCore.efi} unless it was
  already started as a driver. \texttt{BOOTx64.efi} is loaded by the firmware
  by default according to UEFI specification, and \texttt{Bootstrap.efi} can
  be registered as a custom option to let OpenCore coexist with operating systems
  using \texttt{BOOTx64.efi} as their own loaders (e.g. Windows), see
  \texttt{BootProtect} for more details.
\item
  \texttt{boot} \\
  Duet bootstrap loader, which initialises UEFI environment on legacy BIOS firmwares
  and loads \texttt{OpenCore.efi} similarly to other bootstrap loaders. Modern Duet
  bootstrap loader will default to \texttt{OpenCore.efi} on the same partition when
  present.
\item
  \texttt{ACPI} \\
V
vit9696 已提交
499 500 501
  Directory used for storing supplemental ACPI information
  for \hyperref[acpi]{\texttt{ACPI}} section.
\item
502
  \texttt{Drivers} \\
V
vit9696 已提交
503 504 505
  Directory used for storing supplemental \texttt{UEFI}
  drivers for \hyperref[uefi]{\texttt{UEFI}} section.
\item
506
  \texttt{Kexts} \\
V
vit9696 已提交
507 508
  Directory used for storing supplemental kernel information
  for \hyperref[kernel]{\texttt{Kernel}} section.
509
\item
510
  \texttt{Resources} \\
511 512
  Directory used for storing media resources, such as audio files
  for screen reader support. See \hyperref[uefiaudioprops]{\texttt{UEFI Audio Properties}}
513 514
  section for more details. This directory also contains image files
  for graphical user interface. See \hyperref[ueficanopy]{OpenCanopy} section for more details.
V
vit9696 已提交
515
\item
516
  \texttt{Tools} \\
V
vit9696 已提交
517 518
  Directory used for storing supplemental tools.
\item
519
  \texttt{OpenCore.efi} \\
V
vit9696 已提交
520 521
  Main booter driver responsible for operating system loading.
\item
522
  \texttt{config.plist} \\
V
vit9696 已提交
523
  \texttt{OC Config}.
A
Andrey1970AppleLife 已提交
524 525 526
\item
  \texttt{vault.plist} \\
  Hashes for all files potentially loadable by \texttt{OC Config}.
V
vit9696 已提交
527
\item
528
  \texttt{vault.sig} \\
V
vit9696 已提交
529
  Signature for \texttt{vault.plist}.
530 531 532
\item
  \texttt{SysReport} \\
  Directory containing system reports generated by \texttt{SysReport} option.
V
vit9696 已提交
533
\item
534
  \texttt{nvram.plist} \\
V
vit9696 已提交
535 536
  OpenCore variable import file.
\item
537
  \texttt{opencore-YYYY-MM-DD-HHMMSS.txt} \\
V
vit9696 已提交
538
  OpenCore log file.
A
Andrey1970AppleLife 已提交
539 540 541
\item
  \texttt{panic-YYYY-MM-DD-HHMMSS.txt} \\
  Kernel panic log file.
V
vit9696 已提交
542 543
\end{itemize}

544 545 546 547
\emph{Note}: It is not guaranteed that paths longer than
\texttt{OC\_STORAGE\_SAFE\_PATH\_MAX} (128 characters including
\texttt{\\0}-termnator) will be accessible within OpenCore.

548 549 550 551 552 553 554 555
\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 已提交
556 557 558 559
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
560 561 562 563 564 565 566 567 568 569 570
\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
V
vit9696 已提交
571
be used. \texttt{OpenDuetPkg} is one of the known UEFI environment providers
572
for legacy systems. To run OpenCore on such a legacy system you can install
V
vit9696 已提交
573 574 575
\texttt{OpenDuetPkg} with a dedicated tool --- BootInstall (bundled with OpenCore).
\href{https://github.com/corpnewt/gibMacOS}{Third-party utilities} can be used to
perform this on systems different from macOS.
576 577 578 579 580 581

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.

582 583
\subsection{Contribution}\label{configuration-comp}

V
vit9696 已提交
584
OpenCore can be compiled as an ordinary
585
\href{https://github.com/tianocore/tianocore.github.io/wiki/EDK-II}{EDK II} package.
V
vit9696 已提交
586 587 588
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}.
589 590 591
Currently supported EDK II release is hosted in
\href{https://github.com/acidanthera/audk}{acidanthera/audk}. The required patches
for the package are present in \texttt{Patches} directory.
592 593 594 595 596 597 598 599

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}.

To compile with \texttt{XCODE5}, besides \href{https://developer.apple.com/xcode}{Xcode},
one should also install \href{https://www.nasm.us}{NASM} and
V
vit9696 已提交
600
\href{https://github.com/acidanthera/ocbuild/tree/master/external}{MTOC}.
601 602
The latest Xcode version is recommended for use despite the toolchain name. Example
command sequence may look as follows:
603

V
vit9696 已提交
604
\begin{lstlisting}[caption=Compilation Commands, label=compile, style=ocbash]
605
git clone --recursive --depth=1 https://github.com/acidanthera/audk UDK
606 607 608
cd UDK
git clone https://github.com/acidanthera/OpenCorePkg
source edksetup.sh
V
vit9696 已提交
609
make -C BaseTools
610 611 612
build -a X64 -b RELEASE -t XCODE5 -p OpenCorePkg/OpenCorePkg.dsc
\end{lstlisting}

V
vit9696 已提交
613 614 615 616 617 618 619 620 621
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
622 623 624
-I/UefiPackages/MdeModulePkg
-I/UefiPackages/MdeModulePkg/Include
-I/UefiPackages/MdeModulePkg/Include/X64
V
vit9696 已提交
625 626 627
-I/UefiPackages/OpenCorePkg/Include/AMI
-I/UefiPackages/OpenCorePkg/Include/Acidanthera
-I/UefiPackages/OpenCorePkg/Include/Apple
V
vit9696 已提交
628 629
-I/UefiPackages/OpenCorePkg/Include/Apple/X64
-I/UefiPackages/OpenCorePkg/Include/Duet
V
vit9696 已提交
630 631 632 633
-I/UefiPackages/OpenCorePkg/Include/Generic
-I/UefiPackages/OpenCorePkg/Include/Intel
-I/UefiPackages/OpenCorePkg/Include/Microsoft
-I/UefiPackages/OpenCorePkg/Include/VMware
634
-I/UefiPackages/OvmfPkg/Include
V
vit9696 已提交
635
-I/UefiPackages/UefiCpuPkg/Include
V
vit9696 已提交
636 637 638 639 640 641 642 643 644 645 646
-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
647
-Wno-varargs
V
vit9696 已提交
648
-Wno-unused-const-variable
649
-DOC_TARGET_NOOPT=1
V
vit9696 已提交
650
-DNO_MSABI_VA_FUNCS=1
V
vit9696 已提交
651
\end{lstlisting}
V
vit9696 已提交
652

V
vit9696 已提交
653 654 655 656 657 658 659 660
\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.

661 662 663 664 665 666 667 668
\subsection{Coding conventions}\label{configuration-conv}

Just like any other project we have conventions that we follow during the development.
All third-party contributors are highly recommended to read and follow the conventions
listed below before submitting their patches. In general it is also recommended to firstly
discuss the issue in \href{https://github.com/acidanthera/bugtracker}{Acidanthera Bugtracker}
before sending the patch to ensure no double work and to avoid your patch being rejected.

V
vit9696 已提交
669 670
\textbf{Organisation}. The codebase is contained in \texttt{OpenCorePkg} repository,
which is the primary EDK II package.
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
\begin{itemize}
\tightlist
\item Whenever changes are required in multiple repositories, separate pull requests should
be sent to each.
\item Committing the changes should happen firstly to dependent repositories, secondly to
primary repositories to avoid automatic build errors.
\item Each unique commit should compile with \texttt{XCODE5} and preferably with other
toolchains. In the majority of the cases it can be checked by accessing the
\href{https://travis-ci.com/acidanthera}{CI interface}. Ensuring that static analysis finds
no warnings is preferred.
\item External pull requests and tagged commits must be validated. That said, commits in
master may build but may not necessarily work.
\item Internal branches should be named as follows: \texttt{author-name-date}, e.g.
\texttt{vit9696-ballooning-20191026}.
\item Commit messages should be prefixed with the primary module (e.g. library or code module) the
changes were made in. For example, \texttt{OcGuardLib: Add OC\_ALIGNED macro}. For non-library changes
\texttt{Docs} or \texttt{Build} prefixes are used.
\end{itemize}

\textbf{Design}. The codebase is written in a subset of freestanding C11 (C17) supported by
most modern toolchains used by EDK II. Applying common software development practices or requesting
clarification is recommended if any particular case is not discussed below.
\begin{itemize}
\tightlist
\item Never rely on undefined behaviour and try to avoid implementation defined behaviour unless
explicitly covered below (feel free to create an issue when a relevant case is not present).
\item Use \texttt{OcGuardLib} to ensure safe integral arithmetics avoiding overflows. Unsigned
wraparound should be relied on with care and reduced to the necessary amount.
\item Check pointers for correct alignment with \texttt{OcGuardLib} and do not rely on the architecture
being able to dereference unaligned pointers.
\item Use flexible array members instead of zero-length or one-length arrays where necessary.
\item Use static assertions (\texttt{STATIC\_ASSERT}) for type and value assumptions, and runtime
assertions (\texttt{ASSERT}) for precondition and invariant sanity checking. Do not use runtime
assertions to check for errors as they should never alter control flow and potentially be excluded.
\item Assume \texttt{UINT32}/\texttt{INT32} to be \texttt{int}-sized and use \texttt{\%u},
\texttt{\%d}, and \texttt{\%x} to print them.
\item Assume \texttt{UINTN}/\texttt{INTN} to be of unspecified size, and cast them to
\texttt{UINT64}/\texttt{INT64} for printing with \texttt{\%Lu}, \texttt{\%Ld} and so on as normal.
\item Do not rely on integer promotions for numeric literals. Use explicit casts when the type is
implementation-dependent or suffixes when type size is known. Assume \texttt{U} for \texttt{UINT32}
and \texttt{ULL} for \texttt{UINT64}.
\item Do ensure unsigned arithmetics especially in bitwise maths, shifts in particular.
\item \texttt{sizeof} operator should take variables instead of types where possible to be error prone.
Use \texttt{ARRAY\_SIZE} to obtain array size in elements. Use \texttt{L\_STR\_LEN} and
\texttt{L\_STR\_SIZE} macros from \texttt{OcStringLib} to obtain string literal sizes to ensure compiler
optimisation.
\item Do not use \texttt{goto} keyword. Prefer early \texttt{return}, \texttt{break}, or \texttt{continue}
after failing to pass error checking instead of nesting conditionals.
\item Use \texttt{EFIAPI}, force UEFI calling convention, only in protocols, external callbacks between
modules, and functions with variadic arguments.
\item Provide inline documentation to every added function, at least describing its inputs, outputs,
precondition, postcondition, and giving a brief description.
\item Do not use \texttt{RETURN\_STATUS}. Assume \texttt{EFI\_STATUS} to be a matching superset that is
to be always used when \texttt{BOOLEAN} is not enough.
\item Security violations should halt the system or cause a forced reboot.
\end{itemize}

\textbf{Codestyle}. The codebase follows
\href{https://github.com/tianocore/tianocore.github.io/wiki/Code-Style-C}{EDK II codestyle} with few changes
and clarifications.
\begin{itemize}
\tightlist
\item Write inline documentation for the functions and variables only once: in headers, where a header prototype
is available, and inline for \texttt{static} variables and functions.
\item Use line length of 120 characters or less, preferably 100 characters.
\item Use spaces after casts, e.g. \texttt{(VOID *)(UINTN) Variable}.
\item Use SPDX license headers as shown in
\href{https://github.com/acidanthera/bugtracker/issues/483}{acidanthera/bugtracker\#483}.
\end{itemize}

V
vit9696 已提交
741 742 743
\subsection{Debugging}\label{configuration-debug}

The codebase incorporates EDK II debugging and few custom features to improve the experience.
744 745 746 747 748 749 750 751 752
\begin{itemize}
\tightlist
\item Use module prefixes, 2-5 letters followed by a colon (\texttt{:}), for debug messages. For \texttt{OpenCorePkg}
use \texttt{OC:}, for libraries and drivers use their own unique prefixes.
\item Do not use dots (\texttt{.}) in the end of debug messages and separate \texttt{EFI\_STATUS}, printed by
\texttt{\%r}, with a hyphen (e.g. \texttt{OCRAM: Allocation of \%u bytes failed - \%r\textbackslash n}).
\item Use \texttt{DEBUG\_CODE\_BEGIN ()} and \texttt{DEBUG\_CODE\_END ()} constructions to guard debug checks
that may potentially reduce the performance of release builds and are otherwise unnecessary.
\item Use \texttt{DEBUG} macro to print debug messages during normal functioning, and \texttt{RUNTIME\_DEBUG} for
753
debugging after \texttt{EXIT\_BOOT\_SERVICES}.
754 755 756 757 758 759 760 761 762
\item Use \texttt{DEBUG\_VERBOSE} debug level to leave debug messages for future debugging of the code, which
are currently not necessary. By default \texttt{DEBUG\_VERBOSE} messages are ignored even in \texttt{DEBUG} builds.
\item Use \texttt{DEBUG\_INFO} debug level for all non critical messages (including errors) and \texttt{DEBUG\_BULK\_INFO}
for extensive messages that should not appear in NVRAM log that is heavily limited in size. These messages are ignored in
\texttt{RELEASE} builds.
\item Use \texttt{DEBUG\_ERROR} to print critical human visible messages that may potentially halt the boot process, and
\texttt{DEBUG\_WARN} for all other human visible errors, \texttt{RELEASE} builds included.
\end{itemize}

V
vit9696 已提交
763 764 765
When trying to find the problematic change it is useful to rely on
\href{https://git-scm.com/docs/git-bisect}{\texttt{git-bisect}} functionality.

V
vit9696 已提交
766 767 768 769 770 771 772 773
\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})
774
and various methods (e.g. \texttt{\_DSM}, \texttt{\_PRW}) for implementation.
V
vit9696 已提交
775 776 777
Modern hardware needs little changes to maintain ACPI compatibility, yet
some of those are provided as a part of OpenCore.

V
vit9696 已提交
778 779 780 781
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 已提交
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801
ACPI changes apply globally (to every operating system) with the following effective order:

\begin{itemize}
\tightlist
\item \texttt{Patch} is processed.
\item \texttt{Delete} is processed.
\item \texttt{Add} is processed.
\item \texttt{Quirks} are processed.
\end{itemize}

Applying the changes globally resolves the problems of incorrect operating system
detection, which is not possible before the operating system boots according to
the ACPI specification, operating system chainloading, and harder ACPI debugging.
For this reason it may be required to carefully use \texttt{\_OSI} method when
writing the changes.

Applying the patches early makes it possible to write so called ``proxy'' patches,
where the original method is patched in the original table and is implemented in
the patched table.

V
vit9696 已提交
802 803 804 805 806 807 808 809 810 811 812 813 814 815
There are many places providing ACPI tables and workarounds. Commonly used
ACPI tables are provided with OpenCore, VirtualSMC, VoodooPS2, and WhateverGreen
releases. Besides those there are several third-party instructions commonly found
on AppleLife in \href{https://applelife.ru/forums/xakintosh.67}{Laboratory}
and \href{https://applelife.ru/forums/dsdt.129}{DSDT} subforums
(e.g. \href{https://applelife.ru/posts/498967}{Battery register splitting} guide).
A slightly more user-friendly explanation of some tables included with OpenCore
can also be found in \href{https://dortania.github.io}{Dortania}'s
\href{https://dortania.github.io/Getting-Started-With-ACPI}{Getting started with ACPI} guide.
For more exotic cases there also are several other places including
\href{https://github.com/daliansky}{daliansky}'s
\href{https://github.com/daliansky/OC-little}{ACPI sample collection}, but the quality
of the suggested solutions will vary from case to case.

V
vit9696 已提交
816 817 818 819 820 821
\subsection{Properties}\label{acpiprops}

\begin{enumerate}
\item
  \texttt{Add}\\
  \textbf{Type}: \texttt{plist\ array}\\
822
  \textbf{Failsafe}: Empty\\
823
  \textbf{Description}: Load selected tables from \texttt{OC/ACPI}
V
vit9696 已提交
824 825
  directory.

826
  Designed to be filled with \texttt{plist\ dict} values, describing each add entry.
827
  See \hyperref[acpipropsadd]{Add Properties} section below.
V
vit9696 已提交
828 829

\item
830
  \texttt{Delete}\\
V
vit9696 已提交
831
  \textbf{Type}: \texttt{plist\ array}\\
832
  \textbf{Failsafe}: Empty\\
V
vit9696 已提交
833 834
  \textbf{Description}: Remove selected tables from ACPI stack.

835 836
  Designed to be filled with \texttt{plist\ dict} values, describing each delete entry.
  See \hyperref[acpipropsdelete]{Delete Properties} section below.
V
vit9696 已提交
837 838 839 840

\item
  \texttt{Patch}\\
  \textbf{Type}: \texttt{plist\ array}\\
841
  \textbf{Failsafe}: Empty\\
842 843
  \textbf{Description}: Perform binary patches in ACPI tables before
  table addition or removal.
V
vit9696 已提交
844 845 846 847 848 849 850 851 852 853 854 855

  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}

856 857 858 859 860 861
\subsection{Add Properties}\label{acpipropsadd}

\begin{enumerate}
\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
862
  \textbf{Failsafe}: Empty string\\
863 864 865 866 867 868 869
  \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}\\
870
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
871
  \textbf{Description}: This ACPI table will not be added unless set to
872 873 874 875 876
  \texttt{true}.

\item
  \texttt{Path}\\
  \textbf{Type}: \texttt{plist\ string}\\
877
  \textbf{Failsafe}: Empty string\\
878 879 880 881 882
  \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
883
  load from \texttt{OC/ACPI} directory.
884 885 886 887 888 889 890

  \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}

891
\subsection{Delete Properties}\label{acpipropsdelete}
V
vit9696 已提交
892 893

\begin{enumerate}
894 895 896
\item
  \texttt{All}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
897
  \textbf{Failsafe}: \texttt{false}\\
898
  \textbf{Description}: If set to \texttt{true}, all ACPI tables matching the
899
  condition will be deleted. Otherwise only first matched table.
900

V
vit9696 已提交
901 902 903
\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
904
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
905 906 907 908 909 910 911
  \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}\\
912
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
913 914 915 916 917 918
  \textbf{Description}: This ACPI table will not be removed unless set to
  \texttt{true}.

\item
  \texttt{OemTableId}\\
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
919
  \textbf{Failsafe}: All zero\\
V
vit9696 已提交
920 921 922 923
  \textbf{Description}: Match table OEM ID to be equal to this value
  unless all zero.

\item
924
  \texttt{TableLength}\\
V
vit9696 已提交
925
  \textbf{Type}: \texttt{plist\ integer}\\
926
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
927 928 929
  \textbf{Description}: Match table size to be equal to this value
  unless \texttt{0}.

930 931 932
\item
  \texttt{TableSignature}\\
  \textbf{Type}: \texttt{plist\ data}, 4 bytes\\
933
  \textbf{Failsafe}: All zero\\
934 935 936
  \textbf{Description}: Match table signature to be equal to this value
  unless all zero.

937 938 939 940
  \emph{Note}: Make sure not to specify table signature when the sequence
  needs to be replaced in multiple places. Especially when performing
  different kinds of renames.

V
vit9696 已提交
941 942 943 944 945 946 947 948 949
\end{enumerate}

\subsection{Patch Properties}\label{acpipropspatch}

\begin{enumerate}

\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
950
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
951 952 953 954 955 956 957
  \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}\\
958
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
959 960 961 962 963 964
  \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}\\
965
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
966 967 968 969 970 971
  \textbf{Description}: This ACPI patch will not be used unless set to
  \texttt{true}.

\item
  \texttt{Find}\\
  \textbf{Type}: \texttt{plist\ data}\\
972
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
973 974 975 976 977
  \textbf{Description}: Data to find. Must equal to \texttt{Replace} in size.

\item
  \texttt{Limit}\\
  \textbf{Type}: \texttt{plist\ integer}\\
978
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
979 980 981 982 983 984
  \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}\\
985
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
986 987 988 989 990 991 992 993
  \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\\
994
  \textbf{Failsafe}: All zero\\
V
vit9696 已提交
995 996 997 998 999 1000
  \textbf{Description}: Match table OEM ID to be equal to this value
  unless all zero.

\item
  \texttt{Replace}\\
  \textbf{Type}: \texttt{plist\ data}\\
1001
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
1002 1003 1004 1005 1006
  \textbf{Description}: Replacement data of one or more bytes.

\item
  \texttt{ReplaceMask}\\
  \textbf{Type}: \texttt{plist\ data}\\
1007
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
1008 1009 1010 1011 1012 1013 1014 1015
  \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}\\
1016
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
1017 1018 1019 1020 1021 1022
  \textbf{Description}: Number of found occurrences to be skipped before replacement
  is done.

\item
  \texttt{TableLength}\\
  \textbf{Type}: \texttt{plist\ integer}\\
1023
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
1024 1025 1026 1027 1028
  \textbf{Description}: Match table size to be equal to this value
  unless \texttt{0}.

\item
  \texttt{TableSignature}\\
V
vit9696 已提交
1029
  \textbf{Type}: \texttt{plist\ data}, 4 bytes\\
1030
  \textbf{Failsafe}: All zero\\
V
vit9696 已提交
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052
  \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
1053
  Try to avoid hacky changes like renaming \texttt{\_PRW} or \texttt{\_DSM}
V
vit9696 已提交
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
  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}

1072
Tianocore \href{https://github.com/acidanthera/audk/blob/master/MdePkg/Include/IndustryStandard/AcpiAml.h}{AcpiAml.h}
V
vit9696 已提交
1073 1074
source file may help understanding ACPI opcodes.

V
vit9696 已提交
1075 1076
\emph{Note}: Patches of different \texttt{Find} and \texttt{Replace} lengths
are unsupported as they may corrupt ACPI tables and make you system unstable
A
Andrey1970AppleLife 已提交
1077
due to area relocation. If you need such changes you may utilise ``proxy''
V
vit9696 已提交
1078 1079
patching or \texttt{NOP} the remaining area.

V
vit9696 已提交
1080 1081 1082 1083 1084 1085 1086
\subsection{Quirks Properties}\label{acpipropsquirks}

\begin{enumerate}

\item
  \texttt{FadtEnableReset}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1087
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1088
  \textbf{Description}: Provide reset register and flag in FADT table to enable
V
vit9696 已提交
1089 1090 1091 1092
  reboot and shutdown.

  Mainly required on legacy hardware and few laptops. Can also fix power-button
  shortcuts. Not recommended unless required.
V
vit9696 已提交
1093 1094 1095 1096

\item
  \texttt{NormalizeHeaders}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1097
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1098 1099 1100 1101 1102 1103 1104 1105 1106
  \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}\\
1107
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132
  \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.

1133 1134 1135
\item
  \texttt{ResetHwSig}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1136
  \textbf{Failsafe}: \texttt{false}\\
1137 1138 1139 1140 1141 1142
  \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.

1143 1144 1145
\item
  \texttt{ResetLogoStatus}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
1146
  \textbf{Failsafe}: \texttt{false}\\
1147 1148 1149 1150 1151 1152
  \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 已提交
1153 1154 1155
\end{enumerate}


1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
\section{Booter}\label{booter}

\subsection{Introduction}\label{booterintro}

This section allows to apply different kinds of UEFI modifications on
Apple bootloader (\texttt{boot.efi}). The modifications currently provide
various patches and environment alterations for different firmwares. Some
of these features were originally implemented as a part of
\href{https://github.com/acidanthera/AptioFixPkg}{\text{AptioMemoryFix.efi}},
which is no longer maintained. See \hyperref[troubleshootingtricks]{Tips and Tricks}
section for migration steps.

1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181
If you are using this for the first time on a customised firmware, there is a
list of checks to do first. Prior to starting please ensure that you have:

\begin{itemize}
\tightlist
\item Most up-to-date UEFI firmware (check your motherboard vendor website).
\item \texttt{Fast Boot} and \texttt{Hardware Fast Boot} disabled in firmware
  settings if present.
\item \texttt{Above 4G Decoding} or similar enabled in firmware
  settings if present. Note, that on some motherboards (notably ASUS WS-X299-PRO) this
  option causes adverse effects, and must be disabled. While no other motherboards
  with the same issue are known, consider this option to be first to check if you
  have erratic boot failures.
\item \texttt{DisableIoMapper} quirk enabled, or \texttt{VT-d} disabled in
1182
  firmware settings if present, or ACPI DMAR table deleted.
1183 1184 1185 1186
\item \textbf{No} `slide` boot argument present in NVRAM or anywhere else.
  It is not necessary unless you cannot boot at all or see
  \texttt{No slide values are usable! Use custom slide!} message in the log.
\item \texttt{CFG Lock} (MSR \texttt{0xE2} write protection) disabled in
A
Andrey1970AppleLife 已提交
1187
  firmware settings if present. Consider
1188 1189
\href{https://github.com/LongSoft/UEFITool/blob/master/UEFIPatch/patches.txt}{patching it}
  if you have enough skills and no option is available. See
A
Andrey1970AppleLife 已提交
1190 1191
\hyperref[kernelpropsquirks]{VerifyMsrE2}
  notes for more details.
1192 1193
\item \texttt{CSM} (Compatibility Support Module) disabled in firmware settings
  if present. You may need to flash GOP ROM on NVIDIA 6xx/AMD 2xx or older. Use
1194 1195
  \href{https://www.win-raid.com/t892f16-AMD-and-Nvidia-GOP-update-No-requests-DIY.html}{GopUpdate}
  (see the second post) or \href{http://www.insanelymac.com/forum/topic/299614-asus-eah6450-video-bios-uefi-gop-upgrade-and-gop-uefi-binary-in-efi-for-many-ati-cards/page-1#entry2042163}{AMD UEFI GOP MAKER}
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217
  in case you are not sure how.
\item \texttt{EHCI/XHCI Hand-off} enabled in firmware settings \texttt{only} if boot
  stalls unless USB devices are disconnected.
\item \texttt{VT-x}, \texttt{Hyper Threading}, \texttt{Execute Disable Bit} enabled
  in firmware settings if present.
\item While it may not be required, sometimes you have to disable
  \texttt{Thunderbolt support}, \texttt{Intel SGX}, and \texttt{Intel Platform Trust}
  in firmware settings present.
\end{itemize}

When debugging sleep issues you may want to (temporarily) disable Power Nap and
automatic power off, which appear to sometimes cause wake to black screen or boot loop
issues on older platforms. The particular issues may vary, but in general you should
check ACPI tables first. Here is an example of a bug found in some
\href{http://www.insanelymac.com/forum/topic/329624-need-cmos-reset-after-sleep-only-after-login/#entry2534645}{Z68 motherboards}.
To turn Power Nap and the others off run the following commands in Terminal:
\begin{lstlisting}[label=powernap, style=ocbash]
sudo pmset autopoweroff 0
sudo pmset powernap 0
sudo pmset standby 0
\end{lstlisting}

1218
\emph{Note}: These settings may reset at hardware change and in certain other circumstances.
1219 1220
To view their current state use \texttt{pmset -g} command in Terminal.

1221 1222 1223 1224
\subsection{Properties}\label{booterprops}

\begin{enumerate}

V
vit9696 已提交
1225 1226 1227 1228 1229 1230 1231 1232
\item
  \texttt{MmioWhitelist}\\
  \textbf{Type}: \texttt{plist\ array}\\
  \textbf{Description}: Designed to be filled with \texttt{plist\ dict} values,
  describing addresses critical for particular firmware functioning when
  \texttt{DevirtualiseMmio} quirk is in use. See \hyperref[booterpropsmmio]{MmioWhitelist Properties}
  section below.

1233 1234 1235 1236 1237 1238 1239 1240
\item
  \texttt{Quirks}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Apply individual booter quirks described
  in \hyperref[booterpropsquirks]{Quirks Properties} section below.

\end{enumerate}

V
vit9696 已提交
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273
\subsection{MmioWhitelist Properties}\label{booterpropsmmio}

\begin{enumerate}

\item
  \texttt{Address}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Exceptional MMIO address, which memory descriptor should be left
  virtualised (unchanged) by \texttt{DevirtualiseMmio}. This means that the firmware will
  be able to directly communicate with this memory region during operating system functioning,
  because the region this value is in will be assigned a virtual address.

  The addresses written here must be part of the memory map, have \texttt{EfiMemoryMappedIO}
  type and \texttt{EFI\_MEMORY\_RUNTIME} attribute (highest bit) set. To find the list of the
  candidates the debug log can be used.

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

\item
  \texttt{Enabled}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: This address will be devirtualised unless set to \texttt{true}.

\end{enumerate}

1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287
\subsection{Quirks Properties}\label{booterpropsquirks}

\begin{enumerate}

\item
  \texttt{AvoidRuntimeDefrag}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Protect from boot.efi runtime memory defragmentation.

  This option fixes UEFI runtime services (date, time, NVRAM, power control, etc.)
  support on many firmwares using SMM backing for select services like variable
  storage. SMM may try to access physical addresses, but they get moved by boot.efi.

1288
  \emph{Note}: Most but Apple and VMware firmwares need this quirk.
1289

1290 1291 1292 1293 1294 1295 1296 1297 1298
\item
  \texttt{DevirtualiseMmio}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Remove runtime attribute from select MMIO regions.

  This option reduces stolen memory footprint from the memory map by removing
  runtime bit for known memory regions. This quirk may result in the increase
  of KASLR slides available, but is not necessarily compatible with the target
V
vit9696 已提交
1299 1300 1301 1302
  board without additional measures. In general this frees from 64 to 256
  megabytes of memory (present in the debug log), and on some platforms it
  is the only way to boot macOS, which otherwise fails with allocation
  error at bootloader stage.
V
vit9696 已提交
1303 1304 1305 1306 1307

  This option is generally useful on all firmwares except some very old ones,
  like Sandy Bridge. On select firmwares it may require a list of exceptional
  addresses that still need to get their virtual addresses for proper NVRAM and
  hibernation functioning. Use \texttt{MmioWhitelist} section to do this.
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320

\item
  \texttt{DisableSingleUser}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Disable single user mode.

  This is a security option allowing one to restrict single user mode usage
  by ignoring \texttt{CMD+S} hotkey and \texttt{-s} boot argument. The
  behaviour with this quirk enabled is supposed to match T2-based model
  behaviour. Read \href{https://support.apple.com/HT201573}{this article}
  to understand how to use single user mode with this quirk enabled.

1321 1322 1323 1324 1325 1326 1327 1328
\item
  \texttt{DisableVariableWrite}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Protect from macOS NVRAM write access.

  This is a security option allowing one to restrict NVRAM access in macOS.
  This quirk requires \texttt{OC\_FIRMWARE\_RUNTIME} protocol implemented
V
vit9696 已提交
1329
  in \texttt{OpenRuntime.efi}.
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346

  \emph{Note}: This quirk can also be used as an ugly workaround to buggy UEFI
  runtime services implementations that fail to write variables to NVRAM and
  break the rest of the operating system.

\item
  \texttt{DiscardHibernateMap}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reuse original hibernate memory map.

  This option forces XNU kernel to ignore newly supplied memory map and assume
  that it did not change after waking from hibernation. This behaviour is required
  to work by Windows, which mandates to
  \href{https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/oem-uefi#hibernation-state-s4-transition-requirements}{preserve}
  runtime memory size and location after S4 wake.

1347 1348 1349 1350
  \emph{Note}: This may be used to workaround buggy memory maps on older hardware,
  and is now considered rare legacy. Examples of such hardware are Ivy Bridge laptops
  with Insyde firmware, like Acer V3-571G. Do not use this unless you fully understand
  the consequences.
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376

\item
  \texttt{EnableSafeModeSlide}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Patch bootloader to have KASLR enabled in safe mode.

  This option is relevant to the users that have issues booting to safe mode
  (e.g. by holding \texttt{shift} or using \texttt{-x} boot argument). By default
  safe mode forces \texttt{0} slide as if the system was launched with \texttt{slide=0}
  boot argument. This quirk tries to patch \texttt{boot.efi} to lift that limitation
  and let some other value (from \texttt{1} to \texttt{255}) be used. This quirk requires
  \texttt{ProvideCustomSlide} to be enabled.

  \emph{Note}: The necessity of this quirk is determined by safe mode availability. If
  booting to safe mode fails, this option can be tried to be enabled.

\item
  \texttt{EnableWriteUnprotector}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Permit write access to UEFI runtime services code.

  This option bypasses \texttt{R\^X} permissions in code pages of UEFI runtime
  services by removing write protection (\texttt{WP}) bit from \texttt{CR0}
  register during their execution. This quirk requires \texttt{OC\_FIRMWARE\_RUNTIME}
V
vit9696 已提交
1377
  protocol implemented in \texttt{OpenRuntime.efi}.
1378

1379
  \emph{Note}: This quirk may potentially weaken firmware security, please use
1380
  \texttt{RebuildAppleMemoryMap} if your firmware supports memory attributes table (MAT).
1381
  Refer to \texttt{OCABC: MAT support is 1/0} log entry to determine whether MAT is supported.
1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395

\item
  \texttt{ForceExitBootServices}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Retry \texttt{ExitBootServices} with new memory map on failure.

  Try to ensure that \texttt{ExitBootServices} call succeeds even with outdated MemoryMap
  key argument by obtaining current memory map and retrying \texttt{ExitBootServices} call.

  \emph{Note}: The necessity of this quirk is determined by early boot crashes
  of the firmware. Do not use this unless you fully understand the consequences.

\item
1396
  \texttt{ProtectMemoryRegions}\\
1397 1398
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
1399
  \textbf{Description}: Protect memory regions from incorrect access.
1400

1401
  Some firmwares incorrectly map select memory regions:
1402

1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416
  \begin{itemize}
    \tightlist
    \item CSM region can be marked as boot services code or data, which
      leaves it as free memory for XNU kernel.
    \item MMIO regions can be marked as reserved memory and stay unmapped,
      but may be required to be accessible at runtime for NVRAM support.
  \end{itemize}

  This quirk attempts to fix types of these regions, e.g. ACPI NVS for
  CSM or MMIO for MMIO.

  \emph{Note}: The necessity of this quirk is determined by artifacts, sleep
  wake issues, and boot failures. In general only very old firmwares need
  this quirk.
1417

1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429
\item
  \texttt{ProtectSecureBoot}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Protect UEFI Secure Boot variables from being written.

  Reports security violation during attempts to write to \texttt{db}, \texttt{dbx},
  \texttt{PK}, and \texttt{KEK} variables from the operating system.

  \emph{Note}: This quirk mainly attempts to avoid issues with NVRAM implementations
  with problematic defragmentation, such as select Insyde or \texttt{MacPro5,1}.

1430 1431 1432 1433 1434 1435 1436 1437 1438
\item
  \texttt{ProtectUefiServices}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Protect UEFI services from being overridden by the firmware.

  Some modern firmwares including both hardware and virtual machines, like VMware,
  may update pointers to UEFI services during driver loading and related actions.
  Consequentially this directly breaks other quirks that affect memory management,
A
Andrey1970AppleLife 已提交
1439
  like \texttt{DevirtualiseMmio}, \texttt{ProtectMemoryRegions}, or \texttt{RebuildAppleMemoryMap},
1440 1441 1442 1443 1444
  and may also break other quirks depending on the effects of these.

  \emph{Note}: On VMware the need for this quirk may be diagnosed by ``Your Mac OS guest
  might run unreliably with more than one virtual core.'' message.

1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462
\item
  \texttt{ProvideCustomSlide}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Provide custom KASLR slide on low memory.

  This option performs memory map analysis of your firmware and checks whether
  all slides (from \texttt{1} to \texttt{255}) can be used. As \texttt{boot.efi}
  generates this value randomly with \texttt{rdrand} or pseudo randomly \texttt{rdtsc},
  there is a chance of boot failure when it chooses a conflicting slide. In case
  potential conflicts exist, this option forces macOS to use a pseudo random value
  among the available ones. This also ensures that \texttt{slide=} argument is never
  passed to the operating system for security reasons.

  \emph{Note}: The necessity of this quirk is determined by \texttt{OCABC: Only N/256
  slide values are usable!} message in the debug log. If the message is present,
  this option is to be enabled.

1463 1464 1465 1466 1467 1468
\item
  \texttt{ProvideMaxSlide}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Provide maximum KASLR slide when higher ones are unavailable.

A
Andrey1970AppleLife 已提交
1469
  This option overrides the maximum slide of 255 by a user specified value between 1 and 254 inclusive
1470
  when \texttt{ProvideCustomSlide} is enabled.
A
Andrey1970AppleLife 已提交
1471
  It is believed that modern firmwares allocate pool memory from top to bottom, effectively resulting in
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482
  free memory at the time of slide scanning being later used as temporary
  memory during kernel loading. In case those memory are unavailable, this
  option can stop evaluating higher slides.

  \emph{Note}: The necessity of this quirk is determined by random boot failure
  when \texttt{ProvideCustomSlide} is enabled and the randomized slide fall
  into the unavailable range. When \texttt{AppleDebug} is enabled, usually the
  debug log may contain messages like \texttt{AAPL: [EB|`LD:LKC] \} Err(0x9)}.
  To find the optimal value, manually append \texttt{slide=X} to \texttt{boot-args}
  and log the largest one that won't cause boot failure.

1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508
\item
  \texttt{RebuildAppleMemoryMap}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Generate Memory Map compatible with macOS.

  Apple kernel has several limitations in parsing UEFI memory map:

  \begin{itemize}
  \tightlist
  \item Memory map size must not exceed 4096 bytes as Apple kernel maps
    it as a single 4K page. Since some firmwares have very large memory maps
    (approximately over 100 entries) Apple kernel will crash at boot.
  \item Memory attributes table is ignored. \texttt{EfiRuntimeServicesCode}
    memory statically gets \texttt{RX} permissions, and all other memory types
    get \texttt{RW} permissions. Since some firmware drivers may write to global
    variables at runtime, Apple kernel will crash at calling UEFI runtime services,
    unless driver \texttt{.data} section has \texttt{EfiRuntimeServicesData}
    type.
  \end{itemize}

  To workaround these limitations this quirk applies memory attributes table
  permissions to memory map passed to Apple kernel and optionally attempts
  to unify contiguous slots of similar types if the resulting memory map exceeds
  4 KB.

1509 1510 1511 1512
  \emph{Note 1}: Since many firmwares come with incorrect memory protection
  table this quirk often comes in pair with \texttt{SyncRuntimePermissions}.

  \emph{Note 2}: The necessity of this quirk is determined by early boot failures.
1513
  This quirk replaces \texttt{EnableWriteUnprotector} on firmwares supporting
1514 1515 1516
  memory attributes table (MAT). This quirk is generally unnecessary when using
  \texttt{OpenDuetPkg}, but may be required to boot macOS 10.6 and earlier for
  unclear reasons.
1517

1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528
\item
  \texttt{SetupVirtualMap}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Setup virtual memory at \texttt{SetVirtualAddresses}.

  Select firmwares access memory by virtual addresses after \texttt{SetVirtualAddresses}
  call, which results in early boot crashes. This quirk workarounds the problem by
  performing early boot identity mapping of assigned virtual addresses to physical
  memory.

1529 1530 1531
  \emph{Note}: The necessity of this quirk is determined by early boot failures. Currently
  new firmwares with memory protection support (like OVMF) do not support this quirk due to
  \href{https://github.com/acidanthera/bugtracker/issues/719}{acidanthera/bugtracker\#719}.
1532

1533 1534 1535 1536 1537 1538 1539 1540 1541 1542
\item
  \texttt{SignalAppleOS}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Report macOS being loaded through OS Info for any OS.

  This quirk is useful on Mac firmwares, which behave differently in different OS.
  For example, it is supposed to enable Intel GPU in Windows and Linux in some
  dual-GPU MacBook models.

1543 1544 1545 1546
\item
  \texttt{SyncRuntimePermissions}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
1547
  \textbf{Description}: Update memory permissions for runtime environment.
1548

1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560
  Some firmwares either fail to properly handle runtime permissions:
  \begin{itemize}
    \tightlist
    \item They incorrectly mark \texttt{OpenRuntime} as not executable in the memory map.
    \item They incorrectly mark \texttt{OpenRuntime} as not executable in the memory
    attributes table.
    \item They lose entries from the memory attributes table after \texttt{OpenRuntime}
    is loaded.
    \item They mark items in the memory attributes table as read-write-execute.
  \end{itemize}

  This quirk tries to update memory map and memory attributes table to correct this.
1561 1562 1563 1564

  \emph{Note}: The necessity of this quirk is determined by early boot failures either in
  macOS or in Linux/Windows. In general only firmwares released in 2018 or later are affected.

1565 1566
\end{enumerate}

V
vit9696 已提交
1567 1568 1569 1570 1571
\section{DeviceProperties}\label{devprops}

\subsection{Introduction}\label{devpropsintro}

Device configuration is provided to macOS with a dedicated buffer,
A
Andrey1970AppleLife 已提交
1572
called \texttt{EfiDevicePathPropertyDatabase}. This buffer is a serialised
V
vit9696 已提交
1573 1574
map of DevicePaths to a map of property names and their values.

V
vit9696 已提交
1575 1576 1577 1578 1579 1580 1581 1582 1583 1584
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}

1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620
Device propertties are part of the \texttt{IODeviceTree} (\texttt{gIODT})
plane of macOS I/O Registry. This plane has several construction stages
relevant for the platform initialisation. While the early construction
stage is performed by the XNU kernel in the \texttt{IODeviceTreeAlloc}
method, the majority of the construction is performed by the platform expert,
implemented in \texttt{AppleACPIPlatformExpert.kext}.

AppleACPIPlatformExpert incorporates two stages of \texttt{IODeviceTree}
construction implemented by calling \\
\texttt{AppleACPIPlatformExpert::mergeDeviceProperties}:

\begin{enumerate}
  \tightlist
  \item During ACPI table initialisation through the recursive ACPI namespace scanning
  by the calls to \\
  \texttt{AppleACPIPlatformExpert::createDTNubs}.
  \item During IOService registration (\texttt{IOServices::registerService}) callbacks
  implemented as a part of \\
  \texttt{AppleACPIPlatformExpert::platformAdjustService}
  function and its private worker method \\
  \texttt{AppleACPIPlatformExpert::platformAdjustPCIDevice}
  specific to the PCI devices.
\end{enumerate}

The application of the stages depends on the device presence in ACPI tables.
The first stage applies very early but exclusively to the devices present in ACPI tables.
The second stage applies to all devices much later after the PCI configuration
and may repeat the first stage if the device was not present in ACPI.

For all kernel drivers, which may inspect the \texttt{IODeviceTree} plane without
probing (e.g. \texttt{Lilu} and its plugins like \texttt{WhateverGreen}) it is particularly
important to ensure device presence in the ACPI tables. Failing to do so may result
\textbf{in all kinds of erratic behaviour} caused by ignoring the injected device properties
as they were not constructed at the first stage. See \texttt{SSDT-IMEI.dsl} and
\texttt{SSDT-BRG0.dsl} for an example.

V
vit9696 已提交
1621 1622 1623 1624 1625 1626 1627 1628 1629 1630
\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
1631
  be set if not present and not deleted.
V
vit9696 已提交
1632 1633

  \emph{Note}: Currently properties may only be (formerly) added by the original driver,
1634
  so unless a separate driver was installed, there is no reason to delete the variables.
V
vit9696 已提交
1635 1636

\item
1637
  \texttt{Delete}\\
V
vit9696 已提交
1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 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 1686 1687 1688 1689 1690
  \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}\\
1691
  \textbf{Failsafe}: Empty\\
V
vit9696 已提交
1692 1693 1694
  \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 已提交
1695 1696 1697
  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 已提交
1698

V
vit9696 已提交
1699 1700 1701 1702 1703 1704 1705
  To track the dependency order one can inspect the \texttt{OSBundleLibraries} key
  in the \texttt{Info.plist} of the kext. Any kext mentioned in the
  \texttt{OSBundleLibraries} of the other kext must be precede this kext.

  \emph{Note}: Kexts may have inner kexts (\texttt{Plug-Ins}) in their bundle. Each
  inner kext must be added separately.

V
vit9696 已提交
1706 1707 1708
\item
  \texttt{Block}\\
  \textbf{Type}: \texttt{plist\ array}\\
1709
  \textbf{Failsafe}: Empty\\
V
vit9696 已提交
1710 1711 1712 1713 1714
  \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.

1715 1716 1717 1718 1719 1720
\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 已提交
1721 1722 1723
\item
  \texttt{Patch}\\
  \textbf{Type}: \texttt{plist\ array}\\
1724
  \textbf{Failsafe}: Empty\\
V
vit9696 已提交
1725
  \textbf{Description}: Perform binary patches in kernel and drivers prior to
1726
  driver addition and removal.
V
vit9696 已提交
1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742

  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
1743
  \texttt{BundlePath}\\
V
vit9696 已提交
1744
  \textbf{Type}: \texttt{plist\ string}\\
1745
  \textbf{Failsafe}: Empty string\\
1746 1747
  \textbf{Description}: Kext bundle path (e.g. \texttt{Lilu.kext}
  or \texttt{MyKext.kext/Contents/PlugIns/MySubKext.kext}).
V
vit9696 已提交
1748 1749 1750 1751

\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
1752
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1753 1754 1755 1756 1757 1758 1759
  \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}\\
1760
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1761 1762 1763 1764 1765 1766
  \textbf{Description}: This kernel driver will not be added unless set to
  \texttt{true}.

\item
  \texttt{ExecutablePath}\\
  \textbf{Type}: \texttt{plist\ string}\\
1767
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1768 1769 1770 1771
  \textbf{Description}: Kext executable path relative to bundle
  (e.g. \texttt{Contents/MacOS/Lilu}).

\item
1772
  \texttt{MaxKernel}\\
V
vit9696 已提交
1773
  \textbf{Type}: \texttt{plist\ string}\\
1774
  \textbf{Failsafe}: Empty string\\
1775 1776
  \textbf{Description}: Adds kernel driver on specified macOS version or older.

V
vit9696 已提交
1777 1778 1779
  \hypertarget{kernmatch}Kernel version can be obtained with \texttt{uname -r} command,
  and should look like 3 numbers separated by dots, for example \texttt{18.7.0} is the
  kernel version for \texttt{10.14.6}. Kernel version interpretation is implemented as follows:
1780 1781
  \begin{align*}
    \begin{aligned}
M
Michael Belyaev 已提交
1782
      ParseDarwinVersion(\kappa,\lambda,\mu)&=\kappa \cdot10000 &&
1783
        \text{Where }\kappa\in(0,99)\text{ is kernel version major} \\
V
vit9696 已提交
1784
      &+ \lambda\cdot100 &&
1785
        \text{Where }\lambda\in(0,99)\text{ is kernel version minor} \\
V
vit9696 已提交
1786
      &+ \mu &&
1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820
        \text{Where }\mu\in(0,99)\text{ is kernel version patch}
    \end{aligned}
  \end{align*}
  Kernel version comparison is implemented as follows:
  \begin{align*}
    \alpha&=\begin{cases}
      \vspace{-0.5cm}\mbox{\hspace{8cm}} & \mbox{\hspace{5cm}} \\
      ParseDarwinVersion(\texttt{MinKernel}), & \text{If } \texttt{MinKernel} \text{ is valid} \\
      0 & Otherwise
    \end{cases} \\
    \beta&=\begin{cases}
      \vspace{-0.5cm}\mbox{\hspace{8cm}} & \mbox{\hspace{5cm}} \\
      ParseDarwinVersion(\texttt{MaxKernel}), & \text{If } \texttt{MaxKernel} \text{ is valid} \\
      \infty & Otherwise
    \end{cases} \\
    \gamma&=\begin{cases}
      \vspace{-0.5cm}\mbox{\hspace{8cm}} & \mbox{\hspace{5cm}} \\
      ParseDarwinVersion(FindDarwinVersion()), & \text{If valid } \texttt{"Darwin Kernel Version"} \text{ is found} \\
      \infty & Otherwise
    \end{cases} \\
    & \hspace{5cm} f(\alpha,\beta,\gamma)=\alpha\leq\gamma\leq\beta
  \end{align*}
  Here $ParseDarwinVersion$ argument is assumed to be 3 integers obtained by splitting Darwin kernel version
  string from left to right by the \texttt{.} symbol. $FindDarwinVersion$ function looks up
  Darwin kernel version by locating \texttt{"Darwin Kernel Version $\kappa$.$\lambda$.$\mu$"} string
  in the kernel image.

\item
  \texttt{MinKernel}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: Empty string\\
  \textbf{Description}: Adds kernel driver on specified macOS version or newer.

  \emph{Note}: Refer to \hyperlink{kernmatch}{\texttt{Add} \texttt{MaxKernel} description} for matching logic.
V
vit9696 已提交
1821 1822 1823 1824

\item
  \texttt{PlistPath}\\
  \textbf{Type}: \texttt{plist\ string}\\
1825
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836
  \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}\\
1837
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1838 1839 1840 1841 1842 1843 1844
  \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}\\
1845
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1846
  \textbf{Description}: This kernel driver will not be blocked unless set to
V
vit9696 已提交
1847 1848 1849 1850 1851
  \texttt{true}.

\item
  \texttt{Identifier}\\
  \textbf{Type}: \texttt{plist\ string}\\
1852
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1853 1854 1855 1856
  \textbf{Description}: Kext bundle identifier
    (e.g. \texttt{com.apple.driver.AppleTyMCEDriver}).

\item
1857 1858 1859 1860 1861 1862 1863 1864 1865
  \texttt{MaxKernel}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: Empty string\\
  \textbf{Description}: Blocks kernel driver on specified macOS version or older.

  \emph{Note}: Refer to \hyperlink{kernmatch}{\texttt{Add} \texttt{MaxKernel} description} for matching logic.

\item
  \texttt{MinKernel}\\
V
vit9696 已提交
1866
  \textbf{Type}: \texttt{plist\ string}\\
1867
  \textbf{Failsafe}: Empty string\\
1868 1869 1870
  \textbf{Description}: Blocks kernel driver on specified macOS version or newer.

  \emph{Note}: Refer to \hyperlink{kernmatch}{\texttt{Add} \texttt{MaxKernel} description} for matching logic.
V
vit9696 已提交
1871 1872 1873

\end{enumerate}

1874 1875 1876 1877 1878
\subsection{Emulate Properties}\label{kernelpropsemu}

\begin{enumerate}
\item
  \texttt{Cpuid1Data}\\
A
Andrey1970AppleLife 已提交
1879
  \textbf{Type}: \texttt{plist\ data}, 16 bytes\\
1880
  \textbf{Failsafe}: All zero\\
1881
  \textbf{Description}: Sequence of \texttt{EAX}, \texttt{EBX}, \texttt{ECX},
1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893
  \texttt{EDX} values to replace \texttt{CPUID (1)} call in XNU kernel.

  This property serves for two needs:

  \begin{itemize}
    \tightlist
    \item Enabling support of an unsupported CPU model.
    \item Enabling XCPM support for an unsupported CPU variant.
  \end{itemize}

  Normally it is only the value of \texttt{EAX} that needs to be taken care of,
  since it represents the full CPUID. The remaining bytes are to be left as zeroes.
V
vit9696 已提交
1894 1895
  Byte order is Little Endian, so for example, \texttt{C3 06 03 00} stands for CPUID
  \texttt{0x0306C3} (Haswell).
1896 1897 1898 1899 1900

  For XCPM support it is recommended to use the following combinations.

  \begin{itemize}
    \tightlist
V
vit9696 已提交
1901
    \item Haswell-E (\texttt{0x0306F2}) to Haswell (\texttt{0x0306C3}):\\
1902 1903 1904 1905 1906 1907 1908
    \texttt{Cpuid1Data}: \texttt{C3 06 03 00 00 00 00 00 00 00 00 00 00 00 00 00}\\
    \texttt{Cpuid1Mask}: \texttt{FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00}
    \item Broadwell-E (\texttt{0x0406F1}) to Broadwell (\texttt{0x0306D4}):\\
    \texttt{Cpuid1Data}: \texttt{D4 06 03 00 00 00 00 00 00 00 00 00 00 00 00 00}\\
    \texttt{Cpuid1Mask}: \texttt{FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00}
  \end{itemize}

V
vit9696 已提交
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919
  Keep in mind, that the following configurations are unsupported (at least out of the box):

  \begin{itemize}
    \tightlist
    \item Consumer Ivy Bridge (\texttt{0x0306A9}) as Apple disabled XCPM for Ivy Bridge
      and recommends legacy power management for these CPUs. You will need to manually
      patch \texttt{\_xcpm\_bootstrap} to force XCPM on these CPUs instead of using this option.
    \item Low-end CPUs (e.g. Haswell+ Pentium) as they are not supported properly by macOS.
      Legacy hacks for older models can be found in the \texttt{Special NOTES} section of
      \href{https://github.com/acidanthera/bugtracker/issues/365}{acidanthera/bugtracker\#365}.
  \end{itemize}
1920 1921 1922

\item
  \texttt{Cpuid1Mask}\\
A
Andrey1970AppleLife 已提交
1923
  \textbf{Type}: \texttt{plist\ data}, 16 bytes\\
1924
  \textbf{Failsafe}: All zero\\
1925 1926 1927
  \textbf{Description}: Bit mask of active bits in \texttt{Cpuid1Data}.

  When each \texttt{Cpuid1Mask} bit is set to 0, the original CPU bit is used,
V
vit9696 已提交
1928
  otherwise set bits take the value of \texttt{Cpuid1Data}.
1929 1930 1931

\end{enumerate}

V
vit9696 已提交
1932 1933 1934 1935 1936 1937
\subsection{Patch Properties}\label{kernelpropspatch}

\begin{enumerate}
\item
  \texttt{Base}\\
  \textbf{Type}: \texttt{plist\ string}\\
1938
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1939 1940 1941 1942 1943 1944 1945
  \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}\\
1946
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1947 1948 1949 1950 1951 1952 1953
  \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}\\
1954
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
1955 1956 1957 1958 1959 1960
  \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}\\
1961
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
1962 1963 1964 1965 1966 1967
  \textbf{Description}: This kernel patch will not be used unless set to
  \texttt{true}.

\item
  \texttt{Find}\\
  \textbf{Type}: \texttt{plist\ data}\\
1968
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
1969 1970 1971 1972 1973 1974 1975
  \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}\\
1976
  \textbf{Failsafe}: Empty string\\
V
vit9696 已提交
1977 1978 1979 1980 1981 1982
  \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}\\
1983
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
1984 1985 1986 1987 1988 1989
  \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}\\
1990
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
1991 1992 1993 1994 1995 1996
  \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
1997 1998 1999 2000 2001 2002 2003 2004 2005
  \texttt{MaxKernel}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: Empty string\\
  \textbf{Description}: Patches data on specified macOS version or older.

  \emph{Note}: Refer to \hyperlink{kernmatch}{\texttt{Add} \texttt{MaxKernel} description} for matching logic.

\item
  \texttt{MinKernel}\\
V
vit9696 已提交
2006
  \textbf{Type}: \texttt{plist\ string}\\
2007
  \textbf{Failsafe}: Empty string\\
2008 2009 2010
  \textbf{Description}: Patches data on specified macOS version or newer.

  \emph{Note}: Refer to \hyperlink{kernmatch}{\texttt{Add} \texttt{MaxKernel} description} for matching logic.
V
vit9696 已提交
2011 2012 2013 2014

\item
  \texttt{Replace}\\
  \textbf{Type}: \texttt{plist\ data}\\
2015
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
2016 2017 2018 2019 2020
  \textbf{Description}: Replacement data of one or more bytes.

\item
  \texttt{ReplaceMask}\\
  \textbf{Type}: \texttt{plist\ data}\\
2021
  \textbf{Failsafe}: Empty data\\
V
vit9696 已提交
2022 2023 2024 2025 2026 2027 2028 2029
  \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}\\
2030
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
2031 2032 2033 2034 2035 2036 2037 2038
  \textbf{Description}: Number of found occurrences to be skipped before replacement
  is done.

\end{enumerate}

\subsection{Quirks Properties}\label{kernelpropsquirks}

\begin{enumerate}
2039

V
vit9696 已提交
2040 2041 2042
\item
  \texttt{AppleCpuPmCfgLock}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2043
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
2044 2045 2046 2047
  \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.

V
vit9696 已提交
2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077
  Certain firmwares lock \texttt{PKG\_CST\_CONFIG\_CONTROL} MSR register. To check its
  state one can use bundled \texttt{VerifyMsrE2} tool. Select firmwares have this
  register locked on some cores only.

  As modern firmwares provide \texttt{CFG Lock} setting, which allows configuring
  \texttt{PKG\_CST\_CONFIG\_CONTROL} MSR register lock, this option should be avoided
  whenever possible. For several APTIO firmwares not displaying \texttt{CFG Lock} setting
  in the GUI it is possible to access the option directly:

  \begin{enumerate}
    \tightlist
    \item Download \href{https://github.com/LongSoft/UEFITool/releases}{UEFITool} and
      \href{https://github.com/LongSoft/Universal-IFR-Extractor/releases}{IFR-Extractor}.
    \item Open your firmware image in UEFITool and find \texttt{CFG Lock} unicode string.
      If it is not present, your firmware may not have this option and you should stop.
    \item Extract the \texttt{Setup.bin} PE32 Image Section (the one UEFITool found) through
      \texttt{Extract Body} menu option.
    \item Run IFR-Extractor on the extracted file (e.g. \texttt{./ifrextract Setup.bin Setup.txt}).
    \item Find \texttt{CFG Lock, VarStoreInfo (VarOffset/VarName):} in \texttt{Setup.txt} and
      remember the offset right after it (e.g. \texttt{0x123}).
    \item Download and run \href{http://brains.by/posts/bootx64.7z}{Modified GRUB Shell} compiled by
      \href{https://geektimes.com/post/258090}{brainsucker} or use
      \href{https://github.com/datasone/grub-mod-setup_var}{a newer version} by
      \href{https://github.com/datasone}{datasone}.
    \item Enter \texttt{setup\_var 0x123 0x00} command, where \texttt{0x123} should be replaced by
      your actual offset, and reboot.
  \end{enumerate}

  \textbf{WARNING}: Variable offsets are unique not only to each motherboard but even to its firmware
  version. Never ever try to use an offset without checking.
V
vit9696 已提交
2078

2079 2080 2081
\item
  \texttt{AppleXcpmCfgLock}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2082
  \textbf{Failsafe}: \texttt{false}\\
2083 2084 2085 2086
  \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).

V
vit9696 已提交
2087 2088
  \emph{Note}: This option should be avoided whenever possible. See \texttt{AppleCpuPmCfgLock}
  description for more details.
2089

2090 2091 2092
\item
  \texttt{AppleXcpmExtraMsrs}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2093
  \textbf{Failsafe}: \texttt{false}\\
2094
  \textbf{Description}: Disables multiple MSR access critical for select CPUs,
2095
  which have no native XCPM support.
2096

2097
  This is normally used in conjunction with \texttt{Emulate} section on Haswell-E,
A
Andrey1970AppleLife 已提交
2098
  Broadwell-E, Skylake-SP, and similar CPUs. More details on the XCPM patches are outlined in
2099 2100
  \href{https://github.com/acidanthera/bugtracker/issues/365}{acidanthera/bugtracker\#365}.

2101 2102 2103
  \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.

2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116
\item
  \texttt{AppleXcpmForceBoost}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Forces maximum performance in XCPM mode.

  This patch writes \texttt{0xFF00} to \texttt{MSR\_IA32\_PERF\_CONTROL} (\texttt{0x199}),
  effectively setting maximum multiplier for all the time.

  \emph{Note}: While this may increase the performance, this patch is strongly discouraged
  on all systems but those explicitly dedicated to scientific or media calculations.
  In general only certain Xeon models benefit from the patch.

2117 2118 2119
\item
  \texttt{CustomSMBIOSGuid}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2120
  \textbf{Failsafe}: \texttt{false}\\
2121 2122 2123
  \textbf{Description}: Performs GUID patching for \texttt{UpdateSMBIOSMode}
  \texttt{Custom} mode. Usually relevant for Dell laptops.

2124 2125 2126
\item
  \texttt{DisableIoMapper}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2127
  \textbf{Failsafe}: \texttt{false}\\
2128 2129 2130
  \textbf{Description}: Disables \texttt{IOMapper} support in XNU (VT-d),
  which may conflict with the firmware implementation.

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

2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146
\item
  \texttt{DisableRtcChecksum}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Disables primary checksum (\texttt{0x58}-\texttt{0x59})
  writing in AppleRTC.

  \emph{Note 1}: This option will not protect other areas from being overwritten,
  see \href{https://github.com/acidanthera/RTCMemoryFixup}{RTCMemoryFixup}
  kernel extension if this is desired.

  \emph{Note 2}: This option will not protect areas from being overwritten
2147 2148
  at firmware stage (e.g. macOS bootloader), see \texttt{AppleRtc} protocol
  description if this is desired.
2149

2150 2151 2152 2153 2154 2155 2156 2157 2158 2159
\item
  \texttt{DummyPowerManagement}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Disables \texttt{AppleIntelCpuPowerManagement}.

  \emph{Note}: This option is a preferred alternative to
  \texttt{NullCpuPowerManagement.kext} for CPUs without native power
  management driver in macOS.

V
vit9696 已提交
2160 2161 2162
\item
  \texttt{ExternalDiskIcons}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2163
  \textbf{Failsafe}: \texttt{false}\\
2164
  \textbf{Description}: Apply icon type patches to AppleAHCIPort.kext to force
V
vit9696 已提交
2165 2166
  internal disk icons for all AHCI disks.

A
Andrey1970AppleLife 已提交
2167
  \emph{Note}: This option should be avoided whenever possible. Modern firmwares
V
vit9696 已提交
2168 2169
  usually have compatible AHCI controllers.

2170 2171 2172 2173 2174 2175 2176 2177 2178
\item
  \texttt{IncreasePciBarSize}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Increases 32-bit PCI bar size in IOPCIFamily from 1 to 4 GBs.

  \emph{Note}: This option should be avoided whenever possible. In general the necessity
  of this option means misconfigured or broken firmware.

2179 2180 2181
\item
  \texttt{LapicKernelPanic}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2182
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
2183
  \textbf{Description}: Disables kernel panic on LAPIC interrupts.
2184

2185 2186 2187
\item
  \texttt{PanicNoKextDump}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2188
  \textbf{Failsafe}: \texttt{false}\\
2189 2190 2191
  \textbf{Description}: Prevent kernel from printing kext dump in the panic
  log preventing from observing panic details. Affects 10.13 and above.

2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203
\item
  \texttt{PowerTimeoutKernelPanic}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Disables kernel panic on setPowerState timeout.

  An additional security measure was added to macOS Catalina (10.15) causing
  kernel panic on power change timeout for Apple drivers. Sometimes it may cause
  issues on misconfigured hardware, notably digital audio, which sometimes fails
  to wake up. For debug kernels \texttt{setpowerstate\_panic=0} boot argument
  should be used, which is otherwise equivalent to this quirk.

V
vit9696 已提交
2204
\item
2205
  \texttt{ThirdPartyDrives}\\
V
vit9696 已提交
2206
  \textbf{Type}: \texttt{plist\ boolean}\\
2207
  \textbf{Failsafe}: \texttt{false}\\
2208 2209 2210
  \textbf{Description}: Apply vendor patches to IOAHCIBlockStorage.kext to enable
  native features for third-party drives, such as TRIM on SSDs or hibernation
  support on 10.15 and newer.
V
vit9696 已提交
2211

2212
  \emph{Note}: This option may be avoided on user preference. NVMe SSDs are
V
vit9696 已提交
2213
  compatible without the change. For AHCI SSDs on modern macOS version there
2214 2215 2216
  is a dedicated built-in utility called \texttt{trimforce}. Starting from 10.15
  this utility creates \texttt{EnableTRIM} variable in \texttt{APPLE\_BOOT\_VARIABLE\_GUID}
  namespace with \texttt{01 00 00 00} value.
V
vit9696 已提交
2217 2218 2219 2220

\item
  \texttt{XhciPortLimit}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2221
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
2222 2223 2224
  \textbf{Description}: Patch various kexts (AppleUSBXHCI.kext, AppleUSBXHCIPCI.kext,
  IOUSBHostFamily.kext) to remove USB port count limit of 15 ports.

2225
  \emph{Note}: This option should be avoided whenever possible. USB port limit
V
vit9696 已提交
2226 2227 2228
  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).
2229
  More details can be found on \href{https://applelife.ru/posts/550233}{AppleLife.ru}.
V
vit9696 已提交
2230 2231 2232 2233 2234 2235 2236

\end{enumerate}

\section{Misc}\label{misc}

\subsection{Introduction}\label{miscintro}

2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320
This section contains miscellaneous configuration affecting OpenCore operating system loading behaviour
as well as other entries, which do not go to any other section.

OpenCore tries to follow ``bless'' model also known as ``Apple Boot Policy''. The primary specialty of
``bless'' model is to allow embedding boot options within the file system (and be accessible through a
specialised driver) as well as supporting a broader range of predefined boot paths compared to the
removable media list found in the UEFI specification.

Each partition will only be used for booting when it corresponds to ``Scan policy'': a set of restrictions
to only use partitions with specific file systems and from specific device types. Scan policy behaviour is
discussed in \texttt{ScanPolicy} property description.

Scan process starts with obtaining all the partitions filtered with ``Scan policy''. Each partition may
produce multiple primary and alternate options. Primary options describe operating systems installed
on this media. Alternate options describe recovery options for the operating systems on the media.
It is possible for alternate options to exist without primary options and vice versa. Be warned
that the options may not necessarily describe the operating systems on the same partition.
Each primary and alternate option can be an auxiliary option or not, refer to \texttt{HideAuxiliary}
for more details. Algorithm to determine boot options behaves as follows:

\begin{enumerate}
\tightlist
\item Obtain all available partition handles filtered by ``Scan policy'' (and driver availability).
\item Obtain all available boot options from \texttt{BootOrder} UEFI variable.
\item For each found boot option:
  \begin{itemize}
  \item Retrieve device path of the boot option.
  % Scan policy restrictions are actually checked here as we want the function to be self-contained
  % for non-scan based startup.
  \item Perform fixups (e.g. NVMe subtype correction) and expansion (e.g. for Boot Camp) of the device path.
  \item Obtain device handle by locating device path of the resulting device path (ignore it on failure).
  \item Find device handle in the list of partition handles (ignore it if missing).
  % To determine device path type we can use LocateDevicePath RemainingDevicePath argument. Just check whether
  % it points to the END device path.
  \item For disk device paths (not specifying a bootloader) execute ``bless'' (may return > 1 entry).
  \item For file device paths check presence on the file system directly.
  % Just kill all \EFI\APPLE\ paths.
  \item On OpenCore boot partition exclude all OpenCore bootstrap files by header checks.
  \item Mark device handle as \textit{used} in the list of partition handles if any.
  % Each partition handle will basically have a list of boot option entries for later quick lookup.
  \item Register the resulting entries as primary options and determine their types. \\
  The option will become auxiliary for some types (e.g. Apple HFS recovery).
  \end{itemize}
\item For each partition handle:
  \begin{itemize}
  \item If partition handle is marked as \textit{unused} execute ``bless'' primary option list retrieval. \\
    In case \texttt{BlessOverride} list is set, not only standard ``bless'' paths will be found but
    also custom ones.
  \item On OpenCore boot partition exclude all OpenCore bootstrap files by header checks.
  \item Register the resulting entries as primary options and determine their types if found. \\
  The option will become auxiliary for some types (e.g. Apple HFS recovery).
  % Looking up primary and alternate handles could be done per handle to make sure the list is ordered.
  \item If partition already has primary options of ``Apple Recovery'' type proceed to next handle.
  \item Lookup alternate entries by ``bless'' recovery option list retrieval and predefined paths.
  \item Register the resulting entries as alternate auxiliary options and determine their types if found.
  \end{itemize}
\item Custom entries and tools are added as primary options without any checks with respect to \texttt{Auxiliary}.
\item System entries (e.g. \texttt{Reset NVRAM}) are added as primary auxiliary options.
\end{enumerate}

The display order of the boot options in the picker and the boot process are determined separately from the scanning
algorithm. The display order as follows:

\begin{itemize}
\tightlist
\item Alternate options follow corresponding primary options, i.e. Apple recovery will be following the
  relevant macOS option whenever possible.
\item Options will be listed in file system handle firmware order to maintain an established order across
  the reboots regardless of the chosen operating system for loading.
\item Custom entries, tools, and system entries will be added after all other options.
\item Auxiliary options will only show upon entering ``Advanced Mode'' in the picker (usually by pressing ``Space'').
\end{itemize}

The boot process is as follows:
\begin{itemize}
\tightlist
\item Try looking up first valid primary option through \texttt{BootNext} UEFI variable.
\item On failure looking up first valid primary option through \texttt{BootOrder} UEFI variable.
\item Mark the option as the default option to boot.
\item Boot option through the picker or without it depending on the \texttt{ShowPicker} option.
\item Show picker on failure otherwise.
\end{itemize}

\emph{Note 1}: This process is meant to work reliably only when \texttt{RequestBootVarRouting}
V
vit9696 已提交
2321
option is enabled or the firmware does not control UEFI boot options (\texttt{OpenDuetPkg} or
2322 2323 2324
custom BDS). Without \texttt{BootProtect} it also is possible that other operating systems
overwrite OpenCore, make sure to enable it if you plan to use them.

2325
\emph{Note 2}: UEFI variable boot options' boot arguments will be removed if present as they
2326 2327
may contain arguments compromising the operating system, which is undesired once secure boot
is enabled.
V
vit9696 已提交
2328

V
vit9696 已提交
2329 2330
\emph{Note 3}: Some operating systems, namely Windows, will create their boot option and
mark it as top most upon first boot or after NVRAM Reset. When this happens default boot
A
Andrey1970AppleLife 已提交
2331 2332
entry choice will update till next manual reconfiguration.

V
vit9696 已提交
2333 2334
\subsection{Properties}\label{miscprops}

V
vit9696 已提交
2335
\begin{enumerate}
2336 2337 2338 2339 2340 2341
\item
  \texttt{Boot}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Apply boot configuration described in
  \hyperref[miscbootprops]{Boot Properties} section below.

2342 2343 2344 2345 2346 2347 2348
\item
  \texttt{BlessOverride}\\
  \textbf{Type}: \texttt{plist\ array}\\
  \textbf{Description}: Add custom scanning paths through bless model.

  Designed to be filled with \texttt{plist\ string} entries containing
  absolute UEFI paths to customised bootloaders, for example,
2349 2350
  \texttt{\textbackslash EFI\textbackslash debian\textbackslash grubx64.efi}
  for Debian bootloader. This allows unusual boot paths to be automaticlly
2351
  discovered by the boot picker. Designwise they are equivalent to predefined blessed path, such as
2352 2353
  \texttt{\textbackslash System\textbackslash Library\textbackslash CoreServices\textbackslash boot.efi}
  or \texttt{\textbackslash EFI\textbackslash Microsoft\textbackslash Boot\textbackslash bootmgfw.efi},
2354 2355
  but unlike predefined bless paths they have highest priority.

V
vit9696 已提交
2356 2357 2358 2359 2360 2361
\item
  \texttt{Debug}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Apply debug configuration described in
  \hyperref[miscdebugprops]{Debug Properties} section below.

2362 2363 2364 2365 2366 2367 2368 2369
\item
  \texttt{Entries}\\
  \textbf{Type}: \texttt{plist\ array}\\
  \textbf{Description}: Add boot entries to boot picker.

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

2370 2371 2372 2373 2374 2375
\item
  \texttt{Security}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Description}: Apply security configuration described in
  \hyperref[miscsecurityprops]{Security Properties} section below.

2376 2377 2378
\item
  \texttt{Tools}\\
  \textbf{Type}: \texttt{plist\ array}\\
2379
  \textbf{Description}: Add tool entries to boot picker.
2380

2381 2382
  Designed to be filled with \texttt{plist\ dict} values, describing each load entry.
  See \hyperref[miscentryprops]{Entry Properties} section below.
2383

V
vit9696 已提交
2384
  \emph{Note}: Select tools, for example, UEFI Shell, are very
V
vit9696 已提交
2385 2386 2387
  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.
2388

V
vit9696 已提交
2389 2390
\end{enumerate}

2391 2392 2393 2394
\subsection{Boot Properties}\label{miscbootprops}

\begin{enumerate}

V
vit9696 已提交
2395 2396 2397 2398 2399 2400 2401
\item
  \texttt{ConsoleAttributes}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Sets specific attributes for console.

  Text renderer supports colour arguments as a sum of foreground and background
V
vit9696 已提交
2402
  colours according to UEFI specification. The value of black background and
V
vit9696 已提交
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 2435
  black foreground (\texttt{0}) is reserved. List of colour names:

  \begin{itemize}
  \tightlist
  \item \texttt{0x00} --- \texttt{EFI\_BLACK}
  \item \texttt{0x01} --- \texttt{EFI\_BLUE}
  \item \texttt{0x02} --- \texttt{EFI\_GREEN}
  \item \texttt{0x03} --- \texttt{EFI\_CYAN}
  \item \texttt{0x04} --- \texttt{EFI\_RED}
  \item \texttt{0x05} --- \texttt{EFI\_MAGENTA}
  \item \texttt{0x06} --- \texttt{EFI\_BROWN}
  \item \texttt{0x07} --- \texttt{EFI\_LIGHTGRAY}
  \item \texttt{0x08} --- \texttt{EFI\_DARKGRAY}
  \item \texttt{0x09} --- \texttt{EFI\_LIGHTBLUE}
  \item \texttt{0x0A} --- \texttt{EFI\_LIGHTGREEN}
  \item \texttt{0x0B} --- \texttt{EFI\_LIGHTCYAN}
  \item \texttt{0x0C} --- \texttt{EFI\_LIGHTRED}
  \item \texttt{0x0D} --- \texttt{EFI\_LIGHTMAGENTA}
  \item \texttt{0x0E} --- \texttt{EFI\_YELLOW}
  \item \texttt{0x0F} --- \texttt{EFI\_WHITE}
  \item \texttt{0x00} --- \texttt{EFI\_BACKGROUND\_BLACK}
  \item \texttt{0x10} --- \texttt{EFI\_BACKGROUND\_BLUE}
  \item \texttt{0x20} --- \texttt{EFI\_BACKGROUND\_GREEN}
  \item \texttt{0x30} --- \texttt{EFI\_BACKGROUND\_CYAN}
  \item \texttt{0x40} --- \texttt{EFI\_BACKGROUND\_RED}
  \item \texttt{0x50} --- \texttt{EFI\_BACKGROUND\_MAGENTA}
  \item \texttt{0x60} --- \texttt{EFI\_BACKGROUND\_BROWN}
  \item \texttt{0x70} --- \texttt{EFI\_BACKGROUND\_LIGHTGRAY}
  \end{itemize}

  \emph{Note}: This option may not work well with \texttt{System} text renderer.
  Setting a background different from black could help testing proper GOP functioning.

2436 2437 2438
\item
  \texttt{HibernateMode}\\
  \textbf{Type}: \texttt{plist\ string}\\
2439
  \textbf{Failsafe}: \texttt{None}\\
2440 2441 2442 2443 2444 2445 2446 2447 2448 2449
  \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}

2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460
\item
  \texttt{HideAuxiliary}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Hides auxiliary entries from picker menu by default.

  An entry is considered auxiliary when at least one of the following applies:

  \begin{itemize}
  \tightlist
    \item Entry is macOS recovery.
2461
    \item Entry is macOS Time Machine.
2462
    \item Entry is explicitly marked as \texttt{Auxiliary}.
V
vit9696 已提交
2463
    \item Entry is system (e.g. \texttt{Reset NVRAM}).
2464 2465
  \end{itemize}

V
vit9696 已提交
2466 2467 2468
  To see all entries picker menu needs to be reloaded in extended mode by pressing
  \texttt{Spacebar} key. Hiding auxiliary entries may increase boot performance
  for multidisk systems.
2469

2470 2471 2472 2473 2474 2475
\item
  \texttt{PickerAttributes}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Sets specific attributes for picker.

V
vit9696 已提交
2476 2477 2478 2479 2480
  Different pickers may be configured through the attribute mask containing
  OpenCore-reserved (\texttt{BIT0}\textasciitilde\texttt{BIT15}) and OEM-specific
  (\texttt{BIT16}\textasciitilde\texttt{BIT31}) values.

  Current OpenCore values include:
2481 2482 2483

  \begin{itemize}
  \tightlist
V
vit9696 已提交
2484 2485
  \item \texttt{0x0001} --- \texttt{OC\_ATTR\_USE\_VOLUME\_ICON}, provides custom icons
    for boot entries:
2486 2487
    
    For \texttt{Tools} OpenCore will try to load a custom icon and fallback to the default icon:
V
vit9696 已提交
2488
    \begin{itemize}
2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505
    \tightlist
      \item \texttt{ResetNVRAM} --- \texttt{Resources\textbackslash Image\textbackslash ResetNVRAM.icns}
        --- \texttt{ResetNVRAM.icns} from icons directory.
      \item \texttt{Tools\textbackslash <TOOL\_RELATIVE\_PATH>.icns}
        --- icon near the tool file with appended \texttt{.icns} extension.
    \end{itemize} \medskip
    
    For custom boot \texttt{Entries} OpenCore will try to load a custom icon and fallback
    to the volume icon or the default icon:
    \begin{itemize}
    \tightlist
      \item \texttt{<ENTRY\_PATH>.icns} --- icon near the entry file with appended \texttt{.icns} extension.
    \end{itemize} \medskip
    
    For all other entries OpenCore will try to load a volume icon and fallback to the default icon:
    \begin{itemize}
    \tightlist
V
vit9696 已提交
2506 2507
      \item \texttt{.VolumeIcon.icns} file at \texttt{Preboot} root for APFS.
      \item \texttt{.VolumeIcon.icns} file at volume root for other filesystems.
2508 2509
    \end{itemize} \medskip
    
2510 2511
    Volume icons can be set in Finder. Note, that enabling this may result in
    external and internal icons to be indistinguishable.
V
vit9696 已提交
2512 2513 2514
  \item \texttt{0x0002} --- \texttt{OC\_ATTR\_USE\_DISK\_LABEL\_FILE}, provides custom
    rendered titles for boot entries:
    \begin{itemize}
2515
    \tightlist
V
vit9696 已提交
2516
      \item \texttt{.disk\_label} (\texttt{.disk\_label\_2x}) file near bootloader for all filesystems.
2517
      \item \texttt{<TOOL\_NAME>.lbl} (\texttt{<TOOL\_NAME>.l2x}) file near tool for \texttt{Tools}.
V
vit9696 已提交
2518 2519 2520 2521 2522 2523 2524
    \end{itemize}
    Prerendered labels can be generated via \texttt{disklabel} utility or \texttt{bless} command.
    When disabled or missing text labels (\texttt{.contentDetails} or \texttt{.disk\_label.contentDetails})
    are to be rendered instead.
  \item \texttt{0x0004} --- \texttt{OC\_ATTR\_USE\_GENERIC\_LABEL\_IMAGE}, provides predefined
    label images for boot entries without custom entries. May give less detail for the actual
    boot entry.
2525 2526 2527
  \item \texttt{0x0008} --- \texttt{OC\_ATTR\_USE\_ALTERNATE\_ICONS}, changes used icon set to
    an alternate one if it is supported. For example, this could make a use of old-style icons
    with a custom background colour.
2528 2529
  \end{itemize}

2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546
\item
  \texttt{PickerAudioAssist}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Enable screen reader by default in boot picker.

  For macOS bootloader screen reader preference is set in \texttt{preferences.efires}
  archive in \texttt{isVOEnabled.int32} file and is controlled by the operating system.
  For OpenCore screen reader support this option is an independent equivalent.
  Toggling screen reader support in both OpenCore boot picker and macOS bootloader
  FileVault 2 login window can also be done with \texttt{Command} + \texttt{F5} key
  combination.

  \emph{Note}: screen reader requires working audio support, see
  \hyperref[uefiaudioprops]{\texttt{UEFI Audio Properties}}
  section for more details.

2547 2548 2549 2550
\item
  \texttt{PollAppleHotKeys}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
2551
  \textbf{Description}: Enable \texttt{modifier hotkey} handling in boot picker.
2552

2553
  In addition to \texttt{action hotkeys}, which are partially described in \texttt{PickerMode}
2554 2555 2556 2557 2558 2559 2560 2561 2562
  section and are normally handled by Apple BDS, there exist modifier keys, which are
  handled by operating system bootloader, namely \texttt{boot.efi}. These keys
  allow to change operating system behaviour by providing different boot modes.

  On some firmwares it may be problematic to use modifier keys due to driver incompatibilities.
  To workaround this problem this option allows registering select hotkeys in a more
  permissive manner from within boot picker. Such extensions include the support
  of tapping on keys in addition to holding and pressing \texttt{Shift} along with
  other keys instead of just \texttt{Shift} alone, which is not detectible on many
2563
  PS/2 keyboards. This list of known \texttt{modifier hotkeys} includes:
2564 2565 2566 2567 2568 2569 2570 2571
  \begin{itemize}
  \tightlist
  \item \texttt{CMD+C+MINUS} --- disable board compatibility checking.
  \item \texttt{CMD+K} --- boot release kernel, similar to \texttt{kcsuffix=release}.
  \item \texttt{CMD+S} --- single user mode.
  \item \texttt{CMD+S+MINUS} --- disable KASLR slide, requires disabled SIP.
  \item \texttt{CMD+V} --- verbose mode.
  \item \texttt{Shift} --- safe mode.
2572 2573
  \end{itemize}

2574 2575 2576
\item
  \texttt{ShowPicker}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2577
  \textbf{Failsafe}: \texttt{false}\\
2578 2579
  \textbf{Description}: Show simple boot picker to allow boot entry selection.

2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591
\item
  \texttt{TakeoffDelay}\\
  \textbf{Type}: \texttt{plist\ integer}, 32 bit\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Delay in microseconds performed before handling
  picker startup and \texttt{action hotkeys}.

  Introducing a delay may give extra time to hold the right \texttt{action hotkey}
  sequence to e.g. boot to recovery mode. On some platforms setting this option to
  at least \texttt{5000-10000} microseconds may be necessary to access
  \texttt{action hotkeys} at all due to the nature of the keyboard driver.

2592 2593 2594
\item
  \texttt{Timeout}\\
  \textbf{Type}: \texttt{plist\ integer}, 32 bit\\
2595
  \textbf{Failsafe}: \texttt{0}\\
2596
  \textbf{Description}: Timeout in seconds in boot picker before
A
Andrey1970AppleLife 已提交
2597
  automatic booting of the default boot entry. Use 0 to disable timer.
2598

2599
\item
2600
  \texttt{PickerMode}\\
2601 2602
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: \texttt{Builtin}\\
2603
  \textbf{Description}: Choose boot picker used for boot management.
2604

2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619
  Picker describes underlying boot management with an optional user interface
  responsible for handling boot options. The following values are supported:

  \begin{itemize}
  \tightlist
  \item \texttt{Builtin} --- boot management is handled by OpenCore, a simple
  text only user interface is used.
  \item \texttt{External} --- an external boot management protocol is used
  if available. Otherwise \texttt{Builtin} mode is used.
  \item \texttt{Apple} --- Apple boot management is used if available.
  Otherwise \texttt{Builtin} mode is used.
  \end{itemize}

  Upon success \texttt{External} mode will entirely disable all boot management
  in OpenCore except policy enforcement. In \texttt{Apple} mode it may additionally
V
vit9696 已提交
2620 2621
  bypass policy enforcement. See \hyperref[ueficanopy]{OpenCanopy} plugin
  for an example of a custom user interface.
2622

2623
  OpenCore built-in boot picker contains a set of actions chosen during the boot process.
2624 2625 2626
  The list of supported actions is similar to Apple BDS and in general can be accessed by
  holding \texttt{action hotkeys} during boot process. Currently the following actions are
  considered:
2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643

  \begin{itemize}
  \tightlist
  \item \texttt{Default} --- this is the default option, and it lets OpenCore built-in
  boot picker to loads the default boot option as specified in
  \href{https://support.apple.com/HT202796}{Startup Disk} preference pane.
  \item \texttt{ShowPicker} --- this option forces picker to show. Normally it can be
  achieved by holding \texttt{OPT} key during boot. Setting \texttt{ShowPicker} to
  \texttt{true} will make \texttt{ShowPicker} the default option.
  \item \texttt{ResetNvram} --- this option performs select UEFI variable erase and is
  normally achieved by holding \texttt{CMD+OPT+P+R} key combination during boot.
  Another way to erase UEFI variables is to choose \texttt{Reset NVRAM} in the picker.
  This option requires \texttt{AllowNvramReset} to be set to \texttt{true}.
  \item \texttt{BootApple} --- this options performs booting to the first found Apple
  operating system unless the default chosen operating system is already made by Apple.
  Hold \texttt{X} key to choose this option.
  \item \texttt{BootAppleRecovery} --- this option performs booting to Apple operating
P
PMheart 已提交
2644
  system recovery. Either the one related to the default chosen operating system,
2645 2646 2647 2648
  or first found in case default chosen operating system is not made by Apple or has no
  recovery. Hold \texttt{CMD+R} key combination to choose this option.
  \end{itemize}

V
vit9696 已提交
2649
  \emph{Note 1}: Activated \texttt{KeySupport}, \texttt{OpenUsbKbDxe}, or similar driver is required
2650 2651
  for key handling to work. On many firmwares it is not possible to get all the keys function.

2652
  \emph{Note 2}: In addition to \texttt{OPT} OpenCore supports \texttt{Escape} key to display picker when
2653 2654 2655
  \texttt{ShowPicker} is disabled. This key exists for \texttt{Apple} picker mode and for
  firmwares with PS/2 keyboards that fail to report held \texttt{OPT} key and require continual
  presses of \texttt{Escape} key to enter the boot menu.
2656

2657 2658 2659
  \emph{Note 3}: On Macs with problematic GOP it may be difficult to access Apple BootPicker.
  To workaround this problem even without loading OpenCore \texttt{BootKicker} utility can be blessed.

2660 2661
\end{enumerate}

V
vit9696 已提交
2662 2663 2664 2665
\subsection{Debug Properties}\label{miscdebugprops}

\begin{enumerate}

2666 2667 2668 2669 2670 2671 2672 2673
\item
  \texttt{AppleDebug}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Enable \texttt{boot.efi} debug log saving to OpenCore log.

  \emph{Note}: This option only applies to 10.15.4 and newer.

2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691
\item
  \texttt{ApplePanic}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Save macOS kernel panic to OpenCore root partition.

  The file is saved as \texttt{panic-YYYY-MM-DD-HHMMSS.txt}. It is strongly
  recommended to have \texttt{keepsyms=1} boot argument to see debug symbols
  in the panic log. In case it was not present \texttt{kpdescribe.sh} utility
  (bundled with OpenCore) may be used to partially recover the stacktrace.

  Development and debug kernels produce more helpful kernel panics.
  Consider downloading and installing \texttt{KernelDebugKit} from
  \href{https://developer.apple.com}{developer.apple.com} when debugging a problem.
  To activate a development kernel you will need to add a \texttt{kcsuffix=development}
  boot argument. Use \texttt{uname -a} command to ensure that your current loaded
  kernel is a development (or a debug) kernel.

2692
  In case OpenCore kernel panic saving mechanism was not used, kernel panics may
A
Andrey1970AppleLife 已提交
2693 2694
  still be found in \\
  \texttt{/Library/Logs/DiagnosticReports} directory.
2695 2696 2697 2698 2699 2700 2701 2702
  Starting with macOS Catalina kernel panics are stored in JSON format, so they
  need to be preprocessed before passing to \texttt{kpdescribe.sh}:

\begin{lstlisting}[label=kpanic, style=ocbash]
cat Kernel.panic | grep macOSProcessedStackshotData |
  python -c 'import json,sys;print(json.load(sys.stdin)["macOSPanicString"])'
\end{lstlisting}

2703 2704 2705
\item
  \texttt{DisableWatchDog}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
2706
  \textbf{Failsafe}: \texttt{false}\\
2707 2708 2709 2710
  \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 已提交
2711
\item
V
vit9696 已提交
2712
  \texttt{DisplayDelay}\\
V
vit9696 已提交
2713
  \textbf{Type}: \texttt{plist\ integer}\\
2714
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
2715
  \textbf{Description}: Delay in microseconds performed after
V
vit9696 已提交
2716
  every printed line visible onscreen (i.e. console).
V
vit9696 已提交
2717

2718 2719 2720
\item
  \texttt{DisplayLevel}\\
  \textbf{Type}: \texttt{plist\ integer}, 64 bit\\
2721
  \textbf{Failsafe}: \texttt{0}\\
2722 2723 2724 2725
  \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
2726
  \href{https://github.com/acidanthera/audk/blob/master/MdePkg/Include/Library/DebugLib.h}{DebugLib.h}):
2727 2728 2729

  \begin{itemize}
  \tightlist
2730
    \item \texttt{0x00000002} (bit \texttt{1}) --- \texttt{DEBUG\_WARN} in \texttt{DEBUG},
2731
      \texttt{NOOPT}, \texttt{RELEASE}.
2732
    \item \texttt{0x00000040} (bit \texttt{6}) --- \texttt{DEBUG\_INFO} in \texttt{DEBUG},
2733
      \texttt{NOOPT}.
2734 2735
    \item \texttt{0x00400000} (bit \texttt{22}) --- \texttt{DEBUG\_VERBOSE} in custom builds.
    \item \texttt{0x80000000} (bit \texttt{31}) --- \texttt{DEBUG\_ERROR} in \texttt{DEBUG},
2736 2737 2738
      \texttt{NOOPT}, \texttt{RELEASE}.
  \end{itemize}

2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757
\item
  \texttt{SerialInit}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Perform serial port initialisation.

  This option will perform serial port initialisation within OpenCore prior to enabling
  (any) debug logging. Serial port configuration is defined via PCDs at compile time
  in \texttt{gEfiMdeModulePkgTokenSpaceGuid} GUID. Default values as found in
  \texttt{MdeModulePkg.dec} are as follows:
  
  \begin{itemize}
  \tightlist
    \item \texttt{PcdSerialBaudRate} --- Baud rate: \texttt{115200}.
    \item \texttt{PcdSerialLineControl} --- Line control: no parity, 8 data bits, 1 stop bit.
  \end{itemize}

  See more details in \hyperref[troubleshootingdebug]{\texttt{Debugging}} section.

2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769
\item
  \texttt{SysReport}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Produce system report on ESP folder.

  This option will create a \texttt{SysReport} directory on ESP partition
  unless it is already present. The directory will contain ACPI and SMBIOS dumps.

  \emph{Note}: For security reasons \texttt{SysReport} option is \textbf{not} available
  in \texttt{RELEASE} builds. Use a \texttt{DEBUG} build if you need this option.

V
vit9696 已提交
2770 2771 2772
\item
  \texttt{Target}\\
  \textbf{Type}: \texttt{plist\ integer}\\
2773
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
2774 2775
  \textbf{Description}: A bitmask (sum) of enabled logging targets.
  By default all the logging output is hidden, so this option is
2776 2777 2778
  required to be set when debugging is necessary.

  The following logging targets are supported:
V
vit9696 已提交
2779 2780 2781

  \begin{itemize}
  \tightlist
2782 2783 2784 2785 2786 2787 2788
    \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 已提交
2789 2790
  \end{itemize}

2791
  Console logging prints less than all the other variants.
V
vit9696 已提交
2792 2793 2794
  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 已提交
2795 2796
  Data Hub log will not log kernel and kext patches. To obtain Data Hub log use
  the following command in macOS:
V
vit9696 已提交
2797
\begin{lstlisting}[label=dhublog, style=ocbash]
V
vit9696 已提交
2798
ioreg -lw0 -p IODeviceTree | grep boot-log | sort | sed 's/.*<\(.*\)>.*/\1/' | xxd -r -p
V
vit9696 已提交
2799 2800
\end{lstlisting}

V
vit9696 已提交
2801 2802 2803 2804
  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 已提交
2805 2806
  in macOS:
\begin{lstlisting}[label=nvramlog, style=ocbash]
2807
nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-log |
V
vit9696 已提交
2808 2809 2810
  awk '{gsub(/%0d%0a%00/,"");gsub(/%0d%0a/,"\n")}1'
\end{lstlisting}

2811 2812 2813 2814
  \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 已提交
2815 2816
  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
2817
  even with boot log disabled.
V
vit9696 已提交
2818

2819 2820 2821 2822 2823
  File logging will create a file named \texttt{opencore-YYYY-MM-DD-HHMMSS.txt} at EFI
  volume root with log contents (the upper case letter sequence is replaced with date
  and time from the firmware). 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
2824 2825 2826
  \texttt{DisableWatchDog} is set to \texttt{true} when you use a slow drive. Try to
  avoid frequent use of this option when dealing with flash drives as large I/O
  amounts may speedup memory wear and render this flash drive unusable in shorter time.
V
vit9696 已提交
2827

2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844
  When interpreting the log, note that the lines are prefixed with a tag describing
  the relevant location (module) of the log line allowing one to better attribute the line
  to the functionality. The list of currently used tags is provided below.

  \textbf{Drivers and tools}:
  \begin{itemize}
  \tightlist
  \item \texttt{BMF} --- OpenCanopy, bitmap font
  \item \texttt{BS} --- Bootstrap
  \item \texttt{GSTT} --- GoptStop
  \item \texttt{HDA} --- AudioDxe
  \item \texttt{KKT} --- KeyTester
  \item \texttt{MMDD} --- MmapDump
  \item \texttt{OCPAVP} --- PavpProvision
  \item \texttt{OCRST} --- ResetSystem
  \item \texttt{OCUI} --- OpenCanopy
  \item \texttt{OC} --- OpenCore main
2845
  \item \texttt{VMOPT} --- VerifyMemOpt
2846 2847 2848 2849 2850 2851 2852 2853 2854 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 2889 2890 2891
  \end{itemize}

  \textbf{Libraries}:
  \begin{itemize}
  \tightlist
  \item \texttt{AAPL} --- OcDebugLogLib, Apple EfiBoot logging
  \item \texttt{OCABC} --- OcAfterBootCompatLib
  \item \texttt{OCAE} --- OcAppleEventLib
  \item \texttt{OCAK} --- OcAppleKernelLib
  \item \texttt{OCAU} --- OcAudioLib
  \item \texttt{OCAV} --- OcAppleImageVerificationLib
  \item \texttt{OCA} ---- OcAcpiLib
  \item \texttt{OCBP} --- OcAppleBootPolicyLib
  \item \texttt{OCB} --- OcBootManagementLib
  \item \texttt{OCCL} --- OcAppleChunkListLib
  \item \texttt{OCCPU} --- OcCpuLib
  \item \texttt{OCC} --- OcConsoleLib
  \item \texttt{OCDH} --- OcDataHubLib
  \item \texttt{OCDI} --- OcAppleDiskImageLib
  \item \texttt{OCFSQ} --- OcFileLib, UnblockFs quirk
  \item \texttt{OCFS} --- OcFileLib
  \item \texttt{OCFV} --- OcFirmwareVolumeLib
  \item \texttt{OCHS} --- OcHashServicesLib
  \item \texttt{OCIC} --- OcImageConversionLib
  \item \texttt{OCII} --- OcInputLib
  \item \texttt{OCJS} --- OcApfsLib
  \item \texttt{OCKM} --- OcAppleKeyMapLib
  \item \texttt{OCL} --- OcDebugLogLib
  \item \texttt{OCMCO} --- OcMachoLib
  \item \texttt{OCME} --- OcHeciLib
  \item \texttt{OCMM} --- OcMemoryLib
  \item \texttt{OCPI} --- OcFileLib, partition info
  \item \texttt{OCPNG} --- OcPngLib
  \item \texttt{OCRAM} --- OcAppleRamDiskLib
  \item \texttt{OCRTC} --- OcRtcLib
  \item \texttt{OCSB} --- OcAppleSecureBootLib
  \item \texttt{OCSMB} --- OcSmbiosLib
  \item \texttt{OCSMC} --- OcSmcLib
  \item \texttt{OCST} --- OcStorageLib
  \item \texttt{OCS} --- OcSerializedLib
  \item \texttt{OCTPL} --- OcTemplateLib
  \item \texttt{OCUC} --- OcUnicodeCollationLib
  \item \texttt{OCUT} --- OcAppleUserInterfaceThemeLib
  \item \texttt{OCXML} --- OcXmlLib
  \end{itemize}

V
vit9696 已提交
2892
\end{enumerate}
V
vit9696 已提交
2893

2894 2895 2896
\subsection{Security Properties}\label{miscsecurityprops}

\begin{enumerate}
2897

2898 2899 2900 2901 2902 2903 2904
\item
  \texttt{AllowNvramReset}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Allow \texttt{CMD+OPT+P+R} handling and enable
  showing \texttt{NVRAM Reset} entry in boot picker.

2905 2906 2907 2908 2909 2910
  \emph{Note 1}: It is known that some Lenovo laptops have a firmware
  bug, which makes them unbootable after performing NVRAM reset. See
  \href{https://github.com/acidanthera/bugtracker/issues/995}{acidanthera/bugtracker\#995}
  for more details.

  \emph{Note 2}: Resetting NVRAM will also erase all the boot options
V
vit9696 已提交
2911 2912
  otherwise not backed up with bless (e.g. Linux).

2913 2914 2915 2916 2917 2918 2919
\item
  \texttt{AllowSetDefault}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Allow \texttt{CTRL+Enter} and \texttt{CTRL+Index} handling
  to set the default boot option in boot picker.

2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934
\item
  \texttt{AuthRestart}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Enable \texttt{VirtualSMC}-compatible authenticated restart.

  Authenticated restart is a way to reboot FileVault 2 enabled macOS without entering
  the password. To perform authenticated restart one can use a dedicated terminal
  command: \texttt{sudo fdesetup authrestart}. It is also used when installing
  operating system updates.

  VirtualSMC performs authenticated restart by saving disk encryption key split in
  NVRAM and RTC, which despite being removed as soon as OpenCore starts, may be
  considered a security risk and thus is optional.

2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960
\item
  \texttt{BootProtect}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: \texttt{None}\\
  \textbf{Description}: Attempt to provide bootloader persistence.

  Valid values:

  \begin{itemize}
  \tightlist
  \item \texttt{None} --- do nothing.
  \item \texttt{Bootstrap} --- create or update top-priority
  \texttt{\textbackslash EFI\textbackslash OC\textbackslash Bootstrap\textbackslash Bootstrap.efi}
  boot option (\texttt{Boot9696}) in UEFI variable storage at bootloader startup. For this option
  to work \texttt{RequestBootVarRouting} is required to be enabled.
  \end{itemize}

  This option provides integration with third-party operating system installation and upgrade
  at the times they overwrite \texttt{\textbackslash EFI\textbackslash BOOT\textbackslash BOOTx64.efi}
  file. By creating a custom option in \texttt{Bootstrap} mode this file path becomes no longer
  used for bootstraping OpenCore.

  \emph{Note 1}: Some firmewares may have broken NVRAM, no boot option support, or various other
  incompatibilities of any kind. While unlikely, the use of this option may even cause boot failure.
  Use at your own risk on boards known to be compatible.

2961 2962
  \emph{Note 2}: Be warned that while NVRAM reset executed from OpenCore should not erase the boot
  option created in \texttt{Bootstrap}, executing NVRAM reset prior to loading OpenCore will remove it.
2963

2964 2965 2966
\item
  \texttt{ExposeSensitiveData}\\
  \textbf{Type}: \texttt{plist\ integer}\\
2967
  \textbf{Failsafe}: \texttt{0x6}\\
2968 2969 2970 2971 2972 2973
  \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.
A
Andrey1970AppleLife 已提交
2974
    \item \texttt{0x04} --- Expose OpenCore version in boot picker menu title.
2975
    \item \texttt{0x08} --- Expose OEM information as a set of UEFI variables.
2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992
  \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
2993 2994 2995 2996 2997 2998 2999
\end{lstlisting}

  To obtain OEM information use the following commands in macOS:
\begin{lstlisting}[label=nvramver, style=ocbash]
nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:oem-product # SMBIOS Type1 ProductName
nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:oem-vendor  # SMBIOS Type2 Manufacturer
nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:oem-board   # SMBIOS Type2 ProductName
3000 3001
\end{lstlisting}

3002 3003 3004
\item
  \texttt{HaltLevel}\\
  \textbf{Type}: \texttt{plist\ integer}, 64 bit\\
3005
  \textbf{Failsafe}: \texttt{0x80000000} (\texttt{DEBUG\_ERROR})\\
3006 3007 3008
  \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 已提交
3009 3010

\item
3011 3012 3013 3014
  \texttt{Vault}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: \texttt{Secure}\\
  \textbf{Description}: Enables vaulting mechanism in OpenCore.
V
vit9696 已提交
3015

3016 3017 3018 3019
  Valid values:

  \begin{itemize}
  \tightlist
V
vit9696 已提交
3020
  \item \texttt{Optional} --- require nothing, no vault is enforced, insecure.
3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032
  \item \texttt{Basic} --- require \texttt{vault.plist} file present
  in \texttt{OC} directory. This provides basic filesystem integrity
  verification and may protect from unintentional filesystem corruption.
  \item \texttt{Secure} --- require \texttt{vault.sig} signature file for
  \texttt{vault.plist} in \texttt{OC} directory. This includes \texttt{Basic}
  integrity checking but also attempts to build a trusted bootchain.
  \end{itemize}

  \texttt{vault.plist} 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
3033
  \href{https://github.com/acidanthera/OpenCorePkg/tree/master/Utilities/CreateVault}{\texttt{create\_vault.sh}} script.
3034 3035
  Regardless of the underlying filesystem, path name and case must match
  between \texttt{config.plist} and \texttt{vault.plist}.
V
vit9696 已提交
3036

3037 3038 3039 3040
  \texttt{vault.sig} 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:
V
vit9696 已提交
3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051

  \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
3052
  \href{https://github.com/acidanthera/OpenCorePkg/tree/master/Utilities/CreateVault}{RsaTool}.
V
vit9696 已提交
3053 3054


V
vit9696 已提交
3055 3056 3057 3058 3059
  The complete set of commands to:

  \begin{itemize}
  \tightlist
  \item Create \texttt{vault.plist}.
V
vit9696 已提交
3060
  \item Create a new RSA key (always do this to avoid loading old configuration).
V
vit9696 已提交
3061
  \item Embed RSA key into \texttt{OpenCore.efi}.
V
vit9696 已提交
3062 3063 3064 3065 3066
  \item Create \texttt{vault.sig}.
  \end{itemize}

  Can look as follows:
\begin{lstlisting}[label=createvault, style=ocbash]
V
vit9696 已提交
3067
cd /Volumes/EFI/EFI/OC
3068 3069
/path/to/create_vault.sh .
/path/to/RsaTool -sign vault.plist vault.sig vault.pub
V
vit9696 已提交
3070
off=$(($(strings -a -t d OpenCore.efi | grep "=BEGIN OC VAULT=" | cut -f1 -d' ')+16))
V
vit9696 已提交
3071
dd of=OpenCore.efi if=vault.pub bs=1 seek=$off count=528 conv=notrunc
V
vit9696 已提交
3072
rm vault.pub
V
vit9696 已提交
3073 3074
\end{lstlisting}

3075
  \emph{Note 1}: While it may appear obvious, but you have to use an external
V
vit9696 已提交
3076 3077 3078 3079 3080 3081 3082
  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).

3083 3084 3085 3086 3087
  \emph{Note 2}: \texttt{vault.plist} and \texttt{vault.sig} are used regardless of this
  option when \texttt{vault.plist} is present or public key is embedded into
  \texttt{OpenCore.efi}. Setting this option will only ensure configuration sanity,
  and abort the boot process otherwise.

3088 3089 3090
\item
  \texttt{ScanPolicy}\\
  \textbf{Type}: \texttt{plist\ integer}, 32 bit\\
3091
  \textbf{Failsafe}: \texttt{0x10F0103}\\
3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106
  \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
3107
    \item \texttt{0x00000001} (bit \texttt{0}) --- \texttt{OC\_SCAN\_FILE\_SYSTEM\_LOCK}, restricts
3108 3109 3110 3111 3112
    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\_}.
3113
    \item \texttt{0x00000002} (bit \texttt{1}) --- \texttt{OC\_SCAN\_DEVICE\_LOCK}, restricts scanning
3114 3115 3116 3117
    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\_}.
3118
    \item \texttt{0x00000100} (bit \texttt{8}) --- \texttt{OC\_SCAN\_ALLOW\_FS\_APFS}, allows scanning
3119
    of APFS file system.
3120
    \item \texttt{0x00000200} (bit \texttt{9}) --- \texttt{OC\_SCAN\_ALLOW\_FS\_HFS}, allows scanning
3121 3122 3123
    of HFS file system.
    \item \texttt{0x00000400} (bit \texttt{10}) --- \texttt{OC\_SCAN\_ALLOW\_FS\_ESP}, allows scanning
    of EFI System Partition file system.
3124 3125 3126 3127
    \item \texttt{0x00000800} (bit \texttt{11}) --- \texttt{OC\_SCAN\_ALLOW\_FS\_NTFS}, allows scanning
    of NTFS (Msft Basic Data) file system.
    \item \texttt{0x00001000} (bit \texttt{12}) --- \texttt{OC\_SCAN\_ALLOW\_FS\_EXT}, allows scanning
    of EXT (Linux Root) file system.
3128
    \item \texttt{0x00010000} (bit \texttt{16}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SATA}, allow
3129
    scanning SATA devices.
3130
    \item \texttt{0x00020000} (bit \texttt{17}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SASEX}, allow
3131
    scanning SAS and Mac NVMe devices.
3132
    \item \texttt{0x00040000} (bit \texttt{18}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SCSI}, allow
3133
    scanning SCSI devices.
3134
    \item \texttt{0x00080000} (bit \texttt{19}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_NVME}, allow
3135
    scanning NVMe devices.
3136
    \item \texttt{0x00100000} (bit \texttt{20}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_ATAPI}, allow
3137
    scanning CD/DVD devices.
3138
    \item \texttt{0x00200000} (bit \texttt{21}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_USB}, allow
3139
    scanning USB devices.
3140
    \item \texttt{0x00400000} (bit \texttt{22}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_FIREWIRE}, allow
3141
    scanning FireWire devices.
3142
    \item \texttt{0x00800000} (bit \texttt{23}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_SDCARD}, allow
3143
    scanning card reader devices.
3144 3145
    \item \texttt{0x01000000} (bit \texttt{24}) --- \texttt{OC\_SCAN\_ALLOW\_DEVICE\_PCI}, allow
    scanning devices directly connected to PCI bus (e.g. VIRTIO).
3146 3147 3148 3149 3150
  \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
V
vit9696 已提交
3151
  on USB, CD, and FireWire drives. The combination reads as:
3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162
  \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}

3163 3164
\end{enumerate}

3165
\subsection{Entry Properties}\label{miscentryprops}
3166 3167

\begin{enumerate}
3168 3169 3170 3171 3172 3173 3174
\item
  \texttt{Arguments}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: Empty string\\
  \textbf{Description}: Arbitrary ASCII string used as boot arguments (load options)
  of the specified entry.

3175 3176 3177 3178 3179 3180 3181
\item
  \texttt{Auxiliary}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: This entry will not be listed by default when
  \texttt{HideAuxiliary} is set to \texttt{true}.

3182 3183 3184
\item
  \texttt{Comment}\\
  \textbf{Type}: \texttt{plist\ string}\\
3185
  \textbf{Failsafe}: Empty string\\
3186 3187 3188 3189
  \textbf{Description}: Arbitrary ASCII string used to provide human readable
  reference for the entry. It is implementation defined whether this value is
  used.

3190 3191 3192
\item
  \texttt{Enabled}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
3193
  \textbf{Failsafe}: \texttt{false}\\
3194
  \textbf{Description}: This entry will not be listed unless set to
3195 3196
  \texttt{true}.

3197 3198 3199
\item
  \texttt{Name}\\
  \textbf{Type}: \texttt{plist\ string}\\
3200
  \textbf{Failsafe}: Empty string\\
3201
  \textbf{Description}: Human readable entry name displayed in boot picker.
3202 3203 3204 3205

\item
  \texttt{Path}\\
  \textbf{Type}: \texttt{plist\ string}\\
3206
  \textbf{Failsafe}: Empty string\\
3207 3208 3209 3210 3211 3212 3213 3214 3215
  \textbf{Description}: Entry location depending on entry type.

  \begin{itemize}
  \tightlist
  \item \texttt{Entries} specify external boot options, and therefore take device
  paths in \texttt{Path} key. These values are not checked, thus be extremely careful.
  Example: \texttt{PciRoot(0x0)/Pci(0x1,0x1)/.../\textbackslash EFI\textbackslash COOL.EFI}
  \item \texttt{Tools} specify internal boot options, which are part of bootloader
  vault, and therefore take file paths relative to \texttt{OC/Tools} directory.
V
vit9696 已提交
3216
  Example: \texttt{OpenShell.efi}.
3217
  \end{itemize}
3218 3219 3220 3221

\end{enumerate}


V
vit9696 已提交
3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248
\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})
3249 3250 3251
\item
  \texttt{4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102}
  (\texttt{OC\_VENDOR\_VARIABLE\_GUID})
V
vit9696 已提交
3252 3253
\end{itemize}

V
vit9696 已提交
3254 3255 3256 3257 3258 3259 3260
\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.

3261
For proper macOS functioning it is often required to use \texttt{OC\_FIRMWARE\_RUNTIME}
V
vit9696 已提交
3262
protocol implementation currently offered as a part of \texttt{OpenRuntime} driver.
3263 3264 3265 3266 3267 3268 3269 3270 3271 3272
While it brings any benefits, there are certain limitations which arise depending on the
use.

\begin{enumerate}
\item Not all tools may be aware of protected namespaces.\\
  When \texttt{RequestBootVarRouting} is used \texttt{Boot}-prefixed variable access
  is restricted and protected in a separate namespace. To access the original variables
  tools have to be aware of \texttt{OC\_FIRMWARE\_RUNTIME} logic.
\end{enumerate}

V
vit9696 已提交
3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285
\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.
3286 3287
  Variables will only be set if not present or deleted. I.e. to overwrite
  an existing variable value add the variable name to the \texttt{Delete} section.
3288 3289
  This approach enables to provide default values till the operating system
  takes the lead.
V
vit9696 已提交
3290 3291 3292 3293 3294

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

\item
3295
  \texttt{Delete}\\
V
vit9696 已提交
3296 3297 3298 3299 3300
  \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.

3301 3302 3303
\item
  \texttt{LegacyEnable}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
3304
  \textbf{Failsafe}: \texttt{false}\\
3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315
  \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}

3316
  Variable loading happens prior to \texttt{Delete} (and \texttt{Add}) phases. Unless
3317 3318 3319
  \texttt{LegacyOverwrite} is enabled, it 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}
V
vit9696 已提交
3320 3321 3322
  file. An example of such script can be found in \texttt{Utilities}. 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.
3323 3324 3325 3326

  \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.
3327

3328 3329 3330 3331 3332 3333 3334 3335
\item
  \texttt{LegacyOverwrite}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Permits overwriting firmware variables from \texttt{nvram.plist}.

  \emph{Note}: Only variables accessible from the operating system will be overwritten.

3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346
\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
3347
  this can bypass SIP.
3348

3349 3350 3351 3352 3353
\item
  \texttt{WriteFlash}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Enables writing to flash memory for all added variables.
3354

3355 3356 3357 3358
  \emph{Note}: This value is recommended to be enabled on most firmwares, but is
  left configurable for firmwares that may have issues with NVRAM variable storage
  garbage collection or alike.

V
vit9696 已提交
3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369
\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}

3370 3371 3372 3373 3374 3375
\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 已提交
3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392
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
3393
  of SMBIOS tables, especially in \texttt{boot.efi}.
V
vit9696 已提交
3394 3395 3396 3397
\item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ROM}
  \break
  Primary network adapter MAC address or replacement value. Present on newer Macs
3398
  (2013+ at least) to avoid accessing special memory region, especially in \texttt{boot.efi}.
V
vit9696 已提交
3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426
\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
3427
  real Macs, but used to avoid extra parsing of SMBIOS tables, especially in \texttt{boot.efi}.
V
vit9696 已提交
3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439
\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 已提交
3440 3441
  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
3442
  keyboard list from \texttt{AppleKeyboardLayouts-L.dat} can be found
3443
  \href{https://github.com/acidanthera/OpenCorePkg/tree/master/Utilities/AppleKeyboardLayouts}{here}. Using non-latin keyboard on 10.14
3444
  will not enable ABC keyboard, unlike previous and subsequent macOS versions, and is thus not recommended in case you need 10.14.
V
vit9696 已提交
3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456
\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
3457
  One-byte data defining \texttt{boot.efi} user interface scaling. Should be \textbf{01} for normal
3458
  screens and \textbf{02} for HiDPI screens.
3459 3460 3461
 \item
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:DefaultBackgroundColor}
  \break
A
Andrey1970AppleLife 已提交
3462
  Four-byte \texttt{BGRA} data defining \texttt{boot.efi} user interface background colour.
3463 3464
  Standard colours include \textbf{BF BF BF 00} (Light Gray) and \textbf{00 00 00 00}
  (Syrah Black). Other colours may be set at user's preference.
V
vit9696 已提交
3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479
\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.
3480
  Some of the known boot arguments include:
V
vit9696 已提交
3481 3482

  \begin{itemize}
3483 3484 3485 3486
  \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}})
3487 3488 3489 3490 3491 3492 3493 3494 3495 3496
  \item \texttt{batman=VALUE} (\texttt{AppleSmartBatteryManager} debug mask)
  \item \texttt{batman-nosmc=1} (disable \texttt{AppleSmartBatteryManager} SMC interface)
  \item \texttt{cpus=VALUE} (maximum number of CPUs used)
  \item \texttt{debug=VALUE} (debug mask)
  \item \texttt{io=VALUE} (\texttt{IOKit} debug mask)
  \item \texttt{keepsyms=1} (show panic log debug symbols)
  \item \texttt{kextlog=VALUE} (kernel extension loading debug mask)
  \item \texttt{nv\_disable=1} (disables NVIDIA GPU acceleration)
  \item \texttt{nvda\_drv=1} (legacy way to enable NVIDIA web driver, removed in 10.12)
  \item \texttt{npci=0x2000} (\href{https://www.insanelymac.com/forum/topic/260539-1068-officially-released/?do=findComment&comment=1707972}{legacy}, disables \texttt{kIOPCIConfiguratorPFM64})
3497
  \item \texttt{lapic\_dont\_panic=1}
3498 3499 3500
  \item \texttt{slide=VALUE} (manually set KASLR slide)
  \item \texttt{smcdebug=VALUE} (\texttt{AppleSMC} debug mask)
  \item \texttt{-amd\_no\_dgpu\_accel} (alternative to \href{https://github.com/acidanthera/WhateverGreen}{WhateverGreen}'s \texttt{-radvesa} for new GPUs)
3501
  \item \texttt{-nehalem\_error\_disable}
3502 3503 3504 3505
  \item \texttt{-no\_compat\_check} (disable model checking)
  \item \texttt{-s} (single mode)
  \item \texttt{-v} (verbose mode)
  \item \texttt{-x} (safe mode)
V
vit9696 已提交
3506 3507
  \end{itemize}

3508 3509 3510 3511
  There are multiple external places summarising macOS argument lists:
  \href{https://osxeon.wordpress.com/2015/08/10/boot-argument-options-in-os-x}{example 1},
  \href{https://superuser.com/questions/255176/is-there-a-list-of-available-boot-args-for-darwin-os-x}{example 2}.

V
vit9696 已提交
3512 3513 3514
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:bootercfg}
  \break
3515
  Booter arguments, similar to \texttt{boot-args} but for \texttt{boot.efi}. Accepts a set of
V
vit9696 已提交
3516
  arguments, which are hexadecimal 64-bit values with or without \texttt{0x}.
3517
  At different stages \texttt{boot.efi} will request different debugging (logging)
V
vit9696 已提交
3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537
  modes (e.g. after \texttt{ExitBootServices} it will only print to serial).
  Several booter arguments control whether these requests will succeed. The
  list of known requests is covered below:

  \begin{itemize}
  \tightlist
  \item \texttt{0x00} -- \texttt{INIT}.
  \item \texttt{0x01} -- \texttt{VERBOSE} (e.g. \texttt{-v}, force console logging).
  \item \texttt{0x02} -- \texttt{EXIT}.
  \item \texttt{0x03} -- \texttt{RESET:OK}.
  \item \texttt{0x04} -- \texttt{RESET:FAIL} (e.g. unknown \texttt{board-id}, hibernate mismatch, panic loop, etc.).
  \item \texttt{0x05} -- \texttt{RESET:RECOVERY}.
  \item \texttt{0x06} -- \texttt{RECOVERY}.
  \item \texttt{0x07} -- \texttt{REAN:START}.
  \item \texttt{0x08} -- \texttt{REAN:END}.
  \item \texttt{0x09} -- \texttt{DT} (can no longer log to DeviceTree).
  \item \texttt{0x0A} -- \texttt{EXITBS:START} (forced serial only).
  \item \texttt{0x0B} -- \texttt{EXITBS:END} (forced serial only).
  \item \texttt{0x0C} -- \texttt{UNKNOWN}.
  \end{itemize}
V
vit9696 已提交
3538

V
vit9696 已提交
3539 3540
  In 10.15 debugging support was mostly broken before 10.15.4 due to some
  kind of refactoring and introduction of a
V
vit9696 已提交
3541
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Apple/Protocol/AppleDebugLog.h}{new debug protocol}.
V
vit9696 已提交
3542 3543 3544
  Some of the arguments and their values below may not be valid for versions prior
  to 10.15.4. The list of known arguments is covered below:

V
vit9696 已提交
3545
  \begin{itemize}
V
vit9696 已提交
3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598
  \item \texttt{boot-save-log=VALUE} --- debug log save mode for normal boot.
  	\begin{itemize}
    \item \texttt{0}
    \item \texttt{1}
    \item \texttt{2} --- (default).
    \item \texttt{3}
    \item \texttt{4} --- (save to file).
    \end{itemize}
  \item \texttt{wake-save-log=VALUE} --- debug log save mode for hibernation wake.
  	\begin{itemize}
    \item \texttt{0} --- disabled.
    \item \texttt{1}
    \item \texttt{2} --- (default).
    \item \texttt{3} --- (unavailable).
    \item \texttt{4} --- (save to file, unavailable).
    \end{itemize}
  \item \texttt{breakpoint=VALUE} --- enables debug breaks (missing in production \texttt{boot.efi}).
    \begin{itemize}
    \item \texttt{0} --- disables debug breaks on errors (default).
    \item \texttt{1} --- enables debug breaks on errors.
    \end{itemize}
  \item \texttt{console=VALUE} --- enables console logging.
    \begin{itemize}
    \item \texttt{0} --- disables console logging.
    \item \texttt{1} --- enables console logging when debug protocol is missing (default).
    \item \texttt{2} --- enables console logging unconditionally (unavailable).
    \end{itemize}
  \item \texttt{embed-log-dt=VALUE} --- enables DeviceTree logging.
    \begin{itemize}
    \item \texttt{0} --- disables DeviceTree logging (default).
    \item \texttt{1} --- enables DeviceTree logging.
    \end{itemize}
  \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.
  \item \texttt{log-level=VALUE} --- log level bitmask.
    \begin{itemize}
    \item \texttt{0x01} --- enables trace logging (default).
    \end{itemize}
  \item \texttt{serial=VALUE} --- enables serial logging.
    \begin{itemize}
    \item \texttt{0} --- disables serial logging (default).
    \item \texttt{1} --- enables serial logging for \texttt{EXITBS:END} onwards.
    \item \texttt{1} --- enables serial logging for \texttt{EXITBS:START} onwards.
    \item \texttt{3} --- enables serial logging when debug protocol is missing.
    \item \texttt{4} --- enables serial logging unconditionally.
    \end{itemize}
  \item \texttt{timestamps=VALUE} --- enables timestamp logging.
    \begin{itemize}
    \item \texttt{0} --- disables timestamp logging.
    \item \texttt{1} --- enables timestamp logging (default).
    \end{itemize}
  \item \texttt{log=VALUE} --- deprecated starting from 10.15.
V
vit9696 已提交
3599 3600 3601 3602 3603 3604 3605
    \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}
V
vit9696 已提交
3606
  \item \texttt{debug=VALUE} --- deprecated starting from 10.15.
V
vit9696 已提交
3607 3608 3609 3610 3611 3612
  \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}
V
vit9696 已提交
3613 3614 3615
  \item \texttt{level=VALUE}  --- deprecated starting from 10.15. Verbosity level of
  DEBUG output. Everything but \texttt{0x80000000} is stripped from the binary,
  and this is the default value.
3616 3617
  \end{itemize}

3618 3619 3620 3621
  \emph{Note}: To see verbose output from \texttt{boot.efi} on modern macOS versions
  enable \texttt{AppleDebug} option. This will save the log to general OpenCore log.
  For versions before 10.15.4 set \texttt{bootercfg} to \texttt{log=1}. This will
  print verbose output onscreen.
V
vit9696 已提交
3622 3623 3624
\item \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:bootercfg-once}
  \break
  Booter arguments override removed after first launch. Otherwise equivalent to \texttt{bootercfg}.
3625 3626 3627 3628 3629 3630
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:efiboot-perf-record}
  \break
  Enable performance log saving in \texttt{boot.efi}. Performance log is saved to physical
  memory and is pointed by \texttt{efiboot-perf-record-data} and \texttt{efiboot-perf-record-size}
  variables. Starting from 10.15.4 it can also be saved to OpenCore log by \texttt{AppleDebug} option.
V
vit9696 已提交
3631 3632
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:fmm-computer-name}
3633 3634
  \break
  Current saved host name. ASCII string.
V
vit9696 已提交
3635 3636
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:nvda\_drv}
3637 3638 3639
  \break
  NVIDIA Web Driver control variable. Takes ASCII digit \texttt{1} or \texttt{0}
  to enable or disable installed driver.
3640 3641 3642 3643 3644 3645
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:run-efi-updater}
  \break
  Override EFI firmware updating support in macOS (MultiUpdater, ThorUtil, and so on).
  Setting this to \texttt{No} or alternative boolean-castable value will prevent
  any firmware updates in macOS starting with 10.10 at least.
3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:StartupMute}
  \break
  Mute startup chime sound in firmware audio support. 8-bit integer.
  The value of \texttt{0x00} means unmuted. Missing variable or any
  other value means muted. This variable only affects Gibraltar
  machines (T2).
\item
  \texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:SystemAudioVolume}
  \break
  System audio volume level for firmware audio support. 8-bit integer.
  The bit of \texttt{0x80} means muted. Lower bits are used to encode
  volume range specific to installed audio codec. The value is capped
  by \texttt{MaximumBootBeepVolume} AppleHDA layout value to avoid
  too loud audio playback in the firmware.
V
vit9696 已提交
3661 3662 3663 3664 3665 3666
\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
3667
base part of the configuration may be obtained from
V
vit9696 已提交
3668 3669
\href{https://github.com/acidanthera/OpenCorePkg/blob/master/AppleModels}{\texttt{AppleModels}},
which itself generates a set of interfaces based on a database
V
vit9696 已提交
3670 3671 3672 3673 3674 3675 3676 3677
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
V
vit9696 已提交
3678
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Intel/Protocol/DataHub.h}{Data
V
vit9696 已提交
3679 3680 3681 3682 3683 3684 3685
  Hub}
\item
  NVRAM
\end{itemize}

Most of the fields specify the overrides in SMBIOS, and their field
names conform to EDK2
3686
\href{https://github.com/acidanthera/audk/blob/master/MdePkg/Include/IndustryStandard/SmBios.h}{SmBios.h}
V
vit9696 已提交
3687 3688 3689 3690 3691 3692 3693
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 已提交
3694 3695 3696 3697
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 已提交
3698 3699 3700 3701 3702 3703
\subsection{Properties}\label{platforminfoprops}

\begin{enumerate}
\item
  \texttt{Automatic}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
3704
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
3705 3706 3707 3708 3709
  \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
A
Andrey1970AppleLife 已提交
3710 3711 3712 3713
  enough:
  \begin{itemize}
  \tightlist
  \item When enabled \texttt{SMBIOS}, \texttt{DataHub}, and
3714
  \texttt{PlatformNVRAM} data is unused.
A
Andrey1970AppleLife 已提交
3715 3716
  \item When disabled \texttt{Generic} section is unused.
  \end{itemize}
V
vit9696 已提交
3717 3718 3719
\item
  \texttt{UpdateDataHub}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
3720
  \textbf{Failsafe}: \texttt{false}\\
3721
  \textbf{Description}: Update Data Hub fields. These fields are read
V
vit9696 已提交
3722 3723 3724 3725 3726
  from \texttt{Generic} or \texttt{DataHub} sections depending on
  \texttt{Automatic} value.
\item
  \texttt{UpdateNVRAM}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
3727
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740
  \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}\\
3741
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
3742 3743 3744 3745 3746 3747
  \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}\\
3748
  \textbf{Failsafe}: \texttt{Create}\\
V
vit9696 已提交
3749 3750 3751 3752 3753
  \textbf{Description}: Update SMBIOS fields approach:

  \begin{itemize}
  \tightlist
  \item
3754
    \texttt{TryOverwrite} --- \texttt{Overwrite} if new size is \textless{}= than
V
vit9696 已提交
3755
    the page-aligned original and there are no issues with legacy region
3756
    unlock. \texttt{Create} otherwise. Has issues with some firmwares.
V
vit9696 已提交
3757 3758 3759 3760 3761 3762 3763 3764
  \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
3765 3766
    \texttt{Custom} --- Write SMBIOS tables
    (\texttt{gEfiSmbios(3)TableGuid}) to \texttt{gOcCustomSmbios(3)TableGuid}
V
vit9696 已提交
3767 3768 3769
    to workaround firmwares overwriting SMBIOS contents at
    ExitBootServices. Otherwise equivalent to \texttt{Create}. Requires
    patching AppleSmbios.kext and AppleACPIPlatform.kext to read from
3770 3771
    another GUID: \texttt{"EB9D2D31"} - \texttt{"EB9D2D35"} (in ASCII),
    done automatically by \texttt{CustomSMBIOSGuid} quirk.
V
vit9696 已提交
3772
  \end{itemize}
3773 3774 3775 3776 3777

  \emph{Note}: A side effect of using \texttt{Custom} approach is making
  SMBIOS updates exclusive to macOS, avoiding a collission with existing
  Windows activation and custom OEM software but potentially breaking
  Apple-specific tools.
V
vit9696 已提交
3778 3779 3780
\item
  \texttt{Generic}\\
  \textbf{Type}: \texttt{plist\ dictonary}\\
3781
  \textbf{Optional}: When \texttt{Automatic} is \texttt{false}\\
V
vit9696 已提交
3782 3783 3784 3785 3786
  \textbf{Description}: Update all fields. This section is read only
  when \texttt{Automatic} is active.
\item
  \texttt{DataHub}\\
  \textbf{Type}: \texttt{plist\ dictonary}\\
3787
  \textbf{Optional}: When \texttt{Automatic} is \texttt{true}\\
V
vit9696 已提交
3788 3789 3790 3791 3792
  \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}\\
3793
  \textbf{Optional}: When \texttt{Automatic} is \texttt{true}\\
V
vit9696 已提交
3794 3795 3796 3797 3798
  \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}\\
3799
  \textbf{Optional}: When \texttt{Automatic} is \texttt{true}\\
V
vit9696 已提交
3800 3801 3802 3803 3804 3805 3806
  \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}
3807 3808 3809
\item
  \texttt{SpoofVendor}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
3810
  \textbf{Failsafe}: \texttt{false}\\
3811 3812 3813 3814 3815
  \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 已提交
3816

3817
\item
3818
  \texttt{AdviseWindows}\\
3819 3820
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832
  \textbf{Description}: Forces Windows support in \texttt{FirmwareFeatures}.

  Added bits to \texttt{FirmwareFeatures}:

  \begin{itemize}
    \item \texttt{FW\_FEATURE\_SUPPORTS\_CSM\_LEGACY\_MODE} (\texttt{0x1})
    - Without this bit it is not possible to reboot to Windows installed on
      a drive with EFI partition being not the first partition on the disk.
    \item \texttt{FW\_FEATURE\_SUPPORTS\_UEFI\_WINDOWS\_BOOT} (\texttt{0x20000000})
    - Without this bit it is not possible to reboot to Windows installed on
      a drive with EFI partition being the first partition on the disk.
  \end{itemize}
3833

V
vit9696 已提交
3834 3835 3836
\item
  \texttt{SystemProductName}\\
  \textbf{Type}: \texttt{plist\ string}\\
3837
  \textbf{Failsafe}: \texttt{MacPro6,1}\\
V
vit9696 已提交
3838 3839 3840 3841
  \textbf{Description}: Refer to SMBIOS \texttt{SystemProductName}.
\item
  \texttt{SystemSerialNumber}\\
  \textbf{Type}: \texttt{plist\ string}\\
3842
  \textbf{Failsafe}: \texttt{OPENCORE\_SN1}\\
V
vit9696 已提交
3843 3844 3845 3846
  \textbf{Description}: Refer to SMBIOS \texttt{SystemSerialNumber}.
\item
  \texttt{SystemUUID}\\
  \textbf{Type}: \texttt{plist\ string}, GUID\\
3847
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
3848 3849 3850 3851
  \textbf{Description}: Refer to SMBIOS \texttt{SystemUUID}.
\item
  \texttt{MLB}\\
  \textbf{Type}: \texttt{plist\ string}\\
3852
  \textbf{Failsafe}: \texttt{OPENCORE\_MLB\_SN11}\\
V
vit9696 已提交
3853 3854 3855 3856
  \textbf{Description}: Refer to SMBIOS \texttt{BoardSerialNumber}.
\item
  \texttt{ROM}\\
  \textbf{Type}: \texttt{plist\ data}, 6 bytes\\
3857
  \textbf{Failsafe}: all zero\\
V
vit9696 已提交
3858 3859
  \textbf{Description}: Refer to
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ROM}.
3860

V
vit9696 已提交
3861 3862 3863 3864 3865 3866 3867 3868
\end{enumerate}

\subsection{DataHub Properties}\label{platforminfodatahub}

\begin{enumerate}
\item
  \texttt{PlatformName}\\
  \textbf{Type}: \texttt{plist\ string}\\
3869
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
3870 3871 3872 3873 3874 3875
  \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}\\
3876
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
3877 3878 3879 3880 3881 3882
  \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}\\
3883
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
3884 3885 3886 3887 3888 3889
  \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\\
3890
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
3891 3892 3893 3894 3895 3896
  \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}\\
3897
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
3898 3899 3900 3901 3902 3903
  \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\\
3904
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
3905 3906 3907 3908 3909 3910
  \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\\
3911
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964
  \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\\
3965
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
3966 3967 3968 3969 3970 3971
  \textbf{Description}: Sets \texttt{InitialTSC} in
  \texttt{gEfiProcessorSubClassGuid}. Sets initial TSC value, normally
  0.
\item
  \texttt{FSBFrequency}\\
  \textbf{Type}: \texttt{plist\ integer}, 64-bit\\
3972
  \textbf{Failsafe}: Automatic\\
V
vit9696 已提交
3973
  \textbf{Description}: Sets \texttt{FSBFrequency} in
3974 3975 3976 3977 3978 3979
  \texttt{gEfiProcessorSubClassGuid}.

  Sets CPU FSB frequency. This value equals to CPU nominal frequency divided
  by CPU maximum bus ratio and is specified in Hz. Refer to
  \texttt{MSR\_NEHALEM\_PLATFORM\_INFO}~(\texttt{CEh}) MSR value to determine
  maximum bus ratio on modern Intel CPUs.
3980

V
vit9696 已提交
3981 3982
  \emph{Note}: This value is not used on Skylake and newer but is still provided
  to follow suit.
V
vit9696 已提交
3983 3984 3985
\item
  \texttt{ARTFrequency}\\
  \textbf{Type}: \texttt{plist\ integer}, 64-bit\\
3986
  \textbf{Failsafe}: Automatic\\
V
vit9696 已提交
3987
  \textbf{Description}: Sets \texttt{ARTFrequency} in
3988
  \texttt{gEfiProcessorSubClassGuid}.
3989

3990 3991 3992 3993
  This value contains CPU ART frequency, also known as crystal clock frequency.
  Its existence is exclusive to Skylake generation and newer. The value is specified
  in Hz, and is normally 24 MHz for client Intel segment, 25 MHz for server Intel segment,
  and 19.2 MHz for Intel Atom CPUs. macOS till 10.15 inclusive assumes 24 MHz by default.
3994

3995 3996 3997
  \emph{Note}: On Intel Skylake X ART frequency may be a little less (approx. 0.25\%) than
  24 or 25 MHz due to special EMI-reduction circuit as described in
  \href{https://github.com/acidanthera/bugtracker/issues/448#issuecomment-524914166}{Acidanthera Bugtracker}.
V
vit9696 已提交
3998 3999
\item
  \texttt{DevicePathsSupported}\\
4000
  \textbf{Type}: \texttt{plist\ integer}, 32-bit\\
4001
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
4002
  \textbf{Description}: Sets \texttt{DevicePathsSupported} in
4003
  \texttt{gEfiMiscSubClassGuid}. Must be set to \texttt{1} for
4004 4005
  AppleACPIPlatform.kext to append SATA device paths to
  \texttt{Boot\#\#\#\#} and \texttt{efi-boot-device-data} variables.
4006
  Set to \texttt{1} on all modern Macs.
V
vit9696 已提交
4007 4008 4009
\item
  \texttt{SmcRevision}\\
  \textbf{Type}: \texttt{plist\ data}, 6 bytes\\
4010
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
4011 4012 4013 4014 4015 4016 4017
  \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\\
4018
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
4019 4020 4021 4022 4023 4024 4025
  \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\\
4026
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038
  \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}\\
4039
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
4040 4041 4042 4043 4044 4045
  \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\\
4046
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
4047
  \textbf{Description}: Specifies the values of NVRAM variables
V
vit9696 已提交
4048 4049 4050 4051 4052 4053
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:HW\_ROM} and
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ROM}.

\item
  \texttt{MLB}\\
  \textbf{Type}: \texttt{plist\ string}\\
4054
  \textbf{Failsafe}: Not installed\\
V
vit9696 已提交
4055 4056 4057 4058
  \textbf{Description}: Specifies the values of NVRAM variables
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:HW\_MLB} and
  \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:MLB}.

4059 4060 4061
\item
  \texttt{FirmwareFeatures}\\
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
4062
  \textbf{Failsafe}: Not installed\\
4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073
  \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\\
4074
  \textbf{Failsafe}: Not installed\\
4075 4076 4077 4078 4079 4080 4081 4082
  \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 已提交
4083 4084 4085 4086 4087 4088 4089 4090
\end{enumerate}

\subsection{SMBIOS Properties}\label{platforminfosmbios}

\begin{enumerate}
\item
  \texttt{BIOSVendor}\\
  \textbf{Type}: \texttt{plist\ string}\\
4091
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4092 4093 4094 4095 4096 4097
  \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}\\
4098
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4099 4100 4101 4102 4103 4104
  \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
V
vit9696 已提交
4105
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Apple/Guid/BiosId.h}{BiosId.h}.
V
vit9696 已提交
4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127
  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}\\
4128
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4129 4130 4131 4132 4133 4134
  \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}\\
4135
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4136 4137 4138 4139 4140 4141
  \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
V
vit9696 已提交
4142 4143
  plugins. In addition it will also make some operating systems
  like Linux unbootable.
V
vit9696 已提交
4144 4145 4146
\item
  \texttt{SystemProductName}\\
  \textbf{Type}: \texttt{plist\ string}\\
4147
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159
  \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
V
vit9696 已提交
4160
  \texttt{AppleModels}.
V
vit9696 已提交
4161 4162 4163
\item
  \texttt{SystemVersion}\\
  \textbf{Type}: \texttt{plist\ string}\\
4164
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4165 4166 4167 4168 4169 4170
  \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}\\
4171
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4172 4173 4174
  \textbf{SMBIOS}: System Information (Type 1) --- Serial Number\\
  \textbf{Description}: Product serial number in defined format. Known
  formats are described in
V
vit9696 已提交
4175
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Utilities/macserial/FORMAT.md}{macserial}.
V
vit9696 已提交
4176 4177 4178
\item
  \texttt{SystemUUID}\\
  \textbf{Type}: \texttt{plist\ string}, GUID\\
4179
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4180 4181 4182 4183 4184 4185 4186
  \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}\\
4187
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4188 4189 4190 4191 4192 4193 4194
  \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}\\
4195
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4196 4197 4198 4199 4200
  \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}\\
4201
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4202 4203 4204 4205 4206 4207 4208
  \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}\\
4209
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4210 4211 4212 4213 4214 4215 4216 4217
  \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}\\
4218
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4219 4220 4221 4222 4223 4224 4225
  \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}\\
4226
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4227 4228 4229 4230 4231 4232 4233 4234
  \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}\\
4235
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4236 4237 4238 4239 4240 4241 4242
  \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}\\
4243
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4244 4245 4246 4247 4248 4249 4250 4251
  \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}\\
4252
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4253 4254 4255 4256 4257 4258 4259
  \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}\\
4260
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4261 4262 4263 4264 4265 4266
  \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}\\
4267
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4268 4269 4270 4271 4272 4273
  \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}\\
4274
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4275 4276 4277 4278 4279
  \textbf{SMBIOS}: System Enclosure or Chassis (Type 3) --- Version\\
  \textbf{Description}: Should match \texttt{BoardProduct}.
\item
  \texttt{ChassisSerialNumber}\\
  \textbf{Type}: \texttt{plist\ string}\\
4280
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4281 4282 4283 4284 4285
  \textbf{SMBIOS}: System Enclosure or Chassis (Type 3) --- Version\\
  \textbf{Description}: Should match \texttt{SystemSerialNumber}.
\item
  \texttt{ChassisAssetTag}\\
  \textbf{Type}: \texttt{plist\ string}\\
4286
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4287 4288 4289 4290 4291 4292
  \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}\\
4293
  \textbf{Type}: \texttt{plist\ integer}, 32-bit\\
4294
  \textbf{Failsafe}: \texttt{0xFFFFFFFF}\\
V
vit9696 已提交
4295 4296 4297
  \textbf{SMBIOS}: \texttt{APPLE\_SMBIOS\_TABLE\_TYPE133} -
  \texttt{PlatformFeature}\\
  \textbf{Description}: Platform features bitmask. Refer to
V
vit9696 已提交
4298
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Apple/IndustryStandard/AppleFeatures.h}{AppleFeatures.h}
4299 4300 4301 4302
  for more details. Use \texttt{0xFFFFFFFF} value to not provide this table.
\item
  \texttt{SmcVersion}\\
  \textbf{Type}: \texttt{plist\ data}, 16 bytes\\
4303
  \textbf{Failsafe}: All zero\\
4304 4305 4306
  \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 已提交
4307 4308
\item
  \texttt{FirmwareFeatures}\\
V
vit9696 已提交
4309
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
4310
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
4311 4312 4313
  \textbf{SMBIOS}: \texttt{APPLE\_SMBIOS\_TABLE\_TYPE128} -
  \texttt{FirmwareFeatures} and \texttt{ExtendedFirmwareFeatures}\\
  \textbf{Description}: 64-bit firmware features bitmask. Refer to
V
vit9696 已提交
4314
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Apple/IndustryStandard/AppleFeatures.h}{AppleFeatures.h}
V
vit9696 已提交
4315 4316 4317 4318
  for more details. Lower 32 bits match \texttt{FirmwareFeatures}. Upper
  64 bits match \texttt{ExtendedFirmwareFeatures}.
\item
  \texttt{FirmwareFeaturesMask}\\
V
vit9696 已提交
4319
  \textbf{Type}: \texttt{plist\ data}, 8 bytes\\
4320
  \textbf{Failsafe}: \texttt{0}\\
V
vit9696 已提交
4321 4322 4323 4324 4325
  \textbf{SMBIOS}: \texttt{APPLE\_SMBIOS\_TABLE\_TYPE128} -
  \texttt{FirmwareFeaturesMask} and
  \texttt{ExtendedFirmwareFeaturesMask}\\
  \textbf{Description}: Supported bits of extended firmware features
  bitmask. Refer to
V
vit9696 已提交
4326
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Apple/IndustryStandard/AppleFeatures.h}{AppleFeatures.h}
V
vit9696 已提交
4327 4328 4329 4330 4331
  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\\
4332
  \textbf{Failsafe}: Automatic\\
V
vit9696 已提交
4333 4334 4335 4336 4337 4338
  \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\\
4339
  \textbf{Failsafe}: OEM specified\\
V
vit9696 已提交
4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351
  \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 已提交
4352 4353 4354
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 已提交
4355

V
vit9696 已提交
4356 4357 4358 4359 4360 4361
\subsection{Drivers}\label{uefidrivers}

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 are listed below:

V
vit9696 已提交
4362
\begin{tabular}{p{1.3in}p{5.55in}}
A
Andrey1970AppleLife 已提交
4363
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{AudioDxe}}\textbf{*}
V
vit9696 已提交
4364
& HDA audio support driver in UEFI firmwares for most Intel and some other analog audio controllers.
V
vit9696 已提交
4365
  Staging driver, refer to \href{https://github.com/acidanthera/bugtracker/issues/740}{acidanthera/bugtracker\#740}
V
vit9696 已提交
4366
  for known issues in AudioDxe. \\
4367 4368 4369 4370 4371
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{CrScreenshotDxe}}\textbf{*}
& Screenshot making driver saving images to the root of OpenCore partition (ESP) or
  any available writeable filesystem upon pressing \texttt{F10}.
  This is a modified version of \href{https://github.com/LongSoft/CrScreenshotDxe}{\texttt{CrScreenshotDxe}}
  driver by \href{https://github.com/NikolajSchlej}{Nikolaj Schlej}. \\
V
vit9696 已提交
4372 4373
\href{https://github.com/acidanthera/OcBinaryData}{\texttt{ExFatDxe}}
& Proprietary ExFAT file system driver for Bootcamp support commonly found in Apple
V
vit9696 已提交
4374
  firmwares. For Sandy Bridge and earlier CPUs \texttt{ExFatDxeLegacy} driver should be
V
vit9696 已提交
4375 4376 4377
  used due to the lack of \texttt{RDRAND} instruction support. \\
\href{https://github.com/acidanthera/OcBinaryData}{\texttt{HfsPlus}}
& Proprietary HFS file system driver with bless support commonly found in Apple
V
vit9696 已提交
4378
  firmwares. For Sandy Bridge and earlier CPUs \texttt{HfsPlusLegacy} driver should be
V
vit9696 已提交
4379 4380 4381
  used due to the lack of \texttt{RDRAND} instruction support. \\
\href{https://github.com/acidanthera/audk}{\texttt{HiiDatabase}}\textbf{*}
& HII services support driver from \texttt{MdeModulePkg}. This driver is included in
V
vit9696 已提交
4382
  most firmwares starting with Ivy Bridge generation. Some applications with the GUI
V
vit9696 已提交
4383 4384 4385
  like UEFI Shell may need this driver to work properly. \\
\href{https://github.com/acidanthera/audk}{\texttt{EnhancedFatDxe}}
& FAT filesystem driver from \texttt{FatPkg}. This driver is embedded in all
V
vit9696 已提交
4386 4387 4388
  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
V
vit9696 已提交
4389 4390 4391
  writing to EFI partition is needed during the boot process. \\
  \href{https://github.com/acidanthera/audk}{\texttt{NvmExpressDxe}}\textbf{*}
& NVMe support driver from \texttt{MdeModulePkg}. This driver is included in most
V
vit9696 已提交
4392
  firmwares starting with Broadwell generation. For Haswell and earlier embedding it
V
vit9696 已提交
4393 4394 4395 4396 4397 4398 4399
  within the firmware may be more favourable in case a NVMe SSD drive is installed. \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{OpenCanopy}}\textbf{*}
& \hyperref[ueficanopy]{OpenCore plugin} implementing graphical interface. \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{OpenRuntime}}\textbf{*}
& \hyperref[uefiruntime]{OpenCore plugin} implementing \texttt{OC\_FIRMWARE\_RUNTIME} protocol. \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{OpenUsbKbDxe}}\textbf{*}
& USB keyboard driver adding the support of \texttt{AppleKeyMapAggregator} protocols
V
vit9696 已提交
4400
  on top of a custom USB keyboard driver implementation. This is an alternative to
V
vit9696 已提交
4401
  builtin \texttt{KeySupport}, which may work better or worse depending on the firmware. \\
4402 4403 4404 4405 4406 4407
\href{https://github.com/acidanthera/OcBinaryData}{\texttt{PartitionDxe}}
& Proprietary partition management driver with Apple Partitioning Scheme support
  commonly found in Apple firmwares. This driver can be used to support loading
  older DMG recoveries such as macOS 10.9 using Apple Partitioning Scheme.
  For Sandy Bridge and earlier CPUs \texttt{PartitionDxeLegacy} driver should be
  used due to the lack of \texttt{RDRAND} instruction support. \\
4408
  \href{https://github.com/acidanthera/audk}{\texttt{Ps2KeyboardDxe}}\textbf{*}
V
vit9696 已提交
4409
& PS/2 keyboard driver from \texttt{MdeModulePkg}. \texttt{OpenDuetPkg} and some firmwares
4410 4411 4412
  may not include this driver, but it is necessary for PS/2 keyboard to work.
  Note, unlike \texttt{OpenUsbKbDxe} this driver has no \texttt{AppleKeyMapAggregator}
  support and thus requires \texttt{KeySupport} to be enabled. \\
4413 4414 4415 4416 4417 4418 4419 4420
  \href{https://github.com/acidanthera/audk}{\texttt{Ps2MouseDxe}}\textbf{*}
& PS/2 mouse driver from \texttt{MdeModulePkg}. Some very old laptop firmwares
  may not include this driver, but it is necessary for touchpad to work
  in UEFI graphical interfaces, such as \texttt{OpenCanopy}. \\
  \href{https://github.com/acidanthera/audk}{\texttt{UsbMouseDxe}}\textbf{*}
& USB mouse driver from \texttt{MdeModulePkg}. Some virtual machine firmwares
  like OVMF may not include this driver, but it is necessary for mouse to work
  in UEFI graphical interfaces, such as \texttt{OpenCanopy}. \\
4421
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{VBoxHfs}}
V
vit9696 已提交
4422
& HFS file system driver with bless support. This driver is an alternative to
V
vit9696 已提交
4423 4424
  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
V
vit9696 已提交
4425 4426 4427
  a security audit. \\
\href{https://github.com/acidanthera/audk}{\texttt{XhciDxe}}\textbf{*}
& XHCI USB controller support driver from \texttt{MdeModulePkg}. This driver is
V
vit9696 已提交
4428 4429
  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 已提交
4430
\end{tabular}
V
vit9696 已提交
4431

V
vit9696 已提交
4432
Driver marked with \textbf{*} are bundled with OpenCore.
V
vit9696 已提交
4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449
To compile the drivers from UDK (EDK II) use the same command you normally use
for OpenCore compilation, but choose a corresponding package:
\begin{lstlisting}[label=compileudk, style=ocbash]
git clone https://github.com/acidanthera/audk 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}

\subsection{Tools}\label{uefitools}

Standalone tools may help to debug firmware and hardware. Some of the known tools are listed below.
While some tools can be launched from within OpenCore many should be run separately either directly
or from \texttt{Shell}.

V
vit9696 已提交
4450
To boot into OpenShell or any other tool directly save \texttt{OpenShell.efi}
V
vit9696 已提交
4451 4452 4453 4454 4455 4456 4457 4458 4459
under the name of \texttt{EFI\textbackslash BOOT\textbackslash BOOTX64.EFI}
on a FAT32 partition. In general it is unimportant whether the partitition scheme
is \texttt{GPT} or \texttt{MBR}.

While the previous approach works both on Macs and other computers,
an alternative Mac-only approach to bless the tool on an HFS+ or APFS
volume:

\begin{lstlisting}[caption=Blessing tool, label=blesstool, style=ocbash]
V
vit9696 已提交
4460
sudo bless --verbose --file /Volumes/VOLNAME/DIR/OpenShell.efi \
V
vit9696 已提交
4461 4462 4463 4464 4465 4466 4467 4468 4469 4470
  --folder /Volumes/VOLNAME/DIR/ --setBoot
\end{lstlisting}

\emph{Note 1}: You may have to copy \texttt{/System/Library/CoreServices/BridgeVersion.bin}
  to \texttt{/Volumes/VOLNAME/DIR}. \\
\emph{Note 2}: To be able to use \texttt{bless} you may have to
  \href{https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/ConfiguringSystemIntegrityProtection/ConfiguringSystemIntegrityProtection.html}{disable System Integrity Protection}. \\
\emph{Note 3}: To be able to boot you may have to \href{https://support.apple.com/HT208330}{disable Secure Boot}
  if present.

V
vit9696 已提交
4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496
Some of the known tools are listed below (builtin tools are marked with \textbf{*}):

\begin{tabular}{p{1.3in}p{5.55in}}
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{BootKicker}}\textbf{*}
& Enter Apple BootPicker menu (exclusive for Macs with compatible GPUs). \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{ChipTune}}\textbf{*}
& Test BeepGen protocol and generate audio signals of different style and length. \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{CleanNvram}}\textbf{*}
& Reset NVRAM alternative bundled as a standalone tool. \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{GopStop}}\textbf{*}
& Test GraphicsOutput protocol with a
  \href{https://github.com/acidanthera/OpenCorePkg/tree/master/Application/GopStop}{simple scenario}. \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{HdaCodecDump}}\textbf{*}
& Parse and dump High Definition Audio codec information (requires \texttt{AudioDxe}). \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{KeyTester}}\textbf{*}
& Test keyboard input in \texttt{SimpleText} mode. \\
\href{https://www.memtest86.com}{\texttt{MemTest86}}
& Memory testing utility. \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{OpenControl}}\textbf{*}
& Unlock and lock back NVRAM protection for other tools to be able to get full NVRAM access
  when launching from OpenCore. \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{OpenShell}}\textbf{*}
& OpenCore-configured \href{http://github.com/tianocore/edk2}{\texttt{UEFI Shell}} for compatibility
  with a broad range of firmwares. \\
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{PavpProvision}}
& Perform EPID provisioning (requires certificate data configuration). \\
V
vit9696 已提交
4497 4498
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{ResetSystem}}\textbf{*}
& Utility to perform system reset. Takes reset type as an argument:
V
vit9696 已提交
4499 4500
  \texttt{ColdReset}, \texttt{Firmware}, \texttt{Shutdown}, \texttt{WarmReset}.
  Defaults to \texttt{ColdReset}. \\
V
vit9696 已提交
4501 4502
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{RtcRw}}\textbf{*}
& Utility to read and write RTC (CMOS) memory. \\
V
vit9696 已提交
4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515
\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{VerifyMsrE2}}\textbf{*}
& Check \texttt{CFG Lock} (MSR \texttt{0xE2} write protection) consistency across all cores.
\end{tabular}

\subsection{OpenCanopy}\label{ueficanopy}

OpenCanopy is a graphical OpenCore user interface that runs in
\texttt{External} \texttt{PickerMode} and relies on
\href{https://github.com/acidanthera/OpenCorePkg}{OpenCorePkg} \texttt{OcBootManagementLib}
similar to the builtin text interface.

OpenCanopy requires graphical resources located in \texttt{Resources} directory to run.
Sample resources (fonts and images) can be found in
4516
\href{https://github.com/acidanthera/OcBinaryData}{OcBinaryData repository}. You can find customised icons over the internet 
A
Andrey1970AppleLife 已提交
4517
(e.g. \href{https://github.com/blackosx/OpenCanopyIcons}{here} or \href{https://applelife.ru/threads/kastomizacija-opencanopy.2945020/}{there}).
V
vit9696 已提交
4518

4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563
OpenCanopy provides full support for \texttt{PickerAttributes} and offers a configurable
builtin icon set. The default chosen icon set depends on the \texttt{DefaultBackgroundColor}
variable value. For Light Gray \texttt{Old} icon set will be used, for other colours ---
the one without a prefix.

Predefined icons are put to \texttt{\textbackslash EFI\textbackslash OC\textbackslash Resources\textbackslash Image}
directory. Full list of supported icons (in \texttt{.icns} format) is provided below. Missing optional
icons will use the closest available icon. External entries will use \texttt{Ext}-prefixed
icon if available (e.g. \texttt{OldExtHardDrive.icns}).

\begin{itemize}
\tightlist
  \item \texttt{Cursor} --- Mouse cursor (mandatory).
  \item \texttt{Selected} --- Selected item (mandatory).
  \item \texttt{Selector} --- Selecting item (mandatory).
  \item \texttt{HardDrive} --- Generic OS (mandatory).
  \item \texttt{Apple} --- Apple OS.
  \item \texttt{AppleRecv} --- Apple Recovery OS.
  \item \texttt{AppleTM} --- Apple Time Machine.
  \item \texttt{Windows} --- Windows.
  \item \texttt{Other} --- Custom entry (see \texttt{Entries}).
  \item \texttt{ResetNVRAM} --- Reset NVRAM system action or tool.
  \item \texttt{Shell} --- Entry with UEFI Shell name (e.g. \texttt{OpenShell}).
  \item \texttt{Tool} --- Any other tool.
\end{itemize}

Predefined labels are put to \texttt{\textbackslash EFI\textbackslash OC\textbackslash Resources\textbackslash Label}
directory. Each label has \texttt{.lbl} or \texttt{.l2x} suffix to represent the scaling level.
Full list of labels is provided below. All labels are mandatory.

\begin{itemize}
\tightlist
  \item \texttt{EFIBoot} --- Generic OS.
  \item \texttt{Apple} --- Apple OS.
  \item \texttt{AppleRecv} --- Apple Recovery OS.
  \item \texttt{AppleTM} --- Apple Time Machine.
  \item \texttt{Windows} --- Windows.
  \item \texttt{Other} --- Custom entry (see \texttt{Entries}).
  \item \texttt{ResetNVRAM} --- Reset NVRAM system action or tool.
  \item \texttt{Shell} --- Entry with UEFI Shell name (e.g. \texttt{OpenShell}).
  \item \texttt{Tool} --- Any other tool.
\end{itemize}

Label and icon generation can be performed with bundled utilities: \texttt{disklabel} and
\texttt{icnspack}. Please refer to sample data for the details about the dimensions.
4564 4565 4566 4567 4568 4569 4570
Font is Helvetica 12 pt times scale factor.

Font format corresponds to \href{https://www.angelcode.com/products/bmfont}{AngelCode binary BMF}.
While there are many utilities to generate font files, currently it is recommended to use
\href{https://github.com/danpla/dpfontbaker}{dpFontBaker} to generate bitmap font
(\href{https://github.com/danpla/dpfontbaker/pull/1}{using CoreText produces best results})
and \href{https://github.com/usr-sse2/fonverter}{fonverter} to export it to binary format.
4571 4572

\emph{WARNING}: OpenCanopy is currently considered experimental and is not recommended for
V
vit9696 已提交
4573 4574 4575 4576 4577 4578 4579 4580 4581 4582
everyday use. Refer to
\href{https://github.com/acidanthera/bugtracker/issues/759}{acidanthera/bugtracker\#759}
for more details regarding the current limitations.

\subsection{OpenRuntime}\label{uefiruntime}

\texttt{OpenRuntime} is an OpenCore plugin implementing \texttt{OC\_FIRMWARE\_RUNTIME} protocol.
This protocol implements multiple features required for OpenCore that are otherwise not possible
to implement in OpenCore itself as they are needed to work in runtime, i.e. during operating system
functioning. Feature highlights:
V
vit9696 已提交
4583 4584

\begin{itemize}
V
vit9696 已提交
4585 4586 4587 4588 4589 4590 4591 4592
  \item NVRAM namespaces, allowing to isolate operating systems from accessing select
  variables (e.g. \texttt{RequestBootVarRouting} or \texttt{ProtectSecureBoot}).
  \item Read-only and write-only NVRAM variables, enhancing the security of OpenCore,
  Lilu, and Lilu plugins, like VirtualSMC, which implements \texttt{AuthRestart} support.
  \item NVRAM isolation, allowing to protect all variables from being written from
  an untrusted operating system (e.g. \texttt{DisableVariableWrite}).
  \item UEFI Runtime Services memory protection management to workaround read-only
  mapping (e.g. \texttt{EnableWriteUnprotector}).
V
vit9696 已提交
4593 4594
\end{itemize}

V
vit9696 已提交
4595 4596 4597
\subsection{Properties}\label{uefiprops}

\begin{enumerate}
V
vit9696 已提交
4598 4599 4600 4601 4602 4603 4604
\item
  \texttt{APFS}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Failsafe}: None\\
  \textbf{Description}: Provide APFS support as configured in
  \hyperref[uefiapfsprops]{APFS Properties} section below.

4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629
\item
  \texttt{Audio}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Failsafe}: None\\
  \textbf{Description}: Configure audio backend support described
  in \hyperref[uefiaudioprops]{Audio Properties} section below.

  Audio support provides a way for upstream protocols to interact with the
  selected hardware and audio resources. All audio resources should reside
  in \texttt{\textbackslash EFI\textbackslash OC\textbackslash Resources\textbackslash Audio}
  directory. Currently the only supported audio file format is WAVE PCM. While it is
  driver-dependent which audio stream format is supported, most common audio cards
  support 16-bit signed stereo audio at 44100 or 48000 Hz.

  Audio file path is determined by audio type, audio localisation, and audio path. Each filename
  looks as follows: \texttt{[audio type]\_[audio localisation]\_[audio path].wav}. For unlocalised
  files filename does not include the language code and looks as follows:
  \texttt{[audio type]\_[audio path].wav}.

  \begin{itemize}
  \tightlist
  \item Audio type can be \texttt{OCEFIAudio} for OpenCore audio files or
    \texttt{AXEFIAudio} for macOS bootloader audio files.
  \item Audio localisation is a two letter language code (e.g. \texttt{en})
  with an exception for Chinese, Spanish, and Portuguese. Refer to
V
vit9696 已提交
4630
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Apple/Protocol/AppleVoiceOver.h}{\texttt{APPLE\_VOICE\_OVER\_LANGUAGE\_CODE} definition}
4631 4632
  for the list of all supported localisations.
  \item Audio path is the base filename corresponding to a file identifier. For macOS bootloader audio paths refer to
V
vit9696 已提交
4633
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Apple/Protocol/AppleVoiceOver.h}{\texttt{APPLE\_VOICE\_OVER\_AUDIO\_FILE} definition}.
4634
  For OpenCore audio paths refer to
R
ryan 已提交
4635
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Acidanthera/Protocol/OcAudio.h}{\texttt{OC\_VOICE\_OVER\_AUDIO\_FILE} definition}.
4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646
  The only exception is OpenCore boot chime file, which is \texttt{OCEFIAudio\_VoiceOver\_Boot.wav}.
  \end{itemize}

  Audio localisation is determined separately for macOS bootloader and OpenCore.
  For macOS bootloader it is set in \texttt{preferences.efires} archive in
  \texttt{systemLanguage.utf8} file and is controlled by the operating system.
  For OpenCore the value of \texttt{prev-lang:kbd} variable is used.
  When native audio localisation of a particular file is missing, English language
  (\texttt{en}) localisation is used. Sample audio files can be found in
  \href{https://github.com/acidanthera/OcBinaryData}{OcBinaryData repository}.

V
vit9696 已提交
4647 4648 4649
\item
  \texttt{ConnectDrivers}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
4650
  \textbf{Failsafe}: \texttt{false}\\
4651 4652
  \textbf{Description}: Perform UEFI controller connection after driver loading.

4653 4654 4655 4656
  This option is useful for loading drivers following UEFI driver model
  as they may not start by themselves. Examples of such drivers are filesystem
  or audio drivers. While effective, this option may not be necessary for drivers
  performing automatic connection, and may slightly slowdown the boot.
V
vit9696 已提交
4657

4658 4659 4660 4661
  \emph{Note}: Some firmwares, made by Apple in particular, only connect the boot
  drive to speedup the boot process. Enable this option to be able to see all the
  boot options when having multiple drives.

V
vit9696 已提交
4662 4663 4664
\item
  \texttt{Drivers}\\
  \textbf{Type}: \texttt{plist\ array}\\
4665
  \textbf{Failsafe}: None\\
V
vit9696 已提交
4666 4667 4668 4669
  \textbf{Description}: Load selected drivers from \texttt{OC/Drivers}
  directory.

  Designed to be filled with string filenames meant to be loaded as UEFI
V
vit9696 已提交
4670
  drivers.
4671

V
vit9696 已提交
4672 4673 4674 4675 4676 4677 4678
\item
  \texttt{Input}\\
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Failsafe}: None\\
  \textbf{Description}: Apply individual settings designed for input (keyboard and mouse) in
  \hyperref[uefiinputprops]{Input Properties} section below.

4679
\item
4680
  \texttt{Output}\\
4681 4682 4683 4684
  \textbf{Type}: \texttt{plist\ dict}\\
  \textbf{Failsafe}: None\\
  \textbf{Description}: Apply individual settings designed for output (text and graphics) in
  \hyperref[uefioutputprops]{Output Properties} section below.
V
vit9696 已提交
4685

4686
\item
4687
  \texttt{ProtocolOverrides}\\
4688
  \textbf{Type}: \texttt{plist\ dict}\\
4689
  \textbf{Failsafe}: None\\
4690
  \textbf{Description}: Force builtin versions of select protocols described
4691
  in \hyperref[uefiprotoprops]{ProtocolOverrides Properties} section below.
4692

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

V
vit9696 已提交
4695 4696 4697
\item
  \texttt{Quirks}\\
  \textbf{Type}: \texttt{plist\ dict}\\
4698
  \textbf{Failsafe}: None\\
V
vit9696 已提交
4699 4700 4701
  \textbf{Description}: Apply individual firmware quirks described in
  \hyperref[uefiquirkprops]{Quirks Properties} section below.

4702 4703 4704 4705 4706 4707 4708 4709 4710
\item
  \texttt{ReservedMemory}\\
  \textbf{Type}: \texttt{plist\ array}\\
  \textbf{Description}: Designed to be filled with \texttt{plist\ dict} values,
  describing memory areas exquisite to particular firmware and hardware functioning,
  which should not be used by the operating system. An example of such memory region
  could be second 256 MB corrupted by Intel HD 3000 or an area with faulty RAM.
  See \hyperref[uefirsvdprops]{ReservedMemory Properties} section below.

V
vit9696 已提交
4711 4712
\end{enumerate}

V
vit9696 已提交
4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727
\subsection{APFS Properties}\label{uefiapfsprops}

\begin{enumerate}

\item
  \texttt{EnableJumpstart}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Load embedded APFS drivers from APFS containers.

  APFS EFI driver is bundled in all bootable APFS containers. This
  option performs loading of signed APFS drivers with respect to
  \texttt{ScanPolicy}. See more details in ``EFI Jumpstart'' section of
  \href{https://developer.apple.com/support/apple-file-system/Apple-File-System-Reference.pdf}{Apple File System Reference}.

4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739

\item
  \texttt{GlobalConnect}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Perform full device connection during APFS loading.

  Instead of partition handle connection normally used for APFS driver loading
  every handle is connected recursively. This may take more time than usual
  but can be the only way to access APFS partitions on some firmwares like
  those found on older HP laptops.

V
vit9696 已提交
4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772
\item
  \texttt{HideVerbose}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Hide verbose output from APFS driver.

  APFS verbose output can be useful for debugging.

\item
  \texttt{JumpstartHotPlug}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Load APFS drivers for newly connected devices.

  Performs APFS driver loading not only at OpenCore startup but also
  during boot picker. This permits APFS USB hot plug. Disable if not
  required.

\item
  \texttt{MinDate}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Minimal allowed APFS driver date.

  APFS driver date connects APFS driver with the calendar
  release date. Older versions of APFS drivers may contain unpatched
  vulnerabilities, which can be used to inflict harm on your computer.
  This option permits restricting APFS drivers to only recent releases.

  \begin{itemize}
    \tightlist
    \item \texttt{0} --- require the default supported release date of APFS
    in OpenCore. The default release date will increase with time and thus
4773
    this setting is recommended. Currently set to 2018/06/21.
V
vit9696 已提交
4774 4775 4776
    \item \texttt{-1} --- permit any release date to load (strongly discouraged).
    \item Other --- use custom minimal APFS release date, e.g. \texttt{20200401}
    for 2020/04/01. APFS release dates can be found in OpenCore boot log
R
ryan 已提交
4777
    and \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Acidanthera/Library/OcApfsLib.h}{\texttt{OcApfsLib}}.
V
vit9696 已提交
4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796
  \end{itemize}

\item
  \texttt{MinVersion}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Minimal allowed APFS driver version.

  APFS driver version connects APFS driver with the macOS
  release. APFS drivers from older macOS releases will become
  unsupported and thus may contain unpatched vulnerabilities, which
  can be used to inflict harm on your computer. This option permits
  restricting APFS drivers to only modern macOS versions.

  \begin{itemize}
    \tightlist
    \item \texttt{0} --- require the default supported version of APFS
    in OpenCore. The default version will increase with time and thus
    this setting is recommended. Currently set to the latest point release
4797
    from High Sierra from App Store (\texttt{748077008000000}).
V
vit9696 已提交
4798 4799 4800
    \item \texttt{-1} --- permit any version to load (strongly discouraged).
    \item Other --- use custom minimal APFS version, e.g. \texttt{1412101001000000}
    from macOS Catalina 10.15.4. APFS versions can be found in OpenCore boot log
R
ryan 已提交
4801
    and \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Include/Acidanthera/Library/OcApfsLib.h}{\texttt{OcApfsLib}}.
V
vit9696 已提交
4802 4803 4804 4805
  \end{itemize}

\end{enumerate}

4806 4807 4808 4809 4810 4811 4812 4813

\subsection{Audio Properties}\label{uefiaudioprops}

\begin{enumerate}

\item
  \texttt{AudioCodec}\\
  \textbf{Type}: \texttt{plist\ integer}\\
A
Andrey1970AppleLife 已提交
4814
  \textbf{Failsafe}: \texttt{0}\\
4815 4816 4817
  \textbf{Description}: Codec address on the specified audio controller for audio support.

  Normally this contains first audio codec address on the builtin analog audio controller (\texttt{HDEF}).
V
vit9696 已提交
4818
  Audio codec addresses, e.g. \texttt{2}, can be found in the debug log (marked in bold-italic):
4819

V
vit9696 已提交
4820 4821 4822
  \texttt{OCAU: 1/3 PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x1)/VenMsg(<redacted>,\textit{\textbf{00000000}}) (4 outputs)}\\
  \texttt{OCAU: 2/3 PciRoot(0x0)/Pci(0x3,0x0)/VenMsg(<redacted>,\textit{\textbf{00000000}}) (1 outputs)}\\
  \texttt{OCAU: 3/3 PciRoot(0x0)/Pci(0x1B,0x0)/VenMsg(<redacted>,\textit{\textbf{02000000}}) (7 outputs)}
4823 4824 4825 4826 4827 4828 4829

  As an alternative this value can be obtained from \texttt{IOHDACodecDevice} class in I/O Registry
  containing it in \texttt{IOHDACodecAddress} field.

\item
  \texttt{AudioDevice}\\
  \textbf{Type}: \texttt{plist\ string}\\
A
Andrey1970AppleLife 已提交
4830
  \textbf{Failsafe}: empty string\\
4831 4832 4833 4834
  \textbf{Description}: Device path of the specified audio controller for audio support.

  Normally this contains builtin analog audio controller (\texttt{HDEF}) device path,
  e.g. \texttt{PciRoot(0x0)/Pci(0x1b,0x0)}. The list of recognised audio controllers can be
V
vit9696 已提交
4835
  found in the debug log (marked in bold-italic):
4836

V
vit9696 已提交
4837 4838 4839
  \texttt{OCAU: 1/3 \textit{\textbf{PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x1)}}/VenMsg(<redacted>,00000000) (4 outputs)}\\
  \texttt{OCAU: 2/3 \textit{\textbf{PciRoot(0x0)/Pci(0x3,0x0)}}/VenMsg(<redacted>,00000000) (1 outputs)}\\
  \texttt{OCAU: 3/3 \textit{\textbf{PciRoot(0x0)/Pci(0x1B,0x0)}}/VenMsg(<redacted>,02000000) (7 outputs)}
4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850

  As an alternative \texttt{gfxutil -f HDEF} command can be used in macOS. Specifying empty device
  path will result in the first available audio controller to be used.

\item
  \texttt{AudioOut}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Index of the output port of the specified codec starting from 0.

  Normally this contains the index of the green out of the builtin analog audio controller (\texttt{HDEF}).
V
vit9696 已提交
4851
  The number of output nodes (\texttt{N}) in the debug log (marked in bold-italic):
4852

V
vit9696 已提交
4853 4854 4855
  \texttt{OCAU: 1/3 PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x1)/VenMsg(<redacted>,00000000) (\textit{\textbf{4 outputs}})}\\
  \texttt{OCAU: 2/3 PciRoot(0x0)/Pci(0x3,0x0)/VenMsg(<redacted>,00000000) (\textit{\textbf{1 outputs}})}\\
  \texttt{OCAU: 3/3 PciRoot(0x0)/Pci(0x1B,0x0)/VenMsg(<redacted>,02000000) (\textit{\textbf{7 outputs}})}
V
vit9696 已提交
4856 4857

  The quickest way to find the right port is to bruteforce the values from \texttt{0} to \texttt{N - 1}.
4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909

\item
  \texttt{AudioSupport}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Activate audio support by connecting to a backend driver.

  Enabling this setting routes audio playback from builtin protocols to a dedicated
  audio port (\texttt{AudioOut}) of the specified codec (\texttt{AudioCodec}) located
  on the audio controller (\texttt{AudioDevice}).

\item
  \texttt{MinimumVolume}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Minimal heard volume level from \texttt{0} to \texttt{100}.

  Screen reader will use this volume level, when the calculated volume level is
  less than \texttt{MinimumVolume}. Boot chime sound will not play if the calculated
  volume level is less than \texttt{MinimumVolume}.

\item
  \texttt{PlayChime}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Play chime sound at startup.

  Enabling this setting plays boot chime through builtin audio support. Volume level
  is determined by \texttt{MinimumVolume} and \texttt{VolumeAmplifier} settings and
  \texttt{SystemAudioVolume} NVRAM variable.

  \emph{Note}: this setting is separate from \texttt{StartupMute} NVRAM variable
  to avoid conflicts when the firmware is able to play boot chime.

\item
  \texttt{VolumeAmplifier}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Multiplication coefficient for system volume to raw volume linear translation
  from \texttt{0} to \texttt{1000}.

  Volume level range read from \texttt{SystemAudioVolume} varies depending on the codec.
  To transform read value in \texttt{[0, 127]} range into raw volume range \texttt{[0, 100]}
  the read value is scaled to \texttt{VolumeAmplifier} percents:
  \begin{align*}
      RawVolume &= MIN(\frac{SystemAudioVolume * VolumeAmplifier}{100}, 100)
  \end{align*}
  \emph{Note}: the transformation used in macOS is not linear, but it is very close
  and this nuance is thus ignored.

\end{enumerate}

V
vit9696 已提交
4910 4911 4912 4913
\subsection{Input Properties}\label{uefiinputprops}

\begin{enumerate}

4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924
\item
  \texttt{KeyFiltering}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Enable keyboard input sanity checking.

  Apparently some boards like GA Z77P-D3 may return uninitialised data
  in \texttt{EFI\_INPUT\_KEY} with all input protocols.
  This option discards keys that are neither ASCII, nor are defined
  in the UEFI specification (see tables 107 and 108 in version 2.8).

V
vit9696 已提交
4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936
\item
  \texttt{KeyForgetThreshold}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Remove key unless it was submitted during this timeout in milliseconds.

  \texttt{AppleKeyMapAggregator} protocol is supposed to contain a fixed length buffer
  of currently pressed keys. However, the majority of the drivers only report key
  presses as interrupts and pressing and holding the key on the keyboard results in
  subsequent submissions of this key with some defined time interval. As a result
  we use a timeout to remove once pressed keys from the buffer once the timeout
  expires and no new submission of this key happened.
4937

V
vit9696 已提交
4938 4939 4940 4941 4942 4943 4944
  This option allows to set this timeout based on your platform. The recommended
  value that works on the majority of the platforms is \texttt{5} milliseconds.
  For reference, holding one key on VMware will repeat it roughly every \texttt{2}
  milliseconds and the same value for APTIO V is \texttt{3-4} milliseconds. Thus
  it is possible to set a slightly lower value on faster platforms
  and slightly higher value on slower platforms for more responsive input.

4945 4946 4947 4948 4949 4950
  \emph{Note}: Some platforms may require different values, higher or lower.
  For example, when detecting key misses in OpenCanopy try increasing this value
  (e.g. to \texttt{10}), and when detecting key stall, try decreasing this value.
  Since every platform is different it may be reasonable to check every value
  from \texttt{1} to \texttt{25}.

V
vit9696 已提交
4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976
\item
  \texttt{KeyMergeThreshold}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Assume simultaneous combination for keys submitted within
  this timeout in milliseconds.

  Similarly to \texttt{KeyForgetThreshold}, this option works around the sequential
  nature of key submission. To be able to recognise simultaneously pressed keys
  in the situation when all keys arrive sequentially, we are required to set
  a timeout within which we assume the keys were pressed together.

  Holding multiple keys results in reports every \texttt{2} and \texttt{1} milliseconds
  for VMware and APTIO V respectively. Pressing keys one after the other results in
  delays of at least \texttt{6} and \texttt{10} milliseconds for the same platforms.
  The recommended value for this option is \texttt{2} milliseconds, but it may be
  decreased for faster platforms and increased for slower.

\item
  \texttt{KeySupport}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Enable internal keyboard input translation to
  \texttt{AppleKeyMapAggregator} protocol.

  This option activates the internal keyboard interceptor driver, based on
M
Typo  
Michael Belyaev 已提交
4977
  \texttt{AppleGenericInput} aka (\texttt{AptioInputFix}), to fill
V
vit9696 已提交
4978
  \texttt{AppleKeyMapAggregator} database for input functioning. In case
V
vit9696 已提交
4979
  a separate driver is used, such as \texttt{OpenUsbKbDxe}, this option
V
vit9696 已提交
4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996
  should never be enabled.

\item
  \texttt{KeySupportMode}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: empty string\\
  \textbf{Description}: Set internal keyboard input translation to
  \texttt{AppleKeyMapAggregator} protocol mode.

  \begin{itemize}
  \tightlist
  \item \texttt{Auto} --- Performs automatic choice as available with the following preference: \texttt{AMI}, \texttt{V2}, \texttt{V1}.
  \item \texttt{V1} --- Uses UEFI standard legacy input protocol \texttt{EFI\_SIMPLE\_TEXT\_INPUT\_PROTOCOL}.
  \item \texttt{V2} --- Uses UEFI standard modern input protocol \texttt{EFI\_SIMPLE\_TEXT\_INPUT\_EX\_PROTOCOL}.
  \item \texttt{AMI} --- Uses APTIO input protocol \texttt{AMI\_EFIKEYCODE\_PROTOCOL}.
  \end{itemize}

4997 4998 4999
  \emph{Note}: Currently \texttt{V1}, \texttt{V2}, and \texttt{AMI} unlike \texttt{Auto} only do filtering of
  the particular specified protocol. This may change in the future versions.

V
vit9696 已提交
5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037
\item
  \texttt{KeySwap}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Swap \texttt{Command} and \texttt{Option} keys during submission.

  This option may be useful for keyboard layouts with \texttt{Option} key situated to the right
  of \texttt{Command} key.

\item
  \texttt{PointerSupport}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Enable internal pointer driver.

  This option implements standard UEFI pointer protocol (\texttt{EFI\_SIMPLE\_POINTER\_PROTOCOL})
  through select OEM protocols. The option may be useful on Z87 ASUS boards, where
  \texttt{EFI\_SIMPLE\_POINTER\_PROTOCOL} is broken.

\item
  \texttt{PointerSupportMode}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: empty string\\
  \textbf{Description}: Set OEM protocol used for internal pointer driver.

  Currently the only supported variant is \texttt{ASUS}, using specialised protocol available
  on select Z87 and Z97 ASUS boards. More details can be found in
  \href{https://github.com/LongSoft/UEFITool/pull/116}{\texttt{LongSoft/UefiTool\#116}}.

\item
  \texttt{TimerResolution}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Set architecture timer resolution.

  This option allows to update firmware architecture timer period with the specified value
  in \texttt{100} nanosecond units. Setting a lower value generally improves performance
  and responsiveness of the interface and input handling.
5038

V
vit9696 已提交
5039 5040 5041
  The recommended value is \texttt{50000} (\texttt{5} milliseconds) or slightly higher. Select
  ASUS Z87 boards use \texttt{60000} for the interface. Apple boards use \texttt{100000}.
  You may leave it as \texttt{0} in case there are issues.
V
vit9696 已提交
5042 5043 5044

\end{enumerate}

5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088
\subsection{Output Properties}\label{uefioutputprops}

\begin{enumerate}

\item
  \texttt{TextRenderer}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: \texttt{BuiltinGraphics}\\
  \textbf{Description}: Chooses renderer for text going through standard
  console output.

  Currently two renderers are supported: \texttt{Builtin} and
  \texttt{System}. \texttt{System} renderer uses firmware services
  for text rendering. \texttt{Builtin} bypassing firmware services
  and performs text rendering on its own. Different renderers support
  a different set of options. It is recommended to use \texttt{Builtin}
  renderer, as it supports HiDPI mode and uses full screen resolution.

  UEFI firmwares generally support \texttt{ConsoleControl} with two
  rendering modes: \texttt{Graphics} and \texttt{Text}. Some firmwares
  do not support \texttt{ConsoleControl} and rendering modes. OpenCore
  and macOS expect text to only be shown in \texttt{Graphics} mode and
  graphics to be drawn in any mode. Since this is not required by UEFI
  specification, exact behaviour varies.

  Valid values are combinations of text renderer and rendering mode:

  \begin{itemize}
  \tightlist
  \item \texttt{BuiltinGraphics} --- Switch to \texttt{Graphics}
    mode and use \texttt{Builtin} renderer with
    custom \texttt{ConsoleControl}.
  \item \texttt{SystemGraphics} --- Switch to \texttt{Graphics}
    mode and use \texttt{System} renderer with
    custom \texttt{ConsoleControl}.
  \item \texttt{SystemText} --- Switch to \texttt{Text}
    mode and use \texttt{System} renderer with
    custom \texttt{ConsoleControl}.
  \item \texttt{SystemGeneric} --- Use \texttt{System} renderer with
    system \texttt{ConsoleControl} assuming it behaves correctly.
  \end{itemize}

  The use of \texttt{BuiltinGraphics} is generally straightforward.
  For most platforms it is necessary to enable \texttt{ProvideConsoleGop},
5089
  set \texttt{Resolution} to \texttt{Max}.
5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133

  The use of \texttt{System} protocols is more complicated. In general
  the preferred setting is \texttt{SystemGraphics} or \texttt{SystemText}.
  Enabling \texttt{ProvideConsoleGop}, setting \texttt{Resolution} to
  \texttt{Max}, enabling \texttt{ReplaceTabWithSpace} is useful on almost
  all platforms. \texttt{SanitiseClearScreen}, \texttt{IgnoreTextInGraphics},
  and \texttt{ClearScreenOnModeSwitch} are more specific, and their use
  depends on the firmware.

  \emph{Note}: Some Macs, namely \texttt{MacPro5,1}, may have broken
  console output with newer GPUs, and thus only \texttt{BuiltinGraphics}
  may work for them.

\item
  \texttt{ConsoleMode}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: Empty string\\
  \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. Currently
  \texttt{Builtin} text renderer supports only one console mode, so
  this option is ignored.

  \emph{Note}: This field is best to be left empty on most firmwares.

\item
  \texttt{Resolution}\\
  \textbf{Type}: \texttt{plist\ string}\\
  \textbf{Failsafe}: Empty string\\
  \textbf{Description}: Sets console output screen resolution.

  \begin{itemize}
  \tightlist
  \item Set to \texttt{WxH@Bpp} (e.g. \texttt{1920x1080@32}) or \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
5134 5135 5136
  in \texttt{Builtin} text renderer, FileVault 2 UEFI password interface,
  and boot screen logo. Refer to \hyperref[nvramvarsrec]{Recommended Variables}
  section for more details.
5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147

  \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}
  set to \texttt{true}.

\item
  \texttt{ClearScreenOnModeSwitch}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Some firmwares clear only part of screen when switching
  from graphics to text mode, leaving a fragment of previously drawn image visible.
V
vit9696 已提交
5148
  This option fills the entire graphics screen with black colour before switching to
5149 5150 5151 5152
  text mode.

  \emph{Note}: This option only applies to \texttt{System} renderer.

5153 5154 5155 5156 5157 5158 5159
\item
  \texttt{DirectGopRendering}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Use builtin graphics output protocol renderer for console.

  On some firmwares this may provide better performance or even fix rendering issues,
V
vit9696 已提交
5160 5161
  like on \texttt{MacPro5,1}. However, it is recommended not to use this option unless
  there is an obvious benefit as it may even result in slower scrolling.
5162

5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190
\item
  \texttt{IgnoreTextInGraphics}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \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}: This option only applies to \texttt{System} renderer.

\item
  \texttt{ReplaceTabWithSpace}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Some firmwares do not print tab characters or even everything
  that follows them, causing difficulties or inability to use the UEFI Shell builtin
  text editor to edit property lists and other documents. This option makes the console
  output spaces instead of tabs.

  \emph{Note}: This option only applies to \texttt{System} renderer.

\item
  \texttt{ProvideConsoleGop}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Ensure GOP (Graphics Output Protocol) on console handle.

5191 5192 5193 5194
  macOS bootloader requires GOP or UGA (for 10.4 EfiBoot) to be present on console
  handle, yet the exact location of the graphics protocol is not covered by the
  UEFI specification. This option will ensure GOP and UGA, if present, are available
  on the console handle.
5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225

  \emph{Note}: This option will also replace broken GOP protocol on console handle,
  which may be the case on \texttt{MacPro5,1} with newer GPUs.

\item
  \texttt{ReconnectOnResChange}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reconnect console controllers after changing screen resolution.

  On some firmwares when screen resolution is changed via GOP, it is required to reconnect
  the controllers, which produce the console protocols (simple text out). Otherwise they
  will not produce text based on the new resolution.

  \emph{Note}: On several boards this logic may result in black screen when launching
  OpenCore from Shell and thus it is optional. In versions prior to 0.5.2 this option
  was mandatory and not configurable. Please do not use this unless required.

\item
  \texttt{SanitiseClearScreen}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \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.

  \emph{Note}: This option only applies to \texttt{System} renderer.
   On all known affected systems \texttt{ConsoleMode} had to be set to
   empty string for this to work.

5226 5227 5228 5229 5230 5231 5232 5233 5234
\item
  \texttt{UgaPassThrough}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Provide UGA protocol instances on top of GOP protocol.

  Some firmwares do not implement legacy UGA protocol, but it may be required
  for screen output by older EFI applications like EfiBoot from 10.4.

5235 5236 5237
\end{enumerate}


5238
\subsection{ProtocolOverrides Properties}\label{uefiprotoprops}
5239 5240 5241

\begin{enumerate}

5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262
\item
  \texttt{AppleAudio}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reinstalls Apple audio protocols with builtin
  versions.

  Apple audio protocols allow macOS bootloader and OpenCore to play
  sounds and signals for screen reading or audible error reporting.
  Supported protocols are beep generation and VoiceOver. VoiceOver protocol
  is specific to Gibraltar machines (T2) and is not supported before
  macOS High Sierra (10.13). Instead older macOS versions use AppleHDA protocol,
  which is currently not implemented.

  Only one set of audio protocols can be available at a time, so in order
  to get audio playback in OpenCore user interface on Mac system implementing some
  of these protocols this setting should be enabled.

  \emph{Note}: Backend audio driver needs to be configured in \texttt{UEFI Audio}
  section for these protocols to be able to stream audio.

5263 5264 5265
\item
  \texttt{AppleBootPolicy}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
5266
  \textbf{Failsafe}: \texttt{false}\\
5267
  \textbf{Description}: Reinstalls Apple Boot Policy protocol with a builtin
5268 5269
  version. This may be used to ensure APFS compatibility on VMs or legacy Macs.

5270 5271 5272
  \emph{Note}: Some Macs, namely \texttt{MacPro5,1}, do have APFS compatibility,
  but their Apple Boot Policy protocol contains recovery detection issues, thus
  using this option is advised on them as well.
5273

5274 5275 5276 5277 5278 5279 5280
\item
  \texttt{AppleDebugLog}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reinstalls Apple Debug Log protocol with a builtin
  version.

5281 5282 5283 5284 5285 5286 5287
\item
  \texttt{AppleEvent}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reinstalls Apple Event protocol with a builtin
  version. This may be used to ensure File Vault 2 compatibility on VMs or legacy Macs.

5288 5289 5290 5291 5292 5293 5294 5295
\item
  \texttt{AppleFramebufferInfo}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reinstalls Apple Framebuffer Info protocol with a builtin
  version. This may be used to override framebuffer information on VMs or legacy Macs
  to improve compatibility with legacy EfiBoot like the one in macOS 10.4.

5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309
\item
  \texttt{AppleImageConversion}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reinstalls Apple Image Conversion protocol with a builtin
  version.

\item
  \texttt{AppleKeyMap}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reinstalls Apple Key Map protocols with builtin
  versions.

5310
\item
R
Rodion Shingarev 已提交
5311
  \texttt{AppleRtcRam}\\
5312 5313 5314 5315 5316 5317 5318 5319 5320 5321
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reinstalls Apple RTC RAM protocol with builtin
  version.

  \emph{Note}: Builtin version of Apple RTC RAM protocol may filter out
  I/O attempts to select RTC memory addresses. The list of addresses
  can be specified in \texttt{4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:rtc-blacklist}
  variable as a data array.

5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332
\item
  \texttt{AppleSmcIo}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reinstalls Apple SMC I/O protocol with a builtin
  version.

  This protocol replaces legacy \texttt{VirtualSmc} UEFI driver, and is compatible
  with any SMC kernel extension. However, in case \texttt{FakeSMC} kernel extension
  is used, manual NVRAM key variable addition may be needed.

5333 5334 5335 5336 5337 5338 5339
\item
  \texttt{AppleUserInterfaceTheme}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Reinstalls Apple User Interface Theme protocol with a builtin
  version.

5340 5341 5342
\item
  \texttt{DataHub}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
5343
  \textbf{Failsafe}: \texttt{false}\\
5344
  \textbf{Description}: Reinstalls Data Hub protocol with a builtin version.
5345
  This will delete all previous properties if the protocol was already installed.
5346

5347 5348 5349
\item
  \texttt{DeviceProperties}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
5350
  \textbf{Failsafe}: \texttt{false}\\
5351
  \textbf{Description}: Reinstalls Device Property protocol with a builtin
5352
  version. This will delete all previous properties if it was already installed.
5353 5354
  This may be used to ensure full compatibility on VMs or legacy Macs.

5355 5356 5357 5358 5359 5360 5361 5362
\item
  \texttt{FirmwareVolume}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Forcibly wraps Firmware Volume protocols or installs new
  to support custom cursor images for File Vault 2. Should be set to \texttt{true}
  to ensure File Vault 2 compatibility on everything but VMs and legacy Macs.

5363 5364 5365
  \emph{Note}: Several virtual machines including VMware may have corrupted
  cursor image in HiDPI mode and thus may also require this setting to be enabled.

5366 5367 5368 5369 5370 5371 5372 5373 5374 5375
\item
  \texttt{HashServices}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Forcibly reinstalls Hash Services protocols with builtin
  versions. Should be set to \texttt{true} to ensure File Vault 2 compatibility
  on platforms providing broken SHA-1 hashing. Can be diagnosed by invalid
  cursor size with \texttt{UIScale} set to \texttt{02}, in general platforms
  prior to APTIO V (Haswell and older) are affected.

5376 5377 5378 5379 5380 5381 5382 5383
\item
  \texttt{OSInfo}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Forcibly reinstalls OS Info protocol with builtin
  versions. This protocol is generally used to receive notifications from macOS
  bootloader, by the firmware or by other applications.

5384 5385 5386 5387 5388 5389 5390 5391 5392
\item
  \texttt{UnicodeCollation}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Forcibly reinstalls unicode collation services with builtin
  version. Should be set to \texttt{true} to ensure UEFI Shell compatibility
  on platforms providing broken unicode collation. In general legacy Insyde and APTIO
  platforms on Ivy Bridge and earlier are affected.

5393 5394
\end{enumerate}

V
vit9696 已提交
5395 5396 5397 5398
\subsection{Quirks Properties}\label{uefiquirkprops}

\begin{enumerate}

5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427
\item
  \texttt{DeduplicateBootOrder}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: Remove duplicate entries in \texttt{BootOrder} variable
  in \texttt{EFI\_GLOBAL\_VARIABLE\_GUID}.

  This quirk requires \texttt{RequestBootVarRouting} to be enabled and therefore
  \texttt{OC\_FIRMWARE\_RUNTIME} protocol implemented in \texttt{OpenRuntime.efi}.

  By redirecting \texttt{Boot} prefixed variables to a separate GUID namespace
  with the help of \texttt{RequestBootVarRouting} quirk we achieve multiple goals:
  \begin{itemize}
  \tightlist
  \item Operating systems are jailed and only controlled by OpenCore boot
  environment to enhance security.
  \item Operating systems do not mess with OpenCore boot priority, and guarantee
  fluent updates and hibernation wakes for cases that require reboots with OpenCore
  in the middle.
  \item Potentially incompatible boot entries, such as macOS entries, are not deleted
  or anyhow corrupted.
  \end{itemize}

  However, some firmwares do their own boot option scanning upon startup by checking
  file presence on the available disks. Quite often this scanning includes non-standard
  locations, such as Windows Bootloader paths. Normally it is not an issue, but some
  firmwares, ASUS firmwares on APTIO V in particular, have bugs. For them scanning is
  implemented improperly, and firmware preferences may get accidentally corrupted
  due to \texttt{BootOrder} entry duplication (each option will be added twice) making
V
vit9696 已提交
5428
  it impossible to boot without resetting NVRAM.
5429 5430 5431 5432 5433 5434 5435 5436 5437 5438

  To trigger the bug one should have some valid boot options (e.g. OpenCore) and then
  install Windows with \texttt{RequestBootVarRouting} enabled. As Windows bootloader
  option will not be created by Windows installer, the firmware will attempt to create it
  itself, and then corrupt its boot option list.

  This quirk removes all duplicates in \texttt{BootOrder} variable attempting to resolve
  the consequences of the bugs upon OpenCore loading. It is recommended to use this key
  along with \texttt{BootProtect} option.

5439 5440 5441
\item
  \texttt{ExitBootServicesDelay}\\
  \textbf{Type}: \texttt{plist\ integer}\\
5442
  \textbf{Failsafe}: \texttt{0}\\
5443 5444 5445 5446 5447 5448 5449 5450 5451
  \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 已提交
5452 5453 5454
\item
  \texttt{IgnoreInvalidFlexRatio}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
5455
  \textbf{Failsafe}: \texttt{false}\\
V
vit9696 已提交
5456 5457 5458 5459 5460 5461 5462
  \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.

5463 5464 5465
\item
  \texttt{ReleaseUsbOwnership}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
5466
  \textbf{Failsafe}: \texttt{false}\\
5467 5468 5469 5470 5471
  \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.

5472 5473 5474
\item
  \texttt{RequestBootVarRouting}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
5475
  \textbf{Failsafe}: \texttt{false}\\
5476 5477
  \textbf{Description}: Request redirect of all \texttt{Boot} prefixed variables from
  \texttt{EFI\_GLOBAL\_VARIABLE\_GUID} to \newline \texttt{OC\_VENDOR\_VARIABLE\_GUID}.
5478

5479
  This quirk requires \texttt{OC\_FIRMWARE\_RUNTIME} protocol implemented
V
vit9696 已提交
5480
  in \texttt{OpenRuntime.efi}. The quirk lets default boot entry
5481
  preservation at times when firmwares delete incompatible boot entries.
5482 5483 5484
  Simply said, you are required to enable this quirk to be able to reliably
  use \href{https://support.apple.com/HT202796}{Startup Disk} preference
  pane in a firmware that is not compatible with macOS boot entries by design.
5485

5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510
\item
  \texttt{TscSyncTimeout}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Attempts to perform TSC synchronisation with a specified timeout.

  The primary purpose of this quirk is to enable early bootstrap TSC synchronisation
  on some server and laptop models when running a debug XNU kernel. For the debug kernel
  the TSC needs to be kept in sync across the cores before any kext could kick in rendering
  all other solutions problematic. The timeout is specified in microseconds and depends on the
  amount of cores present on the platform, the recommended starting value is \texttt{500000}.

  This is an experimental quirk, which should only be used for the aforementioned problem.
  In all other cases the quirk may render the operating system unstable and is not recommended.
  The recommended solution in the other cases is to install a kernel driver like
  \href{https://github.com/RehabMan/VoodooTSCSync}{VoodooTSCSync},
  \href{https://github.com/interferenc/TSCAdjustReset}{TSCAdjustReset},
  or \href{https://github.com/lvs1974/CpuTscSync}{CpuTscSync} (a more specialised
  variant of VoodooTSCSync for newer laptops).

  \emph{Note}: The reason this quirk cannot replace the kernel driver is
  because it cannot operate in ACPI S3 mode (sleep wake) and because the UEFI firmwares
  provide very limited multicore support preventing the precise update of the MSR
  registers.

5511
\item
5512
  \texttt{UnblockFsConnect}\\
5513 5514
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
5515 5516
  \textbf{Description}: Some firmwares block partition handles by opening them
  in By Driver mode, which results in File System protocols being unable to install.
5517

5518
  \emph{Note}: The quirk is mostly relevant for select HP laptops with no drives listed.
5519

V
vit9696 已提交
5520 5521
\end{enumerate}

5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557
\subsection{ReservedMemory Properties}\label{uefirsvdprops}

\begin{enumerate}

\item
  \texttt{Address}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Start address of the reserved memory region, which should be allocated
  as reserved effectively marking the memory of this type inaccessible to the operating system.

  The addresses written here must be part of the memory map, have \texttt{EfiConventionalMemory}
  type, and page-aligned (4 KBs).

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

\item
  \texttt{Size}\\
  \textbf{Type}: \texttt{plist\ integer}\\
  \textbf{Failsafe}: \texttt{0}\\
  \textbf{Description}: Size of the reserved memory region, must be page-aligned (4 KBs).

\item
  \texttt{Enabled}\\
  \textbf{Type}: \texttt{plist\ boolean}\\
  \textbf{Failsafe}: \texttt{false}\\
  \textbf{Description}: This region will not be reserved unless set to \texttt{true}.

\end{enumerate}

V
vit9696 已提交
5558 5559
\section{Troubleshooting}\label{troubleshooting}

V
vit9696 已提交
5560
\subsection{Windows support}\label{troubleshootingwin}
V
vit9696 已提交
5561

V
vit9696 已提交
5562 5563 5564
  \textbf{Can I install Windows?}

  While no official Windows support is provided, 64-bit UEFI Windows installations (Windows 8 and
V
vit9696 已提交
5565
  above) prepared with Boot Camp are supposed to work. Third-party UEFI installations
V
vit9696 已提交
5566
  as well as systems partially supporting UEFI boot, like Windows 7, might work with
V
vit9696 已提交
5567
  some extra precautions. Things to keep in mind:
5568

V
vit9696 已提交
5569 5570 5571
  \begin{itemize}
  \item MBR (Master Boot Record) installations are legacy and will not be supported.
  \item All the modifications applied (to ACPI, NVRAM, SMBIOS, etc.) are supposed
V
vit9696 已提交
5572
  to be operating system agnostic, i.e. apply equally regardless of the OS booted.
V
vit9696 已提交
5573 5574 5575 5576 5577 5578
  This enables Boot Camp software experience on Windows.
  \item macOS requires the first partition to be EFI System Partition, and does
  not support the default Windows layout. While OpenCore does have a
  \href{https://github.com/acidanthera/bugtracker/issues/327}{workaround}
  for this, it is highly recommend not to rely on it and install properly.
  \item Windows may need to be reactivated. To avoid it consider
A
Andrey1970AppleLife 已提交
5579
  setting SystemUUID to the original firmware UUID. Be warned,
5580
  on old firmwares it may be invalid, i.e. not random. In case you still have issues,
5581 5582
  consider using HWID or KMS38 license or making the use \texttt{Custom}
  \texttt{UpdateSMBIOSMode}. Other nuances of Windows activation are out of the
5583
  scope of this document and can be found online.
V
vit9696 已提交
5584 5585 5586
  \end{itemize}

  \textbf{What additional software do I need?}
5587

5588 5589 5590 5591 5592
  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 已提交
5593 5594 5595
  Note, that you may have to download and install \href{https://www.7-zip.org}{7-Zip}
  prior to using Brigadier.

V
vit9696 已提交
5596 5597 5598 5599 5600 5601 5602 5603 5604 5605
  Remember to always use the latest version of Windows support software from Boot Camp,
  as versions prior to 6.1 do not support APFS, and thus will not function correctly.
  To download newest software pass most recent Mac model to Brigadier, for example
  \texttt{./brigadier.exe -m iMac19,1}. To install Boot Camp on an unsupported Mac model
  afterwards run PowerShell as Administrator and enter \texttt{msiexec /i BootCamp.msi}.
  In case you already have a previous version of Boot Camp installed you will have to
  remove it first by running \texttt{msiexec /x BootCamp.msi} command. \texttt{BootCamp.msi}
  file is located in \texttt{BootCamp/Drivers/Apple} directory and can be reached through
  Windows Explorer.

V
vit9696 已提交
5606
  While Windows support software from Boot Camp solves most of compatibility problems,
V
vit9696 已提交
5607
  sometimes you may have to address some of them manually:
5608

V
vit9696 已提交
5609 5610 5611 5612 5613 5614 5615
  \begin{itemize}
  \item To invert mouse wheel scroll direction \texttt{FlipFlopWheel} must be set
  to \texttt{1} as explained on \href{https://superuser.com/a/364353}{SuperUser}.
  \item \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).
  \item To access Apple filesystems like HFS and APFS separate software may need to
V
vit9696 已提交
5616
  be installed. Some of the known utilities are:
V
vit9696 已提交
5617
  \href{https://forums.macrumors.com/threads/apple-hfs-windows-driver-download.1368010/}{Apple HFS+ driver}
A
Andrey1970AppleLife 已提交
5618
  (\href{https://forums.macrumors.com/threads/apple-hfs-windows-driver-download.1368010/post-24180079}{hack for Windows 10}),
V
vit9696 已提交
5619 5620 5621 5622
  \href{http://www.catacombae.org/hfsexplorer}{HFSExplorer}, MacDrive, Paragon APFS,
  Paragon HFS+, TransMac, etc. Remember to never ever attempt to modify Apple file systems
  from Windows as this often leads to irrecoverable data loss.
  \end{itemize}
5623

5624
  \textbf{Why do I see \texttt{Basic data partition} in Boot Camp Startup Disk control panel?}
5625 5626 5627

  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.
V
vit9696 已提交
5628
  This can be done with many utilities including open-source
5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664
  \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 已提交
5665

5666 5667 5668 5669
  \textbf{How to choose Windows BOOTCAMP with custom NTFS drivers?}

  Third-party drivers providing NTFS support, such as
  \href{https://www.tuxera.com/community/open-source-ntfs-3g}{NTFS-3G}, Paragon NTFS,
5670 5671
  Tuxera NTFS or \href{https://www.seagate.com/support/software/paragon}{Seagate Paragon Driver}
  break certain macOS functionality, including
5672 5673 5674
  \href{https://support.apple.com/HT202796}{Startup Disk} preference
  pane normally used for operating system selection. While the recommended option
  remains not to use such drivers as they commonly corrupt the filesystem, and prefer
5675 5676 5677
  the driver bundled with macOS with optional write support (
  \href{http://osxdaily.com/2013/10/02/enable-ntfs-write-support-mac-os-x}{command} or
  \href{https://mounty.app}{GUI}),
5678 5679 5680 5681
  there still exist vendor-specific workarounds for their products:
  \href{https://www.tuxera.com/products/tuxera-ntfs-for-mac/faq}{Tuxera},
  \href{https://kb.paragon-software.com/article/6604}{Paragon}, etc.

V
vit9696 已提交
5682 5683 5684 5685 5686 5687
\subsection{Debugging}\label{troubleshootingdebug}

Similar to other projects working with hardware OpenCore supports auditing and debugging.
The use of \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
5688
\href{https://github.com/acidanthera/OpenCorePkg/tree/master/Debug}{OpenCore Debug}
5689 5690 5691
page. For IDA Pro you will need IDA Pro 7.3 or newer, refer to
\href{https://www.hex-rays.com/products/ida/support/tutorials/index.shtml}{Debugging the XNU Kernel with IDA Pro}
for more details.
V
vit9696 已提交
5692 5693

To obtain the log during boot you can make the use of serial port debugging. Serial port
5694 5695
debugging is enabled in \texttt{Target}, e.g. \texttt{0xB} for onscreen with serial. To
initialise serial within OpenCore use \texttt{SerialInit} configuration option.
V
vit9696 已提交
5696
For macOS your best choice are CP2102-based UART devices. Connect motherboard \texttt{TX}
5697
to USB UART \texttt{RX}, and motherboard \texttt{GND} to USB UART \texttt{GND}. Use
V
vit9696 已提交
5698 5699 5700
\texttt{screen} utility to get the output, or download GUI software, such as
\href{https://freeware.the-meiers.org}{CoolTerm}.

5701 5702 5703 5704 5705
\emph{Note}: On several motherboards (and possibly USB UART dongles) PIN naming may be
incorrect. It is very common to have \texttt{GND} swapped with \texttt{RX}, thus you have
to connect motherboard ``\texttt{TX}'' to USB UART \texttt{GND}, and motherboard ``\texttt{GND}''
to USB UART \texttt{RX}.

V
vit9696 已提交
5706 5707 5708 5709
Remember to enable \texttt{COM} port in firmware settings, and never use USB cables longer
than 1 meter to avoid output corruption. To additionally enable XNU kernel serial output
you will need \texttt{debug=0x8} boot argument.

V
vit9696 已提交
5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732
\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}.
  \item Watch Dog is disabled to prevent automatic reboot:
A
Andrey1970AppleLife 已提交
5733
  \texttt{Misc} $\rightarrow$ \texttt{Debug} $\rightarrow$
V
vit9696 已提交
5734 5735 5736 5737 5738 5739
  \texttt{DisableWatchDog} $=$ \texttt{true}.
  \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
V
vit9696 已提交
5740
  one by one. For early boot troubleshooting, for instance, when OpenCore menu does not appear,
A
Andrey1970AppleLife 已提交
5741
  using \texttt{UEFI Shell} (bundled with OpenCore) may help to see
V
vit9696 已提交
5742
  early debug messages.
V
vit9696 已提交
5743

V
vit9696 已提交
5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758
\item
  \textbf{How to debug macOS boot failure?}

  \begin{itemize}
  \tightlist
  \item Refer to \texttt{boot-args} values like \texttt{debug=0x100}, \texttt{keepsyms=1},
    \texttt{-v}, and similar.
  \item Do not forget about \texttt{AppleDebug} and \texttt{ApplePanic} properties.
  \item Take care of \texttt{Booter}, \texttt{Kernel}, and \texttt{UEFI} quirks.
  \item Consider using serial port to inspect early kernel boot failures. For this you may
    need \texttt{debug=0x108}, \texttt{serial=5}, and \texttt{msgbuf=1048576} arguments.
    Refer to the patches in Sample.plist when dying before serial init.
  \item Always read the logs carefully.
  \end{itemize}

V
vit9696 已提交
5759 5760 5761 5762 5763 5764 5765 5766
\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.

V
vit9696 已提交
5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780
\item
  \textbf{How to choose the default boot entry?}

  OpenCore uses the primary UEFI boot option to select the default entry. This choice
  can be altered from UEFI Setup, with the macOS
  \href{https://support.apple.com/HT202796}{Startup Disk} preference, or the Windows
  \href{https://support.apple.com/guide/bootcamp-control-panel/start-up-your-mac-in-windows-or-macos-bcmp29b8ac66/mac}{Boot Camp} Control Panel.
  Since choosing OpenCore's \texttt{BOOTx64.EFI} as a primary boot option limits this
  functionality in addition to several firmwares deleting incompatible boot options,
  potentially including those created by macOS, you are strongly encouraged to use the
  \texttt{RequestBootVarRouting} quirk, which will preserve your selection made in
  the operating system within the OpenCore variable space. Note, that \texttt{RequestBootVarRouting}
  requires a separate driver for functioning.

V
vit9696 已提交
5781 5782 5783 5784 5785 5786 5787 5788 5789
\item
  \textbf{What is the simplest way to install macOS?}

  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.

  To download recovery online you may use
V
vit9696 已提交
5790 5791
  \href{https://github.com/acidanthera/OpenCorePkg/blob/master/Utilities/macrecovery/macrecovery.py}{macrecovery.py},
  builtin tool.
V
vit9696 已提交
5792

V
vit9696 已提交
5793 5794
  For offline installation refer to
  \href{https://support.apple.com/HT201372}{How to create a bootable installer for macOS}
5795
  article. Apart from App Store and \texttt{softwareupdate} utility there also are
V
vit9696 已提交
5796
  \href{https://github.com/corpnewt/gibMacOS}{third-party utilities} to download an offline image.
V
vit9696 已提交
5797

5798
\item
V
vit9696 已提交
5799
  \textbf{Why do online recovery images (\texttt{*.dmg}) fail to load?}
5800 5801

  This may be caused by missing HFS+ driver, as all presently known recovery volumes
A
Andrey1970AppleLife 已提交
5802
  have HFS+ filesystem.
5803

V
vit9696 已提交
5804 5805 5806 5807 5808
\item
  \textbf{Can I use this on Apple hardware or virtual machines?}

  Sure, most relatively modern Mac models including \texttt{MacPro5,1} and virtual machines
  are fully supported. Even though there are little to none specific details relevant to
V
vit9696 已提交
5809 5810
  Mac hardware, some ongoing instructions can be found on
  \href{https://forums.macrumors.com/threads/opencore-on-the-mac-pro.2207814}{MacRumors.com}.
V
vit9696 已提交
5811

5812 5813 5814
\item
  \textbf{Why do Find\&Replace patches must equal in length?}

A
Andrey1970AppleLife 已提交
5815
  For machine code (x86 code) it is not possible to do differently sized replacements due to
5816 5817 5818
  \href{https://en.wikipedia.org/w/index.php?title=Relative_addressing}{relative addressing}.
  For ACPI code this is risky, and is technically equivalent to ACPI table replacement,
  thus not implemented. More detailed explanation can be found on
V
vit9696 已提交
5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849
  \href{https://applelife.ru/posts/819790}{AppleLife.ru} or in the ACPI section of this document.

\item
  \textbf{How can I decide which \texttt{Booter} quirks to use?}

  These quirks originate from \texttt{AptioMemoryFix} driver but provide a wider
  set of changes specific to modern systems. Note, that \texttt{OpenRuntime}
  driver is required for most configurations. To get a configuration similar
  to \texttt{AptioMemoryFix} you may try enabling the following set of quirks:
  \begin{itemize}
  \tightlist
  \item \texttt{ProvideConsoleGop} (UEFI quirk)
  \item \texttt{AvoidRuntimeDefrag}
  \item \texttt{DiscardHibernateMap}
  \item \texttt{EnableSafeModeSlide}
  \item \texttt{EnableWriteUnprotector}
  \item \texttt{ForceExitBootServices}
  \item \texttt{ProtectMemoryRegions}
  \item \texttt{ProvideCustomSlide}
  \item \texttt{RebuildAppleMemoryMap}
  \item \texttt{SetupVirtualMap}
  \end{itemize}

  However, as of today such set is strongly discouraged as some of these quirks
  are not necessary to be enabled or need additional quirks. For example,
  \texttt{DevirtualiseMmio} and \texttt{ProtectUefiServices} are often required,
  while \texttt{DiscardHibernateMap} and \texttt{ForceExitBootServices} are rarely
  necessary.

  Unfortunately for some quirks like \texttt{RebuildAppleMemoryMap},
  \texttt{EnableWriteUnprotector}, \texttt{ProtectMemoryRegions},
5850 5851 5852 5853
  \texttt{SetupVirtualMap}, and \texttt{SyncRuntimePermissions} there
  is no definite approach even on similar systems, so trying all their
  combinations may be required for optimal setup. Refer to individual quirk
  descriptions in this document for more details.
5854

V
vit9696 已提交
5855
\end{enumerate}
V
vit9696 已提交
5856 5857

\end{document}