aboutsummaryrefslogtreecommitdiff
path: root/src/core
AgeCommit message (Collapse)AuthorFilesLines
2021-03-01[acpi] Allow for platforms that provide ACPI tables individuallykexec3kexec2kexecMichael Brown2-3/+3
The ACPI API currently expects platforms to provide access to a single contiguous ACPI table. Some platforms (e.g. Linux userspace) do not provide a convenient way to obtain the entire ACPI table, but do provide access to individual tables. All iPXE consumers of the ACPI API require access only to individual tables. Redefine the internal API to make acpi_find() an API method, with all existing implementations delegating to the current RSDT-based implementation. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-28[acpi] Eliminate redundant acpi_find_rsdt() in acpi_sx()Michael Brown1-10/+2
The result from acpi_find_rsdt() is used only for the debug message. Simplify the debug message and remove the otherwise redundant call to acpi_find_rsdt(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-28[acpi] Use a fixed colour for debug messagesMichael Brown1-9/+12
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-17[pxe] Split out platform-independent portions of cachedhcp.cMichael Brown1-0/+158
Split out the portions of cachedhcp.c that can be shared between BIOS and UEFI (both of which can provide a buffer containing a previously obtained DHCP packet, and neither of which provide a means to determine the length of this DHCP packet). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-25[image] Provide image_memory()Michael Brown1-0/+44
Consolidate the remaining logic common to initrd_init() and imgmem() into a shared image_memory() function. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-22[image] Provide image_set_data()Michael Brown1-0/+24
Extract part of the logic in initrd_init() to a standalone function image_set_data(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-07[interface] Provide intf_insert() to insert a filter interfaceMichael Brown2-3/+18
Generalise the filter interface insertion logic from block_translate() and expose as intf_insert(), allowing a filter interface to be inserted on any existing interface. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-07[interface] Ignore any attempts to plug in the null interfaceMichael Brown1-0/+5
Allow intf_plug() and intf_plug_plug() to be called safely on interfaces that may be the null interface. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-11-29[dma] Provide dma_umalloc() for allocating large DMA-coherent buffersMichael Brown1-0/+39
Some devices (e.g. xHCI USB host controllers) may require the use of large areas of host memory for private use by the device. These allocations cannot be satisfied from iPXE's limited heap space, and so are currently allocated using umalloc() which will allocate external system memory (and alter the system memory map as needed). Provide dma_umalloc() to provide such allocations as part of the DMA API, since there is otherwise no way to guarantee that the allocated regions are usable for coherent DMA. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-11-28[dma] Move I/O buffer DMA operations to iobuf.hMichael Brown2-41/+45
Include a potential DMA mapping within the definition of an I/O buffer, and move all I/O buffer DMA mapping functions from dma.h to iobuf.h. This avoids the need for drivers to maintain a separate list of DMA mappings for each I/O buffer that they may handle. Network device drivers typically do not keep track of transmit I/O buffers, since the network device core already maintains a transmit queue. Drivers will typically call netdev_tx_complete_next() to complete a transmission without first obtaining the relevant I/O buffer pointer (and will rely on the network device core automatically cancelling any pending transmissions when the device is closed). To allow this driver design approach to be retained, update the netdev_tx_complete() family of functions to automatically perform the DMA unmapping operation if required. For symmetry, also update the netdev_rx() family of functions to behave the same way. As a further convenience for drivers, allow the network device core to automatically perform DMA mapping on the transmit datapath before calling the driver's transmit() method. This avoids the need to introduce a mapping error handling code path into the typically error-free transmit methods. With these changes, the modifications required to update a typical network device driver to use the new DMA API are fairly minimal: - Allocate and free descriptor rings and similar coherent structures using dma_alloc()/dma_free() rather than malloc_phys()/free_phys() - Allocate and free receive buffers using alloc_rx_iob()/free_rx_iob() rather than alloc_iob()/free_iob() - Calculate DMA addresses using dma() or iob_dma() rather than virt_to_bus() - Set a 64-bit DMA mask if needed using dma_set_mask_64bit() and thereafter eliminate checks on DMA address ranges - Either record the DMA device in netdev->dma, or call iob_map_tx() as part of the transmit() method - Ensure that debug messages use virt_to_phys() when displaying "hardware" addresses Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-11-28[dma] Record DMA device as part of DMA mapping if neededMichael Brown1-26/+26
Allow for dma_unmap() to be called by code other than the DMA device driver itself. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-11-25[dma] Modify DMA API to simplify calculation of medial addressesMichael Brown1-0/+2
Redefine the value stored within a DMA mapping to be the offset between physical addresses and DMA addresses within the mapped region. Provide a dma() wrapper function to calculate the DMA address for any pointer within a mapped region, thereby simplifying the use cases when a device needs to be given addresses other than the region start address. On a platform using the "flat" DMA implementation the DMA offset for any mapped region is always zero, with the result that dma_map() can be optimised away completely and dma() reduces to a straightforward call to virt_to_phys(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-11-05[dma] Define a DMA API to allow for non-flat device address spacesMichael Brown1-0/+179
iPXE currently assumes that DMA-capable devices can directly address physical memory using host addresses. This assumption fails when using an IOMMU. Define an internal DMA API with two implementations: a "flat" implementation for use in legacy BIOS or other environments in which flat physical addressing is guaranteed to be used and all allocated physical addresses are guaranteed to be within a 32-bit address space, and an "operations-based" implementation for use in UEFI or other environments in which DMA mapping may require bus-specific handling. The purpose of the fully inlined "flat" implementation is to allow the trivial identity DMA mappings to be optimised out at build time, thereby avoiding an increase in code size for legacy BIOS builds. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-11-05[malloc] Rename malloc_dma() to malloc_phys()Michael Brown2-8/+8
The malloc_dma() function allocates memory with specified physical alignment, and is typically (though not exclusively) used to allocate memory for DMA. Rename to malloc_phys() to more closely match the functionality, and to create name space for functions that specifically allocate and map DMA-capable buffers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-07-21[libc] Fix memcmp() to return proper valuesMichael J. Bazzinotti1-1/+1
Fix memcmp() to return proper standard positive/negative values for unequal comparisons. Current implementation is backwards (i.e. the functions are returning negative when should be positive and vice-versa). Currently most consumers of these functions only check the return value for ==0 or !=0 and so we can safely change the implementation without breaking things. However, there is one call that checks the polarity of this function, and that is prf_sha1() for wireless WPA 4-way handshake. Due to the incorrect memcmp() polarity, the WPA handshake creates an incorrect PTK, and the handshake would fail after step 2. Undoubtedly, the AP noticed the supplicant failed the mic check. This commit fixes that issue. Similar to commit 3946aa9 ("[libc] Fix strcmp()/strncmp() to return proper values"). Signed-off-by: Michael Bazzinotti <bazz@bazz1.com> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-07-15[xfer] Remove address family from definition of a socket openerMichael Brown1-3/+1
All implemented socket openers provide definitions for both IPv4 and IPv6 using exactly the same opener method. Simplify the logic by omitting the address family from the definition. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-07-07[libc] Provide an unoptimised generic_memcpy_reverse()Michael Brown1-5/+20
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-19[parseopt] Treat empty integer strings in user input as invalidMichael Brown1-1/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-05[uri] Avoid appearing to access final byte of a potentially empty stringMichael Brown1-2/+2
The URI parsing code for "host[:port]" checks that the final character is not ']' in order to allow for IPv6 literals. If the entire "host[:port]" portion of the URL is an empty string, then this will access the preceding character. This does not result in accessing invalid memory (since the string is guaranteed by construction to always have a preceding character) and does not result in incorrect behaviour (since if the string is empty then strrchr() is guaranteed to return NULL), but it does make the code confusing to read. Fix by inverting the order of the two tests. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-02-16[settings] Eliminate variable-length stack allocationMichael Brown1-2/+7
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-07-19[fdt] Add ability to parse a MAC address from a flattened device treeMichael Brown1-0/+486
The Raspberry Pi NIC has no EEPROM to hold the MAC address. The platform firmware (e.g. UEFI or U-Boot) will typically obtain the MAC address from the VideoCore firmware and add it to the device tree, which is then made available to subsequent programs such as iPXE or the Linux kernel. Add the ability to parse a flattened device tree and to extract the MAC address. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-01-25[init] Show startup and shutdown function names in debug messagesMichael Brown4-2/+16
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-01-15[libc] Fix strcmp()/strncmp() to return proper valuesAaron Young1-3/+3
Fix strcmp() and strncmp() to return proper standard positive/negative values for unequal strings. Current implementation is backwards (i.e. the functions are returning negative when should be positive and vice-versa). Currently all consumers of these functions only check the return value for ==0 or !=0 and so we can safely change the implementation without breaking things. Signed-off-by: Aaron Young <Aaron.Young@oracle.com> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-18[profile] Prevent potential division by zeroMichael Brown1-2/+4
Limit the profile sample count to INT_MAX to avoid both signed overflow and a potential division by zero when updating the stored mean value. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-02-19[http] Allow for domain names within NTLM user namesMichael Brown1-0/+60
Allow a NetBIOS domain name to be specified within a URL using a syntax such as: http://domain%5Cusername:password@server/path Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-06[resolv] Use pass-through interfaces for name resolution multiplexerMichael Brown1-15/+24
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-05[monojob] Display job status message, if presentMichael Brown1-9/+25
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-05[downloader] Allow underlying downloads to provide detailed job progressMichael Brown1-2/+9
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-05[monojob] Check for job progress only once per timer tickMichael Brown1-13/+15
Checking for job progress is essentially a user interface activity, and can safely be performed only once per timer tick (as is already done with checking for keypresses). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-04[malloc] Avoid false positive warnings from valgrindMichael Brown1-1/+8
Calling discard_cache() is likely to result in a call to free_memblock(), which will call valgrind_make_blocks_noaccess() before returning. This causes valgrind to report an invalid read on the next iteration through the loop in alloc_memblock(). Fix by explicitly calling valgrind_make_blocks_defined() after discard_cache() returns. Also call valgrind_make_blocks_noaccess() before calling discard_cache(), to guard against free list corruption while executing cache discarders. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-07-28[acpi] Fix spurious uninitialised-variable warning on some gcc versionsMichael Brown1-1/+1
Reported-by: Christian Nilsson <nikize@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-07-28[acpi] Compute and check checksum for ACPI tablesLaurent Gourvénec1-6/+37
Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-13[syslog] Handle backspace charactersMichael Brown1-0/+7
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-23[acpi] Expose ACPI tables via settings mechanismMichael Brown1-0/+161
Allow values to be read from ACPI tables using the syntax ${acpi/<signature>.<index>.0.<offset>.<length>} where <signature> is the ACPI table signature as a 32-bit hexadecimal number (e.g. 0x41504093 for the 'APIC' signature on the MADT), <index> is the index into the array of tables matching this signature, <offset> is the byte offset within the table, and <length> is the field length in bytes. Numeric values are returned in reverse byte order, since ACPI numeric values are usually little-endian. For example: ${acpi/0x41504943.0.0.0.0} - entire MADT table in raw hex ${acpi/0x41504943.0.0.0x0a.6:string} - MADT table OEM ID ${acpi/0x41504943.0.0.0x24.4:uint32} - local APIC address Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-23[acpi] Make acpi_find_rsdt() a per-platform methodMichael Brown2-71/+23
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-22[settings] Extend numerical setting tags to 64 bitsMichael Brown2-17/+25
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-26[block] Provide abstraction to allow system to be quiescedMichael Brown2-0/+68
When performing a SAN boot via INT 13, there is no way for the operating system to indicate that it has finished using the INT 13 SAN device. We therefore have no opportunity to clean up state before the loaded operating system's native drivers take over. This can cause problems when booting Windows, which tends not to be forgiving of unexpected system state. Windows will typically write a flag to the SAN device as the last action before transferring control to the native drivers. We can use this as a heuristic to bring the system to a quiescent state (without performing a full shutdown); this provides us an opportunity to temporarily clean up state that could otherwise prevent a successful Windows boot. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-26[block] Provide sandev_read() and sandev_write() as global symbolsMichael Brown1-8/+48
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-12[block] Allow use of a non-default EFI SAN boot filenameMichael Brown3-2/+15
Some older operating systems (e.g. RHEL6) use a non-default filename on the root disk and rely on setting an EFI variable to point to the bootloader. This does not work when performing a SAN boot on a machine where the EFI variable is not present. Fix by allowing a non-default filename to be specified via the "sanboot --filename" option or the "san-filename" setting. For example: sanboot --filename \efi\redhat\grub.efi \ iscsi:192.168.0.1::::iqn.2010-04.org.ipxe.demo:rhel6 or option ipxe.san-filename code 188 = string; option ipxe.san-filename "\\efi\\redhat\\grub.efi"; option root-path "iscsi:192.168.0.1::::iqn.2010-04.org.ipxe.demo:rhel6"; Originally-implemented-by: Vishvananda Ishaya Abrams <vish.ishaya@oracle.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-28[block] Describe all SAN devices via ACPI tablesMichael Brown4-43/+173
Describe all SAN devices via ACPI tables such as the iBFT. For tables that can describe only a single device (i.e. the aBFT and sBFT), one table is installed per device. For multi-device tables (i.e. the iBFT), all devices are described in a single table. An underlying SAN device connection may be closed at the time that we need to construct an ACPI table. We therefore introduce the concept of an "ACPI descriptor" which enables the SAN boot code to maintain an opaque pointer to the underlying object, and an "ACPI model" which can build tables from a list of such descriptors. This separates the lifecycles of ACPI descriptions from the lifecycles of the block device interfaces, and allows for construction of the ACPI tables even if the block device interface has been closed. For a multipath SAN device, iPXE will wait until sufficient information is available to describe all devices but will not wait for all paths to connect successfully. For example: with a multipath iSCSI boot iPXE will wait until at least one path has become available and name resolution has completed on all other paths. We do this since the iBFT has to include IP addresses rather than DNS names. We will commence booting without waiting for the inactive paths to either become available or close; this avoids unnecessary boot delays. Note that the Linux kernel will refuse to accept an iBFT with more than two NIC or target structures. We therefore describe only the NICs that are actually required in order to reach the described targets. Any iBFT with at most two targets is therefore guaranteed to describe at most two NICs. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-28[block] Ignore redundant xfer_window_changed() messagesMichael Brown1-0/+4
For some block device protocols, the active path may continue to receive xfer_window_changed() notifications during normal use. These currently result in the active path being erroneously closed. Fix by ignoring any xfer_window_changed() messages if this path is already the active path. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27[block] Gracefully close SAN device if registration failsMichael Brown1-6/+16
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27[block] Retry reopening indefinitely for multipath devicesMichael Brown1-3/+18
For multipath SAN devices, verify that the device is capable of being opened (i.e. that all URIs are parseable and that at least one path is alive) and thereafter retry indefinitely to reopen the device as needed. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27[block] Add a small delay between attempts to reopen SAN targetsMichael Brown1-0/+14
When all SAN targets are completely unreachable, there will be a natural delay between reopening attempts due to the network connection timeout on the unreachable targets. However, some SAN targets may accept connections instantly and report a temporary unavailability by e.g. failing the TEST UNIT READY command. If all targets are behaving this way then there will be no natural delay, and we will attempt to saturate the network with connection attempts. Fix by introducing a small delay between attempts. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27[block] Allow SAN retry count to be reconfiguredMichael Brown1-17/+52
Allow the SAN retry count to be configured via the ${san-retry} setting, defaulting to the current value of 10 retries if not specified. Note that setting a retry count of zero is inadvisable, since iSCSI targets in particular will often report spurious errors such as "power on occurred" for the first few commands. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27[time] Add sleep_fixed() function to sleep without checking for Ctrl-CMichael Brown1-3/+36
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-26[block] Add basic multipath supportMichael Brown3-78/+229
Add basic support for multipath block devices. The "sanboot" and "sanhook" commands now accept a list of SAN URIs. We open all URIs concurrently. The first connection to become available for issuing block device commands is marked as the active path and used for all subsequent commands; all other connections are then closed. Whenever the active path fails, we reopen all URIs and repeat the process. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-26[block] Add dummy SAN deviceMichael Brown1-0/+115
Add a dummy SAN device which allows the "sanhook" command to be tested even when no SAN booting capability is present on the platform. This allows substantial portions of the SAN boot code to be run in Linux under Valgrind. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22[malloc] Track maximum heap usageMichael Brown1-3/+21
Track the current and maximum heap usage, and display the maximum during shutdown when DEBUG=malloc is enabled. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22[pixbuf] Avoid potential division by zeroMichael Brown1-1/+3
Avoid potential division by zero when performing the check against multiplication overflow. (Note that if the width is zero then there can be no overflow anyway, so it is then safe to bypass the check.) Signed-off-by: Michael Brown <mcb30@ipxe.org>