summaryrefslogtreecommitdiffstats
path: root/src/arch/x86
Commit message (Collapse)AuthorAgeFilesLines
...
* [serial] Check for UART existence in uart_select()Michael Brown2015-07-311-8/+15
| | | | | | | | | | | Check for existence of the UART in uart_select(), not just in uart_init(). This allows uart_select() to refuse to set a non-working address in uart->base, which in turns means that the serial console code will not attempt to use a non-existent UART. Reported-by: Torgeir Wulfsberg <Torgeir.Wulfsberg@kongsberg.com> Reported-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [xen] Wait for and clear XenStore event before receiving dataMichael Brown2015-06-301-0/+19
| | | | | | | | | | | | | | | Older, out-of-tree Xen kernel modules (such as those provided with SuSE Linux Enterprise Server 11) do not clear the leftover "event pending" bit when opening an event channel. Consequently, no event is ever delivered to indicate that there is information in the XenStore ring buffer, and the system hangs shortly after loading the xen-platform-pci kernel module. Work around this problem by always waiting for the XenStore event channel to be signalled, and clearing the event before processing the received data. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [serial] Add general abstraction of a 16550-compatible UARTMichael Brown2015-06-293-0/+104
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [int13con] Add basic ability to log to a local disk via INT 13Michael Brown2015-05-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Several popular public cloud providers do not provide any sensible mechanism for obtaining debug output from an OS which is failing to boot. For example, Amazon EC2 provides the "Get System Log" facility, which occasionally deigns to report a random subset of the characters emitted via the VM's serial port, but usually returns only a blank screen. (Amazingly, this is still superior to the debugging facilities provided by Azure.) Work around these shortcomings by adding a console type which sends output to a magically detected raw disk partition, and including such a partition within any iPXE .usb-format image. To use this facility: - build an iPXE .usb image with CONSOLE_INT13 enabled - boot the cloud VM from this image - after the boot fails, attach the VM's boot disk to a second VM - from this second VM, use "less -f -R /dev/sdb3" (or similar) to view the iPXE output. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [vram] Add "vram" built-in setting to dump video RAMMichael Brown2015-04-241-0/+72
| | | | | | | | | | | | | | | | | | | | The "vram" setting returns the (Base64-encoded) contents of video RAM, and can be used to capture a screenshot. For example: after running memtest.0 and encountering an error, the output can be captured and sent to a remote server for later diagnosis: #!ipxe chain -a http://server/memtest.0 && goto ok || goto bad :bad params param errno ${errno} param vram ${vram} chain -a http://server/report.php##params :ok Inspired-by: Christian Nilsson <nikize@gmail.com> Originally-implemented-by: Christian Nilsson <nikize@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Construct all-drivers list based on driver classMichael Brown2015-04-222-2/+2
| | | | | | | | | | | | The USB bus drivers (ehci.c and xhci.c) have PCI device ID tables and hence PCI_ROM() lines, but should probably not be included in the all-drivers build on this basis, since they do nothing useful unless a USB network driver is also present. Fix by constructing the all-drivers list based on the driver class (i.e. the portion of the source path immediately after "drivers/"). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Use the EFI_RNG_PROTOCOL as an entropy source if availableMichael Brown2015-04-141-3/+76
| | | | | | | | | | | | | | | Entropy gathering via timer ticks is slow under UEFI (of the order of 20-30 seconds on some machines). Use the EFI_RNG_PROTOCOL if available, to speed up the process of entropy gathering. Note that some implementations (including EDK2) will fail if we request fewer than 32 random bytes at a time, and that the RNG protocol provides no guarantees about the amount of entropy provided by a call to GetRNG(). We take the (hopefully pessimistic) view that a 32-byte block returned by GetRNG() will contain at least the 1.3 bits of entropy claimed by min_entropy_per_sample(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add EFI entropy sourceMichael Brown2015-04-142-0/+151
| | | | | Originally-implemented-by: Jarrod Johnson <jbjohnso@us.ibm.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Ensure drivers are disconnected when ExitBootServices() is calledMichael Brown2015-04-131-0/+35
| | | | | | | | | | | | | | | | | | We hook the UEFI ExitBootServices() event and use it to trigger a call to shutdown_boot(). This does not automatically cause drivers to be disconnected from their devices, since device enumeration is now handled by the UEFI core rather than by iPXE. (Under the old and dubiously compatible device model, iPXE used to perform its own device enumeration and so the call to shutdown_boot() would indeed have caused drivers to be disconnected.) Fix by replicating parts of the dummy "EFI root device" from efiprefix.c to efidrvprefix.c, so that the call to shutdown_boot() will call efi_driver_disconnect_all(). Originally-fixed-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Fix the REQUIRE_SYMBOL mechanismMichael Brown2015-03-052-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | At some point in the past few years, binutils became more aggressive at removing unused symbols. To function as a symbol requirement, a relocation record must now be in a section marked with @progbits and must not be in a section which gets discarded during the link (either via --gc-sections or via /DISCARD/). Update REQUIRE_SYMBOL() to generate relocation records meeting these criteria. To minimise the impact upon the final binary size, we use existing symbols (specified via the REQUIRING_SYMBOL() macro) as the relocation targets where possible. We use R_386_NONE or R_X86_64_NONE relocation types to prevent any actual unwanted relocation taking place. Where no suitable symbol exists for REQUIRING_SYMBOL() (such as in config.c), the macro PROVIDE_REQUIRING_SYMBOL() can be used to generate a one-byte-long symbol to act as the relocation target. If there are versions of binutils for which this approach fails, then the fallback will probably involve killing off REQUEST_SYMBOL(), redefining REQUIRE_SYMBOL() to use the current definition of REQUEST_SYMBOL(), and postprocessing the linked ELF file with something along the lines of "nm -u | wc -l" to check that there are no undefined symbols remaining. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [malloc] Move valgrind headers out of arch/x86Michael Brown2015-03-032-4849/+0Star
| | | | | | | The valgrind headers are not x86-specific; they detect the CPU architecture and contain inline assembly for multiple architectures. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Rewrite byte-swapping codeMichael Brown2015-03-021-0/+8
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-025-7/+20
| | | | | | | | | | These files cannot be automatically relicensed by util/relicense.pl since they either contain unusual but trivial contributions (such as the addition of __nonnull function attributes), or contain lines dating back to the initial git revision (and so require manual knowledge of the code's origin). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-0225-25/+73
| | | | | | | Relicense files for which I am the sole author (as identified by util/relicense.pl). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hyperv] Check for required featuresMichael Brown2015-02-202-0/+41
| | | | | | | | | | | Other hypervisors (e.g. KVM) may provide an unusable subset of the Hyper-V features, and our attempts to use these non-existent features cause the guest to reboot. Fix by explicitly checking for the Hyper-V features that we use. Reported-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [timer] Rewrite the 8254 Programmable Interval Timer supportMichael Brown2015-02-172-0/+147
| | | | | | | | The 8254 timer code (used to implement udelay()) has an unknown provenance. Rewrite this code to avoid potential licensing uncertainty. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Reduce size of memset()Michael Brown2015-02-171-1/+127
| | | | | | | | | As with memcpy(), we can reduce the code size (by an average of 0.2%) by giving the compiler more visibility into what memset() is doing, and by avoiding the "rep" prefix on short fixed-length sequences of string operations. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Rewrite string functionsMichael Brown2015-02-172-102/+0Star
| | | | | | | | | | | | Some of the C library string functions have an unknown provenance. Reimplement all such functions to avoid potential licensing uncertainty. Remove the inline-assembler versions of strlen(), memswap(), and strncmp(); these save a minimal amount of space (around 40 bytes in total) and are not performance-critical. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Include Hyper-V driver in the all-drivers buildMichael Brown2014-12-211-0/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hyperv] Add support for NetVSC paravirtual network devicesMichael Brown2014-12-181-0/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hyperv] Add support for VMBus devicesMichael Brown2014-12-181-0/+8
| | | | | | Add support for an abstraction of a VMBus device. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hyperv] Add support for Hyper-V hypervisorMichael Brown2014-12-187-0/+737
| | | | | | | Add support for detecting and communicating with the Hyper-V hypervisor. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [xen] Use version 1 grant tables by defaultMichael Brown2014-08-131-52/+23Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [xen] Accept alternative Xen platform PCI device ID 5853:0002Michael Brown2014-08-131-0/+1
| | | | | | | | | | | | | | | | | 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>
* [efi] Default to releasing network devices for use via SNPMichael Brown2014-07-302-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* [xen] Add support for Xen netfront virtual NICsMichael Brown2014-07-291-0/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [xen] Add basic support for PV-HVM domainsMichael Brown2014-07-295-0/+762
| | | | | | | | | 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>
* [ioapi] Centralise notion of PAGE_SIZEMichael Brown2014-07-281-0/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ioapi] Fail ioremap() when attempting to map a zero bus addressMichael Brown2014-07-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [efi] Include SNP NIC driver within the all-drivers targetMichael Brown2014-07-081-0/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Identify autoboot device by MAC address when chainloadingMichael Brown2014-07-081-0/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Restructure EFI driver modelMichael Brown2014-06-251-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [build] Avoid errors when build directory is mounted via NFSMichael Brown2014-05-131-1/+1
| | | | | Reported-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Add flsll()Michael Brown2014-04-271-31/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Add inline assembly implementation of flsl() using BSR instructionMichael Brown2014-04-241-0/+31
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Disable SNP devices when running iPXE as the applicationMichael Brown2014-03-141-2/+4
| | | | | | | | | | | | | 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>
* [efi] Unload our own image before exiting UEFI applicationMichael Brown2014-03-141-4/+9
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Avoid accidentally calling main() twiceMichael Brown2014-03-141-1/+5
| | | | | | | | | | | | | | 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>
* [settings] Force settings into alphabetical order within sectionsMichael Brown2013-12-051-18/+20
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Explicitly separate the concept of a completed fetched settingMichael Brown2013-12-051-3/+3
| | | | | | | | | | 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>
* [vesafb] Add VESA frame buffer consoleMichael Brown2013-11-281-0/+1
| | | | | | | | | | | 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>
* [console] Allow console input and output to be disabled independentlyMichael Brown2013-11-281-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Generate command option help text automaticallyMichael Brown2013-11-071-2/+1Star
| | | | | | | Generate the command option help text automatically from the list of defined options. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Expose CPUID instruction via settings mechanismMichael Brown2013-08-074-19/+299
| | | | | | | | | | | | | | | | | | | | | | | 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>
* [build] Fix %.licence build targetMichael Brown2013-07-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* [cmdline] Add "poweroff" commandMarin Hannache2013-07-151-0/+1
| | | | | | Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Add FILE_LICENCE for valgrind headersMarin Hannache2013-07-142-0/+4
| | | | | Signed-off-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [linux] Add support for accessing PCI configuration space via /proc/bus/pciMichael Brown2013-07-131-0/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Add efidrv.cab target for UEFI Secure Boot signingMichael Brown2013-05-141-0/+10
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pxe] Convert external PXE API errors into iPXE platform-generated errorsMichael Brown2013-04-291-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>