david/ipxe
david
/
ipxe
Archived
1
0
Fork 0
Commit Graph

1983 Commits

Author SHA1 Message Date
Michael Brown 20d35b0145 [pool] Add a generic concept of a pooled connection
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28 16:37:00 +01:00
Michael Brown a8d9cd9485 [peerdist] Add support for constructing and decoding retrieval messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28 16:09:18 +01:00
Michael Brown 51b99d8bc8 [peerdist] Add support for constructing and decoding discovery messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28 16:09:14 +01:00
Michael Brown f0d594557c [peerdist] Include trimmed range within content information block
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28 15:22:26 +01:00
Michael Brown b20d4a1522 [netdevice] Allow network devices to disclaim IRQ support at runtime
VLAN and 802.11 devices use a network device operations structure that
wraps an underlying structure.  For example, the vlan_operations
structure wraps the network device operations structure of the
underlying trunk device.  This can cause false positives from the
current implementation of netdev_irq_supported(), which will always
report that VLAN devices support interrupts since it has no visibility
into the support provided by the underlying trunk device.

Fix by allowing network devices to explicitly flag that interrupts are
not supported, despite the presence of an irq() method.

Originally-fixed-by: Wissam Shoukair <wissams@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28 15:14:40 +01:00
Michael Brown 2bcf13f13a [ipv4] Allow IPv4 socket addresses to include a scope ID
Extend the IPv6 concept of "scope ID" (indicating the network device
index) to IPv4 socket addresses, so that IPv4 multicast transmissions
may specify the transmitting network device.

The scope ID is not (currently) exposed via the string representation
of the socket address, since IPv4 does not use the IPv6 concept of
link-local addresses (which could legitimately be specified in a URI).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28 13:48:29 +01:00
Michael Brown 6efcabd415 [ipv4] Redefine IP address constants to avoid unnecessary byte swapping
Redefine various IPv4 address constants and testing macros to avoid
unnecessary byte swapping at runtime, and slightly rename the macros
to prevent code from accidentally using the old definitions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28 13:48:29 +01:00
Michael Brown 41670ca2fe [ipv6] Treat a missing network device name as "netX"
When an IPv6 socket address string specifies a link-local or multicast
address but does not specify the requisite network device name
(e.g. "fe80::69ff:fe50:5845" rather than "fe80::69ff:fe50:5845%net0"),
assume the use of "netX".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28 13:48:23 +01:00
Michael Brown 09824eca31 [crypto] Replace AES implementation
Replace the AES implementation from AXTLS with a dedicated iPXE
implementation which is slightly smaller and around 1000% faster.
This implementation has been verified using the existing self-tests
based on the NIST AES test vectors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27 17:23:34 +01:00
Michael Brown 69891db8e2 [crypto] Add ECB block cipher mode (for debug and self-tests only)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27 16:04:31 +01:00
Michael Brown 775f5943c0 [crypto] Add bit-rotation functions for 8-bit and 16-bit values
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27 15:21:17 +01:00
Michael Brown 07b0d4fa30 [xferbuf] Add xfer_buffer() to provide direct access to underlying buffer
Allow data transfer buffer users to provide direct access to their
underlying data transfer buffer.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown cbbd6b761e [xferbuf] Generalise to handle umalloc()-based buffers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown 0dc85aed03 [xfer] Add xfer_check_order() utility function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown 81c80c8ba9 [interface] Add intf_poke() helper
Reduce the cost of implementing object methods which convey no
information beyond the fact that the method has been called.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown 6bc3d99496 [profile] Add profile_custom() for profiling with arbitrary time units
Provide profile_custom() as a trivial wrapper around profile_update()
to allow for the use of the profiling infrastructure by code using
timers other than the default profile_timestamp() provider.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown 89816af2a4 [fault] Add inject_corruption() to randomly corrupt data
Provide an inject_corruption() function that can be used to randomly
corrupt data bytes with configurable probabilities.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown d0325b1da6 [fault] Generalise NETDEV_DISCARD_RATE fault injection mechanism
Provide a generic inject_fault() function that can be used to inject
random faults with configurable probabilities.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown 88a5f56dc7 [efi] Fix receive and transmit completion reporting
Fix the TxBuf value filled in by GetStatus() to report the transmit
buffer address as required by the (now clarified) specification.

Simplify "interrupt" handling in GetStatus() to report only that one
or more packets have been transmitted or received; there is no need to
report one GetStatus() "interrupt" per packet.

Simplify receive handling to dequeue received packets immediately from
the network device into an internal list (thereby avoiding the hacks
previously used to determine when to report new packet arrivals).

Originally-fixed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 18:31:45 +01:00
Michael Brown 38afcc51ea [tcp] Gracefully close connections during shutdown
We currently do not wait for a received FIN before exiting to boot a
loaded OS.  In the common case of booting from an HTTP server, this
means that the TCP connection is left consuming resources on the
server side: the server will retransmit the FIN several times before
giving up.

Fix by initiating a graceful close of all TCP connections and waiting
(for up to one second) for all connections to finish closing
gracefully (i.e. for the outgoing FIN to have been sent and ACKed, and
for the incoming FIN to have been received and ACKed at least once).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-04 12:51:23 +01:00
Michael Brown a0f60d26f5 [gdb] Allow gdbstub to be started on an arbitrary serial port
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-29 16:44:16 +01:00
Michael Brown 8829634bd7 [ipoib] Attempt to generate ARPs as needed to repopulate REMAC cache
The only way to map an eIPoIB MAC address (REMAC) to an IPoIB MAC
address is to intercept an incoming ARP request or reply.

If we do not have an REMAC cache entry for a particular destination
MAC address, then we cannot transmit the packet.  This can arise in at
least two situations:

 - An external program (e.g. a PXE NBP using the UNDI API) may attempt
   to transmit to a destination MAC address that has been obtained by
   some method other than ARP.

 - Memory pressure may have caused REMAC cache entries to be
   discarded.  This is fairly likely on a busy network, since REMAC
   cache entries are created for all received (broadcast) ARP
   requests.  (We can't sensibly avoid creating these cache entries,
   since they are required in order to send an ARP reply, and when we
   are being used via the UNDI API we may have no knowledge of which
   IP addresses are "ours".)

Attempt to ameliorate the situation by generating a semi-spurious ARP
request whenever we find a missing REMAC cache entry.  This will
hopefully trigger an ARP reply, which would then provide us with the
information required to populate the REMAC cache.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-29 14:50:16 +01:00
Michael Brown 2a696ab963 [serial] Use new UART abstraction in serial console driver
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-29 11:04:10 +01:00
Michael Brown 5e622dc085 [gdb] Use new UART abstraction in GDB serial transport
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-29 11:03:12 +01:00
Michael Brown 611c9e39da [serial] Add general abstraction of a 16550-compatible UART
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-29 11:03:05 +01:00
Michael Brown fb28c4a979 [stp] Add support for detecting Spanning Tree Protocol non-forwarding ports
A fairly common end-user problem is that the default configuration of
a switch may leave the port in a non-forwarding state for a
substantial length of time (tens of seconds) after link up.  This can
cause iPXE to time out and give up attempting to boot.

We cannot force the switch to start forwarding packets sooner, since
any attempt to send a Spanning Tree Protocol bridge PDU may cause the
switch to disable our port (if the switch happens to have the Bridge
PDU Guard feature enabled for the port).

For non-ancient versions of the Spanning Tree Protocol, we can detect
whether or not the port is currently forwarding and use this to inform
the network device core that the link is currently blocked.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-25 16:58:38 +01:00
Michael Brown f3812395a2 [netdevice] Add a generic concept of a "blocked link"
When Spanning Tree Protocol (STP) is used, there may be a substantial
delay (tens of seconds) from the time that the link goes up to the
time that the port starts forwarding packets.

