summaryrefslogtreecommitdiffstats
path: root/src/arch/x86/core
Commit message (Collapse)AuthorAgeFilesLines
* [init] Show startup and shutdown function names in debug messagesMichael Brown2019-01-252-0/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Ensure that inline code symbols are uniqueMichael Brown2018-03-211-1/+1
| | | | | | | | | | | | | | | Commit 6149e0a ("[librm] Provide symbols for inline code placed into other sections") may cause build failures due to duplicate label names if the compiler chooses to duplicate inline assembly code. Fix by using the "%=" special format string to include a guaranteed-unique number within the label name. The "%=" will be expanded only if constraints exist for the inline assembly. This fix therefore requires that all REAL_CODE() fragments use a (possibly empty) constraint list. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cpuid] Allow input %ecx value to be specifiedMichael Brown2017-06-163-33/+44
| | | | | | | | | | | | | | | | | | | | For some CPUID leaves (e.g. %eax=0x00000004), the result depends on the input value of %ecx. Allow this subfunction number to be specified as a parameter to the cpuid() wrapper. The subfunction number is exposed via the ${cpuid/...} settings mechanism using the syntax ${cpuid/<subfunction>.0x40.<register>.<function>} e.g. ${cpuid/0.0x40.0.0x0000000b} ${cpuid/1.0x40.0.0x0000000b} to retrieve the CPU topology information. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [video_subr] Use memmove() for overlapping memory copyMichael Brown2017-03-221-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [time] Allow timer to be selected at runtimeMichael Brown2017-01-261-37/+120
| | | | | | | | | | | | | | | | | | | | | | Allow the active timer (providing udelay() and currticks()) to be selected at runtime based on probing during the INIT_EARLY stage of initialisation. TICKS_PER_SEC is now a fixed compile-time constant for all builds, and is independent of the underlying clock tick rate. We choose the value 1024 to allow multiplications and divisions on seconds to be converted to bit shifts. TICKS_PER_MS is defined as 1, allowing multiplications and divisions on milliseconds to be omitted entirely. The 2% inaccuracy in this definition is negligible when using the standard BIOS timer (running at around 18.2Hz). TIMER_RDTSC now checks for a constant TSC before claiming to be a usable timer. (This timer can be tested in KVM via the command-line option "-cpu host,+invtsc".) Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cpuid] Provide cpuid_supported() to test for supported functionsMichael Brown2017-01-252-58/+67
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [af_packet] Add new AF_PACKET driver for LinuxDavid Decotigny2017-01-221-0/+39
| | | | | | | | | | | | This code largely inspired by tap.c. Allows for testing iPXE on real NICs from within Linux. For example: make bin-x86_64-linux/af_packet.linux valgrind ./bin-x86_64-linux/af_packet.linux --net af_packet,if=eth3 Tested as x86_64 and i386 binary. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pci] Support systems with multiple PCI root bridgesMichael Brown2016-06-091-2/+4
| | | | | | | | | Extend the 16-bit PCI bus:dev.fn address to a 32-bit seg:bus:dev.fn address, assuming a segment value of zero in contexts where multiple segments are unsupported by the underlying data structures (e.g. in the iBFT or BOFM tables). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [tcpip] Do not fall back to using unoptimised TCP/IP checksummingMichael Brown2016-05-041-2/+2
| | | | | | | | Require architecture-specific code to make a deliberate choice to use the unoptimised generic_tcpip_continue_chksum() function, if there is no optimised version available. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [gdb] Add support for x86_64Michael Brown2016-03-221-0/+251
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ioapi] Split ioremap() out to a separate IOMAP APIMichael Brown2016-02-261-3/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Add phys_call() wrapper for calling code with physical addressingMichael Brown2016-02-211-145/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a phys_call() wrapper function (analogous to the existing real_call() wrapper function) for calling code with flat physical addressing, and use this wrapper within the PHYS_CODE() macro. Move the relevant functionality inside librm.S, where it more naturally belongs. The COMBOOT code currently uses explicit calls to _virt_to_phys and _phys_to_virt. These will need to be rewritten if our COMBOOT support is ever generalised to be able to run in a 64-bit build. Specifically: - com32_exec_loop() should be restructured to use PHYS_CODE() - com32_wrapper.S should be restructured to use an equivalent of prot_call(), passing parameters via a struct i386_all_regs - there appears to be no need for com32_wrapper.S to switch between external and internal stacks; this could be omitted to simplify the design. For now, librm.S continues to expose _virt_to_phys and _phys_to_virt for use by com32.c and com32_wrapper.S. Similarly, librm.S continues to expose _intr_to_virt for use by gdbidt.S. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Prepare for long-mode memory mapMichael Brown2016-02-191-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of the iPXE binary (the .textdata section) is physically relocated at runtime to the top of the 32-bit address space in order to allow space for an OS to be loaded. The relocation is achieved with the assistance of segmentation: we adjust the code and data segment bases so that the link-time addresses remain valid. Segmentation is not available (for normal code and data segments) in long mode. We choose to compile the C code with -mcmodel=kernel and use a link-time address of 0xffffffffeb000000. This choice allows us to identity-map the entirety of the 32-bit address space, and to alias our chosen link-time address to the physical location of our .textdata section. (This requires the .textdata section to always be aligned to a page boundary.) We simultaneously choose to set the 32-bit virtual address segment bases such that the link-time addresses may simply be truncated to 32 bits in order to generate a valid 32-bit virtual address. This allows symbols in .textdata to be trivially accessed by both 32-bit and 64-bit code. There is no (sensible) way in 32-bit assembly code to generate the required R_X86_64_32S relocation records for these truncated symbols. However, subtracting the fixed constant 0xffffffff00000000 has the same effect as truncation, and can be represented in a standard R_X86_64_32 relocation record. We define the VIRTUAL() macro to abstract away this truncation operation, and apply it to all references by 32-bit (or 16-bit) assembly code to any symbols within the .textdata section. We define "virt_offset" for a 64-bit build as "the value to be added to an address within .textdata in order to obtain its physical address". With this definition, the low 32 bits of "virt_offset" can be treated by 32-bit code as functionally equivalent to "virt_offset" in a 32-bit build. We define "text16" and "data16" for a 64-bit build as the physical addresses of the .text16 and .data16 sections. Since a physical address within the 32-bit address space may be used directly as a 64-bit virtual address (thanks to the identity map), this definition provides the most natural access to variables in .text16 and .data16. Note that this requires a minor adjustment in prot_to_real(), which accesses .text16 using 32-bit virtual addresses. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [relocate] Preserve page alignment during relocationMichael Brown2016-02-191-12/+10Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Provide an abstraction wrapper for prot_callMichael Brown2016-02-191-3/+2Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Convert prot_call() to a real-mode near callMichael Brown2016-02-181-1/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [bios] Use an 8kB stack for x86_64Michael Brown2016-02-181-1/+7
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Discard argument as part of return from prot_call()Michael Brown2016-02-171-1/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [bios] Add bin-x86_64-pcbios build platformMichael Brown2016-02-1612-0/+1117
| | | | | | | | | | | | | | Move most arch/i386 files to arch/x86, and adjust the contents of the Makefiles and the include/bits/*.h headers to reflect the new locations. This patch makes no substantive code changes, as can be seen using a rename-aware diff (e.g. "git show -M5"). This patch does not make the pcbios platform functional for x86_64; it merely allows it to compile without errors. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [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>
* [serial] Add general abstraction of a 16550-compatible UARTMichael Brown2015-06-291-0/+62
| | | | 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>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-021-1/+5
| | | | | | | | | | 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-028-8/+40
| | | | | | | Relicense files for which I am the sole author (as identified by util/relicense.pl). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [timer] Rewrite the 8254 Programmable Interval Timer supportMichael Brown2015-02-171-0/+66
| | | | | | | | 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] Rewrite string functionsMichael Brown2015-02-171-84/+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>
* [hyperv] Add support for Hyper-V hypervisorMichael Brown2014-12-181-0/+67
| | | | | | | Add support for detecting and communicating with the Hyper-V hypervisor. 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>
* [console] Allow console input and output to be disabled independentlyMichael Brown2013-11-281-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Expose CPUID instruction via settings mechanismMichael Brown2013-08-072-19/+273
| | | | | | | | | | | | | | | | | | | | | | | 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>
* [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>
* [libc] Fix and externalise memswap()Michael Brown2012-11-121-0/+28
| | | | | | Make memswap() behave correctly if called with a length of zero. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Reduce overall code size by externalising strlen()Michael Brown2012-11-121-0/+18
| | | | | | Typical saving is 5-20 bytes in each file using strlen(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Reduce overall code size by externalising strncmp()Michael Brown2012-11-121-0/+38
| | | | | | Typical saving is 20-30 bytes in each file using strncmp(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Reduce overall code size by externalising memmove()Michael Brown2012-11-121-1/+49
| | | | | | Typical saving is 15-20 bytes in each file using memmove(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Add support for the bochs/qemu debug port consoleMichael Brown2012-09-101-0/+86
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [tcpip] Fix building under CygwinJoshua Oreman2012-07-241-1/+1
| | | | | | | 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>
* [legal] Update FSF mailing address in GPL licence textsMichael Brown2012-07-205-5/+10
| | | | | Suggested-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ioapi] Generalise i386 raw I/O API to x86Michael Brown2012-07-171-0/+101
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [tcpip] Add faster algorithm for calculating the TCP/IP checksumMichael Brown2012-06-281-0/+169
| | | | | | | | | 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>
* [libc] Simplify memcpy() implementationMichael Brown2012-06-271-16/+10Star
| | | | | | | | 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>
* [cmdline] Add "cpuid" commandMichael Brown2012-06-071-0/+154
| | | | | | | 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>
* [crypto] Add big-integer library for RSA calculationsMichael Brown2012-03-141-0/+90
| | | | | | | | | | | | | | 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>
* [pci] Replace pci_max_bus() with pci_num_bus()Michael Brown2011-02-171-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pci] Use single "busdevfn" field in struct pci_deviceMichael Brown2011-02-171-2/+2
| | | | | | | Merge the "bus" and "devfn" fields into a single "busdevfn" field, to match the format used by the majority of external code. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [linux] Fix building on RHEL5 and similar platformsMichael Brown2010-10-111-48/+40Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [linux] Add most of the linux apiPiotr Jaroszyński2010-08-192-0/+283
| | | | | Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Rename gPXE to iPXEMichael Brown2010-04-201-2/+2
| | | | | | | | | | | Access to the gpxe.org and etherboot.org domains and associated resources has been revoked by the registrant of the domain. Work around this problem by renaming project from gPXE to iPXE, and updating URLs to match. Also update README, LOG and COPYRIGHTS to remove obsolete information. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Add a selection of FILE_LICENCE declarationsMichael Brown2009-05-182-0/+4
| | | | | Add FILE_LICENCE declarations to almost all files that make up the various standard builds of gPXE.