make GRUB multi-tree and re-add xhci patches

Re-add xHCI only on haswell and broadwell machines, where
they are needed. Otherwise, keep the same GRUB code.

The xHCI patches were removed because they caused issues
on Sandybridge-based Dell Latitude laptops. See:
https://codeberg.org/libreboot/lbmk/issues/216

The issue was not reported elsewhere, including on the
Haswell/Broadwell hardware where they are needed, but the
build system could only build one version of GRUB.

The older machines do not need xHCI patches, because they
either do not have xHCI patches, or work (in GRUB) because
they're in EHCI mode when running the payload.

So, the problem is that we need the xHCI patches for GRUB
on Haswell/Broadwell hardware, but the patches break
Sandybridge hardware, and we only had the one build of GRUB.
To mitigate this problem, the build system now supports
building multiple revisions of GRUB, with different patches,
and each given coreboot target can say which GRUB tree to use
by setting this in target.cfg:

grubtree="xhci"

In the above example, the "xhci" tree would be used. Some
generic GRUB config has been moved to config/data/grub/
and config/grub/ now looks like config/coreboot/ - also,
the grub.cfg file (named "payload" in each tree) is copied
to the GRUB source tree as ".config", then added to GRUB's
memdisk in the same way, as grub.cfg.

Several other design changes had to be made because of this:

* grub.cfg in memdisk no longer automatically jumps to one
  in CBFS, but now shows a menuentry for it if available

* Certain commands in script/trees are disabled for GRUB,
  such as *config make commands.

* gnulib is now defined in config/submodule/grub/, instead
  of config/git/grub - and this mitigates an existing bug
  where downloading gnulib first would make grub no longer
  possible to download in lbmk.

The coreboot option CONFIG_FINALIZE_USB_ROUTE_XHCI has been
re-enabled on: Dell OptiPlex 9020 MT, Dell OptiPlex 9020 SFF,
Lenovo ThinkPad T440p and Lenovo ThinkPad W541 - now USB should
work again in GRUB.

The GRUB payload has been re-enabled on HP EliteBook 820 G2.

This change will enable per-board GRUB optimisation in the
future. For example, we hardcode what partitions and LVMs
GRUB scans because * is slow on ICH7-based machines, due
to GRUB's design. On other machines, * is reasonably fast,
for automatically enumerating the list of devices for boot.

Use of * (and other wildcards) could enable our GRUB payload
to automatically boot more distros, with minimal fuss. This
can be done at a later date, in subsequent revisions.

Signed-off-by: Leah Rowe <leah@libreboot.org>
20240612_branch
Leah Rowe 2024-06-01 23:01:30 +01:00
parent 9daf7f05f1
commit 429e91f908
86 changed files with 8430 additions and 755 deletions

View File

@ -288,7 +288,7 @@ CONFIG_USE_NATIVE_RAMINIT=y
# CONFIG_PCIEXP_HOTPLUG is not set # CONFIG_PCIEXP_HOTPLUG is not set
CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y
CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y
# CONFIG_FINALIZE_USB_ROUTE_XHCI is not set CONFIG_FINALIZE_USB_ROUTE_XHCI=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y

View File

@ -286,7 +286,7 @@ CONFIG_USE_NATIVE_RAMINIT=y
# CONFIG_PCIEXP_HOTPLUG is not set # CONFIG_PCIEXP_HOTPLUG is not set
CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y
CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y
# CONFIG_FINALIZE_USB_ROUTE_XHCI is not set CONFIG_FINALIZE_USB_ROUTE_XHCI=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y

View File

@ -4,3 +4,4 @@ payload_seabios="y"
payload_seabios_withgrub="y" payload_seabios_withgrub="y"
payload_memtest="y" payload_memtest="y"
grub_scan_disk="nvme ahci" grub_scan_disk="nvme ahci"
grubtree="xhci"

View File

@ -288,7 +288,7 @@ CONFIG_USE_NATIVE_RAMINIT=y
# CONFIG_PCIEXP_HOTPLUG is not set # CONFIG_PCIEXP_HOTPLUG is not set
CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y
CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y
# CONFIG_FINALIZE_USB_ROUTE_XHCI is not set CONFIG_FINALIZE_USB_ROUTE_XHCI=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y

View File

@ -286,7 +286,7 @@ CONFIG_USE_NATIVE_RAMINIT=y
# CONFIG_PCIEXP_HOTPLUG is not set # CONFIG_PCIEXP_HOTPLUG is not set
CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y
CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y
# CONFIG_FINALIZE_USB_ROUTE_XHCI is not set CONFIG_FINALIZE_USB_ROUTE_XHCI=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y

View File

@ -4,3 +4,4 @@ payload_seabios="y"
payload_seabios_withgrub="y" payload_seabios_withgrub="y"
payload_memtest="y" payload_memtest="y"
grub_scan_disk="nvme ahci" grub_scan_disk="nvme ahci"
grubtree="xhci"

View File

@ -1,6 +1,8 @@
tree="default" tree="default"
xarch="i386-elf" xarch="i386-elf"
payload_seabios="y" payload_seabios="y"
payload_seabios_withgrub="y"
payload_memtest="y" payload_memtest="y"
release="n" release="n"
grub_scan_disk="nvme ahci" grub_scan_disk="nvme ahci"
grubtree="xhci"

View File

@ -325,7 +325,7 @@ CONFIG_USE_NATIVE_RAMINIT=y
# CONFIG_PCIEXP_HOTPLUG is not set # CONFIG_PCIEXP_HOTPLUG is not set
CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y
CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y
# CONFIG_FINALIZE_USB_ROUTE_XHCI is not set CONFIG_FINALIZE_USB_ROUTE_XHCI=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y

View File

@ -323,7 +323,7 @@ CONFIG_USE_NATIVE_RAMINIT=y
# CONFIG_PCIEXP_HOTPLUG is not set # CONFIG_PCIEXP_HOTPLUG is not set
CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y
CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y
# CONFIG_FINALIZE_USB_ROUTE_XHCI is not set CONFIG_FINALIZE_USB_ROUTE_XHCI=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y

View File

@ -4,3 +4,4 @@ payload_seabios="y"
payload_seabios_withgrub="y" payload_seabios_withgrub="y"
payload_memtest="y" payload_memtest="y"
grub_scan_disk="nvme ahci" grub_scan_disk="nvme ahci"
grubtree="xhci"

View File

@ -325,7 +325,7 @@ CONFIG_USE_NATIVE_RAMINIT=y
# CONFIG_PCIEXP_HOTPLUG is not set # CONFIG_PCIEXP_HOTPLUG is not set
CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y
CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y
# CONFIG_FINALIZE_USB_ROUTE_XHCI is not set CONFIG_FINALIZE_USB_ROUTE_XHCI=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y

View File

@ -323,7 +323,7 @@ CONFIG_USE_NATIVE_RAMINIT=y
# CONFIG_PCIEXP_HOTPLUG is not set # CONFIG_PCIEXP_HOTPLUG is not set
CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y CONFIG_INTEL_DESCRIPTOR_MODE_REQUIRED=y
CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT=y
# CONFIG_FINALIZE_USB_ROUTE_XHCI is not set CONFIG_FINALIZE_USB_ROUTE_XHCI=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RESET=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_RTC=y
CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y CONFIG_SOUTHBRIDGE_INTEL_COMMON_PMCLIB=y

View File

@ -4,3 +4,4 @@ payload_seabios="y"
payload_seabios_withgrub="y" payload_seabios_withgrub="y"
payload_memtest="y" payload_memtest="y"
grub_scan_disk="nvme ahci" grub_scan_disk="nvme ahci"
grubtree="xhci"

View File

@ -0,0 +1,4 @@
The deer logo for Libreboot is copyright 2014 Marcus Moeller and released under
CC-0 1.0: https://creativecommons.org/publicdomain/zero/1.0/legalcode
The grey backgrounds with it were made by Leah Rowe in 2016, also CC-0 1.0; the
same applies to the purple version which was made in 2023.

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -9,7 +9,6 @@ usbserial_pl2303 \
usbserial_usbdebug \ usbserial_usbdebug \
video_colors \ video_colors \
" "
# Modules (and always loaded) # Modules (and always loaded)
grub_modules=" \ grub_modules=" \
acpi \ acpi \

157
config/data/grub/module/xhci Executable file
View File

@ -0,0 +1,157 @@
# Install modules (installed, but not automatically loaded)
grub_install_modules=" \
hexdump \
newc \
odc \
usbserial_common \
usbserial_ftdi \
usbserial_pl2303 \
usbserial_usbdebug \
video_colors \
"
# Modules (and always loaded)
grub_modules=" \
acpi \
ahci \
at_keyboard \
all_video \
ata \
bitmap \
bitmap_scale \
boot \
bsd \
btrfs \
cat \
cbfs \
cbls \
cbmemc \
cbtime \
chain \
configfile \
cpio \
cpio_be \
crc64 \
crypto \
cryptodisk \
diskfilter \
echo \
xhci \
ehci \
eval \
exfat \
elf \
ext2 \
fat \
f2fs \
gcry_arcfour \
gcry_blowfish \
gcry_camellia \
gcry_cast5 \
gcry_crc \
gcry_des \
gcry_dsa \
gcry_idea \
gcry_md4 \
gcry_md5 \
gcry_rfc2268 \
gcry_rijndael \
gcry_rmd160 \
gcry_rsa \
gcry_seed \
gcry_serpent \
gcry_sha1 \
gcry_sha256 \
gcry_sha512 \
gcry_tiger \
gcry_twofish \
gcry_whirlpool \
geli \
gfxmenu \
gfxterm_background \
gfxterm_menu \
gzio \
hashsum \
halt \
help \
iorw \
iso9660 \
jpeg \
json \
keylayouts \
keystatus \
linux \
linux16 \
loadenv \
loopback \
ls \
lsacpi \
lsmmap \
lspci \
luks \
luks2 \
argon2 \
lvm \
lzopio \
mdraid09 \
mdraid09_be \
mdraid1x \
memdisk \
memrw \
minicmd \
mmap \
multiboot \
multiboot2 \
nativedisk \
normal \
ntfs \
nvme \
ohci \
part_bsd \
part_dfly \
part_gpt \
part_msdos \
password \
password_pbkdf2 \
pata \
pbkdf2 \
pcidump \
pgp \
play \
png \
procfs \
raid5rec \
raid6rec \
read \
reboot \
regexp \
romfs \
scsi \
search \
search_fs_file \
search_fs_uuid \
search_label \
serial \
syslinuxcfg \
setjmp \
setpci \
spkmodem \
squash4 \
sleep \
tar \
test \
true \
uhci \
udf \
ufs1 \
ufs1_be \
ufs2 \
usb \
usb_keyboard \
usbms \
xfs \
xzio \
zfs \
zfscrypt \
zfsinfo \
zstd \
"

View File

@ -1,14 +1,6 @@
{grub}{ {grub}{
rev: 8719cc2040368d43ab2de0b6e1b850b2c9cfc5b7 rev: HEAD
loc: grub loc: grub/grub
url: git://git.savannah.gnu.org/grub.git url: git://git.savannah.gnu.org/grub.git
bkup_url: https://codeberg.org/libreboot/grub bkup_url: https://codeberg.org/libreboot/grub
depend: gnulib
}
{gnulib}{
rev: 9f48fb992a3d7e96610c4ce8be969cff2d61a01b
loc: grub/gnulib
url: git://git.sv.gnu.org/gnulib
bkup_url: https://codeberg.org/libreboot/gnulib
} }

