summaryrefslogtreecommitdiffstats
path: root/src/core
Commit message (Collapse)AuthorAgeFilesLines
* [init] Show startup and shutdown function names in debug messagesMichael Brown2019-01-254-2/+16
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Fix strcmp()/strncmp() to return proper valuesAaron Young2019-01-151-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>
* [profile] Prevent potential division by zeroMichael Brown2018-03-181-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>
* [http] Allow for domain names within NTLM user namesMichael Brown2018-02-191-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>
* [resolv] Use pass-through interfaces for name resolution multiplexerMichael Brown2017-09-061-15/+24
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [monojob] Display job status message, if presentMichael Brown2017-09-061-9/+25
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [downloader] Allow underlying downloads to provide detailed job progressMichael Brown2017-09-061-2/+9
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [monojob] Check for job progress only once per timer tickMichael Brown2017-09-061-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>
* [malloc] Avoid false positive warnings from valgrindMichael Brown2017-09-041-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>
* [acpi] Fix spurious uninitialised-variable warning on some gcc versionsMichael Brown2017-07-281-1/+1
| | | | | Reported-by: Christian Nilsson <nikize@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [acpi] Compute and check checksum for ACPI tablesLaurent Gourvénec2017-07-281-6/+37
| | | | | Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [syslog] Handle backspace charactersMichael Brown2017-06-131-0/+7
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [acpi] Expose ACPI tables via settings mechanismMichael Brown2017-05-231-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>
* [acpi] Make acpi_find_rsdt() a per-platform methodMichael Brown2017-05-232-71/+23Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Extend numerical setting tags to 64 bitsMichael Brown2017-05-222-17/+25
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Provide abstraction to allow system to be quiescedMichael Brown2017-04-262-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>
* [block] Provide sandev_read() and sandev_write() as global symbolsMichael Brown2017-04-261-8/+48
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Allow use of a non-default EFI SAN boot filenameMichael Brown2017-04-123-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>
* [block] Describe all SAN devices via ACPI tablesMichael Brown2017-03-284-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>
* [block] Ignore redundant xfer_window_changed() messagesMichael Brown2017-03-281-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>
* [block] Gracefully close SAN device if registration failsMichael Brown2017-03-271-6/+16
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Retry reopening indefinitely for multipath devicesMichael Brown2017-03-271-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>
* [block] Add a small delay between attempts to reopen SAN targetsMichael Brown2017-03-271-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>
* [block] Allow SAN retry count to be reconfiguredMichael Brown2017-03-271-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>
* [time] Add sleep_fixed() function to sleep without checking for Ctrl-CMichael Brown2017-03-271-3/+36
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Add basic multipath supportMichael Brown2017-03-263-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>
* [block] Add dummy SAN deviceMichael Brown2017-03-261-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>
* [malloc] Track maximum heap usageMichael Brown2017-03-221-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>
* [pixbuf] Avoid potential division by zeroMichael Brown2017-03-221-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>
* [block] Quell spurious Coverity size mismatch warningMichael Brown2017-03-221-6/+10
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [xfer] Ensure va_end() is called on failure pathMichael Brown2017-03-211-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dhcp] Allow vendor class to be changed in DHCP requestsMichael Brown2017-03-201-0/+9
| | | | | | | Allow the DHCPv4 vendor class to be specified via the "vendor-class" setting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Use intfs_shutdown() when shutting down multiple interfacesMichael Brown2017-03-091-2/+1Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Retry any SAN device operationMichael Brown2017-03-071-19/+35
| | | | | | | | | | The SCSI layer currently implements a retry loop in order to retry commands that fail due to spurious "error" conditions such as "power on occurred". Move this retry loop to the generic SAN device layer: this allow for retries due to other transient error conditions such as an iSCSI target having dropped the connection due to inactivity. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Centralise "san-drive" settingMichael Brown2017-03-072-1/+39
| | | | | | | | | | | | The concept of the SAN drive number is meaningful only in a BIOS environment, where it represents the INT13 drive number (0x80 for the first hard disk). We retain this concept in a UEFI environment to allow for a simple way for iPXE commands to refer to SAN drives. Centralise the concept of the default drive number, since it is shared between all supported environments. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Centralise SAN device abstractionMichael Brown2017-03-071-0/+563
| | | | | | | Create a central SAN device abstraction to be shared between BIOS and UEFI. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [interface] Provide the ability to shut down multiple interfacesMichael Brown2017-02-021-0/+69
| | | | | | | | | | | | | | | Shutting down (and optionally restarting) multiple interfaces is fraught with problems if there are loops in the interface connectivity (e.g. the HTTP content-decoded and transfer-decoded interfaces, which will generally loop back to each other). Various workarounds currently exist across the codebase, generally involving preceding calls to intf_nullify() to avoid problems due to known loops. Provide intfs_shutdown() and intfs_restart() to allow all of an object's interfaces to be shut down (or restarted) in a single call, without having to worry about potential external loops. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [time] Report attempts to use timers before initialisationMichael Brown2017-02-011-3/+25
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "unixtime" builtin setting to expose the current timeMichael Brown2017-01-261-0/+33
| | | | | | | | | | | Expose the current wall-clock time (in seconds since the Epoch), since this is often useful in captured boot logs and can also be useful when checking unexpected X.509 certificate validation failures. Use a :uint32 setting to avoid Y2K38 rollover, thereby ensuring that this will eventually be somebody else's problem. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [time] Allow timer to be selected at runtimeMichael Brown2017-01-262-2/+62
| | | | | | | | | | | | | | | | | | | | | | Allow the active timer (providing udelay() and currticks()) to be selected at runtime based on probing during the INIT_EARLY stage of initialisation. TICKS_PER_SEC is now a fixed compile-time constant for all builds, and is independent of the underlying clock tick rate. We choose the value 1024 to allow multiplications and divisions on seconds to be converted to bit shifts. TICKS_PER_MS is defined as 1, allowing multiplications and divisions on milliseconds to be omitted entirely. The 2% inaccuracy in this definition is negligible when using the standard BIOS timer (running at around 18.2Hz). TIMER_RDTSC now checks for a constant TSC before claiming to be a usable timer. (This timer can be tested in KVM via the command-line option "-cpu host,+invtsc".) Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [interface] Unplug interface before calling intf_close() in intf_shutdown()Michael Brown2017-01-251-4/+9
| | | | | | | | | | | | | | | | | | | The call to intf_close() may result in the original interface being reopened. For example: when reading the capacity of a 2TB+ disk via iSCSI, the SCSI layer will respond to the intf_close() from the READ CAPACITY (10) command by immediately issuing a READ CAPACITY (16) command. The iSCSI layer happens to reuse the same interface for the new command (since it allows only a single concurrent command). Currently, intf_shutdown() unplugs the interface after the call to intf_close() returns. In the above scenario, this results in unplugging the just-reopened interface. Fix by transferring the interface destination (and its reference) to a temporary interface, and so effectively performing the unplug before making the call to intf_close(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [interface] Remove misleading commentMichael Brown2017-01-251-3/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [interface] Avoid unnecessary reference counting in intf_unplug()Michael Brown2017-01-251-1/+4
| | | | | | | The null interface does not have a reference counter, so the call to intf_get() is always redundant. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Return const char * from uuid_ntoa()David Decotigny2017-01-221-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [interface] Provide intf_reinit() to reinitialise nullified interfacesMichael Brown2016-11-161-2/+1Star
| | | | | | | Provide an abstraction intf_reinit() to restore the descriptor of a previously nullified interface. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pixbuf] Enable PNG format by defaultMichael Brown2016-07-292-24/+32
| | | | | | | Enable IMAGE_PNG (but not IMAGE_PNM) by default, and drag in the relevant objects only when image_pixbuf() is present in the binary. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Enable both DER and PEM formats by defaultMichael Brown2016-07-291-35/+0Star
| | | | | | | | | | Enable both IMAGE_DER and IMAGE_PEM by default, and drag in the relevant objects only when image_asn1() is present in the binary. This allows "imgverify" to transparently use either DER or PEM signature files. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [image] Add image_asn1() to extract ASN.1 objects from imageMichael Brown2016-07-291-0/+35
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Allow settings blocks to specify a sibling orderingMichael Brown2016-07-191-0/+2
| | | | | | | Allow settings blocks to provide an explicit default ordering between siblings, with lower precedence than the existing ${priority} setting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Correctly mortalise autovivified child settings blocksMichael Brown2016-07-191-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>