summaryrefslogtreecommitdiffstats
path: root/hwaccess.c
Commit message (Collapse)AuthorAgeFilesLines
* Various cross-platform fixesCarl-Daniel Hailfinger2013-07-131-3/+2
| | | | | | | | | | | | | | | | | | | | | | | Improve compilation with libpayload (compiling flashrom.c and linking is still broken): - disable Ponyprog (which enforced serial.c compilation) - make errno available where it is needed Fix internal.c for non-x86 and enable cb parsing on ARM. Fix mingw builds by using its __USE_MINGW_ANSI_STDIO macro and gnu_printf definition for printf format style checking. See http://sourceforge.net/apps/trac/mingw-w64/wiki/gnu%20printf This requires inclusion of stdio.h in flash.h. Fix order of libraries in the Makefile: FEATURE_LIBS needs to come *after* PCILIBS in case ZLIB is needed by it. Corresponding to flashrom svn r1697. 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>
* Fix hwaccess (again)Stefan Tauner2013-07-131-11/+16
| | | | | | | | | | | | I completely forgot about NetBSD in r1638 which was broken since then. Also, on OpenBSD use iopl again and refine the warning in case we have insufficient privileges. Thanks to Jonathan A. Kollasch for his help in getting the details right. Corresponding to flashrom svn r1695. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
* Fix building for MacOSXStefan Tauner2013-02-041-3/+4
| | | | | | | | | | | | | | | | | | - Add a new macro named IS_MACOSX to hwaccess.c and use it to enable iopl(). This was broken since r1638. This fix does *not* restore the very permissive concept where iopl() was activated in an #else branch that was inplace before r1638. - Make printing the image file's size in flashrom.c platform independent. Bonus: remove definitions of off64_t and lseek64 which are not necessary anymore for about 1000 commits. Thanks to SJ for reporting the issue and testing the solution. Corresponding to flashrom svn r1648. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
* Fix compilation for DOS and non-x86 targetsCarl-Daniel Hailfinger2013-01-081-12/+7
| | | | | | | | | | Fixup for r1638. Thanks to Idwer Vollering for testing. Corresponding to flashrom svn r1645. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
* Simplify hwaccess.cPeter Lemenkov2012-12-291-68/+42
| | | | | | | | | | | | | | | | | | Previously the code was focused on architectures which led to lots of duplicate code and spread the information regarding differences between the architectures accross the file. With this patch there is a single function header for any function and the differentiation between architectures (and OS where needed) happens in one place for each function. Also, this patch adds simple defines to bundle often used arch and os checks. A central check for unknown architectures and OSes has been added on top. Corresponding to flashrom svn r1638. Signed-off-by: Peter Lemenkov <lemenkov@gmail.com> Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
* Some ISO C fixesCarl-Daniel Hailfinger2012-08-271-1/+1
| | | | | | | | | | | | | | | | | 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>
* Automatically release I/O permissions on shutdownCarl-Daniel Hailfinger2012-07-211-27/+28
| | | | | | | | | | | | | | | | | | | | | Get_io_perms() is renamed to rget_io_perms() and automatically registers a function to release I/O permissions on shutdown. Actually release I/O permissions on Solaris and iopl()-supporting operating systems like Linux. This patch fixes quite a few programmers which forgot to release I/O permissions on shutdown, and it simplifies the shutdown and error handling code for all others. Do not call exit(1) if I/O permissions are denied and return an error instead. This part of the patch was written by Niklas Söderlund. Corresponding to flashrom svn r1551. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Signed-off-by: Niklas Söderlund <niso@kth.se> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
* Hide hwaccess.h from public APIPatrick Georgi2012-07-201-0/+1
| | | | | | | | | | | | | Move hwaccess.h #include from flash.h to individual drivers. libflashrom users need flash.h, but they do not care about hwaccess.h and should not see its definitions because they may conflict with other hardware access functions and #defines used by the libflashrom user. Corresponding to flashrom svn r1549. Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
* Fix parallel-style programmer access from ITE IT87/Winbond W83627 SPICarl-Daniel Hailfinger2012-03-011-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | The ITE IT87 SPI driver uses a trick to speed up reading and writing: If a flash chip is 512 kByte or less, the flash chip can be completely mapped in memory and both read and write accesses are faster that way. The current IT87 SPI code did use the parallel programmer interface for memory mapped reads and writes, but that's the wrong abstraction. It has been fixed to use mmio_read*/mmio_write* for that purpose. The Winbond W83627 SPI driver uses the same trick in its read path for all supported chip sizes. Fix it the same way. Switch internal_chip_readn to use mmio_readn as proper abstraction. Kudos to Michael Karcher for spotting the bugs. Tested-by: Johan Svensson <flashrom.js@crypt.se> Corresponding to flashrom svn r1511. Reported-by: Johan Svensson <flashrom.js@crypt.se> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
* Support Debian/kFreeBSDCarl-Daniel Hailfinger2012-02-251-3/+3
| | | | | | | | | Corresponding to flashrom svn r1507. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Tested-by: Robert Millan <rmh@debian.org> Tested-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
* Support compilation for the ARM architecture (little-endian only)David Hendricks2012-02-131-0/+14
| | | | | | | | | | | | | Note: The internal programmer will abort during processor check. This is intentional. The other hardware drivers (except those using port I/O) should work. Corresponding to flashrom svn r1492. Signed-off-by: David Hendricks <dhendrix@google.com> Acked-by: David Hendricks <dhendrix@google.com> Tested-by: Timo Juhani Lindfors <timo.lindfors@iki.fi> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
* Fix unchecked malloc calls and casts of malloc return valuesStefan Tauner2011-07-121-0/+4
| | | | | | | | | | | | In the long term the exit calls should be replaced by returns. until then this is the correct way to handle failures. the casts are not needed (in C) and we don't cast malloc return values anywhere else. Corresponding to flashrom svn r1370. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
* Use shutdown callback mechanism to shutdown programmersDavid Hendricks2011-06-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch attempts to resolve some programmer shutdown ordering issues by having the programmer init functions register shutdown callbacks explicitly wherever it makes most sense. Before, assumptions were made that could lead to the internal programmer's state changing before the external programmer could be shut down properly. Now, each programmer cleans up after itself and (hopefully) performs each operation in the correct order. As a side-effect, this patch gives us a better usage model for reverse operations such as rpci_* and rmmio_*. In the long-run, this should make reversing the initialization process easier to understand, less tedious, and less error-prone. In short, this patch does the following: - Registers a shutdown callback during initialization for each programmer. - Kills the .shutdown function pointer from programmer_entry struct. Also, make most shutdown functions static. - Adds a few minor clean-ups and corrections (e.g. missing physunmap() calls). TODO: Remove forward declaration of serprog_shutdown() (added to simplify diff) Corresponding to flashrom svn r1338. Signed-off-by: David Hendricks <dhendrix@google.com> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
* Revert MMIO space writes on shutdown as neededCarl-Daniel Hailfinger2011-05-031-0/+101
| | | | | | | | | | | | | | | | | | Reversible MMIO space writes now use rmmio_write*(). Reversible PCI MMIO space writes now use pci_rmmio_write*(). If a MMIO value needs to be queued for restore without writing it, use rmmio_val*(). MMIO space writes which are one-shot (e.g. communication with some chip) should continue to use the permanent mmio_write* variants. Corresponding to flashrom svn r1292. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> David tested it successfully on some NM10/ICH7 platforms which switch between SPI and LPC targets (x86 BIOS ROM vs. EC firmware ROM). Acked-by: David Hendricks <dhendrix@google.com>
* Add support for building flashrom against libpayloadPatrick Georgi2010-09-301-2/+4
| | | | | | | | | | | 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>
* Add OpenBSD supportCarl-Daniel Hailfinger2010-07-021-0/+5
| | | | | | | | | | | | | | Add a requirements section to the man page which lists the needed access permissions for each programmer. This feature needs my pciutils/libpci 8/16-bit write emulation patch at http://marc.info/?l=openbsd-ports&m=127780030728045 titled [PATCH] Fix pciutils non-32bit PCI write on OpenBSD Corresponding to flashrom svn r1067. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stuart Henderson <sthen@openbsd.org>
* Kill unneeded #include wherever possibleCarl-Daniel Hailfinger2010-06-211-3/+8
| | | | | | | | | | Tested on Linux, FreeBSD, NetBSD, OpenBSD, DOS. Thanks to Jonathan A. Kollasch and Idwer Vollering for testing. Corresponding to flashrom svn r1057. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Idwer Vollering <vidwer+lists.flashrom@gmail.com>
* Remove unneeded #include statements completelyCarl-Daniel Hailfinger2010-05-301-0/+1
| | | | | | | | | | | | | | | 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>
* Handle the following architectures in generic flashrom codeCarl-Daniel Hailfinger2010-05-261-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - x86/x86_64 (little endian) - PowerPC (big endian) - MIPS (big+little endian) No changes to programmer specific code. This means any drivers with MMIO access will _not_ suddenly start working on big endian systems, but with this patch everything is in place to fix them. Compilation should work on all architectures listed above for all drivers except nic3com and nicrealtek which require PCI Port IO which is x86-only for now. To compile without nic3com and nicrealtek, run make distclean make CONFIG_NIC3COM=no CONFIG_NICREALTEK=no Thanks to Misha Manulis for testing early versions of this patch on PowerPC (big endian) with the satasii programmer. Thanks to Segher Boessenkool for design review and for helping out with compiler tricks and pointing out that we need eieio on PowerPC. Thanks to Vladimir Serbinenko for compile testing on MIPS (little endian) and PowerPC (big endian) and for runtime testing on MIPS (little endian). Thanks to David Daney for compile testing on MIPS (big endian). Thanks to Uwe Hermann for compile and runtime testing on x86_64. DO NOT RUN flashrom ON NON-X86 AFTER APPLYING THIS PATCH! This patch only provides the infrastructure, but does not convert any drivers, so flashrom will compile, but it won't do the right thing on non-x86 platforms. Corresponding to flashrom svn r1013. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Misha Manulis <misha@manulis.com> Acked-by: Vladimir 'phcoder/φ-coder' Serbinenko <phcoder@gmail.com> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Segher Boessenkool <segher@kernel.crashing.org>
* Convert various prints to use msg_p* and msg_g* respectivelySean Nelson2010-05-071-1/+1
| | | | | | | | | 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>
* Fix the DOS portRudolf Marek2010-04-251-39/+0
| | | | | | | | | | | | Now the DS selector limit is set to 4GB and all mmio accesses goes through DS, the 1:1 mapping is fixed so the _DS base is taken onto account. Plus is that the hwaccess.c needs no change and memcpy etc can be used on mmaped space. Corresponding to flashrom svn r995. Signed-off-by: Rudolf Marek <r.marek@assembler.cz> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
* Add MS-DOS crosscompilation supportRudolf Marek2010-03-161-1/+42
| | | | | | | | | Tested, works fine. Part 1: Code changes. Corresponding to flashrom svn r944. Signed-off-by: Rudolf Marek <r.marek@assembler.cz> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
* Split internal.c into internal.c and hwaccess.cCarl-Daniel Hailfinger2010-02-121-0/+83
Linking in support for the internal programmer doesn't make sense if you only need hardware (ioport, memory) access. Note: This patch was created by "svn cp internal.c hwaccess.c" and then removing stuff from both files. That's why you can't apply the patch as-is before running the svn cp. Corresponding to flashrom svn r898. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Sean Nelson <audiohacked@gmail.com>
OpenPOWER on IntegriCloud