--- /dev/null
+Requirements
+============
+
+To compile rEFInd, you'll need the following:
+
+* A Linux installation. Note that this installation does NOT need to be
+ EFI-based. It can be 32- or 64-bit, but unless you use a cross-compiler
+ (which I've not tested), it must be the appropriate bit width for your
+ EFI implementation. (Normally that means 64-bit.) If you don't normally
+ run Linux, you can run it in a VirtualBox or similar virtual machine. (I
+ describe some unsupported non-Linux build options shortly.)
+
+* A standard set of Linux development tools, based on GCC.
+
+* One of the following:
+
+ * The TianoCore EDK2 package
+ (http://sourceforge.net/projects/tianocore/). I initially used the
+ UDK2010 package and others in that series, but beginning with rEFInd
+ 0.8.2, I've been using UDK2014
+ (http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=UDK2014).
+ All of the UDK release are "frozen," rather than the main EDK2
+ development branch, which is changing as the developers add features,
+ fix bugs, and so on. See below for TianoCore setup instructions.
+
+ * The GNU-EFI package (http://sourceforge.net/projects/gnu-efi/). You can
+ install this from a package called "gnu-efi"; however, rEFInd relies on
+ features that were added sometime between version 3.0s and 3.0u, so I
+ recommend using 3.0u (or conceivably later). You should check your
+ GNU-EFI version number; you may need to download the latest source
+ code, compile it, and install it locally. The Makefiles assume a
+ GNU-EFI package installed via a package manager. If you install from
+ source code, you may need to adjust those Makefiles' paths.
+
+Of the two toolkits, I prefer to use TianoCore because it produces binaries
+that are about 20-30KiB smaller than those made by GNU-EFI, and I can
+easily build 32-bit binaries on my 64-bit Linux installations. Also, I've
+had problems on a 32-bit Mac Mini with the drivers produced by GNU-EFI
+hanging the system if I try to load more than one of them. (I haven't
+encountered this problem on UEFI-based PCs.) That said, the TianoCore EDK2
+package is much harder to install, so you may prefer to use GNU-EFI unless
+you have a specific need for the TianoCore toolkit. Automated build tools
+like the OpenSUSE Build Service (OBS) and the Ubuntu Personal Package
+Archive (PPA) mechanism don't yet support TianoCore.
+
+It's possible to use a non-Linux platform to compile rEFInd. To the best of
+my knowledge, the rEFInd code doesn't rely on anything Linux-specific in
+its build requirements, and GNU-EFI's Sourceforge page indicates that it
+works under Windows and OS X, too; however, my one attempt to compile
+GNU-EFI under OS X failed. I've received one report that rEFInd compiles
+successfully with Clang and the TianoCore toolkit under OS X by adding the
+refind.inf file to a .dsc file that you use for your own projects. You can
+find brief instructions here (note that this is not my documentation):
+
+https://github.com/snarez/refind-edk2
+
+Under Windows, you would need to either create a project or Makefile for
+your non-GCC compiler or use a GCC port, such as MinGW
+(http://www.mingw.org). You'd probably need to adjust the Makefiles in the
+latter case. A procedure similar to that used under OS X might work using
+GCC or Microsoft's C compiler, but I haven't tested this.
+
+
+Preparing Your Development Kit
+==============================
+
+If you're using Linux, GNU-EFI is the easiest way to compile rEFInd. I
+don't describe GNU-EFI's setup here because it's likely to be fairly easy.
+If your distribution provides a recent enough version, you should be able
+to install a package called gnu-efi and be done with it. If not, you'll
+need to download the source code tarball, build it, and install it. This
+process is fairly typical of Linux packages. Read the GNU-EFI documentation
+if you need help. If you're using GNU-EFI, you can skip the rest of this
+section.
+
+You might also want to use the TianoCore toolkit if you have problems with
+GNU-EFI or if you want to build rEFInd on a non-Linux platform.
+Unfortunately, the TianoCore toolkit is weird by Linux programming
+standards. It's also quite large -- it's intended as a means to develop a
+complete EFI firmware implementation, so it contains much more code than is
+needed to develop standalone EFI applications. I don't know of any Linux
+distribution packages for it in RPM, Debian package file, or other formats;
+you MUST install the kit from source code using its own unusual compilation
+procedure. The installation documentation also omits at least one step and
+is a bit unclear about others. Here's how I installed the toolkit:
+
+1) Download UDK2014.SR1.UP1.P1 from
+ https://sourceforge.net/apps/mediawiki/tianocore/index.php?title=UDK2014.
+
+2) Type "mkdir /usr/local/UDK2014". You can use another directory, but the
+ Makefile for rEFInd's EFI drivers assumes this location. You'll need to
+ edit the EDK2BASE line in the Make.tiano file if you install somewhere
+ else.
+
+3) Type "cd /usr/local/UDK2014".
+
+4) Unzip the downloaded file (UDK2014.SR1.UP1.P1.Complete.MyWorkSpace.zip)
+ in the current directory (/usr/local/UDK2014). This creates a handful of
+ files, including a tarball and a couple of .zip files.
+
+5) Type "unzip UDK2014.SR1.UP1.MyWorkSpace.zip". This extracts the
+ platform-neutral portion of the development kit.
+
+6) Type "cd MyWorkSpace".
+
+7) Type "tar xvf ../BaseTools\(Unix\).tar". This extracts the
+ Linux/Unix-specific portions of the toolkit.
+
+8) Follow the build instructions at
+ https://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Using_EDK_II_with_Native_GCC_4.4;
+ however, a few changes are required, as detailed below....
+
+9) Type "source edksetup.sh BaseTools". This sets up some environment
+ variables, so subsequent steps (NOT including compiling the rEFInd EFI
+ drivers) must be typed in the shell you use for this step.
+
+10) Edit Conf/target.txt and change the following:
+ - ACTIVE_PLATFORM = MdePkg/MdePkg.dsc
+ - TARGET = RELEASE (DEBUG might work, but I've not tested it).
+ - TARGET_ARCH = X64 (on x86-64; leave this as IA32 on x86). If you plan
+ to build both architectures on an x86-64 system, you can set this to
+ "IA32 X64".
+ - TOOL_CHAIN_TAG = GCC46 (or other value depending on your GCC version;
+ type "gcc -v" to learn your GCC version number). Note that GCC 4.7
+ and 4.8 don't have their own entries, so use GCC46 for them.
+ The TianoCore Makefiles read some of these variables from this file
+ and use them when accessing directories, so be sure to type these
+ entries in the case specified.
+
+11) The documentation refers to editing Conf/tools_def.txt in addition to
+ Conf/target.txt, but doesn't specify what to change in
+ Conf/tools_def.txt. I haven't found it necessary to make any changes in
+ Conf/tools_def.txt EXCEPT when using GCC 4.7 on a Fedora 17 system.
+ (I haven't used GCC 4.7 on other platforms, so this may well be
+ necessary on other systems, too.) With that setup, I found it
+ necessary to change the following line:
+ *_GCC46_X64_ASM_FLAGS = DEF(GCC46_ASM_FLAGS) -m64 -melf_x86_64
+ to:
+ *_GCC46_X64_ASM_FLAGS = DEF(GCC46_ASM_FLAGS) -m64
+
+12) Type "make -C /usr/local/UDK2014/MyWorkSpace/BaseTools/Source/C".
+ (This step is not documented on the EDK Web page.) Note that this
+ requires the g++ compiler and UUID development libraries.
+
+13) Type "build" to build the main set of EDK2 files. This process is
+ likely to take a few minutes. This step requires Python 2; if you have
+ Python 3 installed, you may need to adjust the default python for this
+ build (for instance, by typing "eselect python set python2.7" in
+ Gentoo).
+
+If you installed in a location other than the one I've specified, you must
+edit the EDK2BASE variable in the Make.tiano and filesystems/Make.tiano
+files in the rEFInd source package. Once the toolkit is installed, you can
+build the filesystem drivers or rEFInd, as described below.
+
+
+Compiling rEFInd
+================
+
+With your development system set up, you can compile rEFInd as follows:
+
+1) Download and uncompress the rEFInd source code archive. (If you're
+ reading this file, you've probably already done this task.)
+
+2) Open a Linux shell prompt
+
+3) Change into the archive's main directory. You should see several files
+ including this BUILDING.txt file and several subdirectories such as
+ "refind", "libeg", "mok", "filesystems", and "include".
+
+4) Type "make gnuefi" to build with GNU-EFI, or either "make" alone or
+ "make tiano" to build with TianoCore EDK2. With any luck, rEFInd will
+ compile without error, leaving the "refind_ia32.efi" or "refind_x64.efi"
+ file, depending on your platform, in the "refind" subdirectory. This same
+ step builds the "gptsync_x64.efi" or "gptsync_ia32.efi" program file, in
+ the "gptsync" subdirectory. If you want to build IA32 binaries on an
+ x86-64 (X64) system, type "ARCH=ia32 make". This works only if you're
+ using the TianoCore build kit, and only if you set TARGET_ARCH to either
+ "IA32" or "IA32 X64" in target.txt when you set up the TianoCore toolkit.
+ If you plan to build both architectures, be sure to copy the .efi file
+ for the first build out of the refind subdirectory before building the
+ second architecture.
+
+5) The default build process does NOT build the filesystem drivers. If you
+ want to build them, you must type "make fs" in the main rEFInd source
+ directory to build with the TianoCore EDK2, or "make fs_gnuefi" to build
+ with GNU-EFI. (Typing "ARCH=ia32 make fs" builds IA32 filesystem drivers
+ on an x86-64 system, provided TianoCore is properly configured, as
+ described earlier.) The result is filesystem drivers in the filesystems
+ subdirectory, and also copies placed in the drivers_{arch} subdirectory.
+
+If rEFInd doesn't compile correctly, you'll need to track down the source
+of the problem. Double-check that you've got all the necessary development
+tools installed, including GCC, make, and either GNU-EFI or TianoCore EDK2.
+You may also need to adjust the Makefile, Make.common file, or Make.tiano
+file for your system. (The main Makefile controls the process for both
+toolkits, while Make.common holds GNU-EFI options and Make.tiano holds
+TianoCore options.) The most likely thing you'll need to change is the path
+to the various GNU-EFI include files and libraries. Since rEFInd 0.6.2, the
+default Make.common file includes the following definitions:
+
+EFIINC = /usr/include/efi
+GNUEFILIB = /usr/lib
+EFILIB = /usr/lib
+EFICRT0 = /usr/lib
+
+If you've installed GNU-EFI from source code, you may need to add "local"
+to those paths, as in "/usr/local/include/efi". You might need to change
+references to "lib" to "lib32" or "lib64" on some systems. Recall that you
+need at least GNU-EFI version 3.0l to build rEFInd, and until very
+recently, most distributions provided out-of-date versions of this package.
+
+If you're using TianoCore's EDK2, as noted earlier, you may need to adjust
+the EDK2BASE variable in Make.tiano and filesystems/Make.tiano.
+
+When I tried to compile rEFInd under Ubuntu 12.04 (i386) using GNU-EFI,
+even with a locally-compiled GNU-EFI 3.0p or 3.0q, I got errors like this:
+
+main.o: In function `StartLegacy.isra.0':
+main.c:(.text+0x8b1): undefined reference to `__stack_chk_fail_local'
+lib.o: In function `ScanVolumeBootcode.part.3':
+lib.c:(.text+0xf2f): undefined reference to `__stack_chk_fail_local'
+lib.o: In function `ScanExtendedPartition.isra.4':
+
+The solution was to recompile GNU-EFI with the -fno-stack-protector GCC
+flag. In GNU-EFI, this can be added to the CFLAGS line in Make.defaults.
+
+
+Installing rEFInd
+=================
+
+With rEFInd compiled, you can install it. The easiest way to do this is
+with the refind-install script, which works on both Linux and Mac OS X.
+Alternatively, you can type "make install" to install using this script.
+Note that this script copies files to the ESP and uses "efibootmgr" (on
+Linux) or "bless" (on OS X) to add rEFInd to the firmware's boot loader
+list. The docs/refind/installing.html file provides more details on this
+script and its use.
+
+If refind-install doesn't work for you or if you prefer to do the job
+manually, you may. On a UEFI-based system, you'll want to copy files on the
+ESP as follows:
+
+* Create a directory for rEFInd, such as EFI/refind.
+* Copy refind/refind_ia32.efi or refind_x64.efi to the ESP's EFI/refind
+ directory.
+* Copy refind.conf-sample to the EFI/refind directory as refind.conf.
+* Copy the icons subdirectory, including all its files, to EFI/refind.
+
+You'll then need to activate rEFInd in your EFI. This can be done with
+tools such as "efibootmgr" under Linux or "bless" under OS X. See the
+docs/refind/installing.html file for details.
+
+
+Note to Distribution Maintainers
+================================
+
+The refind-install script, and therefore the "install" target in the
+Makefile, installs the program directly to the ESP and it modifies the
+*CURRENT COMPUTER's* NVRAM. Thus, you should *NOT* use this target as part
+of the build process for your binary packages (RPMs, Debian packages,
+etc.). (Gentoo could use it in an ebuild, though....) You COULD, however,
+install the files to a directory somewhere (/usr/share/refind or whatever)
+and then call refind-install as part of the binary package installation
+process. Placing the files directly in /boot/efi/EFI/{distname}/refind and
+then having a post-install script call efibootmgr is probably the better
+way to go, but this assumes that the ESP is mounted at /boot/efi.
+
+
+Compiling the EFI Filesystem Drivers
+====================================
+
+To build all the drivers, you can type "make fs" or "make fs_gnuefi" from
+the main directory, which builds the drivers and places copies in both the
+filesystems and drivers_{arch} subdirectories. If you want to build just
+one driver, you can change into the "filesystems" directory and type "make
+{fsname}" or "make {fsname}_gnuefi", where {fsname} is a filesystem name --
+"ext2", "ext4", "reiserfs", "iso9660", or "hfs". In all cases, the build
+target that appends "_gnuefi" builds with GNU-EFI and the one that doesn't
+builds with TianoCore.
+
+To install drivers, you can type "make install" in the "filesystems"
+directory. This copies all the drivers to the
+"/boot/efi/EFI/refind/drivers" directory. Alternatively, you can copy the
+files you want manually. The refind-install script includes an optional
+"--drivers" option that will install the drivers along with the main rEFInd
+program, but to the drivers_{arch} subdirectory of the main rEFInd
+installation directory.
+
+*CAUTION:* Install drivers for your system's architecture *ONLY*.
+Installing drivers for the wrong architecture causes some systems to hang
+at boot time. This risk can be minimized by including the architecture code
+in the drivers subdirectory name (drivers_x64 or drivers_ia32).
+
+The drivers all rely on filesystem wrapper code created by rEFIt's author,
+Christoph Pfisterer. Most of the drivers seem to have passed through
+Oracle's VirtualBox project (https://www.virtualbox.org) and the Clover
+boot loader project (https://sourceforge.net/projects/cloverefiboot/),
+which I used as the source for this build.
+
+Adding Support for Network Boot
+===============================
+
+rEFInd provides EXPERIMENTAL support for booting over the network using
+iPXE (http://ipxe.org) as a means to receive the payload. In order to
+enable this feature you'll want to follow these instructions:
+
+* cd net/
+* make source
+* make netboot
+* copy bin/ipxe.efi and bin/ipxe_discover.efi to the EFI volume at EFI/tools/
+
+Note that you may need to install additional development packages, such as
+libiberty-dev and binutils-dev, in addition to those needed to build rEFInd
+itself.
+
+My own tests show this support to work under optimal conditions; however,
+architecture (EFI vs. BIOS) detection may not work, and some computers will
+hang or won't retrieve boot files from the network. For these reasons, this
+support is disabled by default in rEFInd, and I do not provide iPXE
+binaries.
--- /dev/null
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
--- /dev/null
+Although I (Roderick W. Smith) am releasing rEFInd in its current form, the
+program is not the work of a single person. Others have contributed to the
+program, both in its original version (rEFIt) and by providing features
+I've incorporated into the current version. Specifically:
+
+Program (C source code) files:
+------------------------------
+
+* Christoph Pfisterer was the original author of rEFIt. See its Web page,
+ http://refit.sourceforge.net, for this version of the program. Christoph
+ has therefore contributed more to rEFInd than anybody else, myself
+ included; my changes are comparatively small additions to the original
+ rEFIt base.
+
+* The Debian project has made a version of rEFIt available that
+ incorporates a number of patches, all attributed to Julien BLACHE
+ (jblache@debian.org), to enable it to build properly on a Linux system.
+ It was this version of rEFIt that I used as a starting point for creating
+ rEFInd. See http://packages.debian.org/sid/refit for this version of the
+ program.
+
+* The filesystem drivers released with version 0.4.0 rely on a filesystem
+ wrapper created by Christoph Phisterer. They then passed through Oracle's
+ VirtualBox (https://www.virtualbox.org) and the Clover boot loader
+ project (https://sourceforge.net/projects/cloverefiboot/). The
+ filesystem-specific code comes from various sources, including Apple,
+ the Linux kernel, and Christoph Pfisterer.
+
+* Assorted support code is borrowed from the TianoCore EDK2
+ (https://sourceforge.net/projects/tianocore/), which is the reference
+ implementation for EFI.
+
+* Dave Vasilevsky (dave@vasilevsky.ca) contributed the disk-ejection
+ code.
+
+* John Bressler (jrb1327@gmail.com) contributed the code to boot BIOS-based
+ OSes on UEFI-based PCs.
+
+* The code for editing boot options (cursor_left(), cursor_right(), and
+ line_edit() in screen.c) is taken from gummiboot
+ (http://freedesktop.org/wiki/Software/gummiboot).
+
+* Stefan Agner (stefan@agner.ch) turned the original ext2fs/ext3fs driver
+ into one that can read ext4fs.
+
+* Samuel Liao ported the GRUB 2 Btrfs and NTFS code into EFI drivers and
+ contributed them to this project, along with several miscellaneous
+ improvements.
+
+* Emerson Barcelos (emerson_freitas@yahoo.com.br) wrote the code for
+ enabling Intel VMX support (the enable_and_lock_vmx token in
+ refind.conf).
+
+* Rohan Sehgal (rohan.sehgal.su@gmail.com) wrote code to help rEFInd
+ detect network boot options and launch them, with the help of the
+ external ipxe.efi and ipxe_discover.efi programs.
+
+* Matthew J. Garrett (mjg@redhat.com) wrote the shim boot loader upon which
+ rEFInd relies for its Secure Boot functionality. I took a few shim
+ functions to help out on the rEFInd side, too; see the mok/mok.c source
+ code file.
+
+* James Bottomley (James.Bottomley@HansenPartnership.com) wrote the
+ Linux Foundation's PreBootloader, which is an alternative to shim. I've
+ found that much of its code is also useful in implementing Secure Boot
+ functionality in rEFInd. Most of the files in the mok subdirectory are
+ based on Bottomley's PreBootloader code.
+
+* The PNG support, in the files libeg/lodepng.c and libeg/lodepng.h, is a
+ slightly modified version of LodePNG (http://lodev.org/lodepng/) by Lode
+ Vandevenne. (The libeg/lodepng_xtra.c file provides some necessary
+ ancillary and interface functions written by me.)
+
+Icons and graphics:
+-------------------
+
+* Most icons are derived from the AwOken icon set, version 2.5, by
+ Alessandro Roncone (aka alecive); see
+ http://alecive.deviantart.com/art/AwOken-163570862. Many of these icons
+ have been scaled or altered in color from their original forms.
+
+* The Debian icon is based on the SVG available from
+ https://commons.wikimedia.org/wiki/File:Debian-OpenLogo.svg. I modified
+ it to fit the general style set by the AwOken icons.
+
+* The Elementary OS icon is based on the SVG available from
+ https://commons.wikimedia.org/wiki/File:Elementary_logo.svg. I modified
+ it to fit the general style set by the AwOken icons.
+
+* Erik Kemperman provided the original (pre-0.9.3) rEFInd icon, which is a
+ combination of the common refresh/reload icon and the search/find icon.
+ For version 0.9.3, I created a new icon from Erik's basic design concept,
+ but to match the AwOken flat-with-drop-shadow style.
+
+* Additional icons were created by me.
--- /dev/null
+/** @file\r
+ BDS Lib functions which relate with connect the device\r
+\r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "Platform.h"\r
+\r
+\r
+EFI_STATUS ScanDeviceHandles(EFI_HANDLE ControllerHandle,\r
+ UINTN *HandleCount,\r
+ EFI_HANDLE **HandleBuffer,\r
+ UINT32 **HandleType)\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN HandleIndex;\r
+ EFI_GUID **ProtocolGuidArray;\r
+ UINTN ArrayCount;\r
+ UINTN ProtocolIndex;\r
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;\r
+ UINTN OpenInfoCount;\r
+ UINTN OpenInfoIndex;\r
+ UINTN ChildIndex;\r
+\r
+ *HandleCount = 0;\r
+ *HandleBuffer = NULL;\r
+ *HandleType = NULL;\r
+\r
+ //\r
+ // Retrieve the list of all handles from the handle database\r
+ //\r
+ Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, HandleCount, HandleBuffer);\r
+ if (EFI_ERROR (Status)) goto Error;\r
+\r
+ *HandleType = AllocatePool (*HandleCount * sizeof (UINT32));\r
+ if (*HandleType == NULL) goto Error;\r
+\r
+ for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {\r
+ (*HandleType)[HandleIndex] = EFI_HANDLE_TYPE_UNKNOWN;\r
+ //\r
+ // Retrieve the list of all the protocols on each handle\r
+ //\r
+ Status = gBS->ProtocolsPerHandle (\r
+ (*HandleBuffer)[HandleIndex],\r
+ &ProtocolGuidArray,\r
+ &ArrayCount\r
+ );\r
+ if (!EFI_ERROR (Status)) { \r
+ for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) \r
+ {\r
+\r
+ if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid))\r
+ {\r
+ (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_IMAGE_HANDLE;\r
+ }\r
+\r
+ if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid))\r
+ {\r
+ (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_BINDING_HANDLE;\r
+ }\r
+\r
+ if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid)) \r
+ {\r
+ (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_CONFIGURATION_HANDLE;\r
+ }\r
+\r
+ if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid)) \r
+ {\r
+ (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_DIAGNOSTICS_HANDLE;\r
+ }\r
+\r
+ if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid)) \r
+ {\r
+ (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_COMPONENT_NAME_HANDLE;\r
+ }\r
+\r
+ if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) \r
+ {\r
+ (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_COMPONENT_NAME_HANDLE;\r
+ }\r
+\r
+ if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid)) \r
+ {\r
+ (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DEVICE_HANDLE;\r
+ }\r
+\r
+ //\r
+ // Retrieve the list of agents that have opened each protocol\r
+ //\r
+ Status = gBS->OpenProtocolInformation (\r
+ (*HandleBuffer)[HandleIndex],\r
+ ProtocolGuidArray[ProtocolIndex],\r
+ &OpenInfo,\r
+ &OpenInfoCount\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+\r
+ for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
+\r
+ if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle)\r
+ {\r
+ if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == EFI_OPEN_PROTOCOL_BY_DRIVER) \r
+ {\r
+ for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) \r
+ {\r
+ if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].AgentHandle) \r
+ {\r
+ (*HandleType)[ChildIndex] |= EFI_HANDLE_TYPE_DEVICE_DRIVER;\r
+ }\r
+ }\r
+ }\r
+\r
+ if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) == EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER)\r
+ {\r
+ (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_PARENT_HANDLE;\r
+ for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) \r
+ {\r
+ if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].AgentHandle) \r
+ {\r
+ (*HandleType)[ChildIndex] |= EFI_HANDLE_TYPE_BUS_DRIVER;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ FreePool (OpenInfo);\r
+ }\r
+ }\r
+\r
+ FreePool (ProtocolGuidArray);\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+\r
+Error:\r
+ if (*HandleType != NULL) {\r
+ FreePool (*HandleType);\r
+ }\r
+\r
+ if (*HandleBuffer != NULL) {\r
+ FreePool (*HandleBuffer);\r
+ }\r
+\r
+ *HandleCount = 0;\r
+ *HandleBuffer = NULL;\r
+ *HandleType = NULL;\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS BdsLibConnectMostlyAllEfi()\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN AllHandleCount;\r
+ EFI_HANDLE *AllHandleBuffer;\r
+ UINTN Index;\r
+ UINTN HandleCount;\r
+ EFI_HANDLE *HandleBuffer;\r
+ UINT32 *HandleType;\r
+ UINTN HandleIndex;\r
+ BOOLEAN Parent;\r
+ BOOLEAN Device;\r
+ EFI_PCI_IO_PROTOCOL* PciIo;\r
+ PCI_TYPE00 Pci;\r
+ \r
+ \r
+ Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &AllHandleCount, &AllHandleBuffer);\r
+ if (CheckError(Status, L"locating handle buffer")) \r
+ return Status;\r
+ \r
+ for (Index = 0; Index < AllHandleCount; Index++) \r
+ {\r
+ Status = ScanDeviceHandles(AllHandleBuffer[Index], &HandleCount, &HandleBuffer, &HandleType);\r
+ \r
+ if (EFI_ERROR (Status))\r
+ goto Done;\r
+ \r
+ Device = TRUE;\r
+ \r
+ if (HandleType[Index] & EFI_HANDLE_TYPE_DRIVER_BINDING_HANDLE)\r
+ Device = FALSE;\r
+ if (HandleType[Index] & EFI_HANDLE_TYPE_IMAGE_HANDLE)\r
+ Device = FALSE;\r
+ \r
+ if (Device) \r
+ { \r
+ Parent = FALSE;\r
+ for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) \r
+ {\r
+ if (HandleType[HandleIndex] & EFI_HANDLE_TYPE_PARENT_HANDLE)\r
+ Parent = TRUE;\r
+ }\r
+ \r
+ if (!Parent) \r
+ {\r
+ if (HandleType[Index] & EFI_HANDLE_TYPE_DEVICE_HANDLE) \r
+ {\r
+ Status = gBS->HandleProtocol (AllHandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID*)&PciIo);\r
+ if (!EFI_ERROR (Status)) \r
+ {\r
+ Status = PciIo->Pci.Read (PciIo,EfiPciIoWidthUint32, 0, sizeof (Pci) / sizeof (UINT32), &Pci);\r
+ if (!EFI_ERROR (Status))\r
+ {\r
+ if(IS_PCI_VGA(&Pci)==TRUE)\r
+ {\r
+ gBS->DisconnectController(AllHandleBuffer[Index], NULL, NULL);\r
+ }\r
+ }\r
+ }\r
+ Status = gBS->ConnectController(AllHandleBuffer[Index], NULL, NULL, TRUE);\r
+ }\r
+ }\r
+ }\r
+ \r
+ FreePool (HandleBuffer);\r
+ FreePool (HandleType);\r
+ }\r
+ \r
+Done:\r
+ FreePool (AllHandleBuffer);\r
+ return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Connects all drivers to all controllers.\r
+ This function make sure all the current system driver will manage\r
+ the correspoinding controllers if have. And at the same time, make\r
+ sure all the system controllers have driver to manage it if have.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibConnectAllDriversToAllControllers (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ do {\r
+ //\r
+ // Connect All EFI 1.10 drivers following EFI 1.10 algorithm\r
+ //\r
+ //BdsLibConnectAllEfi ();\r
+ BdsLibConnectMostlyAllEfi ();\r
+\r
+ //\r
+ // Check to see if it's possible to dispatch an more DXE drivers.\r
+ // The BdsLibConnectAllEfi () may have made new DXE drivers show up.\r
+ // If anything is Dispatched Status == EFI_SUCCESS and we will try\r
+ // the connect again.\r
+ //\r
+ Status = gDS->Dispatch ();\r
+\r
+ } while (!EFI_ERROR (Status));\r
+\r
+}\r
--- /dev/null
+/*
+ * EfiLib/BdsHelper.c
+ * Functions to call legacy BIOS API.
+ *
+ */
+
+
+#include "BdsHelper.h"
+#include "legacy.h"
+#include "mystrings.h"
+#include "../refind/screen.h"
+#include "../refind/lib.h"
+#include "../include/refit_call_wrapper.h"
+
+EFI_GUID gEfiLegacyBootProtocolGuid = { 0xdb9a1e3d, 0x45cb, 0x4abb, { 0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d }};
+
+/**
+ Internal helper function.
+
+ Update the BBS Table so that devices of DeviceType have their boot priority
+ updated to a high/bootable value.
+
+ See "DeviceType values" in
+ http://www.intel.com/content/dam/doc/reference-guide/efi-compatibility-support-module-specification-v097.pdf
+
+ NOTE: This function should probably be refactored! Currently, all devices of
+ type are enabled. This should be updated so that only a specific device is
+ enabled. The wrong device could boot if there are multiple targets of the same
+ type.
+
+ @param DeviceType The device type that we wish to enable
+**/
+VOID UpdateBbsTable (BDS_COMMON_OPTION *Option) {
+ UINT16 Idx;
+ EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
+ EFI_STATUS Status;
+ UINT16 HddCount = 0;
+ HDD_INFO *HddInfo = NULL;
+ UINT16 BbsCount = 0;
+ BBS_TABLE *LocalBbsTable = NULL;
+ BBS_BBS_DEVICE_PATH *OptionBBS;
+ CHAR16 Desc[100];
+
+ Status = refit_call3_wrapper(gBS->LocateProtocol, &gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
+ if (EFI_ERROR (Status) || (Option == NULL)) {
+ return;
+ }
+
+ OptionBBS = (BBS_BBS_DEVICE_PATH *) Option->DevicePath;
+ Status = refit_call5_wrapper(LegacyBios->GetBbsInfo, LegacyBios, &HddCount, &HddInfo, &BbsCount, &LocalBbsTable);
+
+// Print (L"\n");
+// Print (L" NO Prio bb/dd/ff cl/sc Type Stat segm:offs\n");
+// Print (L"=============================================\n");
+
+ for (Idx = 0; Idx < BbsCount; Idx++) {
+ if(LocalBbsTable[Idx].DeviceType == 0) {
+ continue;
+ }
+
+ BdsBuildLegacyDevNameString (&LocalBbsTable[Idx], Idx, sizeof (Desc), Desc);
+
+ // Set devices of a particular type to BootPriority of 0 or 1. 0 is the highest priority.
+ if (LocalBbsTable[Idx].DeviceType == OptionBBS->DeviceType) {
+ if (MyStriCmp(Desc, Option->Description)) {
+ // This entry exactly matches what we're looking for; make it highest priority
+ LocalBbsTable[Idx].BootPriority = 0;
+ } else {
+ // This entry doesn't exactly match, but is the right disk type; make it a bit lower
+ // in priority. Done mainly as a fallback in case of string-matching weirdness.
+ LocalBbsTable[Idx].BootPriority = 1;
+ } // if/else
+ } else if (LocalBbsTable[Idx].BootPriority <= 1) {
+ // Something's got a high enough boot priority to interfere with booting
+ // our chosen entry, so bump it down a bit....
+ LocalBbsTable[Idx].BootPriority = 2;
+ } // if/else if
+
+// Print (
+// L" %02x: %04x %02x/%02x/%02x %02x/%02x %04x %04x %04x:%04x\n",
+// (UINTN) Idx,
+// (UINTN) LocalBbsTable[Idx].BootPriority,
+// (UINTN) LocalBbsTable[Idx].Bus,
+// (UINTN) LocalBbsTable[Idx].Device,
+// (UINTN) LocalBbsTable[Idx].Function,
+// (UINTN) LocalBbsTable[Idx].Class,
+// (UINTN) LocalBbsTable[Idx].SubClass,
+// (UINTN) LocalBbsTable[Idx].DeviceType,
+// (UINTN) * (UINT16 *) &LocalBbsTable[Idx].StatusFlags,
+// (UINTN) LocalBbsTable[Idx].BootHandlerSegment,
+// (UINTN) LocalBbsTable[Idx].BootHandlerOffset,
+// (UINTN) ((LocalBbsTable[Idx].MfgStringSegment << 4) + LocalBbsTable[Idx].MfgStringOffset),
+// (UINTN) ((LocalBbsTable[Idx].DescStringSegment << 4) + LocalBbsTable[Idx].DescStringOffset)
+// );
+// Print(L"%s\n", Desc);
+
+ } // for
+// PauseForKey();
+}
+
+/**
+ Boot the legacy system with the boot option
+
+ @param Option The legacy boot option which have BBS device path
+
+ @retval EFI_UNSUPPORTED There is no legacybios protocol, do not support
+ legacy boot.
+ @retval EFI_STATUS Return the status of LegacyBios->LegacyBoot ().
+
+**/
+EFI_STATUS
+BdsLibDoLegacyBoot (
+ IN BDS_COMMON_OPTION *Option
+ )
+{
+ EFI_STATUS Status;
+ EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
+
+ Status = refit_call3_wrapper(gBS->LocateProtocol, &gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ UpdateBbsTable(Option);
+
+ return refit_call4_wrapper(LegacyBios->LegacyBoot, LegacyBios, (BBS_BBS_DEVICE_PATH *) Option->DevicePath,
+ Option->LoadOptionsSize, Option->LoadOptions);
+}
--- /dev/null
+/*
+ * EfiLib/BdsHelper.c
+ * Functions to call legacy BIOS API.
+ *
+ */
+
+#ifdef __MAKEWITH_TIANO
+#include "../include/tiano_includes.h"
+#else
+#include "gnuefi-helper.h"
+#include "GenericBdsLib.h"
+#endif
+
+#ifndef _BDS_HELPER_H_
+#define _BDS_HELPER_H_
+
+
+/**
+ Boot the legacy system with the boot option
+
+ @param Option The legacy boot option which have BBS device path
+
+ @retval EFI_UNSUPPORTED There is no legacybios protocol, do not support
+ legacy boot.
+ @retval EFI_STATUS Return the status of LegacyBios->LegacyBoot ().
+
+**/
+EFI_STATUS
+BdsLibDoLegacyBoot (
+ IN BDS_COMMON_OPTION *Option
+ );
+
+EFI_STATUS BdsConnectDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
+ OUT EFI_HANDLE * Handle,
+ OUT EFI_DEVICE_PATH_PROTOCOL ** RemainingDevicePath
+);
+
+#endif //_BDS_HELPER_H_
--- /dev/null
+/** @file
+ BDS Lib functions which relate with create or process the boot option.
+
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifdef __MAKEWITH_TIANO
+#include "../include/tiano_includes.h"
+#else
+#include "BdsHelper.h"
+#include "gnuefi-helper.h"
+#endif
+#include "../include/refit_call_wrapper.h"
+
+EFI_GUID EfiDevicePathProtocolGuid = { 0x09576E91, 0x6D3F, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+
+/**
+ This function will create all handles associate with every device
+ path node. If the handle associate with one device path node can not
+ be created success, then still give one chance to do the dispatch,
+ which load the missing drivers if possible.
+
+ @param DevicePathToConnect The device path which will be connected, it can be
+ a multi-instance device path
+
+ @retval EFI_SUCCESS All handles associate with every device path node
+ have been created
+ @retval EFI_OUT_OF_RESOURCES There is no resource to create new handles
+ @retval EFI_NOT_FOUND Create the handle associate with one device path
+ node failed
+
+**/
+EFI_STATUS
+BdsLibConnectDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *Instance;
+ EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *Next;
+ EFI_HANDLE Handle;
+ EFI_HANDLE PreviousHandle;
+ UINTN Size;
+
+ if (DevicePathToConnect == NULL) {
+ return EFI_SUCCESS;
+ }
+
+ DevicePath = DuplicateDevicePath (DevicePathToConnect);
+ if (DevicePath == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ CopyOfDevicePath = DevicePath;
+
+ do {
+ //
+ // The outer loop handles multi instance device paths.
+ // Only console variables contain multiple instance device paths.
+ //
+ // After this call DevicePath points to the next Instance
+ //
+ Instance = GetNextDevicePathInstance (&DevicePath, &Size);
+ if (Instance == NULL) {
+ FreePool (CopyOfDevicePath);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Next = Instance;
+ while (!IsDevicePathEndType (Next)) {
+ Next = NextDevicePathNode (Next);
+ }
+
+ SetDevicePathEndNode (Next);
+
+ //
+ // Start the real work of connect with RemainingDevicePath
+ //
+ PreviousHandle = NULL;
+ do {
+ //
+ // Find the handle that best matches the Device Path. If it is only a
+ // partial match the remaining part of the device path is returned in
+ // RemainingDevicePath.
+ //
+ RemainingDevicePath = Instance;
+ Status = refit_call3_wrapper(gBS->LocateDevicePath, &EfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
+
+ if (!EFI_ERROR (Status)) {
+#ifdef __MAKEWITH_TIANO
+ if (Handle == PreviousHandle) {
+ //
+ // If no forward progress is made try invoking the Dispatcher.
+ // A new FV may have been added to the system an new drivers
+ // may now be found.
+ // Status == EFI_SUCCESS means a driver was dispatched
+ // Status == EFI_NOT_FOUND means no new drivers were dispatched
+ //
+ Status = gDS->Dispatch ();
+ }
+#endif
+
+ if (!EFI_ERROR (Status)) {
+ PreviousHandle = Handle;
+ //
+ // Connect all drivers that apply to Handle and RemainingDevicePath,
+ // the Recursive flag is FALSE so only one level will be expanded.
+ //
+ // Do not check the connect status here, if the connect controller fail,
+ // then still give the chance to do dispatch, because partial
+ // RemainingDevicepath may be in the new FV
+ //
+ // 1. If the connect fail, RemainingDevicepath and handle will not
+ // change, so next time will do the dispatch, then dispatch's status
+ // will take effect
+ // 2. If the connect success, the RemainingDevicepath and handle will
+ // change, then avoid the dispatch, we have chance to continue the
+ // next connection
+ //
+ refit_call4_wrapper(gBS->ConnectController, Handle, NULL, RemainingDevicePath, FALSE);
+ }
+ }
+ //
+ // Loop until RemainingDevicePath is an empty device path
+ //
+ } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
+
+ } while (DevicePath != NULL);
+
+ if (CopyOfDevicePath != NULL) {
+ FreePool (CopyOfDevicePath);
+ }
+ //
+ // All handle with DevicePath exists in the handle database
+ //
+ return Status;
+}
+
+/**
+ Build the boot#### or driver#### option from the VariableName, the
+ build boot#### or driver#### will also be linked to BdsCommonOptionList.
+
+ @param BdsCommonOptionList The header of the boot#### or driver#### option
+ link list
+ @param VariableName EFI Variable name indicate if it is boot#### or
+ driver####
+
+ @retval BDS_COMMON_OPTION Get the option just been created
+ @retval NULL Failed to get the new option
+
+**/
+BDS_COMMON_OPTION *
+BdsLibVariableToOption (
+ IN OUT LIST_ENTRY *BdsCommonOptionList,
+ IN CHAR16 *VariableName
+ )
+{
+ UINT32 Attribute;
+ UINT16 FilePathSize;
+ UINT8 *Variable;
+ UINT8 *TempPtr;
+ UINTN VariableSize;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ BDS_COMMON_OPTION *Option;
+ VOID *LoadOptions;
+ UINT32 LoadOptionsSize;
+ CHAR16 *Description;
+ UINT8 NumOff;
+ EFI_GUID EfiGlobalVariableGuid = { 0x8BE4DF61, 0x93CA, 0x11D2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }};
+
+ //
+ // Read the variable. We will never free this data.
+ //
+ Variable = BdsLibGetVariableAndSize (
+ VariableName,
+ &EfiGlobalVariableGuid,
+ &VariableSize
+ );
+ if (Variable == NULL) {
+ return NULL;
+ }
+ //
+ // Notes: careful defined the variable of Boot#### or
+ // Driver####, consider use some macro to abstract the code
+ //
+ //
+ // Get the option attribute
+ //
+ TempPtr = Variable;
+ Attribute = *(UINT32 *) Variable;
+ TempPtr += sizeof (UINT32);
+
+ //
+ // Get the option's device path size
+ //
+ FilePathSize = *(UINT16 *) TempPtr;
+ TempPtr += sizeof (UINT16);
+
+ //
+ // Get the option's description string
+ //
+ Description = (CHAR16 *) TempPtr;
+
+ //
+ // Get the option's description string size
+ //
+ TempPtr += StrSize ((CHAR16 *) TempPtr);
+
+ //
+ // Get the option's device path
+ //
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;
+ TempPtr += FilePathSize;
+
+ LoadOptions = TempPtr;
+ LoadOptionsSize = (UINT32) (VariableSize - (UINTN) (TempPtr - Variable));
+
+ //
+ // The Console variables may have multiple device paths, so make
+ // an Entry for each one.
+ //
+ Option = AllocateZeroPool (sizeof (BDS_COMMON_OPTION));
+ if (Option == NULL) {
+ return NULL;
+ }
+
+ Option->Signature = BDS_LOAD_OPTION_SIGNATURE;
+ Option->DevicePath = AllocateZeroPool (GetDevicePathSize (DevicePath));
+ ASSERT(Option->DevicePath != NULL);
+ CopyMem (Option->DevicePath, DevicePath, GetDevicePathSize (DevicePath));
+
+ Option->Attribute = Attribute;
+ Option->Description = AllocateZeroPool (StrSize (Description));
+ ASSERT(Option->Description != NULL);
+ CopyMem (Option->Description, Description, StrSize (Description));
+
+ Option->LoadOptions = AllocateZeroPool (LoadOptionsSize);
+ ASSERT(Option->LoadOptions != NULL);
+ CopyMem (Option->LoadOptions, LoadOptions, LoadOptionsSize);
+ Option->LoadOptionsSize = LoadOptionsSize;
+
+ //
+ // Get the value from VariableName Unicode string
+ // since the ISO standard assumes ASCII equivalent abbreviations, we can be safe in converting this
+ // Unicode stream to ASCII without any loss in meaning.
+ //
+ if (*VariableName == 'B') {
+ NumOff = (UINT8) (sizeof (L"Boot") / sizeof(CHAR16) - 1);
+ Option->BootCurrent = (UINT16) ((VariableName[NumOff] -'0') * 0x1000);
+ Option->BootCurrent = (UINT16) (Option->BootCurrent + ((VariableName[NumOff+1]-'0') * 0x100));
+ Option->BootCurrent = (UINT16) (Option->BootCurrent + ((VariableName[NumOff+2]-'0') * 0x10));
+ Option->BootCurrent = (UINT16) (Option->BootCurrent + ((VariableName[NumOff+3]-'0')));
+ }
+ //
+ // Insert active entry to BdsDeviceList
+ //
+ if ((Option->Attribute & LOAD_OPTION_ACTIVE) == LOAD_OPTION_ACTIVE) {
+ InsertTailList (BdsCommonOptionList, &Option->Link);
+ FreePool (Variable);
+ return Option;
+ }
+
+ FreePool (Variable);
+ FreePool (Option);
+ return NULL;
+
+}
+
+
+/**
+ Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
+ buffer, and the size of the buffer. If failure return NULL.
+
+ @param Name String part of EFI variable name
+ @param VendorGuid GUID part of EFI variable name
+ @param VariableSize Returns the size of the EFI variable that was read
+
+ @return Dynamically allocated memory that contains a copy of the EFI variable
+ Caller is responsible freeing the buffer.
+ @retval NULL Variable was not read
+
+**/
+VOID *
+BdsLibGetVariableAndSize (
+ IN CHAR16 *Name,
+ IN EFI_GUID *VendorGuid,
+ OUT UINTN *VariableSize
+ )
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ VOID *Buffer;
+
+ Buffer = NULL;
+
+ //
+ // Pass in a zero size buffer to find the required buffer size.
+ //
+ BufferSize = 0;
+ Status = refit_call5_wrapper(gRT->GetVariable, Name, VendorGuid, NULL, &BufferSize, Buffer);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ //
+ // Allocate the buffer to return
+ //
+ Buffer = AllocateZeroPool (BufferSize);
+ if (Buffer == NULL) {
+ return NULL;
+ }
+ //
+ // Read variable into the allocated buffer.
+ //
+ Status = refit_call5_wrapper(gRT->GetVariable, Name, VendorGuid, NULL, &BufferSize, Buffer);
+ if (EFI_ERROR (Status)) {
+ BufferSize = 0;
+ }
+ }
+
+ *VariableSize = BufferSize;
+ return Buffer;
+}
+
--- /dev/null
+/** @file\r
+ Utility routines used by boot maintenance modules.\r
+\r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifdef __MAKEWITH_TIANO\r
+#include "Platform.h"\r
+#else\r
+#include "gnuefi-helper.h"\r
+#endif\r
+#include "../include/refit_call_wrapper.h"\r
+\r
+/**\r
+\r
+ Find the first instance of this Protocol\r
+ in the system and return it's interface.\r
+\r
+\r
+ @param ProtocolGuid Provides the protocol to search for\r
+ @param Interface On return, a pointer to the first interface\r
+ that matches ProtocolGuid\r
+\r
+ @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found\r
+ @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid\r
+\r
+**/\r
+EFI_STATUS\r
+EfiLibLocateProtocol (\r
+ IN EFI_GUID *ProtocolGuid,\r
+ OUT VOID **Interface\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = refit_call3_wrapper(gBS->LocateProtocol,\r
+ ProtocolGuid,\r
+ NULL,\r
+ (VOID **) Interface\r
+ );\r
+ return Status;\r
+}\r
+\r
+/**\r
+\r
+ Function opens and returns a file handle to the root directory of a volume.\r
+\r
+ @param DeviceHandle A handle for a device\r
+\r
+ @return A valid file handle or NULL is returned\r
+\r
+**/\r
+EFI_FILE_HANDLE\r
+EfiLibOpenRoot (\r
+ IN EFI_HANDLE DeviceHandle\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;\r
+ EFI_FILE_HANDLE File;\r
+\r
+ File = NULL;\r
+\r
+ //\r
+ // File the file system interface to the device\r
+ //\r
+ Status = refit_call3_wrapper(gBS->HandleProtocol,\r
+ DeviceHandle,\r
+ &gEfiSimpleFileSystemProtocolGuid,\r
+ (VOID **) &Volume\r
+ );\r
+\r
+ //\r
+ // Open the root directory of the volume\r
+ //\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = Volume->OpenVolume (\r
+ Volume,\r
+ &File\r
+ );\r
+ }\r
+ //\r
+ // Done\r
+ //\r
+ return EFI_ERROR (Status) ? NULL : File;\r
+}\r
+\r
+/**\r
+ Duplicate a string.\r
+\r
+ @param Src The source.\r
+\r
+ @return A new string which is duplicated copy of the source.\r
+ @retval NULL If there is not enough memory.\r
+\r
+**/\r
+CHAR16 *\r
+EfiStrDuplicate (\r
+ IN CHAR16 *Src\r
+ )\r
+{\r
+ CHAR16 *Dest;\r
+ UINTN Size;\r
+\r
+ Size = StrSize (Src); //at least 2bytes\r
+ Dest = AllocateZeroPool (Size);\r
+ if (Dest != NULL) {\r
+ CopyMem (Dest, Src, Size);\r
+ }\r
+\r
+ return Dest;\r
+}\r
+\r
+/**\r
+\r
+ Function gets the file information from an open file descriptor, and stores it\r
+ in a buffer allocated from pool.\r
+\r
+ @param FHand File Handle.\r
+\r
+ @return A pointer to a buffer with file information or NULL is returned\r
+\r
+**/\r
+EFI_FILE_INFO *\r
+EfiLibFileInfo (\r
+ IN EFI_FILE_HANDLE FHand\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_FILE_INFO *FileInfo = NULL;\r
+ UINTN Size = 0;\r
+ \r
+ Status = FHand->GetInfo (FHand, &gEfiFileInfoGuid, &Size, FileInfo);\r
+ if (Status == EFI_BUFFER_TOO_SMALL) {\r
+ FileInfo = AllocateZeroPool (Size);\r
+ Status = FHand->GetInfo (FHand, &gEfiFileInfoGuid, &Size, FileInfo);\r
+ }\r
+ \r
+ return EFI_ERROR(Status)?NULL:FileInfo;\r
+}\r
+\r
+EFI_FILE_SYSTEM_INFO *\r
+EfiLibFileSystemInfo (\r
+ IN EFI_FILE_HANDLE FHand\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_FILE_SYSTEM_INFO *FileSystemInfo = NULL;\r
+ UINTN Size = 0;\r
+\r
+ Status = FHand->GetInfo (FHand, &gEfiFileSystemInfoGuid, &Size, FileSystemInfo);\r
+ if (Status == EFI_BUFFER_TOO_SMALL) {\r
+ FileSystemInfo = AllocateZeroPool (Size);\r
+ Status = FHand->GetInfo (FHand, &gEfiFileSystemInfoGuid, &Size, FileSystemInfo);\r
+ }\r
+\r
+ return EFI_ERROR(Status)?NULL:FileSystemInfo;\r
+}\r
+\r
+/**\r
+ Adjusts the size of a previously allocated buffer.\r
+\r
+\r
+ @param OldPool - A pointer to the buffer whose size is being adjusted.\r
+ @param OldSize - The size of the current buffer.\r
+ @param NewSize - The size of the new buffer.\r
+\r
+ @return The newly allocated buffer.\r
+ @retval NULL Allocation failed.\r
+\r
+**/\r
+VOID *\r
+EfiReallocatePool (\r
+ IN VOID *OldPool,\r
+ IN UINTN OldSize,\r
+ IN UINTN NewSize\r
+ )\r
+{\r
+ VOID *NewPool;\r
+\r
+ NewPool = NULL;\r
+ if (NewSize != 0) {\r
+ NewPool = AllocateZeroPool (NewSize);\r
+ }\r
+\r
+ if (OldPool != NULL) {\r
+ if (NewPool != NULL) {\r
+ CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
+ }\r
+\r
+ FreePool (OldPool);\r
+ }\r
+\r
+ return NewPool;\r
+}\r
--- /dev/null
+/** @file\r
+ BDS internal function define the default device path string, it can be\r
+ replaced by platform device path.\r
+\r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "Platform.h"\r
+\r
+/**\r
+ Concatenates a formatted unicode string to allocated pool.\r
+ The caller must free the resulting buffer.\r
+\r
+ @param Str Tracks the allocated pool, size in use, and amount of pool allocated.\r
+ @param Fmt The format string\r
+ @param ... The data will be printed.\r
+\r
+ @return Allocated buffer with the formatted string printed in it.\r
+ The caller must free the allocated buffer.\r
+ The buffer allocation is not packed.\r
+\r
+**/\r
+\r
+CHAR16 *\r
+EFIAPI\r
+CatPrint (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN CHAR16 *Fmt,\r
+ ...\r
+ )\r
+{\r
+ UINT16 *AppendStr;\r
+ VA_LIST Args;\r
+ UINTN StringSize;\r
+\r
+ AppendStr = AllocateZeroPool (0x1000);\r
+ if (AppendStr == NULL) {\r
+ return Str->Str;\r
+ }\r
+\r
+ VA_START (Args, Fmt);\r
+ UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r
+ VA_END (Args);\r
+ if (NULL == Str->Str) {\r
+ StringSize = StrSize (AppendStr);\r
+ Str->Str = AllocateZeroPool (StringSize);\r
+ ASSERT (Str->Str != NULL);\r
+ } else {\r
+ StringSize = StrSize (AppendStr);\r
+ StringSize += (StrSize (Str->Str) - sizeof (UINT16));\r
+\r
+ Str->Str = EfiReallocatePool (\r
+ Str->Str, \r
+ StrSize (Str->Str),\r
+ StringSize \r
+ );\r
+ ASSERT (Str->Str != NULL);\r
+ }\r
+\r
+ Str->Maxlen = MAX_CHAR * sizeof (UINT16);\r
+ if (StringSize < Str->Maxlen) {\r
+ StrCat (Str->Str, AppendStr);\r
+ Str->Len = StringSize - sizeof (UINT16);\r
+ }\r
+\r
+ FreePool (AppendStr);\r
+ return Str->Str;\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathPci (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ PCI_DEVICE_PATH *Pci;\r
+\r
+ Pci = DevPath;\r
+ CatPrint (Str, L"Pci(%x|%x)", (UINTN) Pci->Device, (UINTN) Pci->Function);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathPccard (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ PCCARD_DEVICE_PATH *Pccard;\r
+\r
+ Pccard = DevPath;\r
+ CatPrint (Str, L"Pcmcia(Function%x)", (UINTN) Pccard->FunctionNumber);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathMemMap (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ MEMMAP_DEVICE_PATH *MemMap;\r
+\r
+ MemMap = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"MemMap(%d:%lx-%lx)",\r
+ (UINTN) MemMap->MemoryType,\r
+ MemMap->StartingAddress,\r
+ MemMap->EndingAddress\r
+ );\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathController (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ CONTROLLER_DEVICE_PATH *Controller;\r
+\r
+ Controller = DevPath;\r
+ CatPrint (Str, L"Ctrl(%d)", (UINTN) Controller->ControllerNumber);\r
+}\r
+\r
+\r
+/**\r
+ Convert Vendor device path to device name.\r
+\r
+ @param Str The buffer store device name\r
+ @param DevPath Pointer to vendor device path\r
+\r
+**/\r
+VOID\r
+DevPathVendor (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ VENDOR_DEVICE_PATH *Vendor;\r
+ CHAR16 *Type;\r
+ UINTN DataLength;\r
+ UINTN Index;\r
+// UINT32 FlowControlMap;\r
+\r
+ UINT16 Info;\r
+\r
+ Vendor = DevPath;\r
+\r
+ switch (DevicePathType (&Vendor->Header)) {\r
+ case HARDWARE_DEVICE_PATH:\r
+ Type = L"Hw";\r
+ break;\r
+\r
+ case MESSAGING_DEVICE_PATH:\r
+ Type = L"Msg";\r
+/* \r
+ if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {\r
+ CatPrint (Str, L"VenPcAnsi()");\r
+ return ;\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {\r
+ CatPrint (Str, L"VenVt100()");\r
+ return ;\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {\r
+ CatPrint (Str, L"VenVt100Plus()");\r
+ return ;\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
+ CatPrint (Str, L"VenUft8()");\r
+ return ;\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid )) {\r
+ FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
+ switch (FlowControlMap & 0x00000003) {\r
+ case 0:\r
+ CatPrint (Str, L"UartFlowCtrl(%s)", L"None");\r
+ break;\r
+\r
+ case 1:\r
+ CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");\r
+ break;\r
+\r
+ case 2:\r
+ CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return ;\r
+\r
+ } else\r
+ */\r
+ if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r
+ CatPrint (\r
+ Str,\r
+ L"SAS(%lx,%lx,%x,",\r
+ ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
+ ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
+ (UINTN) ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
+ );\r
+ Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
+ if ((Info & 0x0f) == 0) {\r
+ CatPrint (Str, L"NoTopology,0,0,0,");\r
+ } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {\r
+ CatPrint (\r
+ Str,\r
+ L"%s,%s,%s,",\r
+ ((Info & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",\r
+ ((Info & (0x1 << 5)) != 0) ? L"External" : L"Internal",\r
+ ((Info & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"\r
+ );\r
+ if ((Info & 0x0f) == 1) {\r
+ CatPrint (Str, L"0,");\r
+ } else {\r
+ CatPrint (Str, L"%x,", (UINTN) ((Info >> 8) & 0xff));\r
+ }\r
+ } else {\r
+ CatPrint (Str, L"0,0,0,0,");\r
+ }\r
+\r
+ CatPrint (Str, L"%x)", (UINTN) ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
+ return ;\r
+\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
+ CatPrint (Str, L"DebugPort()");\r
+ return ;\r
+ }\r
+ break;\r
+\r
+ case MEDIA_DEVICE_PATH:\r
+ Type = L"Media";\r
+ break;\r
+\r
+ default:\r
+ Type = L"?";\r
+ break;\r
+ }\r
+\r
+ CatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid);\r
+ DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);\r
+ if (DataLength > 0) {\r
+ CatPrint (Str, L",");\r
+ for (Index = 0; Index < DataLength; Index++) {\r
+ CatPrint (Str, L"%02x", (UINTN) ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
+ }\r
+ }\r
+ CatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathAcpi (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ ACPI_HID_DEVICE_PATH *Acpi;\r
+\r
+ Acpi = DevPath;\r
+ if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+ CatPrint (Str, L"Acpi(PNP%04x,%x)", (UINTN) EISA_ID_TO_NUM (Acpi->HID), (UINTN) Acpi->UID);\r
+ } else {\r
+ CatPrint (Str, L"Acpi(%08x,%x)", (UINTN) Acpi->HID, (UINTN) Acpi->UID);\r
+ }\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathExtendedAcpi (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ ACPI_EXTENDED_HID_DEVICE_PATH *ExtendedAcpi;\r
+ \r
+ //\r
+ // Index for HID, UID and CID strings, 0 for non-exist\r
+ //\r
+ UINT16 HIDSTRIdx;\r
+ UINT16 UIDSTRIdx;\r
+ UINT16 CIDSTRIdx;\r
+ UINT16 Index;\r
+ UINT16 Length;\r
+ UINT16 Anchor;\r
+ CHAR8 *AsChar8Array;\r
+\r
+ HIDSTRIdx = 0;\r
+ UIDSTRIdx = 0;\r
+ CIDSTRIdx = 0;\r
+ ExtendedAcpi = DevPath;\r
+ Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) ExtendedAcpi);\r
+\r
+ AsChar8Array = (CHAR8 *) ExtendedAcpi;\r
+\r
+ //\r
+ // find HIDSTR\r
+ //\r
+ Anchor = 16;\r
+ for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
+ ;\r
+ }\r
+ if (Index > Anchor) {\r
+ HIDSTRIdx = Anchor;\r
+ }\r
+ //\r
+ // find UIDSTR\r
+ //\r
+ Anchor = (UINT16) (Index + 1);\r
+ for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
+ ;\r
+ }\r
+ if (Index > Anchor) {\r
+ UIDSTRIdx = Anchor;\r
+ }\r
+ //\r
+ // find CIDSTR\r
+ //\r
+ Anchor = (UINT16) (Index + 1);\r
+ for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
+ ;\r
+ }\r
+ if (Index > Anchor) {\r
+ CIDSTRIdx = Anchor;\r
+ }\r
+\r
+ if (HIDSTRIdx == 0 && CIDSTRIdx == 0 && ExtendedAcpi->UID == 0) {\r
+ CatPrint (Str, L"AcpiExp(");\r
+ if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+ CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->HID));\r
+ } else {\r
+ CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID);\r
+ }\r
+ if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+ CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->CID));\r
+ } else {\r
+ CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->CID);\r
+ }\r
+ if (UIDSTRIdx != 0) {\r
+ CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx);\r
+ } else {\r
+ CatPrint (Str, L"\"\")");\r
+ }\r
+ } else {\r
+ CatPrint (Str, L"AcpiEx(");\r
+ if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+ CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->HID));\r
+ } else {\r
+ CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID);\r
+ }\r
+ if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+ CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->CID));\r
+ } else {\r
+ CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->CID);\r
+ }\r
+ CatPrint (Str, L"%x,", (UINTN) ExtendedAcpi->UID);\r
+\r
+ if (HIDSTRIdx != 0) {\r
+ CatPrint (Str, L"%a,", AsChar8Array + HIDSTRIdx);\r
+ } else {\r
+ CatPrint (Str, L"\"\",");\r
+ }\r
+ if (CIDSTRIdx != 0) {\r
+ CatPrint (Str, L"%a,", AsChar8Array + CIDSTRIdx);\r
+ } else {\r
+ CatPrint (Str, L"\"\",");\r
+ }\r
+ if (UIDSTRIdx != 0) {\r
+ CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx);\r
+ } else {\r
+ CatPrint (Str, L"\"\")");\r
+ }\r
+ }\r
+\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathAdrAcpi (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ ACPI_ADR_DEVICE_PATH *AcpiAdr;\r
+ UINT16 Index;\r
+ UINT16 Length;\r
+ UINT16 AdditionalAdrCount;\r
+\r
+ AcpiAdr = DevPath;\r
+ Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);\r
+ AdditionalAdrCount = (UINT16) ((Length - 8) / 4);\r
+\r
+ CatPrint (Str, L"AcpiAdr(%x", (UINTN) AcpiAdr->ADR);\r
+ for (Index = 0; Index < AdditionalAdrCount; Index++) {\r
+ CatPrint (Str, L",%x", (UINTN) *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
+ }\r
+ CatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathAtapi (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ ATAPI_DEVICE_PATH *Atapi;\r
+\r
+ Atapi = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"Ata(%s,%s)",\r
+ (Atapi->PrimarySecondary != 0)? L"Secondary" : L"Primary",\r
+ (Atapi->SlaveMaster != 0)? L"Slave" : L"Master"\r
+ );\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathScsi (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ SCSI_DEVICE_PATH *Scsi;\r
+\r
+ Scsi = DevPath;\r
+ CatPrint (Str, L"Scsi(Pun%x,Lun%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathFibre (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ FIBRECHANNEL_DEVICE_PATH *Fibre;\r
+\r
+ Fibre = DevPath;\r
+ CatPrint (Str, L"Fibre(Wwn%lx,Lun%x)", Fibre->WWN, Fibre->Lun);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPath1394 (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ F1394_DEVICE_PATH *F1394Path;\r
+\r
+ F1394Path = DevPath;\r
+ CatPrint (Str, L"1394(%lx)", &F1394Path->Guid);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathUsb (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ USB_DEVICE_PATH *Usb;\r
+\r
+ Usb = DevPath;\r
+ CatPrint (Str, L"Usb(%x,%x)", (UINTN) Usb->ParentPortNumber, (UINTN) Usb->InterfaceNumber);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathUsbWWID (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ USB_WWID_DEVICE_PATH *UsbWWId;\r
+\r
+ UsbWWId = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"UsbWwid(%x,%x,%x,\"WWID\")",\r
+ (UINTN) UsbWWId->VendorId,\r
+ (UINTN) UsbWWId->ProductId,\r
+ (UINTN) UsbWWId->InterfaceNumber\r
+ );\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathLogicalUnit (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
+\r
+ LogicalUnit = DevPath;\r
+ CatPrint (Str, L"Unit(%x)", (UINTN) LogicalUnit->Lun);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathUsbClass (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ USB_CLASS_DEVICE_PATH *UsbClass;\r
+\r
+ UsbClass = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"Usb Class(%x,%x,%x,%x,%x)",\r
+ (UINTN) UsbClass->VendorId,\r
+ (UINTN) UsbClass->ProductId,\r
+ (UINTN) UsbClass->DeviceClass,\r
+ (UINTN) UsbClass->DeviceSubClass,\r
+ (UINTN) UsbClass->DeviceProtocol\r
+ );\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathSata (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ SATA_DEVICE_PATH *Sata;\r
+\r
+ Sata = DevPath;\r
+ if ((Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) != 0) {\r
+ CatPrint (\r
+ Str,\r
+ L"Sata(%x,%x)",\r
+ (UINTN) Sata->HBAPortNumber,\r
+ (UINTN) Sata->Lun\r
+ );\r
+ } else {\r
+ CatPrint (\r
+ Str,\r
+ L"Sata(%x,%x,%x)",\r
+ (UINTN) Sata->HBAPortNumber,\r
+ (UINTN) Sata->PortMultiplierPortNumber,\r
+ (UINTN) Sata->Lun\r
+ );\r
+ }\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathI2O (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ I2O_DEVICE_PATH *I2OPath;\r
+\r
+ I2OPath = DevPath;\r
+ CatPrint (Str, L"I2O(%x)", (UINTN) I2OPath->Tid);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathMacAddr (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ MAC_ADDR_DEVICE_PATH *MACDevPath;\r
+ UINTN HwAddressSize;\r
+ UINTN Index;\r
+\r
+ MACDevPath = DevPath;\r
+\r
+ HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
+ if (MACDevPath->IfType == 0x01 || MACDevPath->IfType == 0x00) {\r
+ HwAddressSize = 6;\r
+ }\r
+\r
+ CatPrint (Str, L"Mac(");\r
+\r
+ for (Index = 0; Index < HwAddressSize; Index++) {\r
+ CatPrint (Str, L"%02x", (UINTN) MACDevPath->MacAddress.Addr[Index]);\r
+ }\r
+\r
+ CatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathIPv4 (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ IPv4_DEVICE_PATH *IPDevPath;\r
+\r
+ IPDevPath = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"IPv4(%d.%d.%d.%d:%d)",\r
+ (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
+ (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
+ (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
+ (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r
+ (UINTN) IPDevPath->RemotePort\r
+ );\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathIPv6 (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ IPv6_DEVICE_PATH *IPv6DevPath;\r
+\r
+ IPv6DevPath = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[0],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[1],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[2],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[3],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[4],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[5],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[6],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[7],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[8],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[9],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[10],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[11],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[12],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[13],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[14],\r
+ (UINTN) IPv6DevPath->RemoteIpAddress.Addr[15]\r
+ );\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathInfiniBand (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ INFINIBAND_DEVICE_PATH *InfiniBand;\r
+\r
+ InfiniBand = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"Infiniband(%x,%g,%lx,%lx,%lx)",\r
+ (UINTN) InfiniBand->ResourceFlags,\r
+ InfiniBand->PortGid,\r
+ InfiniBand->ServiceId,\r
+ InfiniBand->TargetPortId,\r
+ InfiniBand->DeviceId\r
+ );\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathUart (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ UART_DEVICE_PATH *Uart;\r
+ CHAR8 Parity;\r
+\r
+ Uart = DevPath;\r
+ switch (Uart->Parity) {\r
+ case 0:\r
+ Parity = 'D';\r
+ break;\r
+\r
+ case 1:\r
+ Parity = 'N';\r
+ break;\r
+\r
+ case 2:\r
+ Parity = 'E';\r
+ break;\r
+\r
+ case 3:\r
+ Parity = 'O';\r
+ break;\r
+\r
+ case 4:\r
+ Parity = 'M';\r
+ break;\r
+\r
+ case 5:\r
+ Parity = 'S';\r
+ break;\r
+\r
+ default:\r
+ Parity = 'x';\r
+ break;\r
+ }\r
+\r
+ if (Uart->BaudRate == 0) {\r
+ CatPrint (Str, L"Uart(DEFAULT,%c,", Parity);\r
+ } else {\r
+ CatPrint (Str, L"Uart(%ld,%c,", Uart->BaudRate, Parity);\r
+ }\r
+\r
+ if (Uart->DataBits == 0) {\r
+ CatPrint (Str, L"D,");\r
+ } else {\r
+ CatPrint (Str, L"%d,", (UINTN) Uart->DataBits);\r
+ }\r
+\r
+ switch (Uart->StopBits) {\r
+ case 0:\r
+ CatPrint (Str, L"D)");\r
+ break;\r
+\r
+ case 1:\r
+ CatPrint (Str, L"1)");\r
+ break;\r
+\r
+ case 2:\r
+ CatPrint (Str, L"1.5)");\r
+ break;\r
+\r
+ case 3:\r
+ CatPrint (Str, L"2)");\r
+ break;\r
+\r
+ default:\r
+ CatPrint (Str, L"x)");\r
+ break;\r
+ }\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathiSCSI (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ ISCSI_DEVICE_PATH_WITH_NAME *IScsi;\r
+ UINT16 Options;\r
+\r
+ IScsi = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"iSCSI(%a,%x,%lx,",\r
+ IScsi->TargetName,\r
+ (UINTN) IScsi->TargetPortalGroupTag,\r
+ IScsi->Lun\r
+ );\r
+\r
+ Options = IScsi->LoginOption;\r
+ CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
+ CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
+ if (((Options >> 11) & 0x0001) != 0) {\r
+ CatPrint (Str, L"%s,", L"None");\r
+ } else if (((Options >> 12) & 0x0001) != 0) {\r
+ CatPrint (Str, L"%s,", L"CHAP_UNI");\r
+ } else {\r
+ CatPrint (Str, L"%s,", L"CHAP_BI");\r
+\r
+ }\r
+\r
+ CatPrint (Str, L"%s)", (IScsi->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathVlan (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ VLAN_DEVICE_PATH *Vlan;\r
+\r
+ Vlan = DevPath;\r
+ CatPrint (Str, L"Vlan(%d)", (UINTN) Vlan->VlanId);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathHardDrive (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ HARDDRIVE_DEVICE_PATH *Hd;\r
+\r
+ Hd = DevPath;\r
+ switch (Hd->SignatureType) {\r
+ case SIGNATURE_TYPE_MBR:\r
+ CatPrint (\r
+ Str,\r
+ L"HD(Part%d,Sig%08x)",\r
+ (UINTN) Hd->PartitionNumber,\r
+ (UINTN) *((UINT32 *) (&(Hd->Signature[0])))\r
+ );\r
+ break;\r
+\r
+ case SIGNATURE_TYPE_GUID:\r
+ CatPrint (\r
+ Str,\r
+ L"HD(Part%d,Sig%g)",\r
+ (UINTN) Hd->PartitionNumber,\r
+ (EFI_GUID *) &(Hd->Signature[0])\r
+ );\r
+ break;\r
+\r
+ default:\r
+ CatPrint (\r
+ Str,\r
+ L"HD(Part%d,MBRType=%02x,SigType=%02x)",\r
+ (UINTN) Hd->PartitionNumber,\r
+ (UINTN) Hd->MBRType,\r
+ (UINTN) Hd->SignatureType\r
+ );\r
+ break;\r
+ }\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathCDROM (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ CDROM_DEVICE_PATH *Cd;\r
+\r
+ Cd = DevPath;\r
+ CatPrint (Str, L"CDROM(Entry%x)", (UINTN) Cd->BootEntry);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathFilePath (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ FILEPATH_DEVICE_PATH *Fp;\r
+\r
+ Fp = DevPath;\r
+ CatPrint (Str, L"%s", Fp->PathName);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathMediaProtocol (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
+\r
+ MediaProt = DevPath;\r
+ CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathFvFilePath (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;\r
+\r
+ FvFilePath = DevPath;\r
+ CatPrint (Str, L"%g", &FvFilePath->FvFileName);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+MyDevPathRelativeOffsetRange (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
+\r
+ Offset = DevPath;\r
+ CatPrint (\r
+ Str,\r
+ L"Offset(%lx,%lx)",\r
+ Offset->StartingOffset,\r
+ Offset->EndingOffset\r
+ );\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathBssBss (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ BBS_BBS_DEVICE_PATH *Bbs;\r
+ CHAR16 *Type;\r
+\r
+ Bbs = DevPath;\r
+ switch (Bbs->DeviceType) {\r
+ case BBS_TYPE_FLOPPY:\r
+ Type = L"Floppy";\r
+ break;\r
+\r
+ case BBS_TYPE_HARDDRIVE:\r
+ Type = L"Harddrive";\r
+ break;\r
+\r
+ case BBS_TYPE_CDROM:\r
+ Type = L"CDROM";\r
+ break;\r
+\r
+ case BBS_TYPE_PCMCIA:\r
+ Type = L"PCMCIA";\r
+ break;\r
+\r
+ case BBS_TYPE_USB:\r
+ Type = L"Usb";\r
+ break;\r
+\r
+ case BBS_TYPE_EMBEDDED_NETWORK:\r
+ Type = L"Net";\r
+ break;\r
+\r
+ case BBS_TYPE_BEV:\r
+ Type = L"BEV";\r
+ break;\r
+\r
+ default:\r
+ Type = L"?";\r
+ break;\r
+ }\r
+ CatPrint (Str, L"Legacy-%s", Type);\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathEndInstance (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ CatPrint (Str, L",");\r
+}\r
+\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maixmum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathNodeUnknown (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ CatPrint (Str, L"?");\r
+}\r
+/**\r
+ Convert Device Path to a Unicode string for printing.\r
+\r
+ @param Str The buffer holding the output string.\r
+ This buffer contains the length of the\r
+ string and the maximum length reserved\r
+ for the string buffer.\r
+ @param DevPath The device path.\r
+\r
+**/\r
+VOID\r
+DevPathFvPath (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ )\r
+{\r
+ MEDIA_FW_VOL_DEVICE_PATH *FvPath;\r
+\r
+ FvPath = DevPath;\r
+ CatPrint (Str, L"Fv(%g)", &FvPath->FvName);\r
+}\r
+\r
+DEVICE_PATH_STRING_TABLE DevPathTable[] = {\r
+ {\r
+ HARDWARE_DEVICE_PATH,\r
+ HW_PCI_DP,\r
+ DevPathPci\r
+ },\r
+ {\r
+ HARDWARE_DEVICE_PATH,\r
+ HW_PCCARD_DP,\r
+ DevPathPccard\r
+ },\r
+ {\r
+ HARDWARE_DEVICE_PATH,\r
+ HW_MEMMAP_DP,\r
+ DevPathMemMap\r
+ },\r
+ {\r
+ HARDWARE_DEVICE_PATH,\r
+ HW_VENDOR_DP,\r
+ DevPathVendor\r
+ },\r
+ {\r
+ HARDWARE_DEVICE_PATH,\r
+ HW_CONTROLLER_DP,\r
+ DevPathController\r
+ },\r
+ {\r
+ ACPI_DEVICE_PATH,\r
+ ACPI_DP,\r
+ DevPathAcpi\r
+ },\r
+ {\r
+ ACPI_DEVICE_PATH,\r
+ ACPI_EXTENDED_DP,\r
+ DevPathExtendedAcpi\r
+ },\r
+ {\r
+ ACPI_DEVICE_PATH,\r
+ ACPI_ADR_DP,\r
+ DevPathAdrAcpi\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_ATAPI_DP,\r
+ DevPathAtapi\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_SCSI_DP,\r
+ DevPathScsi\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_FIBRECHANNEL_DP,\r
+ DevPathFibre\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_1394_DP,\r
+ DevPath1394\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_USB_DP,\r
+ DevPathUsb\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_USB_WWID_DP,\r
+ DevPathUsbWWID\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_DEVICE_LOGICAL_UNIT_DP,\r
+ DevPathLogicalUnit\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_USB_CLASS_DP,\r
+ DevPathUsbClass\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_SATA_DP,\r
+ DevPathSata\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_I2O_DP,\r
+ DevPathI2O\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_MAC_ADDR_DP,\r
+ DevPathMacAddr\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_IPv4_DP,\r
+ DevPathIPv4\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_IPv6_DP,\r
+ DevPathIPv6\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_INFINIBAND_DP,\r
+ DevPathInfiniBand\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_UART_DP,\r
+ DevPathUart\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_VENDOR_DP,\r
+ DevPathVendor\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_ISCSI_DP,\r
+ DevPathiSCSI\r
+ },\r
+ {\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_VLAN_DP,\r
+ DevPathVlan\r
+ },\r
+ {\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_HARDDRIVE_DP,\r
+ DevPathHardDrive\r
+ },\r
+ {\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_CDROM_DP,\r
+ DevPathCDROM\r
+ },\r
+ {\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_VENDOR_DP,\r
+ DevPathVendor\r
+ },\r
+ {\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_FILEPATH_DP,\r
+ DevPathFilePath\r
+ },\r
+ {\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_PROTOCOL_DP,\r
+ DevPathMediaProtocol\r
+ },\r
+ {\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_PIWG_FW_VOL_DP,\r
+ DevPathFvPath,\r
+ },\r
+ {\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_PIWG_FW_FILE_DP,\r
+ DevPathFvFilePath\r
+ },\r
+ {\r
+ MEDIA_DEVICE_PATH,\r
+ MEDIA_RELATIVE_OFFSET_RANGE_DP,\r
+ MyDevPathRelativeOffsetRange,\r
+ },\r
+ {\r
+ BBS_DEVICE_PATH,\r
+ BBS_BBS_DP,\r
+ DevPathBssBss\r
+ },\r
+ {\r
+ END_DEVICE_PATH_TYPE,\r
+ END_INSTANCE_DEVICE_PATH_SUBTYPE,\r
+ DevPathEndInstance\r
+ },\r
+ {\r
+ 0,\r
+ 0,\r
+ NULL\r
+ }\r
+};\r
+\r
+\r
+/**\r
+ This function converts an input device structure to a Unicode string.\r
+\r
+ @param DevPath A pointer to the device path structure.\r
+\r
+ @return A new allocated Unicode string that represents the device path.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+DevicePathToStr (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
+ )\r
+{\r
+ POOL_PRINT Str;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
+ VOID (*DumpNode) (POOL_PRINT *, VOID *);\r
+\r
+ UINTN Index;\r
+ UINTN NewSize;\r
+\r
+ EFI_STATUS Status;\r
+ CHAR16 *ToText;\r
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;\r
+\r
+ ZeroMem (&Str, sizeof (Str));\r
+\r
+ if (DevPath == NULL) {\r
+ goto Done;\r
+ }\r
+\r
+ Status = gBS->LocateProtocol (\r
+ &gEfiDevicePathToTextProtocolGuid,\r
+ NULL,\r
+ (VOID **) &DevPathToText\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ ToText = DevPathToText->ConvertDevicePathToText (\r
+ DevPath,\r
+ FALSE,\r
+ TRUE\r
+ );\r
+ ASSERT (ToText != NULL);\r
+ return ToText;\r
+ }\r
+\r
+ //\r
+ // Process each device path node\r
+ //\r
+ DevPathNode = DevPath;\r
+ while (!IsDevicePathEnd (DevPathNode)) {\r
+ //\r
+ // Find the handler to dump this device path node\r
+ //\r
+ DumpNode = NULL;\r
+ for (Index = 0; DevPathTable[Index].Function != NULL; Index += 1) {\r
+\r
+ if (DevicePathType (DevPathNode) == DevPathTable[Index].Type &&\r
+ DevicePathSubType (DevPathNode) == DevPathTable[Index].SubType\r
+ ) {\r
+ DumpNode = DevPathTable[Index].Function;\r
+ break;\r
+ }\r
+ }\r
+ //\r
+ // If not found, use a generic function\r
+ //\r
+ if (!DumpNode) {\r
+ DumpNode = DevPathNodeUnknown;\r
+ }\r
+ //\r
+ // Put a path seperator in if needed\r
+ //\r
+ if ((Str.Len != 0) && (DumpNode != DevPathEndInstance)) {\r
+ CatPrint (&Str, L"/");\r
+ }\r
+ //\r
+ // Print this node of the device path\r
+ //\r
+ DumpNode (&Str, DevPathNode);\r
+\r
+ //\r
+ // Next device path node\r
+ //\r
+ DevPathNode = NextDevicePathNode (DevPathNode);\r
+ }\r
+\r
+Done:\r
+ NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
+ Str.Str = EfiReallocatePool (Str.Str, NewSize, NewSize);\r
+ ASSERT (Str.Str != NULL);\r
+ Str.Str[Str.Len] = 0;\r
+ return Str.Str;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+ DevicePathUtilities.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _DEVICE_PATH_UTILITIES_PROTOCOL_H_\r
+#define _DEVICE_PATH_UTILITIES_PROTOCOL_H_\r
+\r
+//\r
+// Device Path Utilities protocol\r
+//\r
+#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \\r
+ { \\r
+ 0x379be4e, 0xd706, 0x437d, {0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4} \\r
+ }\r
+\r
+typedef\r
+UINTN\r
+EFIAPI\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE) (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Returns the size of the device path, in bytes.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the start of the EFI device path.\r
+\r
+ Returns:\r
+ Size - Size of the specified device path, in bytes, including the end-of-path tag.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+EFIAPI\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH) (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Create a duplicate of the specified path.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the source EFI device path.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the duplicate device path.\r
+ NULL - Insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+EFIAPI\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_PATH) (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Create a new path by appending the second device path to the first.\r
+\r
+ Arguments:\r
+ Src1 - Points to the first device path. If NULL, then it is ignored.\r
+ Src2 - Points to the second device path. If NULL, then it is ignored.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the newly created device path.\r
+ NULL - Memory could not be allocated\r
+ or either DevicePath or DeviceNode is NULL.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+EFIAPI\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_NODE) (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a new path by appending the device node to the device path.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the device path.\r
+ DeviceNode - Points to the device node.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the allocated device node.\r
+ NULL - Memory could not be allocated\r
+ or either DevicePath or DeviceNode is NULL.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+EFIAPI\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE) (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a new path by appending the specified device path instance to the specified device path.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the device path. If NULL, then ignored.\r
+ DevicePathInstance - Points to the device path instance.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the newly created device path\r
+ NULL - Memory could not be allocated or DevicePathInstance is NULL.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+EFIAPI\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE) (\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,\r
+ OUT UINTN *DevicePathInstanceSize\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a copy of the current device path instance and returns a pointer to the next device path instance.\r
+\r
+ Arguments:\r
+ DevicePathInstance - On input, this holds the pointer to the current device path\r
+ instance. On output, this holds the pointer to the next\r
+ device path instance or NULL if there are no more device\r
+ path instances in the device path.\r
+ DevicePathInstanceSize - On output, this holds the size of the device path instance,\r
+ in bytes or zero, if DevicePathInstance is zero.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the copy of the current device path instance.\r
+ NULL - DevicePathInstace was NULL on entry or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+BOOLEAN\r
+EFIAPI\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE) (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Returns whether a device path is multi-instance.\r
+\r
+ Arguments:\r
+ DevicePath - Points to the device path. If NULL, then ignored.\r
+\r
+ Returns:\r
+ TRUE - The device path has more than one instance\r
+ FALSE - The device path is empty or contains only a single instance.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+EFIAPI\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_CREATE_NODE) (\r
+ IN UINT8 NodeType,\r
+ IN UINT8 NodeSubType,\r
+ IN UINT16 NodeLength\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Creates a device node\r
+\r
+ Arguments:\r
+ NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for\r
+ the new device node.\r
+ NodeSubType - NodeSubType is the device node sub-type\r
+ EFI_DEVICE_PATH.SubType) for the new device node.\r
+ NodeLength - NodeLength is the length of the device node\r
+ (EFI_DEVICE_PATH.Length) for the new device node.\r
+\r
+ Returns:\r
+ Pointer - A pointer to the newly created device node.\r
+ NULL - NodeLength is less than\r
+ the size of the header or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize;\r
+ EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH DuplicateDevicePath;\r
+ EFI_DEVICE_PATH_UTILS_APPEND_PATH AppendDevicePath;\r
+ EFI_DEVICE_PATH_UTILS_APPEND_NODE AppendDeviceNode;\r
+ EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE AppendDevicePathInstance;\r
+ EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE GetNextDevicePathInstance;\r
+ EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE IsDevicePathMultiInstance;\r
+ EFI_DEVICE_PATH_UTILS_CREATE_NODE CreateDeviceNode;\r
+} EFI_DEVICE_PATH_UTILITIES_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid;\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Generic BDS library defines general interfaces for a BDS driver, including:\r
+ 1) BDS boot policy interface.\r
+ 2) BDS boot device connect interface.\r
+ 3) BDS Misc interfaces for mainting boot variable, ouput string.\r
+\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under \r
+the terms and conditions of the BSD License that accompanies this distribution. \r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php. \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _GENERIC_BDS_LIB_H_\r
+#define _GENERIC_BDS_LIB_H_\r
+\r
+#ifdef __MAKEWITH_GNUEFI\r
+#include "gnuefi-helper.h"\r
+#endif\r
+\r
+//#include <Protocol/UserManager.h>\r
+\r
+///\r
+/// Constants which are variable names used to access variables.\r
+///\r
+#define VAR_LEGACY_DEV_ORDER L"LegacyDevOrder"\r
+\r
+///\r
+/// Data structures and defines.\r
+///\r
+#define FRONT_PAGE_QUESTION_ID 0x0000\r
+#define FRONT_PAGE_DATA_WIDTH 0x01\r
+\r
+///\r
+/// ConnectType\r
+///\r
+#define CONSOLE_OUT 0x00000001\r
+#define STD_ERROR 0x00000002\r
+#define CONSOLE_IN 0x00000004\r
+#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)\r
+\r
+///\r
+/// Load Option Attributes\r
+///\r
+#define LOAD_OPTION_ACTIVE 0x00000001\r
+#define LOAD_OPTION_FORCE_RECONNECT 0x00000002\r
+\r
+#define LOAD_OPTION_HIDDEN 0x00000008\r
+#define LOAD_OPTION_CATEGORY 0x00001F00\r
+\r
+#define LOAD_OPTION_CATEGORY_BOOT 0x00000000\r
+#define LOAD_OPTION_CATEGORY_APP 0x00000100\r
+\r
+#define EFI_BOOT_OPTION_SUPPORT_KEY 0x00000001\r
+#define EFI_BOOT_OPTION_SUPPORT_APP 0x00000002\r
+\r
+#define IS_LOAD_OPTION_TYPE(_c, _Mask) (BOOLEAN) (((_c) & (_Mask)) != 0)\r
+\r
+///\r
+/// Define the maximum characters that will be accepted.\r
+///\r
+#define MAX_CHAR 480\r
+#define MAX_CHAR_SIZE (MAX_CHAR * 2)\r
+\r
+///\r
+/// Define maximum characters for boot option variable "BootXXXX".\r
+///\r
+#define BOOT_OPTION_MAX_CHAR 10\r
+\r
+//\r
+// This data structure is the part of BDS_CONNECT_ENTRY\r
+//\r
+#ifdef __MAKEWITH_TIANO\r
+#define BDS_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('B', 'd', 'C', 'O')\r
+#else\r
+#define BDS_LOAD_OPTION_SIGNATURE EFI_SIGNATURE_32 ('B', 'd', 'C', 'O')\r
+#endif\r
+\r
+typedef struct {\r
+\r
+ UINTN Signature;\r
+ LIST_ENTRY Link;\r
+\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ CHAR16 *OptionName;\r
+ UINTN OptionNumber;\r
+ UINT16 BootCurrent;\r
+ UINT32 Attribute;\r
+ CHAR16 *Description;\r
+ VOID *LoadOptions;\r
+ UINT32 LoadOptionsSize;\r
+ CHAR16 *StatusString;\r
+\r
+} BDS_COMMON_OPTION;\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ UINTN ConnectType;\r
+} BDS_CONSOLE_CONNECT_ENTRY;\r
+\r
+//\r
+// Bds boot related lib functions\r
+//\r
+/**\r
+ Boot from the UEFI spec defined "BootNext" variable.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibBootNext (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Process the boot option according to the UEFI specification. The legacy boot option device path includes BBS_DEVICE_PATH.\r
+\r
+ @param Option The boot option to be processed.\r
+ @param DevicePath The device path describing where to load the\r
+ boot image or the legcy BBS device path to boot\r
+ the legacy OS.\r
+ @param ExitDataSize The size of exit data.\r
+ @param ExitData Data returned when Boot image failed.\r
+\r
+ @retval EFI_SUCCESS Boot from the input boot option succeeded.\r
+ @retval EFI_NOT_FOUND The Device Path is not found in the system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibBootViaBootOption (\r
+ IN BDS_COMMON_OPTION * Option,\r
+ IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,\r
+ OUT UINTN *ExitDataSize,\r
+ OUT CHAR16 **ExitData OPTIONAL\r
+ );\r
+\r
+\r
+/**\r
+ This function will enumerate all possible boot devices in the system, and\r
+ automatically create boot options for Network, Shell, Removable BlockIo, \r
+ and Non-BlockIo Simplefile devices. \r
+ \r
+ BDS separates EFI boot options into six types:\r
+ 1. Network - The boot option points to the SimpleNetworkProtocol device. \r
+ Bds will try to automatically create this type of boot option during enumeration.\r
+ 2. Shell - The boot option points to internal flash shell. \r
+ Bds will try to automatically create this type of boot option during enumeration.\r
+ 3. Removable BlockIo - The boot option points to a removable media\r
+ device, such as a USB flash drive or DVD drive.\r
+ These devices should contain a *removable* blockIo\r
+ protocol in their device handle.\r
+ Bds will try to automatically create this type boot option \r
+ when enumerate.\r
+ 4. Fixed BlockIo - The boot option points to a Fixed blockIo device, \r
+ such as a hard disk.\r
+ These devices should contain a *fixed* blockIo\r
+ protocol in their device handle.\r
+ BDS will skip fixed blockIo devices, and not\r
+ automatically create boot option for them. But BDS \r
+ will help to delete those fixed blockIo boot options, \r
+ whose description rules conflict with other auto-created\r
+ boot options.\r
+ 5. Non-BlockIo Simplefile - The boot option points to a device whose handle \r
+ has SimpleFileSystem Protocol, but has no blockio\r
+ protocol. These devices do not offer blockIo\r
+ protocol, but BDS still can get the \r
+ \EFI\BOOT\boot{machinename}.EFI by SimpleFileSystem\r
+ Protocol.\r
+ 6. File - The boot option points to a file. These boot options are usually \r
+ created by the user, either manually or with an OS loader. BDS will not delete or modify\r
+ these boot options. \r
+ \r
+ This function will enumerate all possible boot devices in the system, and\r
+ automatically create boot options for Network, Shell, Removable BlockIo, \r
+ and Non-BlockIo Simplefile devices.\r
+ It will excute once every boot.\r
+ \r
+ @param BdsBootOptionList The header of the linked list that indexed all\r
+ current boot options.\r
+\r
+ @retval EFI_SUCCESS Finished all the boot device enumerations and \r
+ created the boot option based on the boot device.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES Failed to enumerate the boot device and create \r
+ the boot option list.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibEnumerateAllBootOption (\r
+ IN OUT LIST_ENTRY *BdsBootOptionList\r
+ );\r
+\r
+/**\r
+ Build the boot option with the handle parsed in.\r
+\r
+ @param Handle The handle representing the device path for which \r
+ to create a boot option.\r
+ @param BdsBootOptionList The header of the link list that indexed all\r
+ current boot options.\r
+ @param String The description of the boot option.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibBuildOptionFromHandle (\r
+ IN EFI_HANDLE Handle,\r
+ IN LIST_ENTRY *BdsBootOptionList,\r
+ IN CHAR16 *String\r
+ );\r
+\r
+\r
+/**\r
+ Build the on flash shell boot option with the handle parsed in.\r
+\r
+ @param Handle The handle which present the device path to create\r
+ the on flash shell boot option.\r
+ @param BdsBootOptionList The header of the link list that indexed all\r
+ current boot options.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibBuildOptionFromShell (\r
+ IN EFI_HANDLE Handle,\r
+ IN OUT LIST_ENTRY *BdsBootOptionList\r
+ );\r
+\r
+\r
+/**\r
+ The function will go through the driver option link list, and then load and start\r
+ every driver to which the driver option device path points.\r
+\r
+ @param BdsDriverLists The header of the current driver option link list.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibLoadDrivers (\r
+ IN LIST_ENTRY *BdsDriverLists\r
+ );\r
+\r
+\r
+/**\r
+ This function processes BootOrder or DriverOrder variables, by calling\r
+\r
+ BdsLibVariableToOption () for each UINT16 in the variables.\r
+\r
+ @param BdsCommonOptionList The header of the option list base on the variable\r
+ VariableName.\r
+ @param VariableName An EFI Variable name indicate the BootOrder or\r
+ DriverOrder.\r
+\r
+ @retval EFI_SUCCESS Successfully created the boot option or driver option\r
+ list.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to get the boot option or the driver option list.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibBuildOptionFromVar (\r
+ IN LIST_ENTRY *BdsCommonOptionList,\r
+ IN CHAR16 *VariableName\r
+ );\r
+\r
+/**\r
+ This function reads the EFI variable (VendorGuid/Name) and returns a dynamically allocated\r
+ buffer and the size of the buffer. If it fails, return NULL.\r
+\r
+ @param Name The string part of the EFI variable name.\r
+ @param VendorGuid The GUID part of the EFI variable name.\r
+ @param VariableSize Returns the size of the EFI variable that was read.\r
+\r
+ @return Dynamically allocated memory that contains a copy \r
+ of the EFI variable. The caller is responsible for \r
+ freeing the buffer.\r
+ @retval NULL The variable was not read.\r
+\r
+**/\r
+VOID *\r
+BdsLibGetVariableAndSize (\r
+ IN CHAR16 *Name,\r
+ IN EFI_GUID *VendorGuid,\r
+ OUT UINTN *VariableSize\r
+ );\r
+\r
+\r
+/**\r
+ This function prints a series of strings.\r
+\r
+ @param ConOut A pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.\r
+ @param ... A variable argument list containing a series of\r
+ strings, the last string must be NULL.\r
+\r
+ @retval EFI_SUCCESS Successfully printed out the string using ConOut.\r
+ @retval EFI_STATUS Return the status of the ConOut->OutputString ().\r
+\r
+**/\r
+// EFI_STATUS\r
+// EFIAPI\r
+// BdsLibOutputStrings (\r
+// IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut,\r
+// ...\r
+// );\r
+\r
+/**\r
+ Build the boot#### or driver#### option from the VariableName. The\r
+ build boot#### or driver#### will also be linked to BdsCommonOptionList.\r
+\r
+ @param BdsCommonOptionList The header of the boot#### or driver#### option\r
+ link list.\r
+ @param VariableName EFI Variable name, indicates if it is boot#### or\r
+ driver####.\r
+\r
+ @retval BDS_COMMON_OPTION The option that was created.\r
+ @retval NULL Failed to get the new option.\r
+\r
+**/\r
+BDS_COMMON_OPTION *\r
+BdsLibVariableToOption (\r
+ IN OUT LIST_ENTRY *BdsCommonOptionList,\r
+ IN CHAR16 *VariableName\r
+ );\r
+\r
+\r
+/**\r
+ This function creates all handles associated with the given device\r
+ path node. If the handle associated with one device path node cannot\r
+ be created, then it tries to execute the dispatch to load the missing drivers. \r
+\r
+ @param DevicePathToConnect The device path to be connected. Can be\r
+ a multi-instance device path.\r
+\r
+ @retval EFI_SUCCESS All handles associates with every device path node\r
+ were created.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough resources to create new handles.\r
+ @retval EFI_NOT_FOUND At least one handle could not be created.\r
+\r
+**/\r
+EFI_STATUS\r
+BdsLibConnectDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect\r
+ );\r
+\r
+\r
+//\r
+// Bds connect and disconnect driver lib funcions\r
+//\r
+/**\r
+ This function connects all system drivers with the corresponding controllers. \r
+\r
+ **/\r
+VOID\r
+EFIAPI\r
+BdsLibConnectAllDriversToAllControllers (\r
+ VOID\r
+);\r
+\r
+/**\r
+ This function will connect console device based on the console\r
+ device variable ConIn, ConOut and ErrOut.\r
+\r
+ @retval EFI_SUCCESS At least one of the ConIn and ConOut devices have\r
+ been connected.\r
+ @retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectAllDefaultConsoles (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function updates the console variable based on ConVarName. It can\r
+ add or remove one specific console device path from the variable\r
+\r
+ @param ConVarName The console-related variable name: ConIn, ConOut,\r
+ ErrOut.\r
+ @param CustomizedConDevicePath The console device path to be added to\r
+ the console variable ConVarName. Cannot be multi-instance.\r
+ @param ExclusiveDevicePath The console device path to be removed\r
+ from the console variable ConVarName. Cannot be multi-instance.\r
+\r
+ @retval EFI_UNSUPPORTED The added device path is the same as a removed one.\r
+ @retval EFI_SUCCESS Successfully added or removed the device path from the\r
+ console variable.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibUpdateConsoleVariable (\r
+ IN CHAR16 *ConVarName,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath\r
+ );\r
+\r
+/**\r
+ Connect the console device base on the variable ConVarName. If\r
+ ConVarName is a multi-instance device path, and at least one\r
+ instance connects successfully, then this function\r
+ will return success.\r
+\r
+ @param ConVarName The console related variable name: ConIn, ConOut,\r
+ ErrOut.\r
+\r
+ @retval EFI_NOT_FOUND No console devices were connected successfully\r
+ @retval EFI_SUCCESS Connected at least one instance of the console\r
+ device path based on the variable ConVarName.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectConsoleVariable (\r
+ IN CHAR16 *ConVarName\r
+ );\r
+\r
+//\r
+// Bds device path related lib functions\r
+//\r
+/**\r
+ Delete the instance in Multi that overlaps with Single. \r
+\r
+ @param Multi A pointer to a multi-instance device path data\r
+ structure.\r
+ @param Single A pointer to a single-instance device path data\r
+ structure.\r
+\r
+ @return This function removes the device path instances in Multi that overlap\r
+ Single, and returns the resulting device path. If there is no\r
+ remaining device path as a result, this function will return NULL.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+BdsLibDelPartMatchInstance (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *Single\r
+ );\r
+\r
+/**\r
+ This function compares a device path data structure to that of all the nodes of a\r
+ second device path instance.\r
+\r
+ @param Multi A pointer to a multi-instance device path data\r
+ structure.\r
+ @param Single A pointer to a single-instance device path data\r
+ structure.\r
+\r
+ @retval TRUE If the Single device path is contained within a \r
+ Multi device path.\r
+ @retval FALSE The Single device path is not contained within a \r
+ Multi device path.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+BdsLibMatchDevicePaths (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *Single\r
+ );\r
+\r
+/**\r
+ This function converts an input device structure to a Unicode string.\r
+\r
+ @param DevPath A pointer to the device path structure.\r
+\r
+ @return A newly allocated Unicode string that represents the device path.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+DevicePathToStr (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
+ );\r
+\r
+#ifdef __MAKEWITH_TIANO\r
+//\r
+// Internal definitions\r
+//\r
+typedef struct {\r
+ CHAR16 *Str;\r
+ UINTN Len;\r
+ UINTN Maxlen;\r
+} POOL_PRINT;\r
+#endif\r
+\r
+typedef\r
+VOID\r
+(*DEV_PATH_FUNCTION) (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ );\r
+\r
+typedef struct {\r
+ UINT8 Type;\r
+ UINT8 SubType;\r
+ DEV_PATH_FUNCTION Function;\r
+} DEVICE_PATH_STRING_TABLE;\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_PROTOCOL Header;\r
+ EFI_GUID Guid;\r
+ UINT8 VendorDefinedData[1];\r
+} VENDOR_DEVICE_PATH_WITH_DATA;\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_PROTOCOL Header;\r
+ UINT16 NetworkProtocol;\r
+ UINT16 LoginOption;\r
+ UINT64 Lun;\r
+ UINT16 TargetPortalGroupTag;\r
+ CHAR16 TargetName[1];\r
+} ISCSI_DEVICE_PATH_WITH_NAME;\r
+\r
+//\r
+// BBS support macros and functions\r
+//\r
+\r
+#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)\r
+#define REFRESH_LEGACY_BOOT_OPTIONS \\r
+ BdsDeleteAllInvalidLegacyBootOptions ();\\r
+ BdsAddNonExistingLegacyBootOptions (); \\r
+ BdsUpdateLegacyDevOrder ()\r
+#else\r
+#define REFRESH_LEGACY_BOOT_OPTIONS\r
+#endif\r
+\r
+/**\r
+ Delete all the invalid legacy boot options.\r
+\r
+ @retval EFI_SUCCESS All invalid legacy boot options are deleted.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate necessary memory.\r
+ @retval EFI_NOT_FOUND Failed to retrieve variable of boot order.\r
+\r
+**/\r
+EFI_STATUS\r
+BdsDeleteAllInvalidLegacyBootOptions (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Add the legacy boot options from BBS table if they do not exist.\r
+\r
+ @retval EFI_SUCCESS The boot options were added successfully, \r
+ or they are already in boot options.\r
+ @retval EFI_NOT_FOUND No legacy boot options is found.\r
+ @retval EFI_OUT_OF_RESOURCE No enough memory.\r
+ @return Other value LegacyBoot options are not added.\r
+**/\r
+EFI_STATUS\r
+BdsAddNonExistingLegacyBootOptions (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Add the legacy boot devices from BBS table into \r
+ the legacy device boot order.\r
+\r
+ @retval EFI_SUCCESS The boot devices were added successfully.\r
+ @retval EFI_NOT_FOUND The legacy boot devices are not found.\r
+ @retval EFI_OUT_OF_RESOURCES Memory or storage is not enough.\r
+ @retval EFI_DEVICE_ERROR Failed to add the legacy device boot order into EFI variable\r
+ because of a hardware error.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsUpdateLegacyDevOrder (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Refresh the boot priority for BBS entries based on boot option entry and boot order.\r
+\r
+ @param Entry The boot option is to be checked for a refreshed BBS table.\r
+ \r
+ @retval EFI_SUCCESS The boot priority for BBS entries refreshed successfully.\r
+ @retval EFI_NOT_FOUND BBS entries can't be found.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to get the legacy device boot order.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsRefreshBbsTableForBoot (\r
+ IN BDS_COMMON_OPTION *Entry\r
+ );\r
+\r
+/**\r
+ Delete the Boot Option from EFI Variable. The Boot Order Arrray\r
+ is also updated.\r
+\r
+ @param OptionNumber The number of Boot options wanting to be deleted.\r
+ @param BootOrder The Boot Order array.\r
+ @param BootOrderSize The size of the Boot Order Array.\r
+\r
+ @retval EFI_SUCCESS The Boot Option Variable was found and removed.\r
+ @retval EFI_UNSUPPORTED The Boot Option Variable store was inaccessible.\r
+ @retval EFI_NOT_FOUND The Boot Option Variable was not found.\r
+**/\r
+EFI_STATUS\r
+BdsDeleteBootOption (\r
+ IN UINTN OptionNumber,\r
+ IN OUT UINT16 *BootOrder,\r
+ IN OUT UINTN *BootOrderSize\r
+ );\r
+\r
+//\r
+//The interface functions related to the Setup Browser Reset Reminder feature\r
+//\r
+/**\r
+ Enable the setup browser reset reminder feature.\r
+ This routine is used in a platform tip. If the platform policy needs the feature, use the routine to enable it.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnableResetReminderFeature (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Disable the setup browser reset reminder feature.\r
+ This routine is used in a platform tip. If the platform policy does not want the feature, use the routine to disable it.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DisableResetReminderFeature (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Record the info that a reset is required.\r
+ A module boolean variable is used to record whether a reset is required.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnableResetRequired (\r
+ VOID\r
+ );\r
+\r
+\r
+/**\r
+ Record the info that no reset is required.\r
+ A module boolean variable is used to record whether a reset is required.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DisableResetRequired (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Check whether platform policy enables the reset reminder feature. The default is enabled.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsResetReminderFeatureEnable (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Check if the user changed any option setting that needs a system reset to be effective.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsResetRequired (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Check whether a reset is needed, and finish the reset reminder feature.\r
+ If a reset is needed, pop up a menu to notice user, and finish the feature\r
+ according to the user selection.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SetupResetReminder (\r
+ VOID\r
+ );\r
+\r
+\r
+///\r
+/// Define the boot type with which to classify the boot option type.\r
+/// Different boot option types could have different boot behaviors.\r
+/// Use their device path node (Type + SubType) as the type value.\r
+/// The boot type here can be added according to requirements.\r
+///\r
+\r
+///\r
+/// ACPI boot type. For ACPI devices, using sub-types to distinguish devices is not allowed, so hardcode their values.\r
+///\r
+#define BDS_EFI_ACPI_FLOPPY_BOOT 0x0201\r
+///\r
+/// Message boot type\r
+/// If a device path of boot option only points to a message node, the boot option is a message boot type.\r
+///\r
+#define BDS_EFI_MESSAGE_ATAPI_BOOT 0x0301 // Type 03; Sub-Type 01\r
+#define BDS_EFI_MESSAGE_SCSI_BOOT 0x0302 // Type 03; Sub-Type 02\r
+#define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05\r
+#define BDS_EFI_MESSAGE_SATA_BOOT 0x0312 // Type 03; Sub-Type 18\r
+#define BDS_EFI_MESSAGE_MAC_BOOT 0x030b // Type 03; Sub-Type 11\r
+#define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF\r
+\r
+///\r
+/// Media boot type\r
+/// If a device path of boot option contains a media node, the boot option is media boot type.\r
+///\r
+#define BDS_EFI_MEDIA_HD_BOOT 0x0401 // Type 04; Sub-Type 01\r
+#define BDS_EFI_MEDIA_CDROM_BOOT 0x0402 // Type 04; Sub-Type 02\r
+///\r
+/// BBS boot type\r
+/// If a device path of boot option contains a BBS node, the boot option is BBS boot type.\r
+///\r
+#define BDS_LEGACY_BBS_BOOT 0x0501 // Type 05; Sub-Type 01\r
+\r
+#define BDS_EFI_UNSUPPORT 0xFFFF\r
+\r
+/**\r
+ Check whether an instance in BlockIoDevicePath has the same partition node as the HardDriveDevicePath device path.\r
+\r
+ @param BlockIoDevicePath Multi device path instances to check.\r
+ @param HardDriveDevicePath A device path starting with a hard drive media\r
+ device path.\r
+\r
+ @retval TRUE There is a matched device path instance.\r
+ @retval FALSE There is no matched device path instance.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MatchPartitionDevicePathNode (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,\r
+ IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
+ );\r
+\r
+\r
+/**\r
+ Expand a device path that starts with a hard drive media device path node to be a\r
+ full device path that includes the full hardware path to the device. This function enables the device to boot. \r
+ To avoid requiring a connect on every boot, the front match is saved in a variable (the part point\r
+ to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ).\r
+ All successful history device paths\r
+ that point to the front part of the partition node will be saved.\r
+\r
+ @param HardDriveDevicePath EFI Device Path to boot, if it starts with a hard\r
+ drive media device path.\r
+ @return A Pointer to the full device path, or NULL if a valid Hard Drive devic path\r
+ cannot be found.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+BdsExpandPartitionPartialDevicePathToFull (\r
+ IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
+ );\r
+ \r
+/**\r
+ Return the bootable media handle.\r
+ First, check whether the device is connected.\r
+ Second, check whether the device path points to a device that supports SimpleFileSystemProtocol.\r
+ Third, detect the the default boot file in the Media, and return the removable Media handle.\r
+\r
+ @param DevicePath The Device Path to a bootable device.\r
+\r
+ @return The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.\r
+\r
+**/\r
+EFI_HANDLE\r
+EFIAPI\r
+BdsLibGetBootableHandle (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ );\r
+ \r
+\r
+/**\r
+ Checks whether the Device path in a boot option points to a valid bootable device, and if the device\r
+ is ready to boot now.\r
+\r
+ @param DevPath The Device path in a boot option.\r
+ @param CheckMedia If TRUE, check whether the device is ready to boot now.\r
+\r
+ @retval TRUE The Device path is valid.\r
+ @retval FALSE The Device path is invalid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+BdsLibIsValidEFIBootOptDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
+ IN BOOLEAN CheckMedia\r
+ );\r
+\r
+/**\r
+ Checks whether the Device path in a boot option points to a valid bootable device, and if the device\r
+ is ready to boot now.\r
+ If Description is not NULL and the device path points to a fixed BlockIo\r
+ device, this function checks whether the description conflicts with other auto-created\r
+ boot options.\r
+\r
+ @param DevPath The Device path in a boot option.\r
+ @param CheckMedia If TRUE, checks if the device is ready to boot now.\r
+ @param Description The description of a boot option.\r
+\r
+ @retval TRUE The Device path is valid.\r
+ @retval FALSE The Device path is invalid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+BdsLibIsValidEFIBootOptDevicePathExt (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
+ IN BOOLEAN CheckMedia,\r
+ IN CHAR16 *Description\r
+ );\r
+\r
+/**\r
+ For a bootable Device path, return its boot type.\r
+\r
+ @param DevicePath The bootable device Path to check.\r
+\r
+ @retval BDS_EFI_MEDIA_HD_BOOT The given device path contains MEDIA_DEVICE_PATH type device path node,\r
+ whose subtype is MEDIA_HARDDRIVE_DP. \r
+ @retval BDS_EFI_MEDIA_CDROM_BOOT If given device path contains MEDIA_DEVICE_PATH type device path node, \r
+ whose subtype is MEDIA_CDROM_DP. \r
+ @retval BDS_EFI_ACPI_FLOPPY_BOOT A given device path contains ACPI_DEVICE_PATH type device path node, \r
+ whose HID is floppy device. \r
+ @retval BDS_EFI_MESSAGE_ATAPI_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node, \r
+ and its last device path node's subtype is MSG_ATAPI_DP. \r
+ @retval BDS_EFI_MESSAGE_SCSI_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node,\r
+ and its last device path node's subtype is MSG_SCSI_DP. \r
+ @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node, \r
+ and its last device path node's subtype is MSG_USB_DP.\r
+ @retval BDS_EFI_MESSAGE_MISC_BOOT The device path does not contain any media device path node, and \r
+ its last device path node points to a message device path node. \r
+ @retval BDS_LEGACY_BBS_BOOT A given device path contains BBS_DEVICE_PATH type device path node. \r
+ @retval BDS_EFI_UNSUPPORT An EFI Removable BlockIO device path does not point to a media and message device. \r
+\r
+ **/\r
+UINT32\r
+EFIAPI\r
+BdsGetBootTypeFromDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ );\r
+\r
+\r
+/**\r
+ This routine registers a function to adjust the different types of memory page numbers\r
+ just before booting, and saves the updated info into the variable for the next boot to use.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibSaveMemoryTypeInformation (\r
+ VOID\r
+ );\r
+ \r
+/**\r
+ Identify a user and, if authenticated, returns the current user profile handle.\r
+\r
+ @param[out] User Points to the user profile handle.\r
+ \r
+ @retval EFI_SUCCESS The user is successfully identified, or user identification\r
+ is not supported.\r
+ @retval EFI_ACCESS_DENIED The user was not successfully identified.\r
+\r
+**/\r
+// EFI_STATUS\r
+// EFIAPI\r
+// BdsLibUserIdentify (\r
+// OUT EFI_USER_PROFILE_HANDLE *User\r
+// ); \r
+\r
+/**\r
+ This function checks if a Fv file device path is valid, according to a file GUID. If it is invalid,\r
+ it tries to return the valid device path.\r
+ FV address maybe changes for memory layout adjust from time to time, use this funciton\r
+ could promise the Fv file device path is right.\r
+\r
+ @param DevicePath On input, the Fv file device path to check. On\r
+ output, the updated valid Fv file device path\r
+ @param FileGuid the Fv file GUID.\r
+\r
+ @retval EFI_INVALID_PARAMETER The input DevicePath or FileGuid is invalid.\r
+ @retval EFI_UNSUPPORTED The input DevicePath does not contain an Fv file\r
+ GUID at all.\r
+ @retval EFI_ALREADY_STARTED The input DevicePath has pointed to the Fv file and is\r
+ valid.\r
+ @retval EFI_SUCCESS Successfully updated the invalid DevicePath\r
+ and returned the updated device path in DevicePath.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibUpdateFvFileDevicePath (\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,\r
+ IN EFI_GUID *FileGuid\r
+ );\r
+\r
+\r
+/**\r
+ Connect the specific USB device that matches the RemainingDevicePath,\r
+ and whose bus is determined by Host Controller (Uhci or Ehci).\r
+\r
+ @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci\r
+ (0xFF).\r
+ @param RemainingDevicePath A short-form device path that starts with the first\r
+ element being a USB WWID or a USB Class device\r
+ path.\r
+\r
+ @retval EFI_SUCCESS The specific Usb device is connected successfully.\r
+ @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF) \r
+ or RemainingDevicePath is not the USB class device path.\r
+ @retval EFI_NOT_FOUND The device specified by device path is not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectUsbDevByShortFormDP(\r
+ IN UINT8 HostControllerPI,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+ \r
+\r
+//\r
+// The implementation of this function is provided by Platform code.\r
+//\r
+/**\r
+ Convert Vendor device path to a device name.\r
+\r
+ @param Str The buffer storing device name.\r
+ @param DevPath The pointer to vendor device path.\r
+\r
+**/\r
+VOID\r
+DevPathVendor (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN VOID *DevPath\r
+ );\r
+\r
+/**\r
+ Concatenates a formatted unicode string to an allocated pool.\r
+ The caller must free the resulting buffer.\r
+\r
+ @param Str Tracks the allocated pool, size in use, and amount of pool allocated.\r
+ @param Fmt The format string.\r
+ @param ... The data will be printed.\r
+\r
+ @return Allocated buffer with the formatted string printed in it.\r
+ The caller must free the allocated buffer.\r
+ The buffer allocation is not packed.\r
+\r
+**/\r
+\r
+CHAR16 *\r
+EFIAPI\r
+CatPrint (\r
+ IN OUT POOL_PRINT *Str,\r
+ IN CHAR16 *Fmt,\r
+ ...\r
+ );\r
+\r
+/**\r
+ Use SystemTable ConOut to stop video based Simple Text Out consoles from going\r
+ to the video device. Put up LogoFile on every video device that is a console.\r
+\r
+ @param[in] LogoFile The file name of logo to display on the center of the screen.\r
+\r
+ @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
+ @retval EFI_UNSUPPORTED Logo not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EnableQuietBoot (\r
+ IN EFI_GUID *LogoFile\r
+ );\r
+\r
+\r
+/**\r
+ Use SystemTable ConOut to turn on video based Simple Text Out consoles. The \r
+ Simple Text Out screens will now be synced up with all non-video output devices.\r
+\r
+ @retval EFI_SUCCESS UGA devices are back in text mode and synced up.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DisableQuietBoot (\r
+ VOID\r
+ );\r
+\r
+#endif\r
+\r
--- /dev/null
+/** @file\r
+ The EFI Legacy BIOS Protocol is used to abstract legacy Option ROM usage\r
+ under EFI and Legacy OS boot. This file also includes all the related\r
+ COMPATIBILIY16 structures and defintions.\r
+\r
+ Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow\r
+ well known naming conventions.\r
+\r
+ Thunk is the code that switches from 32-bit protected environment into the 16-bit real-mode\r
+ environment. Reverse thunk is the code that does the opposite.\r
+\r
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under \r
+the terms and conditions of the BSD License that accompanies this distribution. \r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php. \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ @par Revision Reference:\r
+ This protocol is defined in Framework for EFI Compatibility Support Module spec\r
+ Version 0.97.\r
+\r
+**/\r
+\r
+#ifndef _EFI_LEGACY_BIOS_H_\r
+#define _EFI_LEGACY_BIOS_H_\r
+\r
+///\r
+/// \r
+///\r
+#pragma pack(1)\r
+\r
+typedef UINT8 SERIAL_MODE;\r
+typedef UINT8 PARALLEL_MODE;\r
+\r
+#define EFI_COMPATIBILITY16_TABLE_SIGNATURE SIGNATURE_32 ('I', 'F', 'E', '$')\r
+\r
+///\r
+/// There is a table located within the traditional BIOS in either the 0xF000:xxxx or 0xE000:xxxx\r
+/// physical address range. It is located on a 16-byte boundary and provides the physical address of the\r
+/// entry point for the Compatibility16 functions. These functions provide the platform-specific\r
+/// information that is required by the generic EfiCompatibility code. The functions are invoked via\r
+/// thunking by using EFI_LEGACY_BIOS_PROTOCOL.FarCall86() with the 32-bit physical\r
+/// entry point.\r
+///\r
+typedef struct {\r
+ ///\r
+ /// The string "$EFI" denotes the start of the EfiCompatibility table. Byte 0 is "I," byte\r
+ /// 1 is "F," byte 2 is "E," and byte 3 is "$" and is normally accessed as a DWORD or UINT32.\r
+ ///\r
+ UINT32 Signature;\r
+ \r
+ ///\r
+ /// The value required such that byte checksum of TableLength equals zero.\r
+ ///\r
+ UINT8 TableChecksum;\r
+ \r
+ ///\r
+ /// The length of this table.\r
+ ///\r
+ UINT8 TableLength;\r
+ \r
+ ///\r
+ /// The major EFI revision for which this table was generated.\r
+ /// \r
+ UINT8 EfiMajorRevision;\r
+ \r
+ ///\r
+ /// The minor EFI revision for which this table was generated.\r
+ ///\r
+ UINT8 EfiMinorRevision;\r
+ \r
+ ///\r
+ /// The major revision of this table.\r
+ ///\r
+ UINT8 TableMajorRevision;\r
+ \r
+ ///\r
+ /// The minor revision of this table.\r
+ ///\r
+ UINT8 TableMinorRevision;\r
+ \r
+ ///\r
+ /// Reserved for future usage.\r
+ ///\r
+ UINT16 Reserved;\r
+ \r
+ ///\r
+ /// The segment of the entry point within the traditional BIOS for Compatibility16 functions.\r
+ ///\r
+ UINT16 Compatibility16CallSegment;\r
+ \r
+ ///\r
+ /// The offset of the entry point within the traditional BIOS for Compatibility16 functions.\r
+ ///\r
+ UINT16 Compatibility16CallOffset;\r
+ \r
+ ///\r
+ /// The segment of the entry point within the traditional BIOS for EfiCompatibility \r
+ /// to invoke the PnP installation check.\r
+ ///\r
+ UINT16 PnPInstallationCheckSegment;\r
+ \r
+ ///\r
+ /// The Offset of the entry point within the traditional BIOS for EfiCompatibility \r
+ /// to invoke the PnP installation check.\r
+ ///\r
+ UINT16 PnPInstallationCheckOffset;\r
+ \r
+ ///\r
+ /// EFI system resources table. Type EFI_SYSTEM_TABLE is defined in the IntelPlatform \r
+ ///Innovation Framework for EFI Driver Execution Environment Core Interface Specification (DXE CIS).\r
+ ///\r
+ UINT32 EfiSystemTable; \r
+ \r
+ ///\r
+ /// The address of an OEM-provided identifier string. The string is null terminated.\r
+ ///\r
+ UINT32 OemIdStringPointer;\r
+ \r
+ ///\r
+ /// The 32-bit physical address where ACPI RSD PTR is stored within the traditional\r
+ /// BIOS. The remained of the ACPI tables are located at their EFI addresses. The size\r
+ /// reserved is the maximum for ACPI 2.0. The EfiCompatibility will fill in the ACPI\r
+ /// RSD PTR with either the ACPI 1.0b or 2.0 values.\r
+ ///\r
+ UINT32 AcpiRsdPtrPointer;\r
+ \r
+ ///\r
+ /// The OEM revision number. Usage is undefined but provided for OEM module usage.\r
+ ///\r
+ UINT16 OemRevision;\r
+ \r
+ ///\r
+ /// The 32-bit physical address where INT15 E820 data is stored within the traditional\r
+ /// BIOS. The EfiCompatibility code will fill in the E820Pointer value and copy the\r
+ /// data to the indicated area.\r
+ ///\r
+ UINT32 E820Pointer;\r
+ \r
+ ///\r
+ /// The length of the E820 data and is filled in by the EfiCompatibility code.\r
+ ///\r
+ UINT32 E820Length;\r
+ \r
+ ///\r
+ /// The 32-bit physical address where the $PIR table is stored in the traditional BIOS.\r
+ /// The EfiCompatibility code will fill in the IrqRoutingTablePointer value and\r
+ /// copy the data to the indicated area.\r
+ ///\r
+ UINT32 IrqRoutingTablePointer;\r
+ \r
+ ///\r
+ /// The length of the $PIR table and is filled in by the EfiCompatibility code.\r
+ ///\r
+ UINT32 IrqRoutingTableLength;\r
+ \r
+ ///\r
+ /// The 32-bit physical address where the MP table is stored in the traditional BIOS.\r
+ /// The EfiCompatibility code will fill in the MpTablePtr value and copy the data \r
+ /// to the indicated area.\r
+ ///\r
+ UINT32 MpTablePtr;\r
+ \r
+ ///\r
+ /// The length of the MP table and is filled in by the EfiCompatibility code.\r
+ ///\r
+ UINT32 MpTableLength;\r
+ \r
+ ///\r
+ /// The segment of the OEM-specific INT table/code.\r
+ /// \r
+ UINT16 OemIntSegment;\r
+ \r
+ ///\r
+ /// The offset of the OEM-specific INT table/code.\r
+ ///\r
+ UINT16 OemIntOffset;\r
+ \r
+ ///\r
+ /// The segment of the OEM-specific 32-bit table/code.\r
+ ///\r
+ UINT16 Oem32Segment;\r
+ \r
+ ///\r
+ /// The offset of the OEM-specific 32-bit table/code.\r
+ ///\r
+ UINT16 Oem32Offset;\r
+ \r
+ ///\r
+ /// The segment of the OEM-specific 16-bit table/code.\r
+ ///\r
+ UINT16 Oem16Segment;\r
+ \r
+ ///\r
+ /// The offset of the OEM-specific 16-bit table/code.\r
+ ///\r
+ UINT16 Oem16Offset;\r
+ \r
+ ///\r
+ /// The segment of the TPM binary passed to 16-bit CSM.\r
+ ///\r
+ UINT16 TpmSegment;\r
+ \r
+ ///\r
+ /// The offset of the TPM binary passed to 16-bit CSM.\r
+ ///\r
+ UINT16 TpmOffset;\r
+ \r
+ ///\r
+ /// A pointer to a string identifying the independent BIOS vendor.\r
+ ///\r
+ UINT32 IbvPointer;\r
+ \r
+ ///\r
+ /// This field is NULL for all systems not supporting PCI Express. This field is the base\r
+ /// value of the start of the PCI Express memory-mapped configuration registers and\r
+ /// must be filled in prior to EfiCompatibility code issuing the Compatibility16 function\r
+ /// Compatibility16InitializeYourself().\r
+ /// Compatibility16InitializeYourself() is defined in Compatability16\r
+ /// Functions.\r
+ ///\r
+ UINT32 PciExpressBase;\r
+ \r
+ ///\r
+ /// Maximum PCI bus number assigned.\r
+ ///\r
+ UINT8 LastPciBus;\r
+} EFI_COMPATIBILITY16_TABLE;\r
+\r
+///\r
+/// Functions provided by the CSM binary which communicate between the EfiCompatibility \r
+/// and Compatability16 code.\r
+///\r
+/// Inconsistent with the specification here: \r
+/// The member's name started with "Compatibility16" [defined in Intel Framework \r
+/// Compatibility Support Module Specification / 0.97 version] \r
+/// has been changed to "Legacy16" since keeping backward compatible.\r
+///\r
+typedef enum {\r
+ ///\r
+ /// Causes the Compatibility16 code to do any internal initialization required.\r
+ /// Input:\r
+ /// AX = Compatibility16InitializeYourself\r
+ /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_INIT_TABLE\r
+ /// Return:\r
+ /// AX = Return Status codes\r
+ ///\r
+ Legacy16InitializeYourself = 0x0000,\r
+ \r
+ ///\r
+ /// Causes the Compatibility16 BIOS to perform any drive number translations to match the boot sequence.\r
+ /// Input:\r
+ /// AX = Compatibility16UpdateBbs\r
+ /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE\r
+ /// Return:\r
+ /// AX = Returned status codes\r
+ ///\r
+ Legacy16UpdateBbs = 0x0001,\r
+ \r
+ ///\r
+ /// Allows the Compatibility16 code to perform any final actions before booting. The Compatibility16\r
+ /// code is read/write.\r
+ /// Input:\r
+ /// AX = Compatibility16PrepareToBoot\r
+ /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE structure \r
+ /// Return:\r
+ /// AX = Returned status codes\r
+ ///\r
+ Legacy16PrepareToBoot = 0x0002,\r
+ \r
+ ///\r
+ /// Causes the Compatibility16 BIOS to boot. The Compatibility16 code is Read/Only.\r
+ /// Input:\r
+ /// AX = Compatibility16Boot\r
+ /// Output:\r
+ /// AX = Returned status codes\r
+ ///\r
+ Legacy16Boot = 0x0003,\r
+ \r
+ ///\r
+ /// Allows the Compatibility16 code to get the last device from which a boot was attempted. This is\r
+ /// stored in CMOS and is the priority number of the last attempted boot device.\r
+ /// Input:\r
+ /// AX = Compatibility16RetrieveLastBootDevice\r
+ /// Output:\r
+ /// AX = Returned status codes\r
+ /// BX = Priority number of the boot device.\r
+ ///\r
+ Legacy16RetrieveLastBootDevice = 0x0004,\r
+ \r
+ ///\r
+ /// Allows the Compatibility16 code rehook INT13, INT18, and/or INT19 after dispatching a legacy OpROM.\r
+ /// Input:\r
+ /// AX = Compatibility16DispatchOprom\r
+ /// ES:BX = Pointer to EFI_DISPATCH_OPROM_TABLE\r
+ /// Output:\r
+ /// AX = Returned status codes\r
+ /// BX = Number of non-BBS-compliant devices found. Equals 0 if BBS compliant.\r
+ ///\r
+ Legacy16DispatchOprom = 0x0005,\r
+ \r
+ ///\r
+ /// Finds a free area in the 0xFxxxx or 0xExxxx region of the specified length and returns the address\r
+ /// of that region.\r
+ /// Input:\r
+ /// AX = Compatibility16GetTableAddress\r
+ /// BX = Allocation region\r
+ /// 00 = Allocate from either 0xE0000 or 0xF0000 64 KB blocks.\r
+ /// Bit 0 = 1 Allocate from 0xF0000 64 KB block\r
+ /// Bit 1 = 1 Allocate from 0xE0000 64 KB block\r
+ /// CX = Requested length in bytes.\r
+ /// DX = Required address alignment. Bit mapped. First non-zero bit from the right is the alignment.\r
+ /// Output:\r
+ /// AX = Returned status codes\r
+ /// DS:BX = Address of the region\r
+ ///\r
+ Legacy16GetTableAddress = 0x0006,\r
+ \r
+ ///\r
+ /// Enables the EfiCompatibility module to do any nonstandard processing of keyboard LEDs or state.\r
+ /// Input:\r
+ /// AX = Compatibility16SetKeyboardLeds\r
+ /// CL = LED status.\r
+ /// Bit 0 Scroll Lock 0 = Off\r
+ /// Bit 1 NumLock\r
+ /// Bit 2 Caps Lock\r
+ /// Output:\r
+ /// AX = Returned status codes\r
+ ///\r
+ Legacy16SetKeyboardLeds = 0x0007,\r
+ \r
+ ///\r
+ /// Enables the EfiCompatibility module to install an interrupt handler for PCI mass media devices that\r
+ /// do not have an OpROM associated with them. An example is SATA.\r
+ /// Input:\r
+ /// AX = Compatibility16InstallPciHandler\r
+ /// ES:BX = Pointer to EFI_LEGACY_INSTALL_PCI_HANDLER structure\r
+ /// Output:\r
+ /// AX = Returned status codes\r
+ ///\r
+ Legacy16InstallPciHandler = 0x0008\r
+} EFI_COMPATIBILITY_FUNCTIONS;\r
+\r
+\r
+///\r
+/// EFI_DISPATCH_OPROM_TABLE\r
+///\r
+typedef struct {\r
+ UINT16 PnPInstallationCheckSegment; ///< A pointer to the PnpInstallationCheck data structure.\r
+ UINT16 PnPInstallationCheckOffset; ///< A pointer to the PnpInstallationCheck data structure.\r
+ UINT16 OpromSegment; ///< The segment where the OpROM was placed. Offset is assumed to be 3.\r
+ UINT8 PciBus; ///< The PCI bus.\r
+ UINT8 PciDeviceFunction; ///< The PCI device * 0x08 | PCI function.\r
+ UINT8 NumberBbsEntries; ///< The number of valid BBS table entries upon entry and exit. The IBV code may\r
+ ///< increase this number, if BBS-compliant devices also hook INTs in order to force the\r
+ ///< OpROM BIOS Setup to be executed.\r
+ UINT32 BbsTablePointer; ///< A pointer to the BBS table.\r
+ UINT16 RuntimeSegment; ///< The segment where the OpROM can be relocated to. If this value is 0x0000, this\r
+ ///< means that the relocation of this run time code is not supported.\r
+ ///< Inconsistent with specification here: \r
+ ///< The member's name "OpromDestinationSegment" [defined in Intel Framework Compatibility Support Module Specification / 0.97 version] \r
+ ///< has been changed to "RuntimeSegment" since keeping backward compatible.\r
+\r
+} EFI_DISPATCH_OPROM_TABLE;\r
+\r
+///\r
+/// EFI_TO_COMPATIBILITY16_INIT_TABLE\r
+///\r
+typedef struct {\r
+ ///\r
+ /// Starting address of memory under 1 MB. The ending address is assumed to be 640 KB or 0x9FFFF.\r
+ ///\r
+ UINT32 BiosLessThan1MB;\r
+ \r
+ ///\r
+ /// The starting address of the high memory block.\r
+ ///\r
+ UINT32 HiPmmMemory;\r
+ \r
+ ///\r
+ /// The length of high memory block.\r
+ ///\r
+ UINT32 HiPmmMemorySizeInBytes;\r
+ \r
+ ///\r
+ /// The segment of the reverse thunk call code.\r
+ ///\r
+ UINT16 ReverseThunkCallSegment;\r
+ \r
+ ///\r
+ /// The offset of the reverse thunk call code.\r
+ ///\r
+ UINT16 ReverseThunkCallOffset;\r
+ \r
+ ///\r
+ /// The number of E820 entries copied to the Compatibility16 BIOS.\r
+ ///\r
+ UINT32 NumberE820Entries;\r
+ \r
+ ///\r
+ /// The amount of usable memory above 1 MB, e.g., E820 type 1 memory.\r
+ ///\r
+ UINT32 OsMemoryAbove1Mb;\r
+ \r
+ ///\r
+ /// The start of thunk code in main memory. Memory cannot be used by BIOS or PMM.\r
+ ///\r
+ UINT32 ThunkStart;\r
+ \r
+ ///\r
+ /// The size of the thunk code.\r
+ ///\r
+ UINT32 ThunkSizeInBytes;\r
+ \r
+ ///\r
+ /// Starting address of memory under 1 MB.\r
+ ///\r
+ UINT32 LowPmmMemory;\r
+ \r
+ ///\r
+ /// The length of low Memory block.\r
+ ///\r
+ UINT32 LowPmmMemorySizeInBytes;\r
+} EFI_TO_COMPATIBILITY16_INIT_TABLE;\r
+\r
+///\r
+/// DEVICE_PRODUCER_SERIAL.\r
+///\r
+typedef struct {\r
+ UINT16 Address; ///< I/O address assigned to the serial port.\r
+ UINT8 Irq; ///< IRQ assigned to the serial port.\r
+ SERIAL_MODE Mode; ///< Mode of serial port. Values are defined below.\r
+} DEVICE_PRODUCER_SERIAL;\r
+\r
+///\r
+/// DEVICE_PRODUCER_SERIAL's modes.\r
+///@{\r
+#define DEVICE_SERIAL_MODE_NORMAL 0x00\r
+#define DEVICE_SERIAL_MODE_IRDA 0x01\r
+#define DEVICE_SERIAL_MODE_ASK_IR 0x02\r
+#define DEVICE_SERIAL_MODE_DUPLEX_HALF 0x00\r
+#define DEVICE_SERIAL_MODE_DUPLEX_FULL 0x10\r
+///@)\r
+\r
+///\r
+/// DEVICE_PRODUCER_PARALLEL.\r
+///\r
+typedef struct {\r
+ UINT16 Address; ///< I/O address assigned to the parallel port.\r
+ UINT8 Irq; ///< IRQ assigned to the parallel port.\r
+ UINT8 Dma; ///< DMA assigned to the parallel port.\r
+ PARALLEL_MODE Mode; ///< Mode of the parallel port. Values are defined below.\r
+} DEVICE_PRODUCER_PARALLEL;\r
+\r
+///\r
+/// DEVICE_PRODUCER_PARALLEL's modes.\r
+///@{\r
+#define DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY 0x00\r
+#define DEVICE_PARALLEL_MODE_MODE_BIDIRECTIONAL 0x01\r
+#define DEVICE_PARALLEL_MODE_MODE_EPP 0x02\r
+#define DEVICE_PARALLEL_MODE_MODE_ECP 0x03\r
+///@}\r
+\r
+///\r
+/// DEVICE_PRODUCER_FLOPPY\r
+///\r
+typedef struct {\r
+ UINT16 Address; ///< I/O address assigned to the floppy.\r
+ UINT8 Irq; ///< IRQ assigned to the floppy.\r
+ UINT8 Dma; ///< DMA assigned to the floppy.\r
+ UINT8 NumberOfFloppy; ///< Number of floppies in the system.\r
+} DEVICE_PRODUCER_FLOPPY;\r
+\r
+///\r
+/// LEGACY_DEVICE_FLAGS\r
+///\r
+typedef struct {\r
+ UINT32 A20Kybd : 1; ///< A20 controller by keyboard controller.\r
+ UINT32 A20Port90 : 1; ///< A20 controlled by port 0x92.\r
+ UINT32 Reserved : 30; ///< Reserved for future usage.\r
+} LEGACY_DEVICE_FLAGS;\r
+\r
+///\r
+/// DEVICE_PRODUCER_DATA_HEADER\r
+///\r
+typedef struct {\r
+ DEVICE_PRODUCER_SERIAL Serial[4]; ///< Data for serial port x. Type DEVICE_PRODUCER_SERIAL is defined below.\r
+ DEVICE_PRODUCER_PARALLEL Parallel[3]; ///< Data for parallel port x. Type DEVICE_PRODUCER_PARALLEL is defined below.\r
+ DEVICE_PRODUCER_FLOPPY Floppy; ///< Data for floppy. Type DEVICE_PRODUCER_FLOPPY is defined below.\r
+ UINT8 MousePresent; ///< Flag to indicate if mouse is present.\r
+ LEGACY_DEVICE_FLAGS Flags; ///< Miscellaneous Boolean state information passed to CSM.\r
+} DEVICE_PRODUCER_DATA_HEADER;\r
+\r
+///\r
+/// ATAPI_IDENTIFY\r
+///\r
+typedef struct {\r
+ UINT16 Raw[256]; ///< Raw data from the IDE IdentifyDrive command.\r
+} ATAPI_IDENTIFY;\r
+\r
+///\r
+/// HDD_INFO\r
+///\r
+typedef struct {\r
+ ///\r
+ /// Status of IDE device. Values are defined below. There is one HDD_INFO structure\r
+ /// per IDE controller. The IdentifyDrive is per drive. Index 0 is master and index\r
+ /// 1 is slave.\r
+ ///\r
+ UINT16 Status; \r
+ \r
+ ///\r
+ /// PCI bus of IDE controller.\r
+ ///\r
+ UINT32 Bus;\r
+ \r
+ ///\r
+ /// PCI device of IDE controller.\r
+ ///\r
+ UINT32 Device;\r
+ \r
+ ///\r
+ /// PCI function of IDE controller.\r
+ ///\r
+ UINT32 Function;\r
+ \r
+ ///\r
+ /// Command ports base address.\r
+ ///\r
+ UINT16 CommandBaseAddress;\r
+ \r
+ ///\r
+ /// Control ports base address.\r
+ ///\r
+ UINT16 ControlBaseAddress;\r
+ \r
+ ///\r
+ /// Bus master address.\r
+ ///\r
+ UINT16 BusMasterAddress;\r
+ \r
+ UINT8 HddIrq;\r
+ \r
+ ///\r
+ /// Data that identifies the drive data; one per possible attached drive.\r
+ ///\r
+ ATAPI_IDENTIFY IdentifyDrive[2];\r
+} HDD_INFO;\r
+\r
+///\r
+/// HDD_INFO status bits\r
+///\r
+#define HDD_PRIMARY 0x01\r
+#define HDD_SECONDARY 0x02\r
+#define HDD_MASTER_ATAPI_CDROM 0x04\r
+#define HDD_SLAVE_ATAPI_CDROM 0x08\r
+#define HDD_MASTER_IDE 0x20\r
+#define HDD_SLAVE_IDE 0x40\r
+#define HDD_MASTER_ATAPI_ZIPDISK 0x10\r
+#define HDD_SLAVE_ATAPI_ZIPDISK 0x80\r
+\r
+///\r
+/// BBS_STATUS_FLAGS;\.\r
+///\r
+typedef struct {\r
+ UINT16 OldPosition : 4; ///< Prior priority.\r
+ UINT16 Reserved1 : 4; ///< Reserved for future use.\r
+ UINT16 Enabled : 1; ///< If 0, ignore this entry.\r
+ UINT16 Failed : 1; ///< 0 = Not known if boot failure occurred.\r
+ ///< 1 = Boot attempted failed.\r
+ \r
+ ///\r
+ /// State of media present.\r
+ /// 00 = No bootable media is present in the device.\r
+ /// 01 = Unknown if a bootable media present.\r
+ /// 10 = Media is present and appears bootable.\r
+ /// 11 = Reserved.\r
+ ///\r
+ UINT16 MediaPresent : 2;\r
+ UINT16 Reserved2 : 4; ///< Reserved for future use.\r
+} BBS_STATUS_FLAGS;\r
+\r
+///\r
+/// BBS_TABLE, device type values & boot priority values.\r
+///\r
+typedef struct {\r
+ ///\r
+ /// The boot priority for this boot device. Values are defined below.\r
+ ///\r
+ UINT16 BootPriority;\r
+ \r
+ ///\r
+ /// The PCI bus for this boot device.\r
+ ///\r
+ UINT32 Bus;\r
+ \r
+ ///\r
+ /// The PCI device for this boot device.\r
+ ///\r
+ UINT32 Device;\r
+ \r
+ ///\r
+ /// The PCI function for the boot device.\r
+ ///\r
+ UINT32 Function;\r
+ \r
+ ///\r
+ /// The PCI class for this boot device.\r
+ ///\r
+ UINT8 Class;\r
+ \r
+ ///\r
+ /// The PCI Subclass for this boot device.\r
+ ///\r
+ UINT8 SubClass;\r
+ \r
+ ///\r
+ /// Segment:offset address of an ASCIIZ description string describing the manufacturer.\r
+ ///\r
+ UINT16 MfgStringOffset;\r
+ \r
+ ///\r
+ /// Segment:offset address of an ASCIIZ description string describing the manufacturer.\r
+ /// \r
+ UINT16 MfgStringSegment;\r
+ \r
+ ///\r
+ /// BBS device type. BBS device types are defined below.\r
+ ///\r
+ UINT16 DeviceType;\r
+ \r
+ ///\r
+ /// Status of this boot device. Type BBS_STATUS_FLAGS is defined below.\r
+ ///\r
+ BBS_STATUS_FLAGS StatusFlags;\r
+ \r
+ ///\r
+ /// Segment:Offset address of boot loader for IPL devices or install INT13 handler for\r
+ /// BCV devices.\r
+ ///\r
+ UINT16 BootHandlerOffset;\r
+ \r
+ ///\r
+ /// Segment:Offset address of boot loader for IPL devices or install INT13 handler for\r
+ /// BCV devices.\r
+ /// \r
+ UINT16 BootHandlerSegment;\r
+ \r
+ ///\r
+ /// Segment:offset address of an ASCIIZ description string describing this device.\r
+ ///\r
+ UINT16 DescStringOffset;\r
+\r
+ ///\r
+ /// Segment:offset address of an ASCIIZ description string describing this device.\r
+ ///\r
+ UINT16 DescStringSegment;\r
+ \r
+ ///\r
+ /// Reserved.\r
+ ///\r
+ UINT32 InitPerReserved;\r
+ \r
+ ///\r
+ /// The use of these fields is IBV dependent. They can be used to flag that an OpROM\r
+ /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI\r
+ /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup\r
+ ///\r
+ UINT32 AdditionalIrq13Handler;\r
+ \r
+ ///\r
+ /// The use of these fields is IBV dependent. They can be used to flag that an OpROM\r
+ /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI\r
+ /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup\r
+ /// \r
+ UINT32 AdditionalIrq18Handler;\r
+ \r
+ ///\r
+ /// The use of these fields is IBV dependent. They can be used to flag that an OpROM\r
+ /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI\r
+ /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup\r
+ /// \r
+ UINT32 AdditionalIrq19Handler;\r
+ \r
+ ///\r
+ /// The use of these fields is IBV dependent. They can be used to flag that an OpROM\r
+ /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI\r
+ /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup\r
+ /// \r
+ UINT32 AdditionalIrq40Handler;\r
+ UINT8 AssignedDriveNumber;\r
+ UINT32 AdditionalIrq41Handler;\r
+ UINT32 AdditionalIrq46Handler;\r
+ UINT32 IBV1;\r
+ UINT32 IBV2;\r
+} BBS_TABLE;\r
+\r
+///\r
+/// BBS device type values\r
+///@{\r
+#define BBS_FLOPPY 0x01\r
+#define BBS_HARDDISK 0x02\r
+#define BBS_CDROM 0x03\r
+#define BBS_PCMCIA 0x04\r
+#define BBS_USB 0x05\r
+#define BBS_EMBED_NETWORK 0x06\r
+#define BBS_BEV_DEVICE 0x80\r
+#define BBS_UNKNOWN 0xff\r
+///@}\r
+\r
+///\r
+/// BBS boot priority values\r
+///@{\r
+#define BBS_DO_NOT_BOOT_FROM 0xFFFC\r
+#define BBS_LOWEST_PRIORITY 0xFFFD\r
+#define BBS_UNPRIORITIZED_ENTRY 0xFFFE\r
+#define BBS_IGNORE_ENTRY 0xFFFF\r
+///@}\r
+\r
+///\r
+/// SMM_ATTRIBUTES\r
+///\r
+typedef struct {\r
+ ///\r
+ /// Access mechanism used to generate the soft SMI. Defined types are below. The other\r
+ /// values are reserved for future usage.\r
+ ///\r
+ UINT16 Type : 3;\r
+ \r
+ ///\r
+ /// The size of "port" in bits. Defined values are below.\r
+ ///\r
+ UINT16 PortGranularity : 3;\r
+ \r
+ ///\r
+ /// The size of data in bits. Defined values are below.\r
+ ///\r
+ UINT16 DataGranularity : 3;\r
+ \r
+ ///\r
+ /// Reserved for future use.\r
+ ///\r
+ UINT16 Reserved : 7;\r
+} SMM_ATTRIBUTES;\r
+\r
+///\r
+/// SMM_ATTRIBUTES type values.\r
+///@{\r
+#define STANDARD_IO 0x00\r
+#define STANDARD_MEMORY 0x01\r
+///@}\r
+\r
+///\r
+/// SMM_ATTRIBUTES port size constants.\r
+///@{\r
+#define PORT_SIZE_8 0x00\r
+#define PORT_SIZE_16 0x01\r
+#define PORT_SIZE_32 0x02\r
+#define PORT_SIZE_64 0x03\r
+///@}\r
+\r
+///\r
+/// SMM_ATTRIBUTES data size constants.\r
+///@{\r
+#define DATA_SIZE_8 0x00\r
+#define DATA_SIZE_16 0x01\r
+#define DATA_SIZE_32 0x02\r
+#define DATA_SIZE_64 0x03\r
+///@}\r
+\r
+///\r
+/// SMM_FUNCTION & relating constants.\r
+///\r
+typedef struct {\r
+ UINT16 Function : 15;\r
+ UINT16 Owner : 1;\r
+} SMM_FUNCTION;\r
+\r
+///\r
+/// SMM_FUNCTION Function constants.\r
+///@{\r
+#define INT15_D042 0x0000\r
+#define GET_USB_BOOT_INFO 0x0001\r
+#define DMI_PNP_50_57 0x0002\r
+///@}\r
+\r
+///\r
+/// SMM_FUNCTION Owner constants.\r
+///@{\r
+#define STANDARD_OWNER 0x0\r
+#define OEM_OWNER 0x1\r
+///@}\r
+\r
+///\r
+/// This structure assumes both port and data sizes are 1. SmmAttribute must be\r
+/// properly to reflect that assumption.\r
+///\r
+typedef struct {\r
+ ///\r
+ /// Describes the access mechanism, SmmPort, and SmmData sizes. Type\r
+ /// SMM_ATTRIBUTES is defined below.\r
+ ///\r
+ SMM_ATTRIBUTES SmmAttributes;\r
+ \r
+ ///\r
+ /// Function Soft SMI is to perform. Type SMM_FUNCTION is defined below.\r
+ ///\r
+ SMM_FUNCTION SmmFunction;\r
+ \r
+ ///\r
+ /// SmmPort size depends upon SmmAttributes and ranges from2 bytes to 16 bytes.\r
+ ///\r
+ UINT8 SmmPort;\r
+ \r
+ ///\r
+ /// SmmData size depends upon SmmAttributes and ranges from2 bytes to 16 bytes.\r
+ ///\r
+ UINT8 SmmData;\r
+} SMM_ENTRY;\r
+\r
+///\r
+/// SMM_TABLE\r
+///\r
+typedef struct {\r
+ UINT16 NumSmmEntries; ///< Number of entries represented by SmmEntry.\r
+ SMM_ENTRY SmmEntry; ///< One entry per function. Type SMM_ENTRY is defined below.\r
+} SMM_TABLE;\r
+\r
+///\r
+/// UDC_ATTRIBUTES\r
+///\r
+typedef struct {\r
+ ///\r
+ /// This bit set indicates that the ServiceAreaData is valid.\r
+ ///\r
+ UINT8 DirectoryServiceValidity : 1;\r
+ \r
+ ///\r
+ /// This bit set indicates to use the Reserve Area Boot Code Address (RACBA) only if\r
+ /// DirectoryServiceValidity is 0.\r
+ ///\r
+ UINT8 RabcaUsedFlag : 1;\r
+ \r
+ ///\r
+ /// This bit set indicates to execute hard disk diagnostics.\r
+ ///\r
+ UINT8 ExecuteHddDiagnosticsFlag : 1;\r
+ \r
+ ///\r
+ /// Reserved for future use. Set to 0.\r
+ ///\r
+ UINT8 Reserved : 5;\r
+} UDC_ATTRIBUTES;\r
+\r
+///\r
+/// UD_TABLE\r
+///\r
+typedef struct {\r
+ ///\r
+ /// This field contains the bit-mapped attributes of the PARTIES information. Type\r
+ /// UDC_ATTRIBUTES is defined below.\r
+ ///\r
+ UDC_ATTRIBUTES Attributes;\r
+ \r
+ ///\r
+ /// This field contains the zero-based device on which the selected\r
+ /// ServiceDataArea is present. It is 0 for master and 1 for the slave device. \r
+ ///\r
+ UINT8 DeviceNumber;\r
+ \r
+ ///\r
+ /// This field contains the zero-based index into the BbsTable for the parent device.\r
+ /// This index allows the user to reference the parent device information such as PCI\r
+ /// bus, device function.\r
+ ///\r
+ UINT8 BbsTableEntryNumberForParentDevice;\r
+ \r
+ ///\r
+ /// This field contains the zero-based index into the BbsTable for the boot entry.\r
+ ///\r
+ UINT8 BbsTableEntryNumberForBoot;\r
+ \r
+ ///\r
+ /// This field contains the zero-based index into the BbsTable for the HDD diagnostics entry.\r
+ ///\r
+ UINT8 BbsTableEntryNumberForHddDiag;\r
+ \r
+ ///\r
+ /// The raw Beer data.\r
+ ///\r
+ UINT8 BeerData[128];\r
+ \r
+ ///\r
+ /// The raw data of selected service area.\r
+ ///\r
+ UINT8 ServiceAreaData[64];\r
+} UD_TABLE;\r
+\r
+#define EFI_TO_LEGACY_MAJOR_VERSION 0x02\r
+#define EFI_TO_LEGACY_MINOR_VERSION 0x00\r
+#define MAX_IDE_CONTROLLER 8\r
+\r
+///\r
+/// EFI_TO_COMPATIBILITY16_BOOT_TABLE\r
+///\r
+typedef struct {\r
+ UINT16 MajorVersion; ///< The EfiCompatibility major version number.\r
+ UINT16 MinorVersion; ///< The EfiCompatibility minor version number.\r
+ UINT32 AcpiTable; ///< The location of the RSDT ACPI table. < 4G range.\r
+ UINT32 SmbiosTable; ///< The location of the SMBIOS table in EFI memory. < 4G range.\r
+ UINT32 SmbiosTableLength;\r
+ //\r
+ // Legacy SIO state\r
+ //\r
+ DEVICE_PRODUCER_DATA_HEADER SioData; ///< Standard traditional device information.\r
+ UINT16 DevicePathType; ///< The default boot type.\r
+ UINT16 PciIrqMask; ///< Mask of which IRQs have been assigned to PCI.\r
+ UINT32 NumberE820Entries; ///< Number of E820 entries. The number can change from the\r
+ ///< Compatibility16InitializeYourself() function.\r
+ //\r
+ // Controller & Drive Identify[2] per controller information\r
+ //\r
+ HDD_INFO HddInfo[MAX_IDE_CONTROLLER]; ///< Hard disk drive information, including raw Identify Drive data.\r
+ UINT32 NumberBbsEntries; ///< Number of entries in the BBS table\r
+ UINT32 BbsTable; ///< A pointer to the BBS table. Type BBS_TABLE is defined below.\r
+ UINT32 SmmTable; ///< A pointer to the SMM table. Type SMM_TABLE is defined below.\r
+ UINT32 OsMemoryAbove1Mb; ///< The amount of usable memory above 1 MB, i.e. E820 type 1 memory. This value can\r
+ ///< differ from the value in EFI_TO_COMPATIBILITY16_INIT_TABLE as more\r
+ ///< memory may have been discovered.\r
+ UINT32 UnconventionalDeviceTable; ///< Information to boot off an unconventional device like a PARTIES partition. Type\r
+ ///< UD_TABLE is defined below.\r
+} EFI_TO_COMPATIBILITY16_BOOT_TABLE;\r
+\r
+///\r
+/// EFI_LEGACY_INSTALL_PCI_HANDLER\r
+///\r
+typedef struct {\r
+ UINT8 PciBus; ///< The PCI bus of the device.\r
+ UINT8 PciDeviceFun; ///< The PCI device in bits 7:3 and function in bits 2:0.\r
+ UINT8 PciSegment; ///< The PCI segment of the device.\r
+ UINT8 PciClass; ///< The PCI class code of the device.\r
+ UINT8 PciSubclass; ///< The PCI subclass code of the device.\r
+ UINT8 PciInterface; ///< The PCI interface code of the device.\r
+ //\r
+ // Primary section\r
+ //\r
+ UINT8 PrimaryIrq; ///< The primary device IRQ.\r
+ UINT8 PrimaryReserved; ///< Reserved.\r
+ UINT16 PrimaryControl; ///< The primary device control I/O base.\r
+ UINT16 PrimaryBase; ///< The primary device I/O base.\r
+ UINT16 PrimaryBusMaster; ///< The primary device bus master I/O base.\r
+ //\r
+ // Secondary Section\r
+ //\r
+ UINT8 SecondaryIrq; ///< The secondary device IRQ.\r
+ UINT8 SecondaryReserved; ///< Reserved.\r
+ UINT16 SecondaryControl; ///< The secondary device control I/O base.\r
+ UINT16 SecondaryBase; ///< The secondary device I/O base.\r
+ UINT16 SecondaryBusMaster; ///< The secondary device bus master I/O base.\r
+} EFI_LEGACY_INSTALL_PCI_HANDLER;\r
+\r
+//\r
+// Restore default pack value\r
+//\r
+#pragma pack()\r
+\r
+#define EFI_LEGACY_BIOS_PROTOCOL_GUID \\r
+ { \\r
+ 0xdb9a1e3d, 0x45cb, 0x4abb, {0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d } \\r
+ }\r
+\r
+typedef struct _EFI_LEGACY_BIOS_PROTOCOL EFI_LEGACY_BIOS_PROTOCOL;\r
+\r
+///\r
+/// Flags returned by CheckPciRom().\r
+///\r
+#define NO_ROM 0x00\r
+#define ROM_FOUND 0x01\r
+#define VALID_LEGACY_ROM 0x02\r
+#define ROM_WITH_CONFIG 0x04 ///< Not defined in the Framework CSM Specification.\r
+\r
+///\r
+/// The following macros do not appear in the Framework CSM Specification and \r
+/// are kept for backward compatibility only. They convert 32-bit address (_Adr) \r
+/// to Segment:Offset 16-bit form.\r
+///\r
+///@{\r
+#define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)\r
+#define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)\r
+///@}\r
+\r
+#define CARRY_FLAG 0x01\r
+\r
+///\r
+/// EFI_EFLAGS_REG\r
+///\r
+typedef struct {\r
+ UINT32 CF:1;\r
+ UINT32 Reserved1:1;\r
+ UINT32 PF:1;\r
+ UINT32 Reserved2:1;\r
+ UINT32 AF:1;\r
+ UINT32 Reserved3:1;\r
+ UINT32 ZF:1;\r
+ UINT32 SF:1;\r
+ UINT32 TF:1;\r
+ UINT32 IF:1;\r
+ UINT32 DF:1;\r
+ UINT32 OF:1;\r
+ UINT32 IOPL:2;\r
+ UINT32 NT:1;\r
+ UINT32 Reserved4:2;\r
+ UINT32 VM:1;\r
+ UINT32 Reserved5:14;\r
+} EFI_EFLAGS_REG;\r
+\r
+///\r
+/// EFI_DWORD_REGS\r
+///\r
+typedef struct {\r
+ UINT32 EAX;\r
+ UINT32 EBX;\r
+ UINT32 ECX;\r
+ UINT32 EDX;\r
+ UINT32 ESI;\r
+ UINT32 EDI;\r
+ EFI_EFLAGS_REG EFlags;\r
+ UINT16 ES;\r
+ UINT16 CS;\r
+ UINT16 SS;\r
+ UINT16 DS;\r
+ UINT16 FS;\r
+ UINT16 GS;\r
+ UINT32 EBP;\r
+ UINT32 ESP;\r
+} EFI_DWORD_REGS;\r
+\r
+///\r
+/// EFI_FLAGS_REG\r
+///\r
+typedef struct {\r
+ UINT16 CF:1;\r
+ UINT16 Reserved1:1;\r
+ UINT16 PF:1;\r
+ UINT16 Reserved2:1;\r
+ UINT16 AF:1;\r
+ UINT16 Reserved3:1;\r
+ UINT16 ZF:1;\r
+ UINT16 SF:1;\r
+ UINT16 TF:1;\r
+ UINT16 IF:1;\r
+ UINT16 DF:1;\r
+ UINT16 OF:1;\r
+ UINT16 IOPL:2;\r
+ UINT16 NT:1;\r
+ UINT16 Reserved4:1;\r
+} EFI_FLAGS_REG;\r
+\r
+///\r
+/// EFI_WORD_REGS\r
+///\r
+typedef struct {\r
+ UINT16 AX;\r
+ UINT16 ReservedAX;\r
+ UINT16 BX;\r
+ UINT16 ReservedBX;\r
+ UINT16 CX;\r
+ UINT16 ReservedCX;\r
+ UINT16 DX;\r
+ UINT16 ReservedDX;\r
+ UINT16 SI;\r
+ UINT16 ReservedSI;\r
+ UINT16 DI;\r
+ UINT16 ReservedDI;\r
+ EFI_FLAGS_REG Flags;\r
+ UINT16 ReservedFlags;\r
+ UINT16 ES;\r
+ UINT16 CS;\r
+ UINT16 SS;\r
+ UINT16 DS;\r
+ UINT16 FS;\r
+ UINT16 GS;\r
+ UINT16 BP;\r
+ UINT16 ReservedBP;\r
+ UINT16 SP;\r
+ UINT16 ReservedSP;\r
+} EFI_WORD_REGS;\r
+\r
+///\r
+/// EFI_BYTE_REGS\r
+///\r
+typedef struct {\r
+ UINT8 AL, AH;\r
+ UINT16 ReservedAX;\r
+ UINT8 BL, BH;\r
+ UINT16 ReservedBX;\r
+ UINT8 CL, CH;\r
+ UINT16 ReservedCX;\r
+ UINT8 DL, DH;\r
+ UINT16 ReservedDX;\r
+} EFI_BYTE_REGS;\r
+\r
+///\r
+/// EFI_IA32_REGISTER_SET\r
+///\r
+typedef union {\r
+ EFI_DWORD_REGS E;\r
+ EFI_WORD_REGS X;\r
+ EFI_BYTE_REGS H;\r
+} EFI_IA32_REGISTER_SET;\r
+\r
+/**\r
+ Thunk to 16-bit real mode and execute a software interrupt with a vector\r
+ of BiosInt. Regs will contain the 16-bit register context on entry and\r
+ exit.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[in] BiosInt The processor interrupt vector to invoke.\r
+ @param[in,out] Reg Register contexted passed into (and returned) from thunk to\r
+ 16-bit mode.\r
+\r
+ @retval TRUE Thunk completed with no BIOS errors in the target code. See Regs for status. \r
+ @retval FALSE There was a BIOS error in the target code.\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_LEGACY_BIOS_INT86)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ IN UINT8 BiosInt,\r
+ IN OUT EFI_IA32_REGISTER_SET *Regs\r
+ );\r
+\r
+/**\r
+ Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the\r
+ 16-bit register context on entry and exit. Arguments can be passed on\r
+ the Stack argument\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[in] Segment The segemnt of 16-bit mode call.\r
+ @param[in] Offset The offset of 16-bit mdoe call.\r
+ @param[in] Reg Register contexted passed into (and returned) from thunk to\r
+ 16-bit mode.\r
+ @param[in] Stack The caller allocated stack used to pass arguments.\r
+ @param[in] StackSize The size of Stack in bytes.\r
+\r
+ @retval FALSE Thunk completed with no BIOS errors in the target code. See Regs for status. @retval TRUE There was a BIOS error in the target code.\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_LEGACY_BIOS_FARCALL86)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ IN UINT16 Segment,\r
+ IN UINT16 Offset,\r
+ IN EFI_IA32_REGISTER_SET *Regs,\r
+ IN VOID *Stack,\r
+ IN UINTN StackSize\r
+ );\r
+\r
+/**\r
+ Test to see if a legacy PCI ROM exists for this device. Optionally return\r
+ the Legacy ROM instance for this PCI device.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded\r
+ @param[out] RomImage Return the legacy PCI ROM for this device.\r
+ @param[out] RomSize The size of ROM Image.\r
+ @param[out] Flags Indicates if ROM found and if PC-AT. Multiple bits can be set as follows:\r
+ - 00 = No ROM.\r
+ - 01 = ROM Found.\r
+ - 02 = ROM is a valid legacy ROM.\r
+\r
+ @retval EFI_SUCCESS The Legacy Option ROM availible for this device\r
+ @retval EFI_UNSUPPORTED The Legacy Option ROM is not supported.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_CHECK_ROM)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ IN EFI_HANDLE PciHandle,\r
+ OUT VOID **RomImage, OPTIONAL\r
+ OUT UINTN *RomSize, OPTIONAL\r
+ OUT UINTN *Flags\r
+ );\r
+\r
+/**\r
+ Load a legacy PC-AT OPROM on the PciHandle device. Return information\r
+ about how many disks were added by the OPROM and the shadow address and\r
+ size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded.\r
+ This value is NULL if RomImage is non-NULL. This is the normal\r
+ case.\r
+ @param[in] RomImage A PCI PC-AT ROM image. This argument is non-NULL if there is\r
+ no hardware associated with the ROM and thus no PciHandle,\r
+ otherwise is must be NULL.\r
+ Example is PXE base code.\r
+ @param[out] Flags The type of ROM discovered. Multiple bits can be set, as follows:\r
+ - 00 = No ROM.\r
+ - 01 = ROM found.\r
+ - 02 = ROM is a valid legacy ROM.\r
+ @param[out] DiskStart The disk number of first device hooked by the ROM. If DiskStart\r
+ is the same as DiskEnd no disked were hooked.\r
+ @param[out] DiskEnd disk number of the last device hooked by the ROM.\r
+ @param[out] RomShadowAddress Shadow address of PC-AT ROM.\r
+ @param[out] RomShadowSize Size of RomShadowAddress in bytes.\r
+\r
+ @retval EFI_SUCCESS Thunk completed, see Regs for status.\r
+ @retval EFI_INVALID_PARAMETER PciHandle not found\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_INSTALL_ROM)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ IN EFI_HANDLE PciHandle,\r
+ IN VOID **RomImage,\r
+ OUT UINTN *Flags,\r
+ OUT UINT8 *DiskStart, OPTIONAL\r
+ OUT UINT8 *DiskEnd, OPTIONAL\r
+ OUT VOID **RomShadowAddress, OPTIONAL\r
+ OUT UINT32 *ShadowedRomSize OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function attempts to traditionally boot the specified BootOption. If the EFI context has\r
+ been compromised, this function will not return. This procedure is not used for loading an EFI-aware\r
+ OS off a traditional device. The following actions occur:\r
+ - Get EFI SMBIOS data structures, convert them to a traditional format, and copy to\r
+ Compatibility16.\r
+ - Get a pointer to ACPI data structures and copy the Compatibility16 RSD PTR to F0000 block.\r
+ - Find the traditional SMI handler from a firmware volume and register the traditional SMI\r
+ handler with the EFI SMI handler.\r
+ - Build onboard IDE information and pass this information to the Compatibility16 code.\r
+ - Make sure all PCI Interrupt Line registers are programmed to match 8259.\r
+ - Reconfigure SIO devices from EFI mode (polled) into traditional mode (interrupt driven).\r
+ - Shadow all PCI ROMs.\r
+ - Set up BDA and EBDA standard areas before the legacy boot.\r
+ - Construct the Compatibility16 boot memory map and pass it to the Compatibility16 code.\r
+ - Invoke the Compatibility16 table function Compatibility16PrepareToBoot(). This\r
+ invocation causes a thunk into the Compatibility16 code, which sets all appropriate internal\r
+ data structures. The boot device list is a parameter.\r
+ - Invoke the Compatibility16 Table function Compatibility16Boot(). This invocation\r
+ causes a thunk into the Compatibility16 code, which does an INT19.\r
+ - If the Compatibility16Boot() function returns, then the boot failed in a graceful\r
+ manner--meaning that the EFI code is still valid. An ungraceful boot failure causes a reset because the state\r
+ of EFI code is unknown.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[in] BootOption The EFI Device Path from BootXXXX variable.\r
+ @param[in] LoadOptionSize The size of LoadOption in size.\r
+ @param[in] LoadOption LThe oadOption from BootXXXX variable.\r
+\r
+ @retval EFI_DEVICE_ERROR Failed to boot from any boot device and memory is uncorrupted. Note: This function normally does not returns. It will either boot the OS or reset the system if memory has been "corrupted" by loading a boot sector and passing control to it.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_BOOT)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ IN BBS_BBS_DEVICE_PATH *BootOption,\r
+ IN UINT32 LoadOptionsSize,\r
+ IN VOID *LoadOptions\r
+ );\r
+\r
+/**\r
+ This function takes the Leds input parameter and sets/resets the BDA accordingly. \r
+ Leds is also passed to Compatibility16 code, in case any special processing is required. \r
+ This function is normally called from EFI Setup drivers that handle user-selectable\r
+ keyboard options such as boot with NUM LOCK on/off. This function does not\r
+ touch the keyboard or keyboard LEDs but only the BDA.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[in] Leds The status of current Scroll, Num & Cap lock LEDS:\r
+ - Bit 0 is Scroll Lock 0 = Not locked.\r
+ - Bit 1 is Num Lock.\r
+ - Bit 2 is Caps Lock.\r
+\r
+ @retval EFI_SUCCESS The BDA was updated successfully.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ IN UINT8 Leds\r
+ );\r
+\r
+/**\r
+ Retrieve legacy BBS info and assign boot priority.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[out] HddCount The number of HDD_INFO structures.\r
+ @param[out] HddInfo Onboard IDE controller information.\r
+ @param[out] BbsCount The number of BBS_TABLE structures.\r
+ @param[in,out] BbsTable Points to List of BBS_TABLE.\r
+\r
+ @retval EFI_SUCCESS Tables were returned.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_GET_BBS_INFO)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ OUT UINT16 *HddCount,\r
+ OUT HDD_INFO **HddInfo,\r
+ OUT UINT16 *BbsCount,\r
+ IN OUT BBS_TABLE **BbsTable\r
+ );\r
+\r
+/**\r
+ Assign drive number to legacy HDD drives prior to booting an EFI\r
+ aware OS so the OS can access drives without an EFI driver.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[out] BbsCount The number of BBS_TABLE structures\r
+ @param[out] BbsTable List of BBS entries\r
+\r
+ @retval EFI_SUCCESS Drive numbers assigned.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ OUT UINT16 *BbsCount,\r
+ OUT BBS_TABLE **BbsTable\r
+ );\r
+\r
+/**\r
+ To boot from an unconventional device like parties and/or execute\r
+ HDD diagnostics.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[in] Attributes How to interpret the other input parameters.\r
+ @param[in] BbsEntry The 0-based index into the BbsTable for the parent\r
+ device.\r
+ @param[in] BeerData A pointer to the 128 bytes of ram BEER data.\r
+ @param[in] ServiceAreaData A pointer to the 64 bytes of raw Service Area data. The\r
+ caller must provide a pointer to the specific Service\r
+ Area and not the start all Service Areas.\r
+\r
+ @retval EFI_INVALID_PARAMETER If error. Does NOT return if no error.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ IN UDC_ATTRIBUTES Attributes,\r
+ IN UINTN BbsEntry,\r
+ IN VOID *BeerData,\r
+ IN VOID *ServiceAreaData\r
+ );\r
+\r
+/**\r
+ Shadow all legacy16 OPROMs that haven't been shadowed.\r
+ Warning: Use this with caution. This routine disconnects all EFI\r
+ drivers. If used externally, then the caller must re-connect EFI\r
+ drivers.\r
+ \r
+ @param[in] This The protocol instance pointer.\r
+ \r
+ @retval EFI_SUCCESS OPROMs were shadowed.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This\r
+ );\r
+\r
+/**\r
+ Get a region from the LegacyBios for S3 usage.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[in] LegacyMemorySize The size of required region.\r
+ @param[in] Region The region to use.\r
+ 00 = Either 0xE0000 or 0xF0000 block.\r
+ - Bit0 = 1 0xF0000 block.\r
+ - Bit1 = 1 0xE0000 block.\r
+ @param[in] Alignment Address alignment. Bit mapped. The first non-zero\r
+ bit from right is alignment.\r
+ @param[out] LegacyMemoryAddress The Region Assigned\r
+\r
+ @retval EFI_SUCCESS The Region was assigned.\r
+ @retval EFI_ACCESS_DENIED The function was previously invoked.\r
+ @retval Other The Region was not assigned.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_GET_LEGACY_REGION)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ IN UINTN LegacyMemorySize,\r
+ IN UINTN Region,\r
+ IN UINTN Alignment,\r
+ OUT VOID **LegacyMemoryAddress\r
+ );\r
+\r
+/**\r
+ Get a region from the LegacyBios for Tiano usage. Can only be invoked once.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[in] LegacyMemorySize The size of data to copy.\r
+ @param[in] LegacyMemoryAddress The Legacy Region destination address.\r
+ Note: must be in region assigned by\r
+ LegacyBiosGetLegacyRegion.\r
+ @param[in] LegacyMemorySourceAddress The source of the data to copy.\r
+\r
+ @retval EFI_SUCCESS The Region assigned.\r
+ @retval EFI_ACCESS_DENIED Destination was outside an assigned region.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_COPY_LEGACY_REGION)(\r
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
+ IN UINTN LegacyMemorySize,\r
+ IN VOID *LegacyMemoryAddress,\r
+ IN VOID *LegacyMemorySourceAddress\r
+ );\r
+\r
+///\r
+/// Abstracts the traditional BIOS from the rest of EFI. The LegacyBoot()\r
+/// member function allows the BDS to support booting a traditional OS.\r
+/// EFI thunks drivers that make EFI bindings for BIOS INT services use\r
+/// all the other member functions.\r
+///\r
+struct _EFI_LEGACY_BIOS_PROTOCOL {\r
+ ///\r
+ /// Performs traditional software INT. See the Int86() function description.\r
+ ///\r
+ EFI_LEGACY_BIOS_INT86 Int86;\r
+ \r
+ ///\r
+ /// Performs a far call into Compatibility16 or traditional OpROM code.\r
+ ///\r
+ EFI_LEGACY_BIOS_FARCALL86 FarCall86;\r
+ \r
+ ///\r
+ /// Checks if a traditional OpROM exists for this device.\r
+ ///\r
+ EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom;\r
+ \r
+ ///\r
+ /// Loads a traditional OpROM in traditional OpROM address space.\r
+ ///\r
+ EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom;\r
+ \r
+ ///\r
+ /// Boots a traditional OS.\r
+ ///\r
+ EFI_LEGACY_BIOS_BOOT LegacyBoot;\r
+ \r
+ ///\r
+ /// Updates BDA to reflect the current EFI keyboard LED status.\r
+ ///\r
+ EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus;\r
+ \r
+ ///\r
+ /// Allows an external agent, such as BIOS Setup, to get the BBS data.\r
+ ///\r
+ EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo;\r
+ \r
+ ///\r
+ /// Causes all legacy OpROMs to be shadowed.\r
+ ///\r
+ EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms;\r
+ \r
+ ///\r
+ /// Performs all actions prior to boot. Used when booting an EFI-aware OS\r
+ /// rather than a legacy OS. \r
+ ///\r
+ EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi;\r
+ \r
+ ///\r
+ /// Allows EFI to reserve an area in the 0xE0000 or 0xF0000 block.\r
+ ///\r
+ EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion;\r
+ \r
+ ///\r
+ /// Allows EFI to copy data to the area specified by GetLegacyRegion.\r
+ ///\r
+ EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion;\r
+ \r
+ ///\r
+ /// Allows the user to boot off an unconventional device such as a PARTIES partition.\r
+ ///\r
+ EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice;\r
+};\r
+\r
+extern EFI_GUID gEfiLegacyBiosProtocolGuid;\r
+\r
+#endif\r
--- /dev/null
+#
+# EfiLib/Make.tiano
+# Build control file for EfiLib components of rEFInd, using TianoCore EDK2
+#
+
+include ../Make.tiano
+
+SOURCE_NAMES = legacy BmLib&n