Am 03.04.2013 01:11 schrieb Kyösti Mälkki:
On Wed, 2013-04-03 at 00:03 +0200, Carl-Daniel Hailfinger wrote:
Based on an idea by Kyösti Mälkki.
Except that you dropped the .private field in the dev_entry struct which made big difference.
Added a .devdata field for this purpose.
The if/elseif/else -approach used in ft2232_spi to parse type= command line parameter force a redundant listing of the model strings and you do not list the supported model strings verbatim in flashrom -L output.
AFAICS you didn't rework ft2232_spi either. Admittedly the possible changes for ft2232_spi are really not easy (one USB ID corresponds to two types, the other USB IDs correspond to one type each).
Anyway, this version should look better.
print_wiki.c is still not fully converted. The output of flashrom -L for non-PCI/USB devices should look better now, but I'd appreciate a review of the changes.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-noid_programmers_support_device_list/ogp_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/ogp_spi.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/ogp_spi.c (Arbeitskopie) @@ -47,7 +47,7 @@ static uint32_t ogp_reg__ce; static uint32_t ogp_reg_sck;
-const struct dev_entry ogp_spi[] = { +const struct id_dev_entry ogp_spi[] = { {PCI_VENDOR_ID_OGP, 0x0000, OK, "Open Graphics Project", "Development Board OGD1"},
{0}, Index: flashrom-noid_programmers_support_device_list/drkaiser.c =================================================================== --- flashrom-noid_programmers_support_device_list/drkaiser.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/drkaiser.c (Arbeitskopie) @@ -33,7 +33,7 @@ /* Mask to restrict flash accesses to the 128kB memory window. */ #define DRKAISER_MEMMAP_MASK ((1 << 17) - 1)
-const struct dev_entry drkaiser_pcidev[] = { +const struct id_dev_entry drkaiser_pcidev[] = { {0x1803, 0x5057, OK, "Dr. Kaiser", "PC-Waechter (Actel FPGA)"},
{0}, Index: flashrom-noid_programmers_support_device_list/pcidev.c =================================================================== --- flashrom-noid_programmers_support_device_list/pcidev.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/pcidev.c (Arbeitskopie) @@ -184,7 +184,7 @@ * also matches the specified bus:device.function. * For convenience, this function also registers its own undo handlers. */ -struct pci_dev *pcidev_init(const struct dev_entry *devs, int bar) +struct pci_dev *pcidev_init(const struct id_dev_entry *devs, int bar) { struct pci_dev *dev; struct pci_dev *found_dev = NULL; Index: flashrom-noid_programmers_support_device_list/gfxnvidia.c =================================================================== --- flashrom-noid_programmers_support_device_list/gfxnvidia.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/gfxnvidia.c (Arbeitskopie) @@ -34,7 +34,7 @@
uint8_t *nvidia_bar;
-const struct dev_entry gfx_nvidia[] = { +const struct id_dev_entry gfx_nvidia[] = { {0x10de, 0x0010, NT, "NVIDIA", "Mutara V08 [NV2]" }, {0x10de, 0x0018, NT, "NVIDIA", "RIVA 128" }, {0x10de, 0x0020, NT, "NVIDIA", "RIVA TNT" }, Index: flashrom-noid_programmers_support_device_list/serprog.c =================================================================== --- flashrom-noid_programmers_support_device_list/serprog.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/serprog.c (Arbeitskopie) @@ -44,6 +44,11 @@
#define MSGHEADER "serprog: "
+const struct noid_dev_entry serprog_devs[] = { + {"", OK, "All programmer devices speaking the serprog protocol"}, + {0}, +}; + /* * FIXME: This prototype was added to help reduce diffs for the shutdown * registration patch, which shifted many lines of code to place Index: flashrom-noid_programmers_support_device_list/nicrealtek.c =================================================================== --- flashrom-noid_programmers_support_device_list/nicrealtek.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/nicrealtek.c (Arbeitskopie) @@ -30,7 +30,7 @@
static int bios_rom_addr, bios_rom_data;
-const struct dev_entry nics_realtek[] = { +const struct id_dev_entry nics_realtek[] = { {0x10ec, 0x8139, OK, "Realtek", "RTL8139/8139C/8139C+"}, {0x10ec, 0x8169, NT, "Realtek", "RTL8169"}, {0x1113, 0x1211, OK, "SMC", "1211TX"}, /* RTL8139 clone */ Index: flashrom-noid_programmers_support_device_list/satamv.c =================================================================== --- flashrom-noid_programmers_support_device_list/satamv.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/satamv.c (Arbeitskopie) @@ -29,7 +29,7 @@ uint8_t *mv_bar; uint16_t mv_iobar;
-const struct dev_entry satas_mv[] = { +const struct id_dev_entry satas_mv[] = { /* 88SX6041 and 88SX6042 are the same according to the datasheet. */ {0x11ab, 0x7042, OK, "Marvell", "88SX7042 PCI-e 4-port SATA-II"},
Index: flashrom-noid_programmers_support_device_list/dummyflasher.c =================================================================== --- flashrom-noid_programmers_support_device_list/dummyflasher.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/dummyflasher.c (Arbeitskopie) @@ -39,6 +39,11 @@ #include <sys/stat.h> #endif
+const struct noid_dev_entry dummy_devs[] = { + {"", OK, "Dummy device, does nothing and logs all accesses"}, + {0}, +}; + #if EMULATE_CHIP static uint8_t *flashchip_contents = NULL; enum emu_chip { Index: flashrom-noid_programmers_support_device_list/internal.c =================================================================== --- flashrom-noid_programmers_support_device_list/internal.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/internal.c (Arbeitskopie) @@ -97,6 +97,13 @@ #endif
#if CONFIG_INTERNAL == 1 +/* The presence of this struct instance is an implementation quirk. We store supported chipsets and mainboards + * separately. + */ +const struct noid_dev_entry internal_devs[] = { + {0}, +}; + int force_boardenable = 0; int force_boardmismatch = 0;
Index: flashrom-noid_programmers_support_device_list/print_wiki.c =================================================================== --- flashrom-noid_programmers_support_device_list/print_wiki.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/print_wiki.c (Arbeitskopie) @@ -301,21 +301,23 @@
/* Following functions are not needed when no PCI/USB programmers are compiled in, * but since print_wiki code has no size constraints we include it unconditionally. */ -static int count_supported_devs_wiki(const struct dev_entry *devs) +static int count_supported_id_devs_wiki(const struct id_dev_entry *devs) { unsigned int count = 0; unsigned int i = 0; + for (i = 0; devs[i].vendor_id != 0; i++) count++; return count; } +#warning Handle noid_dev_entry devices
-static void print_supported_devs_wiki_helper(const struct programmer_entry prog) +static void print_supported_id_devs_wiki_helper(const struct programmer_entry prog) { int i = 0; static int c = 0; - const struct dev_entry *devs = prog.devs.dev; - const unsigned int count = count_supported_devs_wiki(devs); + const struct id_dev_entry *devs = prog.devs.id_dev; + const unsigned int count = count_supported_id_devs_wiki(devs);
/* Alternate colors if the vendor changes. */ c = !c; @@ -329,22 +331,35 @@ } }
+static int count_supported_noid_devs_wiki(const struct noid_dev_entry *devs) +{ + unsigned int count = 0; + unsigned int i = 0; + + for (i = 0; devs[i].type != NULL; i++) + count++; + return count; +} + static void print_supported_devs_wiki() { unsigned int pci_count = 0; unsigned int usb_count = 0; + unsigned int other_count = 0; unsigned int i;
for (i = 0; i < PROGRAMMER_INVALID; i++) { const struct programmer_entry prog = programmer_table[i]; switch (prog.type) { case USB: - usb_count += count_supported_devs_wiki(prog.devs.dev); + usb_count += count_supported_id_devs_wiki(prog.devs.id_dev); break; case PCI: - pci_count += count_supported_devs_wiki(prog.devs.dev); + pci_count += count_supported_id_devs_wiki(prog.devs.id_dev); break; case OTHER: + other_count += count_supported_noid_devs_wiki(prog.devs.noid_dev); + break; default: break; } @@ -357,7 +372,7 @@ for (i = 0; i < PROGRAMMER_INVALID; i++) { const struct programmer_entry prog = programmer_table[i]; if (prog.type == PCI) { - print_supported_devs_wiki_helper(prog); + print_supported_id_devs_wiki_helper(prog); } } printf("\n|}\n\n|}\n"); @@ -369,11 +384,12 @@ for (i = 0; i < PROGRAMMER_INVALID; i++) { const struct programmer_entry prog = programmer_table[i]; if (prog.type == USB) { - print_supported_devs_wiki_helper(prog); + print_supported_id_devs_wiki_helper(prog); } } printf("\n|}\n\n|}\n");
+#warning missing "Total amount of supported other devices", other_count printf("\n== Other programmers ==\n\n" "{%s", th_start); printf("! align="left" | Programmer\n" @@ -382,6 +398,13 @@ for (i = 0; i < PROGRAMMER_INVALID; i++) { static int c = 0; const struct programmer_entry prog = programmer_table[i]; +#if CONFIG_INTERNAL == 1 + /* Already handled in print_supported_chipsets_wiki()/print_supported_boards_wiki(). */ + if (i == PROGRAMMER_INTERNAL) + continue; +#endif +#warning .note does not exist anymore, the NULL check isn't needed anymore because we handle PROGRAMMER_INTERNAL explicitly +#warning This code should use print_supported_noid_devs_wiki_helper. Caveat: prog.devs.noid_dev.type may be an empty string, change formatting in that case (see print.c) if (prog.type == OTHER && prog.devs.note != NULL) { c = !c; printf("|- bgcolor="#%s"\n", (c) ? "eeeeee" : "dddddd"); Index: flashrom-noid_programmers_support_device_list/nicintel_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/nicintel_spi.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/nicintel_spi.c (Arbeitskopie) @@ -67,7 +67,7 @@
uint8_t *nicintel_spibar;
-const struct dev_entry nics_intel_spi[] = { +const struct id_dev_entry nics_intel_spi[] = { {PCI_VENDOR_ID_INTEL, 0x105e, OK, "Intel", "82571EB Gigabit Ethernet Controller"}, {PCI_VENDOR_ID_INTEL, 0x1076, OK, "Intel", "82541GI Gigabit Ethernet Controller"}, {PCI_VENDOR_ID_INTEL, 0x107c, OK, "Intel", "82541PI Gigabit Ethernet Controller"}, Index: flashrom-noid_programmers_support_device_list/usbblaster_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/usbblaster_spi.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/usbblaster_spi.c (Arbeitskopie) @@ -49,7 +49,7 @@ #define ALTERA_VID 0x09fb #define ALTERA_USBBLASTER_PID 0x6001
-const struct dev_entry devs_usbblasterspi[] = { +const struct id_dev_entry devs_usbblasterspi[] = { {ALTERA_VID, ALTERA_USBBLASTER_PID, OK, "Altera", "USB-Blaster"},
{} Index: flashrom-noid_programmers_support_device_list/nicnatsemi.c =================================================================== --- flashrom-noid_programmers_support_device_list/nicnatsemi.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/nicnatsemi.c (Arbeitskopie) @@ -30,7 +30,7 @@ #define BOOT_ROM_ADDR 0x50 #define BOOT_ROM_DATA 0x54
-const struct dev_entry nics_natsemi[] = { +const struct id_dev_entry nics_natsemi[] = { {0x100b, 0x0020, NT, "National Semiconductor", "DP83815/DP83816"}, {0x100b, 0x0022, NT, "National Semiconductor", "DP83820"},
Index: flashrom-noid_programmers_support_device_list/rayer_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/rayer_spi.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/rayer_spi.c (Arbeitskopie) @@ -37,6 +37,12 @@ #include "programmer.h" #include "hwaccess.h"
+const struct noid_dev_entry rayer_spi_devs[] = { + {"rayer", OK, "RayeR parallel port programmer"}, + {"xilinx", OK, "Xilinx Parallel Cable III (DLC 5)"}, + {0}, +}; + enum rayer_type { TYPE_RAYER, TYPE_XILINX_DLC5, Index: flashrom-noid_programmers_support_device_list/dediprog.c =================================================================== --- flashrom-noid_programmers_support_device_list/dediprog.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/dediprog.c (Arbeitskopie) @@ -27,6 +27,11 @@ #include "programmer.h" #include "spi.h"
+const struct noid_dev_entry dediprog_devs[] = { + {"", OK, "Dediprog SF100"}, + {0}, +}; + #define FIRMWARE_VERSION(x,y,z) ((x << 16) | (y << 8) | z) #define DEFAULT_TIMEOUT 3000 static usb_dev_handle *dediprog_handle; Index: flashrom-noid_programmers_support_device_list/buspirate_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/buspirate_spi.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/buspirate_spi.c (Arbeitskopie) @@ -27,6 +27,11 @@ #include "programmer.h" #include "spi.h"
+const struct noid_dev_entry buspirate_spi_devs[] = { + {"", OK, "Dangerous Prototypes Bus Pirate"}, + {0}, +}; + /* Change this to #define if you want to test without a serial implementation */ #undef FAKE_COMMUNICATION
Index: flashrom-noid_programmers_support_device_list/linux_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/linux_spi.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/linux_spi.c (Arbeitskopie) @@ -34,6 +34,11 @@ #include "programmer.h" #include "spi.h"
+const struct noid_dev_entry linux_spi_devs[] = { + {"", OK, "Device files /dev/spidev*.*"}, + {0}, +}; + static int fd = -1;
static int linux_spi_shutdown(void *data); Index: flashrom-noid_programmers_support_device_list/atahpt.c =================================================================== --- flashrom-noid_programmers_support_device_list/atahpt.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/atahpt.c (Arbeitskopie) @@ -33,7 +33,7 @@
#define PCI_VENDOR_ID_HPT 0x1103
-const struct dev_entry ata_hpt[] = { +const struct id_dev_entry ata_hpt[] = { {0x1103, 0x0004, NT, "Highpoint", "HPT366/368/370/370A/372/372N"}, {0x1103, 0x0005, NT, "Highpoint", "HPT372A/372N"}, {0x1103, 0x0006, NT, "Highpoint", "HPT302/302N"}, Index: flashrom-noid_programmers_support_device_list/nic3com.c =================================================================== --- flashrom-noid_programmers_support_device_list/nic3com.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/nic3com.c (Arbeitskopie) @@ -36,7 +36,7 @@ static uint32_t internal_conf; static uint16_t id;
-const struct dev_entry nics_3com[] = { +const struct id_dev_entry nics_3com[] = { /* 3C90xB */ {0x10b7, 0x9055, OK, "3COM", "3C90xB: PCI 10/100 Mbps; shared 10BASE-T/100BASE-TX"}, {0x10b7, 0x9001, NT, "3COM", "3C90xB: PCI 10/100 Mbps; shared 10BASE-T/100BASE-T4" }, Index: flashrom-noid_programmers_support_device_list/satasii.c =================================================================== --- flashrom-noid_programmers_support_device_list/satasii.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/satasii.c (Arbeitskopie) @@ -30,7 +30,7 @@ static uint8_t *sii_bar; static uint16_t id;
-const struct dev_entry satas_sii[] = { +const struct id_dev_entry satas_sii[] = { {0x1095, 0x0680, OK, "Silicon Image", "PCI0680 Ultra ATA-133 Host Ctrl"}, {0x1095, 0x3112, OK, "Silicon Image", "SiI 3112 [SATALink/SATARaid] SATA Ctrl"}, {0x1095, 0x3114, OK, "Silicon Image", "SiI 3114 [SATALink/SATARaid] SATA Ctrl"}, Index: flashrom-noid_programmers_support_device_list/ft2232_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/ft2232_spi.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/ft2232_spi.c (Arbeitskopie) @@ -57,7 +57,7 @@ #define OLIMEX_ARM_OCD_H_PID 0x002B #define OLIMEX_ARM_TINY_H_PID 0x002A
-const struct dev_entry devs_ft2232spi[] = { +const struct id_dev_entry devs_ft2232spi[] = { {FTDI_VID, FTDI_FT2232H_PID, OK, "FTDI", "FT2232H"}, {FTDI_VID, FTDI_FT4232H_PID, OK, "FTDI", "FT4232H"}, {FTDI_VID, FTDI_FT232H_PID, OK, "FTDI", "FT232H"}, Index: flashrom-noid_programmers_support_device_list/pony_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/pony_spi.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/pony_spi.c (Arbeitskopie) @@ -47,6 +47,13 @@ #include "flash.h" #include "programmer.h"
+const struct noid_dev_entry pony_spi_devs[] = { + {"serbang", OK, "Programmers compatible with serbang"}, + {"si_prog", OK, "Programmers compatible with SI-Prog"}, + {"ajawe", OK, "Programmers compatible with AJAWe"}, + {0}, +}; + enum pony_type { TYPE_SI_PROG, TYPE_SERBANG, Index: flashrom-noid_programmers_support_device_list/nicintel.c =================================================================== --- flashrom-noid_programmers_support_device_list/nicintel.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/nicintel.c (Arbeitskopie) @@ -27,7 +27,7 @@ uint8_t *nicintel_bar; uint8_t *nicintel_control_bar;
-const struct dev_entry nics_intel[] = { +const struct id_dev_entry nics_intel[] = { {PCI_VENDOR_ID_INTEL, 0x1209, NT, "Intel", "8255xER/82551IT Fast Ethernet Controller"}, {PCI_VENDOR_ID_INTEL, 0x1229, OK, "Intel", "82557/8/9/0/1 Ethernet Pro 100"},
Index: flashrom-noid_programmers_support_device_list/flashrom.c =================================================================== --- flashrom-noid_programmers_support_device_list/flashrom.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/flashrom.c (Arbeitskopie) @@ -65,7 +65,7 @@ { .name = "internal", .type = OTHER, - .devs.note = NULL, + .devs.noid_dev = internal_devs, .init = internal_init, .map_flash_region = physmap, .unmap_flash_region = physunmap, @@ -77,8 +77,7 @@ { .name = "dummy", .type = OTHER, - /* FIXME */ - .devs.note = "Dummy device, does nothing and logs all accesses\n", + .devs.noid_dev = dummy_devs, .init = dummy_init, .map_flash_region = dummy_map, .unmap_flash_region = dummy_unmap, @@ -90,7 +89,7 @@ { .name = "nic3com", .type = PCI, - .devs.dev = nics_3com, + .devs.id_dev = nics_3com, .init = nic3com_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -103,7 +102,7 @@ /* This programmer works for Realtek RTL8139 and SMC 1211. */ .name = "nicrealtek", .type = PCI, - .devs.dev = nics_realtek, + .devs.id_dev = nics_realtek, .init = nicrealtek_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -115,7 +114,7 @@ { .name = "nicnatsemi", .type = PCI, - .devs.dev = nics_natsemi, + .devs.id_dev = nics_natsemi, .init = nicnatsemi_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -127,7 +126,7 @@ { .name = "gfxnvidia", .type = PCI, - .devs.dev = gfx_nvidia, + .devs.id_dev = gfx_nvidia, .init = gfxnvidia_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -139,7 +138,7 @@ { .name = "drkaiser", .type = PCI, - .devs.dev = drkaiser_pcidev, + .devs.id_dev = drkaiser_pcidev, .init = drkaiser_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -151,7 +150,7 @@ { .name = "satasii", .type = PCI, - .devs.dev = satas_sii, + .devs.id_dev = satas_sii, .init = satasii_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -163,7 +162,7 @@ { .name = "atahpt", .type = PCI, - .devs.dev = ata_hpt, + .devs.id_dev = ata_hpt, .init = atahpt_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -175,7 +174,7 @@ { .name = "ft2232_spi", .type = USB, - .devs.dev = devs_ft2232spi, + .devs.id_dev = devs_ft2232spi, .init = ft2232_spi_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -187,8 +186,7 @@ { .name = "serprog", .type = OTHER, - /* FIXME */ - .devs.note = "All programmer devices speaking the serprog protocol\n", + .devs.noid_dev = serprog_devs, .init = serprog_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -200,8 +198,7 @@ { .name = "buspirate_spi", .type = OTHER, - /* FIXME */ - .devs.note = "Dangerous Prototypes Bus Pirate\n", + .devs.noid_dev = buspirate_spi_devs, .init = buspirate_spi_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -213,8 +210,7 @@ { .name = "dediprog", .type = OTHER, - /* FIXME */ - .devs.note = "Dediprog SF100\n", + .devs.noid_dev = dediprog_devs, .init = dediprog_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -226,8 +222,7 @@ { .name = "rayer_spi", .type = OTHER, - /* FIXME */ - .devs.note = "RayeR parallel port programmer\n", + .devs.noid_dev = rayer_spi_devs, .init = rayer_spi_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -239,8 +234,7 @@ { .name = "pony_spi", .type = OTHER, - /* FIXME */ - .devs.note = "Programmers compatible with SI-Prog, serbang or AJAWe\n", + .devs.noid_dev = pony_spi_devs, .init = pony_spi_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -252,7 +246,7 @@ { .name = "nicintel", .type = PCI, - .devs.dev = nics_intel, + .devs.id_dev = nics_intel, .init = nicintel_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -264,7 +258,7 @@ { .name = "nicintel_spi", .type = PCI, - .devs.dev = nics_intel_spi, + .devs.id_dev = nics_intel_spi, .init = nicintel_spi_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -276,7 +270,7 @@ { .name = "ogp_spi", .type = PCI, - .devs.dev = ogp_spi, + .devs.id_dev = ogp_spi, .init = ogp_spi_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -288,7 +282,7 @@ { .name = "satamv", .type = PCI, - .devs.dev = satas_mv, + .devs.id_dev = satas_mv, .init = satamv_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -300,7 +294,7 @@ { .name = "linux_spi", .type = OTHER, - .devs.note = "Device files /dev/spidev*.*\n", + .devs.noid_dev = linux_spi_devs, .init = linux_spi_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -312,7 +306,7 @@ { .name = "usbblaster_spi", .type = USB, - .devs.dev = devs_usbblasterspi, + .devs.id_dev = devs_usbblasterspi, .init = usbblaster_spi_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -1675,10 +1669,9 @@ case USB: case PCI: case OTHER: - if (p.devs.note == NULL) { - if (strcmp("internal", p.name) == 0) - break; /* This one has its device list stored separately. */ - msg_gerr("Programmer %s has neither a device list nor a textual description!\n", + /* Either id_dev or noid_dev should be non-NULL. */ + if (p.devs.id_dev == NULL) { + msg_gerr("Programmer %s doesn't have a device list!\n", p.name); ret = 1; } Index: flashrom-noid_programmers_support_device_list/programmer.h =================================================================== --- flashrom-noid_programmers_support_device_list/programmer.h (Revision 1666) +++ flashrom-noid_programmers_support_device_list/programmer.h (Arbeitskopie) @@ -99,20 +99,28 @@ OTHER, };
-struct dev_entry { +struct noid_dev_entry { + const char *type; + const enum test_state status; + const char *description; + const void *devdata; +}; + +struct id_dev_entry { uint16_t vendor_id; uint16_t device_id; const enum test_state status; const char *vendor_name; const char *device_name; + const void *devdata; };
struct programmer_entry { const char *name; const enum programmer_type type; union { - const struct dev_entry *const dev; - const char *const note; + const struct noid_dev_entry *const noid_dev; + const struct id_dev_entry *const id_dev; } devs;
int (*init) (void); @@ -172,7 +180,7 @@ extern struct pci_access *pacc; int pci_init_common(void); uintptr_t pcidev_readbar(struct pci_dev *dev, int bar); -struct pci_dev *pcidev_init(const struct dev_entry *devs, int bar); +struct pci_dev *pcidev_init(const struct id_dev_entry *devs, int bar); /* rpci_write_* are reversible writes. The original PCI config space register * contents will be restored on shutdown. */ @@ -320,6 +328,7 @@ int register_superio(struct superio s); extern enum chipbustype internal_buses_supported; int internal_init(void); +extern const struct noid_dev_entry internal_devs[]; #endif
/* hwaccess.c */ @@ -360,94 +369,97 @@ int dummy_init(void); void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); void dummy_unmap(void *virt_addr, size_t len); +extern const struct noid_dev_entry dummy_devs[]; #endif
/* nic3com.c */ #if CONFIG_NIC3COM == 1 int nic3com_init(void); -extern const struct dev_entry nics_3com[]; +extern const struct id_dev_entry nics_3com[]; #endif
/* gfxnvidia.c */ #if CONFIG_GFXNVIDIA == 1 int gfxnvidia_init(void); -extern const struct dev_entry gfx_nvidia[]; +extern const struct id_dev_entry gfx_nvidia[]; #endif
/* drkaiser.c */ #if CONFIG_DRKAISER == 1 int drkaiser_init(void); -extern const struct dev_entry drkaiser_pcidev[]; +extern const struct id_dev_entry drkaiser_pcidev[]; #endif
/* nicrealtek.c */ #if CONFIG_NICREALTEK == 1 int nicrealtek_init(void); -extern const struct dev_entry nics_realtek[]; +extern const struct id_dev_entry nics_realtek[]; #endif
/* nicnatsemi.c */ #if CONFIG_NICNATSEMI == 1 int nicnatsemi_init(void); -extern const struct dev_entry nics_natsemi[]; +extern const struct id_dev_entry nics_natsemi[]; #endif
/* nicintel.c */ #if CONFIG_NICINTEL == 1 int nicintel_init(void); -extern const struct dev_entry nics_intel[]; +extern const struct id_dev_entry nics_intel[]; #endif
/* nicintel_spi.c */ #if CONFIG_NICINTEL_SPI == 1 int nicintel_spi_init(void); -extern const struct dev_entry nics_intel_spi[]; +extern const struct id_dev_entry nics_intel_spi[]; #endif
/* ogp_spi.c */ #if CONFIG_OGP_SPI == 1 int ogp_spi_init(void); -extern const struct dev_entry ogp_spi[]; +extern const struct id_dev_entry ogp_spi[]; #endif
/* satamv.c */ #if CONFIG_SATAMV == 1 int satamv_init(void); -extern const struct dev_entry satas_mv[]; +extern const struct id_dev_entry satas_mv[]; #endif
/* satasii.c */ #if CONFIG_SATASII == 1 int satasii_init(void); -extern const struct dev_entry satas_sii[]; +extern const struct id_dev_entry satas_sii[]; #endif
/* atahpt.c */ #if CONFIG_ATAHPT == 1 int atahpt_init(void); -extern const struct dev_entry ata_hpt[]; +extern const struct id_dev_entry ata_hpt[]; #endif
/* ft2232_spi.c */ #if CONFIG_FT2232_SPI == 1 int ft2232_spi_init(void); -extern const struct dev_entry devs_ft2232spi[]; +extern const struct id_dev_entry devs_ft2232spi[]; #endif
/* usbblaster_spi.c */ #if CONFIG_USBBLASTER_SPI == 1 int usbblaster_spi_init(void); -extern const struct dev_entry devs_usbblasterspi[]; +extern const struct id_dev_entry devs_usbblasterspi[]; #endif
/* rayer_spi.c */ #if CONFIG_RAYER_SPI == 1 int rayer_spi_init(void); +extern const struct noid_dev_entry rayer_spi_devs[]; #endif
/* pony_spi.c */ #if CONFIG_PONY_SPI == 1 int pony_spi_init(void); +extern const struct noid_dev_entry pony_spi_devs[]; #endif
/* bitbang_spi.c */ @@ -456,16 +468,19 @@ /* buspirate_spi.c */ #if CONFIG_BUSPIRATE_SPI == 1 int buspirate_spi_init(void); +extern const struct noid_dev_entry buspirate_spi_devs[]; #endif
/* linux_spi.c */ #if CONFIG_LINUX_SPI == 1 int linux_spi_init(void); +extern const struct noid_dev_entry linux_spi_devs[]; #endif
/* dediprog.c */ #if CONFIG_DEDIPROG == 1 int dediprog_init(void); +extern const struct noid_dev_entry dediprog_devs[]; #endif
/* flashrom.c */ @@ -642,6 +657,7 @@ #if CONFIG_SERPROG == 1 int serprog_init(void); void serprog_delay(int usecs); +extern const struct noid_dev_entry serprog_devs[]; #endif
/* serial.c */ Index: flashrom-noid_programmers_support_device_list/print.c =================================================================== --- flashrom-noid_programmers_support_device_list/print.c (Revision 1666) +++ flashrom-noid_programmers_support_device_list/print.c (Arbeitskopie) @@ -433,11 +433,11 @@ } #endif
-void print_supported_devs(const struct programmer_entry prog, const char *const type) +static void print_supported_id_devs(const struct programmer_entry prog, const char *const type) { int i;
- const struct dev_entry *const devs = prog.devs.dev; + const struct id_dev_entry *const devs = prog.devs.id_dev; msg_ginfo("\nSupported %s devices for the %s programmer:\n", type, prog.name); for (i = 0; devs[i].vendor_name != NULL; i++) { msg_pinfo("%s %s [%04x:%04x]%s\n", devs[i].vendor_name, devs[i].device_name, devs[i].vendor_id, @@ -445,6 +445,22 @@ } }
+static void print_supported_noid_devs(const struct programmer_entry prog) +{ + int i; + + const struct noid_dev_entry *const devs = prog.devs.noid_dev; + msg_ginfo("\nSupported models for the %s programmer:\n", prog.name); + for (i = 0; devs[i].type != NULL; i++) { + if (!strcmp(devs[i].type, "")) + msg_pinfo("%s %s\n", devs[i].description, + (devs[i].status == NT) ? " (untested)" : ""); + else + msg_pinfo("%-20s %s %s\n", devs[i].type, devs[i].description, + (devs[i].status == NT) ? " (untested)" : ""); + } +} + int print_supported(void) { unsigned int i; @@ -467,18 +483,20 @@ const struct programmer_entry prog = programmer_table[i]; switch (prog.type) { case USB: - print_supported_devs(prog, "USB"); + print_supported_id_devs(prog, "USB"); break; #if NEED_PCI == 1 case PCI: - print_supported_devs(prog, "PCI"); + print_supported_id_devs(prog, "PCI"); break; #endif case OTHER: - if (prog.devs.note != NULL) { - msg_ginfo("\nSupported devices for the %s programmer:\n", prog.name); - msg_ginfo("%s", prog.devs.note); - } +#if CONFIG_INTERNAL == 1 + /* Already listed above. */ + if (i == PROGRAMMER_INTERNAL) + break; +#endif + print_supported_noid_devs(prog); break; default: msg_gerr("\n%s: %s: Uninitialized programmer type! Please report a bug at "