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

1262 Commits

Author SHA1 Message Date
Michael Brown be79ca535a [xen] Use version 1 grant tables by default
Using version 1 grant tables limits guests to using 16TB of grantable
RAM, and prevents the use of subpage grants.  Some versions of the Xen
hypervisor refuse to allow the grant table version to be set after the
first grant references have been created, so the loaded operating
system may be stuck with whatever choice we make here.  We therefore
currently use version 2 grant tables, since they give the most
flexibility to the loaded OS.

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

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

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

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-13 19:21:42 +01:00
Michael Brown 3f39f9fcb3 [xen] Accept alternative Xen platform PCI device ID 5853:0002
At some point during XenServer development history, the Windows PV
drivers changed to using a PCI device ID of 5853:0002 rather than
5853:0001.  Current (7.2.0) drivers will bind to either 5853:0001 or
5853:0002, and the general approach taken by the world at large
(including Amazon EC2) seems to be to use only 5853:0001.

However, the current version of XenServer (6.2.0) will create the
platform device as 5853:0002 (via the platform:device_id VM parameter)
for any VMs created using the built-in templates for Windows Vista or
later.

Accept either PCI ID, since the underlying device is identical.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-13 13:17:33 +01:00
Michael Brown 6566690ba1 [bios] Support displaying and hiding cursor
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-06 15:10:58 +01:00
Michael Brown dc18fd7648 [efi] Default to releasing network devices for use via SNP
We currently treat network devices as available for use via the SNP
API only if RX queue processing has been frozen.  (This is similar in
spirit to the way that RX queue processing is frozen for the network
device currently exposed via the PXE API.)

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

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

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

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-29 15:57:44 +01:00
Michael Brown ec30c856a8 [ioapi] Centralise notion of PAGE_SIZE
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-28 16:58:35 +01:00
Michael Brown 5888c887a4 [x86_64] Add functions to read and write model-specific registers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-23 10:20:15 +01:00
Michael Brown 945b8de1fd [i386] Add functions to read and write model-specific registers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-23 10:20:15 +01:00
Michael Brown ae778091ca [ioapi] Fail ioremap() when attempting to map a zero bus address
When a 32-bit iPXE binary is running on a system which allocates PCI
memory BARs above 4GB, our PCI subsystem will return the base address
for any such BARs as zero (with a warning message if DEBUG=pci is
enabled).  Currently, ioremap() will happily map an address pointing
to the start of physical memory, providing no sensible indication of
failure.

Fix by always returning NULL if we are asked to ioremap() a zero bus
address.

With a totally flat memory model (e.g. under EFI), this provides an
accurate failure indication since no PCI peripheral will be mapped to
the zero bus address.

With the librm memory model, there is the possibility of a spurious
NULL return from ioremap() if the bus address happens to be equal to
virt_offset.  Under the current virtual memory map, the NULL virtual
address will always be the start of .textdata, and so this problem
cannot occur; a NULL return from ioremap() will always be an accurate
failure indication.

