1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

Internal (onboard) programming was the only feature which could not be disabled

Make various pieces of code conditional on support for internal
programming. Code shared between PCI device programmers and onboard
programming is now conditional as well.

It is now possible to build only with dummy support:
make CONFIG_INTERNAL=no CONFIG_NIC3COM=no CONFIG_SATASII=no
CONFIG_DRKAISER=no CONFIG_SERPROG=no CONFIG_FT2232SPI=no

This allows building for a specific use case only, and it also
facilitates porting to a new architecture because it is possible to
focus on highlevel code only.

Note: Either internal or dummy programmer needs to be compiled in due to
the current behaviour of always picking a default programmer if -p is
not specified. Picking an arbitrary external programmer as default  
wouldn't make sense.

Build and runtime tested in all 1024 possible build combinations. The
only failures are by design as mentioned above.

Corresponding to flashrom svn r797.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
This commit is contained in:
Carl-Daniel Hailfinger 2009-12-13 22:28:00 +00:00
parent a7e30503fa
commit 66ef4e5ff3
9 changed files with 138 additions and 50 deletions

View File

@ -43,13 +43,11 @@ endif
LIBS += -lpci LIBS += -lpci
OBJS = chipset_enable.o board_enable.o udelay.o jedec.o stm50flw0x0x.o \ OBJS = jedec.o stm50flw0x0x.o w39v080fa.o sharplhf00l04.o w29ee011.o \
sst28sf040.o am29f040b.o mx29f002.o m29f400bt.o pm29f002.o \ sst28sf040.o am29f040b.o mx29f002.o m29f400bt.o pm29f002.o w39v040c.o \
w49f002u.o 82802ab.o pm49fl00x.o sst49lf040.o en29f002a.o \ w49f002u.o 82802ab.o pm49fl00x.o sst49lf040.o en29f002a.o m29f002.o \
sst49lfxxxc.o sst_fwhub.o layout.o cbtable.o flashchips.o physmap.o \ sst49lfxxxc.o sst_fwhub.o flashchips.o layout.o spi.o \
flashrom.o w39v080fa.o sharplhf00l04.o w29ee011.o spi.o it87spi.o \ flashrom.o print.o physmap.o internal.o udelay.o
ichspi.o w39v040c.o sb600spi.o wbsio_spi.o m29f002.o internal.o \
pcidev.o print.o
all: pciutils features dep $(PROGRAM) all: pciutils features dep $(PROGRAM)
@ -65,6 +63,9 @@ RELEASENAME ?= $(VERSION)
SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"' SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
# Always enable internal/onboard support for now.
CONFIG_INTERNAL ?= yes
# Always enable serprog for now. Needs to be disabled on Windows. # Always enable serprog for now. Needs to be disabled on Windows.
CONFIG_SERPROG ?= yes CONFIG_SERPROG ?= yes
@ -95,6 +96,12 @@ CONFIG_BUSPIRATESPI ?= yes
# Disable wiki printing by default. It is only useful if you have wiki access. # Disable wiki printing by default. It is only useful if you have wiki access.
CONFIG_PRINT_WIKI ?= no CONFIG_PRINT_WIKI ?= no
ifeq ($(CONFIG_INTERNAL), yes)
FEATURE_CFLAGS += -D'INTERNAL_SUPPORT=1'
OBJS += chipset_enable.o board_enable.o cbtable.o it87spi.o ichspi.o sb600spi.o wbsio_spi.o
NEED_PCI := yes
endif
ifeq ($(CONFIG_SERPROG), yes) ifeq ($(CONFIG_SERPROG), yes)
FEATURE_CFLAGS += -D'SERPROG_SUPPORT=1' FEATURE_CFLAGS += -D'SERPROG_SUPPORT=1'
OBJS += serprog.o OBJS += serprog.o
@ -111,16 +118,19 @@ endif
ifeq ($(CONFIG_NIC3COM), yes) ifeq ($(CONFIG_NIC3COM), yes)
FEATURE_CFLAGS += -D'NIC3COM_SUPPORT=1' FEATURE_CFLAGS += -D'NIC3COM_SUPPORT=1'
OBJS += nic3com.o OBJS += nic3com.o
NEED_PCI := yes
endif endif
ifeq ($(CONFIG_GFXNVIDIA), yes) ifeq ($(CONFIG_GFXNVIDIA), yes)
FEATURE_CFLAGS += -D'GFXNVIDIA_SUPPORT=1' FEATURE_CFLAGS += -D'GFXNVIDIA_SUPPORT=1'
OBJS += gfxnvidia.o OBJS += gfxnvidia.o
NEED_PCI := yes
endif endif
ifeq ($(CONFIG_SATASII), yes) ifeq ($(CONFIG_SATASII), yes)
FEATURE_CFLAGS += -D'SATASII_SUPPORT=1' FEATURE_CFLAGS += -D'SATASII_SUPPORT=1'
OBJS += satasii.o OBJS += satasii.o
NEED_PCI := yes
endif endif
FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb") FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb")
@ -139,6 +149,7 @@ endif
ifeq ($(CONFIG_DRKAISER), yes) ifeq ($(CONFIG_DRKAISER), yes)
FEATURE_CFLAGS += -D'DRKAISER_SUPPORT=1' FEATURE_CFLAGS += -D'DRKAISER_SUPPORT=1'
OBJS += drkaiser.o OBJS += drkaiser.o
NEED_PCI := yes
endif endif
ifeq ($(CONFIG_BUSPIRATESPI), yes) ifeq ($(CONFIG_BUSPIRATESPI), yes)
@ -155,6 +166,11 @@ OBJS += serial.o
endif endif
endif endif
ifeq ($(NEED_PCI), yes)
FEATURE_CFLAGS += -D'NEED_PCI=1'
OBJS += pcidev.o
endif
ifeq ($(CONFIG_PRINT_WIKI), yes) ifeq ($(CONFIG_PRINT_WIKI), yes)
FEATURE_CFLAGS += -D'PRINT_WIKI_SUPPORT=1' FEATURE_CFLAGS += -D'PRINT_WIKI_SUPPORT=1'
OBJS += print_wiki.o OBJS += print_wiki.o

