

deleted file mode 100644

index d482a5d..0000000

--- a/

+++ /dev/null diff --git a/.gitignore b/.gitignoredeleted file mode 100644index d482a5d..0000000--- a/ .gitignore +++ /dev/null @@ -1,40 +0,0 @@ -*~ -*.o -*.so -*.cache -*.log -.deps -.libs -*.8 -.dirstamp -/gummiboot -/gummiboot.so -/gummibootx64.efi -/gummibootia32.efi -/stub.so -/stubx64.efi -/stubia32.efi -/test-disk - -Makefile -aclocal.m4 -stamp-h.in -Makefile.in -configure -config.h -config.h.in -config.guess -config.status -config.sub -stamp-h -stamp-h1 -m4/*.m4 -config.rpath -mkinstalldirs -compile -depcomp -install-sh -missing - -# wanted files -!m4/arch.m4

deleted file mode 100644

index 366fbdc..0000000

--- a/

+++ /dev/null diff --git a/.vimrc b/.vimrcdeleted file mode 100644index 366fbdc..0000000--- a/ .vimrc +++ /dev/null @@ -1,4 +0,0 @@ -" 'set exrc' in ~/.vimrc will read .vimrc from the current directory -set tabstop=8 -set shiftwidth=8 -set expandtab

deleted file mode 100644

index 4362b49..0000000

--- a/

+++ /dev/null diff --git a/LICENSE b/LICENSEdeleted file mode 100644index 4362b49..0000000--- a/ LICENSE +++ /dev/null @@ -1,502 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -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 this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -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 -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser 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 Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "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 -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY 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 -LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey 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 library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it!

deleted file mode 100644

index 6568a35..0000000

--- a/

+++ /dev/null diff --git a/Makefile.am b/Makefile.amdeleted file mode 100644index 6568a35..0000000--- a/ Makefile.am +++ /dev/null @@ -1,203 +0,0 @@ -# -# This file is part of gummiboot -# -# Copyright (C) 2013 Karel Zak <kzak@redhat.com> -# -# gummiboot is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# gummiboot 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with systemd; If not, see <http://www.gnu.org/licenses/>. - -ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} -AM_MAKEFLAGS = --no-print-directory - -gummibootlibdir = $(prefix)/lib/gummiboot - -AM_CPPFLAGS = -include config.h -AM_CFLAGS = \ - -D_GNU_SOURCE \ - -Wall \ - -Wextra \ - -Wmissing-prototypes \ - -Wno-unused-parameter -AM_LDFLAGS = - -EXTRA_DIST = autogen.sh README LICENSE -CLEANFILES = - -# ------------------------------------------------------------------------------ -if HAVE_BLKID -bin_PROGRAMS = gummiboot - -gummiboot_SOURCES = \ - src/setup/setup.c \ - src/setup/efivars.c \ - src/setup/efivars.h - -gummiboot_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DMACHINE_TYPE_NAME=\"$(MACHINE_TYPE_NAME)\" \ - -DGUMMIBOOTLIBDIR=\"$(gummibootlibdir)\" - -gummiboot_CFLAGS = \ - $(AM_CFLAGS) \ - $(BLKID_CFLAGS) - -gummiboot_LDADD = \ - $(BLKID_LIBS) -endif - -if ENABLE_MANPAGES -%.8: %.xml - $(AM_V_GEN)$(XSLTPROC) -o $@ --nonet \ - --stringparam man.output.quietly 1 \ - --stringparam man.th.extra1.suppress 1 \ - --stringparam man.authors.section.enabled 0 \ - --stringparam man.copyright.section.enabled 0 \ - http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $< - -dist_man_MANS = man/gummiboot.8 -endif - -EXTRA_DIST += man/gummiboot.xml -CLEANFILES += man/gummiboot.8 - -# ------------------------------------------------------------------------------ -# EFI compilation -- this part of the build system uses custom make rules and -# bypasses regular automake to provide absolute control on compiler and linker -# flags. -efi_cppflags = \ - $(EFI_CPPFLAGS) \ - -I$(top_builddir) -include config.h \ - -I$(EFI_INC_DIR)/efi \ - -I$(EFI_INC_DIR)/efi/$(ARCH) \ - -DMACHINE_TYPE_NAME=\"$(MACHINE_TYPE_NAME)\" - -efi_cflags = \ - $(EFI_CFLAGS) \ - -Wall \ - -Wextra \ - -std=gnu90 \ - -nostdinc \ - -ggdb -O0 \ - -fpic \ - -fshort-wchar \ - -nostdinc \ - -ffreestanding \ - -fno-strict-aliasing \ - -fno-stack-protector \ - -Wsign-compare \ - -mno-sse \ - -mno-mmx - -if ARCH_X86_64 -efi_cflags += \ - -mno-red-zone \ - -DEFI_FUNCTION_WRAPPER \ - -DGNU_EFI_USE_MS_ABI -endif - -efi_ldflags = \ - $(EFI_LDFLAGS) \ - -T $(EFI_LDS_DIR)/elf_$(ARCH)_efi.lds \ - -shared \ - -Bsymbolic \ - -nostdlib \ - -znocombreloc \ - -L $(EFI_LIB_DIR) \ - $(EFI_LDS_DIR)/crt0-efi-$(ARCH).o - -# ------------------------------------------------------------------------------ -gummiboot_headers = \ - src/efi/util.h \ - src/efi/console.h \ - src/efi/graphics.h \ - src/efi/pefile.h - -gummiboot_sources = \ - src/efi/util.c \ - src/efi/console.c \ - src/efi/graphics.c \ - src/efi/pefile.c \ - src/efi/gummiboot.c - -gummiboot_objects = $(addprefix $(top_builddir)/,$(gummiboot_sources:.c=.o)) -gummiboot_solib = $(top_builddir)/src/efi/gummiboot.so -gummiboot = gummiboot$(MACHINE_TYPE_NAME).efi - -gummibootlib_DATA = $(gummiboot) -CLEANFILES += $(gummiboot_objects) $(gummiboot_solib) $(gummiboot) -EXTRA_DIST += $(gummiboot_sources) $(gummiboot_headers) - -$(top_builddir)/src/efi/%.o: $(top_srcdir)/src/efi/%.c $(addprefix $(top_srcdir)/,$(gummiboot_headers)) - @$(MKDIR_P) $(top_builddir)/src/efi/ - $(AM_V_CC)$(EFI_CC) $(efi_cppflags) $(efi_cflags) -c $< -o $@ - -$(gummiboot_solib): $(gummiboot_objects) - $(AM_V_CCLD)$(LD) $(efi_ldflags) $(gummiboot_objects) \ - -o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \ - nm -D -u $@ | grep ' U ' && exit 1 || : -.DELETE_ON_ERROR: $(gummboot_solib) - -$(gummiboot): $(gummiboot_solib) - $(AM_V_GEN) objcopy -j .text -j .sdata -j .data -j .dynamic \ - -j .dynsym -j .rel -j .rela -j .reloc \ - --target=efi-app-$(ARCH) $< $@ - -# ------------------------------------------------------------------------------ -stub_headers = \ - src/efi/util.h \ - src/efi/pefile.h \ - src/efi/linux.h - -stub_sources = \ - src/efi/util.c \ - src/efi/pefile.c \ - src/efi/linux.c \ - src/efi/stub.c - -stub_objects = $(addprefix $(top_builddir)/,$(stub_sources:.c=.o)) -stub_solib = $(top_builddir)/src/efi/stub.so -stub = linux$(MACHINE_TYPE_NAME).efi.stub - -gummibootlib_DATA += $(stub) -CLEANFILES += $(stub_objects) $(stub_solib) $(stub) -EXTRA_DIST += $(stub_sources) $(stub_headers) - -$(top_builddir)/src/efi/%.o: $(top_srcdir)/src/efi/%.c $(addprefix $(top_srcdir)/,$(stub_headers)) - @$(MKDIR_P) $(top_builddir)/src/efi/ - $(AM_V_CC)$(EFI_CC) $(efi_cppflags) $(efi_cflags) -c $< -o $@ - -$(stub_solib): $(stub_objects) - $(AM_V_CCLD)$(LD) $(efi_ldflags) $(stub_objects) \ - -o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \ - nm -D -u $@ | grep ' U ' && exit 1 || : -.DELETE_ON_ERROR: $(gummboot_solib) - -$(stub): $(stub_solib) - $(AM_V_GEN) objcopy -j .text -j .sdata -j .data -j .dynamic \ - -j .dynsym -j .rel -j .rela -j .reloc \ - --target=efi-app-$(ARCH) $< $@ - -# ------------------------------------------------------------------------------ -CLEANFILES += test-disk.img -EXTRA_DIST += test/test-create-disk.sh - -test-disk.img: gummiboot$(MACHINE_TYPE_NAME).efi test/test-create-disk.sh - $(AM_V_GEN)test/test-create-disk.sh - -qemu: test-disk.img - $(QEMU) -machine accel=kvm -m 1024 -bios $(QEMU_BIOS) -snapshot test-disk.img - -install-tree: all - rm -rf $(abs_srcdir)/install-tree - $(MAKE) install DESTDIR=$(abs_srcdir)/install-tree - tree $(abs_srcdir)/install-tree

deleted file mode 100644

index 09f835f..0000000

--- a/

+++ /dev/null diff --git a/README b/READMEdeleted file mode 100644index 09f835f..0000000--- a/ README +++ /dev/null @@ -1,26 +0,0 @@ -gummiboot Simple UEFI boot manager - -gummiboot executes EFI images. The default entry is selected by a configured -pattern (glob) or an on-screen menu. - -gummiboot operates on the EFI System Partition (ESP) only. Configuration -file fragments, kernels, initrds, other EFI images need to reside on the -ESP. Linux kernels must be built with CONFIG_EFI_STUB to be able to be -directly executed as an EFI image. - -gummiboot reads simple and entirely generic configurion files; one file -per boot entry to select from. - -Pressing Space (or most other) keys during bootup will show an on-screen -menu with all configured entries to select from. Pressing enter on the -selected entry loads and starts the EFI image. - -If no timeout is configured and no key pressed during bootup, the default -entry is booted right away. - -Further documentation is available in the gummiboot wiki at: - http://freedesktop.org/wiki/Software/gummiboot - -Links: - http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec - http://www.freedesktop.org/software/systemd/man/kernel-install.html

deleted file mode 100644

index e69de29..0000000

--- a/

+++ /dev/null diff --git a/TODO b/TODOdeleted file mode 100644index e69de29..0000000--- a/ TODO +++ /dev/null

deleted file mode 100755

index dfe9eba..0000000

--- a/

+++ /dev/null diff --git a/autogen.sh b/autogen.shdeleted file mode 100755index dfe9eba..0000000--- a/ autogen.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -# This file is part of gummiboot. -# -# gummiboot is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# gummiboot 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with systemd; If not, see <http://www.gnu.org/licenses/>. - -set -e - -autoreconf --force --install --symlink - -args="\ ---prefix=/usr" - -if [ "x$1" = "xc" ]; then - ./configure $args - make clean -else - echo - echo "----------------------------------------------------------------" - echo "Initialized build system. For a common configuration please run:" - echo "----------------------------------------------------------------" - echo - echo "./configure $args" - echo -fi

deleted file mode 100644

index 27bbe1d..0000000

--- a/

+++ /dev/null diff --git a/configure.ac b/configure.acdeleted file mode 100644index 27bbe1d..0000000--- a/ configure.ac +++ /dev/null @@ -1,155 +0,0 @@ -# -# This file is part of gummiboot. -# -# Copyright (C) 2013 Karel Zak <kzak@redhat.com> -# -# gummiboot is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# gummiboot 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with systemd; If not, see <http://www.gnu.org/licenses/>. - -AC_INIT([gummiboot], - [48], - [systemd-devel@lists.freedesktop.org], - [gummiboot], - [http://freedesktop.org/wiki/Software/gummiboot]) - -AC_CONFIG_SRCDIR([src/setup/setup.c]) -AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_AUX_DIR([build-aux]) -AC_PREFIX_DEFAULT([/usr]) - -AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax no-dist-gzip dist-xz subdir-objects]) -AM_SILENT_RULES([yes]) - -AC_CANONICAL_HOST -AC_SYS_LARGEFILE - -AC_PROG_CC - -dnl Don't try to use things like -std=c99 for efi compilation -EFI_CC=$CC -AC_SUBST([EFI_CC]) - -AC_PROG_CC_C99 -AM_PROG_CC_C_O -AC_PROG_GCC_TRADITIONAL - -AC_PROG_MKDIR_P -AC_PATH_PROG([XSLTPROC], [xsltproc]) - -dnl Define ARCH_<NAME> conditionals -SET_ARCH(IA32, i*86*) -SET_ARCH(X86_64, x86_64*) -SET_ARCH(IA64, ia64*) - -ARCH=`echo $host | sed "s/\(-\).*$//"` - -AM_COND_IF(ARCH_IA32, [ - ARCH=ia32 - MACHINE_TYPE_NAME=ia32]) - -AM_COND_IF(ARCH_X86_64, [ - MACHINE_TYPE_NAME=x64]) - -AC_SUBST([ARCH]) -AC_SUBST([MACHINE_TYPE_NAME]) - -# QEMU and OVMF UEFI firmware -AS_IF([test x"$cross_compiling" = "xyes"], [], [ - AC_PATH_PROG([QEMU], [qemu-system-x86_64]) - AC_CHECK_FILE([/usr/share/qemu/bios-ovmf.bin], [QEMU_BIOS=/usr/share/qemu/bios-ovmf.bin]) - AC_CHECK_FILE([/usr/share/qemu-ovmf/bios.bin], [QEMU_BIOS=/usr/share/qemu-ovmf/bios.bin]) - AC_SUBST([QEMU_BIOS]) -]) - -# ------------------------------------------------------------------------------ -dnl GNU EFI doesn't use relative paths: efi.h includes efibind.h which is in -dnl ${ARCH} relative to efi.h. I can't find a way to get AC_CHECK_HEADERS to -dnl add -I/usr/include/efi/${ARCH} to the conftest.c build. So, just test for -dnl efibind.h as the chances of efi.h not existing if it does are very low. -AC_CHECK_HEADER(efi/${ARCH}/efibind.h, [], - [AC_MSG_ERROR([*** GNU EFI header efibind.h not found])]) - -efiroot=$(echo $(cd /usr/lib/$(gcc -print-multi-os-directory); pwd)) -EFI_LIB_DIR="$efiroot" -AC_ARG_WITH(efi-libdir, - AS_HELP_STRING([--with-efi-libdir=PATH], [Path to efi lib directory]), - [EFI_LIB_DIR="$withval"], [EFI_LIB_DIR="$efiroot"] -) -AC_SUBST([EFI_LIB_DIR]) - -dnl extra objects and linker scripts -AC_ARG_WITH(efi-ldsdir, - AS_HELP_STRING([--with-efi-ldsdir=PATH], [Path to efi lds directory]), - [EFI_LDS_DIR="$withval"], - [ - for EFI_LDS_DIR in "${efiroot}/gnuefi" "${efiroot}"; do - for lds in ${EFI_LDS_DIR}/elf_${ARCH}_efi.lds; do - test -f ${lds} && break 2 - done - done - ] -) -AC_SUBST([EFI_LDS_DIR]) - -AC_ARG_WITH(efi-includedir, - AS_HELP_STRING([--with-efi-includedir=PATH], [Path to efi include directory]), - [EFI_INC_DIR="$withval"], [EFI_INC_DIR="/usr/include"] -) -AC_SUBST([EFI_INC_DIR]) - -# ------------------------------------------------------------------------------ -AC_ARG_ENABLE(blkid, AS_HELP_STRING([--disable-blkid], [disable blkid support])) -if test "x$enable_blkid" != "xno"; then - PKG_CHECK_MODULES(BLKID, [ blkid >= 2.20 ], - [AC_DEFINE(HAVE_BLKID, 1, [Define if blkid is available]) have_blkid=yes], have_blkid=no) - if test "x$have_blkid" = xno -a "x$enable_blkid" = xyes; then - AC_MSG_ERROR([*** blkid support requested but libraries not found]) - fi -fi -AM_CONDITIONAL(HAVE_BLKID, [test "$have_blkid" = "yes"]) - -# ------------------------------------------------------------------------------ -have_manpages=no -AC_ARG_ENABLE(manpages, AS_HELP_STRING([--disable-manpages], [disable manpages])) -AS_IF([test "x$enable_manpages" != xno], [ - AS_IF([test "x$enable_manpages" = xyes -a "x$XSLTPROC" = x], [ - AC_MSG_ERROR([*** Manpages requested but xsltproc not found]) - ]) - AS_IF([test "x$XSLTPROC" != x], [have_manpages=yes]) -]) -AM_CONDITIONAL(ENABLE_MANPAGES, [test "x$have_manpages" = "xyes"]) - -# ------------------------------------------------------------------------------ -AC_CONFIG_FILES([ - Makefile -]) - -AC_OUTPUT -AC_MSG_RESULT([ - $PACKAGE_NAME $VERSION - - prefix: ${prefix} - arch: $ARCH - EFI machine type: $MACHINE_TYPE_NAME - - EFI libdir: ${EFI_LIB_DIR} - EFI ldsdir: ${EFI_LDS_DIR} - EFI includedir: ${EFI_INC_DIR} - - blkid: ${have_blkid} - man pages: ${have_manpages} - - QEMU: ${QEMU} - QEMU OVMF: ${QEMU_BIOS} -])

new file mode 100644

index 0000000..dbf503b

--- /dev/null

+++ b/ diff --git a/dead.package b/dead.packagenew file mode 100644index 0000000..dbf503b--- /dev/null+++ b/ dead.package @@ -0,0 +1 @@ +obsoleted

deleted file mode 100644

index f17b427..0000000

--- a/

+++ /dev/null diff --git a/m4/arch.m4 b/m4/arch.m4deleted file mode 100644index f17b427..0000000--- a/ m4/arch.m4 +++ /dev/null @@ -1,13 +0,0 @@ - -dnl SET_ARCH(ARCHNAME, PATTERN) -dnl -dnl Define ARCH_<archname> condition if the pattern match with the current -dnl architecture -dnl -AC_DEFUN([SET_ARCH], [ - cpu_$1=false - case "$host" in - $2) cpu_$1=true ;; - esac - AM_CONDITIONAL(AS_TR_CPP(ARCH_$1), [test "x$cpu_$1" = xtrue]) -])

deleted file mode 100644

index 36552f8..0000000

--- a/

+++ /dev/null diff --git a/man/gummiboot.xml b/man/gummiboot.xmldeleted file mode 100644index 36552f8..0000000--- a/ man/gummiboot.xml +++ /dev/null @@ -1,137 +0,0 @@ -<?xml version='1.0'?> <!--*-nxml-*--> -<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" - "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> - -<!-- - Copyright 2013 Kay Sievers - - gummiboot is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. ---> - -<refentry id="gummiboot"> - <refentryinfo> - <title>gummiboot</title> - <productname>gummiboot</productname> - - <authorgroup> - <author> - <contrib>Developer</contrib> - <firstname>Kay</firstname> - <surname>Sievers</surname> - <email>kay@vrfy.org</email> - </author> - </authorgroup> - </refentryinfo> - - <refmeta> - <refentrytitle>gummiboot</refentrytitle> - <manvolnum>8</manvolnum> - </refmeta> - - <refnamediv> - <refname>gummiboot</refname> - <refpurpose>Setup and manage Gummiboot Boot Manager</refpurpose> - </refnamediv> - - <refsynopsisdiv> - <cmdsynopsis> - <command>gummiboot <arg choice="opt" rep="repeat">OPTIONS</arg>status</command> - </cmdsynopsis> - <cmdsynopsis> - <command>gummiboot <arg choice="opt" rep="repeat">OPTIONS</arg>update</command> - </cmdsynopsis> - <cmdsynopsis> - <command>gummiboot <arg choice="opt" rep="repeat">OPTIONS</arg>install</command> - </cmdsynopsis> - <cmdsynopsis> - <command>gummiboot <arg choice="opt" rep="repeat">OPTIONS</arg>remove</command> - </cmdsynopsis> - </refsynopsisdiv> - - <refsect1> - <title>Description</title> - - <para><command>gummiboot</command> checks, updates, - installs or removes the boot loader from the current - system.</para> - - <para><command>gummiboot status</command> checks and prints the - currently installed versions of the boot loader binaries and the - all current EFI boot variables.</para> - - <para><command>gummiboot update</command> updates all installed - versions of gummiboot, if the current version is newer than the - version installed in the EFI system partition. This also includes - the EFI default/fallback loader at /EFI/Boot/boot*.efi. An - gummiboot entry in the EFI boot variables is created, if there - is no current entry. A created entry will be added to the end of - the boot order list.</para> - - <para><command>gummiboot install</command> installs gummiboot into - the EFI system partition. A copy of gummiboot will be stored as - the EFI default/fallback loader at /EFI/Boot/boot*.efi. An gummiboot - entry in the EFI boot variables is created and added to the top - of the boot order list.</para> - - <para><command>gummiboot remove</command> removes all installed - versions of gummiboot from the EFI system partition, and removes - gummiboot from the EFI boot variables.</para> - - <para>If no command is passed <command>status</command> is - implied.</para> - </refsect1> - - <refsect1> - <title>Options</title> - <para>The following options are understood:</para> - - <variablelist> - <varlistentry> - <term><option>-h</option></term> - <term><option>--help</option></term> - - <listitem><para>Prints a short help - text and exits.</para></listitem> - </varlistentry> - - <varlistentry> - <term><option>--path</option></term> - <listitem><para>Path to the EFI system - partition. The default is /boot.</para></listitem> - </varlistentry> - - <varlistentry> - <term><option>--no-variables</option></term> - <listitem><para>Do not touch the EFI boot - variables.</para></listitem> - </varlistentry> - </variablelist> - </refsect1> - - <refsect1> - <title>Exit status</title> - <para>On success 0 is returned, a non-zero failure - code otherwise.</para> - </refsect1> - - <refsect1> - <title>See Also</title> - <para> - <ulink url="http://freedesktop.org/wiki/Software/gummiboot">Gummiboot wiki</ulink> - <ulink url="http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec">Boot loader specification</ulink> - <ulink url="http://www.freedesktop.org/wiki/Software/systemd/BootLoaderInterface">Systemd boot loader interface</ulink> - <citerefentry><refentrytitle>bootctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> - </para> - </refsect1> -</refentry>

deleted file mode 100644

index 6206c80..0000000

--- a/

+++ /dev/null diff --git a/src/efi/console.c b/src/efi/console.cdeleted file mode 100644index 6206c80..0000000--- a/ src/efi/console.c +++ /dev/null @@ -1,141 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -/* - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * Copyright (C) 2012-2013 Kay Sievers <kay@vrfy.org> - * Copyright (C) 2012 Harald Hoyer <harald@redhat.com> - */ - -#include <efi.h> -#include <efilib.h> - -#include "util.h" -#include "console.h" - -#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ - { 0xdd9e7534, 0x7762, 0x4698, { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } } - -struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL; - -typedef EFI_STATUS (EFIAPI *EFI_INPUT_RESET_EX)( - struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This; - BOOLEAN ExtendedVerification; -); - -typedef UINT8 EFI_KEY_TOGGLE_STATE; - -typedef struct { - UINT32 KeyShiftState; - EFI_KEY_TOGGLE_STATE KeyToggleState; -} EFI_KEY_STATE; - -typedef struct { - EFI_INPUT_KEY Key; - EFI_KEY_STATE KeyState; -} EFI_KEY_DATA; - -typedef EFI_STATUS (EFIAPI *EFI_INPUT_READ_KEY_EX)( - struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This; - EFI_KEY_DATA *KeyData; -); - -typedef EFI_STATUS (EFIAPI *EFI_SET_STATE)( - struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This; - EFI_KEY_TOGGLE_STATE *KeyToggleState; -); - -typedef EFI_STATUS (EFIAPI *EFI_KEY_NOTIFY_FUNCTION)( - EFI_KEY_DATA *KeyData; -); - -typedef EFI_STATUS (EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY)( - struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This; - EFI_KEY_DATA KeyData; - EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction; - VOID **NotifyHandle; -); - -typedef EFI_STATUS (EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY)( - struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This; - VOID *NotificationHandle; -); - -typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL { - EFI_INPUT_RESET_EX Reset; - EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx; - EFI_EVENT WaitForKeyEx; - EFI_SET_STATE SetState; - EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify; - EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify; -} EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL; - -EFI_STATUS console_key_read(UINT64 *key, BOOLEAN wait) { - EFI_GUID EfiSimpleTextInputExProtocolGuid = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; - static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInputEx; - static BOOLEAN checked; - UINTN index; - EFI_INPUT_KEY k; - EFI_STATUS err; - - if (!checked) { - err = LibLocateProtocol(&EfiSimpleTextInputExProtocolGuid, (VOID **)&TextInputEx); - if (EFI_ERROR(err)) - TextInputEx = NULL; - - checked = TRUE; - } - - /* wait until key is pressed */ - if (wait) { - if (TextInputEx) - uefi_call_wrapper(BS->WaitForEvent, 3, 1, &TextInputEx->WaitForKeyEx, &index); - else - uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &index); - } - - if (TextInputEx) { - EFI_KEY_DATA keydata; - UINT64 keypress; - - err = uefi_call_wrapper(TextInputEx->ReadKeyStrokeEx, 2, TextInputEx, &keydata); - if (!EFI_ERROR(err)) { - UINT32 shift = 0; - - /* do not distinguish between left and right keys */ - if (keydata.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) { - if (keydata.KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED|EFI_LEFT_CONTROL_PRESSED)) - shift |= EFI_CONTROL_PRESSED; - if (keydata.KeyState.KeyShiftState & (EFI_RIGHT_ALT_PRESSED|EFI_LEFT_ALT_PRESSED)) - shift |= EFI_ALT_PRESSED; - }; - - /* 32 bit modifier keys + 16 bit scan code + 16 bit unicode */ - keypress = KEYPRESS(shift, keydata.Key.ScanCode, keydata.Key.UnicodeChar); - if (keypress > 0) { - *key = keypress; - return 0; - } - } - } - - /* fallback for firmware which does not support SimpleTextInputExProtocol - * - * This is also called in case ReadKeyStrokeEx did not return a key, because - * some broken firmwares offer SimpleTextInputExProtocol, but never acually - * handle any key. */ - err = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &k); - if (EFI_ERROR(err)) - return err; - - *key = KEYPRESS(0, k.ScanCode, k.UnicodeChar); - return 0; -}

