[coreboot] [flashrom] r483 - trunk

svn at coreboot.org svn at coreboot.org
Sat May 9 02:54:55 CEST 2009


Author: hailfinger
Date: 2009-05-09 02:54:55 +0200 (Sat, 09 May 2009)
New Revision: 483

Added:
   trunk/dummyflasher.c
Modified:
   trunk/Makefile
   trunk/flash.h
   trunk/flashrom.8
   trunk/flashrom.c
Log:
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.

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/Makefile
===================================================================
--- trunk/Makefile	2009-05-09 00:47:04 UTC (rev 482)
+++ trunk/Makefile	2009-05-09 00:54:55 UTC (rev 483)
@@ -34,7 +34,8 @@
 	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)
 

Added: trunk/dummyflasher.c
===================================================================
--- trunk/dummyflasher.c	                        (rev 0)
+++ trunk/dummyflasher.c	2009-05-09 00:54:55 UTC (rev 483)
@@ -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;
+}
+

Modified: trunk/flash.h
===================================================================
--- trunk/flash.h	2009-05-09 00:47:04 UTC (rev 482)
+++ trunk/flash.h	2009-05-09 00:54:55 UTC (rev 483)
@@ -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 @@
 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); }

Modified: trunk/flashrom.8
===================================================================
--- trunk/flashrom.8	2009-05-09 00:47:04 UTC (rev 482)
+++ trunk/flashrom.8	2009-05-09 00:54:55 UTC (rev 483)
@@ -127,6 +127,8 @@
 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.

Modified: trunk/flashrom.c
===================================================================
--- trunk/flashrom.c	2009-05-09 00:47:04 UTC (rev 482)
+++ trunk/flashrom.c	2009-05-09 00:54:55 UTC (rev 483)
@@ -48,6 +48,17 @@
 		.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 @@
 		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);





More information about the coreboot mailing list