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

30 Commits

Author SHA1 Message Date
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
Patrick Georgi
97bc95ce2b Fix and improve libpayload platform support
- Fix various minor compile issues (eg. include necessary standard headers)
- Fix compilation of libpayload code paths
- Provide libpayload support in Makefile
- Add make target "libflashrom.a" which links non-CLI code to static
  library

Corresponding to flashrom svn r1280.

Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>
Tested-with-DOS-crosscompiler-by: Idwer Vollering <vidwer@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2011-03-08 07:17:44 +00:00
Peter Huewe
73f8ec8b1e Fix sparse warning: Using plain integer as NULL pointer
This patch fixes the "using plain integer as NULL pointer" warnings
generated by running sparse on the flashrom source.

Corresponding to flashrom svn r1255.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Acked-by: Mathias Krause <mathias.krause@secunet.com>
Acked-by: Stefan Reinauer <stepan@coreboot.org>
2011-01-24 19:15:51 +00:00
Patrick Georgi
a9095a9545 Add support for building flashrom against libpayload
This doesn't include changes to the frontend which must be
done separately, so this won't work out of the box.
This code was tested on hardware.

Corresponding to flashrom svn r1184.

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-09-30 17:03:32 +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
9f5f2158a7 Gcc and clang can check format strings of printf-like functions
Since we don't support any other compilers right now, enable that
extension unconditionally.

Fix the bugs found by format string checking.

Corresponding to flashrom svn r1032.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2010-06-04 23:20:21 +00:00
Carl-Daniel Hailfinger
b929d110c1 Measure OS timer precision to refine calibration
Do not trust the OS at all and measure timer precision before
calibrating the delay loop and use that measurement to get reasonable
precision for our own delay code.

Print a measurement for a delay of 4x the OS timer resolution.

Be precise about how bad the deviation was if we had to recalculate.

Tested on Windows XP, 32 bit, built using MinGW by Uwe. Tested on
FreeDOS v1.0 Final, 32bit, built using DJGPP 4.3.2 by Idwer.

Corresponding to flashrom svn r1028.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Idwer Vollering <vidwer+lists.flashrom@gmail.com>
2010-06-03 21:48:13 +00:00
Carl-Daniel Hailfinger
831e8f4abb Remove unneeded #include statements completely
Unistd.h was only used to get a definition of NULL in all files. Add our
own NULL #define and remove unistd.h from flash.h
stdio.h has no place in flash.h, it should be included only in files
which really need it.
Add #include statements in individual .c files where needed.

Replace a few printf with msg_* to eliminate the need for stdio.h.

Corresponding to flashrom svn r1021.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2010-05-30 22:24:40 +00:00
Urja Rannikko
f640401e92 Reinitialize the delay loop upon recalibration
Fix an unescaped % in a format specifier.

Corresponding to flashrom svn r992.

Signed-off-by: Urja Rannikko <urjaman@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-04-09 00:02:38 +00:00
Carl-Daniel Hailfinger
253101e69e Refine and fix the delay loop calculation
The current delay loop calculation is still from revision 1 of flashrom,
and since then it had a logic bug which caused all delays to be twice as
long as intended.

Fix the delay duration.

Protect against delay loop overflows.

Detect a non-working delay loop.

Change the delay loop itself to ensure clever compiler optimizers won't
eliminate it (as happens with clang/llvm in the current code). Some
people suggested machine-specific asm, but the empty asm statement with
the loop counter as register/memory input has the benefit of being
perfectly cross-platform and working in gcc and clang.

If time goes backwards (catastrophical NTP time difference, manual
time change), timing measurements were shot because the new-old time
subtraction yielded negative numbers which weren't handled correctly
because the variable is unsigned. Work around that issue (a fix is
mathematically impossible).

If time goes forward too fast, pick the biggest possible timing
measurement with a guaranteed overflow avoidance for all timing
calculations.

Check four times if the calculated timing is at most 10% too fast. This
addresses OS scheduler interactions, e.g. being scheduled out during
measurement which inflates measurements.

If the timing looks like garbage, recalculate the timer values up to
four times before giving up.

Avoid division by zero in rare cases where timing measurements for a 250
ms delay returned 0 us elapsed.

Corresponding to flashrom svn r990.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Maciej Pijanka <maciej.pijanka@gmail.com>
2010-03-31 23:55:06 +00:00
Carl-Daniel Hailfinger
b811461abb The delay loop is probably one of the oldest pieces of code
Clean up code duplication and measure timing of 10/100/1000/10000 us
delays.

Corresponding to flashrom svn r986.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Maciej Pijanka <maciej.pijanka@gmail.com>
2010-03-27 16:16:01 +00:00
Carl-Daniel Hailfinger
36cc1c8144 Internal.c was always compiled in because it hosted the function internal_delay()
Move that function to udelay.c and compile internal.c only if really
needed. physmap.c is only needed if the programmer is internal or a PCI
card. Make its compilation conditional.

