[settings] Expose build architecture and platform via settings

Expose the build architecture (e.g. "i386" or "x86_64") via
${buildarch} and the firmware platform (e.g. "pcbios" or "efi") via
${platform}.  These settings directly expose the ARCH and PLATFORM
variables from the Makefile.

Note that the build architecture reflects the architecture for which
iPXE was compiled, not the architecture on which iPXE is currently
running.  The "cpuid" command can be used to detect a 64-bit system at
runtime.

Requested-by: James A. Peltier <jpeltier@sfu.ca>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[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>
[intel] Remove hardcoded offsets for descriptor ring registers

The Intel 10 Gigabit NICs use the same simplified (aka "legacy")
descriptor format and the same layout for descriptor register blocks
as the Intel 1 Gigabit NICs.  The offsets of the descriptor register
blocks are not the same.

Simplify reuse of the existing code by removing all hardcoded offsets
for registers within descriptor register blocks, and ensuring that all
offsets are calculated using the descriptor register block base
address provided via intel_init_ring().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[intel] Expose functionality to be shared with intelx driver

The Intel 10 Gigabit NICs have a datapath that is almost
register-compatible with the Intel 1 Gigabit NICs.  Expose common
functionality to avoid duplication of code in the new "intelx" driver.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[intel] Add intelx driver for Intel 10 Gigabit Ethernet NICs

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[efi] Remove obsolete EFI I/O implementation using EFI_CPU_IO_PROTOCOL

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[libc] Use __einfo() tuple as first argument to EUNIQ()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[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>
[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>
[efi] Add sample platform-generated error disambiguations

Add disambiguated errors for LoadImage() and StartImage(), primarily
to demonstrate how to use __einfo_uniqify() and __einfo_platformify()
in the context of EFI platform errors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[netdevice] Use link-layer address as part of RNG seed

iPXE currently seeds the random number generator using the system
timer tick count.  When large numbers of machines are booted
simultaneously, multiple machines may end up choosing the same DHCP
transaction ID (XID) value; this can cause problems.

Fix by using the least significant (and hence most variable) bits of
each network device's link-layer address to perturb the random number
generator.  This introduces some per-machine unique data into the
random number generator's seed, and so reduces the chances of DHCP XID
collisions.

This does not affect the ANS X9.82-compatible random bit generator
used by TLS and other cryptography code, which uses an entirely
separate source of entropy.

Originally-implemented-by: Bernhard Kohl <bernhard.kohl@nsn.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[build] Allow sparse to find compiler.h

sparse seems to have problems finding compiler.h when specified as
"-include compiler.h"; one possible explanation is that it ignores the
include path.  Fix by using "-include include/compiler.h".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[build] Define __WINT_TYPE__ if necessary

sparse does not define __WCHAR_TYPE__ or __WINT_TYPE__.  We already
define __WCHAR_TYPE__ if the compiler does not do so; do the same for
__WINT_TYPE__.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[build] Allow sparse to be invoked via "make C=1"

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[build] Avoid sparse undeclared symbol warning for PROVIDE_SYMBOL()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[process] Mark process descriptor as static in PERMANENT_PROCESS

There is no need for the process descriptor to be a global variable.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[realtek] Print bad MAC address in debug message when inferring no EEPROM

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[build] Use -Wno-decl when running sparse

Linker table entries must be non-static in order to avoid being
completely optimised away by some versions of gcc.  Use -Wno-decl to
prevent sparse from warning about these, since the alternative would
be to litter the code with otherwise unnecessary "extern"
declarations.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[build] Fix uses of literal 0 as a NULL pointer

Detected using sparse.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[build] Fix dubious uses of bitwise operators

Detected by sparse.

Signed-off-by: Michael Brown <mcb30@ipxe.org>