View File

@ -30,6 +30,20 @@
char *lb_part = NULL, *lb_vendor = NULL; char *lb_part = NULL, *lb_vendor = NULL;
int partvendor_from_cbtable = 0; int partvendor_from_cbtable = 0;
void lb_vendor_dev_from_string(char *boardstring)
{
char *tempstr2 = NULL;
strtok(boardstring, ":");
tempstr2 = strtok(NULL, ":");
if (tempstr2) {
lb_vendor = boardstring;
lb_part = tempstr2;
} else {
lb_vendor = NULL;
lb_part = boardstring;
}
}
static unsigned long compute_checksum(void *addr, unsigned long length) static unsigned long compute_checksum(void *addr, unsigned long length)
{ {
uint8_t *ptr; uint8_t *ptr;

View File

@ -32,27 +32,6 @@
#include <fcntl.h> #include <fcntl.h>
#include "flash.h" #include "flash.h"
unsigned long flashbase = 0;
/**
* flashrom defaults to Parallel/LPC/FWH flash devices. If a known host
* controller is found, the init routine sets the buses_supported bitfield to
* contain the supported buses for that controller.
*/
enum chipbustype buses_supported = CHIP_BUSTYPE_NONSPI;
/**
* Programmers supporting multiple buses can have differing size limits on
* each bus. Store the limits for each bus in a common struct.
*/
struct decode_sizes max_rom_decode = {
.parallel = 0xffffffff,
.lpc = 0xffffffff,
.fwh = 0xffffffff,
.spi = 0xffffffff
};
extern int ichspi_lock; extern int ichspi_lock;
static int enable_flash_ali_m1533(struct pci_dev *dev, const char *name) static int enable_flash_ali_m1533(struct pci_dev *dev, const char *name)

49
flash.h
View File

@ -30,7 +30,9 @@
#include <unistd.h> #include <unistd.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#if NEED_PCI == 1
#include <pci/pci.h> #include <pci/pci.h>
#endif
/* for iopl and outb under Solaris */ /* for iopl and outb under Solaris */
#if defined (__sun) && (defined(__i386) || defined(__amd64)) #if defined (__sun) && (defined(__i386) || defined(__amd64))
@ -81,7 +83,9 @@
typedef unsigned long chipaddr; typedef unsigned long chipaddr;
enum programmer { enum programmer {
#if INTERNAL_SUPPORT == 1
PROGRAMMER_INTERNAL, PROGRAMMER_INTERNAL,
#endif
#if DUMMY_SUPPORT == 1 #if DUMMY_SUPPORT == 1
PROGRAMMER_DUMMY, PROGRAMMER_DUMMY,
#endif #endif
@ -97,7 +101,9 @@ enum programmer {
#if SATASII_SUPPORT == 1 #if SATASII_SUPPORT == 1
PROGRAMMER_SATASII, PROGRAMMER_SATASII,
#endif #endif
#if INTERNAL_SUPPORT == 1
PROGRAMMER_IT87SPI, PROGRAMMER_IT87SPI,
#endif
#if FT2232_SPI_SUPPORT == 1 #if FT2232_SPI_SUPPORT == 1
PROGRAMMER_FT2232SPI, PROGRAMMER_FT2232SPI,
#endif #endif
@ -269,6 +275,7 @@ struct flashchip {
extern struct flashchip flashchips[]; extern struct flashchip flashchips[];
#if INTERNAL_SUPPORT == 1
struct penable { struct penable {
uint16_t vendor_id; uint16_t vendor_id;
uint16_t device_id; uint16_t device_id;
@ -316,11 +323,13 @@ extern const struct board_info boards_ok[];
extern const struct board_info boards_bad[]; extern const struct board_info boards_bad[];
extern const struct board_info laptops_ok[]; extern const struct board_info laptops_ok[];
extern const struct board_info laptops_bad[]; extern const struct board_info laptops_bad[];
#endif
/* udelay.c */ /* udelay.c */
void myusec_delay(int usecs); void myusec_delay(int usecs);
void myusec_calibrate_delay(void); void myusec_calibrate_delay(void);
#if NEED_PCI == 1
/* pcidev.c */ /* pcidev.c */
#define PCI_OK 0 #define PCI_OK 0
#define PCI_NT 1 /* Not tested */ #define PCI_NT 1 /* Not tested */
@ -338,11 +347,14 @@ struct pcidev_status {
}; };
uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar, struct pcidev_status *devs); uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar, struct pcidev_status *devs);
uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar, struct pcidev_status *devs, char *pcidev_bdf); uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar, struct pcidev_status *devs, char *pcidev_bdf);
#endif
/* print.c */ /* print.c */
char *flashbuses_to_text(enum chipbustype bustype); char *flashbuses_to_text(enum chipbustype bustype);
void print_supported(void); void print_supported(void);
#if (NIC3COM_SUPPORT == 1) || (GFXNVIDIA_SUPPORT == 1) || (DRKAISER_SUPPORT == 1) || (SATASII_SUPPORT == 1)
void print_supported_pcidevs(struct pcidev_status *devs); void print_supported_pcidevs(struct pcidev_status *devs);
#endif
void print_supported_wiki(void); void print_supported_wiki(void);
/* board_enable.c */ /* board_enable.c */
@ -353,19 +365,8 @@ void sio_write(uint16_t port, uint8_t reg, uint8_t data);
void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask); void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask);
int board_flash_enable(const char *vendor, const char *part); int board_flash_enable(const char *vendor, const char *part);
struct decode_sizes {
uint32_t parallel;
uint32_t lpc;
uint32_t fwh;
uint32_t spi;
};
/* chipset_enable.c */ /* chipset_enable.c */
extern enum chipbustype buses_supported;
int chipset_flash_enable(void); int chipset_flash_enable(void);
extern struct decode_sizes max_rom_decode;
extern unsigned long flashbase;
/* physmap.c */ /* physmap.c */
void *physmap(const char *descr, unsigned long phys_addr, size_t len); void *physmap(const char *descr, unsigned long phys_addr, size_t len);
@ -389,13 +390,16 @@ int freebsd_wrmsr(int addr, msr_t msr);
#endif #endif
/* internal.c */ /* internal.c */
#if NEED_PCI == 1
struct pci_dev *pci_dev_find_filter(struct pci_filter filter); struct pci_dev *pci_dev_find_filter(struct pci_filter filter);
struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t class); struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t class);
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device); struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device, struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
uint16_t card_vendor, uint16_t card_device); uint16_t card_vendor, uint16_t card_device);
#endif
void get_io_perms(void); void get_io_perms(void);
void release_io_perms(void); void release_io_perms(void);
#if INTERNAL_SUPPORT == 1
int internal_init(void); int internal_init(void);
int internal_shutdown(void); int internal_shutdown(void);
void internal_chip_writeb(uint8_t val, chipaddr addr); void internal_chip_writeb(uint8_t val, chipaddr addr);
@ -405,6 +409,7 @@ uint8_t internal_chip_readb(const chipaddr addr);
uint16_t internal_chip_readw(const chipaddr addr); uint16_t internal_chip_readw(const chipaddr addr);
uint32_t internal_chip_readl(const chipaddr addr); uint32_t internal_chip_readl(const chipaddr addr);
void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
#endif
void mmio_writeb(uint8_t val, void *addr); void mmio_writeb(uint8_t val, void *addr);
void mmio_writew(uint16_t val, void *addr); void mmio_writew(uint16_t val, void *addr);
void mmio_writel(uint32_t val, void *addr); void mmio_writel(uint32_t val, void *addr);
@ -428,6 +433,7 @@ extern int io_fd;
#endif #endif
/* dummyflasher.c */ /* dummyflasher.c */
#if DUMMY_SUPPORT == 1
int dummy_init(void); int dummy_init(void);
int dummy_shutdown(void); int dummy_shutdown(void);
void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); void *dummy_map(const char *descr, unsigned long phys_addr, size_t len);
@ -442,34 +448,43 @@ uint32_t dummy_chip_readl(const chipaddr addr);
void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt, int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr); const unsigned char *writearr, unsigned char *readarr);
#endif
/* nic3com.c */ /* nic3com.c */
#if NIC3COM_SUPPORT == 1
int nic3com_init(void); int nic3com_init(void);
int nic3com_shutdown(void); int nic3com_shutdown(void);
void nic3com_chip_writeb(uint8_t val, chipaddr addr); void nic3com_chip_writeb(uint8_t val, chipaddr addr);
uint8_t nic3com_chip_readb(const chipaddr addr); uint8_t nic3com_chip_readb(const chipaddr addr);
extern struct pcidev_status nics_3com[]; extern struct pcidev_status nics_3com[];
#endif
/* gfxnvidia.c */ /* gfxnvidia.c */
#if GFXNVIDIA_SUPPORT == 1
int gfxnvidia_init(void); int gfxnvidia_init(void);
int gfxnvidia_shutdown(void); int gfxnvidia_shutdown(void);
void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr); void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr);
uint8_t gfxnvidia_chip_readb(const chipaddr addr); uint8_t gfxnvidia_chip_readb(const chipaddr addr);
extern struct pcidev_status gfx_nvidia[]; extern struct pcidev_status gfx_nvidia[];
#endif
/* drkaiser.c */ /* drkaiser.c */
#if DRKAISER_SUPPORT == 1
int drkaiser_init(void); int drkaiser_init(void);
int drkaiser_shutdown(void); int drkaiser_shutdown(void);
void drkaiser_chip_writeb(uint8_t val, chipaddr addr); void drkaiser_chip_writeb(uint8_t val, chipaddr addr);
uint8_t drkaiser_chip_readb(const chipaddr addr); uint8_t drkaiser_chip_readb(const chipaddr addr);
extern struct pcidev_status drkaiser_pcidev[]; extern struct pcidev_status drkaiser_pcidev[];
#endif
/* satasii.c */ /* satasii.c */
#if SATASII_SUPPORT == 1
int satasii_init(void); int satasii_init(void);
int satasii_shutdown(void); int satasii_shutdown(void);
void satasii_chip_writeb(uint8_t val, chipaddr addr); void satasii_chip_writeb(uint8_t val, chipaddr addr);
uint8_t satasii_chip_readb(const chipaddr addr); uint8_t satasii_chip_readb(const chipaddr addr);
extern struct pcidev_status satas_sii[]; extern struct pcidev_status satas_sii[];
#endif
/* ft2232_spi.c */ /* ft2232_spi.c */
#define FTDI_FT2232H 0x6010 #define FTDI_FT2232H 0x6010
@ -498,7 +513,16 @@ int buspirate_spi_send_command(unsigned int writecnt, unsigned int readcnt, cons
int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
/* flashrom.c */ /* flashrom.c */
extern enum chipbustype buses_supported;
struct decode_sizes {
uint32_t parallel;
uint32_t lpc;
uint32_t fwh;
uint32_t spi;
};
extern struct decode_sizes max_rom_decode;
extern char *programmer_param; extern char *programmer_param;
extern unsigned long flashbase;
extern int verbose; extern int verbose;
extern const char *flashrom_version; extern const char *flashrom_version;
#define printf_debug(x...) { if (verbose) printf(x); } #define printf_debug(x...) { if (verbose) printf(x); }
@ -522,6 +546,7 @@ int find_romentry(char *name);
int handle_romentries(uint8_t *buffer, struct flashchip *flash); int handle_romentries(uint8_t *buffer, struct flashchip *flash);
/* cbtable.c */ /* cbtable.c */
void lb_vendor_dev_from_string(char *boardstring);
int coreboot_init(void); int coreboot_init(void);
extern char *lb_part, *lb_vendor; extern char *lb_part, *lb_vendor;
extern int partvendor_from_cbtable; extern int partvendor_from_cbtable;
@ -529,12 +554,14 @@ extern int partvendor_from_cbtable;
/* spi.c */ /* spi.c */
enum spi_controller { enum spi_controller {
SPI_CONTROLLER_NONE, SPI_CONTROLLER_NONE,
#if INTERNAL_SUPPORT == 1
SPI_CONTROLLER_ICH7, SPI_CONTROLLER_ICH7,
SPI_CONTROLLER_ICH9, SPI_CONTROLLER_ICH9,
SPI_CONTROLLER_IT87XX, SPI_CONTROLLER_IT87XX,
SPI_CONTROLLER_SB600, SPI_CONTROLLER_SB600,
SPI_CONTROLLER_VIA, SPI_CONTROLLER_VIA,
SPI_CONTROLLER_WBSIO, SPI_CONTROLLER_WBSIO,
#endif
#if FT2232_SPI_SUPPORT == 1 #if FT2232_SPI_SUPPORT == 1
SPI_CONTROLLER_FT2232, SPI_CONTROLLER_FT2232,
#endif #endif

View File

@ -33,10 +33,38 @@
const char *flashrom_version = FLASHROM_VERSION; const char *flashrom_version = FLASHROM_VERSION;
char *chip_to_probe = NULL; char *chip_to_probe = NULL;
int verbose = 0; int verbose = 0;
#if INTERNAL_SUPPORT == 1
enum programmer programmer = PROGRAMMER_INTERNAL; enum programmer programmer = PROGRAMMER_INTERNAL;
#elif DUMMY_SUPPORT == 1
enum programmer programmer = PROGRAMMER_DUMMY;
#else
/* Activating the #error explodes on make dep. */
//#error Neither internal nor dummy selected
#endif
char *programmer_param = NULL; char *programmer_param = NULL;
/**
* flashrom defaults to Parallel/LPC/FWH flash devices. If a known host
* controller is found, the init routine sets the buses_supported bitfield to
* contain the supported buses for that controller.
*/
enum chipbustype buses_supported = CHIP_BUSTYPE_NONSPI;
/**
* Programmers supporting multiple buses can have differing size limits on
* each bus. Store the limits for each bus in a common struct.
*/
struct decode_sizes max_rom_decode = {
.parallel = 0xffffffff,
.lpc = 0xffffffff,
.fwh = 0xffffffff,
.spi = 0xffffffff
};
const struct programmer_entry programmer_table[] = { const struct programmer_entry programmer_table[] = {
#if INTERNAL_SUPPORT == 1
{ {
.name = "internal", .name = "internal",
.init = internal_init, .init = internal_init,
@ -53,6 +81,7 @@ const struct programmer_entry programmer_table[] = {
.chip_writen = fallback_chip_writen, .chip_writen = fallback_chip_writen,
.delay = internal_delay, .delay = internal_delay,
}, },
#endif
#if DUMMY_SUPPORT == 1 #if DUMMY_SUPPORT == 1
{ {
@ -149,6 +178,7 @@ const struct programmer_entry programmer_table[] = {
}, },
#endif #endif
#if INTERNAL_SUPPORT == 1
{ {
.name = "it87spi", .name = "it87spi",
.init = it87spi_init, .init = it87spi_init,
@ -165,6 +195,7 @@ const struct programmer_entry programmer_table[] = {
.chip_writen = fallback_chip_writen, .chip_writen = fallback_chip_writen,
.delay = internal_delay, .delay = internal_delay,
}, },
#endif
#if FT2232_SPI_SUPPORT == 1 #if FT2232_SPI_SUPPORT == 1
{ {
@ -308,6 +339,8 @@ int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len)
return 0; return 0;
} }
unsigned long flashbase = 0;
int min(int a, int b) int min(int a, int b)
{ {
return (a < b) ? a : b; return (a < b) ? a : b;
@ -866,7 +899,9 @@ void usage(const char *name)
" -E | --erase: erase flash device\n" " -E | --erase: erase flash device\n"
" -V | --verbose: more verbose output\n" " -V | --verbose: more verbose output\n"
" -c | --chip <chipname>: probe only for specified flash chip\n" " -c | --chip <chipname>: probe only for specified flash chip\n"
#if INTERNAL_SUPPORT == 1
" -m | --mainboard <[vendor:]part>: override mainboard settings\n" " -m | --mainboard <[vendor:]part>: override mainboard settings\n"
#endif
" -f | --force: force write without checking image\n" " -f | --force: force write without checking image\n"
" -l | --layout <file.layout>: read ROM layout from file\n" " -l | --layout <file.layout>: read ROM layout from file\n"
" -i | --image <name>: only flash image name from flash layout\n" " -i | --image <name>: only flash image name from flash layout\n"
@ -962,7 +997,7 @@ int main(int argc, char *argv[])
char *filename = NULL; char *filename = NULL;
char *tempstr = NULL, *tempstr2 = NULL; char *tempstr = NULL;
print_version(); print_version();
@ -1046,18 +1081,12 @@ int main(int argc, char *argv[])
} }
erase_it = 1; erase_it = 1;
break; break;
#if INTERNAL_SUPPORT == 1
case 'm': case 'm':
tempstr = strdup(optarg); tempstr = strdup(optarg);
strtok(tempstr, ":"); lb_vendor_dev_from_string(tempstr);
tempstr2 = strtok(NULL, ":");
if (tempstr2) {
lb_vendor = tempstr;
lb_part = tempstr2;
} else {
lb_vendor = NULL;
lb_part = tempstr;
}
break; break;
#endif
case 'f': case 'f':
force = 1; force = 1;
break; break;
@ -1224,7 +1253,8 @@ int main(int argc, char *argv[])
"this flash part. Please include the flashrom\noutput " "this flash part. Please include the flashrom\noutput "
"with the additional -V option for all operations you " "with the additional -V option for all operations you "
"tested (-V, -rV,\n-wV, -EV), and mention which " "tested (-V, -rV,\n-wV, -EV), and mention which "
"mainboard you tested. Thanks for your help!\n===\n"); "mainboard or programmer you tested. Thanks for your "
"help!\n===\n");
} }
size = flash->total_size * 1024; size = flash->total_size * 1024;
@ -1318,7 +1348,9 @@ int main(int argc, char *argv[])
} }
numbytes = fread(buf, 1, size, image); numbytes = fread(buf, 1, size, image);
#if INTERNAL_SUPPORT == 1
show_id(buf, size, force); show_id(buf, size, force);
#endif
fclose(image); fclose(image);
if (numbytes != size) { if (numbytes != size) {
fprintf(stderr, "Error: Failed to read file. Got %ld bytes, wanted %ld!\n", numbytes, size); fprintf(stderr, "Error: Failed to read file. Got %ld bytes, wanted %ld!\n", numbytes, size);

View File

@ -31,6 +31,7 @@
int io_fd; int io_fd;
#endif #endif
#if NEED_PCI == 1
struct pci_dev *pci_dev_find_filter(struct pci_filter filter) struct pci_dev *pci_dev_find_filter(struct pci_filter filter)
{ {
struct pci_dev *temp; struct pci_dev *temp;
@ -99,6 +100,7 @@ struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
return NULL; return NULL;
} }
#endif
void get_io_perms(void) void get_io_perms(void)
{ {
@ -122,6 +124,7 @@ void release_io_perms(void)
#endif #endif
} }
#if INTERNAL_SUPPORT == 1
int internal_init(void) int internal_init(void)
{ {
int ret = 0; int ret = 0;
@ -163,6 +166,7 @@ int internal_shutdown(void)
return 0; return 0;
} }
#endif
void internal_chip_writeb(uint8_t val, chipaddr addr) void internal_chip_writeb(uint8_t val, chipaddr addr)
{ {

View File

@ -23,8 +23,10 @@
#include <ctype.h> #include <ctype.h>
#include "flash.h" #include "flash.h"
#if INTERNAL_SUPPORT == 1
char *mainboard_vendor = NULL; char *mainboard_vendor = NULL;
char *mainboard_part = NULL; char *mainboard_part = NULL;
#endif
int romimages = 0; int romimages = 0;
#define MAX_ROMLAYOUT 16 #define MAX_ROMLAYOUT 16
@ -38,6 +40,7 @@ typedef struct {
romlayout_t rom_entries[MAX_ROMLAYOUT]; romlayout_t rom_entries[MAX_ROMLAYOUT];
#if INTERNAL_SUPPORT == 1 /* FIXME: Move the whole block to cbtable.c? */
static char *def_name = "DEFAULT"; static char *def_name = "DEFAULT";
int show_id(uint8_t *bios, int size, int force) int show_id(uint8_t *bios, int size, int force)
@ -126,6 +129,7 @@ int show_id(uint8_t *bios, int size, int force)
return 0; return 0;
} }
#endif
int read_romlayout(char *name) int read_romlayout(char *name)
{ {

View File

@ -144,6 +144,7 @@ void print_supported_chips(void)
} }
} }
#if INTERNAL_SUPPORT == 1
void print_supported_chipsets(void) void print_supported_chipsets(void)
{ {
int i, j, chipsetcount = 0; int i, j, chipsetcount = 0;
@ -221,12 +222,15 @@ void print_supported_boards(void)
print_supported_boards_helper(laptops_bad, print_supported_boards_helper(laptops_bad,
"Laptops which have been verified to NOT work yet"); "Laptops which have been verified to NOT work yet");
} }
#endif
void print_supported(void) void print_supported(void)
{ {
print_supported_chips(); print_supported_chips();
#if INTERNAL_SUPPORT == 1
print_supported_chipsets(); print_supported_chipsets();
print_supported_boards(); print_supported_boards();
#endif
printf("\nSupported PCI devices flashrom can use " printf("\nSupported PCI devices flashrom can use "
"as programmer:\n\n"); "as programmer:\n\n");
#if NIC3COM_SUPPORT == 1 #if NIC3COM_SUPPORT == 1
@ -244,6 +248,7 @@ void print_supported(void)
} }
#if INTERNAL_SUPPORT == 1
/* Please keep this list alphabetically ordered by vendor/board. */ /* Please keep this list alphabetically ordered by vendor/board. */
const struct board_info boards_ok[] = { const struct board_info boards_ok[] = {
/* Verified working boards that don't need write-enables. */ /* Verified working boards that don't need write-enables. */
@ -394,4 +399,5 @@ const struct board_info laptops_bad[] = {
{}, {},
}; };
#endif

6
spi.c
View File

@ -40,6 +40,7 @@ const struct spi_programmer spi_programmer[] = {
.write_256 = NULL, .write_256 = NULL,
}, },
#if INTERNAL_SUPPORT == 1
{ /* SPI_CONTROLLER_ICH7 */ { /* SPI_CONTROLLER_ICH7 */
.command = ich_spi_send_command, .command = ich_spi_send_command,
.multicommand = ich_spi_send_multicommand, .multicommand = ich_spi_send_multicommand,
@ -81,6 +82,7 @@ const struct spi_programmer spi_programmer[] = {
.read = wbsio_spi_read, .read = wbsio_spi_read,
.write_256 = wbsio_spi_write_1, .write_256 = wbsio_spi_write_1,
}, },
#endif
#if FT2232_SPI_SUPPORT == 1 #if FT2232_SPI_SUPPORT == 1
{ /* SPI_CONTROLLER_FT2232 */ { /* SPI_CONTROLLER_FT2232 */
@ -308,11 +310,13 @@ int probe_spi_rdid4(struct flashchip *flash)
{ {
/* only some SPI chipsets support 4 bytes commands */ /* only some SPI chipsets support 4 bytes commands */
switch (spi_controller) { switch (spi_controller) {
#if INTERNAL_SUPPORT == 1
case SPI_CONTROLLER_ICH7: case SPI_CONTROLLER_ICH7:
case SPI_CONTROLLER_ICH9: case SPI_CONTROLLER_ICH9:
case SPI_CONTROLLER_VIA: case SPI_CONTROLLER_VIA:
case SPI_CONTROLLER_SB600: case SPI_CONTROLLER_SB600:
case SPI_CONTROLLER_WBSIO: case SPI_CONTROLLER_WBSIO:
#endif
#if FT2232_SPI_SUPPORT == 1 #if FT2232_SPI_SUPPORT == 1
case SPI_CONTROLLER_FT2232: case SPI_CONTROLLER_FT2232:
#endif #endif
@ -1042,10 +1046,12 @@ int spi_aai_write(struct flashchip *flash, uint8_t *buf)
int result; int result;
switch (spi_controller) { switch (spi_controller) {
#if INTERNAL_SUPPORT == 1
case SPI_CONTROLLER_WBSIO: case SPI_CONTROLLER_WBSIO:
fprintf(stderr, "%s: impossible with Winbond SPI masters," fprintf(stderr, "%s: impossible with Winbond SPI masters,"
" degrading to byte program\n", __func__); " degrading to byte program\n", __func__);
return spi_chip_write_1(flash, buf); return spi_chip_write_1(flash, buf);
#endif
default: default:
break; break;
} }