Corresponding to flashrom svn r822.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Idwer Vollering <vidwer@gmail.com>
2009-12-24 03:11:55 +00:00
Carl-Daniel Hailfinger
ca8bfc6c22 Add programmer-specific delay functions
Add external programmer delay functions so external programmers can
handle the delay on their own if needed.

Corresponding to flashrom svn r578.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Urja Rannikko <urjaman@gmail.com>
2009-06-05 17:48:08 +00:00
Uwe Hermann
2cac6860c3 Drop unused/duplicated #includes and some dead code
Build-tested on 32bit x86.

Corresponding to flashrom svn r521.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2009-05-16 22:05:42 +00:00
Uwe Hermann
7b2969be53 Some coding style and consistency fixes
Corresponding to flashrom svn r429 and coreboot v2 svn r4117.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2009-04-15 10:52:49 +00:00
Uwe Hermann
394131ef14 Coding-style fixes for flashrom, partly indent-aided
Corresponding to flashrom svn r326 and coreboot v2 svn r3669.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2008-10-18 21:14:13 +00:00
Peter Stuge
80d667b518 Debug print actual time base calculated by myusec_calibrate_delay()
Corresponding to flashrom svn r314 and coreboot v2 svn r3569.

Signed-off-by: Peter Stuge <peter@stuge.se>
Acked-by: Peter Stuge <peter@stuge.se>
2008-09-07 03:14:27 +00:00
Uwe Hermann
a502dcea3d Some cosmetic cleanups in the flashrom code and output
Corresponding to flashrom svn r151 and coreboot v2 svn r2873.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2007-10-17 23:55:15 +00:00
Uwe Hermann
ac30934194 Revert my last cleanup patch
Corresponding to flashrom svn r143 and coreboot v2 svn r2847.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2007-10-10 17:42:20 +00:00
Uwe Hermann
17d00abf0a Cosmetic changes to make the flashrom output more consistent
Corresponding to flashrom svn r142 and coreboot v2 svn r2846.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2007-10-10 16:31:30 +00:00
Uwe Hermann
d22a1d4e53 Add '(C)' where it's missing (for consistency reasons)
Corresponding to flashrom svn r136 and coreboot v2 svn r2768.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2007-09-09 20:21:05 +00:00
Uwe Hermann
ca7f0e4668 Add missing license header to udelay.c
I'm self-ack'ing this, as the origin of the code in udelay.c (and thus
the license and copyright owner) is pretty clear.

The code which is now in udelay.c was split out from flash_rom.c in r1428,
and flash_rom.c, in turn, has been around since the beginning and had a
'Copyright 2000 Silicon Integrated System Corporation' line as well as the
usual GPLv2-or-later license header.

Corresponding to flashrom svn r135 and coreboot v2 svn r2767.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2007-09-09 20:02:45 +00:00
Uwe Hermann
0846f89b0a Drop a bunch of useless header files, merge them into flash.h
Corresponding to flashrom svn r128 and coreboot v2 svn r2746.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2007-08-23 13:34:59 +00:00
Stefan Reinauer
7038564346 Trivial (cosmetic) cleanup
* Only open /dev/mem once and do it early.
* Drop extern for function prototypes.
* Minimize ts5300 impact in probe_flash()

This cleanup will making ICH7 SPI support quite some easier.

Corresponding to flashrom svn r100 and coreboot v2 svn r2585.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2007-04-06 11:58:03 +00:00
Uwe Hermann
0b7afe65fb Coding style fixes
Corresponding to flashrom svn r97 and coreboot v2 svn r2577.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2007-04-01 19:44:21 +00:00
Ollie Lho
184a404033 Flashrom update from Stefan, resolve issue 21
Corresponding to flashrom svn r34 and coreboot v2 svn r2111.
2005-11-26 21:55:36 +00:00
Ollie Lho
761bf1bdb7 Consolidate more jedec standard code
Corresponding to flashrom svn r15 and coreboot v2 svn r1457.
2004-03-20 16:46:10 +00:00
Ollie Lho
cf29de8798 Fix 32bit vs. 64bit long int arithematics
Corresponding to flashrom svn r8 and coreboot v2 svn r1434.
2004-03-18 19:40:07 +00:00
Ollie Lho
cec287936c Use standard product ID exit method for w49f002u
Corresponding to flashrom svn r7 and coreboot v2 svn r1433.
2004-03-17 23:03:37 +00:00
Ollie Lho
cbbf125981 Move utility functions into new source files
Corresponding to flashrom svn r6 and coreboot v2 svn r1428.
2004-03-17 22:22:08 +00:00