people/meteger/gpxe.git
9 years ago[ipv6] Update the NDP cache when receiving a router advertisement
Matthew Iselin [Sat, 4 Jun 2011 02:20:52 +0000 (12:20 +1000)]
[ipv6] Update the NDP cache when receiving a router advertisement

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Handle netdev parameter being non-null in ipv6_tx
Matthew Iselin [Sat, 4 Jun 2011 02:10:38 +0000 (12:10 +1000)]
[ipv6] Handle netdev parameter being non-null in ipv6_tx

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Implement router solicitations and integrate with the "ipv6" command
Matthew Iselin [Sat, 4 Jun 2011 02:10:23 +0000 (12:10 +1000)]
[ipv6] Implement router solicitations and integrate with the "ipv6" command

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[dns] Handle AAAA records
Matthew Iselin [Thu, 2 Jun 2011 13:14:57 +0000 (23:14 +1000)]
[dns] Handle AAAA records

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Verify validity of IPv6 address in inet6_aton
Matthew Iselin [Thu, 2 Jun 2011 13:14:37 +0000 (23:14 +1000)]
[ipv6] Verify validity of IPv6 address in inet6_aton

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Make IPv6 routing work with addresses not on local network
Matthew Iselin [Thu, 2 Jun 2011 11:51:58 +0000 (21:51 +1000)]
[ipv6] Make IPv6 routing work with addresses not on local network

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Fix inet6_aton and remove some unnecessary debugging
Matthew Iselin [Wed, 1 Jun 2011 13:03:59 +0000 (23:03 +1000)]
[ipv6] Fix inet6_aton and remove some unnecessary debugging

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Implement handling of neighbour solicit messages
Matthew Iselin [Wed, 1 Jun 2011 12:13:30 +0000 (22:13 +1000)]
[ipv6] Implement handling of neighbour solicit messages

Implement handling of neighbour solicit messages and improve handling
of neighbour advert messages.

Also:

  - Add handling of ICMPv6 echoes, mostly for debugging
  - Implement router advertisement handling for autoconfiguration

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Enable ICMPv6 protocols to check addresses against network devices
Matthew Iselin [Wed, 1 Jun 2011 11:45:44 +0000 (21:45 +1000)]
[ipv6] Enable ICMPv6 protocols to check addresses against network devices

Add a net_protocol so that ICMPv6 protocols can check IPv6 addresses
against network devices.

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Call icmp6_rx directly from ipv6.c
Matthew Iselin [Wed, 8 Jun 2011 12:31:33 +0000 (22:31 +1000)]
[ipv6] Call icmp6_rx directly from ipv6.c

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[uri] Make URI parsing handle IPv6_address:port
Matthew Iselin [Mon, 30 May 2011 12:30:51 +0000 (22:30 +1000)]
[uri] Make URI parsing handle IPv6_address:port

For example:

    http://[fc00::1]:1234

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Fix icmp6 neighbour solicit multicast address creation
Matthew Iselin [Mon, 30 May 2011 12:29:37 +0000 (22:29 +1000)]
[ipv6] Fix icmp6 neighbour solicit multicast address creation

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Fix link-local and local network routing in ipv6_tx
Matthew Iselin [Mon, 30 May 2011 12:28:12 +0000 (22:28 +1000)]
[ipv6] Fix link-local and local network routing in ipv6_tx

This has broken stuff because gPXE doesn't yet respond to neighbour
solicits itself, and it's now possible to have several IPv6 addresses
on a live gPXE instance.

As such, expect TCP (over IPv6) timeouts and such after this commit.

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Fix formatting on a DBG line
Matthew Iselin [Mon, 30 May 2011 12:25:43 +0000 (22:25 +1000)]
[ipv6] Fix formatting on a DBG line

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[tcp] Enable AF_INET6 transport for tcp connections
Matthew Iselin [Mon, 30 May 2011 07:11:53 +0000 (17:11 +1000)]
[tcp] Enable AF_INET6 transport for tcp connections

Now that IPv6 is somewhat usable, enable AF_INET6 transport for tcp
connections.

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[uri] Make URI parsing handle IPv6 addresses
Matthew Iselin [Thu, 26 May 2011 11:27:47 +0000 (21:27 +1000)]
[uri] Make URI parsing handle IPv6 addresses

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Implement inet6_aton, numeric IPv6 address resolution
Matthew Iselin [Thu, 26 May 2011 11:27:14 +0000 (21:27 +1000)]
[ipv6] Implement inet6_aton, numeric IPv6 address resolution

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Add function prototype for inet6_ntoa
Matthew Iselin [Mon, 30 May 2011 07:11:34 +0000 (17:11 +1000)]
[ipv6] Add function prototype for inet6_ntoa

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Modify "ipv6" command to set an IPv6 address on an interface
Matthew Iselin [Thu, 26 May 2011 08:44:54 +0000 (18:44 +1000)]
[ipv6] Modify "ipv6" command to set an IPv6 address on an interface

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Make inet6_ntoa handle all-zero addresses properly
Matthew Iselin [Thu, 26 May 2011 08:43:21 +0000 (18:43 +1000)]
[ipv6] Make inet6_ntoa handle all-zero addresses properly

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Add "ipv6" command to perform stateless autoconfiguration
Matthew Iselin [Tue, 24 May 2011 10:53:00 +0000 (20:53 +1000)]
[ipv6] Add "ipv6" command to perform stateless autoconfiguration

This command performs stateless autoconfiguration on a given network
interface. It does not yet assign the address to the netdevice.

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[igb] Remove __BIG_ENDIAN conditional
Thomas Miletich [Sun, 10 Jul 2011 15:47:09 +0000 (17:47 +0200)]
[igb] Remove __BIG_ENDIAN conditional

