core/lwip/undi: Improve UNDIIF_ID_DEBUG messages

Remove extra space; add TCP flags

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
core: mbox/semaphore NULL checks

Also set mbox invalid and mbox pointer NULL when free()d

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
core: make mbox_post()/__sem_down_slow() check if valid

If the mailbox/semaphore is invalid, disallow additions.

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
PXELINUX: Use sendto() instead of connect()/send()/disconnect()

This commit prevents a race-condition on systems that have functional
interrupts (observed with iPXE and select other Dell systems).  Without
this, the reply packet could be received by the core prior to the
disconnect() call, see that it doesn't have a matching PCB (protocol
control block, iirc) since the reply has a different far-end UDP port
than the original request, and lwIP will discard the packet before
PXELINUX can see it.

net_core_sendto() instead of
net_core_connect() net_core_send() net_core_disconnect()

Commit message expanded with Matt Fleming's assistance

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
core: dprintf() the banner.

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
undiif: show thread of execution on UNDIIF_ID_DEBUG

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
PXELINUX: specify PXE/lwIP

Styled after SYSLINUX

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
com32: Define ddprintf() macro

Duplicating Debug Printf;  Certain warning/error printf()
 statements are not visible if they occur before ldlinux.c32
 is loaded

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
PXE: use ddprintf macro

Messages are needed before ldlinux.c32 is loaded

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
core/lwip: Fix NULL pointer check

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
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>
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>
pxe, efi: Bad read of file size over TFTP on EFI64

A fancy pointers logic has been replaced with a plain old if / else
branches. It was assigning only half of a 64 bits integer which is then
assigned to a size_t. Thus leading to a bug on platform where size_t is
64 bits.

Resolves bug #26

Signed-off-by: Celelibi <celelibi@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>