[flashrom] [PATCH 1/3] Refactor PCI and USB device status printing.

Stefan Tauner stefan.tauner at student.tuwien.ac.at
Sat Nov 17 20:09:34 CET 2012


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 devices (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.

Signed-off-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
---
 flashrom.c   |   48 ++++++++++++++++++-
 ft2232_spi.c |   13 ------
 pcidev.c     |   13 ------
 print.c      |  148 +++++++++++++++++++---------------------------------------
 print_wiki.c |  141 ++++++++++++++++++++++++++++++++++---------------------
 programmer.h |   41 ++++++++++------
 6 files changed, 211 insertions(+), 193 deletions(-)

diff --git a/flashrom.c b/flashrom.c
index 2299b06..d873276 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -64,6 +64,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_INTERNAL == 1
 	{
 		.name			= "internal",
+		.type			= OTHER,
+		.devices.note		= NULL,
 		.init			= internal_init,
 		.map_flash_region	= physmap,
 		.unmap_flash_region	= physunmap,
@@ -74,6 +76,9 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_DUMMY == 1
 	{
 		.name			= "dummy",
+		.type			= OTHER,
+					/* FIXME */
+		.devices.note		= "Dummy device, does nothing and logs all accesses\n",
 		.init			= dummy_init,
 		.map_flash_region	= dummy_map,
 		.unmap_flash_region	= dummy_unmap,
@@ -84,6 +89,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_NIC3COM == 1
 	{
 		.name			= "nic3com",
+		.type			= PCI,
+		.devices.pci		= nics_3com,
 		.init			= nic3com_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -95,6 +102,8 @@ const struct programmer_entry programmer_table[] = {
 	{
 		/* This programmer works for Realtek RTL8139 and SMC 1211. */
 		.name			= "nicrealtek",
+		.type			= PCI,
+		.devices.pci		= nics_realtek,
 		.init			= nicrealtek_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -105,6 +114,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_NICNATSEMI == 1
 	{
 		.name			= "nicnatsemi",
+		.type			= PCI,
+		.devices.pci		= nics_natsemi,
 		.init			= nicnatsemi_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -115,6 +126,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_GFXNVIDIA == 1
 	{
 		.name			= "gfxnvidia",
+		.type			= PCI,
+		.devices.pci		= gfx_nvidia,
 		.init			= gfxnvidia_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -125,6 +138,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_DRKAISER == 1
 	{
 		.name			= "drkaiser",
+		.type			= PCI,
+		.devices.pci		= drkaiser_pcidev,
 		.init			= drkaiser_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -135,6 +150,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_SATASII == 1
 	{
 		.name			= "satasii",
+		.type			= PCI,
+		.devices.pci		= satas_sii,
 		.init			= satasii_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -145,6 +162,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_ATAHPT == 1
 	{
 		.name			= "atahpt",
+		.type			= PCI,
+		.devices.pci		= ata_hpt,
 		.init			= atahpt_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -155,6 +174,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_FT2232_SPI == 1
 	{
 		.name			= "ft2232_spi",
+		.type			= USB,
+		.devices.usb		= devs_ft2232spi,
 		.init			= ft2232_spi_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -165,6 +186,9 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_SERPROG == 1
 	{
 		.name			= "serprog",
+		.type			= OTHER,
+					/* FIXME */
+		.devices.note		= "All programmer devices speaking the serprog protocol\n",
 		.init			= serprog_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -175,6 +199,9 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_BUSPIRATE_SPI == 1
 	{
 		.name			= "buspirate_spi",
+		.type			= OTHER,
+					/* FIXME */
+		.devices.note		= "Dangerous Prototypes Bus Pirate\n",
 		.init			= buspirate_spi_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -185,6 +212,9 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_DEDIPROG == 1
 	{
 		.name			= "dediprog",
+		.type			= OTHER,
+					/* FIXME */
+		.devices.note		= "Dediprog SF100\n",
 		.init			= dediprog_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -195,6 +225,9 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_RAYER_SPI == 1
 	{
 		.name			= "rayer_spi",
+		.type			= OTHER,
+					/* FIXME */
+		.devices.note		= "RayeR parallel port programmer\n",
 		.init			= rayer_spi_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -205,16 +238,21 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_PONY_SPI == 1
 	{
 		.name			= "pony_spi",
+		.type			= OTHER,
+					/* FIXME */
+		.devices.note		= "Programmers compatible with SI-Prog, serbang or AJAWe\n",
 		.init			= pony_spi_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
 		.delay			= internal_delay,
-},
+	},
 #endif
 
 #if CONFIG_NICINTEL == 1
 	{
 		.name			= "nicintel",
+		.type			= PCI,
+		.devices.pci		= nics_intel,
 		.init			= nicintel_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -225,6 +263,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_NICINTEL_SPI == 1
 	{
 		.name			= "nicintel_spi",
+		.type			= PCI,
+		.devices.pci		= nics_intel_spi,
 		.init			= nicintel_spi_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -235,6 +275,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_OGP_SPI == 1
 	{
 		.name			= "ogp_spi",
+		.type			= PCI,
+		.devices.pci		= ogp_spi,
 		.init			= ogp_spi_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -245,6 +287,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_SATAMV == 1
 	{
 		.name			= "satamv",
+		.type			= PCI,
+		.devices.pci		= satas_mv,
 		.init			= satamv_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
@@ -255,6 +299,8 @@ const struct programmer_entry programmer_table[] = {
 #if CONFIG_LINUX_SPI == 1
 	{
 		.name			= "linux_spi",
+		.type			= OTHER,
+		.devices.note		= "Device files /dev/spidev*.*\n",
 		.init			= linux_spi_init,
 		.map_flash_region	= fallback_map,
 		.unmap_flash_region	= fallback_unmap,
diff --git a/ft2232_spi.c b/ft2232_spi.c
index c09405e..dc17d00 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -482,17 +482,4 @@ static int ft2232_spi_send_command(struct flashctx *flash,
 	return failed ? -1 : 0;
 }
 
-void print_supported_usbdevs(const struct usbdev_status *devs)
-{
-	int i;
-
-	msg_pinfo("USB devices:\n");
-	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,
-			  devs[i].device_id,
-			  (devs[i].status == NT) ? " (untested)" : "");
-	}
-}
-
 #endif
diff --git a/pcidev.c b/pcidev.c
index c1b6d6a..bfc8a5d 100644
--- a/pcidev.c
+++ b/pcidev.c
@@ -224,19 +224,6 @@ uintptr_t pcidev_init(int bar, const struct pcidev_status *devs)
 	return curaddr;
 }
 
-void print_supported_pcidevs(const struct pcidev_status *devs)
-{
-	int i;
-
-	msg_pinfo("PCI devices:\n");
-	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,
-		          devs[i].device_id,
-		          (devs[i].status == NT) ? " (untested)" : "");
-	}
-}
-
 enum pci_write_type {
 	pci_write_type_byte,
 	pci_write_type_word,
diff --git a/print.c b/print.c
index d7bdbfe..4b23ca0 100644
--- a/print.c
+++ b/print.c
@@ -433,8 +433,32 @@ static void print_supported_boards_helper(const struct board_info *boards,
 }
 #endif
 
+void print_supported_usbdevs(const struct usbdev_status *devs)
+{
+	int i;
+
+	msg_pinfo("USB devices:\n");
+	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,
+			  devs[i].device_id, (devs[i].status == NT) ? " (untested)" : "");
+	}
+}
+
+#if NEED_PCI == 1
+void print_supported_pcidevs(const struct pcidev_status *devs)
+{
+	int i;
+
+	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,
+		          devs[i].device_id, (devs[i].status == NT) ? " (untested)" : "");
+	}
+}
+#endif
+
 int print_supported(void)
 {
+	unsigned int i;
 	if (print_supported_chips())
 		return 1;
 
@@ -449,107 +473,31 @@ int print_supported(void)
 	msg_ginfo("\n");
 	print_supported_boards_helper(laptops_known, "laptops");
 #endif
-#if CONFIG_DUMMY == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_DUMMY].name);
-	/* FIXME */
-	msg_ginfo("Dummy device, does nothing and logs all accesses\n");
-#endif
-#if CONFIG_NIC3COM == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_NIC3COM].name);
-	print_supported_pcidevs(nics_3com);
-#endif
-#if CONFIG_NICREALTEK == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_NICREALTEK].name);
-	print_supported_pcidevs(nics_realtek);
-#endif
-#if CONFIG_NICNATSEMI == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_NICNATSEMI].name);
-	print_supported_pcidevs(nics_natsemi);
-#endif
-#if CONFIG_GFXNVIDIA == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_GFXNVIDIA].name);
-	print_supported_pcidevs(gfx_nvidia);
-#endif
-#if CONFIG_DRKAISER == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_DRKAISER].name);
-	print_supported_pcidevs(drkaiser_pcidev);
-#endif
-#if CONFIG_SATASII == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_SATASII].name);
-	print_supported_pcidevs(satas_sii);
-#endif
-#if CONFIG_ATAHPT == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_ATAHPT].name);
-	print_supported_pcidevs(ata_hpt);
-#endif
-#if CONFIG_FT2232_SPI == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_FT2232_SPI].name);
-	print_supported_usbdevs(devs_ft2232spi);
-#endif
-#if CONFIG_SERPROG == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_SERPROG].name);
-	/* FIXME */
-	msg_ginfo("All programmer devices speaking the serprog protocol\n");
-#endif
-#if CONFIG_BUSPIRATE_SPI == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_BUSPIRATE_SPI].name);
-	/* FIXME */
-	msg_ginfo("Dangerous Prototypes Bus Pirate\n");
-#endif
-#if CONFIG_DEDIPROG == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_DEDIPROG].name);
-	/* FIXME */
-	msg_ginfo("Dediprog SF100\n");
-#endif
-#if CONFIG_RAYER_SPI == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_RAYER_SPI].name);
-	/* FIXME */
-	msg_ginfo("RayeR parallel port programmer\n");
-#endif
-#if CONFIG_PONY_SPI == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_PONY_SPI].name);
-	/* FIXME */
-	msg_ginfo("SI-Prog, serbang and AJAWe serial port programmers\n");
-#endif
-#if CONFIG_NICINTEL == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_NICINTEL].name);
-	print_supported_pcidevs(nics_intel);
-#endif
-#if CONFIG_NICINTEL_SPI == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_NICINTEL_SPI].name);
-	print_supported_pcidevs(nics_intel_spi);
-#endif
-#if CONFIG_OGP_SPI == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_OGP_SPI].name);
-	print_supported_pcidevs(ogp_spi);
-#endif
-#if CONFIG_SATAMV == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_SATAMV].name);
-	print_supported_pcidevs(satas_mv);
-#endif
-#if CONFIG_LINUX_SPI == 1
-	msg_ginfo("\nSupported devices for the %s programmer:\n",
-	       programmer_table[PROGRAMMER_LINUX_SPI].name);
-	msg_ginfo("Device files /dev/spidev*.*\n");
+	for (i = 0; i < PROGRAMMER_INVALID; i++) {
+		const struct programmer_entry prog = programmer_table[i];
+		switch (prog.type) {
+		case USB:
+			msg_ginfo("\nSupported USB devices for the %s programmer:\n", prog.name);
+			print_supported_usbdevs(prog.devices.usb);
+			break;
+#if NEED_PCI == 1
+		case PCI:
+			msg_ginfo("\nSupported PCI devices for the %s programmer:\n", prog.name);
+			print_supported_pcidevs(prog.devices.pci);
+			break;
 #endif
+		case OTHER:
+			if (prog.devices.note == NULL)
+				break;
+			msg_ginfo("\nSupported devices for the %s programmer:\n", prog.name);
+			msg_ginfo("%s", prog.devices.note);
+			break;
+		default:
+			msg_gerr("\n%s: %s: Uninitialized programmer type! Please report a bug at "
+				 "flashrom at flashrom.org\n", __func__, prog.name);
+			break;
+		}
+	}
 	return 0;
 }
 
diff --git a/print_wiki.c b/print_wiki.c
index 617053c..17e2e85 100644
--- a/print_wiki.c
+++ b/print_wiki.c
@@ -79,13 +79,9 @@ static const char chip_th[] = "\
 static const char programmer_th[] = "\
 ! align=\"left\" | Vendor\n\
 ! align=\"left\" | Device\n\
-! align=\"center\" | PCI IDs\n\
+! align=\"center\" | IDs\n\
 ! align=\"center\" | Status\n\n";
 
-static const char programmer_intro[] = "\
-\n== Supported programmers ==\n\n\
-This is a list of supported PCI devices flashrom can use as programmer:\n\n{";
-
 #if CONFIG_INTERNAL == 1
 static const char laptop_intro[] = "\n== Supported laptops/notebooks ==\n\n\
 In general, flashing laptops is more difficult because laptops\n\n\
@@ -139,7 +135,7 @@ static void print_supported_chipsets_wiki(int cols)
 	printf("\n\n|}\n");
 }
 
-static void wiki_helper(const char *devicetype, int cols, const struct board_info boards[])
+static void print_supported_boards_wiki_helper(const char *devicetype, int cols, const struct board_info boards[])
 {
 	int i, k;
 	unsigned int boardcount, lines_per_col;
@@ -222,10 +218,10 @@ static void wiki_helper(const char *devicetype, int cols, const struct board_inf
 static void print_supported_boards_wiki(void)
 {
 	printf("%s", board_intro);
-	wiki_helper("boards", 2, boards_known);
+	print_supported_boards_wiki_helper("boards", 2, boards_known);
 
 	printf("%s", laptop_intro);
-	wiki_helper("laptops", 1, laptops_known);
+	print_supported_boards_wiki_helper("laptops", 1, laptops_known);
 }
 #endif
 
@@ -302,9 +298,18 @@ static void print_supported_chips_wiki(int cols)
 	printf("|}\n\n");
 }
 
-/* Not needed for CONFIG_INTERNAL, but for all other PCI-based programmers. */
-#if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT+CONFIG_NICINTEL+CONFIG_NICINTEL_SPI+CONFIG_OGP_SPI+CONFIG_SATAMV >= 1
-static void print_supported_pcidevs_wiki(const struct pcidev_status *devs)
+/* 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_pcidevs_wiki(const struct pcidev_status *devs)
+{
+	unsigned int count = 0;
+	unsigned int i = 0;
+	for (i = 0; devs[i].vendor_name != NULL; i++)
+			count++;
+	return count;
+}
+
+static void print_supported_pcidevs_wiki_helper(const struct pcidev_status *devs)
 {
 	int i = 0;
 	static int c = 0;
@@ -313,14 +318,81 @@ static void print_supported_pcidevs_wiki(const struct pcidev_status *devs)
 	c = !c;
 
 	for (i = 0; devs[i].vendor_name != NULL; i++) {
-		printf("|- bgcolor=\"#%s\"\n| %s || %s || "
-		       "%04x:%04x || {{%s}}\n", (c) ? "eeeeee" : "dddddd",
-		       devs[i].vendor_name, devs[i].device_name,
-		       devs[i].vendor_id, devs[i].device_id,
+		printf("|- bgcolor=\"#%s\"\n| %s || %s || %04x:%04x || {{%s}}\n", (c) ? "eeeeee" : "dddddd",
+		       devs[i].vendor_name, devs[i].device_name, devs[i].vendor_id, devs[i].device_id,
 		       (devs[i].status == NT) ? "?3" : "OK");
 	}
 }
-#endif
+
+static int count_supported_usbdevs_wiki(const struct usbdev_status *devs)
+{
+	unsigned int count = 0;
+	unsigned int i = 0;
+	for (i = 0; devs[i].vendor_name != NULL; i++)
+			count++;
+	return count;
+}
+
+static void print_supported_usbdevs_wiki_helper(const struct usbdev_status *devs)
+{
+	int i = 0;
+	static int c = 0;
+
+	/* Alternate colors if the vendor changes. */
+	c = !c;
+
+	for (i = 0; devs[i].vendor_name != NULL; i++) {
+		printf("|- bgcolor=\"#%s\"\n| %s || %s || %04x:%04x || {{%s}}\n", (c) ? "eeeeee" : "dddddd",
+		       devs[i].vendor_name, devs[i].device_name, devs[i].vendor_id, devs[i].device_id,
+		       (devs[i].status == NT) ? "?3" : "OK");
+	}
+}
+
+static void print_supported_devs_wiki()
+{
+	unsigned int pci_count = 0;
+	unsigned int usb_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_usbdevs_wiki(prog.devices.usb);
+			break;
+		case PCI:
+			pci_count += count_supported_pcidevs_wiki(prog.devices.pci);
+			break;
+		case OTHER:
+		default:
+			break;
+		}
+	}
+
+	printf("\n== PCI Devices ==\n\n"
+	       "Total amount of supported PCI devices flashrom can use as a programmer: '''%d'''\n\n"
+	       "{%s%s", pci_count, th_start, programmer_th);
+
+	for (i = 0; i < PROGRAMMER_INVALID; i++) {
+		const struct programmer_entry prog = programmer_table[i];
+		if (prog.type == PCI) {
+			print_supported_pcidevs_wiki_helper(prog.devices.pci);
+		}
+	}
+	printf("\n|}\n\n|}\n");
+
+	printf("\n== USB Devices ==\n\n"
+	       "Total amount of supported USB devices flashrom can use as a programmer: '''%d'''\n\n"
+	       "{%s%s", usb_count, th_start, programmer_th);
+
+	for (i = 0; i < PROGRAMMER_INVALID; i++) {
+		const struct programmer_entry prog = programmer_table[i];
+		if (prog.type == USB) {
+			print_supported_usbdevs_wiki_helper(prog.devices.usb);
+		}
+	}
+	printf("\n|}\n\n|}\n");
+}
 
 void print_supported_wiki(void)
 {
@@ -332,41 +404,6 @@ void print_supported_wiki(void)
 	print_supported_chipsets_wiki(3);
 	print_supported_boards_wiki();
 #endif
-	printf("%s%s%s", programmer_intro, th_start, programmer_th);
-
-#if CONFIG_NIC3COM == 1
-	print_supported_pcidevs_wiki(nics_3com);
-#endif
-#if CONFIG_NICREALTEK == 1
-	print_supported_pcidevs_wiki(nics_realtek);
-#endif
-#if CONFIG_NICNATSEMI == 1
-	print_supported_pcidevs_wiki(nics_natsemi);
-#endif
-#if CONFIG_GFXNVIDIA == 1
-	print_supported_pcidevs_wiki(gfx_nvidia);
-#endif
-#if CONFIG_DRKAISER == 1
-	print_supported_pcidevs_wiki(drkaiser_pcidev);
-#endif
-#if CONFIG_SATASII == 1
-	print_supported_pcidevs_wiki(satas_sii);
-#endif
-#if CONFIG_ATAHPT == 1
-	print_supported_pcidevs_wiki(ata_hpt);
-#endif
-#if CONFIG_NICINTEL == 1
-	print_supported_pcidevs_wiki(nics_intel);
-#endif
-#if CONFIG_NICINTEL_SPI == 1
-	print_supported_pcidevs_wiki(nics_intel_spi);
-#endif
-#if CONFIG_OGP_SPI == 1
-	print_supported_pcidevs_wiki(ogp_spi);
-#endif
-#if CONFIG_SATAMV == 1
-	print_supported_pcidevs_wiki(satas_mv);
-#endif
-	printf("\n|}\n\n|}\n");
+	print_supported_devs_wiki();
 }
 
diff --git a/programmer.h b/programmer.h
index dedec67..21fa707 100644
--- a/programmer.h
+++ b/programmer.h
@@ -90,9 +90,21 @@ 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 *vendor;
 	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;
+	} devices;
 
 	int (*init) (void);
 
@@ -221,13 +233,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
@@ -244,6 +249,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);
@@ -422,13 +442,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);
-- 
Kind regards, Stefan Tauner





More information about the flashrom mailing list