diff options
author | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2012-12-27 18:40:26 +0000 |
---|---|---|
committer | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2012-12-27 18:40:26 +0000 |
commit | af358d6af23b21f93f6e27278e76eec21a3d148f (patch) | |
tree | be7adedc94b5c55dec0e7e1f1dae88ef4e127fad /programmer.h | |
parent | a6d96480176417478350e97338451554b5450cba (diff) | |
download | flashrom-af358d6af23b21f93f6e27278e76eec21a3d148f.tar.gz flashrom-af358d6af23b21f93f6e27278e76eec21a3d148f.tar.bz2 flashrom-af358d6af23b21f93f6e27278e76eec21a3d148f.zip |
Refactor PCI and USB device status printing
To be able to get rid of lots of #ifdefs and centralize programmer-specific
data more...
- introduce two new fields to struct programmer_entry, namely
enum type (OTHER, USB, PCI) and union devs (pcidev_status, usbdev_status
or char *note).
- use those fields to generate device listings in print.c and print_wiki.c.
Bonus: add printing of USB devices to print_wiki.c and count supported PCI
and USB devices.
Corresponding to flashrom svn r1631.
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'programmer.h')
-rw-r--r-- | programmer.h | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/programmer.h b/programmer.h index 1510e2fba..e2bb3d821 100644 --- a/programmer.h +++ b/programmer.h @@ -90,8 +90,20 @@ enum programmer { PROGRAMMER_INVALID /* This must always be the last entry. */ }; +enum programmer_type { + PCI = 1, /* to detect uninitialized values */ + USB, + OTHER, +}; + struct programmer_entry { const char *name; + const enum programmer_type type; + union { + const struct pcidev_status *const pci; + const struct usbdev_status *const usb; + const char *const note; + } devs; int (*init) (void); @@ -219,13 +231,6 @@ void internal_delay(int usecs); extern uint32_t io_base_addr; extern struct pci_access *pacc; extern struct pci_dev *pcidev_dev; -struct pcidev_status { - uint16_t vendor_id; - uint16_t device_id; - const enum test_state status; - const char *vendor_name; - const char *device_name; -}; uintptr_t pcidev_readbar(struct pci_dev *dev, int bar); uintptr_t pcidev_init(int bar, const struct pcidev_status *devs); /* rpci_write_* are reversible writes. The original PCI config space register @@ -242,6 +247,21 @@ int rpci_write_long(struct pci_dev *dev, int reg, uint32_t data); void print_supported_pcidevs(const struct pcidev_status *devs); #endif +struct usbdev_status { + uint16_t vendor_id; + uint16_t device_id; + const enum test_state status; + const char *vendor_name; + const char *device_name; +}; +struct pcidev_status { + uint16_t vendor_id; + uint16_t device_id; + const enum test_state status; + const char *vendor_name; + const char *device_name; +}; + #if CONFIG_INTERNAL == 1 /* board_enable.c */ int board_parse_parameter(const char *boardstring, const char **vendor, const char **model); @@ -420,13 +440,6 @@ extern const struct pcidev_status ata_hpt[]; /* ft2232_spi.c */ #if CONFIG_FT2232_SPI == 1 -struct usbdev_status { - uint16_t vendor_id; - uint16_t device_id; - const enum test_state status; - const char *vendor_name; - const char *device_name; -}; int ft2232_spi_init(void); extern const struct usbdev_status devs_ft2232spi[]; void print_supported_usbdevs(const struct usbdev_status *devs); |