deleted file mode 100644

index 8c2a31a..0000000

--- a/

+++ /dev/null diff --git a/src/efi/console.h b/src/efi/console.hdeleted file mode 100644index 8c2a31a..0000000--- a/ src/efi/console.h +++ /dev/null @@ -1,34 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -/* - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * Copyright (C) 2012-2013 Kay Sievers <kay@vrfy.org> - * Copyright (C) 2012 Harald Hoyer <harald@redhat.com> - */ - -#ifndef __GUMMIBOOT_CONSOLE_H -#define __GUMMIBOOT_CONSOLE_H - -#define EFI_SHIFT_STATE_VALID 0x80000000 -#define EFI_RIGHT_CONTROL_PRESSED 0x00000004 -#define EFI_LEFT_CONTROL_PRESSED 0x00000008 -#define EFI_RIGHT_ALT_PRESSED 0x00000010 -#define EFI_LEFT_ALT_PRESSED 0x00000020 - -#define EFI_CONTROL_PRESSED (EFI_RIGHT_CONTROL_PRESSED|EFI_LEFT_CONTROL_PRESSED) -#define EFI_ALT_PRESSED (EFI_RIGHT_ALT_PRESSED|EFI_LEFT_ALT_PRESSED) -#define KEYPRESS(keys, scan, uni) ((((UINT64)keys) << 32) | ((scan) << 16) | (uni)) -#define KEYCHAR(k) ((k) & 0xffff) -#define CHAR_CTRL(c) ((c) - 'a' + 1) - -EFI_STATUS console_key_read(UINT64 *key, BOOLEAN wait); -#endif

