summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-05-09 00:54:55 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-05-09 00:54:55 +0000
commitc3129208648f241c0b6538235cd4e9854ae6539d (patch)
treebf210d57bb4fc0633ad6e95437568241907774bf
parenta93045cb178231d717f23dce92d264427f2a02d0 (diff)
downloadast2050-flashrom-c3129208648f241c0b6538235cd4e9854ae6539d.zip
ast2050-flashrom-c3129208648f241c0b6538235cd4e9854ae6539d.tar.gz
Add a dummy external flasher which just prints each operation
Usage: flashrom --programmer dummy This is a great way to test flashrom without root access. Corresponding to flashrom svn r483. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
-rw-r--r--Makefile3
-rw-r--r--dummyflasher.c75
-rw-r--r--flash.h13
-rw-r--r--flashrom.82
-rw-r--r--flashrom.c13
5 files changed, 104 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index ecaef6c..2a54af5 100644
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,8 @@ OBJS = chipset_enable.o board_enable.o udelay.o jedec.o stm50flw0x0x.o \
w49f002u.o 82802ab.o pm49fl00x.o sst49lf040.o en29f002a.o \
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
+ ichspi.o w39v040c.o sb600spi.o wbsio_spi.o m29f002.o internal.o \
+ dummyflasher.o
all: pciutils dep $(PROGRAM)
diff --git a/dummyflasher.c b/dummyflasher.c
new file mode 100644
index 0000000..4a4ea0f
--- /dev/null
+++ b/dummyflasher.c
@@ -0,0 +1,75 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * Copyright (C) 2009 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 <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <pci/pci.h>
+#include "flash.h"
+
+int dummy_init(void)
+{
+ printf("%s\n", __func__);
+ return 0;
+}
+
+int dummy_shutdown(void)
+{
+ printf("%s\n", __func__);
+ return 0;
+}
+
+void dummy_chip_writeb(uint8_t val, volatile void *addr)
+{
+ printf("%s: addr=%p, val=0x%02x\n", __func__, addr, val);
+}
+
+void dummy_chip_writew(uint16_t val, volatile void *addr)
+{
+ printf("%s: addr=%p, val=0x%04x\n", __func__, addr, val);
+}
+
+void dummy_chip_writel(uint32_t val, volatile void *addr)
+{
+ printf("%s: addr=%p, val=0x%08x\n", __func__, addr, val);
+}
+
+uint8_t dummy_chip_readb(const volatile void *addr)
+{
+ printf("%s: addr=%p\n", __func__, addr);
+ return 0xff;
+}
+
+uint16_t dummy_chip_readw(const volatile void *addr)
+{
+ printf("%s: addr=%p\n", __func__, addr);
+ return 0xffff;
+}
+
+uint32_t dummy_chip_readl(const volatile void *addr)
+{
+ printf("%s: addr=%p\n", __func__, addr);
+ return 0xffffffff;
+}
+
diff --git a/flash.h b/flash.h
index ef9ae6e..6b4dcb8 100644
--- a/flash.h
+++ b/flash.h
@@ -77,7 +77,8 @@
#endif
extern int programmer;
-#define PROGRAMMER_INTERNAL 0x00
+#define PROGRAMMER_INTERNAL 0x00
+#define PROGRAMMER_DUMMY 0x01
struct programmer_entry {
const char *vendor;
@@ -575,6 +576,16 @@ uint8_t internal_chip_readb(const volatile void *addr);
uint16_t internal_chip_readw(const volatile void *addr);
uint32_t internal_chip_readl(const volatile void *addr);
+/* dummyflasher.c */
+int dummy_init(void);
+int dummy_shutdown(void);
+void dummy_chip_writeb(uint8_t val, volatile void *addr);
+void dummy_chip_writew(uint16_t val, volatile void *addr);
+void dummy_chip_writel(uint32_t val, volatile void *addr);
+uint8_t dummy_chip_readb(const volatile void *addr);
+uint16_t dummy_chip_readw(const volatile void *addr);
+uint32_t dummy_chip_readl(const volatile void *addr);
+
/* flashrom.c */
extern int verbose;
#define printf_debug(x...) { if (verbose) printf(x); }
diff --git a/flashrom.8 b/flashrom.8
index c8ace15..46a3742 100644
--- a/flashrom.8
+++ b/flashrom.8
@@ -127,6 +127,8 @@ of the box.
Specify the programmer device. Currently supported are:
.sp
.BR " internal" " (default, for in-system flashing in the mainboard)"
+
+.BR " dummy" " (just prints all operations and accesses)"
.TP
.B "\-h, \-\-help"
Show a help text and exit.
diff --git a/flashrom.c b/flashrom.c
index 4bf41d9..eb9fca8 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -48,6 +48,17 @@ const struct programmer_entry programmer_table[] = {
.chip_writel = internal_chip_writel,
},
+ {
+ .init = dummy_init,
+ .shutdown = dummy_shutdown,
+ .chip_readb = dummy_chip_readb,
+ .chip_readw = dummy_chip_readw,
+ .chip_readl = dummy_chip_readl,
+ .chip_writeb = dummy_chip_writeb,
+ .chip_writew = dummy_chip_writew,
+ .chip_writel = dummy_chip_writel,
+ },
+
{},
};
@@ -437,6 +448,8 @@ int main(int argc, char *argv[])
case 'p':
if (strncmp(optarg, "internal", 8) == 0) {
programmer = PROGRAMMER_INTERNAL;
+ } else if (strncmp(optarg, "dummy", 5) == 0) {
+ programmer = PROGRAMMER_DUMMY;
} else {
printf("Error: Unknown programmer.\n");
exit(1);
OpenPOWER on IntegriCloud