Automatically unmap physmap()s.

Similarly to the previous PCI self-clean up patch this one allows to get rid
of a huge number of programmer shutdown functions and makes introducing
bugs harder. It adds a new function rphysmap() that takes care of unmapping
at shutdown. Callers are changed where it makes sense.

Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
uintptr_t-ify physmap functions.

unsigned long is not the right type for manipulating pointer values.
Since C99 there are suitable unsigned and signed types available, namely
uintptr_t and intptr_t respectively.

Use them in physmap.c and its callers where applicable.

This patch also changes the display width of all address values in
physmap.c to 16/8 hex characters depending on the actual size.
Allow physmap_common() to round address ranges to page boundaries.

Automatically round address ranges requested from rphysmap() to page
boundaries. Other physmap() variants were not changed so this is
safe regarding unmapping.

I had also to shorten the readbility defines for the physmap_common
parameters to make the calls fit a single line.

Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Add an internal DMI decoder

Previously we had to rely on dmidecode to decode the DMI/SMBIOS table.
This patch integrates a DMI decoder into flashrom. The old behavior of calling
dmidecode can be brought back by setting DMI_INTERNAL to 0.

Significant portions of this patch were taken from dmidecode, hence add its
authors to the copyright notice (dmidecode is also GPL2+). We do a few things
differently though. First of all we do more bounds checking to prevent accessing
unmapped memory. We do not support disovery via EFI (yet), but memory
scanning only. We handle the chassis-type lock bit correctly.

The API to the rest of flashrom remains stable, but the output changes slightly.
To share as much code as possible (which actually is not much), i have added
dmi_fill methods that get called in dmi_init. They are reponsible to fill the
dmi_strings array and setting the is_laptop variable. After it is called, dmi_init
prints all dmi_strings. Previously the strings were printed in the order they were
discovered, followed by the chassis-type, which is now output earlier (in dmi_fill).

Signed-off-by: Sean Nelson<audiohacked@gmail.com>
Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Tested-by: Maciej Pijanka <maciej.pijanka@gmail.com>
Tested-by: Idwer Vollering <vidwer@gmail.com>
Combine serialport_write and serialport_read into serialport_rw.

Because they share almost all code, combine them into serialport_rw
and export the old functions as wrappers. This makes reads "empty reads"-
aware and programmers able to detect such problems even on "blocking"
reads. Also, this fixes error detection on Windows.
Introduce serialport_config().

This allows to easily reconfigure a serial port as needed in
the Bus Pirate speedup.

Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Get rid of sp_die().

- Export msg_perr_strerror()
- Add return values to sp_flush_stream(), sp_pass_writen(),
  sp_execute_opbuf(), sp_execute_opbuf_noflush(),
  sp_check_opbuf_usage(), sp_do_read_n().
- Use those return values to propagate errors instead of exiting.
  In some places this has to wait for core API changes (error handling for
  chip_readb, chip_readn, chip_write) hence comments are added instead.