1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

55 Commits

Author SHA1 Message Date
Edward O'Callaghan
50f812cfc7 dmi.c: Pass is_laptop by ref into dmi
Prefix the remaining global cases with `g_` to avoid shadowing
issues and for easy greping.

Change-Id: I3d5ad6c0623269492d775a99a947fd6fe26c5f91
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/71622
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Sam McNally <sammc@google.com>
2023-03-28 00:36:36 +00:00
Felix Singer
6f5c8fdfc3 dmi.c: Retype variable anchored with bool
Use the bool type instead of an integer for the variable `anchored`,
since this represents its purpose much better.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I5bedaf47cdd2fd5d152f69b6b02aab69fd1285c6
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66903
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2022-09-08 02:14:35 +00:00
Edward O'Callaghan
632bdcb9e2 dmi.c: Ensure g_has_dmi_support is default on shutdown
Ensure the g_has_dmi_support variable has the default state
of false after the life-time has expired.

BUG=none
TEST=builds

Change-Id: I0674950304736e53d014117d287682a4f6349879
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/62996
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2022-04-05 22:41:54 +00:00
Edward O'Callaghan
c706e6b52c dmi.c: Hide has_dmi_support global behind method
This allows has_dmi_support to be become static local
to just the scope of dmi.c

BUG=none
TEST=builds

Change-Id: Ibded9714998ea6f2e5d4e0512fa7c6b105f9638a
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/59283
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-04-05 22:39:17 +00:00
Nico Huber
fd4cb2d7b4 dmi: Correctly check for ERROR_PTR
For the physmap*() functions, NULL is considered valid return value.
Fixes a segmentation fault when DMI tables can't be mapped.

Tested on intel/eblake board with broken coreboot.

Change-Id: Ic403c2940c2b91acbd113f0acfa3ce9ef6c6bb6c
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/62611
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2022-03-08 21:50:00 +00:00
Thomas Heijligen
64b9e3f59e hwaccess: move mmio functions into hwaccess_physmap
The mmio_le/be_read/writex functions are used for raw memory access.
Bundle them with the physmap functions.

Change-Id: I313062b078e89630c703038866ac93c651f0f49a
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/61160
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2022-01-20 16:51:01 +00:00
Thomas Heijligen
b8f364bece physmap: rename to hwaccess_physmap, create own header
Line up physmap with the other hwaccess related code.

Change-Id: Ieba6f4e94cfc3e668fcb8b3c978de5908aed2592
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/60113
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-12-22 22:53:47 +00:00
Thomas Heijligen
4ab9bd7ffb hwaccess.c: move function declarations from programmer.h to hwaccess.h
Move declarations for functions implemented in hwaccess.c from
programmer.h to hwaccess.h.

Change-Id: I075fd86211c766ae3d5f29c76adbd7c5b9bdbd80
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58865
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-11-07 17:07:34 +00:00
Thomas Heijligen
f42d2f72cc hwaccess: replace flashrom specific macros by compiler defines
Replace the remaining IS_* macros with the associated compiler defines

Change-Id: Ia0f022d12390722816066d292e1878824adc613c
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58280
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-15 14:37:20 +00:00
Angel Pons
02be851a63 Revert "Makefile: Explicitly set '-std=c99'"
This reverts commit 5e5c3f15efe262ff23642dd543faf6a9dbb3bbdb.

Reason for revert: Breaks building on PowerPC, NetBSD, DJGPP, and it is
possible that SPARC fails to build as well.

Change-Id: I57b5125207de3fd156dface67cba605da893d6aa
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52425
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-04-22 11:24:29 +00:00
Angel Pons
f0ab83f5f4 Use singular they to refer to "the user" in comments
Change-Id: I726006fe2c1780361bdf6f9a1ddd84da0733642d
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52472
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-04-21 14:48:00 +00:00
Edward O'Callaghan
5e5c3f15ef Makefile: Explicitly set '-std=c99'
This matches the build flags that are correctly explicitly defined in
meson.build where-as the Makefile is randomly picking up whatever the
system toolchain happens to default to.

Fix dmi.c while we are here to avoid a re-define of _GNU_SOURCE.

BUG=none
TEST=`make` with both gcc and clang.

