PXE ISR: Force polling on select hardware WORKAROUND

By OUI == 00:23:ae and flags == 0xdc1b, detect select hardware.

On select platforms (Dell OptiPlex 760, Dell OptiPlex 960; perhaps
more), the interrupt appears to go "deaf" after a few seconds.  By
matching MAC OUI and flags value, force polling on these select
platforms.  I'm not sure if there's any better data available that
shallow in the core.  I believe PCI IDs can be fetched with functions
from other libraries and the UUID and DMI data (the most likely to be
useful is SYSPRODUCT) is available in ldlinux.c32.

Commit message expanded with Matt Fleming's assistance

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
com32/disk: Code cleanup at disk_write_sectors and disk_read_sectors.

Pulled common code out of these functions into new ones.
The functions chs_setup and ebios_setup were created for this purpose.

Signed-off-by: Raphael S.Carvalho <raphael.scarv@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
com32: Fix bugs on cmd_reverse_search (Triple fault dimension)

cmd_reverse_search has a bug that the variable cursor is updated even if a command
wasn't found. If this happens, and the next key falls into the default case,
memmove's size parameter would be a negative number.

This bug can be reproduced by doing the following:
On cmd_reverse_search (ctrl-r), type multiple keys at the same time.
'Enjoy' the triple fault and a screen of random colors.

There is also a small bug that turns the task of using (ctrl-r) on the first command
impossible. Previously, this command was discarded.

Signed-off-by: Raphael S.Carvalho <raphael.scarv@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
com32: Fix a bug on history of commands.

Previously, even zero-length commands would be added to the history when
they shoudn't, e.g: just typing enter.

For example, if you type: FOO -> (ENTER) -> (ENTER),
then to get FOO from the history you would have to press the UP key
twice. It also saves a bit of memory.

Signed-off-by: Raphael S.Carvalho <raphael.scarv@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
efi/: Fix displayed version; add DATE

Version string appeared to be a temporary generic string; complete out in the
  standard fashion

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
isolinux: Clear upper half of EDX before using

In checkin:

    cb015497a4e4 isolinux: Update LBA in getlinsec loop

... we use EDX as a sector count, but the sector count is actually in
DX, and the upper half of EDX is uninitialized.  If the BIOS enters
with a nonzero value in the upper half of EDX, this breaks horribly.

At least one set of BIOSes has been identified where if the LBA > 64K
then the upper half of EDX will be nonzero.

Reported-by: Carl Duff <cdrw2400@gmail.com>
Reported-by: Philip Müller <philm@manjaro.org>
Tested-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Merge remote-tracking branch 'origin/elflink' into firmware

Resolved Conflicts:
	com32/lib/syslinux/disk.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
load_linux: Don't use size heuristic for non-relocatable kernels

For non-relocatable kernels, it really makes no sense to estimate how
much space the kernel is going to need, as if we fail, there is really
nothing we can do about it.  Furthermore, it is actively wrong for
zImage kernels (which aren't decompressed in place) and for non-Linux
kernels.

Additionally, tweak the code for assigning an address to the command
line to handle a few more corner cases correctly, be simpler, and not
need to build the memory map again since we already are doing that
elsewhere.

Reported-and-tested-by: Christian Hesse <list@eworm.de>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
pxe: Make the SENDCOOKIES feature for HTTP worked again

Code refactoring had caused the http_bake_cookies() function to become
inaccessible and the SendCookies variable to be duplicated, causing
the sendcookies feature to not work.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
gnu-efi: Add gnu-efi as a submodule

Tracking the gnu-efi dependency has tripped up some users. We can make
things easier when building Syslinux by including a copy of the gnu-efi
source and building it for efi32 and efi64.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
efi: Add build scripts for gnu-efi

Now that we have a gnu-efi git submodule we need some scripts to build
and install it into architecture-specific build directories.

This actually simplifies things a bit because we no longer need to
account for the variations in distribution installation paths - we now
control the paths.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
efi: Make gnu-efi build scripts more robust

Modify the scripts to check that they're called with the correct number
of arguments and error out otherwise after printing some helpful info.

This change also stops relying on passing arguments through environment
variables and instead passes them explicitly to the scripts, which is
definitely more robust, and handles the case where the scripts are
invoked directly.

Of course, now that the scripts can be invoked directly we need to
regard any input as hostile and exit immediately on error.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
efi: Check the gnu-efi build succeeded

Guard against future changes by requiring that the gnu-efi build scripts
exit with success.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
efi: Don't rebuild gnu-efi every time

There is a typo in the path used to decide whether to build gnu-efi.
Since the condition "does a nonexistent file exist?" will never evaluate
true, we're currently building gnu-efi unnecessarily.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
ldlinux: Fix recent pxe symbol regression

commit 60dabb5b1d6d ("pxe: Make the SENDCOOKIES feature for HTTP worked
again") introduced a regression for ldlinux because it references the
'SendCookies' symbol, which is only provided by PXELINUX.

The regression was caused because the '__weak' tag was dropped from the
declaration of SendCookies.

Tested-by: "Santillanes, Russel" <Russel.Santillanes@gs.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
ansi: switch cindex type to attr_t

To fully support color tables with more than 256 entries

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Merge branch 'efi-date-for-mfleming' of git://github.com/geneC/syslinux into firmware

Pull date fix for EFI from Gene Cumm,

* 'efi-date-for-mfleming' of git://github.com/geneC/syslinux:
  efi/: Fix displayed version; add DATE
version: Bump version

We've now entered the 6.03 development cycle.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>