summaryrefslogtreecommitdiffstats
path: root/src/include
Commit message (Collapse)AuthorAgeFilesLines
* [ehci] Allow UHCI/OHCI controllers to locate the EHCI companion controllerMichael Brown2015-05-091-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Add find_usb_bus_by_location() helper functionMichael Brown2015-05-091-0/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Maintain single lists of halted endpoints and changed portsMichael Brown2015-05-091-6/+0Star
| | | | | | | | | | When an EHCI hotplug action results in the controller disowning the port, it will result in a hotplug action on the corresponding UHCI or OHCI controller. Allow such hotplug actions to be carried out as part of the same call to usb_step() or usb_register_bus(), by maintaining a single central list of changed ports. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Maintain a list of all USB busesMichael Brown2015-05-091-0/+8
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Detect missed disconnectionsMichael Brown2015-05-081-0/+6
| | | | | | | | | | | | | | | | | | | | | The USB core will currently fail to detect disconnections if a new device has attached by the time the port is examined in usb_hotplug(). Fix by recording the fact that a disconnection has taken place whenever the "connection status changed" (CSC) bit is observed to be set. (Whether the change represents a disconnection or a reconnection, it indicates that the port has experienced some time of being disconnected.) Note that the time at which a disconnection can be detected varies by hub type. In particular: root hubs can observe the CSC bit when polling, and so will record the disconnection before calling usb_port_changed(), but USB hubs read the port status (and hence the CSC bit) only during the call to hub_speed(), long after the call to usb_port_changed(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pci] Provide PCI_CLASS() to calculate a scalar PCI class valueMichael Brown2015-05-081-4/+12
| | | | | | | | Rename PCI_CLASS() (which constructs a struct pci_class_id) to PCI_CLASS_ID(), and provide PCI_CLASS() as a macro which constructs the 24-bit scalar value of a PCI class code. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Include setup packet within I/O buffer for message transfersMichael Brown2015-05-011-3/+1Star
| | | | | | | | | | | | | | The USB API currently assumes that host controllers will have immediate data buffer space available in which to store the setup packet. This is true for xHCI, partially true for EHCI (which happens to have 12 bytes of padding in each transfer descriptor due to alignment requirements), and not true at all for UHCI. Include the setup packet within the I/O buffer passed to the host controller's message() method, thereby eliminating the requirement for host controllers to provide immediate data buffers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "base64" setting typeMichael Brown2015-04-241-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [base64] Add buffer size parameter to base64_encode() and base64_decode()Michael Brown2015-04-241-2/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [base16] Add buffer size parameter to base16_encode() and base16_decode()Michael Brown2015-04-241-3/+30
| | | | | | | | | | | | | | The current API for Base16 (and Base64) encoding requires the caller to always provide sufficient buffer space. This prevents the use of the generic encoding/decoding functionality in some situations, such as in formatting the hex setting types. Implement a generic hex_encode() (based on the existing format_hex_setting()), implement base16_encode() and base16_decode() in terms of the more generic hex_encode() and hex_decode(), and update all callers to provide the additional buffer length parameter. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Use the EFI_RNG_PROTOCOL as an entropy source if availableMichael Brown2015-04-141-0/+158
| | | | | | | | | | | | | | | Entropy gathering via timer ticks is slow under UEFI (of the order of 20-30 seconds on some machines). Use the EFI_RNG_PROTOCOL if available, to speed up the process of entropy gathering. Note that some implementations (including EDK2) will fail if we request fewer than 32 random bytes at a time, and that the RNG protocol provides no guarantees about the amount of entropy provided by a call to GetRNG(). We take the (hopefully pessimistic) view that a 32-byte block returned by GetRNG() will contain at least the 1.3 bits of entropy claimed by min_entropy_per_sample(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add EFI time sourceMichael Brown2015-04-143-0/+22
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add EFI entropy sourceMichael Brown2015-04-142-0/+36
| | | | | Originally-implemented-by: Jarrod Johnson <jbjohnso@us.ibm.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [peerdist] Add support for decoding PeerDist Content InformationMichael Brown2015-04-132-0/+446
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add SHA-512/224 algorithmMichael Brown2015-04-122-0/+11
| | | | | | | | | | SHA-512/224 is almost identical to SHA-512, with differing initial hash values and a truncated output length. This implementation has been verified using the NIST SHA-512/224 test vectors. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add SHA-512/256 algorithmMichael Brown2015-04-122-0/+11
| | | | | | | | | | SHA-512/256 is almost identical to SHA-512, with differing initial hash values and a truncated output length. This implementation has been verified using the NIST SHA-512/256 test vectors. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add SHA-384 algorithmMichael Brown2015-04-122-0/+11
| | | | | | | | | | SHA-384 is almost identical to SHA-512, with differing initial hash values and a truncated output length. This implementation has been verified using the NIST SHA-384 test vectors. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add SHA-512 algorithmMichael Brown2015-04-123-0/+96
| | | | | | | This implementation has been verified using the NIST SHA-512 test vectors. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add SHA-224 algorithmMichael Brown2015-04-122-0/+19
| | | | | | | | | | SHA-224 is almost identical to SHA-256, with differing initial hash values and a truncated output length. This implementation has been verified using the NIST SHA-224 test vectors. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [xhci] Support USB1 devices attached via transaction translatorsMichael Brown2015-03-231-2/+21
| | | | | | | | | | | | | | | | | | | | xHCI provides a somewhat convoluted mechanism for specifying details of a transaction translator. Hubs must be marked as such in the device slot context. The only opportunity to do so is as part of a Configure Endpoint command, which can be executed only when opening the hub's interrupt endpoint. We add a mechanism for host controllers to intercept the opening of hub devices, providing xHCI with an opportunity to update the internal device slot structure for the corresponding USB device to indicate that the device is a hub. We then include the hub-specific details in the input context whenever any Configure Endpoint command is issued. When a device is opened, we record the device slot and port for its transaction translator (if any), and supply these as part of the Address Device command. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Clear transaction translator buffers when applicableMichael Brown2015-03-231-0/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Add clear_tt() hub method to clear transaction translator bufferMichael Brown2015-03-231-0/+9
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Reset endpoints without waiting for a new transfer to be enqueuedMichael Brown2015-03-231-3/+6
| | | | | | | | | | | | | | | The current endpoint reset logic defers the reset until the caller attempts to enqueue a new transfer to that endpoint. This is insufficient when dealing with endpoints behind a transaction translator, since the transaction translator is a resource shared between multiple endpoints. We cannot reset the endpoint as part of the completion handling, since that would introduce recursive calls to usb_poll(). Instead, we add the endpoint to a list of halted endpoints, and perform the reset on the next call to usb_step(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Fix USB timeouts to match specificationMichael Brown2015-03-181-5/+27
| | | | | | | | | | | | | | | Several of the USB timeouts were chosen on the principle of "pick an arbitrary but ridiculously large value, just to be safe". It turns out that some of the timeouts permitted by the USB specification are even larger: for example, control transactions are allowed to take up to five seconds to complete. Fix up these USB timeout values to match those found in the USB2 specification. Debugged-by: Robin Smidsrød <robin@smidsrod.no> Tested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ehci] Add support for EHCI host controllersMichael Brown2015-03-182-0/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Add functions for manual device address assignmentMichael Brown2015-03-161-0/+26
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [usb] Add the concept of a USB bus maximum transfer sizeMichael Brown2015-03-161-1/+5
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Add ffs(), ffsl(), and ffsll()Michael Brown2015-03-161-4/+77
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [tcp] Implement support for TCP Selective Acknowledgements (SACK)Michael Brown2015-03-121-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The TCP Selective Acknowledgement option (specified in RFC2018) provides a mechanism for the receiver to indicate packets that have been received out of order (e.g. due to earlier dropped packets). iPXE often operates in environments in which there is a high probability of packet loss. For example, the legacy USB keyboard emulation in some BIOSes involves polling the USB bus from within a system management interrupt: this introduces an invisible delay of around 500us which is long enough for around 40 full-length packets to be dropped. Similarly, almost all 1Gbps USB2 devices will eventually end up dropping packets because the USB2 bus does not provide enough bandwidth to sustain a 1Gbps stream, and most devices will not provide enough internal buffering to hold a full TCP window's worth of received packets. Add support for sending TCP Selective Acknowledgements. This provides the sender with more detailed information about which packets have been lost, and so allows for a more efficient retransmission strategy. We include a SACK-permitted option in our SYN packet, since experimentation shows that at least Linux peers will not include a SACK-permitted option in the SYN-ACK packet if one was not present in the initial SYN. (RFC2018 does not seem to mandate this behaviour, but it is consistent with the approach taken in RFC1323.) We ignore any received SACK options; this is safe to do since SACK is only ever advisory and we never have to send non-trivial amounts of data. Since our TCP receive queue is a candidate for cache discarding under low memory conditions, we may end up discarding data that has been reported as received via a SACK option. This is permitted by RFC2018. We follow the stricture that SACK blocks must not report data which is no longer held by the receiver: previously-reported blocks are validated against the current receive queue before being included within the current SACK block list. Experiments in a qemu VM using forced packet drops (by setting NETDEV_DISCARD_RATE to 32) show that implementing SACK improves throughput by around 400%. Experiments with a USB2 NIC (an SMSC7500) show that implementing SACK improves throughput by around 700%, increasing the download rate from 35Mbps up to 250Mbps (which is approximately the usable bandwidth limit for USB2). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [smsc75xx] Add driver for SMSC/Microchip LAN75xx USB Ethernet NICsMichael Brown2015-03-111-0/+1
| | | | | | | | | | | | | | | | | | | This driver is functional but any downloads via a TCP-based protocol tend to perform poorly. The 1Gbps Ethernet line rate is substantially higher than the 480Mbps (in practice around 280Mbps) provided by USB2, and the device has only 32kB of internal buffer memory. Our 256kB TCP receive window therefore rapidly overflows the RX FIFO, leading to multiple dropped packets (usually within the same TCP window) and hence a low overall throughput. Reducing the TCP window size so that the RX FIFO does not overflow greatly increases throughput, but is not a general-purpose solution. Further investigation is required to determine how other OSes (e.g. Linux) cope with this scenario. It is possible that implementing TCP SACK would provide some benefit. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [mii] Add generic mii_check_link() functionMichael Brown2015-03-101-0/+2
| | | | | | | | | | | | Most devices expose at least the link up/down status via a bit in a MAC register, since the MAC generally already needs to know whether or not the link is up. Some devices (e.g. the SMSC75xx USB NIC) expose this information to software only via the MII registers. Provide a generic mii_check_link() implementation to check the BMSR and report the link status via netdev_link_{up,down}(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dm96xx] Add driver for Davicom DM96xx USB Ethernet NICsMichael Brown2015-03-092-1/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-054-4/+4
| | | | | | | | | | | Relicense files with kind permission from Stefan Hajnoczi <stefanha@redhat.com> alongside the contributors who have already granted such relicensing permission. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [retry] Rewrite unrelicensable portions of retry.cMichael Brown2015-03-051-10/+26
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [linux] Rewrite headers included in all buildsMichael Brown2015-03-056-79/+73Star
| | | | | | | Rewrite (and relicense) the header files which are included in all builds of iPXE (including non-Linux builds). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Fix the REQUIRE_SYMBOL mechanismMichael Brown2015-03-052-43/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | At some point in the past few years, binutils became more aggressive at removing unused symbols. To function as a symbol requirement, a relocation record must now be in a section marked with @progbits and must not be in a section which gets discarded during the link (either via --gc-sections or via /DISCARD/). Update REQUIRE_SYMBOL() to generate relocation records meeting these criteria. To minimise the impact upon the final binary size, we use existing symbols (specified via the REQUIRING_SYMBOL() macro) as the relocation targets where possible. We use R_386_NONE or R_X86_64_NONE relocation types to prevent any actual unwanted relocation taking place. Where no suitable symbol exists for REQUIRING_SYMBOL() (such as in config.c), the macro PROVIDE_REQUIRING_SYMBOL() can be used to generate a one-byte-long symbol to act as the relocation target. If there are versions of binutils for which this approach fails, then the fallback will probably involve killing off REQUEST_SYMBOL(), redefining REQUIRE_SYMBOL() to use the current definition of REQUEST_SYMBOL(), and postprocessing the linked ELF file with something along the lines of "nm -u | wc -l" to check that there are no undefined symbols remaining. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Use REQUIRE_OBJECT() to drag in per-object configurationMichael Brown2015-03-051-5/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Remove obsolete and unused portions of config.cMichael Brown2015-03-041-1/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Remove unused __keepme macroMichael Brown2015-03-031-8/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Remove unused IMPORT_SYMBOL() and EXPORT_SYMBOL() macrosMichael Brown2015-03-031-48/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [malloc] Rewrite unrelicensable portions of malloc.cMichael Brown2015-03-031-2/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [malloc] Move valgrind headers out of arch/x86Michael Brown2015-03-032-0/+4849
| | | | | | | The valgrind headers are not x86-specific; they detect the CPU architecture and contain inline assembly for multiple architectures. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [menu] Abstract out the generic concept of a jump scrollerMichael Brown2015-03-031-0/+50
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pci] Rewrite unrelicensable portions of pci.hMichael Brown2015-03-031-296/+101Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pci] Remove outdated and mostly-unused pci_ids.h fileMichael Brown2015-03-022-289/+50Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [list] Relicense list.hMichael Brown2015-03-021-1/+1
| | | | | | | | | | | The code in list.h was originally taken from the Linux kernel many years ago, but has been rewritten to the point that no original code remains, and may therefore be relicensed. The functions and data structures remain largely API-compatible, to facilitate the conversion of Linux network drivers to iPXE. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [elf] Rewrite ELF headerMichael Brown2015-03-021-215/+62Star
| | | | | | | Rewrite the ELF header to include only the relevant portions from the ELF specification. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Rewrite byte-swapping codeMichael Brown2015-03-024-140/+148
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Rewrite unrelicensable portions of ctype.hMichael Brown2015-03-021-17/+101
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Rewrite unrelicensable portions of stddef.hMichael Brown2015-03-021-11/+29
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>