Reported-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Thomas Miletich <thomas.miletich@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Implemented zero-compression in inet6_ntoa and fixed IPv6 packet RX
Matthew Iselin [Wed, 27 Apr 2011 09:34:18 +0000 (19:34 +1000)]
[ipv6] Implemented zero-compression in inet6_ntoa and fixed IPv6 packet RX

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Make IPv6 configuration option disabled by default
Marty Connor [Tue, 5 Jul 2011 15:01:37 +0000 (11:01 -0400)]
[ipv6] Make IPv6 configuration option disabled by default

For testing, adding the line:

   #define NET_PROTO_IPV6

to the file:

   src/config/local/general.h

should enable this option.

Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[ipv6] Add IPv6 configuration option
Matthew Iselin [Wed, 27 Apr 2011 09:28:11 +0000 (19:28 +1000)]
[ipv6] Add IPv6 configuration option

In preparation for adding IPv6 code to gPXE we create the
NET_PROTO_IPV6 configuration option, disabled by default.

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[3c90x] Clean up reset code
Thomas Miletich [Tue, 1 Feb 2011 22:08:45 +0000 (23:08 +0100)]
[3c90x] Clean up reset code

Removes duplicate hardware resets, remove network interface logic reset.

This also fixes a bug where some 3c905C variants would return bogus
EEPROM values because of a too short delay after the network reset.

Signed-off-by: Thomas Miletich <thomas.miletich@gmail.com>
Reported-by: Peter Huewe <peterhuewe@gmx.de>
Tested-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Marty Connor <mdc@etherboot.org>
9 years ago[3c90x] More fine-grained debugging levels
Thomas Miletich [Tue, 1 Feb 2011 22:08:44 +0000 (23:08 +0100)]
[3c90x] More fine-grained debugging levels

DBG is reserved for errors and important warnings only.
DBG2 for additional information, e.g. "received packet".
DBGP is used to print the name of every function as it is called.

Signed-off-by: Thomas Miletich<thomas.miletich@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[eepro100] Add new PCI ID 8086:27dc
Marty Connor [Mon, 30 Aug 2010 14:24:51 +0000 (10:24 -0400)]
[eepro100] Add new PCI ID 8086:27dc

Add PCI ID 8086:27dc to the eepro100 driver.

Reported-by: Cédric Delmas <c.delmas@akka.eu>
Signed-off-by: Thomas Miletich <thomas.miletich@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[compiler] Prevent empty weak function stubs from being removed
Joshua Oreman [Wed, 18 Aug 2010 23:37:22 +0000 (16:37 -0700)]
[compiler] Prevent empty weak function stubs from being removed

Even with the noinline specifier added by commit 1a260f8, gcc may
skip calls to non-inlinable functions that it knows have no side
effects. This caused the get_cached_dhcpack() call in start_dhcp(),
the weak stub of which has no code in its body, to be removed,
preventing cached DHCP from working.

Fix by adding a __keepme macro to compiler.h expanding to asm(""),
as recommended by gcc's info page, and using it in the weak stub
for get_cached_dhcpack().

Reported-by: Aaron Brooks <aaron@brooks1.net>
Tested-by: Aaron Brooks <aaron@brooks1.net>
Signed-off-by: Joshua Oreman <oremanj@rwcr.net>
10 years ago[dhcp] Allow multiple interfaces in dhcp command
Lars Kellogg-Stedman [Sat, 31 Jul 2010 08:20:41 +0000 (09:20 +0100)]
[dhcp] Allow multiple interfaces in dhcp command

The "dhcp" command now accepts a list of interfaces and to try until one
succeeds:

 gPXE> dhcp net0 net1 net2

If an interface does not exist a message is printed and it is skipped.

If given the single parameter "any" as an interface name, all interfaces
are tried in a manner similar to autoboot:

 gPXE> dhcp any
 DHCP (net0 xx:xx:xx:xx:xx:xx)........ Connection timed out (...)
 Could not configure net0: Connection timed out (...)
 DHCP (net1 xx:xx:xx:xx:xx:xx).... ok
 gPXE>

Note that interfaces which fail to DHCP are closed.  This is usually
desirable since an open interface consumes memory.  On machines with
several interfaces it is possible to exhaust the heap if all interfaces
are open simultaneously.  This behavior differs from the previous "dhcp"
command implementation but should not be detectable to user scripts
since they abort when the dhcp command exits with an error.

Acked-by: Marty Connor <mdc@etherboot.org>
Signed-off-by: Lars Kellogg-Stedman <lars@oddbit.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[tcp] Allow out-of-order receive queue to be discarded
Michael Brown [Wed, 21 Jul 2010 11:01:50 +0000 (12:01 +0100)]
[tcp] Allow out-of-order receive queue to be discarded

Allow packets in the receive queue to be discarded in order to free up
memory.  This avoids a potential deadlock condition in which the
missing packet can never be received because the receive queue is
occupying all of the memory available for further RX buffers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[malloc] Add cache discard mechanism
Michael Brown [Wed, 21 Jul 2010 10:58:50 +0000 (11:58 +0100)]
[malloc] Add cache discard mechanism

Add a facility allowing cached data to be discarded in order to
satisfy memory allocations that would otherwise fail.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[tcp] Fix a 64bit compile time error
Piotr Jaroszyński [Thu, 22 Jul 2010 20:10:40 +0000 (22:10 +0200)]
[tcp] Fix a 64bit compile time error

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[tcp] Handle out-of-order received packets
Michael Brown [Tue, 20 Jul 2010 22:17:30 +0000 (23:17 +0100)]
[tcp] Handle out-of-order received packets