Debugged-by: Anton D. Kachalov <mouse@yandex-team.ru>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-16 15:39:59 +01:00
Michael Brown 5365340e77 [efi] Include SNP NIC driver within the all-drivers target
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-08 16:28:22 +01:00
Michael Brown bcfd3dea1d [efi] Identify autoboot device by MAC address when chainloading
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-08 00:37:31 +01:00
Michael Brown 00c745e5ff [autoboot] Allow autoboot device to be identified by link-layer address
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-08 00:37:31 +01:00
Michael Brown cb2f6ca46f [build] Add yet another potential location for isolinux.bin
Reported-by: Martin Sofaru <ipxe@fhloston.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-26 17:05:36 +01:00
Michael Brown 0e3ab6064e [efi] Restructure EFI driver model
Provide a single instance of EFI_DRIVER_BINDING_PROTOCOL (attached to
our image handle); this matches the expectations scattered throughout
the EFI specification.

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

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

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

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

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-25 14:47:35 +01:00
Michael Brown f3d423b26b [librm] Allow for the PIC interrupt vector offset to be changed
Some external code (observed with FreeBSD's bootloader) will continue
to make INT 13 calls after reconfiguring the 8259 PIC to change the
vector offsets for IRQs.  If an IRQ (e.g. the timer IRQ) subsequently
occurs while iPXE is in protected mode, this will cause a general
protection fault since the corresponding IDT entry is empty.

A general protection fault is INT 0x0d, which happens to overlap with
the original IRQ5.  We therefore do have an ISR set up to handle a
general protection fault, but this ISR simply reflects the interrupt
down to the real-mode INT 0x0d and then attempts to return.  Since our
ISR is expecting a hardware interrupt rather than a general protection
fault, it doesn't remove the error code from the stack before issuing
the iret instruction; it therefore attempts to return to a garbage
address.  Since the segment part of this address is likely to be
invalid, a second general protection fault occurs.  This cycle
continues until we run out of stack space and triple fault.

Fix by reflecting all INTs down to real mode.  This actually reduces
the code size by four bytes (but increases the bss size by almost
2kB).

Reported-by: Brian Rak <dn@devicenull.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-27 14:49:25 +01:00
Michael Brown f747a00c54 [lkrnprefix] Make real-mode setup code relocatable
The bzImage boot protocol allows the real-mode code to be loaded at
any segment within base memory.  (The fact that both iPXE and recent
versions of Syslinux will load the real-mode code at 1000:0000 is a
coincidence; it is not guaranteed by the specification.)

Fix by making the code relocatable.

Reported-by: Andrew Stuart <andrew@shopcusa.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-15 13:04:47 +01:00
Christian Hesse a8f037a275 [build] Merge util/geniso and util/genliso
Rework geniso and genliso to provide a single merged utility for
generating ISO images.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-14 16:00:58 +01:00
Michael Brown d31cf2de30 [undi] Apply quota only to number of complete received packets
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-14 13:50:30 +01:00
Michael Brown 779d65222e [build] Avoid errors when build directory is mounted via NFS
Reported-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-13 16:45:57 +01:00
Michael Brown a8d1b50d8b [lkrnprefix] Function as a bzImage kernel
The .lkrn prefix currently provides a zImage kernel with unused setup
sectors and the whole iPXE binary placed within the "protected mode
kernel" portion of the zImage.

The work carried out years ago to create the .mrom format provides a
mechanism allowing the iPXE binary to be split into a small real-mode
header and a larger payload.  This neatly matches the way that a
bzImage is loaded: the "setup sectors" can contain the header and the
"protected mode kernel" can contain the payload.

This removes the size restrictions on an iPXE .lkrn image (and hence
on derived image formats such as .iso).

Also remove obsolete copyright information, since none of the original
code or functionality now remains.

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-04 13:39:42 +01:00
Michael Brown 69313edad8 [undi] Place an upper limit on the number of PXENV_UNDI_ISR calls per poll
PXENV_UNDI_ISR calls may implicitly refill the underlying receive
ring, and so could continue to retrieve packets indefinitely.  Place
an upper limit on the number of calls to PXENV_UNDI_ISR per call to
undinet_poll().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 19:52:10 +01:00
Michael Brown 71ed061776 [undi] Do not switch to real mode to check for NIC interrupt
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 19:52:10 +01:00
Michael Brown 277f581ac3 [undi] Report any PXENV_UNDI_ISR errors via netdev_rx_err()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 19:52:10 +01:00
Michael Brown 402ce65632 [undi] Profile transmit and receive datapaths
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 19:51:38 +01:00
Michael Brown 50689a8974 [undi] Profile all PXE API calls
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 19:51:29 +01:00
Michael Brown 206bd7bb64 [pxe] Work around missing PXENV_UNDI_OPEN only when necessary
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 18:52:15 +01:00
Michael Brown 90caf71051 [pxe] Profile UNDI transmit datapath
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 18:52:15 +01:00
Michael Brown 579337c368 [pxe] Profile all PXE API calls
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 18:52:15 +01:00
Michael Brown be7f35d9c0 [librm] Add profiling self-tests for complete real_call and prot_call cycles
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 18:52:12 +01:00
Michael Brown a0da06c306 [profile] Provide methods for profiling individual stages of operations
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-03 18:50:26 +01:00
Michael Brown bcfaf119a7 [librm] Speed up protected-mode calls under KVM
When making a call from real mode to protected mode, we save and
restore the global and interrupt descriptor table registers.  The
restore currently takes place after returning to real mode, which
generates two EXCEPTION_NMIs and corresponding VM exits when running
under KVM on an Intel CPU.

Avoid the VM exits by restoring the descriptor table registers inside
prot_to_real, while still running in protected mode.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-02 21:00:53 +01:00
Michael Brown c64747db50 [librm] Speed up real-to-protected mode transition under KVM
Ensure that all segment registers have zero in the low two bits before
transitioning to protected mode.  This allows the CPU state to
immediately be deemed to be "valid", and eliminates the need for any
further emulated instructions.

Load the protected-mode interrupt descriptor table after switching to
protected mode, since this avoids triggering an EXCEPTION_NMI and
corresponding VM exit.

This reduces the time taken by real_to_prot under KVM by around 50%.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-02 15:23:21 +01:00
Michael Brown 5a08b63cb7 [librm] Speed up protected-to-real mode transition under KVM
On an Intel CPU supporting VMX, KVM will emulate instructions while
the CPU state remains "invalid".  In real mode, the CPU state is
defined to be "invalid" if any segment register has a base which is
not equal to (sreg<<4) or a limit which is not equal to 64kB.

We don't actually use the base stored in the REAL_DS descriptor for
any significant purpose.  Change the base stored in this descriptor to
be equal to (REAL_DS<<4).  A segment register loaded with REAL_DS is
then automatically valid in both real and protected modes.  This
allows KVM to stop emulating instructions much sooner.

The only use of REAL_DS for memory accesses currently occurs in the
indirect ljmp within prot_to_real.  Change this to a direct ljmp,
storing rm_cs in .text16 as part of the ljmp instruction.  This
removes the only memory access via REAL_DS (thereby allowing for the
above descriptor base address hack), and also simplifies the ljmp
instruction (which will still have to be emulated).

Load the real-mode interrupt descriptor table register before
switching to real mode, since this avoids triggering an EXCEPTION_NMI
and corresponding VM exit.

This reduces the time taken by prot_to_real under KVM by around 65%.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-02 15:23:20 +01:00
Michael Brown 03e76c34d8 [librm] Add meaningful labels at section changes
The mode-transition code involves paths which switch back and forth
between the .text and .text16 sections.  At present, only the start of
each function is labelled, which makes it difficult to decode
addresses within the parts of the function existing in a different
section.

Add explicit labels at the start of each section change, so that
addresses can be meaningfully decoded to the nearest label.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-02 15:23:20 +01:00
Michael Brown bd640bc364 [librm] Add a profiling self-test for measuring mode transition times
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-02 15:23:20 +01:00
Michael Brown 34eaf69ddf [pcbios] Do not switch to real mode to sleep the CPU
Now that we can handle interrupts while in protected mode, there is no
need to switch to real mode just to halt the CPU.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-29 18:24:10 +01:00
Michael Brown e4593909a8 [pcbios] Do not switch to real mode to check for timer interrupt
The currticks() function is called at least once per TCP packet, and
so is performance-critical.  Switching to real mode just to allow the
timer interrupt to fire is expensive when running inside a virtual
machine, and imposes a significant performance cost.

Fix by enabling interrupts without switching to real mode.  This
results in an approximately 100% increase in download speed when
running under KVM.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-29 18:24:10 +01:00
Michael Brown aaf276ccd4 [comboot] Use built-in interrupt reflector
We now have the ability to handle interrupts while in protected mode,
and so no longer need to set up a dedicated interrupt descriptor table
while running COM32 executables.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-29 18:24:10 +01:00
Michael Brown 23b671daf4 [librm] Allow interrupts in protected mode
When running in a virtual machine, switching to real mode may be
expensive.  Allow interrupts to be enabled while in protected mode and
reflected down to the real-mode interrupt handlers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-29 18:24:04 +01:00
Michael Brown 6d4deeeb6c [librm] Use genuine real mode to accelerate operation in virtual machines
We currently use flat real mode wherever real mode is required.  This
guarantees that we will not surprise some unsuspecting external caller
which has carefully set up flat real mode by suddenly reducing the
segment limits to 64kB.

However, operating in flat real mode imposes a severe performance
penalty in some virtualisation environments, since some CPUs cannot
fully virtualise flat real mode and so the hypervisor must fall back
to emulation.  In particular, operating under KVM on a pre-Westmere
Intel CPU will be at least an order of magnitude slower, to the point
that there is a visible teletype effect when printing anything to the
BIOS console.  (Older versions of KVM used to cheat and ignore the
"flat" part of flat real mode, which masked the problem.)

Switch (back) to using genuine real mode with 64kB segment limits
instead of flat real mode.  Hopefully this won't break anything.

Add an explicit switch to flat real mode before returning to the BIOS
from the ROM prefix, since we know that a PMM BIOS will call the ROM
initialisation point (and potentially the BEV) in flat real mode.

As noted in previous commit messages, it is not possible to restore
the real-mode segment limits after a transition to protected mode,
since there is no way 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>
2014-04-28 01:21:08 +01:00
Michael Brown e5f6a9be38 [profile] Add generic profiling infrastructure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-27 23:14:43 +01:00
Michael Brown d36e814b8a [libc] Add flsll()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-27 16:56:09 +01:00
Michael Brown 082cedb3c3 [build] Fix __libgcc attribute for recent gcc versions
We observed some time ago (in commit 4ce8d61 "Import various libgcc
functions from syslinux") that gcc seems to treat calls to the
implicit arithmetic functions (e.g. __udivdi3()) as being affected by
-mregparm but unaffected by -mrtd.

This seems to be no longer the case with current gcc versions, which
treat calls to these functions as being affected by both -mregparm and
-mrtd, as expected.

There is nothing obvious in the gcc changelogs to indicate precisely
when this happened.  From experimentation with available gcc versions,
the change occurred sometime between v4.6.3 and v4.7.2.  We assume
that only versions up to v4.6.x require the special treatment.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-25 16:06:37 +01:00
Michael Brown dce7107fc0 [libc] Add inline assembly implementation of flsl() using BSR instruction
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-24 14:49:08 +01:00
Michael Brown c1595129b5 [bios] Fix screen clearing on even more buggy BIOSes
Some BIOSes (observed with a ProLiant DL360p Gen8 SE) perform no range
checking whatsoever on the parameters passed to INT10,06 and will
therefore happily write to an area beyond the end of video RAM.  The
area immediately following the video RAM tends to be the VGA BIOS ROM
image.  Overwriting the VGA BIOS leads to an interesting variety of
crashes and reboots.

Fix by specifying an exact width and height to be cleared, rather than
passing in large values and relying upon the BIOS to truncate them to
the appropriate range.

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

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-14 17:09:51 +00:00
Michael Brown f618178e60 [efi] Unload our own image before exiting UEFI application
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-14 16:20:55 +00:00
Michael Brown e662912c53 [efi] Avoid accidentally calling main() twice
EFIRC() uses PLATFORM_TO_ERRNO(), which evaluates its argument twice
(and can't trivially use a braced-group expression or an inline
function to avoid this, since it gets used outside of function
context).

The expression "EFIRC(main())" will therefore end up calling main()
twice, which is not the intended behaviour.  Every other instance of
EFIRC() is of the simple form "EFIRC(rc)", so fix by converting this
instance to match.

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

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-10 13:32:39 +00:00
Michael Brown 1137fa3268 [romprefix] Do not clobber stack segment when returning to BIOS
Commit c429bf0 ("[romprefix] Store boot bus:dev.fn address as autoboot
device location") introduced a regression by using register %cx to
temporarily hold the PCI bus:dev.fn address, despite the fact that %cx
was already being used to hold the stored BIOS stack segment.
Consequently, when returning to the BIOS after a failed or cancelled
boot attempt, iPXE would end up calling INT 18 with the stack segment
set equal to the PCI bus:dev.fn address.  Writing to essentially
random areas of memory tends to upset even the more robust BIOSes.

Fix by using register %ax to temporarily hold the PCI bus:dev.fn
address.

Reported-by: Anton D. Kachalov <mouse@yandex-team.ru>
Tested-by: Anton D. Kachalov <mouse@yandex-team.ru>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-05 12:32:00 +00:00
Michael Brown 0fac055119 [bzimage] Report exact initrd length via bzImage header
iPXE currently pads initrd images to a multiple of 4kB and inserts
zero padding between images, as required by some versions of the Linux
kernel.  The overall length reported via the ramdisk_size field in the
bzImage header includes this zero padding.

This causes problems when using memdisk to load a gzip-compressed disk
image.  memdisk treats the ramdisk_size field as containing the exact
length of the initrd image, and uses this length to locate the 8-byte
gzip footer.  This will generally cause memdisk to fail to decompress
the disk image.

Fix by reporting the exact length of the initrd image set, including
any padding inserted between images but excluding any padding added at
the end of the final image.

Reported-by: Levente LEVAI <levail@aviatronic.hu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-04 14:38:16 +00:00
Michael Brown ff1e7fc72b [prefix] Ignore PCI autoboot device location if set to 00:00.0
qemu can load an option ROM which is not associated with a particular
PCI device using the "-option-rom" syntax.  Under these circumstances,
we should ignore the PCI bus:dev.fn address that we expect to find in
%ax on entry to the initialisation vector.

Fix by using the PCI bus:dev.fn address only if it is non-zero.  Since
00:00.0 will always be the host bridge, it can never be the address of
a network card.

Reported-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-03 16:28:43 +00:00
Alex Williamson c429bf0aa2 [romprefix] Store boot bus:dev.fn address as autoboot device location
Per the BIOS Boot Specification, the initialization phase of the ROM
is called with the PFA (PCI Function Address) in the %ax register.
The intention is that the ROM code will store that device address
somewhere and use it for booting from that device when the Boot Entry
Vector (BEV) is called.  iPXE does store the PFA, but doesn't use it
to select the boot network device.  This renders BIOS IPL lists fairly
ineffective.

Fix by using the BBS-specified bus:dev.fn address as the autoboot
device location.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-03 15:35:08 +00:00
Alex Williamson 90fc273b2b [prefix] Allow prefix to specify a PCI autoboot device location
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-03 15:34:17 +00:00
Alex Williamson 27d1b40ee9 [romprefix] Allow ROM banner timeout to be configured independently
iPXE currently prints a "Press Ctrl-B" banner twice: once when the ROM
is first called for initialisation and again if we attempt to boot
from the ROM.  This slows boot, especially when the NIC is not the
primary boot device.  Tools such as libguestfs make use of QEMU VMs
for performing maintenance on disk images and may make use of NICs in
the VM for network support.  If iPXE introduces a static init-time
delay, that directly translates to increased runtime for the tools.

Fix by allowing the ROM banner timeout to be configured independently
of the main banner timeout.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-03 13:09:25 +00:00
Michael Brown 7667536527 [uri] Refactor URI parsing and formatting
Add support for parsing of URIs containing literal IPv6 addresses
(e.g. "http://[fe80::69ff:fe50:5845%25net0]/boot.ipxe").

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

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

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

Add self-tests for URI functions.

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

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-22 14:28:49 +00:00
Michael Brown 11ad25933f [vesafb] Allow for an arbitrary margin around the text area
Allow for an arbitrary margin to be specified in the console
configuration.  If the actual screen size does not match the requested
screen size, then update any margins specified so that they remain in
the same place relative to the requested screen size.  If margins are
unspecified (i.e. zero), then leave them as zero.

The underlying assumption here is that any specified margins are
likely to describe an area within a background picture, and so should
remain in the same place relative to that background picture.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-22 14:28:32 +00:00
Michael Brown 608d6cac9e [fbcon] Allow for an arbitrary margin around the text area
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-22 14:26:31 +00:00
Michael Brown b20fe32315 [vesafb] Handle failures from fbcon_init()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-22 14:16:30 +00:00
Michael Brown fffd98bd37 [uaccess] Add memcmp_user()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12 22:53:16 +01:00
Michael Brown 8f0173b5c8 [vesafb] Set "magic" colour to transparent when a background picture is used
Use the magic colour facility to cause the user interface background
to become transparent when we have a background picture.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-09 15:34:14 +00:00
Michael Brown 153748cce9 [lkrnprefix] Include iPXE version string in image header
Originally-implemented-by: Christian Hesse <list@eworm.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-06 20:11:36 +00:00
Michael Brown 54c5d08df1 [vesafb] Work around data corruption bug in bochs/qemu VBE implementation
The vgabios used by bochs and qemu (and other virtualisation products)
has a bug in its implementation of INT 10,4f00 which causes the high
16 bits of %ebx and %edx to become corrupted.

The vgabios code uses a "pushaw"/"popaw" pair to preserve the low 16
bits of all non-segment registers.  The vgabios code is compiled using
bcc, which generates 8086-compatible code and so never touches the
high 16 bits of the 32-bit registers.  However, the function
vbe_biosfn_return_controller_information() includes the line:

    size_64k = (Bit16u)((Bit32u)cur_info->info.XResolution *
				cur_info->info.XResolution *
				cur_info->info.BitsPerPixel) >> 19;

which generates an implicit call to the "lmulul" function.  This
function is implemented in vbe.c as:

    ; helper function for memory size calculation
    lmulul:
      and eax, #0x0000FFFF
      shl ebx, #16
      or  eax, ebx
      SEG SS
      mul eax, dword ptr [di]
      mov ebx, eax
      shr ebx, #16
      ret

which modifies %eax, %ebx, and %edx (as a result of the "mul"
instruction, which places its result into %edx:%eax).

Work around this problem by marking %ebx and %edx as being clobbered
by the call to INT 10,4f00.  (%eax is already used as an output
register, so does not need to be on the clobber list.)

Reported-by: Oliver Rath <rath@mglug.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-06 02:54:13 +00:00
Michael Brown b0942534eb [settings] Force settings into alphabetical order within sections
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 12:43:28 +00:00
Michael Brown 03957bcb47 [linux] Provide access to SMBIOS via /dev/mem
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 03:16:27 +00:00
Michael Brown 22001cb206 [settings] Explicitly separate the concept of a completed fetched setting
The fetch_setting() family of functions may currently modify the
definition of the specified setting (e.g. to add missing type
information).  Clean up this interface by requiring callers to provide
an explicit buffer to contain the completed definition of the fetched
setting, if required.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 00:37:02 +00:00
Michael Brown d4f7816de7 [vesafb] Select an optimal mode, rather than the first acceptable mode
There is no requirement for VBE modes to be listed in increasing order
of resolution.  With the present logic, this can cause e.g. a 1024x768
mode to be selected if the user asks for 640x480, if the 1024x768 mode
is earlier in the mode list.

Define a scoring system for modes as

  score = ( width * height - bpp )

and choose the mode with the lowest score among all acceptable modes.
This should prefer to choose the mode closest to the requested
resolution, with a slight preference for higher colour depths.

Reported-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 14:59:48 +00:00
Michael Brown 00bb19257f [vesafb] Return meaningful error when no suitable mode is found
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 12:12:05 +00:00
Michael Brown 405416e4c4 [vesafb] Skip modes for which we cannot get mode information
The VirtualBox BIOS fails to retrieve mode information (with status
0x0100) for some modes within the mode list.  Skip any such modes,
rather than treating this as a fatal error.

Reported-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 11:51:47 +00:00
Michael Brown 9678fedbe4 [vesafb] Include raw status value within VBE error messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 11:51:32 +00:00
Michael Brown aa2e04fe1c [vesafb] Add VESA frame buffer console
The VESA frame buffer console uses the VESA BIOS extensions (VBE) to
enumerate video modes, selects an appropriate mode, and then hands off
to the generic frame buffer code.

The font is extracted from the VGA BIOS, avoiding the need to provide
an external font file.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 05:55:45 +00:00
Michael Brown c501c980e0 [console] Add concept of generic console configuration
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 05:55:43 +00:00
Michael Brown b2251743d8 [console] Allow console input and output to be disabled independently
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 05:54:53 +00:00
Michael Brown 02a63c6dec [console] Pass escape sequence context to ANSI escape sequence handlers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:50 +00:00
Christian Hesse 3f9a482b88 [build] Update build system for Syslinux 6.x
Syslinux 6.x places its files into a bios subdirectory, and requires
that a ldlinux.c32 module be included within the ISO image.  Add the
relevant search paths for isolinux.bin, and include the file
ldlinux.c32 within the ISO image if it exists.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-15 11:59:44 +00:00
Michael Brown c3d1e78697 [pxe] Ensure cached DHCPACK is retrieved prior to network device creation
The retrieval of the cached DHCPACK and the creation of network
devices are both currently scheduled as STARTUP_NORMAL.  It is
therefore possible that the cached DHCPACK will not be retrieved in
time for cachedhcp_probe() to apply it to the relevant network device.

Fix by retrieving the cached DHCPACK at initialisation time rather
than at startup time.

As an optimisation, an unclaimed cached DHCPACK can be freed
immediately after the last network device has been created, rather
than waiting until shutdown.

Reported-by: Espen Braastad <espen.braastad@redpill-linpro.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-08 12:45:22 +00:00
Michael Brown 43eba2f555 [cmdline] Generate command option help text automatically
Generate the command option help text automatically from the list of
defined options.

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-05 17:15:24 +00:00
Michael Brown 5c11ff6304 [netdevice] Make all net_driver methods optional
Most network upper-layer drivers do not implement all three methods
(probe, notify, and remove).  Save code by making all methods
optional.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-01 02:26:44 +00:00
Michael Brown 10d19bd2ac [pxe] Always retrieve cached DHCPACK and apply to relevant network device
When chainloading, always retrieve the cached DHCPACK packet from the
underlying PXE stack, and apply it as the original contents of the
"net<X>.dhcp" settings block.  This allows cached DHCP settings to be
used for any chainloaded iPXE binary (not just undionly.kkpxe).

This change eliminates the undocumented "use-cached" setting.  Issuing
the "dhcp" command will now always result in a fresh DHCP request.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-10-25 17:29:25 +01:00
Michael Brown cba22d36b7 [build] Work around bug in gcc >= 4.8
Commit 238050d ("[build] Work around bug in gcc >= 4.8") works around
one instance of a bug in recent versions of gcc, in which "ebp" cannot
be specified within an asm clobber list.

Some versions of gcc seem to exhibit the same bug on other points in
the codebase.  Fix by changing all instances of "ebp" in a clobber
list to use the push/pop %ebp workaround instead.

Originally-implemented-by: Víctor Román Archidona <contacto@victor-roman.es>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-09-25 12:55:46 +01:00
Michael Brown 55201e2d0e [settings] Expose CPUID instruction via settings mechanism
Allow CPUID values to be read using the syntax

  ${cpuid/<register>.<function>}

For example, ${cpuid/2.0x80000001} will give the value of %ecx after
calling CPUID with %eax=0x80000001.  Values for <register> are encoded
as %eax=0, %ebx=1, %ecx=2, %edx=3.

The numeric encoding is more sophisticated than described above,
allowing for settings such as the CPU model (obtained by calling CPUID
with %eax=0x80000002-0x80000004 inclusive and concatenating the values
returned in %eax:%ebx:%ecx:%edx).  See the source code for details.

The "cpuvendor" and "cpumodel" settings provide easy access to these
more complex CPUID settings.

This functionality is intended to complement the "cpuid" command,
which allows for testing individual CPUID feature bits.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-08-07 12:06:28 +01:00
Michael Brown c70d4cb1b3 [settings] Introduce the generalised concept of a numeric setting
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-08-01 14:39:58 +01:00
Michael Brown 063645118c [settings] Clarify usage of the term "named setting"
There are currently two conflicting usages of the term "named setting"
within iPXE: one refers to predefined settings (such as show up in the
"config" UI), the other refers to settings identified by a name (such
as "net0.dhcp/ip").

Split these usages into the term "predefined setting" and "named
setting" to avoid ambiguity.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-18 15:50:02 +01:00
Michael Brown ca319873bf [build] Fix %.licence build target
Our use of --gc-sections causes the linker to discard the symbols
defined by FILE_LICENCE(), meaning that the resulting licence
determination is incomplete.

We must use the KEEP() directive in the linker script to force the
linker to not discard the licence symbols.  Using KEEP(*(COMMON))
would be undesirable, since there are some symbols in COMMON which we
may wish to discard.

Fix by placing symbols defined by PROVIDE_SYMBOL() (which is used by
FILE_LICENCE()) into a special ".provided" section, which we then mark
with KEEP().  All such symbols are zero-length, so there is no cost in
terms of the final binary size.

Since the symbols are no longer in COMMON, the linker will reject
symbols with the same name coming from multiple objects.  We therefore
append the object name to the licence symbol, to ensure that it is
unique.

Reported-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-16 00:50:54 +02:00
Marin Hannache c0af8c0433 [cmdline] Add "poweroff" command
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-15 13:49:48 +02:00
Marin Hannache 397d4ec3c8 [legal] Add FILE_LICENCE for valgrind headers
Signed-off-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-14 23:37:24 +02:00
Michael Brown d8392851d2 [linux] Add support for accessing PCI configuration space via /proc/bus/pci
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-13 12:44:45 +02:00
Michael Brown 238050dfd4 [build] Work around bug in gcc >= 4.8
gcc 4.8 and 4.9 fail to compile pxe_call.c with the error "bp cannot
be used in asm here".  Other points in the codebase which use "ebp" in
the asm clobber list do not seem to be affected.

Unfortunately gcc provides no way to specify %ebp as an output
register, so we cannot use this as a workaround.  The only viable
solution is to explicitly push/pop %ebp within the asm itself.  This
is ugly for two reasons: firstly, it may be unnecessary; secondly, it
may cause gcc to generate invalid %esp-relative addresses if the asm
happens to use memory operands.  This specific block of asm uses no
memory operands and so will not generate invalid code.

Reported-by: Daniel P. Berrange <berrange@redhat.com>
Reported-by: Christian Hesse <list@eworm.de>
Originally-fixed-by: Christian Hesse <list@eworm.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-06-07 13:59:58 +01:00
Michael Brown e3dd10edc4 [bzimage] Fix spurious uninitialised-variable warning on some gcc versions
Reported-by: Matthew Helton <mwhelton@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-06-05 15:56:23 +01:00
Michael Brown c825a9b39d [bzimage] Align initrd images to page boundary
Some versions of Linux apparently complain if initrds are not aligned
to a page boundary.  Fix by changing INITRD_ALIGN from 4 bytes to 4096
bytes.

The amount of padding at the end of each initrd will now often be
sufficient to allow the cpio header to be prepended without crossing
an alignment boundary.  The final location of the initrd may therefore
end up being slightly higher than the post-shuffle location.
bzimage_load_initrd() must therefore now copy the initrd body prior to
copying the cpio header, otherwise the start of the initrd body may be
overwritten by the cpio header.  (Note that the guarantee that an
initrd will never need to overwrite an initrd at a higher location
still holds, since the overall length of each initrd cannot decrease
as a result of adding a cpio header.)

Reported-by: Dave Hansen <dave@sr71.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-06-05 14:11:43 +01:00
Michael Brown dbea47ce7d [build] Add efidrv.cab target for UEFI Secure Boot signing
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-05-14 20:46:53 +01:00
Michael Brown 640ab792a4 [build] Provide "allXXXs" targets for all media on all platforms
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-05-14 16:18:44 +01:00
Frediano Ziglio 9df238a8aa [romprefix] Fix incorrect pointer offset in undiloader.S
Commit 2422647 ("[prefix] Allow prefix to specify an arbitrary maximum
address for relocation") introduced a regression into the UNDI ROM
loader by preserving an extra register on the stack without modifying
the %sp-relative addresses used in the routine.

Fix by correcting the %sp-relative addresses to allow for the extra
preserved variable.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-05-14 14:51:19 +01:00
Michael Brown 05d11b7337 [build] Use $(eval) if available
When the $(eval) function is available (in GNU make >= 3.80), we can
evaluate many of the dynamically-generated Makefile rules directly.
This avoids generating a few hundred Makefile fragments in the
filesystem, and so speeds up the build process.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-05-14 14:28:30 +01:00
Michael Brown 15d2f947f5 [settings] Eliminate settings "tag magic"
Create an explicit concept of "settings scope" and eliminate the magic
values used for numerical setting tags.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-05-01 19:52:12 +01:00
Michael Brown c6375a85be [romprefix] Report failure cause when unable to open payload
Report the cause of the failure when we are unable to open the .mrom
payload.  There are two possible failure cases:

 - Unable to find a suitable memory BAR to borrow (e.g. if the NIC
   doesn't have a memory BAR that is at least as large as the
   expansion ROM BAR, or if the memory BAR has been assigned a 64-bit
   address which won't fit into the 32-bit expansion ROM BAR).  This
   will be reported as "BABABABA".

 - Unable to find correct ROM image within the BAR.  This will be
   reported as the address (within the borrowed BAR) at which we first
   fail to find a valid 55AA signature.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-30 14:56:19 +01:00
Michael Brown e411b37eb1 [pxe] Convert external PXE API errors into iPXE platform-generated errors
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-29 19:58:25 +01:00
Michael Brown 54409583e2 [efi] Perform meaningful error code conversions
Exploit the redefinition of iPXE error codes to include a "platform
error code" to allow for meaningful conversion of EFI_STATUS values to
iPXE errors and vice versa.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-19 13:34:19 +01:00
Michael Brown 7348035231 [libc] Redefine low 8 bits of error code as "platform error code"
The low 8 bits of an iPXE error code are currently defined as the
closest equivalent PXE error code.  Generalise this scheme to
platforms other than PC-BIOS by extending this definition to "closest
equivalent platform error code".  This allows for the possibility of
returning meaningful errors via EFI APIs.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-19 13:34:13 +01:00
Michael Brown 9909e7b10a [bios] Fix screen clearing on buggy BIOSes
The implementation of INT 10,06 on some BIOSes (observed with both
Hyper-V and a Dell OptiPlex 7010) seems to treat %dx=0xffff as a
special value meaning "do absolutely nothing".  Fix by using
%dx=0xfefe, which should still be sufficient to cover any realistic
screen size.

Reported-by: John Clark <skyman@iastate.edu>
Tested-by: John Clark <skyman@iastate.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-17 19:36:03 +01:00
Michael Brown e68a6ca225 [cmdline] Add ability to perform a warm reboot
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-22 13:54:44 +00:00
Michael Brown 71cd508838 [efi] Add "reboot" command for EFI
Abstract out the ability to reboot the system to a separate reboot()
function (with platform-specific implementations), add an EFI
implementation, and make the existing "reboot" command available under
EFI.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-22 13:44:02 +00:00
Bo Yang 11ad0bafbf [build] Avoid strict-aliasing warning for gcc 4.3
Signed-off-by: Bo Yang <boyang@suse.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-21 13:54:44 +00:00
Michael Brown 4f742bcd95 [smbios] Provide SMBIOS version number via smbios_version()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-20 00:12:30 +00:00
Michael Brown 2ec0c1ea48 [int13] Split out ISO9660 and El Torito definitions to separate header files
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-19 23:21:15 +00:00
Michael Brown 747e9eb6f3 [lkrnprefix] Allow relocation when no initrd is present
Commit 2629b7e ("[pcbios] Inhibit all calls to INT 15,e820 and INT
15,e801 during POST") introduced a regression into .lkrn images when
used with no corresponding initrd.

Specifically, the semantics of the "maximum address for relocation"
value passed to install_prealloc() in %ebp changed so that zero became
a special value meaning "inhibit use of INT 15,e820 and INT 15,e801".
The %ebp value meaing "no upper limit on relocation" was changed from
zero to 0xffffffff, and all prefixes providing fixed values for %ebp
were updated to match the new semantics.

The .lkrn prefix provides the initrd base address as the maximum
address for relocation.  When no initrd is present, this address will
be zero, and so will unintentionally trigger the "inhibit INT 15,e820
and INT 15,e801" behaviour.

Fix by explicitly setting %ebp to 0xffffffff if no initrd is present
before calling install_prealloc().

Reported-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk>
Tested-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-15 15:34:50 +00:00
Michael Brown cb37d92ff6 [romprefix] Display only one "Ctrl-B" prompt per PCI device during POST
If a multifunction PCI device exposes an iPXE ROM via each function,
then each function will display a "Press Ctrl-B to configure iPXE"
prompt, and delay for two seconds.  Since a single instance of iPXE
can drive all functions on the multifunction device, this simply adds
unnecessary delay to the boot process.

Fix by inhibiting the "Press Ctrl-B" prompt for all except the first
function on a PCI device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-11 01:48:00 +00:00
Michael Brown 2629b7e2cd [pcbios] Inhibit all calls to INT 15,e820 and INT 15,e801 during POST
Many BIOSes do not construct the full system memory map until after
calling the option ROM initialisation entry points.  For several
years, we have added sanity checks and workarounds to accommodate
charming quirks such as BIOSes which report the entire 32-bit address
space (including all memory-mapped PCI BARs) as being usable RAM.

The IBM x3650 takes quirky behaviour to a new extreme.  Calling either
INT 15,e820 or INT 15,e801 during POST doesn't just get you invalid
data.  We could cope with invalid data.  Instead, these nominally
read-only API calls manage to trash some internal BIOS state, with the
result that the system memory map is _never_ constructed.  This tends
to confuse subsequent bootloaders and operating systems.

[ GRUB 0.97 fails in a particularly amusing way.  Someone thought it
would be a good idea for memcpy() to check that the destination memory
region is a valid part of the system memory map; if not, then memcpy()
will sulk, fail, and return NULL.  This breaks pretty much every use
of memcpy() including, for example, those inserted implicitly by gcc
to copy non-const initialisers.  Debugging is _fun_ when a simple call
to printf() manages to create an infinite recursion, exhaust the
available stack space, and shut down the CPU. ]

Fix by completely inhibiting calls to INT 15,e820 and INT 15,e801
during POST.

We do now allow relocation during POST up to the maximum address
returned by INT 15,88 (which seems so far to always be safe).  This
allows us to continue to have a reasonable size of external heap, even
if the PMM allocation is close to the 1MB mark.

The downside of allowing relocation during POST is that we may
overwrite PMM-allocated memory in use by other option ROMs.  However,
the downside of inhibiting relocation, when combined with also
inhibiting calls to INT 15,e820 and INT 15,e801, would be that we
might have no external heap available: this would make booting an OS
impossible and could prevent some devices from even completing
initialisation.

On balance, the lesser evil is probably to allow relocation during
POST (up to the limit provided by INT 15,88).  Entering iPXE during
POST is a rare operation; on the even rarer systems where doing so
happens to overwrite a PMM-allocated region, then there exists a
fairly simple workaround: if the user enters iPXE during POST and
wishes to exit iPXE, then the user must reboot.  This is an acceptable
cost, given the rarity of the situation and the simplicity of the
workaround.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-11 01:20:01 +00:00
Michael Brown 0d4a760ffc [prefix] Use %cs as implicit parameter to uninstall()
romprefix.S currently calls uninstall() with an invalid value in %ax.
Consequently, base memory is not freed after a ROM boot attempt (or
after entering iPXE during POST).

The uninstall() function is physically present in .text16, and so can
use %cs to determine the .text16 segment address.  The .data16 segment
address is not required, since uninstall() is called only by code
paths which set up .data16 to immediately follow .text16.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-08 17:42:24 +00:00
Michael Brown c7694acb51 [nbiprefix] Set up real-mode stack before jumping to .text16
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-08 17:41:51 +00:00
Michael Brown b33082a52b [pcbios] Add extra debugging messages when unhiding iPXE from memory
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-08 17:40:46 +00:00
Michael Brown 02b914e812 [tftp] Allow TFTP block size to be controlled via the PXE TFTP API
The PXE TFTP API allows the caller to request a particular TFTP block
size.  Since mid-2008, iPXE has appended a "?blksize=xxx" parameter to
the TFTP URI constructed internally; nothing has ever parsed this
parameter.  Nobody seems to have cared that this parameter has been
ignored for almost five years.

Fix by using xfer_window(), which provides a fairly natural way to
convey the block size information from the PXE TFTP API to the TFTP
protocol layer.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-06 17:35:30 +00:00
Michael Brown 9373ca8ea2 [undi] Work around specific devices with known broken interrupt behaviour
Some PXE stacks are known to claim that IRQs are supported, but then
never generate interrupts.  No satisfactory solution has been found to
this problem; the workaround is to add the PCI vendor and device IDs
to a list of devices which will be treated as simply not supporting
interrupts.

This is something of a hack, since it will generate false positives
for identical devices with a working PXE stack (e.g. those that have
been reflashed with iPXE), but it's an improvement on the current
situation.

Reported-by: Richard Moore <rich@richud.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-05 14:22:53 +00:00
Michael Brown d6b0b76a05 [bzimage] Allow initrds to be rearranged in place
At present, loading a bzImage via iPXE requires enough RAM to hold two
copies of each initrd file.  Remove this constraint by rearranging the
initrds in place.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-12 23:10:45 +00:00
Michael Brown 4ca98693b9 [initrd] Add ability to reshuffle initrds into image list order
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-12 21:56:20 +00:00
Michael Brown 603455bb06 [libc] Relicense x86 string.h
No code from the original source remains within this file; relicense
under GPL2+ with a new copyright notice.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-12 16:58:49 +00:00
Michael Brown 53f3deee06 [libc] Fix and externalise memswap()
Make memswap() behave correctly if called with a length of zero.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-12 16:58:49 +00:00
Michael Brown de20c526e6 [libc] Reduce overall code size by externalising strlen()
Typical saving is 5-20 bytes in each file using strlen().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-12 16:58:49 +00:00
Michael Brown 06766875ad [libc] Reduce overall code size by externalising strncmp()
Typical saving is 20-30 bytes in each file using strncmp().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-12 16:58:49 +00:00
Michael Brown f8ece72fc9 [libc] Remove unnecessary "cld" instruction from memset()
Saving is one byte per call to memset().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-12 16:58:49 +00:00
Michael Brown 61c6af3f0b [libc] Convert memcpy() from a macro to an inline function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-12 16:58:49 +00:00
Michael Brown fc30b13b25 [libc] Reduce overall code size by externalising memmove()
Typical saving is 15-20 bytes in each file using memmove().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-12 16:58:49 +00:00
Michael Brown 7cbac68593 [libc] Remove obsolete implementation of memcpy()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-12 16:58:49 +00:00
Michael Brown fd141fb669 [umalloc] Split largest_memblock() function out from init_eheap()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-06 17:44:40 +00:00
Michael Brown 1494d41d0a [uaccess] Add userptr_sub() to find the difference between two user pointers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-05 16:15:14 +00:00
Michael Brown 4867085c0c [build] Include version number within only a single object file
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-02 14:46:39 +00:00
Michael Brown f008698c68 [build] Use -maccumulate-outgoing-args if required by gcc
Current versions of gcc require -maccumulate-outgoing-args if any
sysv_abi functions call ms_abi functions.  This requirement is likely
to be lifted in future gcc versions, so test explicitly to see if the
current version of gcc requires -maccumulate-outgoing-args.

This problem is currently masked since the implied
-fasynchronous-unwind-tables (which is the default in current gcc
versions) implies -maccumulate-outgoing-args.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-02 13:41:44 +00:00
Michael Brown fcdfe81764 [int13] Do not zero %edx when jumping to a boot sector
Commit 73eb3f1 ("[int13] Zero all possible registers when jumping to a
boot sector") introduced a regression preventing the SAN-booting of
boot sectors which rely upon %dl containing the correct drive number
(such as most CD-ROM boot sectors).

Fix by not zeroing %edx.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-05 15:04:27 +01:00
Michael Brown 73eb3f17db [int13] Zero all possible registers when jumping to a boot sector
At least one boot sector (the DUET boot sector used for bootstrapping
EFI from a non-EFI system) fails to initialise the high words of
registers before using them in calculations, leading to undefined
behaviour.

Work around such broken boot sectors by explicitly zeroing the
contents of all registers apart from %cs:%ip and %ss:%sp.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-09-14 15:42:54 +01:00
Michael Brown 8509dbf86a [int13] Use correct size when estimating floppy disk geometry
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-09-14 15:04:53 +01:00
Michael Brown 117fc61738 [console] Add support for the bochs/qemu debug port console
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-09-10 15:58:02 +01:00
Michael Brown e6427b7ee1 [sdi] Add support for SDI images
Add support (disabled by default) for booting .sdi images as used by
Windows XP Embedded.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-09-05 14:11:01 +01:00
Michael Brown 03f0c23f8b [ipoib] Expose Ethernet-compatible eIPoIB link-layer addresses and headers
Almost all clients of the raw-packet interfaces (UNDI and SNP) can
handle only Ethernet link layers.  Expose an Ethernet-compatible link
layer to local clients, while remaining compatible with IPoIB on the
wire.  This requires manipulation of ARP (but not DHCP) packets within
the IPoIB driver.

This is ugly, but it's the only viable way to allow IPoIB devices to
be driven via the raw-packet interfaces.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-31 21:22:59 +01:00
Michael Brown d0bd383463 [comboot] Accept only ".cbt" as an extension for COMBOOT images
COMBOOT images are detected by looking for a ".com" or ".cbt" filename
extension.  There are widely-used files with a ".com" extension, such
as "wdsnbp.com", which are PXE images rather than COMBOOT images.

Avoid false detection of PXE images as COMBOOT images by accepting
only a ".cbt" extension as indicating a COMBOOT image.

Interestingly, this bug has been present for a long time but was
frequently concealed because the filename was truncated to fit the
fixed-length "name" field in struct image.  (PXE binaries ending in
".com" tend to be related to Windows deployment products and so often
use pathnames including backslashes, which iPXE doesn't recognise as a
path separator and so treats as part of a very long filename.)

Commit 1c127a6 ("[image] Simplify image management commands and
internal API") made the image name a variable-length field, and so
exposed this flaw in the COMBOOT image detection algorithm.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-13 22:14:57 +01:00
Michael Brown d97c6a321e [bzimage] Allow file mode to be specified for standalone initrd files
Allow the file mode to be specified using a "mode=" command line
parameter.  For example:

  initrd http://web/boot/bootlocal.sh /opt/bootlocal.sh mode=755

Requested-by: Bryce Zimmerman <bryce.zimmerman@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-03 02:29:34 +01:00
Michael Brown 1f88e9c8ea [romprefix] Round up PMM allocation sizes to nearest 4kB
Some AMI BIOSes apparently break in exciting ways when asked for PMM
allocations for sizes that are not multiples of 4kB.

Fix by rounding up the image source area to the nearest 4kB.  (The
temporary decompression area is already rounded up to the nearest
128kB, to facilitate sharing between multiple iPXE ROMs.)

Reported-by: Itay Gazit <itayg@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-25 14:37:43 +01:00
Joshua Oreman fb7c022c2c [tcpip] Fix building under Cygwin
Cygwin's assembler treats '/' as a comment character.

Reported-by: Steve Goodrich <steve.goodrich@se-eng.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-23 23:20:56 +01:00
Thomas Miletich c70586f6e9 [build] Fix building under OpenBSD
Similarly to FreeBSD, OpenBSD requires the object format to be
specified as elf_i386_obsd rather than elf_i386.

Reported-by: Jiri B <jirib@devio.us>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-23 23:04:17 +01:00
Thomas Miletich acd74089f5 [vmware] Fix compilation under OpenBSD
Reported-by: Jiri B <jirib@devio.us>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-23 22:53:13 +01:00
Michael Brown 5de45cd3da [romprefix] Report a pessimistic runtime size estimate
PCI3.0 allows us to report a "runtime size" which can be smaller than
the actual ROM size.  On systems that support PMM our runtime size
will be small (~2.5kB), which helps to conserve the limited option ROM
space.  However, there is no guarantee that the PMM allocation will
succeed, and so we need to report the worst-case runtime size in the
PCI header.

Move the "shrunk ROM size" field from the PCI header to a new "iPXE
ROM header", allowing it to be accessed by ROM-manipulation utilities
such as disrom.pl.

Reported-by: Anton D. Kachalov <mouse@yandex-team.ru>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-23 17:57:40 +01:00
Michael Brown c3b4860ce3 [legal] Update FSF mailing address in GPL licence texts
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-20 19:55:45 +01:00
Michael Brown 9200049c80 [pxeprefix] Ignore errors from PXENV_FILE_CMDLINE
PXENV_FILE_CMDLINE is an iPXE extension, and will not be supported by
most PXE stacks.  Do not report any errors to the user, since in
almost all cases the error will mean simply "not loaded by iPXE".

Reported-by: Patrick Domack <patrickdk@patrickdk.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-18 18:19:25 +01:00
Michael Brown 4dc3f8141f [ioapi] Generalise i386 raw I/O API to x86
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-17 21:22:02 +01:00
Michael Brown 88016deccf [pxe] Reopen network device if NBP exits
Attempt to restore the network device to the state it was in prior to
calling the NBP.  This simplifies the task of taking follow-up action
in an iPXE script.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-12 16:06:05 +01:00
Michael Brown e84e19d4ed [pxeprefix] Fetch command line (if any) via PXENV_FILE_CMDLINE
Use PXENV_FILE_CMDLINE to retrieve the command line (if any) provided
by the invoking PXE stack.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-11 21:26:53 +01:00
Michael Brown a814eff38e [pxe] Add PXENV_FILE_CMDLINE API call
Allow a PXE NBP to obtain its command line (if any) via the new PXE
API call PXENV_FILE_CMDLINE.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-11 18:16:13 +01:00
Michael Brown 9e5152e095 [pxeprefix] Place temporary stack after iPXE binary
Some BIOSes (observed on a Supermicro system with an AMI BIOS) seem to
use the area immediately below 0x7c00 to store data related to the
boot process.  This data is currently liable to be overwritten by the
temporary stack used while decompressing and installing iPXE.

Try to avoid any such problems by placing the temporary stack
immediately after the loaded iPXE binary.  Any memory used by the
stack could then potentially have been overwritten anyway by a larger
binary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-10 16:10:49 +01:00
Michael Brown 2c72ce04ae [bzimage] Update setup_move_size only for protocol versions 2.00 and 2.01
The setup_move_size field is not defined in protocol versions earlier
than 2.00 (and is obsolete in versions later than 2.01).  In binaries
using versions earlier than 2.00, the relevant location is likely to
contain executable code.

Interestingly, this bug has been present since support for pre-2.00
protocol versions was added in 2009, and has been unexpectedly
modifying the memtest86+ code fragment:

	mov	$0x92, %dx
	inb	%dx, %al

Fortuitously, the modification exactly overwrote the value loaded into
%dx, and so the net effect was limited to causing Fast Gate A20
detection to always fail.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-09 20:32:34 +01:00
Michael Brown 76d9c1a001 [undi] Align the received frame payload for faster processing
The undinet driver always has to make a copy of the received frame
into an I/O buffer.  Align this copy sensibly so that subsequent
operations are as fast as possible.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-29 01:06:00 +01:00
Michael Brown ec22e08db1 [tcpip] Add faster algorithm for calculating the TCP/IP checksum
The generic TCP/IP checksum implementation requires approximately 10
CPU clocks per byte (as measured using the TSC).  Improve this to
approximately 0.5 CPU clocks per byte by using "lodsl ; adcl" in an
unrolled loop.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-28 16:02:31 +01:00
Michael Brown 1d77d03216 [tcpip] Allow for architecture-specific TCP/IP checksum routines
Calculating the TCP/IP checksum on received packets accounts for a
substantial fraction of the response latency.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-27 19:15:17 +01:00
Michael Brown 6a4ff519c8 [libc] Simplify memcpy() implementation
The "rep" prefix can be used with an iteration count of zero, which
allows the variable-length memcpy() to be implemented without using
any conditional jumps.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-27 19:15:17 +01:00
Michael Brown b9ef880c8d [romprefix] Treat 0xffffffff as an error return from PMM
PMM defines the return code 0xffffffff as meaning "unsupported
function".  It's hard to imagine a PMM BIOS that doesn't support
pmmAllocate(), but apparently such things do exist.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-19 19:35:48 +01:00
Michael Brown b58374fe91 [romprefix] Allow .mrom image to be placed anywhere within the BAR
A .mrom image currently assumes that it is the first image within the
expansion ROM BAR, which may not be correct when multiple images are
present.

Fix by scanning through the BAR until we locate an image matching our
build ID.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-12 15:15:06 +01:00
Michael Brown 9e8d431a0d [romprefix] Add a dummy ROM header to cover the .mrom payload
The header of a .mrom image declares its length to be only a few
kilobytes; the remainder is accessed via a sideband mechanism.  This
makes it difficult to append an additional ROM image, such as an EFI
ROM.

Add a second, dummy ROM header covering the payload portion of the
.mrom image, allowing consumers to locate any appended ROM images in
the usual way.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-12 15:15:03 +01:00
Michael Brown cdee7866f5 [cmdline] Use "cpuid --ext" instead of "cpuid --amd"
Avoid potential confusion in the documentation by using a
vendor-neutral name for the extended (AMD-defined) feature set.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-12 11:33:43 +01:00
Michael Brown 591541af66 [cmdline] Add "cpuid" command
Allow x86 CPU feature flags (such as support for 64-bit mode) to be
checked using the "cpuid" command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-07 00:37:04 +01:00
Michael Brown 734de43585 [build] Merge i386 and x86_64 versions of errfile.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-06 15:21:34 +01:00
Marin Hannache 7865ae0dea [image] Remove non-working image loaders
The WinCE, a.out and FreeBSD loaders are designed to be #included by
core/loader.c, which no longer exists.  These old loaders are not
usable anymore and cause compilation failures when enabled in
config/general.h.

Signed-off-by: Marin Hannache <mareo@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-24 11:39:55 +01:00
Michael Brown 62eb2294f0 [multiboot] Place multiboot modules low in memory
Solaris assumes that there is enough space above the Multiboot modules
to use as a decompression and scratch area.  This assumption is
invalid when using iPXE, which places the Multiboot modules near the
top of (32-bit) memory.

Fix by copying the modules to an area of memory immediately following
the loaded kernel.

Debugged-by: Michael Brown <mcb30@ipxe.org>
Debugged-by: Scott McWhirter <scottm@joyent.com>
Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-19 13:13:32 +01:00
Michael Brown a9cf527641 [vmware] Allow settings to be specified in the VMware .vmx file
Allow iPXE settings to be specified in the .vmx file via the VMware
GuestInfo mechanism.  For example:

    guestinfo.ipxe.filename = "http://boot.ipxe.org/demo/boot.php"
    guestinfo.ipxe.dns = "192.168.0.1"
    guestinfo.ipxe.net0.ip = "192.168.0.15"
    guestinfo.ipxe.net0.netmask = "255.255.255.0"
    guestinfo.ipxe.net0.gateway = "192.168.0.1"

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-17 17:47:33 +01:00
Michael Brown 1d33649516 [libc] Allow strtoul() to interpret negative numbers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-17 10:42:08 +01:00
Michael Brown d11b82f0e4 [multiboot] Include full image URI in command line
Solaris kernels seem to rely on having the full kernel path present in
the multiboot command line; if only the kernel name is present then
the boot fails with the error message

  krtld: failed to open 'unix'

Debugged-by: Michael Brown <mcb30@ipxe.org>
Debugged-by: Scott McWhirter <scottm@joyent.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-15 00:38:43 +01:00
Marin Mareo Hannache cc288dc0f8 [linux] Fix a build error on some platforms
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-10 20:32:56 +01:00
Michael Brown 3c13d68f50 [int13] Fix compilation on some versions of gcc
Using __from_text16() and __from_data16() in inline asm constraints
sometimes defeats gcc's ability to simplify expressions down to
compile-time constants.

Reported-by: Jason Kohles <jkohles@palantir.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-10 13:00:46 +01:00
Michael Brown 4dbb193c33 [int13] Add support for emulating floppy disk drives
Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-30 17:32:32 +01:00
Michael Brown 0b445275c4 [bios] Recognise Page Up and Page Down keys
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-29 13:05:49 +01:00
Michael Brown 82ecaaac91 [console] Remove "log message" usage from interactive console defaults
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-27 00:51:50 +01:00
Michael Brown 2834f9f6de [umalloc] Unhide umalloc()ed memory region when there are no allocations
At present, we always hide an extra sizeof(struct external_memory), to
account for the header on the lowest allocated block.  This header
ceases to exist when there are no allocated blocks remaining.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-27 00:31:01 +01:00
Michael Brown 920799a0ba [umalloc] Fail allocations when we run out of external memory
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-27 00:30:54 +01:00
Michael Brown c2875ae329 [console] Do not share ANSI escape context between lineconsole users
An ANSI escape sequence context cannot be shared between multiple
users.  Make the ANSI escape sequence context part of the line console
definition and provide individual contexts for each user.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-26 21:58:50 +01:00
Michael Brown 64d17dbd50 [console] Exclude text-based UI output from logfile-based consoles
The output from text-based user interfaces such as the "config"
command is not generally meaningful for logfile-based consoles such as
syslog and vmconsole.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-26 19:02:30 +01:00
Michael Brown e024cd39a8 [console] Allow usage to be defined independently for each console
Add the concept of a "console usage", such as "standard output" or
"debug messages".  Allow usages to be associated with each console
independently.  For example, to send debugging output via the serial
port, while preventing it from appearing on the local console:

  #define CONSOLE_SERIAL CONSOLE_USAGE_ALL
  #define CONSOLE_PCBIOS ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_DEBUG )

If no usages are explicitly specified, then a default set of usages
will be applied.  For example:

  #define CONSOLE_SERIAL

will have the same affect as

  #define CONSOLE_SERIAL CONSOLE_USAGE_ALL

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-26 17:40:01 +01:00
Michael Brown 1c127a6962 [image] Simplify image management commands and internal API
Remove the name, cmdline, and action parameters from imgdownload() and
imgdownload_string().  These functions now simply download and return
an image.

Add the function imgacquire(), which will interpret a "name or URI
string" parameter and return either an existing image or a newly
downloaded image.

Use imgacquire() to merge similar image-management commands that
currently differ only by whether they take the name of an existing
image or the URI of a new image to download.  For example, "chain" and
"imgexec" can now be merged.

Extend imgstat and imgfree commands to take an optional list of
images.

Remove the arbitrary restriction on the length of image names.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-24 23:12:04 +00:00
Michael Brown 4766b1455f [build] Fix compilation under Cygwin
Originally-fixed-by: Steve Goodrich <steve.goodrich@se-eng.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-22 23:52:24 +00:00
Michael Brown efb0c7fce4 [bios] Set character attributes only when necessary
There is no INT 10 call for "display character with attribute,
advancing the cursor and scrolling the screen as necessary".  We
therefore make two INT 10 calls: INT 10,09 to write the character with
its attribute at the current cursor position, and then INT 10,0e to
(re)write the character (leaving the attribute unchanged), advance the
cursor position and scroll as necessary.

This confuses the serial-over-LAN console redirection feature provided
by some BIOSes.

Fix by performing the INT10,09 only when necessary to change the
existing attribute.

Reported-by: Itay Gazit <itaygazit@gmail.com>
Tested-by: Itay Gazit <itaygazit@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-22 12:30:47 +00:00
Michael Brown 12002d6955 [time] Add RTC-based time source
Add a time source using the CMOS RTC to obtain the current time.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-19 22:13:32 +00:00
Michael Brown 846bde90e6 [time] Define an API for getting the current time
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-19 22:13:27 +00:00
Michael Brown 0b2c7885c7 [crypto] Use correct constraint for byte-addressable register
Reported-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-19 17:22:52 +00:00
Michael Brown 196f0bb081 [rng] Allow entropy_enable() to return an error
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-18 17:05:37 +00:00
Michael Brown 071184a6e4 [crypto] Add big-integer library for RSA calculations
RSA requires modular exponentiation using arbitrarily large integers.
Given the sizes of the modulus and exponent, all required calculations
can be done without any further dynamic storage allocation.  The x86
architecture allows for efficient large integer support via inline
assembly using the instructions that take advantage of the carry flag
(e.g. "adcl", "rcrl").

This implemention is approximately 80% smaller than the (more generic)
AXTLS implementation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-13 23:27:30 +00:00
Michael Brown b4bb39909e [prefix] Eliminate uninitialised variable
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-09 17:09:26 +00:00
Michael Brown 3b689e531d [x86_64] Use memory address constraint in __bswap_16s()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-04 21:46:45 +00:00
Michael Brown 732bea2f88 [i386] Use memory address constraints in __bswap_16s() and __bswap_64s()
Minimise code size by forcing the use of memory addresses for
__bswap_16s() and __bswap_64s().  (__bswap_32s() cannot avoid loading the
value into a register.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-04 21:41:24 +00:00
Michael Brown e187de7239 [i386] Fix building on older versions of gcc
Fix a strict-aliasing error on certain versions of gcc.

Reported-by: Marko Myllynen <myllynen@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-04 21:34:46 +00:00
Michael Brown 249a833ed4 [x86_64] Provide __bswap_{16,32,64}s()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-04 15:29:24 +00:00
Michael Brown af96c4151c [i386] Optimise byte-swapping functions and provide __bswap_{16,32,64}s()
Use the "bswap" instruction to shrink the size of byte-swapping code,
and provide the in-place variants __bswap_{16,32,64}s.

"bswap" is available only on 486 and later processors.  (We already
assume the presence of "cpuid" and "rdtsc", which are available only
on Pentium and later processors.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-04 15:14:47 +00:00
Michael Brown 6324bd9389 [undi] Allow underlying PXE stack to construct link-layer header
Some PXE stacks (observed with a QLogic 8242) will always try to
prepend a link-layer header, even if the caller uses P_UNKNOWN to
indicate that the link-layer header has already been filled in.  This
results in an invalid packet being transmitted.

Work around these faulty PXE stacks where possible by stripping the
existing link-layer header and allowing the PXE stack to (re)construct
the link-layer header itself.

Originally-fixed-by: Buck Huppmann <buckh@pobox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-02 18:02:03 +00:00
Michael Brown cd29df5c08 [vmware] Fix length returned by guestrpc_command()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-01 14:20:32 +00:00
Michael Brown fa538bdbc6 [vmware] Add VMware logfile console (CONSOLE_VMWARE)
Allow iPXE console output to be sent to the VMware logfile via the
GuestRPC mechanism.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-28 23:10:02 +00:00
Michael Brown 3a5823a126 [vmware] Add GuestRPC mechanism
Use the VMware backdoor I/O port to access the GuestRPC mechanism.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-28 23:10:02 +00:00
Michael Brown 05719804b9 [rng] Add RTC-based entropy source
The RTC-based entropy source uses the nanosecond-scale CPU TSC to
measure the time between two 1kHz interrupts generated by the CMOS
RTC.  In a physical machine these clocks are driven from independent
crystals, resulting in some observable clock drift.  In a virtual
machine, the CMOS RTC is typically emulated using host-OS
constructions such as SIGALRM.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-28 11:18:48 +00:00
Michael Brown 073f41085f [rng] Add ANS X9.82 Approved Source of Entropy Input
ANS X9.82 specifies several Approved Sources of Entropy Input (SEI).
One such SEI uses an entropy source as the Source of Entropy Input,
condensing each entropy source output after each GetEntropy call.
This can be implemented relatively cheaply in iPXE and avoids the need
to allocate potentially very large buffers.

(Note that the terms "entropy source" and "Source of Entropy Input"
are not synonyms within the context of ANS X9.82.)

Use the iPXE API mechanism to allow entropy sources to be selected at
compilation time.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-21 12:42:38 +00:00
Michael Brown 464ca5dbc0 [i386] Add missing #include <ipxe/io.h> in pic8259.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-19 22:09:13 +00:00
Till Straumann d3630b6a64 [prefix] Fix missing underscore in libprefix
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-10 14:12:04 +00:00
Michael Brown 3a4253868c [prefix] Delay initrd image copy until memory map is ready
initrd_init() calls umalloc() to allocate space for the initrd image,
but does so before hide_etherboot() has been called.  It is therefore
possible for the initrd to end up overwriting iPXE itself.

Fix by converting initrd_init() from an init_fn to a startup_fn.

Originally-fixed-by: Till Straumann <strauman@slac.stanford.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-09 16:49:30 +00:00
Michael Brown f5bbe7ec4a [lkrnprefix] Copy command line before installing iPXE
The command line may be situated in an area of base memory that will
be overwritten by iPXE's real-mode segments, causing the command line
to be corrupted before it can be used.

Fix by creating a copy of the command line on the prefix stack (below
0x7c00) before installing the real-mode segments.

Reported-by: Dave Hansen <dave@sr71.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-01-18 00:02:16 +00:00
Michael Brown 9a93db3f09 [pxe] Provide PXENV_FILE_EXIT_HOOK only for ipxelinux.0 builds
PXENV_FILE_EXIT_HOOK is designed to allow ipxelinux.0 to unload both
the iPXE and pxelinux components without affecting the underlying PXE
stack.  Unfortunately, it causes unexpected behaviour in other
situations, such as when loading a non-embedded pxelinux.0 via
undionly.kpxe.  For example:

  PXE ROM -> undionly.kpxe -> pxelinux.0 -> chain.c32 to boot hd0

would cause control to return to iPXE instead of booting from the hard
disk.  In some cases, this would result in a harmless but confusing
"No more network devices" message; in other cases stranger things
would happen, such as being returned to the iPXE shell prompt.

The fundamental problem is that when pxelinux detects
PXENV_FILE_EXIT_HOOK, it may attempt to specify an exit hook and then
exit back to iPXE, assuming that iPXE will in turn exit cleanly via
the specified exit hook.  This is not a valid assumption in the
general case, since the action of exiting back to iPXE does not
directly cause iPXE to exit itself.  (In the specific case of
ipxelinux.0, this will work since the embedded script exits as soon as
pxelinux.0 exits.)

Fix the unexpected behaviour in the non-ipxelinux.0 cases by including
support for PXENV_FILE_EXIT_HOOK only when using a new .kkkpxe format.
The ipxelinux.0 build process should therefore now use undionly.kkkpxe
instead of undionly.kkpxe.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-12-11 02:28:04 +00:00
Michael Brown fa410e0a41 [pxe] Modularise PXE API provision
Use the linker table infrastructure to dispatch PXE API calls to the
relevant function.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-12-11 02:27:58 +00:00
Michael Brown 61944ed602 [pxe] Tidy up debugging output
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-12-08 02:56:46 +00:00
Michael Brown faf50e8fa3 [pxe] Check for a valid PXE network device when applicable
Very nasty things can happen if a NULL network device is used.  Check
that pxe_netdev is non-NULL at the applicable entry points, so that
this type of problem gets reported to the caller rather than being
allowed to crash the system.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-12-08 02:35:23 +00:00
Michael Brown fa3ca017ac [undi] Retry PXENV_UNDI_INITIALIZE multiple times
On at least one PXE stack (Realtek r8169), PXENV_UNDI_INITIALIZE has
been observed to fail intermittently due to a media test failure (PXE
error 0x00000061).  Retrying the call to PXENV_UNDI_INITIALIZE
succeeds, and the NIC is then usable.

It is worth noting that this particular Realtek PXE stack is already
known to be unreliable: for example, it repeatably fails its own
boot-time media test after every warm reboot.

Fix by attempting PXENV_UNDI_INITIALIZE multiple times, with a short
delay between each attempt to allow the link to settle.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-12-08 00:12:28 +00:00
Michael Brown caf98cf624 [pxe] Improve pxe_preboot debugging messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-11-14 13:13:45 +00:00
Michael Brown 524349c559 [pxe] Improve pxe_undi debugging messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-11-14 12:48:15 +00:00
Michael Brown 27fdb95572 [prefix] Allow an initrd to be passed to iPXE
Allow an initrd (such as an embedded script) to be passed to iPXE when
loaded as a .lkrn (or .iso) image.  This allows an embedded script to
be varied without recompiling iPXE.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-11-12 00:34:55 +00:00
Michael Brown 24226472b2 [prefix] Allow prefix to specify an arbitrary maximum address for relocation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-11-11 23:20:52 +00:00
Michael Brown 6c5f1a342b [prefix] Use stack rather than %ebp as temporary storage area
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-11-11 22:24:00 +00:00
Michael Brown a05b89ef45 [undi] Ensure that native drivers are tried before the UNDI PCI driver
Suggested-by: Alessandro Salvatori <sandr8@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-11-11 21:32:09 +00:00
Michael Brown a1f618c625 [undi] Use meaningful driver and device names
Specify a driver name of "undionly" and a device name based on the
UNDI-reported underlying hardware device.  For example:

  net0: 52:54:00:12:34:56 using undionly on UNDI-PCI00:03.0 (open)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-10-28 22:52:55 +01:00
Michael Brown a05a3613a5 [undi] Use current (rather than permanent) link-layer address
Requested-by: Savitha Hiriyannaia <Savitha.Hiriyannaiah@emulex.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-10-28 22:41:15 +01:00
Michael Brown c77aece36a [liba20] Preserve all non-segment registers when calling INT 15,2401
Some BIOSes are reported to corrupt %ebx when using INT 15,2401 (see
http://opensolaris.org/jive/thread.jspa?messageID=377026).  Guard
against this by preserving all (non-segment) registers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-10-25 16:05:02 +01:00
Michael Brown 4d8a009ccf [librm] Avoid (harmless) collisions with linker symbols
The symbol_text16 is defined globally by the linker.  Use rm_text16
instead of _text16 for the local variable within librm.S to avoid
confusion when reading linker maps.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-10-25 16:05:02 +01:00
Michael Brown 790035f78d [image] Eliminate the register_and_xxx_image() functions
All users of imgdownload() require registration of the image, so make
registration an integral part of imgdownload() itself and simplify the
"action" parameter to be one of image_select(), image_exec() et al.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-10-25 01:41:41 +01:00
Valentine Barshak 8a86a848dc [lkrnprefix] Fix lost command line passed by grub
iPXE specifies a value of 0 for cmdline_size, causing GRUB to not pass
in a command line.  Fix by setting cmdline_size to the maximum value
of 2047.

Signed-off-by: Valentine Barshak <gvaxon@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-08-06 23:03:40 +01:00
Valentine Barshak 24b62e0e1e [romprefix] Fix romprefix build with certain versions of binutils
Signed-off-by: Valentine Barshak <gvaxon@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-08-06 23:00:39 +01:00
Michael Brown a667bf044a [netdevice] Allow link layer to report broadcast/multicast packets via pull()
Allow the link layer to directly report whether or not a packet is
multicast or broadcast at the time of calling pull(), rather than
relying on heuristics to determine this at a later stage.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-07-15 18:48:46 +01:00
Michael Brown 9cf2f9dc2b [dhcp] Add symbolic definitions for DHCP client architecture values
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-07-06 15:26:43 +01:00
Michael Brown 69f5b2e8dc [int13] Provide a permanently closed window via the control interface
Allow objects to support both streaming and block device protocols, by
starting streaming data only when the data transfer window opens.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-06-28 14:45:13 +01:00
Michael Brown be600ed996 [prefix] Cope with BOOT_IMAGE= anywhere within command line
Some bootloaders seem to add "BOOT_IMAGE=..." at the end of the
command line; some at the start.  Cope with either variation.

Reported-by: Dave Hansen <dave@sr71.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-06-28 11:33:39 +01:00
Michael Brown d4f0c5d088 [romprefix] Force PnP header to a 16-byte boundary for IBM BIOSes
IBM BIOSes ignore the PnP header offset stored at address 0x1a and
instead scan for the $PnP signature on a 16-byte boundary.  (This
alignment is not mandated by the PnP specification.)

Force PnP header to a 16-byte boundary to work around these BIOSes.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-05-17 22:48:52 +01:00
Michael Brown fcd55f7500 [romprefix] Do not fall back to hooking INT19 by default
Several BIOSes (including most IBM BIOSes and many virtual machine
BIOSes) do not provide detectable PnP support, but will use the BEV
entry point for a PnP option ROM.  On these semi-PnP BIOSes, iPXE will
respond to the absence of detectable PnP support by hooking INT19,
which disrupts the boot order.

BIOSes that genuinely require hooking INT19 seem to be very rare
nowadays.  It may therefore be preferable to assume that the absence
of detectable PnP support indicates a semi-PnP BIOS rather than a
non-PnP BIOS.

Change the default behaviour so that INT19 will never be hooked unless
the compile-time option NONPNP_HOOK_INT19 is enabled.  Leave the
redundant PnP detection routine in-place to allow for debugging via
the ROM banner line.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-05-17 15:35:23 +01:00
Michael Brown 058b69d033 [romprefix] Remove special treatment for IBM BIOSes
Revert commit 38cd351 ("[romprefix] Attempt to gracefully handle
semi-PnP IBM BIOSes"), since the test for the "IBM " signature in %edi
is not sufficient to identify an IBM BIOS.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-05-17 15:27:47 +01:00
Michael Brown 38cd351243 [romprefix] Attempt to gracefully handle semi-PnP IBM BIOSes
Some IBM BIOSes provide partial support for PnP: they will use the BEV
entry point but will not advertise PnP support.  This causes iPXE to
hook INT 19, which disrupts the boot process.

Attempt to improve this situation by detecting an IBM BIOS and
treating it as a PnP BIOS despite the absence of a PnP signature.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-05-04 10:04:43 +01:00
Michael Brown 987b825b7f [build] Fix building on mildly deranged versions of binutils
Some versions of binutils have curious concepts of what constitutes
subtraction.  For example:

  0x00000000000000f0 _text16_late = .
  0x0000000000000898 _mtext16 = .
  0x0000000000000898 _etext16 = .
  0x0000000000000898 _text16_late_filesz = ABSOLUTE ((_mtext16 - _text16_late))
  0x00000000000007a8 _text16_late_memsz = ABSOLUTE ((_etext16 - _text16_late))

This has interesting side-effects such as producing sizes for .bss
segments that are negative, causing the majority of addressable memory
to be zeroed out.

Fix by using the form

  ABSOLUTE ( x ) - ABSOLUTE ( y )

rather than

  ABSOLUTE ( x - y )

Reported-by: H. Peter Anvin <hpa@zytor.com>
Suggested-by: H. Peter Anvin <hpa@zytor.com>
Tested-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-29 01:27:36 +01:00
Michael Brown 62c9635166 [int13] Catch INT 13,4b when no explicit drive number is present
This allows older versions of ELTORITO.SYS (such as the version found
on the FreeDOS installation CD-ROM) to use iPXE's emulated CD-ROM
drive.

Reported-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-28 13:07:32 +01:00
Michael Brown d75d6f65aa [int13] Add support for INT 13,4b
This allows the ELTORITO.SYS driver for MS-DOS to access our emulated
CD-ROM drives.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-28 00:02:53 +01:00
Michael Brown 00d0226fee [int13] Add support for El Torito bootable CD-ROM images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-27 22:57:39 +01:00
Michael Brown a9dbc943ae [linux] Avoid building Linux-specific prefix on non-Linux builds
Reported-by: David Yeske <dyeske@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-27 00:26:38 +01:00
Michael Brown 5d2802e403 [sanboot] Add "sanhook" and "sanunhook" commands
Expose the multiple-SAN-drive capability of the iPXE core via the iPXE
command line by adding commands to hook and unhook additional drives.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-24 16:44:34 +01:00
Michael Brown 8e984f35e0 [undi] Assume that interrupts are not supported if IRQ=0
Some PXE stacks (notably old Etherboot/gPXE stacks) will claim to use
the timer interrupt, rather than reporting that interrupts are not
supported.  Since using the timer interrupt is equivalent to polling
anyway, we may as well genuinely poll these stacks.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-22 23:31:25 +01:00
Thomas Miletich 914dc6bfa9 [linux] Avoid unused-but-set variable warning in gcc 4.6
Temporary modification to prevent valgrind.h from breaking compilation
with gcc 4.6.  When this problem is fixed upstream, a new and
unmodified copy of valgrind.h should be imported.

Signed-off-by: Thomas Miletich <thomas.miletich@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-28 14:48:16 +01:00
Michael Brown f9e3581175 [exeprefix] Add .exe prefix
An iPXE .exe image can be loaded from DOS.  Tested using bin/ipxe.exe
to load a Linux kernel and simple initramfs from within MS-DOS 6.22.
(EDD must be disabled using the "edd=off" kernel parameter, since the
loaded kernel image has already overwritten parts of DOS' INT 13
wrapper.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-28 02:10:14 +01:00
Michael Brown 5924e65cea [prefix] Avoid using base memory for temporary decompression area
In the unlikely (but observable) event that INT 15,88 returns less
memory above 1MB than is required for the temporary decompression
area, ignore it and use the 1MB point anyway.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-28 01:00:59 +01:00
Piotr Jaroszyński b604e8a388 [linux] Make malloc and linux_umalloc valgrindable
Make the allocators used by malloc and linux_umalloc valgrindable.
Include valgrind headers in the codebase to avoid a build dependency
on valgrind.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-27 21:03:05 +01:00
Michael Brown b6ca3aa01f [undi] Cope with devices that erroneously claim not to use interrupts
Some PXE stacks advertise that interrupts are not supported, despite
requiring the use of interrupts.  Attempt to cope with such cards
without breaking others by always hooking the interrupt, and using the
"interrupts supported" flag only to decide whether or not to wait for
an interrupt before calling PXENV_UNDI_ISR_IN_PROCESS.

The possible combinations are therefore:

1. Card generates interrupts and claims to support interrupts

   iPXE will call PXENV_UNDI_ISR_IN_PROCESS only after an interrupt
   has been observed.  (This is required to avoid lockups in some PXE
   stacks, which spuriously sulk if called before an interrupt has
   been generated.)

   Such a card should work correctly.

2. Card does not generate interrupts and does not claim to support
   interrupts

   iPXE will call PXENV_UNDI_ISR_IN_PROCESS indiscriminately, matching
   the observed behaviour of at least one other PXE NBP (winBoot/i).

   Such a card should work correctly.

3. Card generates interrupts but claims not to support interrupts

   iPXE will call PXENV_UNDI_ISR_IN_PROCESS indiscriminately.  An
   interrupt will still result in a call to PXENV_UNDI_ISR_IN_START.

   Such a card may work correctly.

4. Card does not generate interrupts but claims to support interrupts

   Such a card will not work at all.

Reported-by: Jerry Cheng <jaspers.cheng@msa.hinet.net>
Tested-by: Jerry Cheng <jaspers.cheng@msa.hinet.net>
Reported-by: Mauricio Silveira <mauricio@livreti.com.br>
Tested-by: Mauricio Silveira <mauricio@livreti.com.br>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-23 14:23:46 +00:00
Bastian Blank d0eb4e529d [build] Fix building with latest binutils
Signed-off-by: Bastian Blank <waldi@debian.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-16 16:09:05 +00:00
Michael Brown f98cf7d70f [console] Add facility for rudimentary keyboard mapping
Allow for remapping of ASCII characters returned by the BIOS, using a
map consisting of (from,to) pairs.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-16 12:02:52 +00:00
Michael Brown 23daab14a6 [romprefix] Use correct size for PMM allocation of image source block
iPXE allocates its first PMM block using the image source length,
which is rounded up to the nearest 16-byte paragraph.  It then copies
in data of a length calculated from the ROM size, which is
theoretically less than or equal to the image source length, but is
rounded up to the nearest 512-byte sector.  This can result in copying
beyond the end of the allocated PMM block, which can corrupt the PMM
data structures (and other essentially arbitrary areas of memory).

Fix by rounding up the image source length to the nearest 512-byte
sector before using it as the PMM allocation length.

Reported-by: Alex Williamson <alex.williamson@redhat.com>
Reported-by: Jarrod Johnson <jarrod.b.johnson@gmail.com>
Reported-by: Itay Gazit <itayg@mellanox.co.il>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-15 02:07:22 +00:00
Michael Brown 9a5b4aed69 [bios] Use INT 16,11 instead of INT 16,01 to check for keystrokes
INT 16,01 will discard some extended keystrokes on some BIOSes, making
it impossible for iPXE to detect keypresses such as F12.  Fix by using
INT 16,11 instead.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-10 22:50:05 +00:00
Michael Brown 0d277724a9 [pxe] Report an IRQ number only if device supports interrupts
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-10 18:25:24 +00:00
Michael Brown 1c0ff6e1a7 [console] Move include/console.h to include/ipxe/console.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-09 20:09:26 +00:00
Michael Brown 9fa4ac2e9a [image] Simplify use of imgdownload()
Allow imgdownload() to be called without first having to allocate (and
so keep track of) an image.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-09 16:57:34 +00:00
Michael Brown b2332d5118 [prefix] Allow iPXE's own command line to be executed as a script
Some prefixes (e.g. .lkrn) allow a command line to be passed in to
iPXE.  At present, this command line is ignored.

If a command line is provided, treat it as an embedded script (without
an explicit "#!ipxe" magic marker).  This allows for patterns of
invocation such as

  title  iPXE
  kernel /boot/ipxe.lkrn dhcp && \
         sanboot iscsi:10.0.4.1::::iqn.2010-04.org.ipxe.dolphin:storage

Here GRUB is instructed to load ipxe.lkrn with an embedded script
equivalent to

  #!ipxe
  dhcp
  sanboot iscsi:10.0.4.1::::iqn.2010-04.org.ipxe.dolphin:storage

This can be used to effectively vary the embedded script without
having to rebuild ipxe.lkrn.

Originally-implemented-by: Dave Hansen <dave@sr71.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 22:28:31 +00:00
Michael Brown 9e98e4b9b8 [bios] Recognise scancodes for F5-F12 inclusive
The function keys F5-F12 all conform to the same ANSI pattern as the
other "special" keys that we currently recognise.  Add these key
definitions, and shrink the representation of the ANSI sequences in
bios_console.c to compensate.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 19:22:20 +00:00
Michael Brown d1ad046a87 [comboot] Do not assume that image has a non-NULL command line
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 02:38:26 +00:00
Michael Brown 34b6ecb2f1 [image] Simplify image management
Refactor the {load,exec} image operations as {probe,exec}.  This makes
the probe mechanism cleaner, eliminates some forward declarations,
avoids holding magic state in image->priv, eliminates the possibility
of screwing up between the "load" and "exec" stages, and makes the
documentation simpler since the concept of "loading" (as distinct from
"executing") no longer needs to be explained.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 00:37:50 +00:00