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

959 Commits

Author SHA1 Message Date
Piotr Jaroszyński bb5b66b887 [linux] Add linuxprefix
Add a minimal _start required to run main.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-08-19 12:28:21 +01:00
Piotr Jaroszyński e84db1121b [linux] Add linux platform skeleton
Add makefiles, ld scripts and default config for linux platform for
both i386 and x86_64.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-08-19 12:25:06 +01:00
Michael Brown 42a1f43bf9 [build] Provide %.fd0 build targets only for pcbios
Originally-fixed-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-08-17 14:36:39 +01:00
Piotr Jaroszyński 6142b721bf [build] Build pcbios specific drivers only on pcbios
Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-08-16 16:54:37 +01:00
Piotr Jaroszyński 5bbad9c8f0 [ioapi] Move get_memmap() to the I/O API group
pcbios specific get_memmap() is used by the b44 driver making
all-drivers builds fail on other platforms.  Move it to the I/O API
group and provide a dummy implementation on EFI.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-08-16 16:54:03 +01:00
Geoff Lywood a4023e02e8 [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 iPXE, 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>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-08-01 17:38:18 +01:00
Michael Brown 3094d2cf33 [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.  iPXE 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>
2010-06-24 19:03:04 +01:00
Michael Brown 719b49879d [build] Fix broken build caused by implied dependency upon "perl"
Commit ea12dc0 ("[build] Avoid hard-coding the path to perl")
introduced a build failure for fully clean trees (e.g. after running
"make veryclean"), since the dependency upon $(PARSEROM) now includes
a dependency upon "perl" (which doesn't exist) rather than upon
"/usr/bin/perl" (which does exist).

There should of course be no dependency upon the perl binary at all;
the dependency should be upon "./util/parserom.pl" alone.

Fix by removing the $(PERL) from the definition of Perl-based utility
paths, and adding $(PERL) at the point of usage.

Reported-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-06-24 17:25:54 +01:00
Michael Brown 4327d5d39f [interface] Convert all data-xfer interfaces to generic interfaces
Remove data-xfer as an interface type, and replace data-xfer
interfaces with generic interfaces supporting the data-xfer methods.

Filter interfaces (as used by the TLS layer) are handled using the
generic pass-through interface capability.  A side-effect of this is
that deliver_raw() no longer exists as a data-xfer method.  (In
practice this doesn't lose any efficiency, since there are no
instances within the current codebase where xfer_deliver_raw() is used
to pass data to an interface supporting the deliver_raw() method.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-06-22 15:50:31 +01:00
Michael Brown 7b4fbd93a5 [interface] Convert all name-resolution interfaces to generic interfaces
Remove name-resolution as an interface type, and replace
name-resolution interfaces with generic interfaces supporting the
resolv_done() method.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-06-22 15:45:57 +01:00
Wu Fengguang a6a4909afc [doc] Fix comment on Linux/x86 boot protocol path
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-06-03 11:07:44 +01:00
Michael Brown 6c0e8c14be [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>
2010-05-31 03:11:57 +01:00
Michael Brown d2415be069 [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>
2010-05-30 23:30:59 +01:00
Michael Brown 307b39c08c [build] Remove PACKED macro
Most of iPXE 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>
2010-05-29 23:49:47 +01:00
Geoff Lywood 6514d6430d [dhcp] Use correct DHCP options on EFI systems
See RFC 4578 for details.

Signed-off-by: Joshua Oreman <oremanj@rwcr.net>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-05-29 08:51:46 +01:00
Joshua Oreman 2aad3fab23 [build] Use weak definitions instead of weak declarations
This removes the need for inline safety wrappers, marginally reducing
the size penalty of weak functions, and works around an apparent
binutils bug that causes undefined weak symbols to not actually be
NULL when compiling with -fPIE (as EFI builds do).

A bug in versions of binutils prior to 2.16 (released in 2005) will
cause same-file weak definitions to not work with those
toolchains. Update the README to reflect our new dependency on
binutils >= 2.16.

Signed-off-by: Joshua Oreman <oremanj@rwcr.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-05-27 10:19:14 +01:00
Stefan Hajnoczi 0d108681ac [comboot] Propagate carry flag from COMBOOT API
COMBOOT API calls set the carry flag on failure.  This was not being
propagated because the COMBOOT interrupt handler used iret to return
with EFLAGS restored from the stack.  This patch propagates CF before
returning from the interrupt.

Reported-by: Geoff Lywood <glywood@vmware.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-05-25 06:24:58 +01:00
Michael Brown dc8eb04647 [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.  iPXE 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 iPXE.

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>
2010-05-21 03:12:13 +01:00
Michael Brown 2d9a303248 [build] Fix building with binutils 2.16
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-27 09:52:22 +01:00
Michael Brown 132c391712 [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 iPXE 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 iPXE 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 iPXE is invoked.

As a nice side-effect, an iPXE .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>
2010-04-25 16:37:06 +01:00
Michael Brown d8c1f2e94f [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>
2010-04-25 02:54:12 +01:00
Michael Brown 5a5d8dd10a [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 iPXE when iPXE 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>
2010-04-25 01:50:46 +01:00
Michael Brown c97079710f [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 iPXE 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 iPXE 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 iPXE in systems with multiple iPXE ROMs by
sharing PMM allocations where possible.  Image source areas can be
shared with any iPXE ROMs with a matching build identifier, and the
temporary decompression area can be shared with any iPXE ROMs with the
same uncompressed size (rounded up to the nearest 128kB).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-25 01:50:46 +01:00
Michael Brown f0ae1d58e8 [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>
2010-04-25 01:50:46 +01:00
Michael Brown bae3964e6f [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>
2010-04-25 01:50:46 +01:00
Michael Brown 58f6e55362 [build] Generate random build identifier
Randomly generate a 32-bit build identifier that can be used to
identify identical iPXE ROMs when multiple such ROMs are present in a
system (e.g. when a multi-function NIC exposes the same iPXE ROM image
via each function's expansion ROM BAR).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-25 01:50:46 +01:00
Michael Brown 483c3c06ab [romprefix] Provide indication of successful call to install_prealloc
The existing "iPXE starting execution" message indicates that the BEV
(or INT19) was invoked, but gives no indication on whether or not the
iPXE source was successfully retrieved (e.g. from PMM).  Split the
"starting execution message" into "starting execution...ok"; the "ok"
indicates that the main iPXE body was successfully decompressed and
relocated.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-21 13:38:18 +01:00
Michael Brown 92c3202ab1 [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>
2010-04-20 21:00:49 +01:00
Michael Brown 9cf5170c30 [relocate] Remove the even megabyte constraint
iPXE 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>
2010-04-20 21:00:49 +01:00
Michael Brown 38cd2035ff [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>
2010-04-20 21:00:49 +01:00
Michael Brown 24b52ae476 [prefix] Add A20-enabling code in libflat
iPXE 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 iPXE A20 code and the A20 code
from the 2.6.32 Linux kernel.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-20 21:00:42 +01:00
Michael Brown fb754ced56 [prefix] Move flatten_real_mode to libflat.S
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-20 14:23:55 +01:00
Michael Brown d931d4bd9c [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>
2010-04-20 13:04:24 +01:00
Michael Brown 9068249e24 [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>
2010-04-20 12:56:28 +01:00
Michael Brown 6c35a525da [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>
2010-04-20 11:05:47 +01:00
Michael Brown cb43056809 [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 iPXE 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>
2010-04-19 23:43:48 +01:00
Michael Brown 8ffea19225 [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>
2010-04-19 23:43:48 +01:00
Michael Brown 329686c026 [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>
2010-04-19 23:43:48 +01:00
Michael Brown 8406115834 [build] Rename gPXE to iPXE
Access to the gpxe.org and etherboot.org domains and associated
resources has been revoked by the registrant of the domain.  Work
around this problem by renaming project from gPXE to iPXE, and
updating URLs to match.

Also update README, LOG and COPYRIGHTS to remove obsolete information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-19 23:43:39 +01:00
Piotr Jaroszyński 9feb7b38a5 [build] Look for isolinux.bin in more places
Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-04-16 07:49:29 -04:00
Michael Brown 80d1ac7320 [pxe] Remove pxe_set_cached_filename()
gPXE currently overwrites the filename stored in the cached DHCP
packets when a call to PXENV_TFTP_READ_FILE or PXENV_RESTART_TFTP is
made.  This code has existed for many years as a workaround for RIS,
which seemed to require that this be done.

pxe_set_cached_filename() causes problems with the Bootix NBP, and a
recent test demonstrates that RIS will complete successfully even with
pxe_set_cached_filename() removed.  There have been many changes to
the DHCP and PXE logic since this code was first added, and it is
quite plausible that it was masking a bug that no longer exists.

Reported-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
Debugged-by: Shao Miller <Shao.Miller@yrdsb.edu.on.ca>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2010-03-26 18:00:41 +00:00
Michael Brown 9acf442c20 [pxe] Avoid potential interrupt storms when using shared interrupts
Current gPXE code always returns "OURS" in response to
PXENV_UNDI_ISR:START.  This is harmless for non-shared interrupt
lines, and avoids the complexity of trying to determine whether or not
we really did cause the interrupt.  (This is a non-trivial
determination; some drivers don't have interrupt support and hook the
system timer interrupt instead, for example.)

A problem occurs when we have a shared interrupt line, the other
device asserts an interrupt, and the controlling ISR does not chain to
the other device's ISR when we return "OURS".  Under these
circumstances, the other device's ISR never executes, and so the
interrupt remains asserted, causing an interrupt storm.

Work around this by returning "OURS" if and only if our net device's
interrupt is currently recorded as being enabled.  Since we always
disable interrupts as a result of a call to PXENV_UNDI_ISR:START, this
guarantees that we will eventually (on the second call) return "NOT
OURS", allowing the other ISR to be called.  Under normal operation,
including a non-shared interrupt situation, this change will make no
difference since PXENV_UNDI_ISR:START would be called only when
interrupts were enabled anyway.

Signed-off-by: Michael Brown <mcb30@etherboot.org>
2010-03-23 01:39:52 +00:00
Michael Brown 88e436376c [netdevice] Add netdev_is_open() wrapper function
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2010-03-23 00:46:35 +00:00
Daniel Verkamp 12defeca99 [comboot] Match version strings to SYSLINUX style
In the actual SYSLINUX suite's comboot implementation, the version
string is prefixed by CR LF, and the copyright string has a leading
space.  Some tools (specifically HDT) assume these padding characters
exist, so we should probably return strings in a similar format.

Signed-off-by: Michael Brown <mcb30@etherboot.org>
2010-03-01 01:55:54 +00:00
Stefan Hajnoczi b7af0aa34e [undi] Ensure only one UNDI instance is loaded
Loading multiple UNDI instances would be useful in systems that have
several network cards with vendor PXE ROMs.  However, we cannot rely on
UNDI ROMs working correctly with multiple instances loaded
simultaneously.

The gPXE UNDI driver supports the following multi-NIC configurations:
1. Chainloading undionly.kpxe on a specific NIC.
2. Loading the UNDI driver for the first probed device and ignoring all
   other UNDI devices in the system.

This patch refuses to probe additional UNDI devices so there can never
be multiple instances of UNDI loaded.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-02-24 12:58:29 -05:00
Stefan Hajnoczi 1056a1c2d5 [prefix] Remove unsupported ELF prefices
The .elf, .elfd, .lmelf, and .lmelfd prefices were brought over from
legacy Etherboot and they do not build in gPXE.  This patch removes the
ELF prefices.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-31 19:10:25 -05:00
Stefan Hajnoczi 9a89f0d17d [prefix] Remove unsupported .exe prefix
The unfinished .exe prefix was brought over from legacy Etherboot.
There has been no demand for .exe images so this patch removes the
prefix.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-31 19:06:55 -05:00
Stefan Hajnoczi ddcf2d5f08 [prefix] Remove unsupported .com prefix
The DOS .com prefix was brought over from legacy Etherboot but does not
build.  There has been no demand for .com images so this patch removes
the prefix.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-31 19:05:22 -05:00
Stefan Hajnoczi d3b9c3f3d0 [prefix] Remove .bImage in favor of .lkrn
The .lkrn prefix allows gPXE to be loaded as a Linux bzImage.  The
bImage prefix was carried over from legacy Etherboot and does not build.
This patch removes the .bImage prefix, use .lkrn instead.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-31 19:00:56 -05:00
Shao Miller 112a3f2de2 [pxe] Introduce PXE exit hook for NBP chaining
It might be the case that we wish to chain to an NBP without
being "in the way".  We now implement a hook in our exit path
for gPXE *.*pxe build targets.  The hook is a pointer to a
SEG16:OFF16 which we try to jump to during exit.  By default,
this pointer results in the usual exit path.

We also implement the "pxenv_file_exit_hook" PXE API routine
to allow the user to specify an alternate SEG16:OFF16 to jump
to during exit.

Unfortunately, this additional PXE extension has a cost
in code size.  Fortunately, a look at the size difference
for a gPXE .rom build target shows zero size difference
after compression.

The routine is documented in doc/pxe_extensions as follows:

FILE EXIT HOOK

Op-Code:	PXENV_FILE_EXIT_HOOK (00e7h)

Input:	Far pointer to a t_PXENV_FILE_EXIT_HOOK parameter
		structure that has been initialized by the caller.

Output:	PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be
		returned in AX.  The Status field in the parameter
		structure must be set to one of the values represented
		by the PXENV_STATUS_xxx constants.

Description:Modify the exit path to jump to the specified code.
		Only valid for pxeprefix-based builds.

typedef struct s_PXENV_FILE_EXIT_HOOK {
        PXENV_STATUS_t Status;
        SEGOFF16_t Hook;
} t_PXENV_FILE_EXIT_HOOK;

Set before calling API service:

Hook:	The SEG16:OFF16 of the code to jump to.

Returned from API service:

Status:	See PXENV_STATUS_xxx constants.

Requested-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-24 07:54:42 -05:00
Joshua Oreman 06a8398422 [prefix] Add .xrom prefix for a ROM that loads itself by PCI accesses
The standard option ROM format provides a header indicating the size
of the entire ROM, which the BIOS will reserve space for, load, and
call as necessary. However, this space is strictly limited to 128k for
all ROMs. gPXE ameliorates this somewhat by reserving space for itself
in high memory and relocating the majority of its code there, but on
systems prior to PCI3 enough space must still be present to load the
ROM in the first place. Even on PCI3 systems, the BIOS often limits the
size of ROM it will load to a bit over 64kB.

These space problems can be solved by providing an artificially small
size in the ROM header: just enough to let the prefix code (at the
beginning of the ROM image) be loaded by the BIOS. To the BIOS, the
gPXE ROM will appear to be only a few kilobytes; it can then load
the rest of itself by accessing the ROM directly using the PCI
interface reserved for that task.

There are a few problems with this approach. First, gPXE needs to find
an unmapped region in memory to map the ROM so it can read from it;
this is done using the crude but effective approach of scanning high
memory (over 0xF0000000) for a sufficiently large region of all-ones
(0xFF) reads. (In x86 architecture, all-ones is returned for accesses
to memory regions that no mapped device can satisfy.) This is not
provably valid in all situations, but has worked well in practice.
More importantly, this type of ROM access can only work if the PCI ROM
BAR exists at all. NICs on physical add-in PCI cards generally must
have the BAR in order for the BIOS to be able to load their ROM, but
ISA cards and LAN-on-Motherboard cards will both fail to load gPXE
using this scheme.

Due to these uncertainties, it is recommended that .xrom only be used
when a regular .rom image is infeasible due to crowded option ROM
space. However, when it works it could allow loading gPXE images
as large as a flash chip one could find - 128kB or even higher.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-20 17:46:48 -05:00
Joshua Oreman fa4aec8f03 [config] Make PXE stack a compile-time option
For extremely tight space requirements and specific applications, it is
sometimes desirable to create gPXE images that cannot provide the PXE API
functionality to client programs. Add a configuration header option,
PXE_STACK, that can be removed to remove this stack. Also add PXE_MENU
to control the PXE boot menu, which most uses of gPXE do not need.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-20 17:23:37 -05:00
Joshua Oreman 9e9cc8c60f [pxe] Support cached DHCP packets in .kkpxe images
If we don't unload the PXE stack before executing gPXE, automatically
take advantage of the cached DHCPACK that the underlying/parent PXE
stack can provide. If that cached DHCPACK contains option 175.178, or
the user sets the use-cached setting before invoking DHCP, the real
DHCP request will be skipped and the cached DHCPACK will be used for
network configuration. Otherwise, the cached settings block is thrown
away as soon as a fresh one is acquired.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-20 17:16:37 -05:00
Joshua Oreman 337e1ed4b4 [pxe] Separate parent PXE API caller from UNDINET driver
Calling the parent PXE stack (the stack that loaded us, for
undionly.kkpxe) can be useful for more than UNDI calls; for instance,
it lets us get cached DHCP packets to avoid re-DHCP when working with
embedded images.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-20 17:11:57 -05:00
Thomas Horsten c124f6360d [tftp] Make TFTP size requests abort transfer with an error
pxenv_tftp_get_fsize is an API call that PXE clients can call to
obtain the size of a remote file. It is implemented by starting a TFTP
transfer with pxe_tftp_open, waiting for the response and then
stopping the transfer with pxe_tftp_close(). This leaves the session
hanging on the TFTP server and it will try to resend the packet
repeatedly (verified with tftpd-hpa) until it times out.

This patch adds a method "tftpsize" that will abort the transfer after
the first packet is received from the server. This will terminate the
session on the server and is the same behaviour as Intel's PXE ROM
exhibits.

Together with a qemu patch to handle the ERROR packet (submitted to
qemu's mailing list), this resolves a specific issue where booting
pxegrub with qemu's TFTP server would be slow or hang.

I've tested this against qemu's tftp server and against my normal boot
infrastructure (tftpd-hpa). Booting pxegrub and loading extra files
now produces a trace similar to Intel's PXE client and there are no
spurious retransmits from tftpd any more.

Signed-off-by: Thomas Horsten <thomas@horsten.com>
Signed-off-by: Milan Plzik <milan.plzik@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-17 19:18:28 -05:00
Stefan Hajnoczi 37883e99fd [sanboot] Prevent leaking a stack reference for "keep-san" AoE
When the "keep-san" option is used, the function is exited without
unregistering the stack allocated int13h drive.  To prevent a dangling
pointer to the stack, these structs should be heap allocated.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-15 16:35:01 -05:00
Joshua Oreman 5736f5eb32 [prefix] Add .hrom prefix for a ROM that loads high under PCI3 without PMM
gPXE currently takes advantage of the feature of PCI3.0 that allows
option ROMs to relocate the bulk of their code to high memory and so
take up only a small amount of space in the option ROM area. Currently,
the relocation can only take place if the BIOS's implementation of PMM
can be made to return blocks aligned to an even megabyte, because of
the A20 gate. AMI BIOSes, in particular, will not return allocations
that gPXE can use.

Ameliorate the situation somewhat by adding a prefix, .hrom, that works
identically to .rom except in the case that PMM allocation fails. Where
.rom would give up and place itself entirely in option ROM space, .hrom
moves to a block (assumed free) at HIGHMEM_LOADPOINT = 4MB. This allows
for the use of larger gPXE ROMs than would otherwise be possible.

Because there is no way to check that the area at HIGHMEM_LOADPOINT is
really free, other devices using that memory during the boot process
will cause failure for gPXE, the other device, or both. In practice
such conflicts will likely not occur, but this prefix should still be
considered EXPERIMENTAL.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-14 10:56:08 -05:00
Stefan Hajnoczi 9760005fe8 [build] Pad .hd image type to 32 KB
The disk partition prefix code in hdprefix.S reads the gPXE image in
tracks, not individual sectors.  This means it will attempt to read
beyond the end of the image if the .hd image type is not padded to 32
KB.

This issue is affects virtualization software which may execute a .hd or
.usb image file directly - effectively running a machine with a tiny
disk containing just the gPXE image.  Boot will fail when gPXE tries to
read beyond the end of disk.
2009-12-15 20:22:04 +00:00
Stefan Hajnoczi 2eeb711560 [multiboot] Build memory map after shutting down and unhiding gPXE
The Multiboot memory map needs to be built after unhiding gPXE and
downloaded images from memory.  Solaris faults during boot when trying
to access the ramdisk, which is hidden from the memory map while gPXE is
executing.  This issue is fixed by using the memory map from after gPXE
unhides itself.

Reported-by: Moinak Ghosh <moinakg@belenix.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2009-12-14 17:58:38 +00:00
Shao Miller ec7e97f458 [e820mangler] Add missing CLC ins. for success path
The get_underlying_e820 function should return with CF unset on success.

Reported-by: Timothy Stack <tstack@vmware.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2009-11-20 21:21:36 -05:00
Joshua Oreman 572e61754a [linker] Expand and correct symbol requirement macros
REQUIRE_SYMBOL() formerly used a formulation of symbol requirement
that would allow a link to succeed despite lacking a required symbol,
because it did not introduce any relocations. Fix by renaming it to
REQUEST_SYMBOL() (since the soft-requirement behavior can be useful)
and add a REQUIRE_SYMBOL() that truly requires.

Add EXPORT_SYMBOL() and IMPORT_SYMBOL() for REQUEST_SYMBOL()-like
behavior that allows one to make use of the symbol, by combining a
weak external on the symbol itself with a REQUEST_SYMBOL() of a second
symbol.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2009-11-20 20:27:25 -05:00
Michael Brown b515977955 [int13] Guard against BIOSes that "fix" the drive count
Some BIOSes (observed with an AMI BIOS on a SunFire X2200) seem to
reset the BIOS drive counter at 40:75 after a failed boot attempt.
This causes problems when attempting a Windows direct-to-iSCSI
installation: bootmgr.exe calls INT 13,0800 and gets told that there
are no hard disks, so never bothers to read the MBR in order to obtain
the boot disk signature.  The Windows iSCSI initiator will detect the
iBFT and connect to the target, and everything will appear to work
except for the error message "This computer's hardware may not support
booting to this disk.  Ensure that the disk's controller is enabled in
the computer's BIOS menu."

Fix by checking the BIOS drive counter on every INT 13 call, and
updating it whenever necessary.
2009-11-18 02:44:49 +00:00
Michael Brown 89de3e29e1 [int13] Fix number of sectors returned by INT 13,15
INT 13,15 should return the number of sectors, not the number of
cylinders.
2009-11-18 02:44:45 +00:00
Michael Brown 5bee2a2991 [autoboot] Ensure that an error message is always printed for a boot failure
The case of an unsupported SAN protocol will currently not result in
any error message.  Fix by printing the error message at the top level
using strerror(), rather than using hard-coded error messages in the
error paths.
2009-11-18 02:44:40 +00:00
Michael Brown be670840c7 [sanboot] Extend the "keep-san" option to non-iSCSI SAN protocols
This disgustingly ugly hack just keeps getting worse.
2009-11-04 01:21:43 +00:00
Michael Brown 45044acea7 [iscsi] Use the "Ethernet-compatible" MAC address in the iBFT 2009-10-23 22:18:23 +01:00
Michael Brown d000c6b8c7 [iscsi] Fix printing of non-existent strings in iBFT debug messages 2009-10-23 21:33:48 +01:00
Michael Brown 4eab5bc8ca [netdevice] Allow the hardware and link-layer addresses to differ in size
IPoIB has a 20-byte link-layer address, of which only eight bytes
represent anything relating to a "hardware address".

The PXE and EFI SNP APIs expect the permanent address to be the same
size as the link-layer address, so fill in the "permanent address"
field with the initial link layer address (as generated by
register_netdev() based upon the real hardware address).
2009-08-12 00:23:38 +01:00
Michael Brown 37a0aab4ff [netdevice] Separate out the concept of hardware and link-layer addresses
The hardware address is an intrinsic property of the hardware, while
the link-layer address can be changed at runtime.  This separation is
exposed via APIs such as PXE and EFI, but is currently elided by gPXE.

Expose the hardware and link-layer addresses as separate properties
within a net device.  Drivers should now fill in hw_addr, which will
be used to initialise ll_addr at the time of calling
register_netdev().
2009-08-12 00:19:14 +01:00
Joshua Oreman d5d68b2e31 [zbin] Change fixup semantics to support ROMs over 128k uncompressed
The option ROM header contains a one-byte field indicating the number
of 512-byte sectors in the ROM image.  Currently it is linked to
contain the number of uncompressed sectors, with an instruction to the
compressor to correct it.  This causes link failure when the
uncompressed size of the ROM image is over 128k.

Fix by replacing the SUBx compressor fixup with an ADDx fixup that
adds the total compressed output length, scaled as requested, to an
addend stored in the field where the final length value will be
placed.  This is similar to the behavior of ELF relocations, and
ensures that an overflow error will not be generated unless the
compressed size is still too large for the field.

This also allows us to do away with the _filesz_pgh and _filesz_sect
calculations exported by the linker script.

Output tested bitwise identical to the old SUBx mechanism on hd, dsk,
lkrn, and rom prefixes, on both 32-bit and 64-bit processors.

Modified-by: Michael Brown <mcb30@etherboot.org>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-08-11 12:59:26 +01:00
Michael Brown e5f14e5a32 [infiniband] Add support for the SRP Boot Firmware Table
The SRP Boot Firmware Table serves a similar role to the iSCSI and AoE
Boot Firmware Tables; it provides information required by the loaded
OS in order to establish a connection back to the SRP boot device.
2009-08-10 22:32:47 +01:00
Michael Brown 0c30dc6bc5 [infiniband] Add support for SRP over Infiniband
SRP is the SCSI RDMA Protocol.  It allows for a method of SAN booting
whereby the target is responsible for reading and writing data using
Remote DMA directly to the initiator's memory.  The software initiator
merely sends and receives SCSI commands; it never has to touch the
actual data.
2009-08-10 22:27:33 +01:00
Michael Brown 7a3a159af5 [romprefix] Cope with PnP BIOSes that fail to set %es:%di on entry
Some BIOSes support the BIOS Boot Specification (BBS) but fail to set
%es:%di correctly when calling the option ROM initialisation entry
point.  This causes gPXE to identify the BIOS as non-PnP (and so
non-BBS), leaving the user unable to control the boot order.

Fix by scanning for the $PnP signature ourselves, rather than relying
on the BIOS having passed in %es:%di correctly.

Tested-by: Helmut Adrigan <helmut.adrigan@chello.at>
2009-08-08 15:32:28 +01:00
H. Peter Anvin 193d545903 [pxe] Dual-license pxe_api.h under the MIT license
pxe_api.h is just a description of API functions, it's actively
undesirable to have more implementations than necessary.  Allowing it
under the MIT license lets the Syslinux libraries use it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-08-02 23:29:06 +01:00
Michael Brown 2b9f7f042c [pxe] Avoid printf format warning on some compilers
Tested-by: Joshua Oreman <oremanj@xenon.get-linux.org>
2009-08-02 22:45:24 +01:00
Marty Connor 96f4f96540 [build] Add syslinux floppy image type .sdsk
We add a syslinux floppy disk type using parts of the genliso script.
This floppy image cat be dd'ed to a physical floppy or used in
instances where a virtual floppy with an mountable DOS filesystem is
useful.

We also modify the genliso script to only generate .liso images
rather than creating images depending on how it is called.

Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-08-02 11:04:13 +01:00
Michael Brown d09290161e [netdevice] Make ll_broadcast per-netdevice rather than per-ll_protocol
IPoIB has a link-layer broadcast address that varies according to the
partition key.  We currently go through several contortions to pretend
that the link-layer address is a fixed constant; by making the
broadcast address a property of the network device rather than the
link-layer protocol it will be possible to simplify IPoIB's broadcast
handling.
2009-07-17 23:02:48 +01:00
Michael Brown 546cc62394 [pxe] Add startpxe and stoppxe commands
These commands can be used to activate or deactivate the PXE API (on a
specifiable network interface).

This is currently of limited use, since most image formats will call
shutdown() before booting the image, meaning that the underlying net
device gets shut down during remove_devices() anyway.
2009-06-28 20:50:23 +01:00
Michael Brown ee1d315ac0 [pxe] Check for unhookable interrupts in PXENV_STOP_UNDI
PXENV_STOP_UNDI should return PXENV_STATUS_KEEP_UNDI if the UNDI
cannot be safely unloaded (e.g. due to interrupt vectors that could
not be unhooked).
2009-06-28 20:12:16 +01:00
Michael Brown 07b5be3341 [pxe] Create pxe_[de]activate() wrapper functions
Merge the pxe_set_netdev()+pxe_[un]hook_int1a() pattern into a single
pxe_[de]activate() call.
2009-06-28 20:11:32 +01:00
Michael Brown c2965b0fe7 [pxe] Make pxe_init_structures() an initialisation function
pxe_init_structures() fills in the fields of the !PXE and PXENV+
structures that aren't known until gPXE starts up.  Once gPXE is
started, these values will never change.

Make pxe_init_structures() an initialisation function so that PXE
users don't have to worry about calling it.
2009-06-28 19:40:16 +01:00
Michael Brown c26a38b313 [pxe] Update UNDI transmit count before transmitting packet
It is possible that the UNDI ISR may be triggered before netdev_tx()
returns control to pxenv_undi_transmit().  This means that
pxenv_undi_isr() may see a zero undi_tx_count, and so not check for TX
completions.  This is not a significant problem, since it will check
for TX completions on the next call to pxenv_undi_isr() anyway; it
just means that the NBP will see a spurious IRQ that was apparently
caused by nothing.

Fix by updating the undi_tx_count before calling netdev_tx(), so that
pxenv_undi_isr() can decrement it and report the TX completion.
2009-06-27 16:36:21 +01:00
Michael Brown f186ada2d3 [pxe] Implement PXENV_UNDI_{GET,SET}_MCAST_ADDRESS
Symantec Ghost requires working multicast support.  gPXE configures
all (sufficiently supported) network adapters into "receive all
multicasts" mode, which means that PXENV_UNDI_SET_MCAST_ADDRESS is
actually a no-op, but the current implementation returns
PXENV_STATUS_UNSUPPORTED instead.

Fix by making PXENV_UNDI_SET_MCAST_ADDRESS return success.  For good
measure, also implement PXENV_UNDI_GET_MCAST_ADDRESS, since the
relevant functionality is now exposed by the net device core.

Note that this will silently fail if the gPXE driver for the NIC being
used fails to configure the NIC in "receive all multicasts" mode.
2009-06-27 15:46:06 +01:00
Michael Brown 9580f9d5cd [pxe] Improve pxe_undi debug messages
The PXE debugging messages have remained pretty much unaltered since
Etherboot 5.4, and are now difficult to read in comparison to most of
the rest of gPXE.

Bring the pxe_undi debug messages up to normal gPXE standards.
2009-06-27 14:43:10 +01:00
Daniel Verkamp cb9700ef6f [comboot] Implement INT 22h AX=000Bh (Get Serial Console Configuration)
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-06-23 23:09:01 +01:00
Michael Brown 4fe1e08a60 [pxe] Fix interoperability with the Symantec (undipd) DOS UNDI driver
The Symantec UNDI DOS driver fails when run on top of gPXE because we
return our interface type as "gPXE" rather than one of the predefined
NDIS interface type strings.

Fix by returning the standard "DIX+802.3" string; this isn't
necessarily always accurate, but it's highly unlikely that anything
trying to use the UNDI API would understand our IPoIB link-layer
pseudo-header anyway.
2009-06-23 22:56:21 +01:00
Michael Brown 0b922595fe [pxe] Fix interoperability with the Intel DOS UNDI driver
The Intel DOS UNDI driver fails when run on top of gPXE because we do
not fill in the ServiceFlags field in PXENV_UNDI_GET_IFACE_INFO.

Fix by filling in the ServiceFlags field with reasonable values
indicating our approximate feature capabilities.
2009-06-23 22:42:55 +01:00
Michael Brown 4f881ae352 [pxe] Fix interoperability with the 3Com DOS UNDI driver
The 3Com DOS UNDI driver fails when run on top of gPXE for two
reasons: firstly because PXENV_UNDI_SET_PACKET_FILTER is unsupported,
and secondly because gPXE enters the NBP without enabling interrupts
on the NIC, and the 3Com driver never calls PXENV_UNDI_OPEN.

Fix by always returning success from PXENV_UNDI_SET_PACKET_FILTER
(which is no worse than the current situation, since we already ignore
the receive packet filter in PXENV_UNDI_OPEN), and by forcibly
enabling interrupts on the NIC within PXENV_UNDI_TRANSMIT.  The latter
is something of a hack, but avoids the need to implement a complete
base-code ISR that we would otherwise need if we were to enter the NBP
with interrupts enabled.
2009-06-23 21:54:50 +01:00
Michael Brown 198ae0a131 [undi] Include PXENV_GET_IFACE_INFO's ServiceFlags in debug output 2009-06-23 19:26:07 +01:00
Joshua Oreman eb3ca2a36f [netdevice] Add netdev argument to link-layer push and pull handlers
In order to construct outgoing link-layer frames or parse incoming
ones properly, some protocols (such as 802.11) need more state than is
available in the existing variables passed to the link-layer protocol
handlers. To remedy this, add struct net_device *netdev as the first
argument to each of these functions, so that more information can be
fetched from the link layer-private part of the network device.

Updated all three call sites (netdevice.c, efi_snp.c, pxe_undi.c) and
both implementations (ethernet.c, ipoib.c) of ll_protocol to use the
new argument.

Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-06-23 10:41:57 +01:00
Michael Brown a5cd8d1772 [misc] Fix source files erroneously marked as executable 2009-06-02 11:26:09 +01:00
Daniel Verkamp e47869995f [comboot] Implement stub calls for auxiliary data vector handling
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-05-26 11:43:02 +01:00
Michael Brown 822b3b53f4 [multiboot] Include argv[0] as part of "command line"
Grub will include the module name as part of the command line, and
some multiboot kernels expect this to be done.
2009-05-26 06:58:53 +01:00
Michael Brown f4bf4e69f7 [legal] Add FILE_LICENCE declaration to romprefix.S 2009-05-18 09:33:36 +01:00
Michael Brown c44a193d0d [legal] Add a selection of FILE_LICENCE declarations
Add FILE_LICENCE declarations to almost all files that make up the
various standard builds of gPXE.
2009-05-18 08:33:25 +01:00
Michael Brown 4188d51753 [pxeprefix] Work around bug in Etherboot 5.4 when loading undionly.kpxe
Etherboot 5.4 erroneously treats PXENV_UNLOAD_STACK as the "final
shutdown" call, and unhooks INT15.  When using gPXE's undionly.kpxe,
this results in gPXE overwriting the portion of Etherboot located in
high memory, because it is no longer hidden from the system memory map
at the time that gPXE loads.

Work around this by explicitly testing for Etherboot as the underlying
PXE stack (as is already done in undinet.c) and skipping the call to
PXENV_UNLOAD_STACK if necessary.
2009-04-30 04:48:28 +01:00
Michael Brown 6e764282dd [i386] Remove long-obsolete realmode.c file 2009-04-26 06:41:54 +01:00
Michael Brown bb06fc17cc [i386] Remove long-obsolete callbacks_arch.h file 2009-04-26 06:38:36 +01:00
Michael Brown e960fac8d0 [multiboot] Work around raw-flag bug in Solaris kernels
Solaris kernels are multiboot images with the "raw" flag set,
indicating that the loader should use the raw address fields within
the multiboot header rather than looking for an ELF header.  However,
the Solaris kernel contains garbage data in the raw address fields,
and requires us to use the ELF header instead.

Work around this by always using the ELF header if present.  This
renders the "raw" flag somewhat redundant.
2009-04-24 03:19:47 +01:00
Michael Brown 3d6b8a67f2 [build] Remove obsolete linker script files 2009-04-17 14:09:14 +01:00
Michael Brown a63ef9207d [build] Kill off the last multiple-object source file
The build mechanism currently allows for multiple objects per source
file.  The only remaining user of this is unnrv2b.S.  Replace this
usage with a separate unnrv2b16.S wrapper file, as is currently used
for e.g. pxeprefix.S and kpxeprefix.S.
2009-04-17 13:38:18 +01:00
Michael Brown 7aee624881 [build] Reinstate the .pdsk padded-floppy image format
Some utilities that expect a floppy disk image (e.g. iLO?) may test
for a file of the correct size.  Reinstate the .pdsk image format in
order to provide this if needed.
2009-04-16 06:01:07 +01:00
Michael Brown 7741546a40 [build] Pad .rom, .dsk, and .hd images to 512-byte boundaries
QEMU will silently round down a disk or ROM image file to the nearest
512 bytes.  Fix by always padding .rom, .dsk and .hd images to the
nearest 512-byte boundary.

Originally-fixed-by: Stefan Hajnoczi <stefanha@gmail.com>
2009-04-16 03:15:08 +01:00
H. Peter Anvin f44205b9ea [pcbios] Don't use "lret $2" to return from an interrupt
Using "lret $2" to return from an interrupt causes interrupts to be
disabled in the calling program, since the INT instruction will have
disabled interrupts.  Instead, patch CF on the stack and use iret to
return.

Interestingly, the original PC BIOS had this bug in at least one
place.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-04-15 15:45:27 +01:00
Joshua Oreman 820b11dc0a [build] Use __SIZE_TYPE__ macro in definition of size_t
This is required in order to build on Mac OS X.

Modified-by: Michael Brown <mcb30@etherboot.org>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-03-31 07:21:07 +01:00
Michael Brown b0c818d7b5 [int13] Improve debugging messages 2009-03-31 06:26:51 +01:00
Michael Brown 323cdf8c4c [xfer] Implement xfer_vreopen() to properly handle redirections
When handling a redirection event, we need to close the existing
connection before opening the new connection.
2009-03-30 13:24:56 +01:00
Michael Brown abc13af070 [bzimage] Support old (pre-2.00 bootloader) Linux kernel formats
This allows gPXE to load memtest86, which is packaged as an old kernel.

Split all code that directly touches the kernel headers out into
bzimage_parse_header() and bzimage_update_header(), to reduce code
size and offset the cost of supporting older kernels.

Total cost of this feature: 11 bytes (uncompressed).
2009-03-30 11:42:19 +01:00
Thomas Miletich 3da6f1c7bd [pci] Add driver_data field to struct pci_device_id
Modified-by: Michael Brown <mcb30@etherboot.org>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-03-26 10:22:15 +00:00
Michael Brown 1c67623e37 [build] Enable building with the Intel C compiler (icc) 2009-03-26 07:27:19 +00:00
H. Peter Anvin f3d09b5c79 [pxeprefix] Merge common code between !PXE and PXENV+
The parsing of the !PXE and PXENV+ structures share a fair bit of
code; merge the common code to save a few bytes.

Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-03-06 14:51:50 +00:00
Michael Brown 784d3f336e [pxe] Set %ax to zero on entry to PXE NBP
This is not strictly an entry requirement, but it does mean that a PXE
NBP returning without setting %ax will appear to have returned
success.
2009-02-23 08:43:27 +00:00
H. Peter Anvin 6a3f5d6db7 [pxeprefix] Search for the PXE entry points through all methods
Search for the PXE entry points (via the !PXE or PXENV+ structures)
through all known combinations of search methods.  Furthermore, if we
find a PXENV+ structure, attempt to use it to find the !PXE structure
if at all possible.
2009-02-23 02:53:38 +00:00
Michael Brown 4dd746a725 [iscsi] Include credentials in iBFT only if used during iSCSI login
Avoid passing credentials in the iBFT that were available but not
required for login.  This works around a problem in the Microsoft
iSCSI initiator, which will refuse to initiate sessions if the CHAP
password is fewer than 12 characters, even if the target ends up not
asking for CHAP authentication.
2009-02-20 21:41:00 +00:00
H. Peter Anvin aaa26f3bd3 [pxe] Initialize EDX on PXE NBP entry and INT 1Ah
The PXE 1.x spec specifies that on NBP entry or on return from INT
1Ah AX=5650h, EDX shall point to the physical address of the PXENV+
structure.  The PXE 2.x spec drops this requirement, simply stating
that EDX is clobbered.  Given the principle "be conservative in what
you send, liberal in what you accept", however, we should implement
this anyway.
2009-02-18 18:13:20 +00:00
Michael Brown b5577553e5 [pxeprefix] Add .kkpxe image type and ability to return via PXE stack
Certain combinations of PXE stack and BIOS result in a broken INT 18
call, which will leave the system displaying a "PRESS ANY KEY TO
REBOOT" message instead of proceeding to the next boot device.  On
these systems, returning via the PXE stack is the only way to continue
to the next boot device.  Returning via the PXE stack works only if we
haven't already blown away the PXE base code in pxeprefix.S.

In most circumstances, we do want to blow away the PXE base code.
Base memory is a limited resource, and it is desirable to reclaim as
much as possible.  When we perform an iSCSI boot, we need to place the
iBFT above the 512kB mark, because otherwise it may not be detected by
the loaded OS; this may not be possible if the PXE base code is still
occupying that memory.

Introduce a new prefix type .kkpxe which will preserve both the PXE
base code and the UNDI driver (as compared to .kpxe, which preserves
the UNDI driver but uninstalls the PXE base code).  This prefix type
can be used on systems that are known to experience the specific
problem of INT 18 being broken, or in builds (such as gpxelinux.0) for
which it is particularly important to know that returning to the BIOS
will work.

Written by H. Peter Anvin <hpa@zytor.com> and Stefan Hajnoczi
<stefanha@gmail.com>, minor structural alterations by Michael Brown
<mcb30@etherboot.org>.
2009-02-18 18:12:32 +00:00
Michael Brown dd44a7c314 [i386] Kill off obsolete boot1a.s file 2009-02-18 04:48:30 +00:00
Daniel Verkamp dbbd81c140 [comboot] Implement INT 22h AX=001Bh (Cleanup, shuffle, and boot to real mode) 2009-02-17 03:52:44 +00:00
Michael Brown 5026a35fef [comboot] Restore the real-mode stack pointer on exit from a COMBOOT image
COMBOOT images use INTs to issue API calls; these end up making calls
into gPXE from real mode, and so temporarily change the real-mode
stack pointer.  When our COMBOOT code uses a longjmp() to implement
the various "exit COMBOOT image" API calls, this leaves the real-mode
stack pointer stuck with its temporary value, which causes problems if
we eventually try to exit out of gPXE back to the BIOS.

Fix by adding rmsetjmp() and rmlongjmp() calls (analogous to
sigsetjmp()/siglongjmp()); these save and restore the additional state
needed for real-mode calls to function correctly.
2009-02-17 03:38:40 +00:00
Michael Brown 7f903f03af [comboot] Unhook interrupt vectors after returning from a COMBOOT image 2009-02-17 02:03:16 +00:00
Michael Brown 14eafc5b8d [comboot] Fix reference counting on replacement images
When chaining COMBOOT images, the old images now get freed correctly.
2009-02-17 01:45:12 +00:00
Michael Brown 8904cd55f1 [comboot] Allow for tail recursion of COMBOOT images
Multi-level menus via COMBOOT rely on the COMBOOT program being able
to exit and invoke a new COMBOOT program (the next menu).  This works,
but rapidly (within about five iterations) runs out of space in gPXE's
internal stack, since each new image is executed in a new function
context.

Fix by allowing tail recursion between images; an image can now
specify a replacement image for itself, and image_exec() will perform
the necessary tail recursion.
2009-02-17 00:47:35 +00:00
Michael Brown 7bc4093e1a [build] Cope with oddities in the Fedora 10 assembler
The version of the GNU assembler shipped with Fedora 10
(2.18.50.0.9-8.fc10) complains about character literals in some of our
assembly code.  Changing $'x' to $( 'x' ) seems to fix the problem.
Yes, the whitespace is required; using just $('x') does not work.

Reported by Kevin O'Connor <kevin@koconnor.net>.
2009-02-16 03:53:25 +00:00
Michael Brown 24e948f030 [image] Avoid claiming zero-length images as valid
Both the script and PXE images types will claim a zero-length image.
Inhibit this to avoid end-user surprises.
2009-02-16 00:30:48 +00:00
Michael Brown f16668dd60 [romprefix] Update ROM checksum even if PMM allocation fails
There are code paths other than PMM allocation that can result in our
changing the ROM checksum.  For example, we attempt to update our
product string to incorporate the PCI bus:dev.fn number.  In a system
that does not support PMM, we could therefore end up with an incorrect
checksum.

Fix by attempting to update the checksum unconditionally.
2009-02-15 11:44:21 +00:00
Michael Brown c9e5b12473 [i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.

Most of this change was achieved using

    perl -pi \
      -e 's/".text"$/".text", "ax", \@progbits/ ; ' \
      -e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
      -e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
      -e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
      -e 's/".data"$/".data", "aw", \@progbits/ ; ' \
      -e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
      -e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
      -e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
      -e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
      -e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
      -e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
      -e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
      `git grep -l '\.section'`
2009-02-15 10:59:53 +00:00
Michael Brown ce2aa66d39 [i386] Add explicit ""aw", @nobits" declarations to stack sections
As reported by Stefan, commit 13d09e6 ("[i386] Simplify linker script
and standardise linker-defined symbol names") breaks gdb, readelf and
associated utilities.

This is caused by the .stack section overwriting a block in the middle
of the .debug_info section (despite being included in the
.bss.textdata section in the output file, which apparently has the
correct attributes for a .bss section).

Fixed by adding explicit flags and type to the stack section
declaration.
2009-02-15 10:02:26 +00:00
Michael Brown 46da51703a [umalloc] Avoid problems when _textdata_memsz is a multiple of 4kB
If it happens that _textdata_memsz ends up being an exact multiple of
4kB, then this will cause the .textdata section (after relocation) to
start on a page boundary.  This means that the hidden memory region
(which is rounded down to the nearest page boundary) will start
exactly at virtual address 0, i.e. UNULL.  This means that
init_eheap() will erroneously assume that it has failed to allocate a
an external heap, since it typically ends up choosing the area that
lies immediately below .textdata, which in this case will be the
region with top==UNULL.

A subsequent error is that memtop_urealloc() passes through the error
return status -ENOMEM to the caller, which (rightly) assumes that the
result represents a valid userptr_t address.

Fixed by using alternative tests for heap non-existence, and by
returning UNULL in case of an error from init_eheap().
2009-02-15 07:56:16 +00:00
Michael Brown dbe84c5aad [iobuf] Add iob_disown() and use it where it simplifies code
There are many functions that take ownership of the I/O buffer they
are passed as a parameter.  The caller should not retain a pointer to
the I/O buffer.  Use iob_disown() to automatically nullify the
caller's pointer, e.g.:

    xfer_deliver_iob ( xfer, iob_disown ( iobuf ) );

This will ensure that iobuf is set to NULL for any code after the call
to xfer_deliver_iob().

iob_disown() is currently used only in places where it simplifies the
code, by avoiding an extra line explicitly setting the I/O buffer
pointer to NULL.  It should ideally be used with each call to any
function that takes ownership of an I/O buffer.  (The SSA
optimisations will ensure that use of iob_disown() gets optimised away
in cases where the caller makes no further use of the I/O buffer
pointer anyway.)

If gcc ever introduces an __attribute__((free)), indicating that use
of a function argument after a function call should generate a
warning, then we should use this to identify all applicable function
call sites, and add iob_disown() as necessary.
2009-02-01 20:16:10 +00:00
Michael Brown e65afc4b10 [dhcp] Split PXE menuing code out of dhcp.c
The DHCP client code now implements only the mechanism of the DHCP and
PXE Boot Server protocols.  Boot Server Discovery can be initiated
manually using the "pxebs" command.  The menuing code is separated out
into a user-level function on a par with boot_root_path(), and is
entered in preference to a normal filename boot if the DHCP vendor
class is "PXEClient" and the PXE boot menu option exists.
2009-02-01 01:21:40 +00:00
Michael Brown 1284773363 [tftp] Temporary fix for conveying TFTP block size to callers
pxe_tftp.c assumes that the first seek on its data-transfer interface
represents the block size.  Apart from being an ugly hack, this will
also screw up file size calculation for files smaller than one block.

The proper solution would be to extend the data-transfer interface to
support the reporting of stat()-like data.  This is not going to
happen until the cost of adding interface methods is reduced (a fix I
have planned since June 2008).

In the meantime, abuse the xfer_window() method to return the block
size, since it is not being used for anything else and is vaguely
justifiable.

Astonishingly, having returned the incorrect TFTP blocksize via
PXENV_TFTP_OPEN for almost a year seems not to have affected any of
the test cases run during that time; this bug was found only when
someone tried running the heavily-patched version of pxegrub found in
OpenSolaris.
2009-01-27 15:47:00 +00:00
Michael Brown f1d17ae2be [bios] Add F8 function key as a recognised BIOS keycode 2009-01-25 21:12:48 +00:00
Michael Brown 765efac771 [efi] Allow for .efidrv images as well as .efi images
Merge in the changes that allow for building EFI driver images (that
can be loaded using the EFI shell's "load" command) as well as EFI
applications.
2009-01-07 23:43:26 +00:00
Michael Brown 314779eb36 [efi] Use elf2efi utility in place of efilink
elf2efi converts a suitable ELF executable (containing relocation
information, and with appropriate virtual addresses) into an EFI
executable.  It is less tightly coupled with the gPXE build process
and, in particular, does not require the use of a hand-crafted PE
image header in efiprefix.S.

elf2efi correctly handles .bss sections, which significantly reduces
the size of the gPXE EFI executable.
2009-01-07 22:59:05 +00:00
Michael Brown 21cfab4fb8 [efi] Inhibit harmless ld warning on unresolved symbol check
The check for unresolved symbols does not explicitly specify an output
architecture format, and so causes a warning when building an i386 EFI
binary on an x86_64 platform.  This warning is harmless, and
specifying the output architecture in multiple places is cumbersome,
so just inhibit the warning.
2009-01-05 12:54:40 -08:00
Marty Connor 8674bc05a0 [pcbios] Add additional sanity check for bogus e820 map
At POST time some BIOSes return invalid e820 maps even though
they indicate that the data is valid.  We add a check that the first
region returned by e820 is RAM type and declare the map to be invalid
if it is not.

This extends the sanity checks from 8b20e5d ("[pcbios] Sanity-check
the INT15,e820 and INT15,e801 memory maps").
2008-12-18 17:28:57 +00:00
Michael Brown ce0a0ccf5c [x86_64] Add support for compilation as an x86_64 binary
Currently the only supported platform for x86_64 is EFI.

Building an EFI64 gPXE requires a version of gcc that supports
__attribute__((ms_abi)).  This currently means a development build of
gcc; the feature should be present when gcc 4.4 is released.

In the meantime; you can grab a suitable gcc tree from

  git://git.etherboot.org/scm/people/mcb30/gcc/.git
2008-12-05 00:06:27 +00:00
Michael Brown 29480dd715 [efi] Use EFI-native mechanism for accessing SMBIOS table
EFI provides a copy of the SMBIOS table accessible via the EFI system
table, which we should use instead of manually scanning through the
F000:0000 segment.
2008-12-04 23:19:12 +00:00
Michael Brown 4d7c650164 [romprefix] Change from opt-in to opt-out when booting via INT19
On non-BBS systems, we have to hook INT 19 in order to be able to boot
from the gPXE ROM at all.  However, doing this unconditionally will
prevent the user from booting via any other devices.

Previously, the INT 19 entry point would prompt the user to press B in
order to boot from gPXE, which makes it impossible to perform an
unattended network boot.  We now prompt the user to press N to skip
booting from gPXE, which allows for unattended operation.

This should be a better match for most real-world scenarios.  Most
modern systems support BBS and so are unaffected by this change.  Very
old (non-BBS) systems tend not to have PXE ROMs by default anyway; if
the user has added a gPXE ROM then they probably do want to boot from
the network.  Newer non-BBS systems are essentially limited to IBM
servers, which will recapture the INT 19 vector anyway and implement
their own boot-ordering selection mechanism.
2008-12-04 16:46:16 +00:00
Michael Brown e78bcb6175 [netdevice] Kill off the various guess_boot_netdev() functions
Remove the assortment of miscellaneous hacks to guess the "network
boot device", and replace them each with a call to last_opened_netdev().

It still isn't guaranteed correct, but it won't be any worse than
before, and it will at least be consistent.
2008-11-21 20:34:42 +00:00
Michael Brown 8e8a348fd4 [pxe] Select the correct network device on multiport cards
When trying to find the "first open network device", it helps to
actually check the NETDEV_OPEN flag.
2008-11-21 19:45:05 +00:00
Laurent Vivier a2686a55c4 [blockdev] Move block device operations to structure block_device_operations
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
2008-11-19 20:04:43 +00:00
Michael Brown d9b3d09910 [i386] Move iSCSI and AoE boot code to arch/i386/interface/pcbios 2008-11-19 19:20:45 +00:00
Michael Brown b59e0cc56e [i386] Change [u]int32_t to [unsigned] int, rather than [unsigned] long
This brings us in to line with Linux definitions, and also simplifies
adding x86_64 support since both platforms have 2-byte shorts, 4-byte
ints and 8-byte long longs.
2008-11-19 19:15:44 +00:00
Michael Brown 849e4b12d6 [libgcc] Make __libgcc architecture-specific 2008-11-19 19:14:24 +00:00
Michael Brown dc60c24146 [i386] Rename __cdecl to __asmcall
__cdecl is a misleading name, since it currently encapsulates both
cdecl and regparm(0) attributes.  Rename to __asmcall.
2008-11-19 19:12:53 +00:00
Michael Brown 446b6d5fdd [pxe] Move all PXE files to arch/i386
The initial PXE implementation in Etherboot had the goal of being
architecture-agnostic, but this goal has not been realised.
2008-11-18 22:27:02 +00:00
Michael Brown fca2dcabb8 [elf] Kill off unused <bits/elf.h> and <bits/elf_x.h> header files 2008-11-18 22:16:15 +00:00
Michael Brown 0a8a17e669 [i386] Free allocated base memory on exit, if possible
Code paths that automatically allocate memory from the FBMS at 40:13
should also free it, if possible.

Freeing this memory will not be possible if either

  1. The FBMS has been modified since our allocation, or

  2. We have not been able to unhook one or more BIOS interrupt vectors.
2008-11-18 19:43:13 +00:00
Michael Brown cc93556725 [build] Fix calculation of _filesz
_filesz was incorrectly forced to be aligned up to MAX_ALIGN.  In a
non-compressed build, this would cause a build failure unless _filesz
happened to already be aligned to MAX_ALIGN.
2008-11-17 19:58:02 -08:00
Michael Brown c661945e82 [build] Discard junk sections created by newer gcc versions 2008-11-18 03:46:27 +00:00
Michael Brown 54fbd11221 [build] Keep gcc 4.4 happy
gcc 4.4 adds another few warnings, and also seems to complain if we
place %ebp in the clobber list for any inline asm.
2008-11-18 01:52:40 +00:00
Michael Brown 2ca2607b1b [romprefix] Use smaller PMM allocations if possible
The only way that PMM allows us to request a block in a region with
A20=0 is to ask for a block with an alignment of 2MB.  Due to the PMM
API design, the only way we can do this is to ask for a block with a
size of 2MB.

Unfortunately, some BIOSes will hit problems if we allocate a 2MB
block.  In particular, it may not be possible to enter the BIOS setup
screen; the BIOS setup code attempts a PMM allocation, fails, and
hangs the machine.

We now try allocating only as much as we need via PMM.  If the
allocated block has A20=1, we free the allocated block, double the
allocation size, and try again.  Repeat until either we obtain a block
with A20=0 or allocation fails.  (This is guaranteed to terminate by
the time we reach an allocation size of 2MB.)
2008-11-11 20:00:13 +00:00
Michael Brown 29e6f9835e [i386] Add data32 prefixes to all lgdt/lidt instructions
With a 16-bit operand, lgdt/lidt will load only a 24-bit base address,
ignoring the high-order bits.  This meant that we could fail to fully
restore the GDT across a call into gPXE, if the GDT happened to be
located above the 16MB mark.

Not all of our lgdt/lidt instructions require a data32 prefix (for
example, reloading the real-mode IDT can never require a 32-bit base
address), but by adding them everywhere we will hopefully not forget
the necessary ones in future.
2008-11-07 03:48:25 +00:00
Michael Brown 5e6b82104d [romprefix] Add vendor branding facilities and guidelines
Some hardware vendors have been known to remove all gPXE-related
branding from ROMs that they build.  While this is not prohibited by
the GPL, it is a little impolite.

Add a facility for adding branding messages via two #defines
(PRODUCT_NAME and PRODUCT_SHORT_NAME) in config/general.h.  This
should accommodate all known OEM-mandated branding requirements.
Vendors with branding requirements that cannot be satisfied by using
PRODUCT_NAME and/or PRODUCT_SHORT_NAME should contact us so that we
can extended this facility as necessary.
2008-10-31 19:10:28 +00:00
Michael Brown 467c4f77c3 [hacks] Improve the guess_boot_netdev() logic
This function is a major kludge, but can be made slightly more
accurate by ignoring net devices that aren't open.  Eventually it
needs to be removed entirely.
2008-10-31 01:51:26 +00:00
Michael Brown 0a6c66a830 [settings] Add the notion of a "tag magic" to numbered settings
Settings can be constructed using a dotted-decimal notation, to allow
for access to unnamed settings.  The default interpretation is as a
DHCP option number (with encapsulated options represented as
"<encapsulating option>.<encapsulated option>".

In several contexts (e.g. SMBIOS, Phantom CLP), it is useful to
interpret the dotted-decimal notation as referring to non-DHCP
options.  In this case, it becomes necessary for these contexts to
ignore standard DHCP options, otherwise we end up trying to, for
example, retrieve the boot filename from SMBIOS.

Allow settings blocks to specify a "tag magic".  When dotted-decimal
notation is used to construct a setting, the tag magic value of the
originating settings block will be ORed in to the tag number.
Store/fetch methods can then check for the magic number before
interpreting arbitrarily-numbered settings.
2008-10-30 21:47:14 +00:00
Michael Brown 621101c36a [romprefix] Further sanity checks for the PCI 3 runtime segment address
This extends the sanity checks on the runtime segment address provided
in %bx, first implemented in commit 5600955.

We now allow the ROM to be placed anywhere above a000:0000 (rather
than c000:0000, as before), since this is the region allowed by the
PCI 3 spec.  If the BIOS asks us to place the runtime image such that
it would overlap with the init-time image (which is explicitly
prohibited by the PCI 3 spec), then we assume that the BIOS is faulty
and ignore the provided runtime segment address.

Testing on a SuperMicro BIOS providing overlapping segment addresses
shows that ignoring the provided runtime segment address is safe to do
in these circumstances.
2008-10-29 01:16:52 +00:00
Michael Brown 7a4c129af7 [ioapi] Fix broken implementation of insX() in the x86 I/O API 2008-10-27 00:29:16 +00:00
Michael Brown bcc70d6b99 [pcbios] Guard against register corruption in INT 15,e820 implementations
Someone at Dell must have a full-time job designing ways to screw up
implementations of INT 15,e820.  This latest gem is courtesy of a Dell
Xanadu system, which arbitrarily decides to obliterate the contents of
%esi.

Preserve %esi, %edi and %ebp across calls to INT 15,e820, in case
someone tries a variation on this trick in future.
2008-10-23 04:20:45 +01:00
Michael Brown d9c38d14d6 [build] Fix building on FreeBSD
FreeBSD requires the object format to be specified as elf_i386_fbsd,
rather than elf_i386.

Based on a patch from Eygene Ryabinkin <rea-fbsd@codelabs.ru>
2008-10-17 18:24:04 +01:00
Michael Brown 5600955bdd [romprefix] Sanity-check the runtime segment address for PCI 3
Some PCI 3 BIOSes seem to provide a garbage value in %bx, which should
contain the runtime segment address.  Perform a basic sanity check: we
reject the segment if it is below the start of option ROM space.  If
the sanity check fails, we assume that the BIOS was not expecting us
to be a PCI 3 ROM, and we just leave our image in situ.
2008-10-17 18:12:24 +01:00
Michael Brown 7982e79d3c [build] Use ".bss.*" names for uninitialised-data sections
The section name seems to have significance for some versions of
binutils.

There is no way to instruct gcc that sections such as .bss16 contain
uninitialised data; it will emit them with contents explicitly set to
zero.  We therefore have to rely on the linker script to force these
sections to become uninitialised-data sections.  We do this by marking
them as NOLOAD; this seems to be the closest semantic equivalent in the
linker script language.

However, this gets ignored by some versions of ld (including 2.17 as
shipped with Debian Etch), which mark the resulting sections with
(CONTENTS,ALLOC,LOAD,DATA).  Combined with the fact that this version of
ld seems to ignore the specified LMA for these sections, this means that
they end up overlapping other sections, and so parts of .prefix (for
example) get obliterated by .data16's bss section.

Rename the .bss sections from .section_bss to .bss.section; this seems to
cause these versions of ld to treat them as uninitialised data.
2008-10-17 03:12:11 +01:00
Michael Brown 04f3206581 [build] Fix building on Ubuntu 8.04
Not fully understood, but it seems that the LMA of bss sections matters
for some newer binutils builds.  Force all bss sections to have an LMA
at the end of the file, so that they don't interfere with other
sections.

The symptom was that objcopy -O binary -j .zinfo would extract the
.zinfo section from bin/xxx.tmp as a blob of the correct length, but
with zero contents.  This would then cause the [ZBIN] stage of the
build to fail.

Also explicitly state that .zinfo(.*) sections have @progbits, in case
some future assembler or linker variant decides to omit them.
2008-10-17 01:55:58 +01:00
Michael Brown 64e5ca0582 [efi] Fix linker script for ld 2.17.50.0.9
Some versions of ld choke on the "AT ( _xxx_lma )" in efi.lds with an
error saying "nonconstant expression for load base".  Since these were
only explicitly setting the LMA to the address that it would have had
anyway, they can be safely omitted.
2008-10-13 10:41:38 +01:00
Michael Brown 81d92c6d34 [efi] Add EFI image format and basic runtime environment
We have EFI APIs for CPU I/O, PCI I/O, timers, console I/O, user
access and user memory allocation.

EFI executables are created using the vanilla GNU toolchain, with the
EXE header handcrafted in assembly and relocations generated by a
custom efilink utility.
2008-10-13 10:24:14 +01:00
Michael Brown 831e4cfc27 [umalloc] Formalise the user memory allocation API 2008-10-13 05:33:14 +01:00
Michael Brown 6554b79ff9 [uaccess] Formalise the uaccess API
The userptr_t is now the fundamental type that gets used for conversions.
For example, virt_to_phys() is implemented in terms of virt_to_user() and
user_to_phys().
2008-10-13 04:10:34 +01:00
Michael Brown c0835339d0 [nap] Formalise the CPU sleeping API 2008-10-12 23:36:53 +01:00
Michael Brown 16f1e35775 [timer] Formalise the timer API
We now have two implementations for the timer API: one using the
time-of-day counter at 40:70 and one using RDTSC.  Both make use of
timer2_udelay().
2008-10-12 20:22:02 +01:00
Michael Brown 8a4ccebec9 [pci] Formalise the PCI I/O API 2008-10-12 12:54:12 +01:00
Michael Brown aef6d0df5c [ioapi] Absorb virt_to_phys() and phys_to_virt() into the I/O API 2008-10-12 02:15:34 +01:00
Michael Brown 992bbf309c [i386] Remove obsolete functions from virtaddr.h
The copy_{to,from}_phys() functions were obsoleted long ago by
copy_{to,from}_user().

relocate_to() also disappeared some time ago.
2008-10-12 02:14:26 +01:00
Michael Brown ee2df1d6d6 [ioapi] Remove old io.h file and switch all users over to <gpxe/io.h> 2008-10-12 01:06:27 +01:00
Michael Brown 8956a36be5 [ioapi] Formalise the I/O API as used in i386-pcbios 2008-10-12 01:03:17 +01:00
Michael Brown 13d09e6719 [i386] Simplify linker script and standardise linker-defined symbol names
Reduce the number of sections within the linker script to match the
number of practical sections within the output file.

Define _section, _msection, _esection, _section_filesz, _section_memsz,
and _section_lma for each section, replacing the mixture of symbols that
previously existed.

In particular, replace _text and _end with _textdata and _etextdata, to
make it explicit within code that uses these symbols that the .text and
.data sections are always treated as a single contiguous block.
2008-10-10 03:59:57 +01:00
Michael Brown 3029eb0e84 [makefile] Reduce verbosity of various NON_AUTO_MEDIA rules 2008-10-10 03:57:31 +01:00
Michael Brown 5c695db474 [makefile] Split platform-dependent portions out of arch/i386/Makefile 2008-10-10 03:45:34 +01:00
Michael Brown a2588547f9 [makefile] Add support for multiple build platforms
Allow for the build CPU architecture and platform to be specified as part
of the make command goals.  For example:

  make bin/rtl8139.rom      # Standard i386 PC-BIOS build

  make bin-efi/rtl8139.efi  # i386 EFI build

The generic syntax is "bin[-[arch-]platform]", with the default
architecture being "i386" (regardless of the host architecture) and the
default platform being "pcbios".

Non-path targets such as "srcs" can be specified using e.g.

  make bin-efi srcs

Note that this changeset is merely Makefile restructuring to allow the
build architecture and platform to be determined by the make command
goals, and to export these to compiled code via the ARCH and PLATFORM
defines.  It doesn't actually introduce any new build platforms.
2008-10-08 02:17:25 +01:00
Michael Brown f0b942ef42 [makefile] Kill off arch/$(ARCH)/Config
The arch/i386/Config file has long been marked as deprecated.  Move all
the pertinent bits to arch/i386/Makefile instead and remove
arch/i386/Config.
2008-10-07 22:46:43 +01:00
Michael Brown 1dda75c9cd [pcbios] Allow for larger-than-20-byte buffers in e820mangler.S
Although the E820 API allows for a caller to provide only a 20-byte
buffer, there exists at least one combination (HP BIOS, 32-bit WinPE)
that relies on information found only in the "extended attributes"
field, which requires a 24-byte buffer.

Allow for up to a 64-byte E820 buffer, in the hope of coping with
future idiocies like this one.
2008-09-29 05:11:51 +01:00
Michael Brown 040f7cdf3a [pcbios] Print INT 15,E820 extended attributes, if present
The ACPI specification defines an additional 4-byte field at offset 20
for an E820 memory map entry.  This field is presumably optional,
since generally E820 gets given only a 20-byte buffer to fill.
However, the bits of this optional field are defined as:

  bit 0 : region is enabled
  bit 1 : region is non-volatile memory rather than RAM

so it seems as though callers that pass in only a 20-byte buffer may
be missing out on some rather important information.
2008-09-29 03:55:13 +01:00
Michael Brown 0015601f0b [gdb] Fix a compiler warning that shows up only when assertions are enabled
gcc should (I think) be warning about this anyway, but seems to do so
only when assertions are enabled for this object.
2008-09-29 01:00:14 +01:00
Michael Brown 50dc9344b7 [pcbios] Save/restore %es in INT 15,e820
Our INT 15,e820 code was setting %es=%ss (as part of the "look ahead
in the memory map" logic), but failing to restore %es afterwards.
This is a serious bug, but wasn't affecting many platforms because
almost all callers seem to set %es=%ss anyway.
2008-09-29 00:36:11 +01:00
Michael Brown e3c5507178 [i386] Add dump_regs() debug call
Use as "call dump_regs" from any real-mode code within .text16.
Should preserve all registers and flags.
2008-09-28 23:06:53 +01:00
Michael Brown 9d72636da1 [romprefix] Fully clear the "Press B to boot..." message when INT19 is used 2008-09-26 01:36:22 +01:00
Michael Brown 3392cfa7df [pcbios] Fetch INT 15,e820 entry directly into our e820 cache
Some BIOSes require us to pass in not only the continuation value (in
%ebx) as returned by the previous call to INT 15,e820 but also the
unmodified buffer (at %es:%di) as returned by the previous call to INT
15,e820.  Apparently, someone thought it would be a worthwhile
optimisation to fill in only the low dword of the "length" field and
the low byte of the "type field", assuming that the buffer would
remain unaltered from the previous call.

This problem was being triggered by the "peek ahead" logic in
get_mangled_e820(), which would read the next entry into a temporary
buffer in order to be able to guarantee terminating the map with
%ebx=0 rather than CF=1.  (Terminating with CF=1 upsets some Windows
flavours, despite being documented legal behaviour.)

Work around this problem by always fetching directly into our e820
cache; that way we can guarantee that the underlying call always sees
the previous buffer contents (and the same buffer address).
2008-09-25 18:52:49 +01:00
Michael Brown c24bc349ea [pcbios] Add facility for testing arbitrary E820 memory maps
We seem to be having issues with various E820 memory maps.  These
problems are often difficult to reproduce, requiring access to the
specific system exhibiting the problem.

Add a facility for hooking in a fake E820 map generator, using an
arbitrary map defined in a C array, solely in order to be able to test
the map-mangling code against arbitrary E820 maps.
2008-09-25 03:34:26 +01:00
Michael Brown 539f94b980 [romprefix] Allow BANNER_TIMEOUT to control banners in romprefix.S
In particular, allow BANNER_TIMEOUT=0 to inhibit the prompt banners
altogether.

Ironically, this request comes from the same OEM that originally
required the prompts to be present during POST.
2008-09-25 01:53:42 +01:00
Michael Brown fed106b7fb [pxe] Enable interrupts before starting PXE NBP execution
Based on a patch provided by XenSource for Etherboot 5.4.
2008-09-24 21:23:50 +01:00
Michael Brown 887d77c27a [pcbios] Inhibit INT 15 memory map hiding on brain-dead BIOSes
Some really moronic BIOSes bring up the PXE stack via the UNDI loader
entry point during POST, and then don't bother to unload it before
overwriting the code and data segments.  If this happens, we really
don't want to leave INT 15 hooked, because that will cause any loaded
OS to die horribly as soon as it attempts to fetch the system memory
map.

We use a heuristic to detect whether or not we are being loaded at the
top of free base memory.  If we determine that we are being loaded at
some other arbitrary location in base memory, then we assume that it's
not safe to hook INT 15.
2008-09-24 18:33:31 +01:00
Michael Brown 9d44a06188 [romprefix] If we hook INT 19, prompt before attempting boot
On non-BBS systems we hook INT 19, since there is no other way we can
guarantee gaining control of the flow of execution.  If we end up
doing this, prompt the user before attempting boot, since forcibly
capturing INT 19 is rather antisocial.
2008-09-24 00:53:40 +01:00
Michael Brown 8b20e5d2b7 [pcbios] Sanity-check the INT15,e820 and INT15,e801 memory maps
Some systems seem to report insane memory maps (particularly at POST
time).  Detect and work around some of the common failure cases.
2008-09-23 23:35:19 +01:00
Michael Brown ca0b0f0616 [relocate] Guard against systems that report empty memory regions
If the INT 15,e820 memory map reports a region [0,0), this confuses
the "truncate to even megabytes" logic, which ends up rounding the
region 'down' to [0,fff00000).

Fix by ensuring that the region's end address is at least 1, before we
subtract 1 to obtain the "last byte in region" address.
2008-09-23 01:13:28 +01:00
Michael Brown 0fd1e54026 [memmap] Allow for 4GB+ systems in debug message
INT 15,e801 is capable of returning a memory range that extends to
4GB, so allow for this in the debug message that shows the data
returned by INT 15,e801.
2008-09-23 00:58:12 +01:00
Michael Brown 6df82b1a9d [undi] Scan for UNDI ROMs on 512-byte boundaries rather than 2kB boundaries
Apparently some BIOSes will place option ROMs on 512-byte boundaries.
While this is against specification, it doesn't actually hurt
anything, so we may as well increase our scan granularity to 512
bytes.

Contributed by Luca <lucarx76@gmail.com>
2008-09-12 03:10:27 +01:00
Michael Brown 18aa0e79d2 [pcbios] Add extra debugging messages relating to the system memory map 2008-09-07 21:38:41 +01:00
Michael Brown c0beec8baf [pxe] Add a dummy PXENV+ entry point at UNDI_CS:0000
Wyse Streaming Manager server (WLDRM13.BIN) assumes that the PXENV+
entry point is at UNDI_CS:0000; apparently, somebody at Wyse has
difficulty distinguishing between the words "may" and "must"...

Add a dummy entry point at UNDI_CS:0000, which just jumps to the
correct entry point.
2008-09-06 03:19:03 +01:00
Michael Brown 2e03610c0d [multiboot] Allow for unspecified {load,bss}_end_addr for raw images
The multiboot specification states that, for raw images, if
load_end_addr is zero then it should be interpreted as meaning "use
the entire file", and if bss_end_addr is zero it should be interpreted
as meaning "no bss".
2008-09-06 01:57:52 +01:00
Eygene Ryabinkin 99251f5b32 [libprefix] Add addr32 prefix required by older assemblers
Explicitly state that we are using 32-bit addressing in 16-bit code.

GNU as 2.15 (FreeBSD/amd64 7-STABLE) got confused that 32-bit registers
are used in the code that was declared as 16-bit.  Add explicit modifier
'addr32' to make assembler happy.

Signed-off-by: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
2008-09-04 11:27:20 +01:00
Daniel Verkamp e8b22f203f [comboot] Add COMBOOT and COM32 support 2008-08-28 23:52:19 +01:00
Daniel Verkamp aa28544373 [librm] Add rm stack copying functions 2008-08-28 23:09:08 +01:00
Daniel Verkamp 2539f5fa4a [librm] Make rm_sp and rm_ss globals again 2008-08-28 22:50:55 +01:00
Daniel Verkamp 179fa70d34 [libc] Mark setjmp and longjmp as __cdecl 2008-08-28 22:50:39 +01:00
Michael Brown fc0c40a5b0 [pxe] Fill in UNDIROMID pointer in !PXE structure
IBM's iSCSI Firmware Initiator checks the UNDIROMID pointer in the
!PXE structure that gets created by the UNDI loader.  We didn't
previously fill this value in.
2008-08-28 00:11:45 +01:00
Michael Brown 32e34683c0 [romprefix] Add UNDI ROMID structure bus type field
The IBM iSCSI Firmware Initiator complains that we don't have a bus
type field in the UNDI ROMID structure, so include one.
2008-08-27 22:08:57 +01:00
Michael Brown d5732b0272 [romprefix] Preserve %edi when issuing INT 1A,B101
INT 1A,B101 (get PCI BIOS version) will overwrite %edi.
2008-08-26 05:03:19 +01:00
Michael Brown de7be480d6 [romprefix] Add more diagnostic messages to ROM prefix
Include PMM allocation result in POST banner.

Include full product string in "starting execution" message.

Also mark ourselves as supporting DDIM in PnP header, for
completeness.
2008-08-25 23:36:24 +01:00
Michael Brown d5e07dfe92 [romprefix] Fix regression in UNDI loader
Commit 12f203c introduced a bug that caused the UNDI loader to attempt
to load the UNDI code and data segments to incorrect addresses.
2008-08-22 23:58:46 +01:00
Michael Brown 82baea0a4b [romprefix] On a PCI3.0, non-BBS system, use the correct %cs for INT19
On a system that doesn't support BBS, we end up hooking INT19 to gain
control of the boot process.  If the system is PCI3.0, we must take
care to use the runtime value for %cs, rather than the POST-time
value, otherwise we end up pointing INT19 to the temporary option ROM
POST scratch area.
2008-08-22 03:01:46 +01:00
Michael Brown 4815188dfc [elf] Add execution entry point debug messages for elf/multiboot images 2008-08-22 02:12:44 +01:00
Michael Brown 0c7618771e [smbios] Print SMBIOS version number in debugging messages 2008-08-19 22:01:38 +01:00
Michael Brown 320b072c7a [pcbios] Support arbitrary splits of the e820 memory map
Allow for an arbitrary number of splits of the system memory map via
INT 15,e820.

Features of the new map-mangling algorithm include:

  Supports random access to e820 map entries.

  Requires only sequential access support from the underlying e820
  map, even if our caller uses random access.

  Empty regions will always be stripped.

  Always terminates with %ebx=0, even if the underlying map terminates
  with CF=1.

  Allows for an arbitrary number of hidden regions, with underlying
  regions split into as many subregions as necessary.

Total size increase to achieve this is 193 bytes.
2008-08-18 07:17:41 +01:00
Michael Brown 9737095d49 [pcbios] Prepare for multiple splits of hidden e820 memory regions
Define a list of N allowed memory regions, and split each underlying
e820 region into up to N subregions.  Strip resulting empty regions
out of the map, avoiding using the "return with CF set to strip last
empty region" trick, because it seems that bootmgr.exe in Win2k8 gets
upset if the memory map is terminated with CF set.

This is an intermediate checkin that defines a single allowed memory
region covering the entire 64-bit address space, and uses the existing
map-mangling code on top of the new region-splitting code.  This
sanitises the memory map to the point that Win2k8 is able to boot even
on a system that defines a final zero-length region at the 4GB mark.

I'm checking this in because it may be useful for future debugging
efforts to be able to run with the existing and known-working map
mangling code together with the map sanitisation capabilities of the
new map mangling code.
2008-08-18 01:01:45 +01:00
Michael Brown 8332ddf556 [romprefix] Fix ROM image copy on PCI 3.0 BIOSes
Add the missing instructions to the code path that I never tested due
to not having a PCI 3.0 system available.

(D'oh)
2008-08-05 23:18:07 +01:00
Michael Brown fe1f017bde [romprefix] Update PCI ROM structure to PCI 3.0 2008-07-30 19:57:46 +01:00
Stefan Hajnoczi 4cc786de81 [prefix] Reasonable value for lkrn initrd_addr_max
H. Peter Anvin <hpa@zytor.com> sent word that Sergey Vlasov
<vsu@altlinux.ru> discovered gPXE lkrn images fail to load in SYSLINUX
3.70 because we have initrd_addr_max zeroed.  This patch sets the same
value as the Linux kernel.

Also change the header jmp instruction to use a hardcoded opcode value
like Linux does.  Just in case the assembler decides to use a three-byte
instruction instead of the desired two-byte jmp.
2008-07-30 19:45:48 +01:00
Michael Brown 594c672b75 [smbios] Add named settings for manufacturer, product name, and serial no. 2008-07-27 01:18:55 +01:00
Michael Brown 03c80c12b8 [iSCSI] Support Windows Server 2008 direct iSCSI installation
Add yet another ugly hack to iscsiboot.c, this time to allow the user to
inhibit the shutdown/removal of the iSCSI INT13 device (and the network
devices, since they are required for the iSCSI device to function).

On the plus side, the fact that shutdown() now takes flags to
differentiate between shutdown-for-exit and shutdown-for-boot means that
another ugly hack (to allow returning via the PXE stack on BIOSes that
have broken INT 18 calls) will be easier.

I feel dirty.
2008-07-17 17:45:17 +01:00
Michael Brown bb41ec385c [int13] Pairwise swap drive numbers, instead of shifting all drive numbers
Shifting all INT13 drive numbers causes problems on systems that use a
sparse drive number space (e.g. qemu BIOS, which uses 0xe0 for the CD-ROM
drive).

The strategy now is:

  Each drive is assigned a "natural" drive number, being the next
  available drive number in the system (based on the BIOS drive count).

  Each drive is accessed using its specified drive number.  If the
  specified drive number is -1, the natural drive number will be used.

  Accesses to the specified drive number will be delivered to the
  emulated drive, masking out any preexisting drive using this number.

  Accesses to the natural drive number, if different, will be remapped to
  the masked-out drive.

The overall upshot is that, for examples:

  System has no drives.  Emulated INT13 drive gets natural number 0x80
  and specified number 0x80.  Accesses to drive 0x80 go to the emulated
  drive, and there is no remapping.

  System has one drive.  Emulated INT13 drive gets natural number 0x81
  and specified number 0x80.  Accesses to drive 0x80 go to the emulated
  drive.  Accesses to drive 0x81 get remapped to the original drive 0x80.
2008-07-15 23:19:59 +01:00
Michael Brown dbe9269f3a [bzimage] Kill off the initrd image type
We can just treat all non-kernel images as initrds, which matches our
behaviour for multiboot kernels.  This allows us to eliminate initrd as
an image type, and treat the "initrd" command as just another synonym for
"imgfetch".
2008-07-08 01:30:11 +01:00
Michael Brown 4fbbf651d7 [i386] Change semantics of __from_data16 and __from_text16
__from_data16 and __from_text16 now take a pointer to a
.data16/.text16 variable, and return the real-mode offset within the
appropriate segment.  This matches the use case for every occurrence
of these macros, and prevents potential future bugs such as that fixed
in commit d51d80f.  (The bug arose essentially because "&pointer" is
still syntactically valid.)
2008-06-30 18:52:13 -07:00
Stefan Hajnoczi 1719b105cd [lkrnprefix] Make gPXE .lkrn images conform to the zImage 2.07 format 2008-06-30 19:53:28 +01:00
Stefan Hajnoczi ce51128534 [bzImage] Support loading zImage kernels
zImage kernels require the real-mode portion to be loaded at 9000:0000
rather than 1000:0000.
2008-06-30 19:51:41 +01:00
Stefan Hajnoczi fe79edfc3d [GDB] Remove unused DR6 debug register variable 2008-06-30 19:19:48 +01:00
Stefan Hajnoczi 3715c8c721 [GDB] Zero-extend 16-bit segment registers
When the 16-bit segment registers are accessed using 32-bit instructions
the high order bytes are undefined on older CPUs.  We now explicitly
zero the high order bytes when snapshotting the CPU state.  This ensures
that the GDB stub reports consistent values for the segment registers.
2008-06-30 19:19:48 +01:00
Stefan Hajnoczi 5504fa9047 [GDB] Add copyright header for gdbmach.c 2008-06-30 19:19:48 +01:00
Stefan Hajnoczi 19386ec2c8 [GDB] Add watch and rwatch hardware watchpoints 2008-06-30 19:19:48 +01:00
Michael Brown 27731d975e [romprefix] Fix PMM detection start address
Commit fd0aef9 introduced a typo that caused PMM detection to start at
paragraph 0xe00 rather than 0xe000.  (Detection would still work, since it
would scan until it ran out of base memory, but it would end up scanning
an unnecessarily large portion of base memory.)

Spotted by Sebastian Herbszt <herbszt@gmx.de>.
2008-06-28 23:18:11 +01:00
H. Peter Anvin b7882065f5 [a20] Send a null command to the KBC after changing A20
Send a null command, specifically "pulse outputs" with no outputs
selected, to the KBC after changing A20.  This was apparently done by DOS,
presumably as a synchronization hack, and the authors of the UHCI spec
thought it was inherent.  Therefore, there are systems out there (e.g. HP
DL360 G5) which will stop responsing to "legacy USB" unless they see the
null command, 0xFF, written to port 0x64 at the end of the A20 toggling
sequence.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-06-27 22:29:13 +01:00
Michael Brown 2b9e7a4767 [libc] Remove unused le32_to_cpup(x) and cpu_to_le16p() macros
If we ever need these macros, they should be defined in
include/{big,little}_bswap.h, and the whole family should be defined.
2008-06-27 22:12:44 +01:00
Michael Brown 0ea821c7b7 [script] Remove arbitrary limit on script line lengths 2008-06-18 00:43:58 +01:00
Michael Brown cd0e9bcd22 [prefix] When we have to hook INT 19, chain to original handler if possible
When the BIOS doesn't support BBS, hooking INT 19 is the only way to add
ourselves as a boot device.  If we have to do this, we should at least
try to chain to the original INT 19 vector if our boot fails.

Idea suggested by Andrew Schran <aschran@google.com>
2008-06-14 13:49:26 +01:00
Michael Brown ac28d054c8 [bzimage] Support kernel command lines of greater than 256 characters
2.6.22+ kernels have an extra field in the bzimage_header structure to
indicate the maximum permitted command-line length.  Use this if it is
available.
2008-06-12 02:19:10 +01:00
Michael Brown 031b30898a [smbios] Fix SMBIOS string fetching
A bug in read_smbios_string() was causing the starting offset of the
SMBIOS structure to be added twice, resulting in completely the wrong
strings being returned.

Bug identified by Martin Herweg <m.herweg@gmx.de>
2008-06-11 13:43:58 +01:00
Michael Brown 798ddf884f [undi] Ask for promiscuous packet reception when using UNDI driver
We never set up specific multicast filters; native drivers will ask
the card to receive all multicast packets.  The only way to achieve
this via the UNDI API is to enable promiscuous mode.
2008-06-10 08:56:44 +01:00
Michael Brown 77a5cc6b13 [ELF] Add ability to boot ELF images generated by wraplinux and mkelfImage
Delete ELF as a generic image type.  The method for invoking an
ELF-based image (as well as any tables that must be set up to allow it
to boot) will always depend on the specific architecture.  core/elf.c
now only provides the elf_load() function, to avoid duplicating
functionality between ELF-based image types.

Add arch/i386/image/elfboot.c, to handle the generic case of 32-bit
x86 ELF images.  We don't currently set up any multiboot tables, ELF
notes, etc.  This seems to be sufficient for loading kernels generated
using both wraplinux and coreboot's mkelfImage.

Note that while Etherboot 5.4 allowed ELF images to return, we don't.
There is no callback mechanism for the loaded image to shut down gPXE,
which means that we have to shut down before invoking the image.  This
means that we lose device state, protection against being trampled on,
etc.  It is not safe to continue afterwards.
2008-06-09 13:50:00 +01:00
Stefan Hajnoczi 04bc50f025 [GDB] Add GDB stub for remote debugging
See http://etherboot.org/wiki/dev/gdbstub for documentation.
2008-06-05 00:45:50 +01:00
Stefan Hajnoczi 842165ef76 [GDBSYM] Remove unused gdbsym.c
The GDBSYM config.h option was an attempt at QEMU GDB debugging.  I have
removed the code since it is unused and may confuse people wanting to
use the GDB stub.
2008-06-05 00:45:32 +01:00
Michael Brown c899bdc5a8 [Makefile] Remove obsolete SRCDIRS 2008-05-23 02:35:20 +01:00
Michael Brown 7cd08434ea [prefix] Prompt for entering gPXE shell during POST
The ROM prefix now prompts the user to enter the gPXE shell during POST;
this allows for configuring gPXE without needing to attempt to boot from
it.  (It also slows down system boot by three seconds per gPXE ROM, but
hey.)

This is apparently a certain OEM's requirement for option ROMs.
2008-05-22 15:14:33 +01:00
Michael Brown fd0aef9ee1 [prefix] Add PCI bus:dev.fn to ROM product string
This allows multiple gPXE ROMs in a system to be disambiguated at boot
time; the PCI ID will show up in the boot menu for a BBS-compliant BIOS.
2008-05-21 18:43:58 +01:00
Michael Brown 1ba959c6b3 [NETDEV] Add notion of link state
Add ability for network devices to flag link up/down state to the
networking core.

Autobooting code will now wait for link-up before attempting DHCP.

IPoIB reflects the Infiniband link state as the network device link state
(which is not strictly correct; we also need a succesful IPoIB IPv4
broadcast group join), but is probably more informative.
2008-04-22 17:40:50 +01:00
Michael Brown 3475b693b7 [HCI] Display "Not an executable image" when appropriate
PXE is a catch-all image format with no signature checks.  If an
unsupported image file is loaded, it will be treated as a PXE image.  In
most cases, the image will be too large to be loaded as a PXE image (which
has to fit in base memory), so the error returned to the user will be that
the segment could not fit within the memory region.

Add an explicit check to pxe_image.c to reject images larger than base
memory with ENOEXEC.

Add ENOEXEC to the error string table.
2008-04-08 16:28:00 +01:00
Michael Brown feade5da6e [Settings] Expose SMBIOS via settings API
In particular, expose the system UUID as a setting ("smbios/uuid").
2008-03-28 15:35:06 +00:00
H. Peter Anvin d62e89d776 [PXEXT] Add FILE_API_CHECK API function
Add FILE_API_CHECK to the PXEXT API so the NBP can query the
availability and status of the API.
2008-03-26 15:10:56 -07:00
Michael Brown 92d15eff30 [Settings] Remove assumption that all settings have DHCP tag values
Allow for settings to be described by something other than a DHCP option
tag if desirable.  Currently used only for the MAC address setting.

Separate out fake DHCP packet creation code from dhcp.c to fakedhcp.c.

Remove notion of settings from dhcppkt.c.

Rationalise dhcp.c to use settings API only for final registration of the
DHCP options, rather than using {store,fetch}_setting throughout.
2008-03-25 20:46:16 +00:00
Michael Brown dbf8a02e8f [libc] Use __builtin_va_list et al in stdarg.h
The home-grown versions don't work properly for static variadic
functions, when gcc can choose to use a non-standard calling convention.
2008-03-24 00:23:11 +00:00
Michael Brown ee4206a8a7 [DHCP] Fix up fake-packet creation as used by PXENV_GET_CACHED_INFO
Add dedicated functions create_dhcpdiscover(), create_dhcpack() and
create_proxydhcpack() for use by external code such as the PXE preboot
code.

Register ProxyDHCP options under the global scope "proxydhcp".

Unregister previously-acquired DHCP and ProxyDHCP settings when DHCP
succeeds.
2008-03-23 21:58:05 +00:00
Michael Brown 8afb36c3bc [Settings] Migrate DHCP and NVO code to the new settings API (untested) 2008-03-21 22:15:31 +00:00