mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
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>
This commit is contained in:
parent
a93045cb17
commit
c312920864
3
Makefile
3
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)
|
||||
|
||||
|
75
dummyflasher.c
Normal file
75
dummyflasher.c
Normal file
@ -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;
|
||||
}
|
||||
|
13
flash.h
13
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); }
|
||||
|
@ -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.
|
||||
|
13
flashrom.c
13
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user