deleted file mode 100644

index 11305b8..0000000

--- a/

+++ /dev/null diff --git a/src/efi/graphics.c b/src/efi/graphics.cdeleted file mode 100644index 11305b8..0000000--- a/ src/efi/graphics.c +++ /dev/null @@ -1,389 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -/* - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * Copyright (C) 2012-2013 Kay Sievers <kay@vrfy.org> - * Copyright (C) 2012 Harald Hoyer <harald@redhat.com> - * Copyright (C) 2013 Intel Corporation - * Authored by Joonas Lahtinen <joonas.lahtinen@linux.intel.com> - */ - -#include <efi.h> -#include <efilib.h> - -#include "util.h" -#include "graphics.h" - -EFI_STATUS graphics_mode(BOOLEAN on) { - #define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \ - { 0xf42f7782, 0x12e, 0x4c12, { 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21 } }; - - struct _EFI_CONSOLE_CONTROL_PROTOCOL; - - typedef enum { - EfiConsoleControlScreenText, - EfiConsoleControlScreenGraphics, - EfiConsoleControlScreenMaxValue, - } EFI_CONSOLE_CONTROL_SCREEN_MODE; - - typedef EFI_STATUS (EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE)( - struct _EFI_CONSOLE_CONTROL_PROTOCOL *This, - EFI_CONSOLE_CONTROL_SCREEN_MODE *Mode, - BOOLEAN *UgaExists, - BOOLEAN *StdInLocked - ); - - typedef EFI_STATUS (EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE)( - struct _EFI_CONSOLE_CONTROL_PROTOCOL *This, - EFI_CONSOLE_CONTROL_SCREEN_MODE Mode - ); - - typedef EFI_STATUS (EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN)( - struct _EFI_CONSOLE_CONTROL_PROTOCOL *This, - CHAR16 *Password - ); - - typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL { - EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE GetMode; - EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE SetMode; - EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN LockStdIn; - } EFI_CONSOLE_CONTROL_PROTOCOL; - - EFI_GUID ConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID; - EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL; - EFI_CONSOLE_CONTROL_SCREEN_MODE new; - EFI_CONSOLE_CONTROL_SCREEN_MODE current; - BOOLEAN uga_exists; - BOOLEAN stdin_locked; - EFI_STATUS err; - - err = LibLocateProtocol(&ConsoleControlProtocolGuid, (VOID **)&ConsoleControl); - if (EFI_ERROR(err)) { - /* console control protocol is nonstandard and might not exist. */ - return err == EFI_NOT_FOUND ? EFI_SUCCESS : err; - } - - /* check current mode */ - err = uefi_call_wrapper(ConsoleControl->GetMode, 4, ConsoleControl, ¤t, &uga_exists, &stdin_locked); - if (EFI_ERROR(err)) - return err; - - /* do not touch the mode */ - new = on ? EfiConsoleControlScreenGraphics : EfiConsoleControlScreenText; - if (new == current) - return EFI_SUCCESS; - - err = uefi_call_wrapper(ConsoleControl->SetMode, 2, ConsoleControl, new); - - /* some firmware enables the cursor when switching modes */ - uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, FALSE); - - return err; -} - -struct bmp_file { - CHAR8 signature[2]; - UINT32 size; - UINT16 reserved[2]; - UINT32 offset; -} __attribute__((packed)); - -/* we require at least BITMAPINFOHEADER, later versions are - accepted, but their features ignored */ -struct bmp_dib { - UINT32 size; - UINT32 x; - UINT32 y; - UINT16 planes; - UINT16 depth; - UINT32 compression; - UINT32 image_size; - INT32 x_pixel_meter; - INT32 y_pixel_meter; - UINT32 colors_used; - UINT32 colors_important; -} __attribute__((packed)); - -struct bmp_map { - UINT8 blue; - UINT8 green; - UINT8 red; - UINT8 reserved; -} __attribute__((packed)); - -EFI_STATUS bmp_parse_header(UINT8 *bmp, UINTN size, struct bmp_dib **ret_dib, - struct bmp_map **ret_map, UINT8 **pixmap) { - struct bmp_file *file; - struct bmp_dib *dib; - struct bmp_map *map; - UINTN row_size; - - if (size < sizeof(struct bmp_file) + sizeof(struct bmp_dib)) - return EFI_INVALID_PARAMETER; - - /* check file header */ - file = (struct bmp_file *)bmp; - if (file->signature[0] != 'B' || file->signature[1] != 'M') - return EFI_INVALID_PARAMETER; - if (file->size != size) - return EFI_INVALID_PARAMETER; - if (file->size < file->offset) - return EFI_INVALID_PARAMETER; - - /* check device-independent bitmap */ - dib = (struct bmp_dib *)(bmp + sizeof(struct bmp_file)); - if (dib->size < sizeof(struct bmp_dib)) - return EFI_UNSUPPORTED; - - switch (dib->depth) { - case 1: - case 4: - case 8: - case 24: - if (dib->compression != 0) - return EFI_UNSUPPORTED; - - break; - - case 16: - case 32: - if (dib->compression != 0 && dib->compression != 3) - return EFI_UNSUPPORTED; - - break; - - default: - return EFI_UNSUPPORTED; - } - - row_size = (((dib->depth * dib->x) + 31) / 32) * 4; - if (file->size - file->offset < dib->y * row_size) - return EFI_INVALID_PARAMETER; - if (row_size * dib->y > 64 * 1024 * 1024) - return EFI_INVALID_PARAMETER; - - /* check color table */ - map = (struct bmp_map *)(bmp + sizeof(struct bmp_file) + dib->size); - if (file->offset < sizeof(struct bmp_file) + dib->size) - return EFI_INVALID_PARAMETER; - - if (file->offset > sizeof(struct bmp_file) + dib->size) { - UINT32 map_count; - UINTN map_size; - - if (dib->colors_used) - map_count = dib->colors_used; - else { - switch (dib->depth) { - case 1: - case 4: - case 8: - map_count = 1 << dib->depth; - break; - - default: - map_count = 0; - break; - } - } - - map_size = file->offset - (sizeof(struct bmp_file) + dib->size); - if (map_size != sizeof(struct bmp_map) * map_count) - return EFI_INVALID_PARAMETER; - } - - *ret_map = map; - *ret_dib = dib; - *pixmap = bmp + file->offset; - - return EFI_SUCCESS; -} - -static VOID pixel_blend(UINT32 *dst, const UINT32 source) { - UINT32 alpha, src, src_rb, src_g, dst_rb, dst_g, rb, g; - - alpha = (source & 0xff); - - /* convert src from RGBA to XRGB */ - src = source >> 8; - - /* decompose into RB and G components */ - src_rb = (src & 0xff00ff); - src_g = (src & 0x00ff00); - - dst_rb = (*dst & 0xff00ff); - dst_g = (*dst & 0x00ff00); - - /* blend */ - rb = ((((src_rb - dst_rb) * alpha + 0x800080) >> 8) + dst_rb) & 0xff00ff; - g = ((((src_g - dst_g) * alpha + 0x008000) >> 8) + dst_g) & 0x00ff00; - - *dst = (rb | g); -} - -EFI_STATUS bmp_to_blt(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf, - struct bmp_dib *dib, struct bmp_map *map, - UINT8 *pixmap) { - UINT8 *in; - UINTN y; - - /* transform and copy pixels */ - in = pixmap; - for (y = 0; y < dib->y; y++) { - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *out; - UINTN row_size; - UINTN x; - - out = &buf[(dib->y - y - 1) * dib->x]; - for (x = 0; x < dib->x; x++, in++, out++) { - switch (dib->depth) { - case 1: { - UINTN i; - - for (i = 0; i < 8 && x < dib->x; i++) { - out->Red = map[((*in) >> (7 - i)) & 1].red; - out->Green = map[((*in) >> (7 - i)) & 1].green; - out->Blue = map[((*in) >> (7 - i)) & 1].blue; - out++; - x++; - } - out--; - x--; - break; - } - - case 4: { - UINTN i; - - i = (*in) >> 4; - out->Red = map[i].red; - out->Green = map[i].green; - out->Blue = map[i].blue; - if (x < (dib->x - 1)) { - out++; - x++; - i = (*in) & 0x0f; - out->Red = map[i].red; - out->Green = map[i].green; - out->Blue = map[i].blue; - } - break; - } - - case 8: - out->Red = map[*in].red; - out->Green = map[*in].green; - out->Blue = map[*in].blue; - break; - - case 16: { - UINT16 i = *(UINT16 *) in; - - out->Red = (i & 0x7c00) >> 7; - out->Green = (i & 0x3e0) >> 2; - out->Blue = (i & 0x1f) << 3; - in += 1; - break; - } - - case 24: - out->Red = in[2]; - out->Green = in[1]; - out->Blue = in[0]; - in += 2; - break; - - case 32: { - UINT32 i = *(UINT32 *) in; - - pixel_blend((UINT32 *)out, i); - - in += 3; - break; - } - } - } - - /* add row padding; new lines always start at 32 bit boundary */ - row_size = in - pixmap; - in += ((row_size + 3) & ~3) - row_size; - } - - return EFI_SUCCESS; -} - -EFI_STATUS graphics_splash(EFI_FILE *root_dir, CHAR16 *path, - const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background) { - EFI_GUID GraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput = NULL; - UINT8 *content; - INTN len; - struct bmp_dib *dib; - struct bmp_map *map; - UINT8 *pixmap; - UINT64 blt_size; - VOID *blt = NULL; - UINTN x_pos = 0; - UINTN y_pos = 0; - EFI_STATUS err; - - err = LibLocateProtocol(&GraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput); - if (EFI_ERROR(err)) - return err; - - len = file_read(root_dir, path, 0, 0, &content); - if (len < 0) - return EFI_LOAD_ERROR; - - err = bmp_parse_header(content, len, &dib, &map, &pixmap); - if (EFI_ERROR(err)) - goto err; - - if(dib->x < GraphicsOutput->Mode->Info->HorizontalResolution) - x_pos = (GraphicsOutput->Mode->Info->HorizontalResolution - dib->x) / 2; - if(dib->y < GraphicsOutput->Mode->Info->VerticalResolution) - y_pos = (GraphicsOutput->Mode->Info->VerticalResolution - dib->y) / 2; - - uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput, - (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)background, - EfiBltVideoFill, 0, 0, 0, 0, - GraphicsOutput->Mode->Info->HorizontalResolution, - GraphicsOutput->Mode->Info->VerticalResolution, 0); - - /* EFI buffer */ - blt_size = dib->x * dib->y * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL); - blt = AllocatePool(blt_size); - if (!blt) - return EFI_OUT_OF_RESOURCES; - - err = uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput, - blt, EfiBltVideoToBltBuffer, x_pos, y_pos, 0, 0, - dib->x, dib->y, 0); - if (EFI_ERROR(err)) - goto err; - - err = bmp_to_blt(blt, dib, map, pixmap); - if (EFI_ERROR(err)) - goto err; - - err = graphics_mode(TRUE); - if (EFI_ERROR(err)) - goto err; - - err = uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput, - blt, EfiBltBufferToVideo, 0, 0, x_pos, y_pos, - dib->x, dib->y, 0); -err: - FreePool(blt); - FreePool(content); - return err; -}