Change-Id: I4f973927fc018510a3beaa6c4fa2f356c77c7a6e
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/47908
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Sam McNally <sammc@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-01-13 02:20:46 +00:00
Jacob Garber
4a84ec273a tree: Enable -Wwrite-strings
When compiling, this warning gives string literals the type const char[]
to help catch accidental modification (which is undefined behaviour).
There currently aren't any instances of this in flashrom, so let's
enable this warning to keep it that way. This requires adding const
qualifiers to the declarations of several variables that work with
string literals.

Change-Id: I62d9bc194938a0c9a0e4cdff7ced8ea2e14cc1bc
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/34577
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2019-10-04 14:35:20 +00:00
Nico Huber
519be66fc5 Fix -Wsign-compare trouble
Mostly by changing to `unsigned` types where applicable, sometimes
`signed` types, and casting as a last resort.

Change-Id: I08895543ffb7a48058bcf91ef6500ca113f2d305
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/30409
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jacob Garber <jgarber1@ualberta.ca>
2019-07-31 08:26:59 +00:00
Jacob Garber
beeb8bc925 tree: Make internal functions static
None of these functions are used outside of the files they are defined
in, so make them all static.

Change-Id: Ie9cbe12d289bcedacf2f1bf483ae64ef8039ccc1
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33667
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2019-06-23 21:39:31 +00:00
Elyes HAOUAS
a67ac58dd7 dmi.c: Remove unneeded 'else'
'else' is not needed after a 'break' or 'return'.

Change-Id: I71ab1fec98c2b61d73aeb646ddfc810662d4136d
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33344
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2019-06-21 15:07:47 +00:00
Nico Huber
3a41e2a27e dmi: Remove nonsense guard; Makefile handles it
Change-Id: If4216be1f9ed308e4580c36d0356480e637ffc82
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/28715
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2018-10-23 21:15:53 +00:00
Elyes HAOUAS
ac01baa073 Remove unneeded white spaces
Change-Id: I90f171924790ced74a62ca344fee8607607aa480
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/26652
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2018-06-24 13:44:51 +00:00
Elyes HAOUAS
e083880279 Remove address from GPLv2 headers
Change-Id: I7bfc339673cbf5ee2d2ff7564c4db04ca088d0a4
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/25381
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2018-04-24 20:21:41 +00:00
Stefan Tauner
4f444794de dmi: Don't print dmidecode shell error
Don't print the error "sh: dmidecode: not found" if dmidecode is not there.
Uses stderr redirection to /dev/null (or NUL on Windows).

Change-Id: I3ded8e1bad14b5e809185a79c4e3a17329b1ecb9
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/23802
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2018-03-08 09:17:52 +00:00
Stefan Tauner
23e10b8780 Add a bunch of new/tested stuff and various small changes 24
Tested mainboards:
OK:
 - ASRock G31M-GS
   Reported by Александр Трубицын
 - ASRock G41M-VS3
   Reported by Александр Трубицын
 - ASRock N68C-S UCC
   Reported by Alexey Belyaev
 - ASRock AMCP7AION-HT (ION 330HT(-BD))
   Reported by Stefan Tauner
 - ASUS P5K SE
   Reported by Александр Трубицын
 - ASUS P5KPL-VM
   Reported by Marin Vlah
 - ASUS RAMPAGE III GENE
   Reported by stevessss on IRC
 - GIGABYTE GA-945GM-S2
   Reported by Александр Трубицын
 - GIGABYTE GA-945GCM-S2 (rev. 3.0)
   Reported by Александр Трубицын
 - GIGABYTE GA-965P-S3
   Reported by Александр Трубицын
 - GIGABYTE GA-EG43M-S2H
   Reported by Александр Трубицын
 - GIGABYTE GA-EP31-DS3L (rev. 1.0)
   Reported by Александр Трубицын
 - GIGABYTE GA-G33M-S2
   Reported by Александр Трубицын
 - GIGABYTE GA-G33M-S2L
   Reported by Александр Трубицын
 - GIGABYTE GA-H55M-S2
   Reported by Александр Трубицын
 - GIGABYTE GA-J1900N-D3V
   Reported by Marcos Truchado and Guillermo von Hünefeld
 - GIGABYTE GA-K8NS
   Reported  by nicolae788
 - GIGABYTE GA-M56S-S3
   Reported by Estevo Paz Freire
 - GIGABYTE GA-P31-DS3L
   Reported by Александр Трубицын
 - GIGABYTE GA-P31-S3G
   Reported by Александр Трубицын
 - MSI MS-7336
   Reported by Benjamin Bellec
 - MSI X79A-GD45 (8D) (MS-7760)"
   Reported by mortehu on IRC
 - Supermicro A1SAi-2550F
   Reported by Bernard Grymonpon
 - Supermicro X7DWT
   Reported by Steven Stremciuc

