aboutsummaryrefslogtreecommitdiffstats
path: root/src/hci
Commit message (Collapse)AuthorAgeFilesLines
* [menu] Allow a post-activity timeout to be definedHEADmastercoverity_scanMichael Brown4 days2-8/+18
| | | | | | | | | Allow the "--retimeout" option to be used to specify a timeout value that will be (re)applied after each keypress activity. This allows script authors to ensure that a single (potentially accidental) keypress will not pause the boot process indefinitely. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Add "usbscan" command for iterating over USB devicesMichael Brown2024-10-171-0/+122
| | | | | | | | Implement a "usbscan" command as a direct analogy of the existing "pciscan" command, allowing scripts to iterate over all detected USB devices. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [image] Add the "imgdecrypt" commandMichael Brown2024-08-291-0/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the "imgdecrypt" command that can be used to decrypt a detached encrypted data image using a cipher key obtained from a separate CMS envelope image. For example: # Create non-detached encrypted CMS messages # openssl cms -encrypt -binary -aes-256-gcm -recip client.crt \ -in vmlinuz -outform DER -out vmlinuz.cms openssl cms -encrypt -binary -aes-256-gcm -recip client.crt \ -in initrd.img -outform DER -out initrd.img.cms # Detach data from envelopes (using iPXE's contrib/crypto/cmsdetach) # cmsdetach vmlinuz.cms -d vmlinuz.dat -e vmlinuz.env cmsdetach initrd.img.cms -d initrd.img.dat -e initrd.img.env and then within iPXE: #!ipxe imgfetch http://192.168.0.1/vmlinuz.dat imgfetch http://192.168.0.1/initrd.img.dat imgdecrypt vmlinuz.dat http://192.168.0.1/vmlinuz.env imgdecrypt initrd.img.dat http://192.168.0.1/initrd.img.env boot vmlinuz Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hci] Remove the generalised widget user interface abstractionMichael Brown2024-06-213-220/+0
| | | | | | | | Remove the now-unused generalised text widget user interface, along with the associated concept of a widget set and the implementation of a read-only label widget. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [form] Reimplement the "login" user interfaceMichael Brown2024-06-211-61/+31
| | | | | | | | | | | | | | | | | | Rewrite the code implementing the "login" user interface to use a predefined interactive form. The command "login" then becomes roughly equivalent to: #!ipxe form item username Username item --secret password Password present with the result that login form customisations (e.g. to add a Windows domain name) may be implemented within the scripting language. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [form] Add support for dynamically created interactive formsMichael Brown2024-06-202-0/+610
| | | | | | | | | | | | | | | | Add support for presenting a dynamic user interface as an interactive form, alongside the existing support for presenting a dynamic user interface as a menu. An interactive form may be used to allow a user to input (or edit) values for multiple settings on a single screen, as a user-friendly alternative to prompting for setting values via the "read" command. In the present implementation, all input fields must fit on a single screen (with no scrolling), and the only supported widget type is an editable text box. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dynui] Add concept of a secret user interface itemMichael Brown2024-06-201-0/+6
| | | | | | | | | | | | | | For interactive forms, the concept of a secret value becomes meaningful (e.g. for password fields). Add a flag to indicate that an item represents a secret value, and allow this flag to be set via the "--secret" option of the "item" command. This flag has no meaning for menu items, but is silently accepted anyway to keep the code size minimal. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dynui] Allow for multiple flags on a user interface itemMichael Brown2024-06-202-3/+6
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dynui] Generalise mechanisms for looking up user interface itemsMichael Brown2024-06-201-32/+6
| | | | | | | | Generalise the ability to look up a dynamic user interface item by index or by shortcut key, to allow for reuse of this code for interactive forms. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dynui] Generalise the concept of a menu to a dynamic user interfaceMichael Brown2024-06-202-75/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently have an abstract model of a dynamic menu as a list of items, each of which has a name, a description, and assorted metadata such as a shortcut key. The "menu" and "item" commands construct representations in this abstract model, and the "choose" command then presents the items as a single-choice menu, with the selected item's name used as the output value. This same abstraction may be used to model a dynamic form as a list of editable items, each of which has a corresponding setting name, an optional description label, and assorted metadata such as a shortcut key. By defining a "form" command as an alias for the "menu" command, we could construct and present forms using commands such as: #!ipxe form Login to ${url} item username Username or email address item --secret password Password present or #!ipxe form Configure IPv4 networking for ${netX/ifname} item netX/ip IPv4 address item netX/netmask Subnet mask item netX/gateway Gateway address item netX/dns DNS server address present Reusing the same abstract model for both menus and forms allows us to minimise the increase in code size, since the implementation of the "form" and "item" commands is essentially zero-cost. Rename everything within the abstract data model from "menu" to "dynamic user interface" to reflect this generalisation. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hci] Allow tab key to be used to cycle through UI elementsMichael Brown2024-06-203-31/+52
| | | | | | | | | | | Add support for wraparound scrolling and allow the tab key to be used to move forward through a list of elements, wrapping back around to the beginning of the list on overflow. This is mildly useful for a menu, and likely to be a strong user expectation for an interactive form. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hci] Rename "item" command's first parameter from "label" to "name"Michael Brown2024-06-182-19/+19
| | | | | | | | | | | Switch terminology for the "item" command from "item <label> <text>" to "item <name> <text>", in preparation for repurposing the "item" command to cover interactive forms as well as menus. Since this renaming affects only a positional parameter, it does not break compatibility with any existing scripts. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hci] Split out msg() and alert() from settings UI codeMichael Brown2024-06-182-72/+115
| | | | | | | | | | | The msg() and alert() functions currently defined in settings_ui.c provide a general-purpose facility for printing messages centred on the screen. Split this out to a separate file to allow for reuse by the form presentation code. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hci] Draw all widgets on the standard screenMichael Brown2024-06-185-20/+14
| | | | | | | | | | | | | | | The curses concept of a window has been supported but never actively used in iPXE since the mucurses library was first implemented in 2006. Simplify the code by removing the ability to place a widget set in a specified window, and instead use the standard screen for all drawing operations. This simplification allows the widget set parameter to be omitted for the draw_widget() and edit_widget() operations, since the only reason for its inclusion was to provide access to the specified window. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hci] Provide a general concept of a text widget setMichael Brown2024-05-155-109/+296
| | | | | | | | | Create a generic abstraction of a text widget, refactor the existing editable text box widget to use this abstraction, add an implementation of a non-editable text label widget, and generalise the login user interface to use this generic widget abstraction. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hci] Fix semantics of replace_string() to match code commentsMichael Brown2024-04-171-17/+18
| | | | | | | | | | | | | | | | | | The comments for replace_string() state that a successful return status guarantees that the dynamically allocated string pointer is no longer NULL (even if it was initially NULL and the replacement string is NULL or empty). This is relied upon by readline() to guarantee that it will always return a non-NULL string if successful. The code behaviour does not currently match this comment: an empty replacement string may result in a successful return status even if the (single-byte) allocation fails. Fix up the code behaviour to match the comments, and to additionally ensure that the edit history is filled in even in the event of an allocation failure. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hci] Use dynamically allocated buffers for editable stringsMichael Brown2024-04-155-129/+176
| | | | | | | | | | | Editable strings currently require a fixed-size buffer, which is inelegant and limits the potential for creating interactive forms with a variable number of edit box widgets. Remove this limitation by switching to using a dynamically allocated buffer for editable strings and edit box widgets. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Allow SAN boot device to be identified by filesystem labelMichael Brown2024-03-071-1/+6
| | | | | | | Add a "--label" option that can be used to specify a filesystem label, to be matched against the FAT volume label. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Allow SAN boot device to be identified by an extra filenameMichael Brown2024-03-071-2/+7
| | | | | | | | | | | | Add an "--extra" option that can be used to specify an extra (non-boot) filename that must exist within the booted filesystem. Note that only files within the FAT-formatted bootable partition will be visible to this filter. Files within the operating system's root disk (e.g. "/etc/redhat-release") are not generally accessible to the firmware and so cannot be used as the existence check filter filename. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Allow SAN boot device to be identified by UUIDMichael Brown2024-03-061-3/+7
| | | | | | | Add a "--uuid" option which may be used to specify a boot device UUID, to be matched against the GPT partition GUID. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Allow for additional SAN boot parameters alongside filenameMichael Brown2024-03-061-1/+5
| | | | | | | | | | | | | | | The drive specification alone does not necessarily contain enough information to perform a SAN boot (or local disk boot) under UEFI. If the next-stage bootloader is installed in the EFI system partition under a non-standard name (e.g. "\EFI\debian\grubx64.efi") then this explicit boot filename must also be specified. Generalise this concept to use a "SAN boot configuration parameters" structure (currently containing only the optional explicit boot filename), to allow for easy expansion to provide other parameters such as the partition UUID or volume label. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Implement "shim" as a dummy command on non-EFI platformsMichael Brown2023-05-241-0/+14
| | | | | | | | | | | | | | | | | | | | | | The "shim" command will skip downloading the shim binary (and is therefore a conditional no-op) if there is already a selected EFI image that can be executed directly via LoadImage()/StartImage(). This allows the same iPXE script to be used with Secure Boot either enabled or disabled. Generalise this further to provide a dummy "shim" command that is an unconditional no-op on non-EFI platforms. This then allows the same iPXE script to be used for BIOS, EFI with Secure Boot disabled, or EFI with Secure Boot enabled. The same effect could be achieved by using "iseq ${platform} efi" within the script, but this would complicate end-user documentation. To minimise the code size impact, the dummy "shim" command is a pure no-op that does not call parse_options() and so will ignore even standardised arguments such as "--help". Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Support versions of shim that perform SBAT verificationMichael Brown2023-05-231-1/+6
| | | | | | | | | | | | | | | The UEFI shim implements a fairly nicely designed revocation mechanism designed around the concept of security generations. Unfortunately nobody in the shim community has thus far added the relevant metadata to the Linux kernel, with the result that current versions of shim are incapable of booting current versions of the Linux kernel. Experience shows that there is unfortunately no point in trying to get a fix for this upstreamed into shim. We therefore default to working around this undesirable behaviour by patching data read from the "SbatLevel" variable used to hold SBAT configuration. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add "shim" commandMichael Brown2023-05-221-0/+112
| | | | | | | | | | | | Allow a shim to be used to facilitate booting a kernel using a script such as: kernel /images/vmlinuz console=ttyS0,115200n8 initrd /images/initrd.img shim /images/shimx64.efi boot Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [image] Generalise concept of selected imageMichael Brown2023-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most image flags are independent values: any combination of flags may be set for any image, and the flags for one image are independent of the flags for any other image. The "selected" flag does not follow this pattern: at most one image may be marked as selected at any time. When invoking a kernel via the UEFI shim, there will be multiple "special" images: the selected kernel itself, the shim image, and potentially a shim-signed GRUB binary to be used as a crutch to assist shim in loading the kernel (since current versions of the UEFI shim are not capable of directly loading a Linux kernel). Remove the "selected" image flag and replace it with a general concept of an image tag with the same semantics: a given tag may be assigned to at most one image, an image may be found by its tag only while the image is currently registered, and a tag will survive unregistration and reregistration of an image (if it has not already been assigned to a new image). For visual consistency, also replace the current image pointer with a current image tag. The image pointer stored within the image tag holds only a weak reference to the image, since the selection of an image should not prevent that image from being freed. (The strong reference to the currently executing image is held locally within the execution scope of image_exec(), and is logically separate from the current image pointer.) Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [params] Allow for arbitrary HTTP request headers to be specifiedMichael Brown2023-03-011-1/+9
| | | | | | | | | | | Extend the request parameter mechanism to allow for arbitrary HTTP headers to be specified via e.g.: params param --header Referer http://www.example.com imgfetch http://192.168.0.1/script.ipxe##params Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [params] Rename "form parameter" to "request parameter"Michael Brown2023-03-011-2/+2
| | | | | | | | Prepare for the parameter mechanism to be generalised to specifying request parameters that are passed via mechanisms other than an application/x-www-form-urlencoded form. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pci] Check for wraparound in callers of pci_find_next()Michael Brown2022-09-151-0/+6
| | | | | | | | | | | | | | | | The semantics of the bus:dev.fn parameter passed to pci_find_next() are "find the first existent PCI device at this address or higher", with the caller expected to increment the address between finding devices. This does not allow the parameter to distinguish between the two cases "start from address zero" and "wrapped after incrementing maximal possible address", which could therefore lead to an infinite loop in the degenerate case that a device with address ffff:ff:1f.7 really exists. Fix by checking for wraparound in the caller (which is already responsible for performing the increment). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pci] Allow pci_find_next() to return non-zero PCI segmentsMichael Brown2022-09-151-7/+5
| | | | | | | | Separate the return status code from the returned PCI bus:dev.fn address, in order to allow pci_find_next() to be used to find devices with a non-zero PCI segment number. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Include mappings for AltGr-Shift-<key>Michael Brown2022-02-1619-0/+113
| | | | | | | | | | | | | | | | | | | The BIOS console's interpretation of LShift+RShift as equivalent to AltGr requires the shifted ASCII characters to be present in the AltGr mapping table, to allow AltGr-Shift-<key> to be interpreted in the same way as AltGr-<key>. For keyboard layouts that have different ASCII characters for AltGr-<key> and AltGr-Shift-<key>, this will potentially leave the character for AltGr-<key> inaccessible via the BIOS console if the BIOS requires the use of the LShift+RShift workaround. This theoretically affects the numeric keys in the Lithuanian ("lt") keyboard layout (where the numerals are accessed via AltGr-<key> and punctuation characters via AltGr-Shift-<key>), but the simple workaround for that keyboard layout is to avoid using AltGr and Shift entirely since the unmodified numeric keys are not remapped anyway. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Ensure that US keyboard map appears at start of linker tableMichael Brown2022-02-161-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Fix definition of unreachability for remapped keysMichael Brown2022-02-1518-0/+114
| | | | | | | | | | | | | | The AltGr remapping table is constructed to include only keys that are not reachable after applying the basic remapping table. The logic currently fails to include keys that are omitted entirely from the basic remapping table since they would map to a non-ASCII character. Fix this logic by allowing the remapping tables to include null mappings, which are then elided only at the point of constructing the C code fragment. Reported-by: Christian Nilsson <nikize@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Add Swedish "se" keymapMichael Brown2022-02-151-0/+53
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Remove "az" keymapMichael Brown2022-02-151-40/+0
| | | | | | | The "az" keymap has several unreachable ASCII characters, with no obvious closest equivalent keys. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Fix unreachable characters in "mt" keymapMichael Brown2022-02-151-1/+0
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Fix unreachable characters in "il" keymapMichael Brown2022-02-151-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Treat dead keys as producing their ASCII equivalentsMichael Brown2022-02-1514-5/+41
| | | | | | | | Treat dead keys in target keymaps as producing the closest equivalent ASCII character, since many of these characters are otherwise unrepresented on the keyboard. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Support AltGr to access ASCII characters via remappingMichael Brown2022-02-1530-0/+266
| | | | | | | | | | | | | Several keyboard layouts define ASCII characters as accessible only via the AltGr modifier. Add support for this modifier to ensure that all ASCII characters are accessible. Experiments suggest that the BIOS console is likely to fail to generate ASCII characters when the AltGr key is pressed. Work around this limitation by accepting LShift+RShift (which will definitely produce an ASCII character) as a synonym for AltGr. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Allow for named keyboard mappingsMichael Brown2022-02-1530-60/+270
| | | | | | | | Separate the concept of a keyboard mapping from a list of remapped keys, to allow for the possibility of supporting multiple keyboard mappings at runtime. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Handle remapping of scancode 86Michael Brown2022-02-1022-0/+44
| | | | | | | | | | | | | | | | | The key with scancode 86 appears in the position between left shift and Z on a US keyboard, where it typically fails to exist entirely. Most US keyboard maps define this nonexistent key as generating "\|", with the notable exception of "loadkeys" which instead reports it as generating "<>". Both of these mapping choices duplicate keys that exist elsewhere in the map, which causes problems for our ASCII-based remapping mechanism. Work around these quirks by treating the key as generating "\|" with the high bit set, and making it subject to remapping. Where the BIOS generates "\|" as expected, this allows us to remap to the correct ASCII value. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Update genkeymap to work with current databasesMichael Brown2022-02-1022-246/+87
| | | | | | | | Rewrite genkeymap.pl in Python with added sanity checks, and update the list of keyboard mappings to remove those no longer supported by the underlying "loadkeys" tool. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [readline] Extend maximum read line length to 1024 charactersMichael Brown2021-09-101-7/+17
| | | | | | | | | | | Realistic Linux kernel command lines may exceed our current 256 character limit for interactively edited commands or settings. Switch from stack allocation to heap allocation, and increase the limit to 1024 characters. Requested-by: Matteo Guglielmi <Matteo.Guglielmi@dalco.ch> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [image] Add "imgextract" command for extracting archive imagesMichael Brown2021-05-081-0/+105
| | | | | | | | Add the concept of extracting an image from an archive (which could be a single-file archive such as a gzip-compressed file), along with an "imgextract" command to expose this functionality to scripts. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add --timeout option to "read" commandMichael Brown2021-04-231-14/+43
| | | | | Requested-by: Matteo Guglielmi <Matteo.Guglielmi@dalco.ch> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [readline] Add an optional timeout to readline_history()Michael Brown2021-04-233-5/+16
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [linux] Use host glibc system call wrappersMichael Brown2021-02-281-17/+3
| | | | | | | | | | | | | | | | | | | | | | When building as a Linux userspace application, iPXE currently implements its own system calls to the host kernel rather than relying on the host's C library. The output binary is statically linked and has no external dependencies. This matches the general philosophy of other platforms on which iPXE runs, since there are no external libraries available on either BIOS or UEFI bare metal. However, it would be useful for the Linux userspace application to be able to link against host libraries such as libslirp. Modify the build process to perform a two-stage link: first picking out the requested objects in the usual way from blib.a but with relocations left present, then linking again with a helper object to create a standard hosted application. The helper object provides the standard main() entry point and wrappers for the Linux system calls required by the iPXE Linux drivers and interface code. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Expose "iflinkwait" as a commandMichael Brown2021-01-261-0/+56
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [image] Provide image_memory()Michael Brown2021-01-251-3/+1
| | | | | | | Consolidate the remaining logic common to initrd_init() and imgmem() into a shared image_memory() function. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [image] Add the "imgmem" commandMichael Brown2021-01-221-0/+98
| | | | | | | Provide the "imgmem" command to create an image from an existing block of memory, for debugging purposes only. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Add "--timeout" parameter to "ifconf" commandJoe Groocock2020-07-221-1/+7
| | | | | Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>