deleted file mode 100644

index edec1f4..0000000

--- a/

+++ /dev/null diff --git a/src/efi/graphics.h b/src/efi/graphics.hdeleted file mode 100644index edec1f4..0000000--- a/ src/efi/graphics.h +++ /dev/null @@ -1,26 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -/* - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * Copyright (C) 2012-2013 Kay Sievers <kay@vrfy.org> - * Copyright (C) 2012 Harald Hoyer <harald@redhat.com> - * Copyright (C) 2013 Intel Corporation - * Authored by Joonas Lahtinen <joonas.lahtinen@linux.intel.com> - */ - -#ifndef __GUMMIBOOT_GRAPHICS_H -#define __GUMMIBOOT_GRAPHICS_H - -EFI_STATUS graphics_mode(BOOLEAN on); -EFI_STATUS graphics_splash(EFI_FILE *root_dir, CHAR16 *path, - const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background); -#endif

deleted file mode 100644

index be5765c..0000000

--- a/

+++ /dev/null diff --git a/src/efi/gummiboot.c b/src/efi/gummiboot.cdeleted file mode 100644index be5765c..0000000--- a/ src/efi/gummiboot.c +++ /dev/null @@ -1,2047 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -/* - * Simple UEFI boot loader which executes configured EFI images, where the - * default entry is selected by a configured pattern (glob) or an on-screen - * menu. - * - * All gummiboot code is LGPL not GPL, to stay out of politics and to give - * the freedom of copying code from programs to possible future libraries. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * Copyright (C) 2012-2013 Kay Sievers <kay@vrfy.org> - * Copyright (C) 2012 Harald Hoyer <harald@redhat.com> - * - * "Any intelligent fool can make things bigger, more complex, and more violent." - * -- Albert Einstein - */ - -#include <efi.h> -#include <efilib.h> - -#include "util.h" -#include "console.h" -#include "graphics.h" -#include "pefile.h" -#include "linux.h" - -#ifndef EFI_OS_INDICATIONS_BOOT_TO_FW_UI -#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001ULL -#endif - -#ifndef EFI_SECURITY_VIOLATION -#define EFI_SECURITY_VIOLATION EFIERR(26) -#endif - -/* magic string to find in the binary image */ -static const char __attribute__((used)) magic[] = "#### LoaderInfo: gummiboot " VERSION " ####"; - -static const EFI_GUID global_guid = EFI_GLOBAL_VARIABLE; - -enum loader_type { - LOADER_UNDEFINED, - LOADER_EFI, - LOADER_LINUX -}; - -typedef struct { - CHAR16 *file; - CHAR16 *title_show; - CHAR16 *title; - CHAR16 *version; - CHAR16 *machine_id; - EFI_HANDLE *device; - enum loader_type type; - CHAR16 *loader; - CHAR16 *options; - CHAR16 *splash; - CHAR16 key; - EFI_STATUS (*call)(VOID); - BOOLEAN no_autoselect; - BOOLEAN non_unique; -} ConfigEntry; - -typedef struct { - ConfigEntry **entries; - UINTN entry_count; - INTN idx_default; - INTN idx_default_efivar; - UINTN timeout_sec; - UINTN timeout_sec_config; - INTN timeout_sec_efivar; - CHAR16 *entry_default_pattern; - CHAR16 *splash; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background; - CHAR16 *entry_oneshot; - CHAR16 *options_edit; - CHAR16 *entries_auto; - BOOLEAN no_editor; -} Config; - -static VOID cursor_left(UINTN *cursor, UINTN *first) -{ - if ((*cursor) > 0) - (*cursor)--; - else if ((*first) > 0) - (*first)--; -} - -static VOID cursor_right(UINTN *cursor, UINTN *first, UINTN x_max, UINTN len) -{ - if ((*cursor)+1 < x_max) - (*cursor)++; - else if ((*first) + (*cursor) < len) - (*first)++; -} - -static BOOLEAN line_edit(CHAR16 *line_in, CHAR16 **line_out, UINTN x_max, UINTN y_pos) { - CHAR16 *line; - UINTN size; - UINTN len; - UINTN first; - CHAR16 *print; - UINTN cursor; - UINTN clear; - BOOLEAN exit; - BOOLEAN enter; - - if (!line_in) - line_in = L""; - size = StrLen(line_in) + 1024; - line = AllocatePool(size * sizeof(CHAR16)); - StrCpy(line, line_in); - len = StrLen(line); - print = AllocatePool((x_max+1) * sizeof(CHAR16)); - - uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, TRUE); - - first = 0; - cursor = 0; - clear = 0; - enter = FALSE; - exit = FALSE; - while (!exit) { - EFI_STATUS err; - UINT64 key; - UINTN i; - - i = len - first; - if (i >= x_max-1) - i = x_max-1; - CopyMem(print, line + first, i * sizeof(CHAR16)); - while (clear > 0 && i < x_max-1) { - clear--; - print[i++] = ' '; - } - print[i] = '\0'; - - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_pos); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, print); - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, cursor, y_pos); - - err = console_key_read(&key, TRUE); - if (EFI_ERROR(err)) - continue; - - switch (key) { - case KEYPRESS(0, SCAN_ESC, 0): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'c'): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'g'): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('c')): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('g')): - exit = TRUE; - break; - - case KEYPRESS(0, SCAN_HOME, 0): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'a'): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('a')): - /* beginning-of-line */ - cursor = 0; - first = 0; - continue; - - case KEYPRESS(0, SCAN_END, 0): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'e'): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('e')): - /* end-of-line */ - cursor = len - first; - if (cursor+1 >= x_max) { - cursor = x_max-1; - first = len - (x_max-1); - } - continue; - - case KEYPRESS(0, SCAN_DOWN, 0): - case KEYPRESS(EFI_ALT_PRESSED, 0, 'f'): - case KEYPRESS(EFI_CONTROL_PRESSED, SCAN_RIGHT, 0): - /* forward-word */ - while (line[first + cursor] && line[first + cursor] == ' ') - cursor_right(&cursor, &first, x_max, len); - while (line[first + cursor] && line[first + cursor] != ' ') - cursor_right(&cursor, &first, x_max, len); - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, cursor, y_pos); - continue; - - case KEYPRESS(0, SCAN_UP, 0): - case KEYPRESS(EFI_ALT_PRESSED, 0, 'b'): - case KEYPRESS(EFI_CONTROL_PRESSED, SCAN_LEFT, 0): - /* backward-word */ - if ((first + cursor) > 0 && line[first + cursor-1] == ' ') { - cursor_left(&cursor, &first); - while ((first + cursor) > 0 && line[first + cursor] == ' ') - cursor_left(&cursor, &first); - } - while ((first + cursor) > 0 && line[first + cursor-1] != ' ') - cursor_left(&cursor, &first); - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, cursor, y_pos); - continue; - - case KEYPRESS(0, SCAN_RIGHT, 0): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'f'): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('f')): - /* forward-char */ - if (first + cursor == len) - continue; - cursor_right(&cursor, &first, x_max, len); - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, cursor, y_pos); - continue; - - case KEYPRESS(0, SCAN_LEFT, 0): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'b'): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('b')): - /* backward-char */ - cursor_left(&cursor, &first); - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, cursor, y_pos); - continue; - - case KEYPRESS(EFI_ALT_PRESSED, 0, 'd'): - /* kill-word */ - clear = 0; - for (i = first + cursor; i < len && line[i] == ' '; i++) - clear++; - for (; i < len && line[i] != ' '; i++) - clear++; - - for (i = first + cursor; i + clear < len; i++) - line[i] = line[i + clear]; - len -= clear; - line[len] = '\0'; - continue; - - case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'w'): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('w')): - case KEYPRESS(EFI_ALT_PRESSED, 0, CHAR_BACKSPACE): - /* backward-kill-word */ - clear = 0; - if ((first + cursor) > 0 && line[first + cursor-1] == ' ') { - cursor_left(&cursor, &first); - clear++; - while ((first + cursor) > 0 && line[first + cursor] == ' ') { - cursor_left(&cursor, &first); - clear++; - } - } - while ((first + cursor) > 0 && line[first + cursor-1] != ' ') { - cursor_left(&cursor, &first); - clear++; - } - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, cursor, y_pos); - - for (i = first + cursor; i + clear < len; i++) - line[i] = line[i + clear]; - len -= clear; - line[len] = '\0'; - continue; - - case KEYPRESS(0, SCAN_DELETE, 0): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'd'): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('d')): - if (len == 0) - continue; - if (first + cursor == len) - continue; - for (i = first + cursor; i < len; i++) - line[i] = line[i+1]; - clear = 1; - len--; - continue; - - case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'k'): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('k')): - /* kill-line */ - line[first + cursor] = '\0'; - clear = len - (first + cursor); - len = first + cursor; - continue; - - case KEYPRESS(0, 0, CHAR_LINEFEED): - case KEYPRESS(0, 0, CHAR_CARRIAGE_RETURN): - if (StrCmp(line, line_in) != 0) { - *line_out = line; - line = NULL; - } - enter = TRUE; - exit = TRUE; - break; - - case KEYPRESS(0, 0, CHAR_BACKSPACE): - if (len == 0) - continue; - if (first == 0 && cursor == 0) - continue; - for (i = first + cursor-1; i < len; i++) - line[i] = line[i+1]; - clear = 1; - len--; - if (cursor > 0) - cursor--; - if (cursor > 0 || first == 0) - continue; - /* show full line if it fits */ - if (len < x_max) { - cursor = first; - first = 0; - continue; - } - /* jump left to see what we delete */ - if (first > 10) { - first -= 10; - cursor = 10; - } else { - cursor = first; - first = 0; - } - continue; - - case KEYPRESS(0, 0, ' ') ... KEYPRESS(0, 0, '~'): - case KEYPRESS(0, 0, 0x80) ... KEYPRESS(0, 0, 0xffff): - if (len+1 == size) - continue; - for (i = len; i > first + cursor; i--) - line[i] = line[i-1]; - line[first + cursor] = KEYCHAR(key); - len++; - line[len] = '\0'; - if (cursor+1 < x_max) - cursor++; - else if (first + cursor < len) - first++; - continue; - } - } - - uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, FALSE); - FreePool(print); - FreePool(line); - return enter; -} - -static UINTN entry_lookup_key(Config *config, UINTN start, CHAR16 key) { - UINTN i; - - if (key == 0) - return -1; - - /* select entry by number key */ - if (key >= '1' && key <= '9') { - i = key - '0'; - if (i > config->entry_count) - i = config->entry_count; - return i-1; - } - - /* find matching key in config entries */ - for (i = start; i < config->entry_count; i++) - if (config->entries[i]->key == key) - return i; - - for (i = 0; i < start; i++) - if (config->entries[i]->key == key) - return i; - - return -1; -} - -static VOID print_status(Config *config, EFI_FILE *root_dir, CHAR16 *loaded_image_path) { - UINT64 key; - UINTN i; - CHAR16 *s; - CHAR8 *b; - UINTN x; - UINTN y; - UINTN size; - EFI_STATUS err; - UINTN color = 0; - const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *pixel = config->background; - - uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK); - uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); - - /* show splash and wait for key */ - for (;;) { - static const EFI_GRAPHICS_OUTPUT_BLT_PIXEL colors[] = { - { .Red = 0xff, .Green = 0xff, .Blue = 0xff }, - { .Red = 0xc0, .Green = 0xc0, .Blue = 0xc0 }, - { .Red = 0xff, .Green = 0, .Blue = 0 }, - { .Red = 0, .Green = 0xff, .Blue = 0 }, - { .Red = 0, .Green = 0, .Blue = 0xff }, - { .Red = 0, .Green = 0, .Blue = 0 }, - }; - - err = EFI_NOT_FOUND; - if (config->splash) - err = graphics_splash(root_dir, config->splash, pixel); - if (EFI_ERROR(err)) - err = graphics_splash(root_dir, L"\\EFI\\gummiboot\\splash.bmp", pixel); - if (EFI_ERROR(err)) - break; - - /* 'b' rotates through background colors */ - console_key_read(&key, TRUE); - if (key == KEYPRESS(0, 0, 'b')) { - pixel = &colors[color++]; - if (color == ELEMENTSOF(colors)) - color = 0; - - continue; - } - - graphics_mode(FALSE); - uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); - break; - } - - Print(L"gummiboot version: " VERSION "