Laptop:
 - ASUS U38N
   Reported by Ultra on IRC
 - Dell Latitude D630
   Reported by Márton Miklós
 - Fujitsu Amilo Xi 3650
   Reported by Elmar Stellnberger
 - Lenovo T400 (whitelisting only)

Chipsets:
 - Mark 8086:1f38 (Intel Avoton/Rangeley) as tested
   Reported by Jeremy Porter and Bernard Grymonpon
 - Add Intel Sunrise Point IDs but no support yet.

Flash chips:
 - Atmel AT45DB321D to PREW (+PREW)
   Reported by The Raven
 - Eon EN25QH32 to PREW (+PREW)
   Reported by Josua Mayer
 - Eon EN25QH64 to PREW (+EW)
   Reported by David s. Alessio
 - GigaDevice GD25LQ64(B) to PREW (+PREW)
   Reported by Greg Tippit
 - Intel 28F001BN/BX-T to PREW (+EW)
   Reported by Lu Xie
 - Micron M25P10-A to PREW (+W)
   Reported by the Raven
 - Micron M25PE40
   Reported by David Wood
 - Micron N25Q128..3E to PREW (+PREW)
   Reported by Miklós Márton
 - Macronix MX25L3273E to PREW (+PREW)
   Reported by Roklobsta on IRC
 - Macronix MX23L6454 to PR (+PR)
   Reported by Steven Honeyman
 - Macronix MX25U6435E/F to PREW (+PREW)
   Reported by Marcos Truchado and Guillermo von Hünefeld
 - PMC Pm25LQ032C to PREW (+EW)
   Reported by Dirk Knop
 - Spansion S25FL016A to PREW (+EW)
   Reported by Márton Miklós
 - Spansion S25FL128S......0 to PREW (+PREW)
   Reported by Jim Houston
 - Spansion S25FL204K to PR (+PR)
   Reported by Thomas Debrunner
 - SST SST49LF016C to PREW (+EW)
   Reported by Steven Stremciuc
 - SST SST39VF040 to PREW (+PREW)
   Reported by Xavier Bourgeois
 - SST SST49LF040B to PREW (+EW)
   Reported by Rikard Åhlund
 - ST M25P10-A to PREW (+W)
   Reported by Martijn Schiedon
 - Winbond W39V040FA to PREW (+EW)
   Reported by Евгений Черкашин
 - Winbond W39V080FA to PREW (+EW)
   Reported by protagonist0 on IRC
 - Winbond W25Q80.W to PREW (+PREW)
   Reported by Miklós Márton
 - Winbond W25X64 to PREW (+REW)
   Reported by Johannes Krampf and Manuel Dejonghe
 - Fix ID of AMIC A25LQ64
   Reported by Roman Titov
 - Fix page size of Spansion S25FL129P......1
   Copy and paste error from the 128S uniform 256kB variant, probably.
 - Add Micron/Numonyx phase-change memory IDs

Miscellaneous:
 - Detect Android target OS.
   No changes are required to build flashrom (excluding programmers
   with NEED_PCI) on Android.
 - Update rayerspi (spipgm) URL
 - Fix max_data_write handling of at45db.
 - Minor refinement of the README
 - Mark board enable for the GA-K8NS variants as tested.
   Tested by "nicolae788" on a board with socket 754.
 - Mark "Multi-system" chassis as non-laptop case.
 - Remove W836xx log requests.
   We got enough (and no one is looking at them for the time being anyway).
 - serprog: improve invalid reply error message, contributed by Urja Rannikko.
 - Remove default include paths for MinGW.
 - Disable implicit rules in the Makefile because we don't need them and they
   just make the build (imperceptibly) slower.
 - Enable our own strnlen() implementation not only on DJGPP but also if
   HAVE_STRNLEN is not defined. This is needed to get older BSDs
   (e.g. NetBSD 6.0, FreeBSD < 8.0) to work.
 - Tiny other stuff.