Maintain a queue of received packets, so that lost packets need not
result in retransmission of the entire TCP window.

Increase the TCP window to 8kB, in order that we can potentially
transmit enough duplicate ACKs to trigger Fast Retransmission at the
sender.

Using a 10MB HTTP download in qemu-kvm with an artificial drop rate of
1 in 64 packets, this reduces the download time from around 26s to
around 4s.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[tcp] Treat ACKs as sent only when successfully transmitted
Michael Brown [Thu, 15 Jul 2010 18:33:46 +0000 (19:33 +0100)]
[tcp] Treat ACKs as sent only when successfully transmitted

gPXE currently forces sending (i.e. sends a pure ACK even in the
absence of fresh data to send) only in response to packets that
consume sequence space or that lie outside of the receive window.
This ignores the possibility that a previous ACK was not actually sent
(due to, for example, the retransmission timer running).

This does not cause incorrect behaviour, but does cause unnecessary
retransmissions from our peer.  For example:

 1. Peer sends final data packet (ack      106 seq 521..523)
 2. We send FIN                  (seq 106..107 ack      523)
 3. Peer sends FIN               (ack      106 seq 523..524)
 4. We send nothing since retransmission timer is running for our FIN
 5. Peer ACKs our FIN            (ack      107 seq 524..524)
 6. We send nothing since this packet consumes no sequence space
 7. Peer retransmits FIN         (ack      107 seq 523..524)
 8. We ACK peer's FIN            (seq 107..107 ack      524)

What should happen at step (6) is that we should ACK the peer's FIN,
since we can deduce that we have never sent this ACK.

Fix by maintaining an "ACK pending" flag that is set whenever we are
made aware that our peer needs an ACK (whether by consuming sequence
space or by sending a packet that appears out of order), and is
cleared only when the ACK packet has been transmitted.

Reported-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[tcp] Merge boolean flags into a single "flags" field
Michael Brown [Thu, 15 Jul 2010 18:15:36 +0000 (19:15 +0100)]
[tcp] Merge boolean flags into a single "flags" field

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Modified-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[tcp] Use a dedicated timer for the TIME_WAIT state
Michael Brown [Thu, 15 Jul 2010 17:57:34 +0000 (18:57 +0100)]
[tcp] Use a dedicated timer for the TIME_WAIT state

