Some programmers (most notably FT2232SPI) use fallback_* and noop_*, but those functions lived inside internal.c and were unavailable if no PCI-based programmers were compiled in. Move those functions to the new file programmer.c. Thanks to Patrick Georgi for finding this.
In the future, we should move other stuff to programmer.c as well, especially programmer definitions and wrappers which now live in flashrom.c.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-fallback_noop_programmerc/flash.h =================================================================== --- flashrom-fallback_noop_programmerc/flash.h (Revision 828) +++ flashrom-fallback_noop_programmerc/flash.h (Arbeitskopie) @@ -370,6 +370,8 @@ uint8_t mmio_readb(void *addr); uint16_t mmio_readw(void *addr); uint32_t mmio_readl(void *addr); + +/* programmer.c */ int noop_shutdown(void); void *fallback_map(const char *descr, unsigned long phys_addr, size_t len); void fallback_unmap(void *virt_addr, size_t len); Index: flashrom-fallback_noop_programmerc/Makefile =================================================================== --- flashrom-fallback_noop_programmerc/Makefile (Revision 828) +++ flashrom-fallback_noop_programmerc/Makefile (Arbeitskopie) @@ -50,7 +50,7 @@
CLI_OBJS = flashrom.o print.o
-PROGRAMMER_OBJS = udelay.o +PROGRAMMER_OBJS = udelay.o programmer.o
all: pciutils features dep $(PROGRAM)
Index: flashrom-fallback_noop_programmerc/programmer.c =================================================================== --- flashrom-fallback_noop_programmerc/programmer.c (Revision 0) +++ flashrom-fallback_noop_programmerc/programmer.c (Revision 0) @@ -0,0 +1,99 @@ +/* + * This file is part of the flashrom project. + * + * Copyright (C) 2009,2010 Carl-Daniel Hailfinger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdlib.h> +#include "flash.h" + +/* No-op shutdown() for programmers which don't need special handling */ +int noop_shutdown(void) +{ + return 0; +} + +/* Fallback map() for programmers which don't need special handling */ +void *fallback_map(const char *descr, unsigned long phys_addr, size_t len) +{ + /* FIXME: Should return phys_addr. */ + return 0; +} + +/* No-op/fallback unmap() for programmers which don't need special handling */ +void fallback_unmap(void *virt_addr, size_t len) +{ +} + +/* No-op chip_writeb() for drivers not supporting addr/data pair accesses */ +uint8_t noop_chip_readb(const chipaddr addr) +{ + return 0xff; +} + +/* No-op chip_writeb() for drivers not supporting addr/data pair accesses */ +void noop_chip_writeb(uint8_t val, chipaddr addr) +{ +} + +/* Little-endian fallback for drivers not supporting 16 bit accesses */ +void fallback_chip_writew(uint16_t val, chipaddr addr) +{ + chip_writeb(val & 0xff, addr); + chip_writeb((val >> 8) & 0xff, addr + 1); +} + +/* Little-endian fallback for drivers not supporting 16 bit accesses */ +uint16_t fallback_chip_readw(const chipaddr addr) +{ + uint16_t val; + val = chip_readb(addr); + val |= chip_readb(addr + 1) << 8; + return val; +} + +/* Little-endian fallback for drivers not supporting 32 bit accesses */ +void fallback_chip_writel(uint32_t val, chipaddr addr) +{ + chip_writew(val & 0xffff, addr); + chip_writew((val >> 16) & 0xffff, addr + 2); +} + +/* Little-endian fallback for drivers not supporting 32 bit accesses */ +uint32_t fallback_chip_readl(const chipaddr addr) +{ + uint32_t val; + val = chip_readw(addr); + val |= chip_readw(addr + 2) << 16; + return val; +} + +void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len) +{ + size_t i; + for (i = 0; i < len; i++) + chip_writeb(buf[i], addr + i); + return; +} + +void fallback_chip_readn(uint8_t *buf, chipaddr addr, size_t len) +{ + size_t i; + for (i = 0; i < len; i++) + buf[i] = chip_readb(addr + i); + return; +} Index: flashrom-fallback_noop_programmerc/internal.c =================================================================== --- flashrom-fallback_noop_programmerc/internal.c (Revision 828) +++ flashrom-fallback_noop_programmerc/internal.c (Arbeitskopie) @@ -247,80 +247,3 @@ { return *(volatile uint32_t *) addr; } - -/* No-op shutdown() for programmers which don't need special handling */ -int noop_shutdown(void) -{ - return 0; -} - -/* Fallback map() for programmers which don't need special handling */ -void *fallback_map(const char *descr, unsigned long phys_addr, size_t len) -{ - /* FIXME: Should return phys_addr. */ - return 0; -} - -/* No-op/fallback unmap() for programmers which don't need special handling */ -void fallback_unmap(void *virt_addr, size_t len) -{ -} - -/* No-op chip_writeb() for drivers not supporting addr/data pair accesses */ -uint8_t noop_chip_readb(const chipaddr addr) -{ - return 0xff; -} - -/* No-op chip_writeb() for drivers not supporting addr/data pair accesses */ -void noop_chip_writeb(uint8_t val, chipaddr addr) -{ -} - -/* Little-endian fallback for drivers not supporting 16 bit accesses */ -void fallback_chip_writew(uint16_t val, chipaddr addr) -{ - chip_writeb(val & 0xff, addr); - chip_writeb((val >> 8) & 0xff, addr + 1); -} - -/* Little-endian fallback for drivers not supporting 16 bit accesses */ -uint16_t fallback_chip_readw(const chipaddr addr) -{ - uint16_t val; - val = chip_readb(addr); - val |= chip_readb(addr + 1) << 8; - return val; -} - -/* Little-endian fallback for drivers not supporting 32 bit accesses */ -void fallback_chip_writel(uint32_t val, chipaddr addr) -{ - chip_writew(val & 0xffff, addr); - chip_writew((val >> 16) & 0xffff, addr + 2); -} - -/* Little-endian fallback for drivers not supporting 32 bit accesses */ -uint32_t fallback_chip_readl(const chipaddr addr) -{ - uint32_t val; - val = chip_readw(addr); - val |= chip_readw(addr + 2) << 16; - return val; -} - -void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len) -{ - size_t i; - for (i = 0; i < len; i++) - chip_writeb(buf[i], addr + i); - return; -} - -void fallback_chip_readn(uint8_t *buf, chipaddr addr, size_t len) -{ - size_t i; - for (i = 0; i < len; i++) - buf[i] = chip_readb(addr + i); - return; -}
Am 05.01.2010 23:33, schrieb Carl-Daniel Hailfinger:
Some programmers (most notably FT2232SPI) use fallback_* and noop_*, but those functions lived inside internal.c and were unavailable if no PCI-based programmers were compiled in. Move those functions to the new file programmer.c. Thanks to Patrick Georgi for finding this.
With this patch, it builds. Thank you!
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Acked-by: Patrick Georgi patrick.georgi@coresystems.de
On 06.01.2010 11:10, Patrick Georgi wrote:
Am 05.01.2010 23:33, schrieb Carl-Daniel Hailfinger:
Some programmers (most notably FT2232SPI) use fallback_* and noop_*, but those functions lived inside internal.c and were unavailable if no PCI-based programmers were compiled in. Move those functions to the new file programmer.c. Thanks to Patrick Georgi for finding this.
With this patch, it builds. Thank you!
You're welcome.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Acked-by: Patrick Georgi patrick.georgi@coresystems.de
Thanks, committed in r829.
Regards, Carl-Daniel