Corresponding to flashrom svn r1917.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2016-01-23 16:16:49 +00:00
Stefan Tauner
dc62793184 Make strnlen() visible in old versions of glibc
Strnlen() is in POSIX 2008 but was a GNU extension up to glibc 2.10
requiring to define _GNU_SOURCE. This fixes compilation on CentOS 4.9.
Also, move our implementation of strnlen() that was added to support
DJGPP to helpers.c.

Corresponding to flashrom svn r1878.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2015-01-27 18:07:50 +00:00
Stefan Tauner
ff9e6c32c3 dmi.c: make sure we call isprint() correctly
ISO C and POSIX require to call ctype functions with values representable
by unsigned char. We have used a char as input so far which might be
negative and hence get sign-extended.

Corresponding to flashrom svn r1852.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2014-10-19 07:54:27 +00:00
Stefan Tauner
778c6d81c8 dmi.c: Duplicate returned strings because they are meant to be freed
Without this patch dmi_shutdown calls free() on read-only strings.

Corresponding to flashrom svn r1849.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2014-09-05 16:14:11 +00:00
Stefan Tauner
6697f71ade Add a bunch of new/tested stuff and various small changes 21
Tested mainboards:
OK:
 - ASUS F2A85-M
   Reported by various corebooters
 - ASUS M2N-MX SE Plus
   Reported by Antonio
 - ASUS P5LD2
   Reported by François Revol
 - Lenovo ThinkPad T530
   Reported and partially authored by Edward O'Callaghan
 - MSI MS-7502 (Medion MD8833)
   Reported by naq on IRC
 - Shuttle AB61
   Reported by olofolleola4
 - ZOTAC IONITX-F-E
   Reported by Bernardo Kuri

Flash chips:
 - Atmel AT45DB021D to PREW (+PREW)
   Reported by The Raven
 - Atmel AT25F4096 to PREW (+PREW)
   Reported by 공준혁
 - GigaDevice GD25Q16(B) to PREW (+PREW)
   Reported by luxflow@live.com using a GD25Q16BSIG
 - Catalyst CAT28F512
   Mark erase and write as known bad (not implemented)

Miscellaneous:
 - Various spelling corrections by Daniele Forsi.
 - Added and refined a bunch of chips originally investigated by Carl-Daniel.
 - Marked the ARM-USB-OCD-H programmer as tested
   (reported by Ruud Schramp).
 - Tiny other stuff.

Corresponding to flashrom svn r1839.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2014-08-06 15:09:15 +00:00
Stefan Tauner
9972d15e12 Fix garbage handling in DMI strings
Previously we tried to replace garbage characters with <space> directly in
the read-only memory-mapped SMBIOS area(!). This could never have
worked for any DMI strings with garbage and results in a segfault on
machines with such strings.

Thanks to Brian Rak (Supermicro X10SLE-F) and John Pohlman (HP XW9400)
for reporting this issue.

With this patch the strings are duplicated within dmi_string() already,
just before we sanitize them. Also, the limit variable used everywhere
points to the first invalid byte address. Refine respective checks
accordingly.

Corresponding to flashrom svn r1824.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2014-07-13 12:52:15 +00:00
Carl-Daniel Hailfinger
43eac03945 Clean up physmap, fix unaligned mapping problems
Convert all physmaps in dmi.c to use aligned readonly maps.
Convert all physmaps in cbtable.c to use unaligned readonly maps.
Make physunmap() a generic architecture-independent wrapper.
Add physunmap_unaligned() to complement physmap*_unaligned().

Corresponding to flashrom svn r1765.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2014-03-05 00:16:16 +00:00
Stefan Tauner
d1045d8b24 Ensure DMI strings used in dmi_compare() are not NULL
Previously the external DMI decoder did not allow this to happen because
all possible pointers were initialized at startup by the output of
'dmidecode -s ...' which has default values for all supported types.

The now active internal DMI decoder does work differently: it scans the
complete DMI table once and copies the available strings. Therefore, strings
that are not set by the firmware are left at their default value of NULL.

A segfault would arise if the following conditions are all true:
 - the firmware sets up a DMI/SMBIOS table which has at least a correct
   checksum, and
 - that table does *not* define at least one of the DMI strings we use
   for matching (as defined by dmi_strings[] in dmi.c), and
 - there exists a board enable whose PCI IDs are matched by the board,
   and which has a DMI string set that ends with a $ anchor, and
 - the user calls the internal programmer of flashrom without the
   optional mainboard parameter.