"); - Print(L"gummiboot architecture: " MACHINE_TYPE_NAME "

"); - Print(L"loaded image: %s

", loaded_image_path); - Print(L"UEFI specification: %d.%02d

", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff); - Print(L"firmware vendor: %s

", ST->FirmwareVendor); - Print(L"firmware version: %d.%02d

", ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff); - - if (uefi_call_wrapper(ST->ConOut->QueryMode, 4, ST->ConOut, ST->ConOut->Mode->Mode, &x, &y) == EFI_SUCCESS) - Print(L"console size: %d x %d

", x, y); - - if (efivar_get_raw(&global_guid, L"SecureBoot", &b, &size) == EFI_SUCCESS) { - Print(L"SecureBoot: %s

", yes_no(*b > 0)); - FreePool(b); - } - - if (efivar_get_raw(&global_guid, L"SetupMode", &b, &size) == EFI_SUCCESS) { - Print(L"SetupMode: %s

", *b > 0 ? L"setup" : L"user"); - FreePool(b); - } - - if (efivar_get_raw(&global_guid, L"OsIndicationsSupported", &b, &size) == EFI_SUCCESS) { - Print(L"OsIndicationsSupported: %d

", (UINT64)*b); - FreePool(b); - } - Print(L"

"); - - Print(L"timeout: %d