Add a generic concept of a "blocked link" (i.e. a link which is up but
which is not expected to communicate successfully), and allow "ifstat"
to indicate when a link is blocked.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-25 16:46:47 +01:00
Michael Brown a91b1f7339 [intel] Add intelxvf driver for Intel 10 GigE virtual function NICs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-16 14:54:38 +01:00
Michael Brown bb1e1048f6 [intel] Add support for mailbox used by virtual functions
Virtual functions use a mailbox to communicate with the physical
function driver: this covers functionality such as obtaining the MAC
address.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-16 14:54:37 +01:00
Michael Brown 372672275e [usb] Add basic support for USB keyboards
When USB network card drivers are used, the BIOS' legacy USB
capability is necessarily disabled since there is no way to share the
host controller between the BIOS and iPXE.  This currently results in
USB keyboards becoming non-functional in USB-enabled builds of iPXE.

Fix by adding basic support for USB keyboards, enabled by default in
iPXE builds which include USB support.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-12 15:53:22 +01:00
Michael Brown a8e4187c45 [usb] Add generic USB human interface device (HID) framework
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-12 15:40:20 +01:00
Michael Brown 0eaa3a34bf [usb] Add USB_INTERRUPT_OUT internal type
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-11 14:56:46 +01:00
Michael Brown 86aa959561 [ipv6] Disambiguate received ICMPv6 errors
Originally-implemented-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-11 12:45:14 +01:00
Michael Brown 9d43c4080d [usb] Provide usb_endpoint_name() for use by host controller drivers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-09 23:45:13 +01:00
Michael Brown 6dba29b18f [uhci] Add support for UHCI host controllers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-09 23:14:34 +01:00
Michael Brown 9ea8a2daa7 [ehci] Allow UHCI/OHCI controllers to locate the EHCI companion controller
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-09 20:09:08 +01:00
Michael Brown a66fd8920d [usb] Add find_usb_bus_by_location() helper function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-09 20:09:08 +01:00
Michael Brown e4783add79 [usb] Maintain single lists of halted endpoints and changed ports
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>
2015-05-09 20:08:50 +01:00
Michael Brown 5e1e2069fd [usb] Maintain a list of all USB buses
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-09 19:37:29 +01:00
Michael Brown f6604627ff [usb] Detect missed disconnections
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>
2015-05-08 14:57:14 +01:00
Michael Brown b88ab14ba3 [pci] Provide PCI_CLASS() to calculate a scalar PCI class value
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>
2015-05-08 14:57:12 +01:00
Michael Brown 50e703a534 [usb] Include setup packet within I/O buffer for message transfers
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>
2015-05-01 16:29:11 +01:00
Michael Brown dc15a5a779 [settings] Add "base64" setting type
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24 15:36:41 +01:00
Michael Brown 1205721cbd [base64] Add buffer size parameter to base64_encode() and base64_decode()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24 15:32:04 +01:00
Michael Brown 9aa8090d06 [base16] Add buffer size parameter to base16_encode() and base16_decode()
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>
2015-04-24 14:41:32 +01:00
Michael Brown 7ca801d637 [efi] Use the EFI_RNG_PROTOCOL as an entropy source if available
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>
2015-04-14 17:53:13 +01:00
Michael Brown 6567511c3d [efi] Add EFI time source
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-14 11:55:08 +01:00
Michael Brown eb2252fd7a [efi] Add EFI entropy source
Originally-implemented-by: Jarrod Johnson <jbjohnso@us.ibm.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-14 11:37:38 +01:00
Michael Brown d9166bbcae [peerdist] Add support for decoding PeerDist Content Information
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-13 12:26:05 +01:00
Michael Brown ea3d5875cd [crypto] Add SHA-512/224 algorithm
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>
2015-04-12 17:02:11 +01:00
Michael Brown e5e91ab471 [crypto] Add SHA-512/256 algorithm
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>
2015-04-12 17:01:10 +01:00
Michael Brown 02879299c9 [crypto] Add SHA-384 algorithm
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>
2015-04-12 17:01:10 +01:00
Michael Brown 6f713c2d95 [crypto] Add SHA-512 algorithm
This implementation has been verified using the NIST SHA-512 test
vectors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-12 17:01:10 +01:00
Michael Brown 4dbc44348c [crypto] Add SHA-224 algorithm
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>
2015-04-12 17:01:10 +01:00
Michael Brown f557794ab3 [xhci] Support USB1 devices attached via transaction translators
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>
2015-03-23 20:24:20 +00:00
Michael Brown 5486c947e2 [usb] Clear transaction translator buffers when applicable
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23 16:22:55 +00:00
Michael Brown 9e88194655 [usb] Add clear_tt() hub method to clear transaction translator buffer
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23 16:21:13 +00:00
Michael Brown de6f4e3ede [usb] Reset endpoints without waiting for a new transfer to be enqueued
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>
2015-03-23 15:21:35 +00:00
Michael Brown acc27b9005 [usb] Fix USB timeouts to match specification
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>
2015-03-18 16:43:18 +00:00
Michael Brown 8370f87745 [ehci] Add support for EHCI host controllers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-18 12:35:17 +00:00
Michael Brown 838ab97ce3 [usb] Add functions for manual device address assignment
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16 15:42:29 +00:00
Michael Brown 7b6765ff1b [usb] Add the concept of a USB bus maximum transfer size
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16 15:40:53 +00:00
Michael Brown 79697c75ee [libc] Add ffs(), ffsl(), and ffsll()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16 15:40:53 +00:00
Michael Brown e0fc8fe781 [tcp] Implement support for TCP Selective Acknowledgements (SACK)
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>
2015-03-11 23:14:39 +00:00
Michael Brown 69062bbc21 [smsc75xx] Add driver for SMSC/Microchip LAN75xx USB Ethernet NICs
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>
2015-03-11 13:38:38 +00:00
Michael Brown 6ad02e78bb [mii] Add generic mii_check_link() function
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>
2015-03-10 21:31:07 +00:00
Michael Brown 1ae94c903d [dm96xx] Add driver for Davicom DM96xx USB Ethernet NICs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-09 19:58:57 +00:00
Michael Brown 1a4e94a828 [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
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>
2015-03-05 11:40:13 +00:00
Michael Brown 47ad8fc1ba [retry] Rewrite unrelicensable portions of retry.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-05 11:06:03 +00:00
Michael Brown bfbb2b8f1c [linux] Rewrite headers included in all builds
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>
2015-03-05 02:43:37 +00:00
Michael Brown fbc4ba4b4e [build] Fix the REQUIRE_SYMBOL mechanism
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>
2015-03-05 00:59:38 +00:00
Michael Brown 86ae6e6c18 [build] Use REQUIRE_OBJECT() to drag in per-object configuration
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-05 00:57:44 +00:00
Michael Brown 04c1ea8170 [build] Remove obsolete and unused portions of config.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-04 14:49:43 +00:00
Michael Brown 334eed0cb5 [build] Remove unused __keepme macro
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 16:08:39 +00:00
Michael Brown 30d356b455 [build] Remove unused IMPORT_SYMBOL() and EXPORT_SYMBOL() macros
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 15:51:33 +00:00
Michael Brown b2f38da888 [malloc] Rewrite unrelicensable portions of malloc.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 15:24:15 +00:00
Michael Brown 5f3d165232 [malloc] Move valgrind headers out of arch/x86
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>
2015-03-03 14:25:51 +00:00
Michael Brown 58752cc10d [menu] Abstract out the generic concept of a jump scroller
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 02:47:37 +00:00
Michael Brown e399fc0d21 [pci] Rewrite unrelicensable portions of pci.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 00:08:41 +00:00
Michael Brown 06c8a27b74 [pci] Remove outdated and mostly-unused pci_ids.h file
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 21:37:45 +00:00
Michael Brown 2d707ac964 [list] Relicense list.h
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>
2015-03-02 19:47:32 +00:00
Michael Brown 350768d4b4 [elf] Rewrite ELF header
Rewrite the ELF header to include only the relevant portions from the
ELF specification.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 19:42:48 +00:00
Michael Brown 01d16d821f [libc] Rewrite byte-swapping code
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 16:35:37 +00:00
Michael Brown d1f0e89e4e [libc] Rewrite unrelicensable portions of ctype.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 16:35:37 +00:00
Michael Brown 5d1f351278 [libc] Rewrite unrelicensable portions of stddef.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 16:35:37 +00:00
Michael Brown 2f020a8df3 [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
These files cannot be automatically relicensed by util/relicense.pl
since they either contain unusual but trivial contributions (such as
the addition of __nonnull function attributes), or contain lines
dating back to the initial git revision (and so require manual
knowledge of the code's origin).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 16:35:29 +00:00
Michael Brown 626ccf76ea [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Relicence files with kind permission from the following contributors:

  Alex Williamson <alex.williamson@redhat.com>
  Eduardo Habkost <ehabkost@redhat.com>
  Greg Jednaszewski <jednaszewski@gmail.com>
  H. Peter Anvin <hpa@zytor.com>
  Marin Hannache <git@mareo.fr>
  Robin Smidsrød <robin@smidsrod.no>
  Shao Miller <sha0.miller@gmail.com>
  Thomas Horsten <thomas@horsten.com>

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 14:50:42 +00:00
Michael Brown b6ee89ffb5 [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Relicense files for which I am the sole author (as identified by
util/relicense.pl).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 14:17:31 +00:00
Michael Brown 2782ccec41 [legal] Add support for the Unmodified Binary Distribution Licence
Add the text for the Unmodified Binary Distribution Licence.  This
Licence allows for the distribution of unmodified binaries built from
publicly available source code, without imposing the obligations of
the GNU General Public License upon anyone who chooses to distribute
only the unmodified binaries built from that source code.  See the
licence text for the precise terms and conditions.

Add the licence GPL2_OR_LATER_OR_UBDL to the set of licences which can
be declared using FILE_LICENCE(), and add the corresponding support to
licence.pl.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 12:07:14 +00:00
Michael Brown 5e95a79241 [legal] Include full licence text for all GPL2_OR_LATER files
Add the standard warranty disclaimer and Free Software Foundation
address paragraphs to the licence text where these are not currently
present.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-26 17:59:53 +00:00
Alex Williamson 47aebc24d3 [dhcp] Extract timing parameters out to config/dhcp.h
iPXE uses DHCP timeouts loosely based on values recommended by the
specification, but often abbreviated to reduce timeouts for reliable
and/or simple network topologies.  Extract the DHCP timing parameters
to config/dhcp.h and document them.  The resulting default iPXE
behavior is exactly the same, but downstreams are now afforded the
opportunity to implement spec-compliant behavior via config file
overrides.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-25 16:58:43 +00:00
Michael Brown a32b1e9e35 [libc] Rewrite strtoul()
The implementation of strtoul() has a partially unknown provenance.
Rewrite this code to avoid potential licensing uncertainty.

Since we now use -ffunction-sections, there is no need to place
strtoull() in a separate file from strtoul().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-19 16:00:01 +00:00
Michael Brown a92fb8d9a5 [usb] Add generic USB network device framework
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-17 01:21:53 +00:00
Michael Brown 8ee39f7432 [libc] Rewrite string functions
Some of the C library string functions have an unknown provenance.
Reimplement all such functions to avoid potential licensing
uncertainty.

Remove the inline-assembler versions of strlen(), memswap(), and
strncmp(); these save a minimal amount of space (around 40 bytes in
total) and are not performance-critical.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-16 23:16:20 +00:00
Michael Brown b54167b8b6 [libc] Remove unused string functions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-16 16:25:20 +00:00
Michael Brown 17fc79425e [usb] Provide generic framework for refilling receive endpoints
Provide a generic framework for allocating, refilling, and optionally
recycling I/O buffers used by bulk IN and interrupt endpoints.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-13 01:10:51 +00:00
Michael Brown 6fe8f80418 [usb] Handle port status changes received after failing to find a driver
Commit a60f2dd ("[usb] Try multiple USB device configurations")
changed the behaviour of register_usb() such that if no drivers are
found then the device will be closed and the memory used will be
freed.

If a port status change subsequently occurs while the device is still
physically attached, then usb_hotplug() will see this as a new device
having been attached, since there is no device recorded as being
currently attached to the port.  This can lead to spurious hotplug
events (or even endless loops of hotplug events, if the process of
opening and closing the device happens to generate a port status
change).

Fix by using a separate flag to indicate that a device is physically
attached (even if we have no corresponding struct usb_device).

Reported-by: Dan Ellis <Dan.Ellis@displaylink.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-12 00:57:15 +00:00
Michael Brown f3725a86e0 [rndis] Add rndis_rx_err()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-11 17:26:51 +00:00
Michael Brown 58c3e7f747 [usb] Allow usb_stream() to enforce a terminating short packet
Some USB endpoints require that a short packet be used to terminate
transfers, since they have no other way to determine message
boundaries.  If the message length happens to be an exact multiple of
the USB packet size, then this requires the use of an additional
zero-length packet.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-10 13:49:27 +00:00
Michael Brown 17aceb34da [usb] Parse endpoint descriptor bInterval field
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-10 01:14:22 +00:00
Michael Brown cf153f60a5 [usb] Handle CDC union functional descriptors
USB Communications Device Class devices may use a union functional
descriptor to group several interfaces into a function.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-09 16:34:55 +00:00
Michael Brown a60f2ddfeb [usb] Try multiple USB device configurations
Iterate over a USB device's available configurations until we find one
for which we have working drivers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-09 14:46:22 +00:00
Michael Brown e2a26f76de [uri] Allow tftp_uri() to construct a URI with a custom port
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-06 12:18:18 +00:00
Michael Brown cc5a27f9cb [ncm] Add support for CDC-NCM USB Ethernet devices
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-03 12:33:35 +00:00
Michael Brown fd53ada87c [usb] Add support for xHCI host controllers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-03 12:33:28 +00:00
Michael Brown e17e771a13 [usb] Add basic support for USB hubs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-03 12:19:52 +00:00
Michael Brown 018b13dcec [usb] Add basic support for USB devices
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-03 12:19:47 +00:00
Michael Brown 072d656a2f [pci] Allow drivers to specify a PCI class
Allow drivers to specify a supported PCI class code.  To save space in
the final binary, make this an attribute of the driver rather than an
attribute of a PCI device ID list entry.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-02 14:31:18 +00:00
Michael Brown 0166a68351 [hyperv] Require support for VMBus version 3.0 or newer
We require the ability to disconnect from and reconnect to VMBus; if
we don't have this then there is no (viable) way for a loaded
operating system to continue to use any VMBus devices.  (There is also
a small but non-zero risk that the host will continue to write to our
interrupt and monitor pages, since the VMBUS_UNLOAD message in earlier
versions is essentially a no-op.)

This requires us to ensure that the host supports protocol version 3.0
(VMBUS_VERSION_WIN8_1).  However, we can't actually _use_ protocol
version 3.0, since doing so causes an iSCSI-booted Windows Server 2012
R2 VM to crash due to a NULL pointer dereference in vmbus.sys.

To work around this problem, we first ensure that we can connect using
protocol v3.0, then disconnect and reconnect using the oldest known
protocol.

This deliberately prevents the use of the iPXE native Hyper-V drivers
on older versions of Hyper-V, where we could use our drivers but in so
doing would break the loaded operating system.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-21 11:21:23 +00:00
Michael Brown f6a3bc0aa1 [rndis] Ignore start-of-day RNDIS_INDICATE_STATUS_MSG with status 0x40020006
Windows Server 2012 R2 generates an RNDIS_INDICATE_STATUS_MSG with a
status code of 0x4002006.  This status code does not appear to be
documented anywhere within the sphere of human knowledge.

Explicitly ignore this status code in order to avoid unnecessarily
cluttering the display when RNDIS debugging is enabled.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-20 21:33:59 +00:00
Michael Brown 639632b059 [hyperv] Assume that VMBus xfer page ranges correspond to RNDIS messages
The (undocumented) VMBus protocol seems to allow for transfer
page-based packets where the data payload is split into an arbitrary
set of ranges within the transfer page set.

The RNDIS protocol includes a length field within the header of each
message, and it is known from observation that multiple RNDIS messages
can be concatenated into a single VMBus message.

iPXE currently assumes that the transfer page range boundaries are
entirely arbitrary, and uses the RNDIS header length to determine the
RNDIS message boundaries.

Windows Server 2012 R2 generates an RNDIS_INDICATE_STATUS_MSG for an
undocumented and unknown status code (0x40020006) with a malformed
RNDIS header length: the length does not cover the StatusBuffer
portion of the message.  This causes iPXE to report a malformed RNDIS
message and to discard any further RNDIS messages within the same
VMBus message.

The Linux Hyper-V driver assumes that the transfer page range
boundaries correspond to RNDIS message boundaries, and so does not
notice the malformed length field in the RNDIS header.

Match the behaviour of the Linux Hyper-V driver: assume that the
transfer page range boundaries correspond to the RNDIS message
boundaries and ignore the RNDIS header length.  This avoids triggering
the "malformed packet" error and also avoids unnecessary data copying:
since we now have one I/O buffer per RNDIS message, there is no longer
any need to use iob_split().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-20 21:33:53 +00:00
Michael Brown 4de0e273a7 [rndis] Send RNDIS_HALT_MSG
The RNDIS specification requires that we send RNDIS_HALT_MSG.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-19 18:09:04 +00:00
Michael Brown 1d0ade42db [rndis] Send RNDIS_INITIALISE_MSG
The Hyper-V RNDIS implementation on Windows Server 2012 R2 requires
that we send an explicit RNDIS initialisation message in order to get
a working RX datapath.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-19 17:05:56 +00:00
Michael Brown ef16d0d2b3 [hyperv] Add support for NetVSC paravirtual network devices
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-18 16:27:37 +00:00
Michael Brown d1894970db [hyperv] Add support for VMBus devices
Add support for an abstraction of a VMBus device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-18 16:27:37 +00:00
Michael Brown d77a546fb4 [hyperv] Add support for Hyper-V hypervisor
Add support for detecting and communicating with the Hyper-V
hypervisor.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-18 16:27:27 +00:00
Michael Brown 1d2b7c91f7 [rndis] Add generic RNDIS device abstraction
RNDIS provides an abstraction of a network device on top of a generic
packet transmission mechanism.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-18 14:46:38 +00:00
Michael Brown c86b22221d [iobuf] Add iob_split() to split an I/O buffer into portions
RNDIS devices may provide multiple packets encapsulated into a single
message.  Provide an API to allow the RNDIS driver to split an I/O
buffer into smaller portions.

The current implementation will always copy the underlying data,
rather than splitting the buffer in situ.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-18 14:46:38 +00:00
Michael Brown d83fb45b66 [device] Provide a driver-private data field for root devices
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-18 14:46:38 +00:00
Michael Brown 28149d30f5 [list] Add sanity checks after list-adding functions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-12 10:18:03 +00:00
Michael Brown 67879f66eb [libc] Add ASSERTED macro to test if any assertion has triggered
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-12 10:18:03 +00:00
Michael Brown dea6a6c1a0 [ping] Allow "ping" command output to be inhibited
Originally-implemented-by: Cedric Levasseur <cyr-ius@ipocus.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-23 16:52:08 +01:00
Michael Brown 1c34ca70d1 [ping] Allow termination after a specified number of packets
Add the "-c <count>" option to the "ping" command, allowing for
automatic termination after a specified number of packets.

When a number of packets is specified:

  - if a serious error (i.e. length mismatch or content mismatch)
    occurs, then the ping will be immediately terminated with the relevant
    status code;

  - if at least one response is received successfully, and all errors
    are non-serious (i.e. timeouts or out-of-sequence responses), then
    the ping will be terminated after the final response (or timeout)
    with a success status;

  - if no responses are received successfully, then the ping will be
    terminated after the final timeout with ETIMEDOUT.

If no number of packets is specified, then the ping will continue
until manually interrupted.

Originally-implemented-by: Cedric Levasseur <cyr-ius@ipocus.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-23 16:39:42 +01:00
Michael Brown 047baaba38 [efi] Add NII / UNDI driver
Some UEFI network drivers provide a software UNDI interface which is
exposed via the Network Interface Identifier Protocol (NII), rather
than providing a Simple Network Protocol (SNP).

The UEFI platform firmware will usually include the SnpDxe driver,
which attaches to NII and provides an SNP interface.  The SNP
interface is usually provided on the same handle as the underlying NII
device.  This causes problems for our EFI driver model: when
efi_driver_connect() detaches existing drivers from the handle it will
cause the SNP interface to be uninstalled, and so our SNP driver will
not be able to attach to the handle.  The platform firmware will
eventually reattach the SnpDxe driver and may attach us to the SNP
handle, but we have no way to prevent other drivers from attaching
first.

Fix by providing a driver which can attach directly to the NII
protocol, using the software UNDI interface to drive the network
device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-16 14:13:20 +01:00
Michael Brown 318b5fca1a [efi] Update to current EDK2 headers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-16 14:12:42 +01:00
Michael Brown b9a5ff2b03 [efi] Generalise snpnet_dev_info() to efi_device_info()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-16 14:12:42 +01:00
Michael Brown a48a71b720 [efi] Add definitions of GUIDs observed when chainloading from Intel driver
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-09-25 13:16:44 +01:00
Michael Brown 9ee89d0bf1 [efi] Centralise definitions of more protocol GUIDs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-09-25 12:29:12 +01:00
Michael Brown f94d651632 [efi] Avoid returning uninitialised data from PCI configuration space reads
Under UEFI, reads from PCI configuration space may fail.  If this
happens, we should return all-ones (which will mimic the behaviour of
an absent PCI device).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-09-04 16:00:11 +01:00
Michael Brown 0cc2f42f46 [efi] Wrap any images loaded by our wrapped image
Propagate our modified EFI system table to any images loaded by the
image that we wrap, thereby allowing us to observe boot services calls
made by all subsequent EFI images.

Also show details of intercepted ExitBootServices() calls.  When
wrapping is used, exiting boot services will almost certainly fail,
but this at least allows us to see when it happens.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-29 13:10:18 +01:00
Michael Brown a56bba3912 [efi] Add definitions of GUIDs observed during Windows boot
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-21 17:49:12 +01:00
Michael Brown 8b2942a7db [xen] Cope with unexpected initial backend states
Under some circumstances (e.g. if iPXE itself is booted via iSCSI, or
after an unclean reboot), the backend may not be in the expected
InitWait state when iPXE starts up.

There is no generic reset mechanism for Xenbus devices.  Recent
versions of xen-netback will gracefully perform all of the required
steps if the frontend sets its state to Initialising.  Older versions
(such as that found in XenServer 6.2.0) require the frontend to
transition through Closed before reaching Initialising.

Add a reset mechanism for netfront devices which does the following:

 - read current backend state

 - if backend state is anything other than InitWait, then set the
   frontend state to Closed and wait for the backend to also reach
   Closed

 - set the frontend state to Initialising and wait for the backend to
   reach InitWait.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-14 00:14:51 +01:00
Michael Brown be79ca535a [xen] Use version 1 grant tables by default
Using version 1 grant tables limits guests to using 16TB of grantable
RAM, and prevents the use of subpage grants.  Some versions of the Xen
hypervisor refuse to allow the grant table version to be set after the
first grant references have been created, so the loaded operating
system may be stuck with whatever choice we make here.  We therefore
currently use version 2 grant tables, since they give the most
flexibility to the loaded OS.

Current versions (7.2.0) of the Windows PV drivers have no support for
version 2 grant tables, and will merrily create version 1 entries in
what the hypervisor believes to be a version 2 table.  This causes
some confusion.

Avoid this problem by attempting to use version 1 tables, since
otherwise we may render Windows unable to boot.

Play nicely with other potential bootloaders by accepting either
version 1 or version 2 grant tables (if we are unable to set our
requested version).

Note that the use of version 1 tables on a 64-bit system introduces a
possible failure path in which a frame number cannot fit into the
32-bit field within the v1 structure.  This in turn introduces
additional failure paths into netfront_transmit() and
netfront_refill_rx().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-13 19:21:42 +01:00
Michael Brown 5c4f1da2ce [efi] Generalise snpnet_pci_info() to efi_locate_device()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-06 14:27:45 +01:00
Michael Brown 2bf428c2a9 [efi] Move abstract device path and handle functions to efi_utils.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-06 14:27:45 +01:00
Michael Brown 7b3cc18462 [efi] Open device path protocol only at point of use
Some EFI 1.10 systems (observed on an Apple iMac) do not allow us to
open the device path protocol with an attribute of
EFI_OPEN_PROTOCOL_BY_DRIVER and so we cannot maintain a safe,
long-lived pointer to the device path.  Work around this by instead
opening the device path protocol with an attribute of
EFI_OPEN_PROTOCOL_GET_PROTOCOL whenever we need to use it.

Debugged-by: Curtis Larsen <larsen@dixie.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-05 23:10:33 +01:00
Michael Brown 3b42ed477f [efi] Provide centralised definitions of commonly-used GUIDs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-05 23:08:32 +01:00
Michael Brown 4a480f1d15 [efi] Avoid unnecessarily passing pointers to EFI_HANDLEs
efi_file_install() and efi_download_install() are both used to install
onto existing handles.  There is therefore no need to allow for each
of their calls to InstallMultipleProtocolInterfaces() to create a new
handle.

By passing the handle directly (rather than a pointer to the handle),
we avoid potential confusion (and erroneous debug message colours).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31 12:50:09 +01:00
Michael Brown 88bd71a27a [efi] Allow compiler to perform type checks on EFI_HANDLE
The EFI headers define EFI_HANDLE as a void pointer, which renders
type checking on anything dealing with EFI handles somewhat useless.
Work around this bizarre sabotage attempt by redefining EFI_HANDLE as
a pointer to an anonymous structure.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31 12:17:59 +01:00
Michael Brown 2e0821b9ed [efi] Use efi_handle_name() instead of efi_handle_devpath_text()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31 11:56:44 +01:00
Michael Brown 736fcf60d1 [efi] Add ability to dump all openers of a given protocol on a handle
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31 01:50:05 +01:00
Michael Brown 550f212d15 [efi] Provide efi_handle_name() for debugging
Provide a function efi_handle_name() (as a generalisation of
efi_handle_devpath_text()) which tries various methods to produce a
human-readable name for an EFI handle.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31 01:49:58 +01:00
Michael Brown 0b40e76d95 [efi] Expand the range of well-known EFI GUIDs in debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31 01:49:50 +01:00
Michael Brown 98d09a1e03 [netdevice] Avoid registering duplicate network devices
Reject network devices which appear to be duplicates of those already
available via a different underlying hardware device.  On a Xen PV-HVM
system, this allows us to filter out the emulated PCI NICs (which
would otherwise appear alongside the netfront NICs).

Note that we cannot use the Xen facility to "unplug" the emulated PCI
NICs, since there is no guarantee that the OS we subsequently load
will have a native netfront driver.

We permit devices with the same MAC address if they are attached to
the same underlying hardware device (e.g. VLAN devices).

Inspired-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-30 18:22:09 +01:00
Michael Brown dc18fd7648 [efi] Default to releasing network devices for use via SNP
We currently treat network devices as available for use via the SNP
API only if RX queue processing has been frozen.  (This is similar in
spirit to the way that RX queue processing is frozen for the network
device currently exposed via the PXE API.)

The default state of a freshly created network device is for the RX
queue to not be frozen, and thus to be unavailable for use via SNP.
This causes problems when devices are added through code paths other
than _efidrv_start() (which explicitly releases devices for use via
SNP).

We don't actually need to freeze RX queue processing, since calls via
the SNP API will always use netdev_poll() rather than net_poll(), and
so will never trigger the RX queue processing code path anyway.

We can therefore simplify the code to use a single global flag to
indicate whether network devices are claimed for use by iPXE or
available for use via SNP.  Using a global flag allows the default
state for dynamically created network devices to behave sensibly.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-30 14:27:07 +01:00
Michael Brown 793a806611 [xen] Add support for Xen netfront virtual NICs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-29 15:57:56 +01:00
Michael Brown 036af27a45 [xen] Add basic support for PV-HVM domains
Add basic support for Xen PV-HVM domains (detected via the Xen
platform PCI device with IDs 5853:0001), including support for
accessing configuration via XenStore and enumerating devices via
XenBus.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-29 15:57:44 +01:00
Michael Brown ec94a8798f [xen] Import selected public headers
Import selected headers from the xen/include/public directory of the
Xen repository at git://xenbits.xen.org/xen.git

The script ./include/xen/import.pl can be used to automatically import
any required headers and their dependencies (in a similar fashion to
./include/ipxe/efi/import.pl).  Trailing whitespace is stripped and an
appropriate FILE_LICENCE declaration is added to each header file.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-29 15:20:49 +01:00
Michael Brown ec30c856a8 [ioapi] Centralise notion of PAGE_SIZE
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-28 16:58:35 +01:00
Michael Brown eb55c6871a [efi] Include EFI_CONSOLE_CONTROL_PROTOCOL header
The EFI_CONSOLE_CONTROL_PROTOCOL does not exist in the current UEFI
specification, but is required to enable text output on some older EFI
1.10 implementations (observed on an old iMac).

The header is not present in any of the standard include directories,
but can still be found in the EDK2 codebase as part of
EdkCompatibilityPkg.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-16 14:53:03 +01:00
Michael Brown c3b6ccf65b [efi] Allow for interception of boot services calls by loaded image
When building with DEBUG=efi_wrap, print details of calls made by the
loaded image to selected boot services functions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-16 01:58:19 +01:00
Michael Brown 8a380987c1 [efi] Install our own disk I/O protocol and claim exclusive use of it
The EFI FAT filesystem driver has a bug: if a block device contains no
FAT filesystem but does have an EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
instance, the FAT driver will assume that it must have previously
installed the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.  This causes the FAT
driver to claim control of our device, and to refuse to stop driving
it, which prevents us from later uninstalling correctly.

Work around this bug by opening the disk I/O protocol ourselves,
thereby preventing the FAT driver from opening it.

Note that the alternative approach of opening the block I/O protocol
(and thereby in theory preventing DiskIo from attaching to the block
I/O protocol) causes an endless loop of calls to our DRIVER_STOP
method when starting the EFI shell.  I have no idea why this is.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-14 16:30:19 +01:00
Michael Brown cff0103bd2 [efi] Update EDK2 headers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-14 16:13:55 +01:00
Michael Brown 8484e97f7c [crypto] Add support for iPAddress subject alternative names
Originally-implemented-by: Jarrod Johnson <jarrod.b.johnson@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-11 16:55:14 +01:00
Michael Brown bcfd3dea1d [efi] Identify autoboot device by MAC address when chainloading
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-08 00:37:31 +01:00
Michael Brown 00c745e5ff [autoboot] Allow autoboot device to be identified by link-layer address
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-08 00:37:31 +01:00
Michael Brown c7051d826b [efi] Allow network devices to be created on top of arbitrary SNP devices
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-03 15:28:17 +01:00
Michael Brown 0e3ab6064e [efi] Restructure EFI driver model
Provide a single instance of EFI_DRIVER_BINDING_PROTOCOL (attached to
our image handle); this matches the expectations scattered throughout
the EFI specification.

Open the underlying hardware device using EFI_OPEN_PROTOCOL_BY_DRIVER
and EFI_OPEN_PROTOCOL_EXCLUSIVE, to prevent other drivers from
attaching to the same device.

Do not automatically connect to devices when being loaded as a driver;
leave this task to the platform firmware (or to the user, if loading
directly from the EFI shell).

When running as an application, forcibly disconnect any existing
drivers from devices that we want to control, and reconnect them on
exit.

Provide a meaningful driver version number (based on the build
timestamp), to allow platform firmware to automatically load newer
versions of iPXE drivers if multiple drivers are present.

Include device paths within debug messages where possible, to aid in
debugging.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-25 14:47:35 +01:00
Michael Brown f2c116ff7d [efi] Provide a meaningful EFI SNP device name
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-25 14:46:41 +01:00
Michael Brown 44338bfd22 [efi] Allow device paths to be easily included in debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-25 14:44:13 +01:00
Michael Brown 8290a95513 [build] Expose build timestamp, build name, and product names
Expose the build timestamp (measured in seconds since the Epoch) and
the build name (e.g. "rtl8139.rom" or "ipxe.efi"), and provide the
product name and product short name in a single centralised location.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-24 15:32:35 +01:00
Dale Hamel 7fe0735170 [smbios] Expose board serial number as ${board-serial}
With blade servers, the chassis serial number (exposed via ${serial})
may not be unique.  Expose ${board-serial} as a named setting to
provide easy access to a more meaningful serial number.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-12 17:59:52 +01:00
Michael Brown d5cf058994 [iscsi] Include IP address origin in iBFT
The iBFT includes an "origin" field to indicate the source of the IP
address.  We use the heuristic of assuming that the source should be
"manual" if the IP address originates directly from the network device
settings block, and "DHCP" otherwise.  This is an imperfect guess, but
is likely to be correct in most common situations.

Originally-implemented-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-12 17:09:16 +01:00
Michael Brown e047811c85 [scsi] Improve sense code parsing
Parse the sense data to extract the reponse code, the sense key, the
additional sense code, and the additional sense code qualifier.

Originally-implemented-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-03 02:04:46 +01:00
Hannes Reinecke d630052e6f [ethernet] Provide eth_random_addr() to generate random Ethernet addresses
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-01 23:32:24 +01:00
Michael Brown 3c7f5f9c4c [ipv6] Fix definition of IN6_IS_ADDR_LINKLOCAL()
Fix an erroneous htonl() in the definition of IN6_IS_ADDR_LINKLOCAL(),
and add self-tests for the IN6_IS_ADDR_xxx() family of macros.

Reported-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-21 17:53:02 +01:00
Michael Brown 95cff6a4d8 [efi] Allow for optional protocols
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-19 20:23:31 +01:00
Marin Hannache f4e069bf2e [nfs] Rewrite NFS URI handling
Get the NFS URI manipulation code out of nfs_open.c.  The resulting
code is now much more readable.

Signed-off-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-18 21:53:39 +01:00
Michael Brown 6f410a16d9 [profile] Allow interrupts to be excluded from profiling results
Interrupt processing adds noise to profiling results.  Allow
interrupts (from within protected mode) to be profiled separately,
with time spent within the interrupt handler being excluded from any
other profiling currently in progress.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-04 13:39:42 +01:00
Michael Brown a0da06c306 [profile] Provide methods for profiling individual stages of operations
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 18:50:26 +01:00
Michael Brown 4413ab4f5a [build] Allow for a debug level of zero
Allow for an explicit debug level of zero, which will enable
assertions and profiling (i.e. anything controlled by NDEBUG) without
generating any debug messages.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-28 14:45:47 +01:00
Michael Brown 7c44fd68f0 [cmdline] Add "profstat" command to display profiling statistics
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-27 23:14:47 +01:00
Michael Brown e5f6a9be38 [profile] Add generic profiling infrastructure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-27 23:14:43 +01:00
Michael Brown d36e814b8a [libc] Add flsll()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-27 16:56:09 +01:00
Michael Brown 3ffd309375 [libc] Add isqrt() function to find integer square roots
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-26 18:19:49 +01:00
Michael Brown dce7107fc0 [libc] Add inline assembly implementation of flsl() using BSR instruction
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-24 14:49:08 +01:00
Michael Brown f10726c8bb [crypto] Add support for subjectAltName and wildcard certificates
Originally-implemented-by: Alex Chernyakhovsky <achernya@google.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31 13:36:54 +01:00
Michael Brown 7c7c957094 [crypto] Allow signed timestamp error margin to be configured at build time
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-30 20:08:00 +01:00
Michael Brown bc8ca6b8ce [crypto] Generalise X.509 cache to a full certificate store
Expand the concept of the X.509 cache to provide the functionality of
a certificate store.  Certificates in the store will be automatically
used to complete certificate chains where applicable.

The certificate store may be prepopulated at build time using the
CERT=... build command line option.  For example:

  make bin/ipxe.usb CERT=mycert1.crt,mycert2.crt

Certificates within the certificate store are not implicitly trusted;
the trust list is specified using TRUST=... as before.  For example:

  make bin/ipxe.usb CERT=root.crt TRUST=root.crt

This can be used to embed the full trusted root certificate within the
iPXE binary, which is potentially useful in an HTTPS-only environment
in which there is no HTTP server from which to automatically download
cross-signed certificates or other certificate chain fragments.

This usage of CERT= extends the existing use of CERT= to specify the
client certificate.  The client certificate is now identified
automatically by checking for a match against the private key.  For
example:

  make bin/ipxe.usb CERT=root.crt,client.crt TRUST=root.crt KEY=client.key

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-28 17:09:40 +00:00
Michael Brown 2dd3fffe18 [crypto] Add pubkey_match() to check for matching public/private key pairs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-27 00:30:47 +00:00
Michael Brown e1ebc50f81 [crypto] Remove dynamically-allocated storage for certificate OCSP URI
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-25 16:30:43 +00:00
Michael Brown 01fa7efa38 [crypto] Remove dynamically-allocated storage for certificate name
iPXE currently allocates a copy the certificate's common name as a
string.  This string is used by the TLS and CMS code to check
certificate names against an expected name, and also appears in
debugging messages.

Provide a function x509_check_name() to centralise certificate name
checking (in preparation for adding subjectAlternativeName support),
and a function x509_name() to provide a name to be used in debugging
messages, and remove the dynamically allocated string.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-25 16:30:43 +00:00
Michael Brown f473b9c3f6 [efi] Disable SNP devices when running iPXE as the application
Some UEFI builds will set up a timer to continuously poll any SNP
devices.  This can drain packets from the network device's receive
queue before iPXE gets a chance to process them.

Use netdev_rx_[un]freeze() to explicitly indicate when we expect our
network devices to be driven via the external SNP API (as we do with
the UNDI API on the standard BIOS build), and disable the SNP API
except when receive queue processing is frozen.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-14 17:09:51 +00:00
Michael Brown 87465258ab [netdevice] Notify upper-layer drivers when RX processing is (un)frozen
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-14 14:05:38 +00:00
Michael Brown 8de6b973c4 [efi] Allow driver to be unloaded
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-10 16:39:46 +00:00
Michael Brown 9681170fbe [efi] Allow for 64-bit EFI_STATUS codes
On a 64-bit build, EFI_STATUS codes are 64-bit quantities, with the
"error/warning" bit located in bit 63.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-10 16:39:46 +00:00
Michael Brown 3f43c1354e [image] Add "--timeout" parameter to image downloading commands
iPXE will detect timeout failures in several situations: network
link-up, DHCP, TCP connection attempts, unacknowledged TCP data, etc.
This does not cover all possible circumstances.  For example, if a
connection to a web server is successfully established and the web
server acknowledges the HTTP request but never sends any data in
response, then no timeout will be triggered.  There is no timeout
defined within the HTTP specifications, and the underlying TCP
connection will not generate a timeout since it has no way to know
that the HTTP layer is expecting to receive data from the server.

Add a "--timeout" parameter to "imgfetch", "chain", etc.  If no
progress is made (i.e. no data is downloaded) within the timeout
period, then the download will be aborted.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-10 13:32:39 +00:00
Michael Brown 9d615539f0 [mii] Add mii_dump() to dump all MII registers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-10 12:21:54 +00:00
Michael Brown e191298a1d [tcp] Calculate correct MSS from peer address
iPXE currently advertises a fixed MSS of 1460, which is correct only
for IPv4 over Ethernet.  For IPv6 over Ethernet, the value should be
1440 (allowing for the larger IPv6 header).  For non-Ethernet link
layers, the value should reflect the MTU of the underlying network
device.

Use tcpip_mtu() to calculate the transport-layer MTU associated with
the peer address, and calculate the MSS to allow for an optionless TCP
header as per RFC 6691.

As a side benefit, we can now fail a connection immediately with a
meaningful error message if we have no route to the destination
address.

Reported-by: Anton D. Kachalov <mouse@yandex-team.ru>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-04 13:23:29 +00:00
Michael Brown 6414b5ca03 [tcpip] Provide tcpip_mtu() to determine the maximum transmission unit
Provide the function tcpip_mtu() to allow external code to determine
the (transport-layer) maximum transmission unit for a given socket
address.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-04 13:13:54 +00:00
Michael Brown db67de6f31 [tcpip] Provide tcpip_netdev() to determine the transmitting network device
Provide the function tcpip_netdev() to allow external code to
determine the transmitting network device for a given socket address.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-04 13:02:58 +00:00
Alex Williamson 123bae9d93 [autoboot] Enable infrastructure to specify an autoboot device location
iPXE will currently attempt to boot from every network device for
which it has a driver.  Where a system has more than one network
device supported by iPXE, this renders BIOS IPL lists ineffective.

Allow an autoboot device location to be specified.  If such a location
is specified, then only devices matching that location will be used as
part of the automatic boot sequence.  If no such location is
specified, then all devices will be used.

Note that this does not affect the "autoboot" command, which will
continue to use all devices.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-03 15:11:03 +00:00
Michael Brown f22c19f3fb [cmdline] Add the "ipstat" command
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-02 23:57:47 +00:00
Michael Brown 11963c4f5f [tcpip] Add IP statistics collection as per RFC 4293
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-02 20:33:35 +00:00
Michael Brown c165e8d1fc [image] Ensure every image has a fully resolved URI
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-27 13:32:58 +00:00
Michael Brown 7667536527 [uri] Refactor URI parsing and formatting
Add support for parsing of URIs containing literal IPv6 addresses
(e.g. "http://[fe80::69ff:fe50:5845%25net0]/boot.ipxe").

Duplicate URIs by directly copying the relevant fields, rather than by
formatting and reparsing a URI string.  This relaxes the requirements
on the URI formatting code and allows it to focus on generating
human-readable URIs (e.g. by not escaping ':' characters within
literal IPv6 addresses).  As a side-effect, this allows relative URIs
containing parameter lists (e.g. "../boot.php##params") to function
as expected.

Add validity check for FTP paths to ensure that only printable
characters are accepted (since FTP is a human-readable line-based
protocol with no support for character escaping).

Construct TFTP next-server+filename URIs directly, rather than parsing
a constructed "tftp://..." string,

Add self-tests for URI functions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-27 13:32:53 +00:00
Michael Brown c7b69ac793 [params] Use reference counters for form parameter lists
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-26 23:34:07 +00:00
Michael Brown d4c0226a6c [dns] Support DNS search lists
Update the DNS resolver to support DNS search lists (as provided by
DHCP option 119, DHCPv6 option 24, or NDP option 31).

Add validation code to ensure that parsing of DNS packets does not
overrun the input, get stuck in infinite loops, or (worse) write
beyond the end of allocated buffers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-05 14:56:49 +00:00
Michael Brown 43c8c272ae [cmdline] Rename "console" command's --bpp option to --depth
Rename the "--bpp" option to "--depth", to free up the single-letter
option "-b" for "--bottom" in preparation for adding margin support.

This does not break backwards compatibility with documented features,
since the "console" command has not yet been documented.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-22 14:28:49 +00:00
Michael Brown 608d6cac9e [fbcon] Allow for an arbitrary margin around the text area
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-22 14:26:31 +00:00
Michael Brown 7fc380e950 [fbcon] Centre background picture on console
Centre the background picture on the console, to give a more
consistent result when the aspect ratio does not match the requested
width and height.

Once drawn for the first time, nothing should ever overwrite the
margins of the display.  We can therefore eliminate the logic used to
redraw only the margin areas, and use much simpler code to draw the
complete initial background image.

Simplify the redrawing logic further by making the background picture
buffer equal in size to the frame buffer.  In the common case of a
background picture which is designed to fill the screen, this wastes
no extra memory, and the combined code simplifications reduce the size
of fbcon.o by approximately 15%.

Redefine the concept of "margin" to match the intuitive definition
(i.e. the size of the gap, rather than the position of the boundary
line).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-22 14:16:34 +00:00
Michael Brown c6c8078964 [png] Add support for PNG images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12 22:53:16 +01:00
Michael Brown fffd98bd37 [uaccess] Add memcmp_user()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12 22:53:16 +01:00
Michael Brown 26f782bb41 [libc] Add abs()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12 22:53:16 +01:00
Michael Brown 9bdfc36bcc [deflate] Add support for DEFLATE decompression
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-06 03:10:41 +01:00
Michael Brown 23f17f7972 [test] Add okx() macro taking an explicit file name and line number
Allow test reports to specify an explicit file name and line number
using the extended okx() macro.  This allows large blocks of test
report code such as tcpip_random_ok() to be implemented as functions
rather than macros.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-06 03:09:37 +01:00
Michael Brown a4e8ef72ab [libc] Add isprint()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-06 01:46:20 +01:00
Michael Brown 2200ca0e8f [ipv6] Fix compilation under FreeBSD
Reported-by: Dewey Hylton <dewey@hyltown.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-21 13:22:53 +00:00
Michael Brown f6dce77b15 [console] Add concept of a "magic" colour
The magic basic colour can be remapped at runtime from COLOR_NORMAL_BG
(usually blue) to COLOR_DEFAULT (which will be transparent as a
background colour on the framebuffer console).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-09 15:34:14 +00:00
Michael Brown 7025f5c648 [console] Add centralised concept of colours and colour pairs
Add a centralised concept of colours and colour pairs (using the
default colour pairs as configured via config/colour.h).  A colour
pair consists of a pair of colour indices.

Add the ability to redefine both a colour pair and an individual
colour index, with minimal overhead if this feature is not required
(e.g. because the relevant shell commands are not present in the
build).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-09 15:34:07 +00:00
Michael Brown 03401f9d21 [console] Allow consoles to update the recorded console size
Provide a mechanism for consoles to update the recorded console width
and height, and use this width and height to provide the curses COLS
and LINES variables.

We choose not to use ANSI escape sequences to obtain the width and
height, for two reasons:

- iPXE's model is that all output is sent to all consoles; we could
  therefore end up with multiple consoles reporting conflicting widths
  and heights

- when a serial console is in use, we probably don't want to resize
  the output shown on the BIOS console to match the size of the serial
  console, since it's likely that the serial console is in use only
  for debugging.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-06 17:47:54 +00:00
Michael Brown 99c679696a [ipv6] Expose NDP-provided settings (including the DNS server)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 16:44:50 +00:00
Michael Brown 4a6c453b5b [dhcpv6] Add DHCPv6 "filename" setting
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 15:12:50 +00:00
Michael Brown f3e5df3162 [settings] Merge SETTING_IPv4 and SETTING_IPv6
Allow for equivalent IPv4 and IPv6 settings (which requires equivalent
settings to be adjacent within the settings list).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 15:11:15 +00:00
Michael Brown b0942534eb [settings] Force settings into alphabetical order within sections
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 12:43:28 +00:00
Michael Brown 8aab959bed [dhcpv6] Use DUID-UUID form of client DUID
Use the system UUID to generate the client DUID-UUID as per RFC 6355.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 03:18:59 +00:00
Michael Brown 03957bcb47 [linux] Provide access to SMBIOS via /dev/mem
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 03:16:27 +00:00
Michael Brown 44a0dc7848 [syslog] Add support for IPv6 syslog server
Note that IANA has not yet assigned a DHCPv6 option code for the
syslog server.  When a code is assigned, the definition of
DHCPV6_LOG_SERVERS should be updated.  Until then, an IPv6 address of
a syslog server can be configured manually using e.g.

  set syslog6 3ffe:302:11:2::8309

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 01:27:33 +00:00
Michael Brown 2649e8ef70 [socket] Ensure socket address structure sizes are fixed
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 01:21:10 +00:00
Michael Brown 6248894f52 [dns] Add support for resolving IPv6 addresses via AAAA records
Our policy is to prefer IPv6 addreses to IPv4 addresses, but to
request IPv6 addresses only if we have an IPv6 address for the name
server itself.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 00:41:49 +00:00
Michael Brown 60c4e62e5d [settings] Add fetch_ipv6_setting()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 00:41:49 +00:00
Michael Brown 17451b53e2 [settings] Allow for IPv6 setting types in non-IPv6 builds
Allow for the existence of references to IPv6 setting types without
dragging in the whole IPv6 stack, by placing the definition of
setting_type_ipv6 in core/settings.c and providing weak stub methods
for parse_ipv6_setting() and format_ipv6_setting().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 00:41:49 +00:00
Michael Brown 22001cb206 [settings] Explicitly separate the concept of a completed fetched setting
The fetch_setting() family of functions may currently modify the
definition of the specified setting (e.g. to add missing type
information).  Clean up this interface by requiring callers to provide
an explicit buffer to contain the completed definition of the fetched
setting, if required.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 00:37:02 +00:00
Michael Brown a2638a8edd [fbcon] Add support for displaying a cursor
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-02 17:27:37 +00:00
Michael Brown 936971d0ed [mucurses] Implement curs_set() to control cursor visibility
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-02 17:23:09 +00:00
Michael Brown 135bf35b11 [console] Allow '?' as an intermediate byte in ANSI escape sequences
The ANSI escape sequences to show and hide the cursor take the form
"<ESC>[?25h" and "<ESC>[?25l" respectively.  iPXE currently treats the
'?' character as the final byte.  Fix by explicitly treating '?' as an
intermediate byte.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-02 17:20:36 +00:00
Michael Brown decf9dd133 [fbcon] Add generic concept of a frame buffer console
Add support for a simple frame buffer console, using single buffering
and a fixed-width bitmap font.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 05:55:45 +00:00
Michael Brown c501c980e0 [console] Add concept of generic console configuration
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 05:55:43 +00:00
Michael Brown b2251743d8 [console] Allow console input and output to be disabled independently
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 05:54:53 +00:00
Michael Brown 7271b50890 [mucurses] Use "<ESC>[2J" ANSI escape sequence to clear screen
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 05:03:05 +00:00
Michael Brown 0ee89338dd [pnm] Add support for PNM images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:51 +00:00
Michael Brown 09f31e9fc4 [image] Add image_pixbuf() to create pixel buffer from image
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:50 +00:00
Michael Brown 95851d1305 [pixbuf] Add generic concept of a pixel buffer
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:50 +00:00
Michael Brown 02a63c6dec [console] Pass escape sequence context to ANSI escape sequence handlers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:50 +00:00
Michael Brown 1312c467ee [test] Include failing code within failed test result output
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:45 +00:00
Michael Brown 6b1eee0452 [ipv6] Separate the concepts of prefix and address creation
Allow for IPv6 routing table entries to be created for an on-link
prefix where a local address has not yet been assigned to the network
device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-15 15:22:54 +00:00
Michael Brown 2fa34085e2 [dhcpv6] Add basic support for stateful and stateless DHCPv6
Add support for the stateful and stateless variants of the DHCPv6
protocol.  The resulting settings block is registered as
"net<x>.dhcpv6", and DHCPv6 options can be obtained using
e.g. "${net0.dhcpv6/23:ipv6}" to obtain the IPv6 DNS server address.

IPv6 addresses obtained via stateful DHCPv6 are not yet applied to the
network device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-14 12:35:43 +00:00
Michael Brown c1570d3dfb [ipv6] Add "ipv6" setting type
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-14 12:35:43 +00:00
Michael Brown 95623e353b [ipv6] Use given source address only if it is not the unspecified address
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-14 12:35:43 +00:00
Michael Brown 4484edd1c0 [settings] Move user-class setting from dhcp.c to settings.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-14 12:35:43 +00:00
Michael Brown 6871a8113f [ipv6] Add IPv6 network device configurator
Include IPv6 within the generic network device configurator
mechanism.  The IPv6 configurator will send a router solicitation and
wait for a router advertisement to be received.  (As per RFC4861
section 6.3.7, we do this even if advertisements have been received
prior to sending the router solicitation.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-07 15:04:47 +00:00
Michael Brown c99f9ee9df [dhcp] Remove obsolete dhcp() function
All functionality provided by dhcp() has now been obviated by the more
generic ifconf().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-05 17:42:55 +00:00
Michael Brown 452fb2d0a2 [cmdline] Make "dhcp" command a synonym for "ifconf"
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-05 17:42:55 +00:00
Michael Brown 26b87b221b [ifmgmt] Add ifconf() to carry out network device configuration
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-05 17:30:20 +00:00
Michael Brown 3a67224c62 [parseopt] Add parse_netdev_configurator()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-05 17:30:20 +00:00
Michael Brown f2bc138391 [netdevice] Add generic concept of a network device configurator
iPXE supports multiple mechanisms for network device configuration:
DHCPv4 for IPv4, FIP for FCoE, and SLAAC for IPv6.  At present, DHCPv4
requires an explicit action (e.g. a "dhcp" command), FIP is initiated
implicitly upon opening a network device, and SLAAC takes place
whenever a RA happens to be received.

Add a generic concept of a network device configurator, which provides
a common interface to triggering configuration and to reporting the
result of the configuration process.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-05 17:30:15 +00:00
Michael Brown 55e85ad1ee [cmdline] Allow "if<xxx>" commands to take options
Allow commands implemented using ifcommon_exec() to accept
command-specific options.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-05 17:15:24 +00:00
Michael Brown 16d37102ca [ifmgmt] Rewrite iflinkwait() to use monojob_wait()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-05 17:15:24 +00:00
Michael Brown 92c56e129b [cmdline] Rewrite "sync" command to use monojob_wait()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-01 17:00:16 +00:00
Michael Brown d1be9f4acc [monojob] Add timeout parameter to monojob_wait()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-01 16:26:02 +00:00