This was first observed by Gelip on an abit BF6 using the coreboot port
for the abit BE6-II V2.0.
The segfault was reproduced by Idwer Vollering on an ASUS F2A85-M with
the default DMI values of CONFIG_MAINBOARD_SMBIOS_MANUFACTURER etc.
overwritten and a forged board enable matching his board.
Idwer also verified that this patch fixes the problem, thanks a lot!

Corresponding to flashrom svn r1763.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2013-10-29 01:38:45 +00:00
Niklas Söderlund
5d3072030a Remove exit call and mayfail parameter from physmap_common()
The only call path where exit was reached was from physmap functions.

Callers of physmap() et al. which were not prepared to handle
ERROR_PTR return values have been adjusted.
physmap_try_ro() has been renamed to physmap_ro() and physmap_common()
slightly refactored due to the now removed *FAIL parameters.

Corresponding to flashrom svn r1745.

Signed-off-by: Niklas Söderlund <niso@kth.se>
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2013-09-14 09:02:27 +00:00
Sean Nelson
4c6d3a4b73 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 using CONFIG_INTERNAL_DMI=no.

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 which dmidecode
did not for a long while.

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).

Because DJGPP does not support strnlen a simple implementation was added
for it.

This is still only available on x86; actually it is not even compiled in for other
architectures at all anymore.

Corresponding to flashrom svn r1735.

Signed-off-by: Sean Nelson <audiohacked@gmail.com>
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Tested-by: Maciej Pijanka <maciej.pijanka@gmail.com>
Tested-by: Idwer Vollering <vidwer@gmail.com>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2013-09-11 23:35:03 +00:00
Stefan Tauner
c6fa32d2b5 Introduce msg_*warn
Also, unify all outputs of "Warning:" and "Error:" to use normal
capitalization instead of mixing it with all capitals.

Corresponding to flashrom svn r1643.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Idwer Vollering <vidwer@gmail.com>
2013-01-04 22:54:07 +00:00
Stefan Tauner
4e6d346c6e Fix memleaks in dmi.c
In dmi_init() we populate static char *dmistrings[] with values that get
later compared in dmi_match(). Those strings are actually strduped in
get_dmi_string() and hence need to be freed later. This patch accomplishes
this by registering another shutdown method. Also, the tangling pointers are
nulled when the memories are freed.

This bug was found thanks to valgrind.

Corresponding to flashrom svn r1604.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2012-09-23 12:14:28 +00:00
Carl-Daniel Hailfinger
1c6d2ff03d Some ISO C fixes
This patch just fixes a limited number of bits not conforming to c99 by using
 - __asm__ instead of just asm
 - {0} instead of {} for struct initialization
 - h_addr_list[0] instead of h_addr to access the host address in
   struct hostent
 - #include <strings.h> where needed (for ffs and strcasecmp)

Based on a previous patch by Carl-Daniel.

Corresponding to flashrom svn r1585.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2012-08-27 00:44:42 +00:00
Stefan Tauner
4c5665f9ab Add a bunch of new/tested stuff and various small changes 11
Tested Mainboards:
NOT OK:
 - HP dc7800
   http://paste.flashrom.org/view.php?id=1084

 - add "Low Profile Desktop" to our DMI whitelist
 - fix print_wiki (broken since r1488)

Corresponding to flashrom svn r1502.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2012-02-17 20:03:37 +00:00
Sylvain "ythier" Hitier
3093f8f75e Add a bunch of new/tested stuff and various small changes 7
- add Asus Crosshair IV Extreme to the list of supported boards
  http://www.flashrom.org/pipermail/flashrom/2011-August/007640.html
- add Biostar N68S3+ to the list of supported boards
  http://www.flashrom.org/pipermail/flashrom/2011-September/007788.html
- add P7H55-M LX to the list of supported boards
  although flashrom works correctly, it is marked as not ok, because flashing the
  vendor image will break the LAN interface.
- add GA-X58A-UD7 to the list of supported boards
  http://paste.flashrom.org/view.php?id=739
- add Asus P4P800-VM to print.c
  (has a working board enable)
- add Asus K8V-X to print.c
  reported by florz
  http://paste.flashrom.org/view.php?id=742
- add Intel D865GLC to print.c as non-working (ICH5 with BIOS lock enable)
  reported by jmd on IRC
  http://paste.flashrom.org/view.php?id=775