", config->timeout_sec); - if (config->timeout_sec_efivar >= 0) - Print(L"timeout (EFI var): %d

", config->timeout_sec_efivar); - Print(L"timeout (config): %d

", config->timeout_sec_config); - if (config->entry_default_pattern) - Print(L"default pattern: '%s'

", config->entry_default_pattern); - if (config->splash) - Print(L"splash '%s'

", config->splash); - if (config->background) - Print(L"background '#%02x%02x%02x'

", - config->background->Red, - config->background->Green, - config->background->Blue); - Print(L"editor: %s

", yes_no(!config->no_editor)); - Print(L"

"); - - Print(L"config entry count: %d

", config->entry_count); - Print(L"entry selected idx: %d

", config->idx_default); - if (config->idx_default_efivar >= 0) - Print(L"entry EFI var idx: %d

", config->idx_default_efivar); - Print(L"

"); - - if (efivar_get_int(L"LoaderConfigTimeout", &i) == EFI_SUCCESS) - Print(L"LoaderConfigTimeout: %d

", i); - if (config->entry_oneshot) - Print(L"LoaderEntryOneShot: %s

", config->entry_oneshot); - if (efivar_get(L"LoaderDeviceIdentifier", &s) == EFI_SUCCESS) { - Print(L"LoaderDeviceIdentifier: %s

", s); - FreePool(s); - } - if (efivar_get(L"LoaderDevicePartUUID", &s) == EFI_SUCCESS) { - Print(L"LoaderDevicePartUUID: %s

", s); - FreePool(s); - } - if (efivar_get(L"LoaderEntryDefault", &s) == EFI_SUCCESS) { - Print(L"LoaderEntryDefault: %s

", s); - FreePool(s); - } - - Print(L"

--- press key ---



"); - console_key_read(&key, TRUE); - - for (i = 0; i < config->entry_count; i++) { - ConfigEntry *entry; - - if (key == KEYPRESS(0, SCAN_ESC, 0) || key == KEYPRESS(0, 0, 'q')) - break; - - entry = config->entries[i]; - - if (entry->splash) { - err = graphics_splash(root_dir, entry->splash, config->background); - if (!EFI_ERROR(err)) { - console_key_read(&key, TRUE); - graphics_mode(FALSE); - } - } - - Print(L"config entry: %d/%d

", i+1, config->entry_count); - if (entry->file) - Print(L"file '%s'

", entry->file); - Print(L"title show '%s'

", entry->title_show); - if (entry->title) - Print(L"title '%s'

", entry->title); - if (entry->version) - Print(L"version '%s'

", entry->version); - if (entry->machine_id) - Print(L"machine-id '%s'

", entry->machine_id); - if (entry->device) { - EFI_DEVICE_PATH *device_path; - CHAR16 *str; - - device_path = DevicePathFromHandle(entry->device); - if (device_path) { - str = DevicePathToStr(device_path); - Print(L"device handle '%s'

", str); - FreePool(str); - } - } - if (entry->loader) - Print(L"loader '%s'

", entry->loader); - if (entry->options) - Print(L"options '%s'

", entry->options); - if (entry->splash) - Print(L"splash '%s'

", entry->splash); - Print(L"auto-select %s

", yes_no(!entry->no_autoselect)); - if (entry->call) - Print(L"internal call yes

"); - - Print(L"

--- press key ---



