aboutsummaryrefslogtreecommitdiff
path: root/src/core
AgeCommit message (Collapse)AuthorFilesLines
2022-01-04[settings] Support formatting UUIDs as little-endian GUIDsguidMichael Brown1-5/+18
The RFC4122 specification defines UUIDs as being in network byte order, but an unfortunately significant amount of (mostly Microsoft) software treats them as having the first three fields in little-endian byte order. In an ideal world, any server-side software that compares UUIDs for equality would perform an endian-insensitive comparison (analogous to comparing strings for equality using a case-insensitive comparison), and would therefore not care about byte order differences. Define a setting type name ":guid" to allow a UUID setting to be formatted in little-endian order, to simplify interoperability with server-side software that expects such a formatting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-11-12[uri] Retain original encodings for path, query, and fragment fieldsuriMichael Brown1-51/+80
iPXE decodes any percent-encoded characters during the URI parsing stage, thereby allowing protocol implementations to consume the raw field values directly without further decoding. When reconstructing a URI string for use in an HTTP request line, the percent-encoding is currently reapplied in a reversible way: we guarantee that our reconstructed URI string could be decoded to give the same raw field values. This technically violates RFC3986, which states that "URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent". Experiments show that several HTTP server applications will attach meaning to the choice of whether or not a particular character was percent-encoded, even when the percent-encoding is unnecessary from the perspective of parsing the URI into its component fields. Fix by storing the originally encoded substrings for the path, query, and fragment fields and using these original encoded versions when reconstructing a URI string. The path field is also stored as a decoded string, for use by protocols such as TFTP that communicate using raw strings rather than URI-encoded strings. All other fields (such as the username and password) continue to be stored only in their decoded versions since nothing ever needs to know the originally encoded versions of these fields. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-09-09[acpi] Allow for extraction of a MAC address from the DSDT/SSDTMichael Brown1-0/+154
Some vendors provide a "system MAC address" within the DSDT/SSDT, to be used to override the MAC address for a USB docking station. A full implementation would require an ACPI bytecode interpreter, since at least one OEM allows the MAC address to be constructed by executable ACPI bytecode (rather than a fixed data structure). We instead attempt to extract a plausible-looking "_AUXMAC_#.....#" string that appears shortly after an "AMAC" or "MACA" signature. This should work for most implementations encountered in practice. Debugged-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-09-08[acpi] Generalise DSDT/SSDT data extraction logicMichael Brown1-64/+30
Allow for the DSDT/SSDT signature-scanning and value extraction code to be reused for extracting a pass-through MAC address. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-07-27[efi] Record cached ProxyDHCPOFFER and PXEBSACK, if presentMichael Brown1-45/+130
Commit cd3de55 ("[efi] Record cached DHCPACK from loaded image's device handle, if present") added the ability for a chainloaded UEFI iPXE to reuse an IPv4 address and DHCP options previously obtained by a built-in PXE stack, without needing to perform a second DHCP request. Extend this to also record the cached ProxyDHCPOFFER and PXEBSACK obtained from the EFI_PXE_BASE_CODE_PROTOCOL instance installed on the loaded image's device handle, if present. This allows a chainloaded UEFI iPXE to reuse a boot filename or other options that were provided via a ProxyDHCP or PXE boot server mechanism, rather than by standard DHCP. Tested-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-07-01[uri] Make URI schemes case-insensitiveMichael Brown1-1/+2
RFC 3986 section 3.1 defines URI schemes as case-insensitive (though the canonical form is always lowercase). Use strcasecmp() rather than strcmp() to allow for case insensitivity in URI schemes. Requested-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-07[libc] Match standard prototype for putchar()Michael Brown1-1/+4
Reported-by: Bernhard M. Wiedemann <bwiedemann@suse.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-07[base64] Include terminating NUL within base64 character arrayMichael Brown1-1/+1
Reported-by: Bernhard M. Wiedemann <bwiedemann@suse.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-21[cpio] Split out bzImage initrd CPIO header constructionMichael Brown1-0/+85
iPXE will construct CPIO headers for images that have a non-empty command line, thereby allowing raw images (without CPIO headers) to be injected into a dynamically constructed initrd. This feature is currently implemented within the BIOS-only bzImage format support. Split out the CPIO header construction logic to allow for reuse in other contexts such as in a UEFI build. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-18[libc] Add strncasecmp()Michael Brown1-1/+16
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-12[image] Propagate trust flag to extracted archive imagesMichael Brown1-0/+4
An extracted image is wholly derived from the original archive image. If the original archive image has been verified and marked as trusted, then this trust logically extends to any image extracted from it. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-12[image] Allow single-member archive images to be executed transparentlyMichael Brown1-0/+30
Provide image_extract_exec() as a helper method to allow single-member archive images (such as gzip compressed images) to be executed without an explicit "imgextract" step. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-08[image] Add "imgextract" command for extracting archive imagesMichael Brown1-0/+104
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>
2021-05-08[image] Provide image_set_len() utility functionMichael Brown1-4/+21
Signed-off-by: Michael Brown <mcb30@ipxe.org>
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>