gPXE currently repurposes the retransmission timer to hold the TCP
connection in the TIME_WAIT state (i.e. waiting for up to 2*MSL in
case we are required to re-ACK our peer's FIN due to a lost ACK).
However, the fact that this timer is running will prevent such an ACK
from ever being sent, since the logic in tcp_xmit() assumes that a
running timer indicates that we ourselves are waiting for an ACK and
so blocks the transmission.  (We always wait for an ACK before sending
our next packet, to keep our transmit data path as simple as
possible.)

Fix by using an entirely separate timer for the TIME_WAIT state, so
that packets can still be sent.

Reported-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[hci] Continue processing while prompting for shell banner
Guo-Fu Tseng [Tue, 13 Jul 2010 13:18:47 +0000 (21:18 +0800)]
[hci] Continue processing while prompting for shell banner

Currently we do nothing while polling for user input in shell_banner.
This commit modifies shell_bannder to do something similar to what is
done in shell, where we schedule processes while waiting for user
input.

This approach provides two potential improvements:

First:
We increase key responsiveness in shell_banner. It is much more
likely to successfully get into shell than before. Before this
change I sometimes pressed the CTRL_B, but failed to get into
shell. It may have been caused by waiting too long in
mdelay(100).

Second:
When using scripts, if the downloaded image is not bootable,
gPXE exits before it has the opportunity to gracefully close
the TCP connection. This can leave the TCP state of a remote
server as not closed when it should have been.

gPXE waits for user to input for 2 seconds by default before
returning control to BIOS. This commit lets TCP have the
opportunity to gracefully close while waiting for the user to
hit keys in shell_banner.

Referenced: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Commit-message-modified-by: Marty Connor <mdc@etherboot.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[cmdline] Fix inconsistent and ugly code formatting in shell_banner()
Michael Brown [Wed, 14 Jul 2010 10:17:26 +0000 (11:17 +0100)]
[cmdline] Fix inconsistent and ugly code formatting in shell_banner()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Modified-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[tcp] Randomize TCP bind port
Guo-Fu Tseng [Tue, 13 Jul 2010 13:16:26 +0000 (21:16 +0800)]
[tcp] Randomize TCP bind port

This changes is intended to reduce possible TCP port collisions.

Reviewed-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[tcp] Fix typos by changing ntohl() to htonl() where appropriate
Michael Brown [Tue, 13 Jul 2010 16:18:48 +0000 (17:18 +0100)]
[tcp] Fix typos by changing ntohl() to htonl() where appropriate

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[tcp] Store local port in host byte order
Michael Brown [Tue, 13 Jul 2010 16:15:57 +0000 (17:15 +0100)]
[tcp] Store local port in host byte order

Every other scalar integer value in struct tcp_connection is in host
byte order; change the definition of local_port to match.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[tcp] Update received sequence number before delivering received data
Michael Brown [Fri, 21 May 2010 23:45:49 +0000 (00:45 +0100)]
[tcp] Update received sequence number before delivering received data

gPXE currently updates the TCP sequence number after delivering the
data to the application via xfer_deliver_iob().  If the application
responds to the received data by transmitting more data, this would
result in a stale ACK number appearing in the transmitted packet,
which potentially causes retransmissions and also gives the
undesirable appearance of violating causality (by sending a response
to a message that we claim not to have yet received).

Reported-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
10 years ago[comboot] Run com32 programs with a valid IDT
Geoff Lywood [Wed, 7 Jul 2010 22:35:01 +0000 (15:35 -0700)]
[comboot] Run com32 programs with a valid IDT

COM32 binaries generally expect to run with interrupts enabled. Syslinux does
so, and COM32 programs will execute cli/sti pairs when running a critical
section, to provide mutual exclusion against BIOS interrupt handlers.
Previously, under gPXE, the IDT was not valid, so any interrupt (e.g. a timer
tick) would generally cause the machine to triple fault.

This change introduces code to:
- Create a valid IDT at the same location that syslinux uses
- Create an "interrupt jump buffer", which contains small pieces of code that
  simply record the vector number and jump to a common handler
- Thunk down to real mode and execute the BIOS's interrupt handler whenever
  an interrupt is received in a COM32 program
- Switch IDTs and enable/disable interrupts when context switching to and from
  COM32 binaries

Testing done:
- Booted VMware ESX using a COM32 multiboot loader (mboot.c32)
- Built with GDBSERIAL enabled, and tested breakpoints on int22 and com32_irq
- Put the following code in a COM32 program:
    asm volatile ( "sti" );
    while ( 1 );
  Before this change, the machine would triple fault immediately. After this
  change, it hangs as expected. Under Bochs, it is possible to see the
  interrupt handler run, and the current time in the BIOS data area gets
  incremented.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[efi] Fix the 32-bit version of elf2efi64
Geoff Lywood [Wed, 21 Jul 2010 02:23:02 +0000 (19:23 -0700)]
[efi] Fix the 32-bit version of elf2efi64

Currently, if elf2efi.c is compiled using a 32-bit HOST_CC, then the
resulting elf2efi64 binary will generate 32-bit EFI binaries instead of
64-bit EFI binaries.

The problem is, elf2efi.c uses the MDE_CPU_* definitions to decide
whether to output a 32-bit or 64-bit PE binary. However, MDE_CPU_* gets
defined in ProcessorBind.h, depending on the compiler's target
architecture. Overriding them on the command line doesn't work in the
expected way, and you can end up in cases where both MDE_CPU_IA32 and
MDE_CPU_X64 are defined.

The patch below should fix the problem. I tested this patch by building
with all 4 combinations of 32- and 64-bit toolchains, targeting both 32-
and 64-bit EFI. In each case, I used objdump to verify that the file
format of bin-*-efi/snponly.efi matched what was expected. I also booted
the 64-bit executable that was generated using the 32-bit toolchain.

Signed-off-by: Geoff Lywood <glywood@vmware.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[forcedeth] Replace driver with native gPXE driver
Andrei Faur [Thu, 29 Jul 2010 20:36:14 +0000 (23:36 +0300)]
[forcedeth] Replace driver with native gPXE driver

This patch adds a native gPXE forcedeth driver and removes the legacy
Etherboot forcedeth driver. It supports 40 different chips, compared
to the original 14.

It has been tested on a NIC with an CK804 Ethernet Controller, and
the results of downloading 5 100mb images in a row have been: 12/11/11/11/11
seconds; booting DSL using pxelinux also succeeded. The driver has also
been tested by chaining undionly.kpxe and it worked.

Signed-off-by: Andrei Faur <da3drus@gmail.com>
Tested-by: Andrei Faur <da3drus@gmail.com>
Tested-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[string] Use 64-bit registers in assembly memswap() on x86_64
Joshua Oreman [Fri, 30 Jul 2010 16:52:03 +0000 (09:52 -0700)]
[string] Use 64-bit registers in assembly memswap() on x86_64

An assembly version of memswap() is in an x86 word-length-agnostic
header file, but it used 32-bit registers to store pointers, leading
to memory errors responding to ARP queries on 64-bit systems.

Signed-off-by: Joshua Oreman <oremanj@rwcr.net>
10 years ago[802.11] Fix a use-after-free
Joshua Oreman [Fri, 30 Jul 2010 03:13:31 +0000 (20:13 -0700)]
[802.11] Fix a use-after-free

When we received an encrypted packet, after replacing it with its decrypted
version and freeing the encrypted original, we would continue to look at
the header of the now-freed original packet. Fix by moving the header pointer
to point at the decrypted packet instead.

10 years ago[802.11] Use correct name for sec80211_detect()
Joshua Oreman [Fri, 30 Jul 2010 03:12:35 +0000 (20:12 -0700)]
[802.11] Use correct name for sec80211_detect()

The workhorse function for detecting 802.11 security was still named
_sec80211_detect(), a holdover from the old style of weak function
handling, with the result that all networks would be identified as
"unknown".

10 years ago[settings] Unregister the children when unregistering the parent
Piotr Jaroszyński [Wed, 14 Jul 2010 20:25:55 +0000 (22:25 +0200)]
[settings] Unregister the children when unregistering the parent

The DHCP settings registered as a child of the netdevice settings are
not unregistered anywhere.  This prevents the netdevice from being
freed on shutdown.

Fix by automatically unregistering any child settings when the parent
settings are unregistered.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Joshua Oreman <oremanj@rwcr.net>
10 years ago[virtio] Replace virtio-net with native gPXE driver
Stefan Hajnoczi [Fri, 2 Jul 2010 18:15:47 +0000 (19:15 +0100)]
[virtio] Replace virtio-net with native gPXE driver

This patch adds a native gPXE virtio-net driver and removes the legacy
Etherboot virtio-net driver.  The main reasons for doing this are:

1. Multiple virtio-net NICs are now supported by gPXE.  The legacy
   driver kept global state and caused issues in virtual machines with
   more than one virtio-net device.

2. Faster downloads.  The native gPXE driver downloads 100 MB over HTTP
   in 12s, the legacy Etherboot driver in 37s.  This simple benchmark
   uses KVM with tap networking and the Python SimpleHTTPServer both
   running on the same host.

Changes to core virtio code reduce vring descriptors to 256 (QEMU uses
128 for virtio-blk and 256 for virtio-net) and change the opaque token
from u16 to void*.  Lowering the descriptor count reduces memory
consumption.  The void* opaque token change makes driver code simpler.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[errcode] Remove unused contrib/errcode scripts
Stefan Hajnoczi [Sun, 11 Jul 2010 07:52:57 +0000 (08:52 +0100)]
[errcode] Remove unused contrib/errcode scripts

The new errdb error code database is more accurate than the regular
expression-based errcode scripts.  This patch removes errcode scripts in
favor of errdb.

The gpxebot.py script is no longer needed, gpxebot has been released as
a separate open source codebase:

  http://git.etherboot.org/?p=people/stefanha/gpxebot.git;a=summary

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[compiler] Mark weak functions noinline
Stefan Hajnoczi [Wed, 14 Jul 2010 07:32:48 +0000 (08:32 +0100)]
[compiler] Mark weak functions noinline

Weak functions whose visibility is hidden may be inlined due to a bug in
GCC.  Explicitly mark weak functions noinline to work around the
problem.

This makes the PXE_MENU config option work again, the PXE boot menu was
never being called because the compiler inlined a weak stub function.

The GCC bug was identified and fixed by Richard Sandiford
<rdsandiford@googlemail.com> but in the meantime gPXE needs to implement
a workaround.

Reported-by: Steve Jones <steve@squaregoldfish.co.uk>
Reported-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Suggested-by: Joshua Oreman <oremanj@rwcr.net>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[image] Fix a memleak in free_image()
Piotr Jaroszyński [Thu, 8 Jul 2010 13:54:55 +0000 (15:54 +0200)]
[image] Fix a memleak in free_image()

image_set_cmdline() strdup()s cmdline, which free_image() doesn't clean
up.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[tcp] Fix potential use-after-free when accessing timestamp option
Michael Brown [Wed, 7 Jul 2010 11:57:08 +0000 (12:57 +0100)]
[tcp] Fix potential use-after-free when accessing timestamp option

Reported-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[refcnt] Fix embedded image building
Alessandro Salvatori [Mon, 5 Jul 2010 10:01:23 +0000 (11:01 +0100)]
[refcnt] Fix embedded image building

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[pcnet32] Fix pcnet32_wio_reset() bug
Andrei Faur [Wed, 7 Jul 2010 12:43:41 +0000 (15:43 +0300)]
[pcnet32] Fix pcnet32_wio_reset() bug

This bug caused .probe to fail because the NIC did not reset properly.

Signed-off-by: Andrei Faur <da3drus@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[romprefix] Do not check for BBS compatibility
Michael Brown [Thu, 24 Jun 2010 18:03:04 +0000 (19:03 +0100)]
[romprefix] Do not check for BBS compatibility

The existence and usage of the BEV entry point is covered by the PnP
spec, not the BBS spec; the BBS spec merely describes a policy for
selecting the boot device order.  gPXE should therefore check only for
a PnP BIOS in order to decide whether or not to hook INT19.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[build] Avoid hard-coding the path to perl
Michael Brown [Thu, 24 Jun 2010 00:23:00 +0000 (01:23 +0100)]
[build] Avoid hard-coding the path to perl

The path "/usr/bin/perl" has been hard-coded since Etherboot 5.1, for
no discernible reason.  Use just "perl" instead to fix the
inconsistency and allow building on systems with Perl installed
outside of /usr/bin.

This commit also includes a later fix that removes a dependency on
"perl" which broke builds from fully clean trees.

Reported-by: Gabor Z. Papp <gzp@papp.hu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[efi] Build gPXE script support into EFI binaries by default
Geoff Lywood [Wed, 16 Jun 2010 21:35:24 +0000 (14:35 -0700)]
[efi] Build gPXE script support into EFI binaries by default

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[refcnt] Add ref_no_free handler
Joshua Oreman [Thu, 26 Nov 2009 01:27:50 +0000 (17:27 -0800)]
[refcnt] Add ref_no_free handler

Since more reference-counted structures than embedded images might
want to mark themselves unfreeable, expose a dummy ref_no_free().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[retry] Use start_timer_fixed() instead of direct timeout manipulation
Michael Brown [Tue, 15 Jun 2010 17:16:02 +0000 (18:16 +0100)]
[retry] Use start_timer_fixed() instead of direct timeout manipulation

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[retry] Add timer_init() wrapper function
Michael Brown [Tue, 15 Jun 2010 17:13:36 +0000 (18:13 +0100)]
[retry] Add timer_init() wrapper function

Standardise on using timer_init() to initialise an embedded retry
timer, to match the coding style used by other embedded objects.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[refcnt] Add ref_init() wrapper function
Michael Brown [Tue, 15 Jun 2010 16:33:23 +0000 (17:33 +0100)]
[refcnt] Add ref_init() wrapper function

Standardise on using ref_init() to initialise an embedded reference
count, to match the coding style used by other embedded objects.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[errdb] Add errdb.pl script to build error database
Michael Brown [Mon, 31 May 2010 13:22:24 +0000 (14:22 +0100)]
[errdb] Add errdb.pl script to build error database

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[libc] Enable automated extraction of error usage reports
Michael Brown [Sun, 30 May 2010 14:29:05 +0000 (15:29 +0100)]
[libc] Enable automated extraction of error usage reports

Add preprocessor magic to the error definitions to enable every error
usage to be tracked.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[process] Hold reference to process during call to step()
Michael Brown [Fri, 13 Jun 2008 02:39:22 +0000 (03:39 +0100)]
[process] Hold reference to process during call to step()

It is conceivable that the process may terminate during the execution
of step().  If nothing else holds a reference to the containing
object, this would cause the object to be freed prior to returning
from step().

Add a ref_get()/ref_put() around the call to ->step() to prevent this
from happening.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[qib7322] Fix whitespace errors
Michael Brown [Tue, 1 Jun 2010 18:11:38 +0000 (19:11 +0100)]
[qib7322] Fix whitespace errors

Fix up the whitespace errors inadvertently introduced by the
last-minute rename from the internal QLogic codename to "qib7322".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[qib7322] Fix uninitialized variables warning
Shao Miller [Tue, 1 Jun 2010 17:19:33 +0000 (17:19 +0000)]
[qib7322] Fix uninitialized variables warning

Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[pxe] Remove obsolete pxe_errortab.c
Michael Brown [Sun, 30 May 2010 22:27:22 +0000 (23:27 +0100)]
[pxe] Remove obsolete pxe_errortab.c

strerror() has not been able to use the PXE-only error table since
commit 9aa61ad ("Add per-file error identifiers") back in 2007.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[efi] Tidy up output of EFI header import script
Michael Brown [Sat, 29 May 2010 22:47:30 +0000 (23:47 +0100)]
[efi] Tidy up output of EFI header import script

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[legal] Add FILE_LICENCE declarations to EFI header files
Michael Brown [Sat, 29 May 2010 22:06:06 +0000 (23:06 +0100)]
[legal] Add FILE_LICENCE declarations to EFI header files

Autodetect the BSD licence statement in EFI header files, and add a
suitable FILE_LICENCE macro to the version imported into the gPXE
tree.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[efi] Synchronise EFI header files
Michael Brown [Sat, 29 May 2010 21:39:22 +0000 (22:39 +0100)]
[efi] Synchronise EFI header files

Now that the PACKED macro conflict is resolved, we can use an
unmodified import of the EFI header files (using
include/gpxe/efi/import.pl).

Synchronised to EDK2 SVN revision 10556.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[build] Remove PACKED macro
Michael Brown [Sat, 29 May 2010 15:51:48 +0000 (16:51 +0100)]
[build] Remove PACKED macro

Most of gPXE uses __attribute__((packed)) anyway, and PACKED conflicts
with an identically-named macro in the upstream EFI header files.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[build] Add rtl8139.rom to the default build target list
Michael Brown [Thu, 27 May 2010 22:20:44 +0000 (23:20 +0100)]
[build] Add rtl8139.rom to the default build target list

rtl8139.rom is the target used in qemu/kvm, which is the default test
platform for iPXE and also commonly used for gPXE.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[build] Inhibit "skipping incompatible" message from ld
Michael Brown [Thu, 27 May 2010 08:42:53 +0000 (09:42 +0100)]
[build] Inhibit "skipping incompatible" message from ld

On 64-bit systems with both 32-bit and 64-bit libraries installed, ld
tends to generate noisy "skipping incompatible /usr/lib/libxxx.so"
messages when building elf2efi.c.

Fix by passing --no-warn-search-mismatch to ld.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[qib7322] Add support for QLogic 7322 HCA
Michael Brown [Wed, 11 Nov 2009 00:50:34 +0000 (00:50 +0000)]
[qib7322] Add support for QLogic 7322 HCA

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[pxe] Treat PXENV_RESTART_TFTP as unreturnable
Michael Brown [Fri, 21 May 2010 02:10:03 +0000 (03:10 +0100)]
[pxe] Treat PXENV_RESTART_TFTP as unreturnable

Microsoft WDS can end up calling PXENV_RESTART_TFTP to execute a
second-stage NBP which then exits.  Specifically, wdsnbp.com uses
PXENV_RESTART_TFTP to execute pxeboot.com, which will exit if the user
does not press F12.  gPXE currently treats PXENV_RESTART_TFTP as a
normal PXE API call, and so attempts to return to wdsnbp.com, which
has just been vaporised by pxeboot.com.

Use rmsetjmp/rmlongjmp to preserve the stack state as of the initial
NBP execution, and to restore this state immediately prior to
executing the NBP loaded via PXENV_RESTART_TFTP.  This matches the
behaviour in the PXE spec (which says that "if TFTP is restarted,
control is never returned to the caller"), and allows pxeboot.com to
exit relatively cleanly back to gPXE.

As with all usage of setjmp/longjmp, there may be subtle corner case
bugs due to not gracefully unwinding any state accumulated by the time
of the longjmp call, but this seems to be the only viable way to
provide the specified behaviour.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[lacp] Add simple LACP implementation
Michael Brown [Mon, 10 May 2010 15:30:10 +0000 (16:30 +0100)]
[lacp] Add simple LACP implementation

Some switch configurations will refuse to enable our port unless we
can speak LACP to inform the switch that we are alive.  Add a very
simple passive LACP implementation that is sufficient to convince at
least Linux's bonding driver (when tested using qemu attached to a tap
device enslaved to a bond device configured as "mode=802.3ad").

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[build] Fix building with binutils 2.16
Michael Brown [Tue, 27 Apr 2010 08:52:22 +0000 (09:52 +0100)]
[build] Fix building with binutils 2.16

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[romprefix] Add .mrom format, allowing loading of large ROMs
Michael Brown [Sun, 25 Apr 2010 14:57:00 +0000 (15:57 +0100)]
[romprefix] Add .mrom format, allowing loading of large ROMs

Add an infrastructure allowing the prefix to provide an open_payload()
method for obtaining out-of-band access to the whole gPXE image.  Add
a mechanism within this infrastructure that allows raw access to the
expansion ROM BAR by temporarily borrowing an address from a suitable
memory BAR on the same PCI card.

For cards that have a memory BAR that is at least as large as their
expansion ROM BAR, this allows large gPXE ROMs to be supported even on
systems where PMM fails, or where option ROM space pressure makes it
impossible to use PMM shrinking.  The BIOS sees only a stub ROM of
approximately 3kB in size; the remainder (which can be well over 64kB)
is loaded only at the time gPXE is invoked.

As a nice side-effect, an gPXE .mrom image will continue to work even
if its PMM-allocated areas are overwritten between initialisation and
invocation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[build] Replace obsolete makerom.pl with quick script using Option::ROM
Michael Brown [Sun, 25 Apr 2010 01:54:12 +0000 (02:54 +0100)]
[build] Replace obsolete makerom.pl with quick script using Option::ROM

The only remaining useful function of makerom.pl is to correct the ROM
and PnP checksums; the PCI IDs are set at link time, and padding is
performed using padimg.pl.

Option::ROM already provides a facility for correcting the checksums,
so we may as well just use this instead.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[main] Match "starting execution" and "initialising devices" message style
Michael Brown [Sun, 25 Apr 2010 00:47:03 +0000 (01:47 +0100)]
[main] Match "starting execution" and "initialising devices" message style

Add a trailing "ok" to the "initialising devices message", to match
the visual style of the "ok" now added to the "starting execution"
message.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[romprefix] Inhibit the use of relocation during POST
Michael Brown [Sun, 25 Apr 2010 00:37:25 +0000 (01:37 +0100)]
[romprefix] Inhibit the use of relocation during POST

It is common for system memory maps to be grotesquely unreliable
during POST.  Many sanity checks have been added to the memory map
reading code, but these do not catch all problems.

Skip relocation entirely if called during POST.  This should avoid the
problems typically encountered, at the cost of slightly disrupting the
memory map of an operating system booted via gPXE when gPXE was
entered during POST.  Since this is a very rare special case (used,
for example, when reflashing an experimental ROM that would otherwise
prevent the system from completing POST), this is an acceptable cost.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[romprefix] Split PMM allocations for image source and decompression area
Michael Brown [Sat, 24 Apr 2010 21:34:28 +0000 (22:34 +0100)]
[romprefix] Split PMM allocations for image source and decompression area

Some BIOSes (at least some AMI BIOSes) tend to refuse to allocate a
single area large enough to hold both the gPXE image source and the
temporary decompression area, despite promising a largest available
PMM memory block of several megabytes.  This causes ROM image
shrinking to fail on these BIOSes, with undesirable consequences:
other option ROMs may be disabled due to shortage of option ROM space,
and the gPXE ROM may itself be corrupted by a further BIOS bug (again,
observed on an AMI BIOS) which causes large ROMs to end up overlapping
reserved areas of memory.  This can potentially render a system
unbootable via any means.

Increase the chances of a successful PMM allocation by dropping the
alignment requirement (which is redundant now that we can enable A20
from within the prefix); this allows us to reduce the allocation size
from 2MB down to only the required size.

Increase the chances still further by using two separate allocations:
one to hold the image source (i.e. the copy of the ROM before being
shrunk) and the other to act as the decompression area.  This allows
ROM image shrinking to take place even on systems that fail to
allocate enough memory for the temporary decompression area.

Improve the behaviour of gPXE in systems with multiple gPXE ROMs by
sharing PMM allocations where possible.  Image source areas can be
shared with any gPXE ROMs with a matching build identifier, and the
temporary decompression area can be shared with any gPXE ROMs with the
same uncompressed size (rounded up to the nearest 128kB).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[prefix] Use area at top of INT 15,88 memory map for temporary decompression
Michael Brown [Sat, 24 Apr 2010 21:22:54 +0000 (22:22 +0100)]
[prefix] Use area at top of INT 15,88 memory map for temporary decompression

Use INT 15,88 to find a suitable temporary decompression area, rather
than a fixed address.  This hopefully gives us a better chance of not
treading on any PMM-allocated areas, in BIOSes where PMM support
exists but tends not to give us the large blocks that we ask for.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[pcbios] Always show INT 15,88 result under DEBUG=memmap
Michael Brown [Sat, 24 Apr 2010 20:52:48 +0000 (21:52 +0100)]
[pcbios] Always show INT 15,88 result under DEBUG=memmap

Always call INT 15,88 even if we don't use the result.  This allows
DEBUG=memmap to show the complete result set returned by all of the
INT 15 memory-map calls.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[build] Generate random build identifier
Michael Brown [Sat, 24 Apr 2010 18:15:51 +0000 (19:15 +0100)]
[build] Generate random build identifier

Randomly generate a 32-bit build identifier that can be used to
identify identical gPXE ROMs when multiple such ROMs are present in a
system (e.g. when a multi-function NIC exposes the same gPXE ROM image
via each function's expansion ROM BAR).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[romprefix] Provide indication of successful call to install_prealloc
Michael Brown [Wed, 21 Apr 2010 12:35:31 +0000 (13:35 +0100)]
[romprefix] Provide indication of successful call to install_prealloc

The existing "gPXE starting execution" message indicates that the BEV
(or INT19) was invoked, but gives no indication on whether or not the
gPXE source was successfully retrieved (e.g. from PMM).  Split the
"starting execution message" into "starting execution...ok"; the "ok"
indicates that the main gPXE body was successfully decompressed and
relocated.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[prefix] Default to 1MB mark as fallback high memory load point
Michael Brown [Tue, 20 Apr 2010 19:44:23 +0000 (20:44 +0100)]
[prefix] Default to 1MB mark as fallback high memory load point

Now that we can use odd megabytes, there is no particular need to use
an even megabyte as the fallback temporary load point.

Note that the old warnings about avoiding 2MB pre-date our ability to
cooperate with other PXE ROMs by using PMM.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[relocate] Remove the even megabyte constraint
Michael Brown [Tue, 20 Apr 2010 18:33:41 +0000 (19:33 +0100)]
[relocate] Remove the even megabyte constraint

gPXE is now capable of operating in odd megabytes of memory, so remove
the obsolete code enforcing an even-megabyte constraint.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[librm] Use libflat to enable A20 line on each real-to-protected transition
Michael Brown [Tue, 20 Apr 2010 18:20:26 +0000 (19:20 +0100)]
[librm] Use libflat to enable A20 line on each real-to-protected transition

Use the shared code in libflat to perform the A20 transitions
automatically on each transition from real to protected mode.  This
allows us to remove all explicit calls to gateA20_set().

The old warnings about avoiding automatically enabling A20 are
essentially redundant; they date back to the time when we would always
start hammering the keyboard controller without first checking to see
if gate A20 was already enabled (which it almost always is).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[prefix] Add A20-enabling code in libflat
Michael Brown [Tue, 20 Apr 2010 17:49:43 +0000 (18:49 +0100)]
[prefix] Add A20-enabling code in libflat

gPXE currently insists on residing in an even megabyte.  This imposes
undesirably severe constraints upon our PMM allocation strategy, and
limits our options for mechanisms to access ROMs greater than 64kB in
size.

Add A20 handling code to libflat so that prefixes are able to access
memory even in odd megabytes.

The algorithms and tuning parameters in the new A20 handling code are
based upon a mixture of the existing gPXE A20 code and the A20 code
from the 2.6.32 Linux kernel.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[prefix] Move flatten_real_mode to libflat.S
Michael Brown [Tue, 20 Apr 2010 13:23:55 +0000 (14:23 +0100)]
[prefix] Move flatten_real_mode to libflat.S

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[prefix] Move flatten_real_mode to .text16.early
Michael Brown [Tue, 20 Apr 2010 11:59:48 +0000 (12:59 +0100)]
[prefix] Move flatten_real_mode to .text16.early

The flatten_real_mode routine is not needed until after decompressing
.text16.early, and currently performs various contortions to
compensate for the fact that .prefix may not be writable.  Move
flatten_real_mode to .text16.early to save on (compressed) binary size
and simplify the code.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[prefix] Add .text16.early section
Michael Brown [Tue, 20 Apr 2010 10:05:53 +0000 (11:05 +0100)]
[prefix] Add .text16.early section

Add a section .text16.early which is always kept inline with the
prefix.  This will allow for some code sharing between the .prefix and
.text16 sections.

Note that the simple solution of just prepending the .prefix section
to the .text16 section will not work, because a bug in Wyse Streaming
Manager server (WLDRM13.BIN) requires us to place a dummy PXENV+ entry
point at the start of .text16.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[prefix] Use flat real mode for access to high memory
Michael Brown [Mon, 19 Apr 2010 21:22:11 +0000 (22:22 +0100)]
[prefix] Use flat real mode for access to high memory

Use flat real mode rather than 16-bit protected mode for access to
high memory during installation.  This simplifies the code by reducing
the number of CPU modes we need to think about, and also increases the
amount of code in common between the normal and (somewhat
hypothetical) KEEP_IT_REAL methods of operation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[prefix] Use flat real mode instead of real mode
Michael Brown [Mon, 19 Apr 2010 20:53:36 +0000 (21:53 +0100)]
[prefix] Use flat real mode instead of real mode

When returning to real mode, set 4GB segment limits instead of 64kB
limits.  This change improves our chances of successfully returning to
a PMM-capable BIOS aftering entering gPXE during POST; the BIOS will
have set up flat real mode before calling our initialisation point,
and may be disconcerted if we then return in genuine real mode.

This change is unlikely to break anything, since any code that might
potentially access beyond 64kB must use addr32 prefixes to do so; if
this is the case then it is almost certainly code written to expect
flat real mode anyway.

Note that it is not possible to restore the real-mode segment limits
to their original values, since it is not possible to know which
protected-mode segment descriptor was originally used to initialise
the limit portion of the segment register.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[romprefix] Remove .hrom prefix
Michael Brown [Mon, 19 Apr 2010 19:38:35 +0000 (20:38 +0100)]
[romprefix] Remove .hrom prefix

The .hrom prefix provides an experimental mechanism for reducing
option ROM space usage on systems where PMM allocation fails, by
pretending that PMM allocation succeeded and gave us an address fixed
at compilation time.  This is unreliable, and potentially dangerous.
In particular, when multiple gPXE ROMs are present in a system, each
gPXE ROM will assume ownership of the same fixed address, resulting in
undefined behaviour.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
10 years ago[romprefix] Remove .xrom prefix
Michael Brown [Mon, 19 Apr 2010 19:32:25 +0000 (20:32 +0100)]
[romprefix] Remove .xrom prefix

The .xrom prefix provides an experimental mechanism for loading ROM
images greater than 64kB in size by mapping the expansion ROM BAR in
at a hopefully-unused address.  This is unreliable, and potentially
dangerous.  In particular, there is no guarantee that any PCI bridges
between the CPU and the device will respond to accesses for the
"unused" memory region that is chosen, and it is possible that the
process of scanning for the "unused" memory region may end up issuing
reads to other PCI devices.  If this ends up trampling on a register
with read side-effects belonging to an unrelated PCI device, this may
cause undefined behaviour.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>