"); - console_key_read(&key, TRUE); - } - - uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); -} - -static BOOLEAN menu_run(Config *config, ConfigEntry **chosen_entry, EFI_FILE *root_dir, CHAR16 *loaded_image_path) { - EFI_STATUS err; - UINTN visible_max; - UINTN idx_highlight; - UINTN idx_highlight_prev; - UINTN idx_first; - UINTN idx_last; - BOOLEAN refresh; - BOOLEAN highlight; - UINTN i; - UINTN line_width; - CHAR16 **lines; - UINTN x_start; - UINTN y_start; - UINTN x_max; - UINTN y_max; - CHAR16 *status; - CHAR16 *clearline; - INTN timeout_remain; - INT16 idx; - BOOLEAN exit = FALSE; - BOOLEAN run = TRUE; - BOOLEAN wait = FALSE; - - graphics_mode(FALSE); - uefi_call_wrapper(ST->ConIn->Reset, 2, ST->ConIn, FALSE); - uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, FALSE); - uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK); - - /* draw a single character to make ClearScreen work on some firmware */ - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L" "); - uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); - - err = uefi_call_wrapper(ST->ConOut->QueryMode, 4, ST->ConOut, ST->ConOut->Mode->Mode, &x_max, &y_max); - if (EFI_ERROR(err)) { - x_max = 80; - y_max = 25; - } - - /* we check 10 times per second for a keystroke */ - if (config->timeout_sec > 0) - timeout_remain = config->timeout_sec * 10; - else - timeout_remain = -1; - - idx_highlight = config->idx_default; - idx_highlight_prev = 0; - - visible_max = y_max - 2; - - if ((UINTN)config->idx_default >= visible_max) - idx_first = config->idx_default-1; - else - idx_first = 0; - - idx_last = idx_first + visible_max-1; - - refresh = TRUE; - highlight = FALSE; - - /* length of the longest entry */ - line_width = 5; - for (i = 0; i < config->entry_count; i++) { - UINTN entry_len; - - entry_len = StrLen(config->entries[i]->title_show); - if (line_width < entry_len) - line_width = entry_len; - } - if (line_width > x_max-6) - line_width = x_max-6; - - /* offsets to center the entries on the screen */ - x_start = (x_max - (line_width)) / 2; - if (config->entry_count < visible_max) - y_start = ((visible_max - config->entry_count) / 2) + 1; - else - y_start = 0; - - /* menu entries title lines */ - lines = AllocatePool(sizeof(CHAR16 *) * config->entry_count); - for (i = 0; i < config->entry_count; i++) { - UINTN j, k; - - lines[i] = AllocatePool(((x_max+1) * sizeof(CHAR16))); - for (j = 0; j < x_start; j++) - lines[i][j] = ' '; - - for (k = 0; config->entries[i]->title_show[k] != '\0' && j < x_max; j++, k++) - lines[i][j] = config->entries[i]->title_show[k]; - - for (; j < x_max; j++) - lines[i][j] = ' '; - lines[i][x_max] = '\0'; - } - - status = NULL; - clearline = AllocatePool((x_max+1) * sizeof(CHAR16)); - for (i = 0; i < x_max; i++) - clearline[i] = ' '; - clearline[i] = 0; - - while (!exit) { - UINT64 key; - - if (refresh) { - for (i = 0; i < config->entry_count; i++) { - if (i < idx_first || i > idx_last) - continue; - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_start + i - idx_first); - if (i == idx_highlight) - uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, - EFI_BLACK|EFI_BACKGROUND_LIGHTGRAY); - else - uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, - EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[i]); - if ((INTN)i == config->idx_default_efivar) { - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, x_start-3, y_start + i - idx_first); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"=>"); - } - } - refresh = FALSE; - } else if (highlight) { - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_start + idx_highlight_prev - idx_first); - uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[idx_highlight_prev]); - if ((INTN)idx_highlight_prev == config->idx_default_efivar) { - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, x_start-3, y_start + idx_highlight_prev - idx_first); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"=>"); - } - - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_start + idx_highlight - idx_first); - uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_BLACK|EFI_BACKGROUND_LIGHTGRAY); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[idx_highlight]); - if ((INTN)idx_highlight == config->idx_default_efivar) { - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, x_start-3, y_start + idx_highlight - idx_first); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"=>"); - } - highlight = FALSE; - } - - if (timeout_remain > 0) { - FreePool(status); - status = PoolPrint(L"Boot in %d sec.", (timeout_remain + 5) / 10); - } - - /* print status at last line of screen */ - if (status) { - UINTN len; - UINTN x; - - /* center line */ - len = StrLen(status); - if (len < x_max) - x = (x_max - len) / 2; - else - x = 0; - uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK); - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_max-1); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, clearline + (x_max - x)); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, status); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, clearline+1 + x + len); - } - - err = console_key_read(&key, wait); - if (EFI_ERROR(err)) { - /* timeout reached */ - if (timeout_remain == 0) { - exit = TRUE; - break; - } - - /* sleep and update status */ - if (timeout_remain > 0) { - uefi_call_wrapper(BS->Stall, 1, 100 * 1000); - timeout_remain--; - continue; - } - - /* timeout disabled, wait for next key */ - wait = TRUE; - continue; - } - - timeout_remain = -1; - - /* clear status after keystroke */ - if (status) { - FreePool(status); - status = NULL; - uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK); - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_max-1); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, clearline+1); - } - - idx_highlight_prev = idx_highlight; - - switch (key) { - case KEYPRESS(0, SCAN_UP, 0): - case KEYPRESS(0, 0, 'k'): - if (idx_highlight > 0) - idx_highlight--; - break; - - case KEYPRESS(0, SCAN_DOWN, 0): - case KEYPRESS(0, 0, 'j'): - if (idx_highlight < config->entry_count-1) - idx_highlight++; - break; - - case KEYPRESS(0, SCAN_HOME, 0): - case KEYPRESS(EFI_ALT_PRESSED, 0, '<'): - if (idx_highlight > 0) { - refresh = TRUE; - idx_highlight = 0; - } - break; - - case KEYPRESS(0, SCAN_END, 0): - case KEYPRESS(EFI_ALT_PRESSED, 0, '>'): - if (idx_highlight < config->entry_count-1) { - refresh = TRUE; - idx_highlight = config->entry_count-1; - } - break; - - case KEYPRESS(0, SCAN_PAGE_UP, 0): - if (idx_highlight > visible_max) - idx_highlight -= visible_max; - else - idx_highlight = 0; - break; - - case KEYPRESS(0, SCAN_PAGE_DOWN, 0): - idx_highlight += visible_max; - if (idx_highlight > config->entry_count-1) - idx_highlight = config->entry_count-1; - break; - - case KEYPRESS(0, 0, CHAR_LINEFEED): - case KEYPRESS(0, 0, CHAR_CARRIAGE_RETURN): - exit = TRUE; - break; - - case KEYPRESS(0, SCAN_F1, 0): - case KEYPRESS(0, 0, 'h'): - case KEYPRESS(0, 0, '?'): - status = StrDuplicate(L"(d)efault, (t/T)timeout, (e)dit, (v)ersion (Q)uit (P)rint (h)elp"); - break; - - case KEYPRESS(0, 0, 'Q'): - exit = TRUE; - run = FALSE; - break; - - case KEYPRESS(0, 0, 'd'): - if (config->idx_default_efivar != (INTN)idx_highlight) { - /* store the selected entry in a persistent EFI variable */ - efivar_set(L"LoaderEntryDefault", config->entries[idx_highlight]->file, TRUE); - config->idx_default_efivar = idx_highlight; - status = StrDuplicate(L"Default boot entry selected."); - } else { - /* clear the default entry EFI variable */ - efivar_set(L"LoaderEntryDefault", NULL, TRUE); - config->idx_default_efivar = -1; - status = StrDuplicate(L"Default boot entry cleared."); - } - refresh = TRUE; - break; - - case KEYPRESS(0, 0, '-'): - case KEYPRESS(0, 0, 'T'): - if (config->timeout_sec_efivar > 0) { - config->timeout_sec_efivar--; - efivar_set_int(L"LoaderConfigTimeout", config->timeout_sec_efivar, TRUE); - if (config->timeout_sec_efivar > 0) - status = PoolPrint(L"Menu timeout set to %d sec.", config->timeout_sec_efivar); - else - status = StrDuplicate(L"Menu disabled. Hold down key at bootup to show menu."); - } else if (config->timeout_sec_efivar <= 0){ - config->timeout_sec_efivar = -1; - efivar_set(L"LoaderConfigTimeout", NULL, TRUE); - if (config->timeout_sec_config > 0) - status = PoolPrint(L"Menu timeout of %d sec is defined by configuration file.", - config->timeout_sec_config); - else - status = StrDuplicate(L"Menu disabled. Hold down key at bootup to show menu."); - } - break; - - case KEYPRESS(0, 0, '+'): - case KEYPRESS(0, 0, 't'): - if (config->timeout_sec_efivar == -1 && config->timeout_sec_config == 0) - config->timeout_sec_efivar++; - config->timeout_sec_efivar++; - efivar_set_int(L"LoaderConfigTimeout", config->timeout_sec_efivar, TRUE); - if (config->timeout_sec_efivar > 0) - status = PoolPrint(L"Menu timeout set to %d sec.", - config->timeout_sec_efivar); - else - status = StrDuplicate(L"Menu disabled. Hold down key at bootup to show menu."); - break; - - case KEYPRESS(0, 0, 'e'): - /* only the options of configured entries can be edited */ - if (config->no_editor || config->entries[idx_highlight]->type == LOADER_UNDEFINED) - break; - uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK); - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_max-1); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, clearline+1); - if (line_edit(config->entries[idx_highlight]->options, &config->options_edit, x_max-1, y_max-1)) - exit = TRUE; - uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_max-1); - uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, clearline+1); - break; - - case KEYPRESS(0, 0, 'v'): - status = PoolPrint(L"gummiboot " VERSION " (" MACHINE_TYPE_NAME "), UEFI Specification %d.%02d, Vendor %s %d.%02d", - ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff, - ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff); - break; - - case KEYPRESS(0, 0, 'P'): - print_status(config, root_dir, loaded_image_path); - refresh = TRUE; - break; - - case KEYPRESS(EFI_CONTROL_PRESSED, 0, 'l'): - case KEYPRESS(EFI_CONTROL_PRESSED, 0, CHAR_CTRL('l')): - refresh = TRUE; - break; - - default: - /* jump with a hotkey directly to a matching entry */ - idx = entry_lookup_key(config, idx_highlight+1, KEYCHAR(key)); - if (idx < 0) - break; - idx_highlight = idx; - refresh = TRUE; - } - - if (idx_highlight > idx_last) { - idx_last = idx_highlight; - idx_first = 1 + idx_highlight - visible_max; - refresh = TRUE; - } - if (idx_highlight < idx_first) { - idx_first = idx_highlight; - idx_last = idx_highlight + visible_max-1; - refresh = TRUE; - } - - idx_last = idx_first + visible_max-1; - - if (!refresh && idx_highlight != idx_highlight_prev) - highlight = TRUE; - } - - *chosen_entry = config->entries[idx_highlight]; - - for (i = 0; i < config->entry_count; i++) - FreePool(lines[i]); - FreePool(lines); - FreePool(clearline); - - uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_WHITE|EFI_BACKGROUND_BLACK); - uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); - return run; -} - -static VOID config_add_entry(Config *config, ConfigEntry *entry) { - if ((config->entry_count & 15) == 0) { - UINTN i; - - i = config->entry_count + 16; - if (config->entry_count == 0) - config->entries = AllocatePool(sizeof(VOID *) * i); - else - config->entries = ReallocatePool(config->entries, - sizeof(VOID *) * config->entry_count, sizeof(VOID *) * i); - } - config->entries[config->entry_count++] = entry; -} - -static VOID config_entry_free(ConfigEntry *entry) { - FreePool(entry->title_show); - FreePool(entry->title); - FreePool(entry->machine_id); - FreePool(entry->loader); - FreePool(entry->options); -} - -static BOOLEAN is_digit(CHAR16 c) -{ - return (c >= '0') && (c <= '9'); -} - -static UINTN c_order(CHAR16 c) -{ - if (c == '\0') - return 0; - if (is_digit(c)) - return 0; - else if ((c >= 'a') && (c <= 'z')) - return c; - else - return c + 0x10000; -} - -static INTN str_verscmp(CHAR16 *s1, CHAR16 *s2) -{ - CHAR16 *os1 = s1; - CHAR16 *os2 = s2; - - while (*s1 || *s2) { - INTN first; - - while ((*s1 && !is_digit(*s1)) || (*s2 && !is_digit(*s2))) { - INTN order; - - order = c_order(*s1) - c_order(*s2); - if (order) - return order; - s1++; - s2++; - } - - while (*s1 == '0') - s1++; - while (*s2 == '0') - s2++; - - first = 0; - while (is_digit(*s1) && is_digit(*s2)) { - if (first == 0) - first = *s1 - *s2; - s1++; - s2++; - } - - if (is_digit(*s1)) - return 1; - if (is_digit(*s2)) - return -1; - - if (first) - return first; - } - - return StrCmp(os1, os2); -} - -static CHAR8 *line_get_key_value(CHAR8 *content, CHAR8 *sep, UINTN *pos, CHAR8 **key_ret, CHAR8 **value_ret) { - CHAR8 *line; - UINTN linelen; - CHAR8 *value; - -skip: - line = content + *pos; - if (*line == '\0') - return NULL; - - linelen = 0; - while (line[linelen] && !strchra((CHAR8 *)"

