1 Jun 2009 02:02
[flashrom] r559 - trunk
<svn <at> coreboot.org>
2009-06-01 00:02:12 GMT
2009-06-01 00:02:12 GMT
Author: hailfinger Date: 2009-06-01 02:02:11 +0200 (Mon, 01 Jun 2009) New Revision: 559 Modified: trunk/dummyflasher.c trunk/flash.h trunk/flashrom.8 trunk/flashrom.c Log: Add bus type support to the dummy external programmer. The syntax is explained in the man page. Example: flashrom -p dummy=lpc,fwh Tested, works perfectly.As a nice benefit, it allows easy testing of the "probe only compatible flashes" patch. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 <at> gmx.net> Acked-by: Uwe Hermann <uwe <at> hermann-uwe.de> Modified: trunk/dummyflasher.c =================================================================== --- trunk/dummyflasher.c 2009-05-31 21:35:10 UTC (rev 558) +++ trunk/dummyflasher.c 2009-06-01 00:02:11 UTC (rev 559) <at> <at> -20,16 +20,52 <at> <at> #include <string.h> #include <stdlib.h> +#include <ctype.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <errno.h> #include "flash.h" +char *dummytype = NULL; + int dummy_init(void) { + int i; printf_debug("%s\n", __func__); - spi_controller = SPI_CONTROLLER_DUMMY; + + /* "all" is equivalent to specifying no type. */ + if (!strcmp(dummytype, "all")) { + free(dummytype); + dummytype = NULL; + } + if (!dummytype) + dummytype = strdup("parallel,lpc,fwh,spi"); + /* Convert the parameters to lowercase. */ + for (i = 0; dummytype[i] != '\0'; i++) + dummytype[i] = (char)tolower(dummytype[i]); + + buses_supported = CHIP_BUSTYPE_NONE; + if (strstr(dummytype, "parallel")) { + buses_supported |= CHIP_BUSTYPE_PARALLEL; + printf_debug("Enabling support for %s flash.\n", "parallel"); + } + if (strstr(dummytype, "lpc")) { + buses_supported |= CHIP_BUSTYPE_LPC; + printf_debug("Enabling support for %s flash.\n", "LPC"); + } + if (strstr(dummytype, "fwh")) { + buses_supported |= CHIP_BUSTYPE_FWH; + printf_debug("Enabling support for %s flash.\n", "FWH"); + } + if (strstr(dummytype, "spi")) { + buses_supported |= CHIP_BUSTYPE_SPI; + spi_controller = SPI_CONTROLLER_DUMMY; + printf_debug("Enabling support for %s flash.\n", "SPI"); + } + if (buses_supported == CHIP_BUSTYPE_NONE) + printf_debug("Support for all flash bus types disabled.\n"); + free(dummytype); return 0; } Modified: trunk/flash.h =================================================================== --- trunk/flash.h 2009-05-31 21:35:10 UTC (rev 558) +++ trunk/flash.h 2009-06-01 00:02:11 UTC (rev 559) <at> <at> -122,6 +122,7 <at> <at> #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) enum chipbustype { + CHIP_BUSTYPE_NONE = 0, CHIP_BUSTYPE_PARALLEL = 1 << 0, CHIP_BUSTYPE_LPC = 1 << 1, CHIP_BUSTYPE_FWH = 1 << 2, <at> <at> -646,6 +647,7 <at> <at> #endif /* dummyflasher.c */ +extern char *dummytype; int dummy_init(void); int dummy_shutdown(void); void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); Modified: trunk/flashrom.8 =================================================================== --- trunk/flashrom.8 2009-05-31 21:35:10 UTC (rev 558) +++ trunk/flashrom.8 2009-06-01 00:02:11 UTC (rev 559) <at> <at> -135,6 +135,18 <at> <at> .sp .BR "* it87spi" " (for flash ROMs behind a IT87xx SuperI/O LPC/SPI translation unit)" .sp +The dummy programmer has an optional parameter specifying the bus types it +should support. For that you have to use the +.B "flashrom -p dummy=type" +syntax where +.B type +can be any comma-separated combination of +.B parallel lpc fwh spi all +in any order. +.sp +Example: +.B "flashrom -p dummy=lpc,fwh" +.sp If you have multiple supported PCI cards which can program flash chips (NICs, SATA/IDE controllers, etc.) in your system, you must use the .B "flashrom -p xxxx=bb:dd.f" Modified: trunk/flashrom.c =================================================================== --- trunk/flashrom.c 2009-05-31 21:35:10 UTC (rev 558) +++ trunk/flashrom.c 2009-06-01 00:02:11 UTC (rev 559) <at> <at> -537,6 +537,8 <at> <at> programmer = PROGRAMMER_INTERNAL; } else if (strncmp(optarg, "dummy", 5) == 0) { programmer = PROGRAMMER_DUMMY; + if (optarg[5] == '=') + dummytype = strdup(optarg + 6); } else if (strncmp(optarg, "nic3com", 7) == 0) { programmer = PROGRAMMER_NIC3COM; if (optarg[7] == '=') -- -- coreboot mailing list: coreboot <at> coreboot.org http://www.coreboot.org/mailman/listinfo/coreboot
As a nice benefit, it allows easy testing of the "probe only compatible
flashes" patch.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 <at> gmx.net>
Acked-by: Uwe Hermann <uwe <at> hermann-uwe.de>
Modified: trunk/dummyflasher.c
===================================================================
--- trunk/dummyflasher.c 2009-05-31 21:35:10 UTC (rev 558)
+++ trunk/dummyflasher.c 2009-06-01 00:02:11 UTC (rev 559)
<at> <at> -20,16 +20,52 <at> <at>
#include <string.h>
#include <stdlib.h>
+#include <ctype.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include "flash.h"
+char *dummytype = NULL;
+
int dummy_init(void)
{
+ int i;
printf_debug("%s\n", __func__);
- spi_controller = SPI_CONTROLLER_DUMMY;
+
+ /* "all" is equivalent to specifying no type. */
+ if (!strcmp(dummytype, "all")) {
+ free(dummytype);
+ dummytype = NULL;
+ }
+ if (!dummytype)
+ dummytype = strdup("parallel,lpc,fwh,spi");
+ /* Convert the parameters to lowercase. */
+ for (i = 0; dummytype[i] != '\0'; i++)
+ dummytype[i] = (char)tolower(dummytype[i]);
+
+ buses_supported = CHIP_BUSTYPE_NONE;
+ if (strstr(dummytype, "parallel")) {
+ buses_supported |= CHIP_BUSTYPE_PARALLEL;
+ printf_debug("Enabling support for %s flash.\n", "parallel");
+ }
+ if (strstr(dummytype, "lpc")) {
+ buses_supported |= CHIP_BUSTYPE_LPC;
+ printf_debug("Enabling support for %s flash.\n", "LPC");
+ }
+ if (strstr(dummytype, "fwh")) {
+ buses_supported |= CHIP_BUSTYPE_FWH;
+ printf_debug("Enabling support for %s flash.\n", "FWH");
+ }
+ if (strstr(dummytype, "spi")) {
+ buses_supported |= CHIP_BUSTYPE_SPI;
+ spi_controller = SPI_CONTROLLER_DUMMY;
+ printf_debug("Enabling support for %s flash.\n", "SPI");
+ }
+ if (buses_supported == CHIP_BUSTYPE_NONE)
+ printf_debug("Support for all flash bus types disabled.\n");
+ free(dummytype);
return 0;
}
Modified: trunk/flash.h
===================================================================
--- trunk/flash.h 2009-05-31 21:35:10 UTC (rev 558)
+++ trunk/flash.h 2009-06-01 00:02:11 UTC (rev 559)
<at> <at> -122,6 +122,7 <at> <at>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
enum chipbustype {
+ CHIP_BUSTYPE_NONE = 0,
CHIP_BUSTYPE_PARALLEL = 1 << 0,
CHIP_BUSTYPE_LPC = 1 << 1,
CHIP_BUSTYPE_FWH = 1 << 2,
<at> <at> -646,6 +647,7 <at> <at>
#endif
/* dummyflasher.c */
+extern char *dummytype;
int dummy_init(void);
int dummy_shutdown(void);
void *dummy_map(const char *descr, unsigned long phys_addr, size_t len);
Modified: trunk/flashrom.8
===================================================================
--- trunk/flashrom.8 2009-05-31 21:35:10 UTC (rev 558)
+++ trunk/flashrom.8 2009-06-01 00:02:11 UTC (rev 559)
<at> <at> -135,6 +135,18 <at> <at>
.sp
.BR "* it87spi" " (for flash ROMs behind a IT87xx SuperI/O LPC/SPI translation unit)"
.sp
+The dummy programmer has an optional parameter specifying the bus types it
+should support. For that you have to use the
+.B "flashrom -p dummy=type"
+syntax where
+.B type
+can be any comma-separated combination of
+.B parallel lpc fwh spi all
+in any order.
+.sp
+Example:
+.B "flashrom -p dummy=lpc,fwh"
+.sp
If you have multiple supported PCI cards which can program flash chips
(NICs, SATA/IDE controllers, etc.) in your system, you must use the
.B "flashrom -p xxxx=bb:dd.f"
Modified: trunk/flashrom.c
===================================================================
--- trunk/flashrom.c 2009-05-31 21:35:10 UTC (rev 558)
+++ trunk/flashrom.c 2009-06-01 00:02:11 UTC (rev 559)
<at> <at> -537,6 +537,8 <at> <at>
programmer = PROGRAMMER_INTERNAL;
} else if (strncmp(optarg, "dummy", 5) == 0) {
programmer = PROGRAMMER_DUMMY;
+ if (optarg[5] == '=')
+ dummytype = strdup(optarg + 6);
} else if (strncmp(optarg, "nic3com", 7) == 0) {
programmer = PROGRAMMER_NIC3COM;
if (optarg[7] == '=')
RSS Feed