View File

@ -1,3 +0,0 @@
The deer logo for Libreboot is copyright 2014 Marcus Moeller and released under
CC-0: https://creativecommons.org/publicdomain/zero/1.0/legalcode
The grey backgrounds with it were made by Leah Rowe in 2016, also CC-0

1
config/grub/build.list Normal file
View File

@ -0,0 +1 @@
grub.elf

View File

@ -1,2 +0,0 @@
Copyright (C) 2014, 2015, 2016, 2020, 2021, 2023 Leah Rowe <leah@libreboot.org>
Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>

View File

@ -1,695 +0,0 @@
# GRUB configuration files under resources/grub/config/
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# See AUTHORS for copyright holder information.
# Full terms of GPLv3 below, taken from https://www.gnu.org/licenses/licenses.html
________________________________________________________________________
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -1,9 +0,0 @@
# SPDX-License-Identifier: GPL-3.0-or-later
set prefix=(memdisk)/boot/grub
if [ -f (cbfsdisk)/grub.cfg ]; then
source (cbfsdisk)/grub.cfg
else
source (memdisk)/boot/grub/grub_default.cfg
fi

View File

@ -1,4 +1,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2014-2016,2020-2021,2023-2024 Leah Rowe <leah@libreboot.org>
# Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
set prefix=(memdisk)/boot/grub set prefix=(memdisk)/boot/grub
@ -215,6 +217,14 @@ menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on ATA/IDE [d]' --hotkey=
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on NVMe [e]' --hotkey='e' { menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on NVMe [e]' --hotkey='e' {
search_bootcfg nvme search_bootcfg nvme
} }
if [ -f (cbfsdisk)/grub.cfg ]; then
menuentry 'Load configuration (grub.cfg) in CBFS [t]' --hotkey='t' {
set root='(cbfsdisk)'
if [ -f /grub.cfg ]; then
configfile /grub.cfg
fi
}
fi
if [ -f (cbfsdisk)/grubtest.cfg ]; then if [ -f (cbfsdisk)/grubtest.cfg ]; then
menuentry 'Load test configuration (grubtest.cfg) inside of CBFS [t]' --hotkey='t' { menuentry 'Load test configuration (grubtest.cfg) inside of CBFS [t]' --hotkey='t' {
set root='(cbfsdisk)' set root='(cbfsdisk)'

View File

@ -0,0 +1,5 @@
tree="default"
rev="8719cc2040368d43ab2de0b6e1b850b2c9cfc5b7"
bootstrapargs="--gnulib-srcdir=gnulib/ --no-git"
autoconfargs="--with-platform=coreboot --disable-werror"
makeargs="FS_PAYLOAD_MODULES=\"\""

View File

@ -0,0 +1,290 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2014-2016,2020-2021,2023-2024 Leah Rowe <leah@libreboot.org>
# Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
set prefix=(memdisk)/boot/grub
insmod at_keyboard
insmod usb_keyboard
insmod nativedisk
insmod xhci
insmod ehci
insmod ohci
insmod uhci
insmod usb
insmod usbms
insmod regexp
terminal_input --append at_keyboard
terminal_input --append usb_keyboard
terminal_output --append cbmemc
# User interface overrides wherever "keystatus" is supported
# Keep SHIFT key pressed before powering on to disable graphics
if keystatus --shift; then
terminal_output --append vga_text
else
gfxpayload=keep
terminal_output --append gfxterm
if [ -f (cbfsdisk)/background.png ]; then
insmod png
background_image (cbfsdisk)/background.png
elif [ -f (cbfsdisk)/background.jpg ]; then
insmod jpeg
background_image (cbfsdisk)/background.jpg
fi
fi
# Keep CTRL pressed to enable default serial terminal (COM1 or the like)
if keystatus --ctrl; then
serial
terminal_input --append serial
terminal_output --append serial
fi
# Keep ALT pressed to enable spkmodem
if keystatus --alt; then
terminal_output --append spkmodem
fi
set default="0"
if [ -f (cbfsdisk)/timeout.cfg ]; then
source (cbfsdisk)/timeout.cfg
else
set timeout=5
fi
set grub_scan_disk="nvme ahci ata"
if [ -f (cbfsdisk)/scan.cfg ]; then
source (cbfsdisk)/scan.cfg
fi
if [ -f (cbfsdisk)/keymap.gkb ]; then
keymap (cbfsdisk)/keymap.gkb
fi
function really_try_user_config {
set root="${1}"
if [ -f /"${2}"/grub.cfg ]; then
unset superusers
configfile /"${2}"/grub.cfg
fi
}
function try_user_config {
# The @/... entries are for cases where the BTRFS filesystem is being used
for dir in grub boot/grub @/grub @/boot/grub grub2 boot/grub2 @/grub2 @/boot/grub2 boot @/boot; do
really_try_user_config "${1}" "${dir}"
done
for dir in ubuntu debian redhat; do
really_try_user_config "${1}" "EFI/${dir}"
done
}
function search_grub {
echo -n "Attempting to load grub.cfg from '${1}' devices"
for i in 0 1 2 3 4 5 6 7 8; do
for part in 1 2 3 4 5 6 7 8 9 10 11 12; do
if [ "${1}" != "nvme" ]; then
try_user_config "(${1}${i},${part})"
else
# TODO: do we care about other namesapces
try_user_config "(nvme${i}n1,${part})"
fi
done
if [ "${1}" != "nvme" ]; then
# raw devices e.g. (ahci0) instead of (ahci0,1)
try_user_config "(${1}${i})"
else
# TODO: do we care about other namesapces
try_user_config "(nvme${i}n1)"
fi
done
echo # Insert newline
}
function try_isolinux_config {
set root="${1}"
for dir in '' /boot /EFI /@ /@/boot; do
if [ -f "${dir}"/isolinux/isolinux.cfg ]; then
syslinux_configfile -i "${dir}"/isolinux/isolinux.cfg
elif [ -f "${dir}"/syslinux/syslinux.cfg ]; then
syslinux_configfile -s "${dir}"/syslinux/syslinux.cfg
elif [ -f "${dir}"/syslinux/extlinux.conf ]; then
syslinux_configfile -s "${dir}"/syslinux/extlinux.conf
elif [ -f "${dir}"/extlinux/extlinux.conf ]; then
syslinux_configfile -s "${dir}"/extlinux/extlinux.conf
fi
done
}
function search_isolinux {
echo "\nAttempting to parse iso/sys/extlinux config from '${1}' devices"
for i in 0 1 2 3 4 5 6 7 8; do
for part in 1 2 3 4 5 6 7 8 9 10 11 12; do
if [ "${1}" != "nvme" ]; then
try_isolinux_config "(${1}${i},${part})"
else
# TODO: see above
try_isolinux_config "(nvme${i}n1,${part})"
fi
done
if [ "${1}" != "nvme" ]; then
# raw devices e.g. (usb0) instead of (usb0,1)
try_isolinux_config "(${1}${i})"
else
# TODO: do we care about other namesapces
try_isolinux_config "(nvme${i}n1)"
fi
done
echo # Insert newline
}
function try_bootcfg {
try_user_config "${1}"
try_isolinux_config "${1}"
}
function search_bootcfg {
search_grub "${1}"
search_isolinux "${1}"
}
menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' {
for grub_disk in ${grub_scan_disk}; do
search_bootcfg ${grub_disk}
done
# grub device enumeration is very slow, so checks are hardcoded
# TODO: add more strings, based on what distros set up when
# the user select auto-partitioning on those installers
lvmvol="lvm/grubcrypt-bootvol lvm/grubcrypt-rootvol"
raidvol="md/0 md/1 md/2 md/3 md/4 md/5 md/6 md/7 md/8 md/9"
# in practise, doing multiple redundant checks is perfectly fast and
# TODO: optimize grub itself, and use */? here for everything
for vol in ${lvmvol} ${raidvol} ; do
try_bootcfg "${vol}"
done
unset bootdev
for grub_disk in ${grub_scan_disk}; do
for i in 0 1 2 3 4 5 6 7 8; do
for part in 1 2 3 4 5 6 7 8 9 10 11 12; do
if [ "${grub_disk}" = "ahci" ]; then
bootdev="${bootdev} (ahci${i},${part})"
elif [ "${grub_disk}" = "ata" ]; then
bootdev="${bootdev} (ata${i},${part})"
elif [ "${grub_disk}" = "nvme" ]; then
# TODO: do we care about other namesapces
bootdev="${bootdev} (nvme${i}n1,${part})"
fi
done
done
done
set pager=0
echo -n "Attempting to unlock encrypted volumes"
for dev in ${bootdev} ${lvmvol} ${raidvol}; do
if cryptomount "${dev}" ; then break ; fi
done
set pager=1
echo
# after cryptomount, lvm volumes might be available
for vol in ${lvmvol}; do
try_bootcfg "${vol}"
done
search_bootcfg crypto
for vol in lvm/* ; do
try_bootcfg "${vol}"
done
true # Prevent pager requiring to accept each line instead of whole screen
}
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on USB [s]' --hotkey='s' {
search_bootcfg usb
}
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on AHCI [a]' --hotkey='a' {
search_bootcfg ahci
}
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on ATA/IDE [d]' --hotkey='d' {
search_bootcfg ata
}
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on NVMe [e]' --hotkey='e' {
search_bootcfg nvme
}
if [ -f (cbfsdisk)/grub.cfg ]; then
menuentry 'Load configuration (grub.cfg) in CBFS [t]' --hotkey='t' {
set root='(cbfsdisk)'
if [ -f /grub.cfg ]; then
configfile /grub.cfg
fi
}
fi
if [ -f (cbfsdisk)/grubtest.cfg ]; then
menuentry 'Load test configuration (grubtest.cfg) in CBFS [t]' --hotkey='t' {
set root='(cbfsdisk)'
if [ -f /grubtest.cfg ]; then
configfile /grubtest.cfg
fi
}
fi
if [ -f (cbfsdisk)/seabios.elf ]; then
menuentry 'Load SeaBIOS (payload) [b]' --hotkey='b' {
set root='cbfsdisk'
chainloader /seabios.elf
}
fi
if [ -f (cbfsdisk)/img/grub2 ]; then
menuentry 'Return to SeaBIOS [b]' --hotkey='b' {
set root='cbfsdisk'
chainloader /fallback/payload
}
fi
menuentry 'Poweroff [p]' --hotkey='p' {
halt
}
menuentry 'Reboot [r]' --hotkey='r' {
reboot
}
if [ -f (cbfsdisk)/img/memtest ]; then
menuentry 'Load MemTest86+ [m]' --hotkey='m' {
set root='cbfsdisk'
chainloader /img/memtest
}
fi
submenu 'Other [z]' --hotkey='z' {
menuentry 'Enable default serial terminal [s]' --hotkey='s' {
serial
terminal_input --append serial
terminal_output --append serial
}
menuentry 'Disable default serial terminal' {
terminal_input --remove serial
terminal_output --remove serial
}
menuentry 'Enable gfxterm' {
terminal_output --append gfxterm
terminal_output --remove vga_text
}
menuentry 'Disable gfxterm [g]' --hotkey='g' {
terminal_output --remove gfxterm
terminal_output --append vga_text
}
menuentry 'Enable spkmodem [a]' --hotkey='a' {
terminal_output --append spkmodem
}
menuentry 'Disable spkmodem [z]' --hotkey='z' {
terminal_output --remove spkmodem
}
}

View File

@ -0,0 +1,90 @@
From ce13539fe2103abbd991814d995e06cf96e485f7 Mon Sep 17 00:00:00 2001
From: Leah Rowe <leah@libreboot.org>
Date: Sun, 31 Oct 2021 03:47:05 +0000
Subject: [PATCH 1/3] mitigate grub's missing characters for borders/arrow
characters
This cleans up the display on the main screen in GRUB.
Just don't draw a border, at all.
---
grub-core/normal/menu_text.c | 49 ++----------------------------------
1 file changed, 2 insertions(+), 47 deletions(-)
diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c
index b1321eb26..e76094dfd 100644
--- a/grub-core/normal/menu_text.c
+++ b/grub-core/normal/menu_text.c
@@ -108,47 +108,6 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right,
grub_print_message_indented_real (msg, margin_left, margin_right, term, 0);
}
-static void
-draw_border (struct grub_term_output *term, const struct grub_term_screen_geometry *geo)
-{
- int i;
-
- grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
-
- grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1,
- geo->first_entry_y - 1 });
- grub_putcode (GRUB_UNICODE_CORNER_UL, term);
- for (i = 0; i < geo->entry_width + 1; i++)
- grub_putcode (GRUB_UNICODE_HLINE, term);
- grub_putcode (GRUB_UNICODE_CORNER_UR, term);
-
- for (i = 0; i < geo->num_entries; i++)
- {
- grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1,
- geo->first_entry_y + i });
- grub_putcode (GRUB_UNICODE_VLINE, term);
- grub_term_gotoxy (term,
- (struct grub_term_coordinate) { geo->first_entry_x + geo->entry_width + 1,
- geo->first_entry_y + i });
- grub_putcode (GRUB_UNICODE_VLINE, term);
- }
-
- grub_term_gotoxy (term,
- (struct grub_term_coordinate) { geo->first_entry_x - 1,
- geo->first_entry_y - 1 + geo->num_entries + 1 });
- grub_putcode (GRUB_UNICODE_CORNER_LL, term);
- for (i = 0; i < geo->entry_width + 1; i++)
- grub_putcode (GRUB_UNICODE_HLINE, term);
- grub_putcode (GRUB_UNICODE_CORNER_LR, term);
-
- grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
-
- grub_term_gotoxy (term,
- (struct grub_term_coordinate) { geo->first_entry_x - 1,
- (geo->first_entry_y - 1 + geo->num_entries
- + GRUB_TERM_MARGIN + 1) });
-}
-
static int
print_message (int nested, int edit, struct grub_term_output *term, int dry_run)
{
@@ -167,10 +126,8 @@ command-line or ESC to discard edits and return to the GRUB menu."),
{
char *msg_translated;
- msg_translated = grub_xasprintf (_("Use the %C and %C keys to select which "
- "entry is highlighted."),
- GRUB_UNICODE_UPARROW,
- GRUB_UNICODE_DOWNARROW);
+ msg_translated = grub_xasprintf (_("Use the arrow keys to select which "
+ "entry is highlighted."));
if (!msg_translated)
return 0;
ret += grub_print_message_indented_real (msg_translated, STANDARD_MARGIN,
@@ -410,8 +367,6 @@ grub_menu_init_page (int nested, int edit,
grub_term_normal_color = grub_color_menu_normal;
grub_term_highlight_color = grub_color_menu_highlight;
- if (geo->border)
- draw_border (term, geo);
grub_term_normal_color = old_color_normal;
grub_term_highlight_color = old_color_highlight;
geo->timeout_y = geo->first_entry_y + geo->num_entries
--
2.25.1

View File

@ -0,0 +1,25 @@
From 70f9e72c3ff6381fe3519612de3b649c0cf26b9a Mon Sep 17 00:00:00 2001
From: Leah Rowe <leah@libreboot.org>
Date: Sat, 19 Nov 2022 16:30:24 +0000
Subject: [PATCH 2/3] say the name libreboot, in the grub menu
---
grub-core/normal/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index bd4431000..31308e16a 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -209,7 +209,7 @@ grub_normal_init_page (struct grub_term_output *term,
grub_term_cls (term);
- msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION);
+ msg_formatted = grub_xasprintf (_("Libreboot 20240504 release, based on coreboot. https://libreboot.org/"));
if (!msg_formatted)
return;
--
2.25.1

View File

@ -0,0 +1,42 @@
From de6e7cc62522ce1be21bd2f06e7c15cd234b5426 Mon Sep 17 00:00:00 2001
From: Ax333l <main@axelen.xyz>
Date: Thu, 17 Aug 2023 00:00:00 +0000
Subject: [PATCH 1/6] Add CC0 license
Signed-off-by: Nicholas Johnson <nick@nicholasjohnson.ch>
---
grub-core/kern/dl.c | 3 ++-
util/grub-module-verifierXX.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index 0bf40caa6..4011e2d15 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -470,7 +470,8 @@ grub_dl_check_license (grub_dl_t mod, Elf_Ehdr *e)
if (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0
|| grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3+") == 0
- || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0)
+ || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0
+ || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=CC0") == 0)
return GRUB_ERR_NONE;
return grub_error (GRUB_ERR_BAD_MODULE,
diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c
index a42c20bd1..7157a30aa 100644
--- a/util/grub-module-verifierXX.c
+++ b/util/grub-module-verifierXX.c
@@ -236,7 +236,8 @@ check_license (const char * const filename,
Elf_Shdr *s = find_section (arch, e, ".module_license", module_size);
if (s && (strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3") == 0
|| strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3+") == 0
- || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv2+") == 0))
+ || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv2+") == 0
+ || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=CC0") == 0))
return;
grub_util_error ("%s: incompatible license", filename);
}
--
2.39.2

View File

@ -0,0 +1,39 @@
From 9edaaffac91d593a439e44bac3b6f5558f5a8245 Mon Sep 17 00:00:00 2001
From: Ax333l <main@axelen.xyz>
Date: Thu, 17 Aug 2023 00:00:00 +0000
Subject: [PATCH 2/6] Define GRUB_UINT32_MAX
Signed-off-by: Nicholas Johnson <nick@nicholasjohnson.ch>
---
include/grub/types.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/grub/types.h b/include/grub/types.h
index 0d96006fe..a13f3a60b 100644
--- a/include/grub/types.h
+++ b/include/grub/types.h
@@ -156,6 +156,7 @@ typedef grub_int32_t grub_ssize_t;
#define GRUB_SHRT_MAX 0x7fff
#define GRUB_SHRT_MIN (-GRUB_SHRT_MAX - 1)
#define GRUB_UINT_MAX 4294967295U
+#define GRUB_UINT32_MAX 4294967295U
#define GRUB_INT_MAX 0x7fffffff
#define GRUB_INT_MIN (-GRUB_INT_MAX - 1)
#define GRUB_INT32_MAX 2147483647
@@ -177,6 +178,13 @@ typedef grub_int32_t grub_ssize_t;
#define GRUB_TYPE_U_MAX(type) ((unsigned long long)((typeof (type))(~0)))
#define GRUB_TYPE_U_MIN(type) 0ULL
+# define GRUB_UINT32_C(x) x ## U
+# if GRUB_ULONG_MAX >> 31 >> 31 >> 1 == 1
+# define GRUB_UINT64_C(x) x##UL
+# elif 1
+# define GRUB_UINT64_C(x) x##ULL
+# endif
+
typedef grub_uint64_t grub_properly_aligned_t;
#define GRUB_PROPERLY_ALIGNED_ARRAY(name, size) grub_properly_aligned_t name[((size) + sizeof (grub_properly_aligned_t) - 1) / sizeof (grub_properly_aligned_t)]
--
2.39.2

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
From 0044d32121bf52c4547c6b3c78f12d7305f57e6b Mon Sep 17 00:00:00 2001
From: Ax333l <main@axelen.xyz>
Date: Thu, 17 Aug 2023 00:00:00 +0000
Subject: [PATCH 4/6] Error on missing Argon2id parameters
Signed-off-by: Nicholas Johnson <nick@nicholasjohnson.ch>
---
grub-core/disk/luks2.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
index d5106402f..bc818ea69 100644
--- a/grub-core/disk/luks2.c
+++ b/grub-core/disk/luks2.c
@@ -38,6 +38,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
enum grub_luks2_kdf_type
{
LUKS2_KDF_TYPE_ARGON2I,
+ LUKS2_KDF_TYPE_ARGON2ID,
LUKS2_KDF_TYPE_PBKDF2
};
typedef enum grub_luks2_kdf_type grub_luks2_kdf_type_t;
@@ -90,7 +91,7 @@ struct grub_luks2_keyslot
grub_int64_t time;
grub_int64_t memory;
grub_int64_t cpus;
- } argon2i;
+ } argon2;
struct
{
const char *hash;
@@ -160,10 +161,11 @@ luks2_parse_keyslot (grub_luks2_keyslot_t *out, const grub_json_t *keyslot)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing or invalid KDF");
else if (!grub_strcmp (type, "argon2i") || !grub_strcmp (type, "argon2id"))
{
- out->kdf.type = LUKS2_KDF_TYPE_ARGON2I;
- if (grub_json_getint64 (&out->kdf.u.argon2i.time, &kdf, "time") ||
- grub_json_getint64 (&out->kdf.u.argon2i.memory, &kdf, "memory") ||
- grub_json_getint64 (&out->kdf.u.argon2i.cpus, &kdf, "cpus"))
+ out->kdf.type = !grub_strcmp (type, "argon2i")
+ ? LUKS2_KDF_TYPE_ARGON2I : LUKS2_KDF_TYPE_ARGON2ID;
+ if (grub_json_getint64 (&out->kdf.u.argon2.time, &kdf, "time") ||
+ grub_json_getint64 (&out->kdf.u.argon2.memory, &kdf, "memory") ||
+ grub_json_getint64 (&out->kdf.u.argon2.cpus, &kdf, "cpus"))
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing Argon2i parameters");
}
else if (!grub_strcmp (type, "pbkdf2"))
@@ -459,6 +461,7 @@ luks2_decrypt_key (grub_uint8_t *out_key,
switch (k->kdf.type)
{
case LUKS2_KDF_TYPE_ARGON2I:
+ case LUKS2_KDF_TYPE_ARGON2ID:
ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Argon2 not supported");
goto err;
case LUKS2_KDF_TYPE_PBKDF2:
--
2.39.2

View File

@ -0,0 +1,83 @@
From 0a21695c55f76f1c958bb633481d55b3168562f7 Mon Sep 17 00:00:00 2001
From: Ax333l <main@axelen.xyz>
Date: Thu, 17 Aug 2023 00:00:00 +0000
Subject: [PATCH 5/6] Compile with Argon2id support
Signed-off-by: Nicholas Johnson <nick@nicholasjohnson.ch>
---
Makefile.util.def | 6 +++++-
grub-core/Makefile.core.def | 2 +-
grub-core/disk/luks2.c | 13 +++++++++++--
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/Makefile.util.def b/Makefile.util.def
index 1e9a13d3e..a167825c3 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -3,7 +3,7 @@ AutoGen definitions Makefile.tpl;
library = {
name = libgrubkern.a;
cflags = '$(CFLAGS_GNULIB)';
- cppflags = '$(CPPFLAGS_GNULIB) -I$(srcdir)/grub-core/lib/json';
+ cppflags = '$(CPPFLAGS_GNULIB) -I$(srcdir)/grub-core/lib/json -I$(srcdir)/grub-core/lib/argon2';
common = util/misc.c;
common = grub-core/kern/command.c;
@@ -36,6 +36,10 @@ library = {
common = grub-core/kern/misc.c;
common = grub-core/kern/partition.c;
common = grub-core/lib/crypto.c;
+ common = grub-core/lib/argon2/argon2.c;
+ common = grub-core/lib/argon2/core.c;
+ common = grub-core/lib/argon2/ref.c;
+ common = grub-core/lib/argon2/blake2/blake2b.c;
common = grub-core/lib/json/json.c;
common = grub-core/disk/luks.c;
common = grub-core/disk/luks2.c;
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 4a06789e5..e939dcc99 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -1238,7 +1238,7 @@ module = {
common = disk/luks2.c;
common = lib/gnulib/base64.c;
cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
- cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB) -I$(srcdir)/lib/json';
+ cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB) -I$(srcdir)/lib/json -I$(srcdir)/lib/argon2';
};
module = {
diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
index bc818ea69..5b9eaa599 100644
--- a/grub-core/disk/luks2.c
+++ b/grub-core/disk/luks2.c
@@ -27,6 +27,7 @@
#include <grub/partition.h>
#include <grub/i18n.h>
+#include <argon2.h>
#include <base64.h>
#include <json.h>
@@ -462,8 +463,16 @@ luks2_decrypt_key (grub_uint8_t *out_key,
{
case LUKS2_KDF_TYPE_ARGON2I:
case LUKS2_KDF_TYPE_ARGON2ID:
- ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Argon2 not supported");
- goto err;
+ ret = argon2_hash (k->kdf.u.argon2.time, k->kdf.u.argon2.memory, k->kdf.u.argon2.cpus,
+ passphrase, passphraselen, salt, saltlen, area_key, k->area.key_size,
+ k->kdf.type == LUKS2_KDF_TYPE_ARGON2I ? Argon2_i : Argon2_id,
+ ARGON2_VERSION_NUMBER);
+ if (ret)
+ {
+ grub_dprintf ("luks2", "Argon2 failed: %s\n", argon2_error_message (ret));
+ goto err;
+ }
+ break;
case LUKS2_KDF_TYPE_PBKDF2:
hash = grub_crypto_lookup_md_by_name (k->kdf.u.pbkdf2.hash);
if (!hash)
--
2.39.2

View File

@ -0,0 +1,26 @@
From 6c9a6625c0dc038d1bdbdc13665f40e269e86496 Mon Sep 17 00:00:00 2001
From: Ax333l <main@axelen.xyz>
Date: Thu, 17 Aug 2023 00:00:00 +0000
Subject: [PATCH 6/6] Make grub-install work with Argon2
Signed-off-by: Nicholas Johnson <nick@nicholasjohnson.ch>
---
util/grub-install.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/util/grub-install.c b/util/grub-install.c
index 1ad04db36..a8a3330b8 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -448,6 +448,8 @@ probe_mods (grub_disk_t disk)
{
grub_util_cryptodisk_get_abstraction (disk,
push_cryptodisk_module, NULL);
+ /* HACK: always push argon2 */
+ grub_install_push_module ("argon2");
have_abstractions = 1;
have_cryptodisk = 1;
}
--
2.39.2

View File

@ -0,0 +1,107 @@
From 96c0bbe5d406b616360a7fce7cee67d7692c0d6d Mon Sep 17 00:00:00 2001
From: Leah Rowe <leah@libreboot.org>
Date: Mon, 30 Oct 2023 22:19:21 +0000
Subject: [PATCH 1/1] at_keyboard coreboot: force scancodes2+translate
Scan code set 2 with translation should be assumed in
every case, as the default starting position.
However, GRUB is trying to detect and use other modes
such as set 2 without translation, or set 1 without
translation from set 2; it also detects no-mode and
assumes mode 1, on really old keyboards.
The current behaviour has been retained, for everything
except GRUB_MACHINE_COREBOOT; for the latter, scan code
set 2 with translation is hardcoded, and forced in code.
This is required to make keyboard initialisation work on
the MEC5035 EC used by the Dell Latitude E6400, when
running GRUB as a coreboot payload on that laptop. The
EC reports scancode set 2 with translation when probed,
but actually only outputs scancode set 1.
Since GRUB is attempting to use it without translation,
and since the machine reports set 2 with translation,
but only ever outputs set 1 scancodes, this results in
wrong keypresses for every key.
This fix fixed that, by forcing set 2 with translation,
treating it as set 1, but only on coreboot. This is the
same behaviour used in GNU+Linux systems and SeaBIOS.
With this change, GRUB keyboard initialisation now works
just fine on those machines.
This has *also* been tested on other coreboot machines
running GRUB; several HP EliteBooks, ThinkPads and
Dell Precision T1650. All seems to work just fine.
Signed-off-by: Leah Rowe <leah@libreboot.org>
---
grub-core/term/at_keyboard.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c
index f8a129eb7..8207225c2 100644
--- a/grub-core/term/at_keyboard.c
+++ b/grub-core/term/at_keyboard.c
@@ -138,6 +138,7 @@ write_mode (int mode)
return (i != GRUB_AT_TRIES);
}
+#if !defined (GRUB_MACHINE_COREBOOT)
static int
query_mode (void)
{
@@ -161,10 +162,12 @@ query_mode (void)
return 3;
return 0;
}
+#endif
static void
set_scancodes (void)
{
+#if !defined (GRUB_MACHINE_COREBOOT)
/* You must have visited computer museum. Keyboard without scancode set
knowledge. Assume XT. */
if (!grub_keyboard_orig_set)
@@ -173,20 +176,33 @@ set_scancodes (void)
ps2_state.current_set = 1;
return;
}
+#endif
#if !USE_SCANCODE_SET
ps2_state.current_set = 1;
return;
-#else
+#endif
+#if defined (GRUB_MACHINE_COREBOOT)
+ /* enable translation */
+ grub_keyboard_controller_write (grub_keyboard_controller_orig
+ & ~KEYBOARD_AT_DISABLE);
+#else
+ /* if not coreboot, disable translation and try mode 2 first, before 1 */
grub_keyboard_controller_write (grub_keyboard_controller_orig
& ~KEYBOARD_AT_TRANSLATE
& ~KEYBOARD_AT_DISABLE);
+#endif
keyboard_controller_wait_until_ready ();
grub_outb (KEYBOARD_COMMAND_ENABLE, KEYBOARD_REG_DATA);
-
write_mode (2);
+
+#if defined (GRUB_MACHINE_COREBOOT)
+ /* mode 2 with translation, so make grub treat as set 1 */
+ ps2_state.current_set = 1;
+#else
+ /* if not coreboot, translation isn't set; test 2 and fall back to 1 */
ps2_state.current_set = query_mode ();
grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set);
if (ps2_state.current_set == 2)
--
2.39.2