- add Intel DH67CF to print.c as non-working (H67 with BIOS lock enable and locked ME region)
  http://www.flashrom.org/pipermail/flashrom/2011-September/007789.html
- add ECS P4M800PRO-M (V1.0A) to the list of supported boards
  reported by dweg on IRC (hot flashed a SST49LF040B, original was W39V040B)
- add X8DTU-6TF+ to print.c (needs ME unlocking)
  http://www.flashrom.org/pipermail/flashrom/2011-August/007553.html
- add Shuttle FH67 (used in the SH67H3 barebone) to the list of supported boards
  http://www.flashrom.org/pipermail/flashrom/2011-August/007749.html
- add Tyan S2912 to the list of supported boards
  reported by erlan on IRC
- add ZOTAC GeForce 8200 to the list of supported boards
  http://www.flashrom.org/pipermail/flashrom/2011-August/007612.html

- mark AT25DF321A as TEST_OK_PROBE
  http://www.flashrom.org/pipermail/flashrom/2011-August/007553.html
- mark 28F001BN/BX-T as TEST_OK_PR
  http://www.flashrom.org/pipermail/flashrom/2011-July/007208.html
- rename MX29F002
  http://patchwork.coreboot.org/patch/2794/
- mark SST39SF040 as fully tested
  reported by Florian 'florz' Zumbiehl
  http://paste.flashrom.org/view.php?id=742
- mark SST49LF040B as fully tested
  reported by dweg on IRC and later by Armin on the ml:
  http://www.flashrom.org/pipermail/flashrom/2011-August/007764.html

- mark H55 chipset as OK
  http://www.flashrom.org/pipermail/flashrom/2011-July/007432.html
- mark H67 chipset as OK
  http://www.flashrom.org/pipermail/flashrom/2011-August/007749.html
- mark a MCP61 version as OK
  http://www.flashrom.org/pipermail/flashrom/2011-September/007788.html
- add preliminary X79 (patsburg) PCI IDs
  0x1d40 was reported already as working (not archived in our pipermail?)
  http://marc.info/?l=flashrom&m=130683026218257&w=2

- mark "82557/8/9/0/1 Ethernet Pro 100" in nicintel.c as working
  http://www.flashrom.org/pipermail/flashrom/2011-August/007480.html

- rename some chips that had gratuitous "probing" suffixes:
  - SST25VF010.REMS
  - SST25VF040.REMS
  - M25P05.RES
  - M25P10.RES
  some other chip names with suffixes are needed due to lack of support
  for multiple probe functions per chip. this is explained here:
  http://www.flashrom.org/pipermail/flashrom/2011-August/007597.html

- remove unneeded nicintel_spi-related function declarations in programmer.h

- typos and whitespace fixes

- fix Asus P4P800-E Deluxe detection
  The original board enable was added before DMI matching and used
  the IDs of a Promise controller as secondary PCI ID set. The
  controller could be disabled in the BIOS which would make the
  board not match. This patch uses the SMBus controller instead and
  adds a DMI pattern. This was
Tested-by: Michael Schneider <vdrportal_midas at gmx dot de>

Corresponding to flashrom svn r1425.

- add "Sealed-case PC" to the list of chassis type (as indicating "not a laptop")
This is
Acked-by: Idwer Vollering <vidwer@gmail.com>

the fix for the typo unusued -> unused is
Signed-off-by: Sylvain "ythier" Hitier <sylvain.hitier@gmail.com>

everything else is
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>

And everything was reviewed and
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2011-09-03 11:22:27 +00:00
Carl-Daniel Hailfinger
082c8b559c Fixup of r1397
- Mixing uninitialized and initialized local variables leads to
  confusion.
- ft2232_spi error cases should have gotten some error handling, and
  that's the reason the curly braces were there.
- Fixing typos/wording in some places would have been nice given that
  those places were touched anyway.

Corresponding to flashrom svn r1413.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2011-08-15 19:54:20 +00:00
Uwe Hermann
91f4afa110 Random whitespace and coding-style fixes
Also, indentation fixes, e.g. due to conversion to msg_*, use ARRAY_SIZE
where possible, wrap overly long line, etc.

Compile-tested. There should be no functional changes.

