Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions buildipxe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ cp ${FOGDIR}/src/ipxescript10sec .
cp ${FOGDIR}/src/config/general.h config/
cp ${FOGDIR}/src/config/settings.h config/
cp ${FOGDIR}/src/config/console.h config/
# For BIOS builds, disable USB_HCD_USBIO as it's EFI-specific
sed -i 's+#define USB_HCD_USBIO+//#define USB_HCD_USBIO+g' config/usb.h
# USB settings go in as an overlaid config/local/usb.h, which upstream's
# config/usb.h includes last so our values win. This used to be a sed against
# upstream's file; see src-efi/config/local/usb.h for why that had to go.
mkdir -p config/local
cp ${FOGDIR}/src/config/local/usb.h config/local/

# Build the files
make -j$(nproc) EMBED=ipxescript bin/ipxe.iso bin/{undionly,ipxe,intel,realtek}.{,k,kk}pxe bin/ipxe.lkrn bin/ipxe.usb ${BUILDOPTS}
Expand Down Expand Up @@ -130,10 +133,12 @@ cp ${FOGDIR}/src-efi/ipxescript10sec .
cp ${FOGDIR}/src-efi/config/general.h config/
cp ${FOGDIR}/src-efi/config/settings.h config/
cp ${FOGDIR}/src-efi/config/console.h config/
# For EFI builds, enable USB_HCD_USBIO for keyboard support and disable conflicting USB_EFI
sed -i 's+//#define USB_HCD_USBIO+#define USB_HCD_USBIO+g' config/usb.h
sed -i 's+//#undef USB_KEYBOARD+#define USB_KEYBOARD+g' config/usb.h
sed -i 's+//#undef USB_EFI+#undef USB_EFI+g' config/usb.h
# USB keyboard support. Overlaid rather than sed-patched into upstream's
# config/usb.h -- v2.0.0 restructured that file and every sed pattern silently
# stopped matching, which is what broke the keyboard on ipxe.efi. See
# src-efi/config/local/usb.h.
mkdir -p config/local
cp ${FOGDIR}/src-efi/config/local/usb.h config/local/

# Build the files
make -j$(nproc) EMBED=ipxescript bin-{i386,x86_64}-efi/{snp{,only},ipxe,intel,realtek}.efi ${BUILDOPTS}
Expand Down
42 changes: 42 additions & 0 deletions src-efi/config/local/usb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef CONFIG_LOCAL_USB_H
#define CONFIG_LOCAL_USB_H

/** @file
*
* FOG USB configuration overrides for EFI builds
*
* upstream's config/usb.h includes this file last, after its own
* PLATFORM_efi block, so everything here wins. That is the whole reason it
* exists: buildipxe.sh used to patch these same three settings with sed
* against upstream's config/usb.h, and when v2.0.0 restructured that file --
* one space where there had been a tab, "#undef USB_KEYBOARD" active rather
* than commented out -- all three patterns stopped matching and silently did
* nothing. Every published EFI binary was then built with upstream's defaults
* instead of FOG's, which is what killed the keyboard on ipxe.efi
* (forums #18213). An overlaid file cannot half-apply the way a sed pattern
* can, so the next upstream refresh can only ever break this loudly.
*
*/

/* Drive the USB keyboard ourselves rather than relying on the firmware's.
*
* ipxe.efi carries the native xHCI/EHCI/UHCI drivers and efi_driver_connect_all()
* binds them, which takes the controller away from the firmware and with it the
* firmware's SimpleTextInput. Upstream's default for EFI is to leave USB_KEYBOARD
* undefined and re-expose the devices through USB_EFI so the firmware's own
* keyboard driver can re-bind on top; on hardware where that re-bind does not
* happen (Lenovo M70t/M80t Gen3, and this is not a new class of firmware bug)
* there is then no keyboard driver at all and the machine is unusable at the
* boot menu. snponly.efi is unaffected either way -- it has no native host
* controller drivers, so the firmware keeps USB.
*
* This is the configuration FOG shipped and tested for years, restored rather
* than invented. USB_HCD_USBIO is upstream-labelled "very slow", which it is,
* but it only ever drives the keyboard, and correctness at a boot menu beats
* throughput.
*/
#define USB_HCD_USBIO /* EFI USB pseudo-host controller */
#define USB_KEYBOARD /* USB keyboards */
#undef USB_EFI /* Conflicts with driving USB ourselves */

#endif /* CONFIG_LOCAL_USB_H */
26 changes: 26 additions & 0 deletions src/config/local/usb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef CONFIG_LOCAL_USB_H
#define CONFIG_LOCAL_USB_H

/** @file
*
* FOG USB configuration overrides for BIOS builds
*
* See src-efi/config/local/usb.h for why these settings are overlaid here
* rather than patched into upstream's config/usb.h with sed.
*
*/

/* USB_HCD_USBIO is an EFI construct -- it drives USB through
* EFI_USB_IO_PROTOCOL -- and has no meaning in a legacy BIOS build.
*
* As of v2.0.0 upstream only defines it inside a PLATFORM_efi block, so a BIOS
* build cannot pick it up by accident and this line is belt-and-braces. It is
* kept anyway because the sed it replaces was load-bearing against an older
* upstream layout that did define it unconditionally, and a standing #undef
* holds whichever way a future refresh moves the default. The alternative is
* depending on upstream's current arrangement staying put, which is the
* assumption that produced forums #18213 in the first place.
*/
#undef USB_HCD_USBIO

#endif /* CONFIG_LOCAL_USB_H */
Loading