View File

@ -0,0 +1,38 @@
From 0a6abeb40ac4284fbff6ef5958989d561b6290a7 Mon Sep 17 00:00:00 2001
From: Leah Rowe <leah@libreboot.org>
Date: Tue, 31 Oct 2023 10:33:28 +0000
Subject: [PATCH 1/1] keylayouts: don't print "Unknown key" message
on keyboards with stuck keys, this results in GRUB just
spewing it repeatedly, preventing use of GRUB.
in such cases, it's still possible to use the keyboard,
and we should let the user at least boot.
it often appears when people plug in faulty usb keyboards,
but can appear for laptop keyboards too; one of my e6400
has stuck keys.
with this patch, grub should be a bit more reliable in
terms of user experience, when the keyboard is faulty.
Signed-off-by: Leah Rowe <leah@libreboot.org>
---
grub-core/commands/keylayouts.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c
index aa3ba34f2..445fa0601 100644
--- a/grub-core/commands/keylayouts.c
+++ b/grub-core/commands/keylayouts.c
@@ -174,7 +174,6 @@ grub_term_map_key (grub_keyboard_key_t code, int status)
key = map_key_core (code, status, &alt_gr_consumed);
if (key == 0 || key == GRUB_TERM_SHIFT) {
- grub_printf ("Unknown key 0x%x detected\n", code);
return GRUB_TERM_NO_KEY;
}
--
2.39.2

