Am 04.04.2013 06:57 schrieb Kyösti Mälkki:
On Thu, 2013-04-04 at 02:07 +0200, Carl-Daniel Hailfinger wrote:
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.
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).
The patch (which never appeared on the mailing list, BTW) was about fixing rayer_spi to list the different pinout models with flashrom -L. It wasn't a solution to any other programmer hardware. With the existing state of review queue, I felt it was better not to suggest global changes. Unfortunately, this dev_entry came up during the discussion.
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.
I need a conclusion on patches 3920-3924 first to regain motivation. I received Your comments on #flashrom previously, but since then You posted these partially conflicting and incompatible patches on the list.
Stefan Tauner has committed those meanwhile.
I will probably return to this topic in an average flashrom review feedback time.
New version. Wiki support is done, but I'm not totally happy with the "Other" device output, especially the column labels. Suggestions are appreciated. Sample wiki output is here: https://www.flashrom.org/User:Hailfinger/Tests/--print-wiki2#Other_devices
I also would love to get a review of the changes for the -L output for non-ID devices.
Additional changes compared to previous versions of the patch: Dediprog is now listed as USB device instead of as a "Other" device. Rayer_spi now uses the same array for model selection and -L/-z.
TODO: Pony_spi should use the same code as Rayer_spi for handling different variants of the hardware. Debatable whether that should happen in this patch. Dediprog should not code the IDs in a table, then use them again in open-coded form during init. Same for Usbblaster_spi. Ft2232_spi is even weirder in that regard. In general, all the USB programmers have init functions without any consistent style whatsoever compared to the unified PCI programmer init approach. A few FIXMEs and #warnings mark the places where review would be highly appreciated.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-noid_programmers_support_device_list/atahpt.c =================================================================== --- flashrom-noid_programmers_support_device_list/atahpt.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/atahpt.c (Arbeitskopie) @@ -35,7 +35,7 @@
static uint32_t io_base_addr = 0;
-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/atavia.c =================================================================== --- flashrom-noid_programmers_support_device_list/atavia.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/atavia.c (Arbeitskopie) @@ -52,7 +52,7 @@ #define ENABLE_BYTE(address) ((~(1 << ((address) & 3))) & BROM_BYTE_ENABLE_MASK) #define BYTE_OFFSET(address) (((addr) & 3) * 8)
-const struct dev_entry ata_via[] = { +const struct id_dev_entry ata_via[] = { {PCI_VENDOR_ID_VIA, 0x3249, DEP, "VIA", "VT6421A"},
{}, Index: flashrom-noid_programmers_support_device_list/buspirate_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/buspirate_spi.c (Revision 1842) +++ 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/dediprog.c =================================================================== --- flashrom-noid_programmers_support_device_list/dediprog.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/dediprog.c (Arbeitskopie) @@ -27,6 +27,15 @@ #include "programmer.h" #include "spi.h"
+#define DEDIPROG_VID 0x0483 +#define SF100_PID 0xdada + +const struct id_dev_entry dediprog_devs[] = { + {DEDIPROG_VID, SF100_PID, OK, "Dediprog", "SF100"}, + + {} +}; + #define FIRMWARE_VERSION(x,y,z) ((x << 16) | (y << 8) | z) #define DEFAULT_TIMEOUT 3000 static usb_dev_handle *dediprog_handle; @@ -876,7 +885,8 @@ usb_init(); usb_find_busses(); usb_find_devices(); - dev = get_device_by_vid_pid(0x0483, 0xdada, (unsigned int) usedevice); +#warning Use dediprog_devs instead + dev = get_device_by_vid_pid(DEDIPROG_VID, SF100_PID, (unsigned int) usedevice); if (!dev) { msg_perr("Could not find a Dediprog SF100 on USB!\n"); return 1; Index: flashrom-noid_programmers_support_device_list/drkaiser.c =================================================================== --- flashrom-noid_programmers_support_device_list/drkaiser.c (Revision 1842) +++ 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/dummyflasher.c =================================================================== --- flashrom-noid_programmers_support_device_list/dummyflasher.c (Revision 1842) +++ 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/flashrom.c =================================================================== --- flashrom-noid_programmers_support_device_list/flashrom.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/flashrom.c (Arbeitskopie) @@ -63,7 +63,7 @@ { .name = "internal", .type = OTHER, - .devs.note = NULL, + .devs.noid_dev = internal_devs, .init = internal_init, .map_flash_region = physmap, .unmap_flash_region = physunmap, @@ -75,8 +75,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, @@ -88,7 +87,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, @@ -101,7 +100,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, @@ -113,7 +112,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, @@ -125,7 +124,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, @@ -137,7 +136,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, @@ -149,7 +148,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, @@ -161,7 +160,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, @@ -173,7 +172,7 @@ { .name = "atavia", .type = PCI, - .devs.dev = ata_via, + .devs.id_dev = ata_via, .init = atavia_init, .map_flash_region = atavia_map, .unmap_flash_region = fallback_unmap, @@ -185,7 +184,7 @@ { .name = "it8212", .type = PCI, - .devs.dev = devs_it8212, + .devs.id_dev = devs_it8212, .init = it8212_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -197,7 +196,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, @@ -209,8 +208,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, @@ -222,8 +220,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, @@ -234,9 +231,8 @@ #if CONFIG_DEDIPROG == 1 { .name = "dediprog", - .type = OTHER, - /* FIXME */ - .devs.note = "Dediprog SF100\n", + .type = USB, + .devs.id_dev = dediprog_devs, .init = dediprog_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -248,8 +244,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, @@ -261,8 +256,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, @@ -274,7 +268,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, @@ -286,7 +280,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, @@ -298,7 +292,7 @@ { .name = "nicintel_eeprom", .type = PCI, - .devs.dev = nics_intel_ee, + .devs.id_dev = nics_intel_ee, .init = nicintel_ee_init, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, @@ -310,7 +304,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, @@ -322,7 +316,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, @@ -334,7 +328,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, @@ -346,7 +340,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, @@ -1709,11 +1703,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", - p.name); + /* The union id_dev/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; } break; Index: flashrom-noid_programmers_support_device_list/ft2232_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/ft2232_spi.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/ft2232_spi.c (Arbeitskopie) @@ -58,7 +58,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/gfxnvidia.c =================================================================== --- flashrom-noid_programmers_support_device_list/gfxnvidia.c (Revision 1842) +++ 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/internal.c =================================================================== --- flashrom-noid_programmers_support_device_list/internal.c (Revision 1842) +++ 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/it8212.c =================================================================== --- flashrom-noid_programmers_support_device_list/it8212.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/it8212.c (Arbeitskopie) @@ -27,7 +27,7 @@
#define PCI_VENDOR_ID_ITE 0x1283
-const struct dev_entry devs_it8212[] = { +const struct id_dev_entry devs_it8212[] = { {PCI_VENDOR_ID_ITE, 0x8212, NT, "ITE", "8212F PATA RAID"},
{}, Index: flashrom-noid_programmers_support_device_list/linux_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/linux_spi.c (Revision 1842) +++ 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/nic3com.c =================================================================== --- flashrom-noid_programmers_support_device_list/nic3com.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/nic3com.c (Arbeitskopie) @@ -37,7 +37,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/nicintel.c =================================================================== --- flashrom-noid_programmers_support_device_list/nicintel.c (Revision 1842) +++ 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/nicintel_eeprom.c =================================================================== --- flashrom-noid_programmers_support_device_list/nicintel_eeprom.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/nicintel_eeprom.c (Arbeitskopie) @@ -64,7 +64,7 @@
#define UNPROG_DEVICE 0x1509
-const struct dev_entry nics_intel_ee[] = { +const struct id_dev_entry nics_intel_ee[] = { {PCI_VENDOR_ID_INTEL, 0x150e, OK, "Intel", "82580 Quad Gigabit Ethernet Controller (Copper)"}, {PCI_VENDOR_ID_INTEL, 0x150f, NT , "Intel", "82580 Quad Gigabit Ethernet Controller (Fiber)"}, {PCI_VENDOR_ID_INTEL, 0x1510, NT , "Intel", "82580 Quad Gigabit Ethernet Controller (Backplane)"}, Index: flashrom-noid_programmers_support_device_list/nicintel_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/nicintel_spi.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/nicintel_spi.c (Arbeitskopie) @@ -73,7 +73,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/nicnatsemi.c =================================================================== --- flashrom-noid_programmers_support_device_list/nicnatsemi.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/nicnatsemi.c (Arbeitskopie) @@ -31,7 +31,7 @@ #define BOOT_ROM_DATA 0x54
static uint32_t io_base_addr = 0; -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/nicrealtek.c =================================================================== --- flashrom-noid_programmers_support_device_list/nicrealtek.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/nicrealtek.c (Arbeitskopie) @@ -31,7 +31,7 @@ static uint32_t io_base_addr = 0; 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/ogp_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/ogp_spi.c (Revision 1842) +++ 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/pcidev.c =================================================================== --- flashrom-noid_programmers_support_device_list/pcidev.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/pcidev.c (Arbeitskopie) @@ -183,7 +183,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/pony_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/pony_spi.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/pony_spi.c (Arbeitskopie) @@ -47,6 +47,14 @@ #include "flash.h" #include "programmer.h"
+// FIXME: Make the names here consistent with the parameter names, and don't store the names both in the struct and again explicitly in the init function +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, @@ -152,6 +160,7 @@ * Configure the serial port pins, depending on the used programmer. */ switch (type) { +#warning Do this like rayer_spi.c does it case TYPE_AJAWE: pony_negate_cs = 1; pony_negate_sck = 1; Index: flashrom-noid_programmers_support_device_list/print.c =================================================================== --- flashrom-noid_programmers_support_device_list/print.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/print.c (Arbeitskopie) @@ -446,9 +446,9 @@ } #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) { - 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); unsigned int maxvendorlen = strlen("Vendor") + 1; unsigned int maxdevlen = strlen("Device") + 1; @@ -485,6 +485,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; @@ -507,18 +523,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 " Index: flashrom-noid_programmers_support_device_list/print_wiki.c =================================================================== --- flashrom-noid_programmers_support_device_list/print_wiki.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/print_wiki.c (Arbeitskopie) @@ -117,6 +117,12 @@ ! align="center" | IDs\n\ ! align="center" | Status\n\n";
+static const char noid_programmer_th[] = "\ +! align="left" | Programmer\n\ +! align="left" | Description\n\ +! align="center" | ID/Name\n\ +! align="center" | Status\n\n"; + /* The output of this module relies on MediaWiki templates to select special formatting styles for table cells * reflecting the test status of the respective hardware. This functions returns the correct template name for * the supplied enum test_state. */ @@ -350,21 +356,22 @@
/* 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; }
-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; @@ -378,10 +385,41 @@ } }
+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_noid_devs_wiki_helper(const struct programmer_entry prog) +{ + int i = 0; + static int c = 0; + const struct noid_dev_entry *devs = prog.devs.noid_dev; + const unsigned int count = count_supported_noid_devs_wiki(devs); + + /* Alternate colors if the programmer driver changes. */ + c = !c; + +#warning Caveat: prog.devs.noid_dev.type may be an empty string, change formatting in that case (see print.c) + for (i = 0; devs[i].type != NULL; i++) { + printf("|- bgcolor="#%s"\n", (c) ? "eeeeee" : "dddddd"); + if (i == 0) + printf("| rowspan="%u" | %s |", count, prog.name); + printf("| %s || %s || {{%s}}\n", devs[i].description, + devs[i].type, test_state_to_template(devs[i].status)); + } +} + 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++) { @@ -388,12 +426,19 @@ 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: +#if CONFIG_INTERNAL == 1 + /* Already handled in print_supported_chipsets_wiki()/print_supported_boards_wiki(). */ + if (i == PROGRAMMER_INTERNAL) + break; +#endif + other_count += count_supported_noid_devs_wiki(prog.devs.noid_dev); + break; default: break; } @@ -406,7 +451,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"); @@ -418,23 +463,24 @@ 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");
- printf("\n== Other programmers ==\n\n" - "{%s", th_start); - printf("! align="left" | Programmer\n" - "! align="left" | Note\n\n"); + printf("\n== Other devices ==\n\n" + "Total amount of supported other devices flashrom can use as a programmer: '''%d'''\n\n" + "{%s%s", other_count, th_start, noid_programmer_th);
for (i = 0; i < PROGRAMMER_INVALID; i++) { - static int c = 0; const struct programmer_entry prog = programmer_table[i]; - if (prog.type == OTHER && prog.devs.note != NULL) { - c = !c; - printf("|- bgcolor="#%s"\n", (c) ? "eeeeee" : "dddddd"); - printf("| %s || %s", prog.name, prog.devs.note); +#if CONFIG_INTERNAL == 1 + /* Already handled in print_supported_chipsets_wiki()/print_supported_boards_wiki(). */ + if (i == PROGRAMMER_INTERNAL) + continue; +#endif + if (prog.type == OTHER) { + print_supported_noid_devs_wiki_helper(prog); } } printf("\n|}\n\n|}\n"); Index: flashrom-noid_programmers_support_device_list/programmer.h =================================================================== --- flashrom-noid_programmers_support_device_list/programmer.h (Revision 1842) +++ flashrom-noid_programmers_support_device_list/programmer.h (Arbeitskopie) @@ -108,12 +108,20 @@ 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 { @@ -120,8 +128,8 @@ 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); @@ -180,7 +188,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. */ @@ -335,6 +343,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 */ @@ -375,78 +384,79 @@ int dummy_init(void); void *dummy_map(const char *descr, uintptr_t 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
/* nicintel_eeprom.c */ #if CONFIG_NICINTEL_EEPROM == 1 int nicintel_ee_init(void); -extern const struct dev_entry nics_intel_ee[]; +extern const struct id_dev_entry nics_intel_ee[]; #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
/* atavia.c */ @@ -453,35 +463,37 @@ #if CONFIG_ATAVIA == 1 int atavia_init(void); void *atavia_map(const char *descr, uintptr_t phys_addr, size_t len); -extern const struct dev_entry ata_via[]; +extern const struct id_dev_entry ata_via[]; #endif
/* it8212.c */ #if CONFIG_IT8212 == 1 int it8212_init(void); -extern const struct dev_entry devs_it8212[]; +extern const struct id_dev_entry devs_it8212[]; #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 */ @@ -490,16 +502,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 id_dev_entry dediprog_devs[]; #endif
/* flashrom.c */ @@ -684,6 +699,7 @@ #if CONFIG_SERPROG == 1 int serprog_init(void); void serprog_delay(unsigned int usecs); +extern const struct noid_dev_entry serprog_devs[]; #endif
/* serial.c */ Index: flashrom-noid_programmers_support_device_list/rayer_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/rayer_spi.c (Revision 1842) +++ flashrom-noid_programmers_support_device_list/rayer_spi.c (Arbeitskopie) @@ -40,13 +40,6 @@ * Default settings are for the RayeR hardware. */
-struct rayer_programmer { - const char *type; - const enum test_state status; - const char *description; - const void *dev_data; -}; - struct rayer_pinout { uint8_t cs_bit; uint8_t sck_bit; @@ -106,7 +99,7 @@ .miso_bit = 7, };
-static const struct rayer_programmer rayer_spi_types[] = { +const struct noid_dev_entry rayer_spi_devs[] = { {"rayer", NT, "RayeR SPIPGM", &rayer_spipgm}, {"xilinx", NT, "Xilinx Parallel Cable III (DLC 5)", &xilinx_dlc5}, {"byteblastermv", OK, "Altera ByteBlasterMV", &altera_byteblastermv}, @@ -163,7 +156,7 @@
int rayer_spi_init(void) { - const struct rayer_programmer *prog = rayer_spi_types; + const struct noid_dev_entry *prog = rayer_spi_devs; char *arg = NULL;
/* Non-default port requested? */ @@ -215,7 +208,7 @@ free(arg); } msg_pinfo("Using %s pinout.\n", prog->description); - pinout = (struct rayer_pinout *)prog->dev_data; + pinout = (struct rayer_pinout *)prog->devdata;
if (rget_io_perms()) return 1; Index: flashrom-noid_programmers_support_device_list/satamv.c =================================================================== --- flashrom-noid_programmers_support_device_list/satamv.c (Revision 1842) +++ 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/satasii.c =================================================================== --- flashrom-noid_programmers_support_device_list/satasii.c (Revision 1842) +++ 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/serprog.c =================================================================== --- flashrom-noid_programmers_support_device_list/serprog.c (Revision 1842) +++ 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/usbblaster_spi.c =================================================================== --- flashrom-noid_programmers_support_device_list/usbblaster_spi.c (Revision 1842) +++ 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"},
{}