Corresponding to flashrom svn r1397.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2011-07-28 08:13:25 +00:00
Stefan Tauner
a34d719037 Be more refined regarding DMI chassis types
We had broken laptops in the past that were not detected as such because
their DMI chassis-type was either undefined/out-of-spec, or set to
'other' or 'unknown'.

this patch tries to mitigate this problem as follows:
- if the DMI chassis-type clearly identifies the system as
  laptop/notebook/mobile platform then nothing changes: the user gets
  the laptop warning without a hint to the force switch.
- if the DMI chassis-type is not specific enough, we warn the user
  similarly, but tell them the switch.

to reduce the number of false positives i have added a few new
chassis types that we have encountered in the last months to the list.

Corresponding to flashrom svn r1390.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2011-07-26 00:54:42 +00:00
Cristian Măgherușan-Stanciu
9932c7bebf Add a bunch of new/tested stuff and various small changes 4
- add Asus E35M1-I DELUXE to boards_known
  http://www.flashrom.org/pipermail/flashrom/2011-June/006918.html
- add Asus M3A to boards_known
  http://www.flashrom.org/pipermail/flashrom/2011-July/007085.html
- add Freetech P6F91i to boards_known
  http://www.flashrom.org/pipermail/flashrom/2011-June/006800.html
- add GA-M720-US3 to boards_known
  http://www.flashrom.org/pipermail/flashrom/2011-July/007096.html
- add GA-MA770-UD3 (rev. 2.1) to boards_known
  http://www.flashrom.org/pipermail/flashrom/2011-June/006879.html
- add GA-965GM-S2 to boards_known
  http://www.flashrom.org/pipermail/flashrom/2011-June/006746.html
- add HP xw4400 (0A68h) to boards_known
  http://paste.flashrom.org/view.php?id=686
- add MSI MS-6566 (845 Ultra-C) to boards_known
  http://www.flashrom.org/pipermail/flashrom/2011-June/006908.html
- add MSI MS-7698 (E350IA-E45) to boards_known
  http://www.flashrom.org/pipermail/flashrom/2011-June/007003.html
- add PCCHIPS M863G (V5.1A) to boards_known
  http://www.flashrom.org/pipermail/flashrom/2011-July/007084.html

- modify the X8SIE entry in boards_known with the information from "fuzzy"
  http://paste.flashrom.org/view.php?id=669

- mark W29C020(C)/W29C022 as fully tested
  http://www.flashrom.org/pipermail/flashrom/2011-June/006800.html
- mark W49V002A as fully tested
  http://www.flashrom.org/pipermail/flashrom/2011-July/007084.html
- mark M25P128 as fully tested
  http://www.flashrom.org/pipermail/flashrom/2011-June/006843.html
- mark SST39SF010A as fully tested
  http://www.flashrom.org/pipermail/flashrom/2011-July/007115.html

- correct entries for GA-K8NS Pro-939 (was ultra before. thanks uwe!)
- another tiny fix for "a small fix"/r1321
  Without this you will get broken bus names "Unknow" and "Non-SP".
  Note to self: don't self-ack even fairly trivial patches.
- fix spew output of spi_rems in spi25.c
- add URL to ASUS M3A76-CM
- rename all Winbond W25x chips to W25X
- fixes some common misspellings/typos in comments:
  lenght->length              2
  ocassional->occasional      1
  unsucessfull->unsuccessful  1
  upto->up to                 5

Corresponding to flashrom svn r1367.

the patch for M25P128 is
Signed-off-by: Cristian Măgherușan-Stanciu <cristi.magherusan@gmail.com>

the typos are
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>

everything else is
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2011-07-07 19:56:58 +00:00
Carl-Daniel Hailfinger
cb3eb05172 Add list with DMI chassis types
Half a dozen hardcoded strcmp() don't make sense if we need a
chassis-type list anyway once we merge the internal DMI decoder. Provide
and array of the most interesting chassis types and annotate them with
laptop/non-laptop status. Match the dmidecode chassis type against the
strings in the array.

Corresponding to flashrom svn r1182.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2010-09-26 21:43:53 +00:00
Michael Karcher
d9f266d1fb Add dmidecode quirk workaround
Dmidecode emits a warning message about unsupported SMBIOS versions
to stdout before the information asked for when using "-s". I consider
this behaviour broken, but we still need to workaround it as e.g. Fedora
currently distributes an dmidecode with this behaviour.

