Author: hailfinger Date: 2009-09-16 12:09:21 +0200 (Wed, 16 Sep 2009) New Revision: 724
Modified: trunk/Makefile trunk/flash.h trunk/flashrom.c trunk/internal.c trunk/print.c trunk/spi.c Log: Allow to exclude each of the external programmer drivers from being compiled in.
Example make commandline if you want only internal programmers: make CONFIG_FT2232SPI=no CONFIG_SERPROG=no CONFIG_NIC3COM=no CONFIG_SATASII=no CONFIG_DRKAISER=no CONFIG_DUMMY=no
Of course, all of the CONFIG_* symbols can be mixed and matched as needed. CONFIG_FT2232SPI is special because even if it is enabled, make will check if the headers are available and skip it otherwise.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net Acked-by: Stefan Reinauer stepan@coresystems.de
Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-09-16 08:26:59 UTC (rev 723) +++ trunk/Makefile 2009-09-16 10:09:21 UTC (rev 724) @@ -49,8 +49,7 @@ sst49lfxxxc.o sst_fwhub.o layout.o cbtable.o flashchips.o physmap.o \ flashrom.o w39v080fa.o sharplhf00l04.o w29ee011.o spi.o it87spi.o \ ichspi.o w39v040c.o sb600spi.o wbsio_spi.o m29f002.o internal.o \ - dummyflasher.o pcidev.o nic3com.o satasii.o ft2232_spi.o \ - print.o drkaiser.o + pcidev.o print.o
all: pciutils features dep $(PROGRAM)
@@ -67,8 +66,23 @@ SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
# Always enable serprog for now. Needs to be disabled on Windows. -CONFIG_SERPROG = yes +CONFIG_SERPROG ?= yes
+# Always enable 3Com NICs for now. +CONFIG_NIC3COM ?= yes + +# Always enable SiI SATA controllers for now. +CONFIG_SATASII ?= yes + +# Always enable FT2232 SPI dongles for now. +CONFIG_FT2232SPI ?= yes + +# Always enable dummy tracing for now. +CONFIG_DUMMY ?= yes + +# Always enable Dr. Kaiser for now. +CONFIG_DRKAISER ?= yes + ifeq ($(CONFIG_SERPROG), yes) FEATURE_CFLAGS += -D'SERPROG_SUPPORT=1' OBJS += serprog.o @@ -77,10 +91,33 @@ endif endif
+ifeq ($(CONFIG_NIC3COM), yes) +FEATURE_CFLAGS += -D'NIC3COM_SUPPORT=1' +OBJS += nic3com.o +endif + +ifeq ($(CONFIG_SATASII), yes) +FEATURE_CFLAGS += -D'SATASII_SUPPORT=1' +OBJS += satasii.o +endif + +ifeq ($(CONFIG_FT2232SPI), yes) +# This is a totally ugly hack. FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'FT2232_SPI_SUPPORT=1'") - FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-lftdi") +OBJS += ft2232_spi.o +endif
+ifeq ($(CONFIG_DUMMY), yes) +FEATURE_CFLAGS += -D'DUMMY_SUPPORT=1' +OBJS += dummyflasher.o +endif + +ifeq ($(CONFIG_DRKAISER), yes) +FEATURE_CFLAGS += -D'DRKAISER_SUPPORT=1' +OBJS += drkaiser.o +endif + $(PROGRAM): $(OBJS) $(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS) $(FEATURE_LIBS)
Modified: trunk/flash.h =================================================================== --- trunk/flash.h 2009-09-16 08:26:59 UTC (rev 723) +++ trunk/flash.h 2009-09-16 10:09:21 UTC (rev 724) @@ -82,10 +82,18 @@
enum programmer { PROGRAMMER_INTERNAL, +#if DUMMY_SUPPORT == 1 PROGRAMMER_DUMMY, +#endif +#if NIC3COM_SUPPORT == 1 PROGRAMMER_NIC3COM, +#endif +#if DRKAISER_SUPPORT == 1 PROGRAMMER_DRKAISER, +#endif +#if SATASII_SUPPORT == 1 PROGRAMMER_SATASII, +#endif PROGRAMMER_IT87SPI, #if FT2232_SPI_SUPPORT == 1 PROGRAMMER_FT2232SPI, @@ -375,10 +383,11 @@ uint16_t mmio_readw(void *addr); uint32_t mmio_readl(void *addr); void internal_delay(int usecs); -int fallback_shutdown(void); +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); -void fallback_chip_writeb(uint8_t val, chipaddr addr); +uint8_t noop_chip_readb(const chipaddr addr); +void noop_chip_writeb(uint8_t val, chipaddr addr); void fallback_chip_writew(uint16_t val, chipaddr addr); void fallback_chip_writel(uint32_t val, chipaddr addr); void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len); @@ -474,7 +483,9 @@ #if FT2232_SPI_SUPPORT == 1 SPI_CONTROLLER_FT2232, #endif +#if DUMMY_SUPPORT == 1 SPI_CONTROLLER_DUMMY, +#endif SPI_CONTROLLER_INVALID /* This must always be the last entry. */ }; extern const int spi_programmer_count;
Modified: trunk/flashrom.c =================================================================== --- trunk/flashrom.c 2009-09-16 08:26:59 UTC (rev 723) +++ trunk/flashrom.c 2009-09-16 10:09:21 UTC (rev 724) @@ -54,6 +54,7 @@ .delay = internal_delay, },
+#if DUMMY_SUPPORT == 1 { .name = "dummy", .init = dummy_init, @@ -70,7 +71,9 @@ .chip_writen = dummy_chip_writen, .delay = internal_delay, }, +#endif
+#if NIC3COM_SUPPORT == 1 { .name = "nic3com", .init = nic3com_init, @@ -87,7 +90,9 @@ .chip_writen = fallback_chip_writen, .delay = internal_delay, }, +#endif
+#if DRKAISER_SUPPORT == 1 { .name = "drkaiser", .init = drkaiser_init, @@ -104,7 +109,9 @@ .chip_writen = fallback_chip_writen, .delay = internal_delay, }, +#endif
+#if SATASII_SUPPORT == 1 { .name = "satasii", .init = satasii_init, @@ -121,18 +128,19 @@ .chip_writen = fallback_chip_writen, .delay = internal_delay, }, +#endif
{ .name = "it87spi", .init = it87spi_init, - .shutdown = fallback_shutdown, + .shutdown = noop_shutdown, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, - .chip_readb = dummy_chip_readb, + .chip_readb = noop_chip_readb, .chip_readw = fallback_chip_readw, .chip_readl = fallback_chip_readl, .chip_readn = fallback_chip_readn, - .chip_writeb = fallback_chip_writeb, + .chip_writeb = noop_chip_writeb, .chip_writew = fallback_chip_writew, .chip_writel = fallback_chip_writel, .chip_writen = fallback_chip_writen, @@ -143,14 +151,14 @@ { .name = "ft2232spi", .init = ft2232_spi_init, - .shutdown = fallback_shutdown, + .shutdown = noop_shutdown, /* Missing shutdown */ .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, - .chip_readb = dummy_chip_readb, + .chip_readb = noop_chip_readb, .chip_readw = fallback_chip_readw, .chip_readl = fallback_chip_readl, .chip_readn = fallback_chip_readn, - .chip_writeb = fallback_chip_writeb, + .chip_writeb = noop_chip_writeb, .chip_writew = fallback_chip_writew, .chip_writel = fallback_chip_writel, .chip_writen = fallback_chip_writen, @@ -793,9 +801,15 @@ print_supported_boards(); printf("\nSupported PCI devices flashrom can use " "as programmer:\n\n"); +#if NIC3COM_SUPPORT == 1 print_supported_pcidevs(nics_3com); +#endif +#if DRKAISER_SUPPORT == 1 print_supported_pcidevs(drkaiser_pcidev); +#endif +#if SATASII_SUPPORT == 1 print_supported_pcidevs(satas_sii); +#endif exit(0); }
Modified: trunk/internal.c =================================================================== --- trunk/internal.c 2009-09-16 08:26:59 UTC (rev 723) +++ trunk/internal.c 2009-09-16 10:09:21 UTC (rev 724) @@ -222,8 +222,8 @@ } }
-/* Fallback shutdown() for programmers which don't need special handling */ -int fallback_shutdown(void) +/* No-op shutdown() for programmers which don't need special handling */ +int noop_shutdown(void) { return 0; } @@ -231,19 +231,26 @@ /* 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; }
-/* Fallback unmap() for programmers which don't need special handling */ +/* No-op/fallback unmap() for programmers which don't need special handling */ void fallback_unmap(void *virt_addr, size_t len) { }
-/* No-op fallback for drivers not supporting addr/data pair accesses */ -void fallback_chip_writeb(uint8_t val, chipaddr addr) +/* 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) {
Modified: trunk/print.c =================================================================== --- trunk/print.c 2009-09-16 08:26:59 UTC (rev 723) +++ trunk/print.c 2009-09-16 10:09:21 UTC (rev 724) @@ -731,8 +731,15 @@ print_supported_chipsets_wiki(); print_supported_boards_wiki(); printf("%s", programmer_section); +#if NIC3COM_SUPPORT == 1 print_supported_pcidevs_wiki(nics_3com); +#endif +#if DRKAISER_SUPPORT == 1 + /* FIXME: drkaiser_pcidev is missing here. */ +#endif +#if SATASII_SUPPORT == 1 print_supported_pcidevs_wiki(satas_sii); +#endif printf("\n|}\n"); }
Modified: trunk/spi.c =================================================================== --- trunk/spi.c 2009-09-16 08:26:59 UTC (rev 723) +++ trunk/spi.c 2009-09-16 10:09:21 UTC (rev 724) @@ -91,12 +91,14 @@ }, #endif
+#if DUMMY_SUPPORT == 1 { /* SPI_CONTROLLER_DUMMY */ .command = dummy_spi_send_command, .multicommand = default_spi_send_multicommand, .read = NULL, .write_256 = NULL, }, +#endif
{}, /* This entry corresponds to SPI_CONTROLLER_INVALID. */ }; @@ -301,7 +303,9 @@ #if FT2232_SPI_SUPPORT == 1 case SPI_CONTROLLER_FT2232: #endif +#if DUMMY_SUPPORT == 1 case SPI_CONTROLLER_DUMMY: +#endif return probe_spi_rdid_generic(flash, 4); default: printf_debug("4b ID not supported on this SPI controller\n");