\r", line[linelen])) - linelen++; - - /* move pos to next line */ - *pos += linelen; - if (content[*pos]) - (*pos)++; - - /* empty line */ - if (linelen == 0) - goto skip; - - /* terminate line */ - line[linelen] = '\0'; - - /* remove leading whitespace */ - while (strchra((CHAR8 *)" \t", *line)) { - line++; - linelen--; - } - - /* remove trailing whitespace */ - while (linelen > 0 && strchra(sep, line[linelen-1])) - linelen--; - line[linelen] = '\0'; - - if (*line == '#') - goto skip; - - /* split key/value */ - value = line; - while (*value && !strchra(sep, *value)) - value++; - if (*value == '\0') - goto skip; - *value = '\0'; - value++; - while (*value && strchra(sep, *value)) - value++; - - /* unquote */ - if (value[0] == '\"' && line[linelen-1] == '\"') { - value++; - line[linelen-1] = '\0'; - } - - *key_ret = line; - *value_ret = value; - return line; -} - -static VOID config_defaults_load_from_file(Config *config, CHAR8 *content) { - CHAR8 *line; - UINTN pos = 0; - CHAR8 *key, *value; - - line = content; - while ((line = line_get_key_value(content, (CHAR8 *)" \t", &pos, &key, &value))) { - if (strcmpa((CHAR8 *)"timeout", key) == 0) { - CHAR16 *s; - - s = stra_to_str(value); - config->timeout_sec_config = Atoi(s); - config->timeout_sec = config->timeout_sec_config; - FreePool(s); - continue; - } - - if (strcmpa((CHAR8 *)"default", key) == 0) { - FreePool(config->entry_default_pattern); - config->entry_default_pattern = stra_to_str(value); - StrLwr(config->entry_default_pattern); - continue; - } - - if (strcmpa((CHAR8 *)"splash", key) == 0) { - FreePool(config->splash); - config->splash = stra_to_path(value); - continue; - } - - if (strcmpa((CHAR8 *)"background", key) == 0) { - CHAR16 c[3]; - - /* accept #RRGGBB hex notation */ - if (value[0] != '#') - continue; - if (value[7] != '\0') - continue; - - FreePool(config->background); - config->background = AllocateZeroPool(sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - if (!config->background) - continue; - - c[0] = value[1]; - c[1] = value[2]; - c[2] = '\0'; - config->background->Red = xtoi(c); - - c[0] = value[3]; - c[1] = value[4]; - config->background->Green = xtoi(c); - - c[0] = value[5]; - c[1] = value[6]; - config->background->Blue = xtoi(c); - continue; - } - - if (strcmpa((CHAR8 *)"editor", key) == 0) { - BOOLEAN on; - - if (EFI_ERROR(parse_boolean(value, &on))) - continue; - config->no_editor = !on; - } - } -} - -static VOID config_entry_add_from_file(Config *config, EFI_HANDLE *device, CHAR16 *file, CHAR8 *content, CHAR16 *loaded_image_path) { - ConfigEntry *entry; - CHAR8 *line; - UINTN pos = 0; - CHAR8 *key, *value; - UINTN len; - CHAR16 *initrd = NULL; - - entry = AllocateZeroPool(sizeof(ConfigEntry)); - - line = content; - while ((line = line_get_key_value(content, (CHAR8 *)" \t", &pos, &key, &value))) { - if (strcmpa((CHAR8 *)"title", key) == 0) { - FreePool(entry->title); - entry->title = stra_to_str(value); - continue; - } - - if (strcmpa((CHAR8 *)"version", key) == 0) { - FreePool(entry->version); - entry->version = stra_to_str(value); - continue; - } - - if (strcmpa((CHAR8 *)"machine-id", key) == 0) { - FreePool(entry->machine_id); - entry->machine_id = stra_to_str(value); - continue; - } - - if (strcmpa((CHAR8 *)"linux", key) == 0) { - FreePool(entry->loader); - entry->type = LOADER_LINUX; - entry->loader = stra_to_path(value); - entry->key = 'l'; - continue; - } - - if (strcmpa((CHAR8 *)"efi", key) == 0) { - entry->type = LOADER_EFI; - FreePool(entry->loader); - entry->loader = stra_to_path(value); - - /* do not add an entry for ourselves */ - if (StriCmp(entry->loader, loaded_image_path) == 0) { - entry->type = LOADER_UNDEFINED; - break; - } - continue; - } - - if (strcmpa((CHAR8 *)"architecture", key) == 0) { - /* do not add an entry for an EFI image of architecture not matching with that of the gummiboot image */ - if (strcmpa((CHAR8 *)MACHINE_TYPE_NAME, value) != 0) { - entry->type = LOADER_UNDEFINED; - break; - } - continue; - } - - if (strcmpa((CHAR8 *)"initrd", key) == 0) { - CHAR16 *new; - - new = stra_to_path(value); - if (initrd) { - CHAR16 *s; - - s = PoolPrint(L"%s initrd=%s", initrd, new); - FreePool(initrd); - initrd = s; - } else - initrd = PoolPrint(L"initrd=%s", new); - FreePool(new); - continue; - } - - if (strcmpa((CHAR8 *)"options", key) == 0) { - CHAR16 *new; - - new = stra_to_str(value); - if (entry->options) { - CHAR16 *s; - - s = PoolPrint(L"%s %s", entry->options, new); - FreePool(entry->options); - entry->options = s; - } else { - entry->options = new; - new = NULL; - } - FreePool(new); - continue; - } - - if (strcmpa((CHAR8 *)"splash", key) == 0) { - FreePool(entry->splash); - entry->splash = stra_to_path(value); - continue; - } - } - - if (entry->type == LOADER_UNDEFINED) { - config_entry_free(entry); - FreePool(initrd); - FreePool(entry); - return; - } - - /* add initrd= to options */ - if (entry->type == LOADER_LINUX && initrd) { - if (entry->options) { - CHAR16 *s; - - s = PoolPrint(L"%s %s", initrd, entry->options); - FreePool(entry->options); - entry->options = s; - } else { - entry->options = initrd; - initrd = NULL; - } - } - FreePool(initrd); - - if (entry->machine_id) { - CHAR16 *var; - - /* append additional options from EFI variables for this machine-id */ - var = PoolPrint(L"LoaderEntryOptions-%s", entry->machine_id); - if (var) { - CHAR16 *s; - - if (efivar_get(var, &s) == EFI_SUCCESS) { - if (entry->options) { - CHAR16 *s2; - - s2 = PoolPrint(L"%s %s", entry->options, s); - FreePool(entry->options); - entry->options = s2; - } else - entry->options = s; - } - FreePool(var); - } - - var = PoolPrint(L"LoaderEntryOptionsOneShot-%s", entry->machine_id); - if (var) { - CHAR16 *s; - - if (efivar_get(var, &s) == EFI_SUCCESS) { - if (entry->options) { - CHAR16 *s2; - - s2 = PoolPrint(L"%s %s", entry->options, s); - FreePool(entry->options); - entry->options = s2; - } else - entry->options = s; - efivar_set(var, NULL, TRUE); - } - FreePool(var); - } - } - - entry->device = device; - entry->file = StrDuplicate(file); - len = StrLen(entry->file); - /* remove ".conf" */ - if (len > 5) - entry->file[len - 5] = '\0'; - StrLwr(entry->file); - - config_add_entry(config, entry); -} - -static VOID config_load(Config *config, EFI_HANDLE *device, EFI_FILE *root_dir, CHAR16 *loaded_image_path) { - EFI_FILE_HANDLE entries_dir; - EFI_STATUS err; - CHAR8 *content = NULL; - UINTN sec; - UINTN len; - UINTN i; - - len = file_read(root_dir, L"\\loader\\loader.conf", 0, 0, &content); - if (len > 0) - config_defaults_load_from_file(config, content); - FreePool(content); - - err = efivar_get_int(L"LoaderConfigTimeout", &sec); - if (!EFI_ERROR(err)) { - config->timeout_sec_efivar = sec; - config->timeout_sec = sec; - } 