Corresponding to flashrom svn r1136.

Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2010-08-08 21:56:52 +00:00
Carl-Daniel Hailfinger
5b997c3ed6 Split off programmer.h from flash.h
Programmer specific functions are of absolutely no interest to any file
except those dealing with programmer specific actions (special SPI
commands and the generic core).

The new header structure is as follows (and yes, improvements are
possible):
flashchips.h  flash chip IDs
chipdrivers.h  chip-specific read/write/... functions
flash.h  common header for all stuff that doesn't fit elsewhere
hwaccess.h hardware access functions
programmer.h  programmer specific functions
coreboot_tables.h  header from coreboot, internal programmer only
spi.h SPI command definitions

Corresponding to flashrom svn r1112.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2010-07-27 22:41:39 +00:00
Carl-Daniel Hailfinger
ad3cc55e13 Kill global variables, constants and functions if local scope suffices
Constify variables where possible.
Initialize programmer-related variables explicitly in programmer_init to
allow running programmer_init from a clean state after
programmer_shutdown.
Prohibit registering programmer shutdown functions before init or after
shutdown.
Kill some dead code.
Rename global variables with namespace-polluting names.
Use a previously unused locking helper function in sst49lfxxxc.c.

This is needed for libflashrom.

Effects on the binary size of flashrom are minimal (300 bytes
shrinkage), but the data section shrinks by 4384 bytes, and that's a
good thing if flashrom is operating in constrained envionments.

Corresponding to flashrom svn r1068.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2010-07-03 11:02:10 +00:00
Carl-Daniel Hailfinger
e1fdff4472 If flashrom is standalone and has no OS below, it can't call dmidecode
Provide empty DMI stubs for that case until someone implements our own
dmidecode subset.

Tested by Patrick Georgi on top of libpayload.

Corresponding to flashrom svn r1058.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Patrick Georgi <patrick.georgi@coresystems.de>
2010-06-23 23:14:44 +00:00
Sean Nelson
316a29f33f Convert various prints to use msg_p* and msg_g* respectively
Convert programmer print messages to msg_p* convert general print messages to msg_g* a few fixes as suggested by Carl-Daniel.

Corresponding to flashrom svn r997.

Signed-off-by: Sean Nelson <audiohacked@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-05-07 20:09:04 +00:00
Carl-Daniel Hailfinger
270237687a One of the problems is that --force had multiple meanings
- Force chip read by faking probe success.
- Force chip access even if the chip is bigger than max decode size for
  the flash bus.
- Force erase even if erase is known bad.
- Force write even if write is known bad.
- Force writing even if cbtable tells us that this is the wrong image
  for this board.

This patch cleans up --force usage:
- Remove any suggestions to use --force for probe/read from flashrom
  output.
- Don't talk about "success" or "Found chip" if the chip is forced.
- Add a new internal programmer parameter boardmismatch=force. This
  overrides any mismatch detection from cbtable/image comparisons.
- Add a new internal programmer parameter laptop=force_I_want_a_brick.
- Adjust the documentation for --force.
- Clean up the man page a bit whereever it talks about --force or
  laptops.

Additional changes in this patch:
- Add warnings about laptops to the documentation.
- Abort if a laptop is detected. Can be overridden with the programmer
parameter mentioned above.
- Add "Portable" to the list of DMI strings indicating laptops.
- Check if a chip specified with -c is known to flashrom.
- Programmer parameter reliability and consistency fixes.
- More paranoid self-checks.
- Improve documentation.

Corresponding to flashrom svn r996.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2010-04-28 15:22:14 +00:00
Michael Karcher
45f79cb279 Fix handling of empty dmidecode output
Corresponding to flashrom svn r973.

Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-03-24 17:55:04 +00:00
Michael Karcher
fd41670dd6 Skip DMI laptop check if DMI doesn't work
Also further removes dead code from dmi.c and adds a missing newline.

Corresponding to flashrom svn r936.

Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-03-14 17:57:52 +00:00
Uwe Hermann
439597032e Various coding style and cosmetic changes
- Fix coding-style, whitespace, and indentation in a few places.

 - Consistently use the same spelling ("Super I/O") everywhere.

Corresponding to flashrom svn r933.

 - Make some flashrom stdout output look a bit nicer.
 
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2010-03-13 17:28:29 +00:00
Michael Karcher
8c1df280e3 Warn if running on laptops
Corresponding to flashrom svn r916.

Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-02-26 09:51:20 +00:00