View File

@ -0,0 +1,102 @@
From 9e7a651a0f15f2e9dec65a77765c3c4fd97b4165 Mon Sep 17 00:00:00 2001
From: Leah Rowe <leah@libreboot.org>
Date: Sun, 5 Nov 2023 16:14:58 +0000
Subject: [PATCH 1/1] don't print missing prefix errors on the screen
we do actually set the prefix. this patch modifies
grub to still set grub_errno and return accordingly,
so the behaviour is otherwise identical, but it will
no longer print a warning message on the screen.
Signed-off-by: Leah Rowe <leah@libreboot.org>
---
grub-core/commands/keylayouts.c | 2 +-
grub-core/commands/loadenv.c | 2 +-
grub-core/commands/nativedisk.c | 2 +-
grub-core/efiemu/main.c | 3 +--
grub-core/font/font.c | 2 +-
grub-core/kern/dl.c | 2 +-
6 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c
index 445fa0601..00bcf7025 100644
--- a/grub-core/commands/keylayouts.c
+++ b/grub-core/commands/keylayouts.c
@@ -211,7 +211,7 @@ grub_cmd_keymap (struct grub_command *cmd __attribute__ ((unused)),
{
const char *prefix = grub_env_get ("prefix");
if (!prefix)
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("variable `%s' isn't set"), "prefix");
+ return (grub_errno = GRUB_ERR_BAD_ARGUMENT);
filename = grub_xasprintf ("%s/layouts/%s.gkb", prefix, argv[0]);
if (!filename)
return grub_errno;
diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c
index 166445849..699b39bfa 100644
--- a/grub-core/commands/loadenv.c
+++ b/grub-core/commands/loadenv.c
@@ -58,7 +58,7 @@ open_envblk_file (char *filename,
prefix = grub_env_get ("prefix");
if (! prefix)
{
- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
+ grub_errno = GRUB_ERR_FILE_NOT_FOUND;
return 0;
}
diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c
index 580c8d3b0..6806bff9c 100644
--- a/grub-core/commands/nativedisk.c
+++ b/grub-core/commands/nativedisk.c
@@ -186,7 +186,7 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
prefix = grub_env_get ("prefix");
if (! prefix)
- return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
+ return (grub_errno = GRUB_ERR_FILE_NOT_FOUND);
if (prefix)
path_prefix = (prefix[0] == '(') ? grub_strchr (prefix, ')') : NULL;
diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c
index e7037f4ed..e5d4dbff1 100644
--- a/grub-core/efiemu/main.c
+++ b/grub-core/efiemu/main.c
@@ -231,8 +231,7 @@ grub_efiemu_autocore (void)
prefix = grub_env_get ("prefix");
if (! prefix)
- return grub_error (GRUB_ERR_FILE_NOT_FOUND,
- N_("variable `%s' isn't set"), "prefix");
+ return (grub_errno = GRUB_ERR_FILE_NOT_FOUND);
suffix = grub_efiemu_get_default_core_name ();
diff --git a/grub-core/font/font.c b/grub-core/font/font.c
index 18de52562..2a0fea6c8 100644
--- a/grub-core/font/font.c
+++ b/grub-core/font/font.c
@@ -461,7 +461,7 @@ grub_font_load (const char *filename)
if (!prefix)
{
- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
+ grub_errno = GRUB_ERR_FILE_NOT_FOUND;
goto fail;
}
file = try_open_from_prefix (prefix, filename);
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index 4011e2d15..af3bd00d0 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -758,7 +758,7 @@ grub_dl_load (const char *name)
return 0;
if (! grub_dl_dir) {
- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
+ grub_errno = GRUB_ERR_FILE_NOT_FOUND;
return 0;
}
--
2.39.2

View File

@ -0,0 +1,34 @@
From 6237c5762edccc1e1fa4746b1d4aa5e8d81e4883 Mon Sep 17 00:00:00 2001
From: Leah Rowe <leah@libreboot.org>
Date: Sun, 5 Nov 2023 16:36:22 +0000
Subject: [PATCH 1/1] don't print error if module not found
still set grub_errno accordingly, and otherwise
behave the same. in libreboot, we remove a lot of
modules but then rely on loading a grub.cfg
provided by a distro; in almost all cases that works,
but also in almost all cases, that will try to load
a module we don't actually need, but then it prints
a message. this can annoy some users, so silence it.
Signed-off-by: Leah Rowe <leah@libreboot.org>
---
grub-core/kern/dl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index af3bd00d0..21d0cedb1 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -486,7 +486,7 @@ grub_dl_resolve_name (grub_dl_t mod, Elf_Ehdr *e)
s = grub_dl_find_section (e, ".modname");
if (!s)
- return grub_error (GRUB_ERR_BAD_MODULE, "no module name found");
+ return (grub_errno = GRUB_ERR_BAD_MODULE);
mod->name = grub_strdup ((char *) e + s->sh_offset);
if (! mod->name)
--
2.39.2

View File

@ -0,0 +1,31 @@
From e5b7ec81421487e71bcaf8b6b5a27f3649a62753 Mon Sep 17 00:00:00 2001
From: Leah Rowe <leah@libreboot.org>
Date: Sun, 5 Nov 2023 17:25:20 +0000
Subject: [PATCH 1/1] don't print empty error messages
this is part two of the quest to kill the prefix
error message. after i disabled prefix-related
messages, it still printed "error: ." on screen.
Signed-off-by: Leah Rowe <leah@libreboot.org>
---
grub-core/kern/err.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c
index 53c734de7..7cac53983 100644
--- a/grub-core/kern/err.c
+++ b/grub-core/kern/err.c
@@ -107,7 +107,8 @@ grub_print_error (void)
{
if (grub_errno != GRUB_ERR_NONE)
{
- grub_err_printf (_("error: %s.\n"), grub_errmsg);
+ if (grub_strlen(grub_errmsg) > 0)
+ grub_err_printf (_("error: %s.\n"), grub_errmsg);
grub_err_printed_errors++;
}
}
--
2.39.2

View File

@ -0,0 +1,245 @@
From 90c9011f2e0350a97e3df44b0fc6dd022e04c276 Mon Sep 17 00:00:00 2001
From: Patrick Rudolph <patrick.rudolph@9elements.com>
Date: Sun, 15 Nov 2020 19:00:27 +0100
Subject: [PATCH 1/8] grub-core/bus/usb: Parse SuperSpeed companion descriptors
Parse the SS_ENDPOINT_COMPANION descriptor, which is only present on USB 3.0
capable devices and xHCI controllers. Make the descendp an array of pointers
to the endpoint descriptor as it's no longer an continous array.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
grub-core/bus/usb/serial/common.c | 2 +-
grub-core/bus/usb/usb.c | 44 +++++++++++++++++++------------
grub-core/bus/usb/usbhub.c | 22 ++++++++++++----
grub-core/commands/usbtest.c | 2 +-
grub-core/disk/usbms.c | 2 +-
grub-core/term/usb_keyboard.c | 2 +-
include/grub/usb.h | 2 +-
include/grub/usbdesc.h | 11 +++++++-
8 files changed, 59 insertions(+), 28 deletions(-)
diff --git a/grub-core/bus/usb/serial/common.c b/grub-core/bus/usb/serial/common.c
index e9c995a0a..fc847d66d 100644
--- a/grub-core/bus/usb/serial/common.c
+++ b/grub-core/bus/usb/serial/common.c
@@ -72,7 +72,7 @@ grub_usbserial_attach (grub_usb_device_t usbdev, int configno, int interfno,
for (j = 0; j < interf->endpointcnt; j++)
{
struct grub_usb_desc_endp *endp;
- endp = &usbdev->config[0].interf[interfno].descendp[j];
+ endp = usbdev->config[0].interf[interfno].descendp[j];
if ((endp->endp_addr & 128) && (endp->attrib & 3) == 2
&& (in_endp == GRUB_USB_SERIAL_ENDPOINT_LAST_MATCHING
diff --git a/grub-core/bus/usb/usb.c b/grub-core/bus/usb/usb.c
index 7bd49d201..e578af793 100644
--- a/grub-core/bus/usb/usb.c
+++ b/grub-core/bus/usb/usb.c
@@ -118,7 +118,7 @@ grub_usb_device_initialize (grub_usb_device_t dev)
struct grub_usb_desc_device *descdev;
struct grub_usb_desc_config config;
grub_usb_err_t err;
- int i;
+ int i, j;
/* First we have to read first 8 bytes only and determine
* max. size of packet */
@@ -152,6 +152,7 @@ grub_usb_device_initialize (grub_usb_device_t dev)
int currif;
char *data;
struct grub_usb_desc *desc;
+ struct grub_usb_desc_endp *endp;
/* First just read the first 4 bytes of the configuration
descriptor, after that it is known how many bytes really have
@@ -201,24 +202,27 @@ grub_usb_device_initialize (grub_usb_device_t dev)
= (struct grub_usb_desc_if *) &data[pos];
pos += dev->config[i].interf[currif].descif->length;
+ dev->config[i].interf[currif].descendp = grub_malloc (
+ dev->config[i].interf[currif].descif->endpointcnt *
+ sizeof(struct grub_usb_desc_endp));
+
+ j = 0;
while (pos < config.totallen)
{
desc = (struct grub_usb_desc *)&data[pos];
- if (desc->type == GRUB_USB_DESCRIPTOR_ENDPOINT)
- break;
- if (!desc->length)
- {
- err = GRUB_USB_ERR_BADDEVICE;
- goto fail;
- }
- pos += desc->length;
- }
-
- /* Point to the first endpoint. */
- dev->config[i].interf[currif].descendp
- = (struct grub_usb_desc_endp *) &data[pos];
- pos += (sizeof (struct grub_usb_desc_endp)
- * dev->config[i].interf[currif].descif->endpointcnt);
+ if (desc->type == GRUB_USB_DESCRIPTOR_ENDPOINT) {
+ endp = (struct grub_usb_desc_endp *) &data[pos];
+ dev->config[i].interf[currif].descendp[j++] = endp;
+ pos += desc->length;
+ } else {
+ if (!desc->length)
+ {
+ err = GRUB_USB_ERR_BADDEVICE;
+ goto fail;
+ }
+ pos += desc->length;
+ }
+ }
}
}
@@ -226,8 +230,14 @@ grub_usb_device_initialize (grub_usb_device_t dev)
fail:
- for (i = 0; i < GRUB_USB_MAX_CONF; i++)
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++) {
+ int currif;
+
+ for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
+ grub_free (dev->config[i].interf[currif].descendp);
+
grub_free (dev->config[i].descconf);
+ }
return err;
}
diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
index f5608e330..2ae29cba1 100644
--- a/grub-core/bus/usb/usbhub.c
+++ b/grub-core/bus/usb/usbhub.c
@@ -82,8 +82,14 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
if (i == GRUB_USBHUB_MAX_DEVICES)
{
grub_error (GRUB_ERR_IO, "can't assign address to USB device");
- for (i = 0; i < GRUB_USB_MAX_CONF; i++)
- grub_free (dev->config[i].descconf);
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++) {
+ int currif;
+
+ for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
+ grub_free (dev->config[i].interf[currif].descendp);
+
+ grub_free (dev->config[i].descconf);
+ }
grub_free (dev);
return NULL;
}
@@ -96,8 +102,14 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
i, 0, 0, NULL);
if (err)
{
- for (i = 0; i < GRUB_USB_MAX_CONF; i++)
- grub_free (dev->config[i].descconf);
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++) {
+ int currif;
+
+ for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
+ grub_free (dev->config[i].interf[currif].descendp);
+
+ grub_free (dev->config[i].descconf);
+ }
grub_free (dev);
return NULL;
}
@@ -176,7 +188,7 @@ grub_usb_add_hub (grub_usb_device_t dev)
i++)
{
struct grub_usb_desc_endp *endp = NULL;
- endp = &dev->config[0].interf[0].descendp[i];
+ endp = dev->config[0].interf[0].descendp[i];
if ((endp->endp_addr & 128) && grub_usb_get_ep_type(endp)
== GRUB_USB_EP_INTERRUPT)
diff --git a/grub-core/commands/usbtest.c b/grub-core/commands/usbtest.c
index 2c6d93fe6..55a657635 100644
--- a/grub-core/commands/usbtest.c
+++ b/grub-core/commands/usbtest.c
@@ -185,7 +185,7 @@ usb_iterate (grub_usb_device_t dev, void *data __attribute__ ((unused)))
for (j = 0; j < interf->endpointcnt; j++)
{
struct grub_usb_desc_endp *endp;
- endp = &dev->config[0].interf[i].descendp[j];
+ endp = dev->config[0].interf[i].descendp[j];
grub_printf ("Endpoint #%d: %s, max packed size: %d, transfer type: %s, latency: %d\n",
endp->endp_addr & 15,
diff --git a/grub-core/disk/usbms.c b/grub-core/disk/usbms.c
index b81e3ad9d..b1512dc12 100644
--- a/grub-core/disk/usbms.c
+++ b/grub-core/disk/usbms.c
@@ -184,7 +184,7 @@ grub_usbms_attach (grub_usb_device_t usbdev, int configno, int interfno)
for (j = 0; j < interf->endpointcnt; j++)
{
struct grub_usb_desc_endp *endp;
- endp = &usbdev->config[0].interf[interfno].descendp[j];
+ endp = usbdev->config[0].interf[interfno].descendp[j];
if ((endp->endp_addr & 128) && (endp->attrib & 3) == 2)
/* Bulk IN endpoint. */
diff --git a/grub-core/term/usb_keyboard.c b/grub-core/term/usb_keyboard.c
index 7322d8dff..d590979f5 100644
--- a/grub-core/term/usb_keyboard.c
+++ b/grub-core/term/usb_keyboard.c
@@ -175,7 +175,7 @@ grub_usb_keyboard_attach (grub_usb_device_t usbdev, int configno, int interfno)
for (j = 0; j < usbdev->config[configno].interf[interfno].descif->endpointcnt;
j++)
{
- endp = &usbdev->config[configno].interf[interfno].descendp[j];
+ endp = usbdev->config[configno].interf[interfno].descendp[j];
if ((endp->endp_addr & 128) && grub_usb_get_ep_type(endp)
== GRUB_USB_EP_INTERRUPT)
diff --git a/include/grub/usb.h b/include/grub/usb.h
index 0f346af12..688c11f6d 100644
--- a/include/grub/usb.h
+++ b/include/grub/usb.h
@@ -153,7 +153,7 @@ struct grub_usb_interface
{
struct grub_usb_desc_if *descif;
- struct grub_usb_desc_endp *descendp;
+ struct grub_usb_desc_endp **descendp;
/* A driver is handling this interface. Do we need to support multiple drivers
for single interface?
diff --git a/include/grub/usbdesc.h b/include/grub/usbdesc.h
index aac5ab05a..bb2ab2e27 100644
--- a/include/grub/usbdesc.h
+++ b/include/grub/usbdesc.h
@@ -29,7 +29,8 @@ typedef enum {
GRUB_USB_DESCRIPTOR_INTERFACE,
GRUB_USB_DESCRIPTOR_ENDPOINT,
GRUB_USB_DESCRIPTOR_DEBUG = 10,
- GRUB_USB_DESCRIPTOR_HUB = 0x29
+ GRUB_USB_DESCRIPTOR_HUB = 0x29,
+ GRUB_USB_DESCRIPTOR_SS_ENDPOINT_COMPANION = 0x30
} grub_usb_descriptor_t;
struct grub_usb_desc
@@ -105,6 +106,14 @@ struct grub_usb_desc_endp
grub_uint8_t interval;
} GRUB_PACKED;
+struct grub_usb_desc_ssep {
+ grub_uint8_t length;
+ grub_uint8_t type;
+ grub_uint8_t maxburst;
+ grub_uint8_t attrib;
+ grub_uint16_t interval;
+} GRUB_PACKED;
+
struct grub_usb_desc_str
{
grub_uint8_t length;
--
2.39.2

View File

@ -0,0 +1,29 @@
From e111983ca5e2a52bfe2bdc5cd639b06bb2f7902d Mon Sep 17 00:00:00 2001
From: Patrick Rudolph <patrick.rudolph@9elements.com>
Date: Sun, 15 Nov 2020 19:47:06 +0100
Subject: [PATCH 2/8] usb: Add enum for xHCI
Will be used in future patches.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
include/grub/usb.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/grub/usb.h b/include/grub/usb.h
index 688c11f6d..ea6ee8c2c 100644
--- a/include/grub/usb.h
+++ b/include/grub/usb.h
@@ -51,7 +51,8 @@ typedef enum
GRUB_USB_SPEED_NONE,
GRUB_USB_SPEED_LOW,
GRUB_USB_SPEED_FULL,
- GRUB_USB_SPEED_HIGH
+ GRUB_USB_SPEED_HIGH,
+ GRUB_USB_SPEED_SUPER
} grub_usb_speed_t;
typedef int (*grub_usb_iterate_hook_t) (grub_usb_device_t dev, void *data);
--
2.39.2

View File

@ -0,0 +1,33 @@
From 3e25c83a1d1c6e149c7e9f0660ddadb2beca2476 Mon Sep 17 00:00:00 2001
From: Patrick Rudolph <patrick.rudolph@9elements.com>
Date: Sun, 15 Nov 2020 19:48:03 +0100
Subject: [PATCH 3/8] usbtrans: Set default maximum packet size
Set the maximum packet size to 512 for SuperSpeed devices.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
grub-core/bus/usb/usbtrans.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c
index c5680b33a..c1080bb33 100644
--- a/grub-core/bus/usb/usbtrans.c
+++ b/grub-core/bus/usb/usbtrans.c
@@ -128,8 +128,12 @@ grub_usb_control_msg (grub_usb_device_t dev,
setupdata_addr = grub_dma_get_phys (setupdata_chunk);
/* Determine the maximum packet size. */
- if (dev->descdev.maxsize0)
+ if (dev->descdev.maxsize0 && dev->speed != GRUB_USB_SPEED_SUPER)
max = dev->descdev.maxsize0;
+ else if (dev->descdev.maxsize0 && dev->speed == GRUB_USB_SPEED_SUPER)
+ max = 1UL << dev->descdev.maxsize0;
+ else if (dev->speed == GRUB_USB_SPEED_SUPER)
+ max = 512;
else
max = 64;
--
2.39.2

View File

@ -0,0 +1,121 @@
From 89701aba00caa81bb566ab10da0c89264393be30 Mon Sep 17 00:00:00 2001
From: Patrick Rudolph <patrick.rudolph@9elements.com>
Date: Sun, 15 Nov 2020 19:51:42 +0100
Subject: [PATCH 4/8] grub-core/bus/usb: Add function pointer for attach/detach
events
The xHCI code needs to be called for attaching or detaching a device.
Introduce two functions pointers and call it from the USB hub code.
Will be used in future commits, currently this doesn't change any functionality.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
grub-core/bus/usb/ehci.c | 2 ++
grub-core/bus/usb/ohci.c | 2 ++
grub-core/bus/usb/uhci.c | 2 ++
grub-core/bus/usb/usbhub.c | 19 +++++++++++++++++++
include/grub/usb.h | 4 ++++
5 files changed, 29 insertions(+)
diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c
index 9abebc6bd..953b851c0 100644
--- a/grub-core/bus/usb/ehci.c
+++ b/grub-core/bus/usb/ehci.c
@@ -1812,6 +1812,8 @@ static struct grub_usb_controller_dev usb_controller = {
.hubports = grub_ehci_hubports,
.portstatus = grub_ehci_portstatus,
.detect_dev = grub_ehci_detect_dev,
+ .attach_dev = NULL,
+ .detach_dev = NULL,
/* estimated max. count of TDs for one bulk transfer */
.max_bulk_tds = GRUB_EHCI_N_TD * 3 / 4
};
diff --git a/grub-core/bus/usb/ohci.c b/grub-core/bus/usb/ohci.c
index 5363a61f6..7a3f3e154 100644
--- a/grub-core/bus/usb/ohci.c
+++ b/grub-core/bus/usb/ohci.c
@@ -1440,6 +1440,8 @@ static struct grub_usb_controller_dev usb_controller =
.hubports = grub_ohci_hubports,
.portstatus = grub_ohci_portstatus,
.detect_dev = grub_ohci_detect_dev,
+ .attach_dev = NULL,
+ .detach_dev = NULL,
/* estimated max. count of TDs for one bulk transfer */
.max_bulk_tds = GRUB_OHCI_TDS * 3 / 4
};
diff --git a/grub-core/bus/usb/uhci.c b/grub-core/bus/usb/uhci.c
index 0fdea4c1e..03c4605b2 100644
--- a/grub-core/bus/usb/uhci.c
+++ b/grub-core/bus/usb/uhci.c
@@ -845,6 +845,8 @@ static struct grub_usb_controller_dev usb_controller =
.hubports = grub_uhci_hubports,
.portstatus = grub_uhci_portstatus,
.detect_dev = grub_uhci_detect_dev,
+ .attach_dev = NULL,
+ .detach_dev = NULL,
/* estimated max. count of TDs for one bulk transfer */
.max_bulk_tds = N_TD * 3 / 4
};
diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
index 2ae29cba1..8e963e84b 100644
--- a/grub-core/bus/usb/usbhub.c
+++ b/grub-core/bus/usb/usbhub.c
@@ -66,6 +66,15 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
dev->split_hubport = split_hubport;
dev->split_hubaddr = split_hubaddr;
+ if (controller->dev->attach_dev) {
+ err = controller->dev->attach_dev (controller, dev);
+ if (err)
+ {
+ grub_free (dev);
+ return NULL;
+ }
+ }
+
err = grub_usb_device_initialize (dev);
if (err)
{
@@ -405,6 +414,8 @@ static void
detach_device (grub_usb_device_t dev)
{
unsigned i;
+ grub_usb_err_t err;
+
int k;
if (!dev)
return;
@@ -425,6 +436,14 @@ detach_device (grub_usb_device_t dev)
if (inter && inter->detach_hook)
inter->detach_hook (dev, i, k);
}
+ if (dev->controller.dev->detach_dev) {
+ err = dev->controller.dev->detach_dev (&dev->controller, dev);
+ if (err)
+ {
+ // XXX
+ }
+ }
+
grub_usb_devs[dev->addr] = 0;
}
diff --git a/include/grub/usb.h b/include/grub/usb.h
index ea6ee8c2c..4dd179db2 100644
--- a/include/grub/usb.h
+++ b/include/grub/usb.h
@@ -126,6 +126,10 @@ struct grub_usb_controller_dev
grub_usb_speed_t (*detect_dev) (grub_usb_controller_t dev, int port, int *changed);
+ grub_usb_err_t (*attach_dev) (grub_usb_controller_t ctrl, grub_usb_device_t dev);
+
+ grub_usb_err_t (*detach_dev) (grub_usb_controller_t ctrl, grub_usb_device_t dev);
+
/* Per controller flag - port reset pending, don't do another reset */
grub_uint64_t pending_reset;
--
2.39.2

View File

@ -0,0 +1,77 @@
From 5e5d74a4531770258e21dedd45c33f1a9d3afa6b Mon Sep 17 00:00:00 2001
From: Patrick Rudolph <patrick.rudolph@9elements.com>
Date: Sun, 15 Nov 2020 19:54:40 +0100
Subject: [PATCH 5/8] grub-core/bus/usb/usbhub: Add new private fields for xHCI
controller
Store the root port number, the route, consisting out of the port ID
in each nibble, and a pointer to driver private data.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
grub-core/bus/usb/usbhub.c | 11 ++++++++---
include/grub/usb.h | 5 +++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
index 8e963e84b..b4b3a1a61 100644
--- a/grub-core/bus/usb/usbhub.c
+++ b/grub-core/bus/usb/usbhub.c
@@ -49,7 +49,9 @@ static grub_usb_controller_dev_t grub_usb_list;
static grub_usb_device_t
grub_usb_hub_add_dev (grub_usb_controller_t controller,
grub_usb_speed_t speed,
- int split_hubport, int split_hubaddr)
+ int split_hubport, int split_hubaddr,
+ int root_portno,
+ grub_uint32_t route)
{
grub_usb_device_t dev;
int i;
@@ -65,6 +67,8 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
dev->speed = speed;
dev->split_hubport = split_hubport;
dev->split_hubaddr = split_hubaddr;
+ dev->root_port = root_portno;
+ dev->route = route;
if (controller->dev->attach_dev) {
err = controller->dev->attach_dev (controller, dev);
@@ -245,7 +249,7 @@ attach_root_port (struct grub_usb_hub *hub, int portno,
and full/low speed device connected to OHCI/UHCI needs not
transaction translation - e.g. hubport and hubaddr should be
always none (zero) for any device connected to any root hub. */
- dev = grub_usb_hub_add_dev (hub->controller, speed, 0, 0);
+ dev = grub_usb_hub_add_dev (hub->controller, speed, 0, 0, portno, 0);
hub->controller->dev->pending_reset = 0;
npending--;
if (! dev)
@@ -676,7 +680,8 @@ poll_nonroot_hub (grub_usb_device_t dev)
/* Add the device and assign a device address to it. */
next_dev = grub_usb_hub_add_dev (&dev->controller, speed,
- split_hubport, split_hubaddr);
+ split_hubport, split_hubaddr, dev->root_port,
+ dev->route << 4 | (i & 0xf));
if (dev->controller.dev->pending_reset)
{
dev->controller.dev->pending_reset = 0;
diff --git a/include/grub/usb.h b/include/grub/usb.h
index 4dd179db2..609faf7d0 100644
--- a/include/grub/usb.h
+++ b/include/grub/usb.h
@@ -237,6 +237,11 @@ struct grub_usb_device
int split_hubport;
int split_hubaddr;
+
+ /* xHCI specific information */
+ int root_port;
+ grub_uint32_t route;
+ void *xhci_priv;
};
--
2.39.2

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,127 @@
From 2a2c64f6ea62337c1263a70f6ca9a9bade66b78b Mon Sep 17 00:00:00 2001
From: Patrick Rudolph <patrick.rudolph@9elements.com>
Date: Thu, 3 Dec 2020 13:44:55 +0100
Subject: [PATCH 7/8] grub-core/bus/usb/usbhub: Add xHCI non root hub support
Tested on Intel PCH C246, the USB3 hub can be configured by grub.
Issues:
* USB3 devices connected behind that hub are sometimes not detected.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
grub-core/bus/usb/usbhub.c | 38 +++++++++++++++++++++++++++++++++-----
include/grub/usbdesc.h | 1 +
include/grub/usbtrans.h | 4 ++++
3 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
index b4b3a1a61..e96505aa9 100644
--- a/grub-core/bus/usb/usbhub.c
+++ b/grub-core/bus/usb/usbhub.c
@@ -148,19 +148,32 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
return dev;
}
-
+static grub_usb_err_t
+grub_usb_set_hub_depth(grub_usb_device_t dev, grub_uint8_t depth)
+{
+ return grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_DEV),
+ GRUB_USB_HUB_REQ_SET_HUB_DEPTH, depth,
+ 0, 0, NULL);
+}
+
static grub_usb_err_t
grub_usb_add_hub (grub_usb_device_t dev)
{
struct grub_usb_usb_hubdesc hubdesc;
grub_usb_err_t err;
+ grub_uint16_t req;
int i;
+ req = (dev->speed == GRUB_USB_SPEED_SUPER) ? GRUB_USB_DESCRIPTOR_SS_HUB :
+ GRUB_USB_DESCRIPTOR_HUB;
+
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
| GRUB_USB_REQTYPE_CLASS
| GRUB_USB_REQTYPE_TARGET_DEV),
- GRUB_USB_REQ_GET_DESCRIPTOR,
- (GRUB_USB_DESCRIPTOR_HUB << 8) | 0,
+ GRUB_USB_REQ_GET_DESCRIPTOR,
+ (req << 8) | 0,
0, sizeof (hubdesc), (char *) &hubdesc);
if (err)
return err;
@@ -183,6 +196,19 @@ grub_usb_add_hub (grub_usb_device_t dev)
return GRUB_USB_ERR_INTERNAL;
}
+ if (dev->speed == GRUB_USB_SPEED_SUPER)
+ {
+ grub_uint8_t depth;
+ grub_uint32_t route;
+ /* Depth maximum value is 5, but root hubs doesn't count */
+ for (depth = 0, route = dev->route; (route & 0xf) > 0; route >>= 4)
+ depth++;
+
+ err = grub_usb_set_hub_depth(dev, depth);
+ if (err)
+ return err;
+ }
+
/* Power on all Hub ports. */
for (i = 1; i <= hubdesc.portcnt; i++)
{
@@ -637,7 +663,9 @@ poll_nonroot_hub (grub_usb_device_t dev)
int split_hubaddr = 0;
/* Determine the device speed. */
- if (status & GRUB_USB_HUB_STATUS_PORT_LOWSPEED)
+ if (dev->speed == GRUB_USB_SPEED_SUPER)
+ speed = GRUB_USB_SPEED_SUPER;
+ else if (status & GRUB_USB_HUB_STATUS_PORT_LOWSPEED)
speed = GRUB_USB_SPEED_LOW;
else
{
@@ -651,7 +679,7 @@ poll_nonroot_hub (grub_usb_device_t dev)
grub_millisleep (10);
/* Find correct values for SPLIT hubport and hubaddr */
- if (speed == GRUB_USB_SPEED_HIGH)
+ if (speed == GRUB_USB_SPEED_HIGH || speed == GRUB_USB_SPEED_SUPER)
{
/* HIGH speed device needs not transaction translation */
split_hubport = 0;
diff --git a/include/grub/usbdesc.h b/include/grub/usbdesc.h
index bb2ab2e27..1697aa465 100644
--- a/include/grub/usbdesc.h
+++ b/include/grub/usbdesc.h
@@ -30,6 +30,7 @@ typedef enum {
GRUB_USB_DESCRIPTOR_ENDPOINT,
GRUB_USB_DESCRIPTOR_DEBUG = 10,
GRUB_USB_DESCRIPTOR_HUB = 0x29,
+ GRUB_USB_DESCRIPTOR_SS_HUB = 0x2a,
GRUB_USB_DESCRIPTOR_SS_ENDPOINT_COMPANION = 0x30
} grub_usb_descriptor_t;
diff --git a/include/grub/usbtrans.h b/include/grub/usbtrans.h
index 039ebed65..d6c3f71dc 100644
--- a/include/grub/usbtrans.h
+++ b/include/grub/usbtrans.h
@@ -110,6 +110,10 @@ enum
GRUB_USB_REQ_SET_INTERFACE = 0x0B,
GRUB_USB_REQ_SYNC_FRAME = 0x0C
};
+enum
+ {
+ GRUB_USB_HUB_REQ_SET_HUB_DEPTH = 0x0C,
+ };
#define GRUB_USB_FEATURE_ENDP_HALT 0x00
#define GRUB_USB_FEATURE_DEV_REMOTE_WU 0x01
--
2.39.2

View File

@ -0,0 +1,90 @@
From 871d768f8c5c960cb0d9761a9028b16882e1a7d3 Mon Sep 17 00:00:00 2001
From: Patrick Rudolph <patrick.rudolph@9elements.com>
Date: Wed, 24 Feb 2021 08:25:41 +0100
Subject: [PATCH 8/8] Fix compilation on x86_64
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
grub-core/bus/usb/xhci.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/grub-core/bus/usb/xhci.c b/grub-core/bus/usb/xhci.c
index f4591ffb5..3495bb919 100644
--- a/grub-core/bus/usb/xhci.c
+++ b/grub-core/bus/usb/xhci.c
@@ -184,7 +184,7 @@ enum
* then we can get it from a trb pointer (provided by evt ring).
*/
#define XHCI_RING(_trb) \
- ((struct grub_xhci_ring*)((grub_uint32_t)(_trb) & ~(GRUB_XHCI_RING_SIZE-1)))
+ ((struct grub_xhci_ring*)((grub_addr_t)(_trb) & ~(GRUB_XHCI_RING_SIZE-1)))
/* slot context */
struct grub_xhci_slotctx {
@@ -495,6 +495,14 @@ grub_xhci_read8(volatile void *addr) {
return (*((volatile grub_uint32_t *)addr));
}
+static inline void *
+grub_xhci_read_etrb_ptr(volatile struct grub_xhci_trb *trb) {
+ grub_uint64_t tmp;
+ tmp = (grub_uint64_t)grub_xhci_read32(&trb->ptr_low);
+ tmp |= ((grub_uint64_t)grub_xhci_read32(&trb->ptr_high)) << 32;
+ return (void *)(grub_addr_t)tmp;
+}
+
static inline grub_uint32_t
grub_xhci_port_read (struct grub_xhci *x, grub_uint32_t port)
{
@@ -664,7 +672,7 @@ static void xhci_process_events(struct grub_xhci *x)
case ER_TRANSFER:
case ER_COMMAND_COMPLETE:
{
- struct grub_xhci_trb *rtrb = (void*)grub_xhci_read32(&etrb->ptr_low);
+ struct grub_xhci_trb *rtrb = grub_xhci_read_etrb_ptr(etrb);
struct grub_xhci_ring *ring = XHCI_RING(rtrb);
volatile struct grub_xhci_trb *evt = &ring->evt;
grub_uint32_t eidx = rtrb - ring->ring + 1;
@@ -697,9 +705,9 @@ static void xhci_process_events(struct grub_xhci *x)
}
grub_xhci_write32(&evts->nidx, nidx);
volatile struct grub_xhci_ir *ir = x->ir;
- grub_uint32_t erdp = (grub_uint32_t)(evts->ring + nidx);
- grub_xhci_write32(&ir->erdp_low, erdp);
- grub_xhci_write32(&ir->erdp_high, 0);
+ grub_uint64_t erdp = (grub_addr_t)(void *)(&evts->ring[nidx]);
+ grub_xhci_write32(&ir->erdp_low, erdp & 0xffffffff);
+ grub_xhci_write32(&ir->erdp_high, erdp >> 32);
}
}
@@ -800,7 +808,7 @@ static void xhci_trb_queue(volatile struct grub_xhci_ring *ring,
grub_uint32_t xferlen, grub_uint32_t flags)
{
grub_dprintf("xhci", "%s: ring %p data %llx len %d flags 0x%x remain 0x%x\n", __func__,
- ring, data_or_addr, xferlen & 0x1ffff, flags, xferlen >> 17);
+ ring, (unsigned long long)data_or_addr, xferlen & 0x1ffff, flags, xferlen >> 17);
if (xhci_ring_full(ring))
{
@@ -1907,7 +1915,7 @@ grub_xhci_setup_transfer (grub_usb_controller_t dev,
if (transfer->type == GRUB_USB_TRANSACTION_TYPE_CONTROL)
{
volatile struct grub_usb_packet_setup *setupdata;
- setupdata = (void *)transfer->transactions[0].data;
+ setupdata = (void *)(grub_addr_t)transfer->transactions[0].data;
grub_dprintf("xhci", "%s: CONTROLL TRANS req %d\n", __func__, setupdata->request);
grub_dprintf("xhci", "%s: CONTROLL TRANS length %d\n", __func__, setupdata->length);
@@ -1974,7 +1982,7 @@ grub_xhci_setup_transfer (grub_usb_controller_t dev,
/* Assume the ring has enough free space for all TRBs */
if (flags & TRB_TR_IDT && tr->size <= (int)sizeof(inline_data))
{
- grub_memcpy(&inline_data, (void *)tr->data, tr->size);
+ grub_memcpy(&inline_data, (void *)(grub_addr_t)tr->data, tr->size);
xhci_trb_queue(reqs, inline_data, tr->size, flags);
}
else
--
2.39.2

View File

@ -1,3 +1,5 @@
tree="xhci"
rev="8719cc2040368d43ab2de0b6e1b850b2c9cfc5b7"
bootstrapargs="--gnulib-srcdir=gnulib/ --no-git" bootstrapargs="--gnulib-srcdir=gnulib/ --no-git"
autoconfargs="--with-platform=coreboot --disable-werror" autoconfargs="--with-platform=coreboot --disable-werror"
makeargs="FS_PAYLOAD_MODULES=\"\"" makeargs="FS_PAYLOAD_MODULES=\"\""

View File

@ -0,0 +1,3 @@
subrepo="git://git.sv.gnu.org/gnulib"
subrepo_bkup="https://codeberg.org/libreboot/gnulib"
subrev="9f48fb992a3d7e96610c4ce8be969cff2d61a01b"

View File

@ -0,0 +1 @@
gnulib

View File

@ -0,0 +1,3 @@
subrepo="git://git.sv.gnu.org/gnulib"
subrepo_bkup="https://codeberg.org/libreboot/gnulib"
subrev="9f48fb992a3d7e96610c4ce8be969cff2d61a01b"

View File

@ -0,0 +1 @@
gnulib

View File

@ -103,17 +103,17 @@ git_prep()
prep_submodules() prep_submodules()
{ {
[ -f "$tmpgit/.gitmodules" ] || return 0
mdir="$PWD/config/submodule/$project" mdir="$PWD/config/submodule/$project"
[ -n "$tree" ] && mdir="$mdir/$tree" [ -n "$tree" ] && mdir="$mdir/$tree"
if [ -f "$mdir/module.list" ]; then if [ -f "$mdir/module.list" ]; then
cat "$mdir/module.list" > "$tmpdir/modules" || \ cat "$mdir/module.list" > "$tmpdir/modules" || \
$err "!cp $mdir/module.list $tmpdir/modules" $err "!cp $mdir/module.list $tmpdir/modules"
else elif [ -f "$tmpgit/.gitmodules" ]; then
git -C "$tmpgit" submodule status | awk '{print $2}' > \ git -C "$tmpgit" submodule status | awk '{print $2}' > \
"$tmpdir/modules" || $err "$mdir: cannot list submodules" "$tmpdir/modules" || $err "$mdir: cannot list submodules"
else
return 0
fi fi
while read -r msrcdir; do while read -r msrcdir; do

View File

@ -11,10 +11,8 @@ cbdir="src/coreboot/default"
cbcfgsdir="config/coreboot" cbcfgsdir="config/coreboot"
ifdtool="cbutils/default/ifdtool" ifdtool="cbutils/default/ifdtool"
cbfstool="cbutils/default/cbfstool" cbfstool="cbutils/default/cbfstool"
grubcfgsdir="config/grub"
layoutdir="/boot/grub/layouts"
. "$grubcfgsdir/modules.list"
tmpgit="$PWD/tmp/gitclone" tmpgit="$PWD/tmp/gitclone"
grubdata="config/data/grub"
err="err_" err="err_"
err_() err_()

View File

@ -12,7 +12,6 @@ set -u -e
seavgabiosrom="elf/seabios/default/libgfxinit/vgabios.bin" seavgabiosrom="elf/seabios/default/libgfxinit/vgabios.bin"
grub_background="background1280x800.png" grub_background="background1280x800.png"
grubelf="elf/grub/grub.elf"
cfgsdir="config/coreboot" cfgsdir="config/coreboot"
picosrc="src/pico-serprog" picosrc="src/pico-serprog"
picosdk="src/pico-sdk" picosdk="src/pico-sdk"
@ -23,7 +22,7 @@ stm32src="src/stm32-vserprog"
pv="payload_uboot payload_grub_withseabios payload_seabios payload_memtest t" pv="payload_uboot payload_grub_withseabios payload_seabios payload_memtest t"
pv="$pv payload_seabios_withgrub payload_seabios_grubonly payload_grub mt86bin" pv="$pv payload_seabios_withgrub payload_seabios_grubonly payload_grub mt86bin"
v="romdir cbrom initmode displaymode cbcfg targetdir tree keymaps release" v="romdir cbrom initmode displaymode cbcfg targetdir tree keymaps release"
v="$v grub_timeout ubdir board grub_scan_disk uboot_config" v="$v grub_timeout ubdir board grub_scan_disk uboot_config grubtree grubelf"
eval "$(setvars "n" $pv serprog)" eval "$(setvars "n" $pv serprog)"
eval "$(setvars "" $v boards _displaymode _payload _keyboard all targets \ eval "$(setvars "" $v boards _displaymode _payload _keyboard all targets \
serprog_boards_dir _scandisk)" serprog_boards_dir _scandisk)"
@ -172,6 +171,9 @@ configure_target()
[ -z "$_grub_scan_disk" ] && _grub_scan_disk="nvme ahci ata" [ -z "$_grub_scan_disk" ] && _grub_scan_disk="nvme ahci ata"
grub_scan_disk="${_grub_scan_disk# }" grub_scan_disk="${_grub_scan_disk# }"
[ -n "$grubtree" ] || grubtree="default"
grubelf="elf/grub/$grubtree/payload/grub.elf"
[ -z "$tree" ] && $err "$board: tree not defined" [ -z "$tree" ] && $err "$board: tree not defined"
[ "$payload_memtest" != "y" ] && payload_memtest="n" [ "$payload_memtest" != "y" ] && payload_memtest="n"
@ -225,24 +227,14 @@ build_payloads()
build_grub_payload() build_grub_payload()
{ {
x_ mkdir -p elf/grub for keymapfile in "$grubdata/keymap/"*.gkb; do
for keymapfile in config/grub/keymap/*.gkb; do
[ -f "$keymapfile" ] && keymaps="$keymaps $keymapfile" [ -f "$keymapfile" ] && keymaps="$keymaps $keymapfile"
done done
[ -z "$_keyboard" ] || [ -f "$grubcfgsdir/keymap/$_keyboard.gkb" ] || \ [ -z "$_keyboard" ] || [ -f "$grubdata/keymap/$_keyboard.gkb" ] || \
$err "build_grub_payload: $_keyboard layout not defined" $err "build_grub_payload: $_keyboard layout not defined"
[ -n "$_keyboard" ] && keymaps="$grubcfgsdir/keymap/$_keyboard.gkb" [ -n "$_keyboard" ] && keymaps="$grubdata/keymap/$_keyboard.gkb"
[ -f "$grubelf" ] && return 0
[ -f "src/grub/grub-mkstandalone" ] || x_ ./update trees -b grub
./src/grub/grub-mkstandalone --grub-mkimage="src/grub/grub-mkimage" \ [ -f "$grubelf" ] || x_ ./update trees -b grub $grubtree; return 0
-O i386-coreboot -o "elf/grub/grub.elf" -d "src/grub/grub-core/" \
--fonts= --themes= --locales= --modules="$grub_modules" \
--install-modules="$grub_install_modules" \
"/boot/grub/grub.cfg=$grubcfgsdir/config/grub_memdisk.cfg" \
"/boot/grub/grub_default.cfg=$grubcfgsdir/config/grub.cfg" || \
$err "could not generate grub.elf"
} }
build_uboot_payload() build_uboot_payload()
@ -343,7 +335,7 @@ build_grub_roms()
# we only need insert background.png once, for each coreboot config: # we only need insert background.png once, for each coreboot config:
if [ "$displaymode" = "vesafb" ] || \ if [ "$displaymode" = "vesafb" ] || \
[ "$displaymode" = "corebootfb" ]; then [ "$displaymode" = "corebootfb" ]; then
backgroundfile="config/grub/background/$grub_background" backgroundfile="$grubdata/background/$grub_background"
"$cbfstool" "$tmprom" add -f "$backgroundfile" -n \ "$cbfstool" "$tmprom" add -f "$backgroundfile" -n \
background.png -t raw || $err "!bg, $backgroundfile" background.png -t raw || $err "!bg, $backgroundfile"
fi fi
@ -376,7 +368,7 @@ build_grub_roms()
if [ "$payload_seabios_withgrub" = "y" ] && \ if [ "$payload_seabios_withgrub" = "y" ] && \
[ "$payload1" != "grub" ]; then [ "$payload1" != "grub" ]; then
x_ "$cbfstool" "$tmpgrubrom" add \ x_ "$cbfstool" "$tmpgrubrom" add \
-f "config/grub/bootorder" -n bootorder -t raw -f "$grubdata/bootorder" -n bootorder -t raw
x_ cprom "$tmpgrubrom" "${newrom%.rom}_grubfirst.rom" x_ cprom "$tmpgrubrom" "${newrom%.rom}_grubfirst.rom"
if [ "$payload_seabios_grubonly" = "y" ]; then if [ "$payload_seabios_grubonly" = "y" ]; then
x_ "$cbfstool" "$tmpgrubrom" add-int -i 0 \ x_ "$cbfstool" "$tmpgrubrom" add-int -i 0 \

View File

@ -178,9 +178,12 @@ check_config()
handle_makefile() handle_makefile()
{ {
x_ make clean -C "$cdir" && x_ cp "$config" "$cdir/.config" [ "$project" = "grub" ] && [ "${mode%config}" != "$mode" ] && return 0
[ -n "$mode" ] || make -C "$cdir" silentoldconfig || \
make -C "$cdir" oldconfig || : check_makefile "$cdir" && x_ make clean -C "$cdir"
x_ cp "$config" "$cdir/.config"
[ -n "$mode" ] || [ "$project" = "grub" ] || make -C "$cdir" \
silentoldconfig || make -C "$cdir" oldconfig || :
run_make_command || $err "handle_makefile $cdir: no makefile!" run_make_command || $err "handle_makefile $cdir: no makefile!"
@ -204,6 +207,8 @@ run_make_command()
make -C "$cdir" $mode -j$threads $makeargs || $err "!mk $cdir $mode" make -C "$cdir" $mode -j$threads $makeargs || $err "!mk $cdir $mode"
[ "$project" = "grub" ] && [ -z "$mode" ] && mkpayload_grub
[ "$mode" != "clean" ] && return 0 [ "$mode" != "clean" ] && return 0
make -C "$cdir" distclean 2>/dev/null || : make -C "$cdir" distclean 2>/dev/null || :
} }
@ -232,6 +237,25 @@ check_makefile()
[ -f "$1/GNUmakefile" ] || return 1; return 0 [ -f "$1/GNUmakefile" ] || return 1; return 0
} }
mkpayload_grub()
{
[ -f "$grubdata/module/$tree" ] || $err "$tree: grub modules missing"
x_ rm -f "$cdir/grub.elf"
eval "$(setvars "" grub_modules grub_install_modules)"
. "$grubdata/module/$tree" || $err "$tree: !source grub modules"
[ -z "$grub_install_modules" ] && $err "$tree: install modules unset"
[ -z "$grub_modules" ] && $err "$tree: modules unset"
"${cdir}/grub-mkstandalone" --grub-mkimage="${cdir}/grub-mkimage" \
-O i386-coreboot -o "${cdir}/grub.elf" -d "${cdir}/grub-core/" \
--fonts= --themes= --locales= --modules="$grub_modules" \
--install-modules="$grub_install_modules" \
"/boot/grub/grub.cfg=${cdir}/.config" || $err "$tree: !mkgrub"
}
copy_elf() copy_elf()
{ {
while read -r f; do while read -r f; do