blob: b01ab75fdcd58f67d5a6bf5e4c0f4e1d8540feac [file] [log] [blame]
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
5 * Copyright (C) 2009 Carl-Daniel Hailfinger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
Peter Lemenkov4adf8a62010-06-01 10:13:17 +000022#include <stdio.h>
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000023#include <string.h>
24#include <stdlib.h>
25#include <time.h>
26#include "flash.h"
27#include "flashchips.h"
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000028#include "programmer.h"
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000029
Mathias Krausea60faab2011-01-17 07:50:42 +000030static const char wiki_header[] = "= Supported devices =\n\n\
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000031<div style=\"margin-top:0.5em; padding:0.5em 0.5em 0.5em 0.5em; \
Stefan Taunerf74a7b92011-09-14 22:09:48 +000032background-color:#eeeeee; text-align:right; border:1px solid #aabbcc;\">\
33<small>\n\
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000034Please do '''not''' edit these tables in the wiki directly, they are \
35generated by pasting '''flashrom -z''' output.<br />\
36'''Last update:''' %s(generated by flashrom %s)\n</small></div>\n";
37
Stefan Tauner00ec0272012-07-29 02:04:21 +000038static const char th_start[] = "| valign=\"top\"|\n\n\
39{| border=\"0\" style=\"font-size: smaller\" valign=\"top\"\n\
40|- bgcolor=\"#6699dd\"\n";
41
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +000042#if CONFIG_INTERNAL == 1
Stefan Tauner00ec0272012-07-29 02:04:21 +000043static const char chipset_th[] = "\
44! align=\"left\" | Vendor\n\
45! align=\"left\" | Southbridge\n\
46! align=\"center\" | PCI IDs\n\
Stefan Taunerf74a7b92011-09-14 22:09:48 +000047! align=\"center\" | Status\n\n";
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000048
Stefan Tauner00ec0272012-07-29 02:04:21 +000049static const char board_th[] = "\
50! align=\"left\" | Vendor\n\
51! align=\"left\" | Mainboard\n\
52! align=\"left\" | Required option\n\
Stefan Taunerf74a7b92011-09-14 22:09:48 +000053! align=\"center\" | Status\n\n";
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000054
Mathias Krausea60faab2011-01-17 07:50:42 +000055static const char board_intro[] = "\
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000056\n== Supported mainboards ==\n\n\
57In general, it is very likely that flashrom works out of the box even if your \
58mainboard is not listed below.\n\nThis is a list of mainboards where we have \
59verified that they either do or do not need any special initialization to \
60make flashrom work (given flashrom supports the respective chipset and flash \
61chip), or that they do not yet work at all. If they do not work, support may \
62or may not be added later.\n\n\
Stefan Taunerd06d9412011-06-12 19:47:55 +000063Mainboards (or individual revisions) which don't appear in the list may or may \
64not work (we don't know, someone has to give it a try). Please report any \
65further verified mainboards on the [[Mailinglist|mailing list]].\n";
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000066#endif
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000067
Stefan Tauner00ec0272012-07-29 02:04:21 +000068static const char chip_th[] = "\
Stefan Taunerf74a7b92011-09-14 22:09:48 +000069! align=\"left\" | Vendor\n\
70! align=\"left\" | Device\n\
71! align=\"center\" | Size [kB]\n\
72! align=\"center\" | Type\n\
73! align=\"center\" colspan=\"4\" | Status\n\
74! align=\"center\" colspan=\"2\" | Voltage [V]\n\n\
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000075|- bgcolor=\"#6699ff\"\n| colspan=\"4\" | &nbsp;\n\
Stefan Taunerf74a7b92011-09-14 22:09:48 +000076| Probe\n| Read\n| Erase\n| Write\n\
Paul Menzel018d4822011-10-21 12:33:07 +000077| align=\"center\" | Min \n| align=\"center\" | Max\n\n";
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000078
Stefan Tauner1c356bb2013-07-11 13:48:52 +000079static const char chip_intro[] = "\
80\n== Supported flash chips ==\n\n\
81The list below contains all chips that have some kind of explicit support added to flashrom and their last \
82known test status. Newer SPI flash chips might work even without explicit support if they implement SFDP ([\
83http://www.jedec.org/standards-documents/docs/jesd216 Serial Flash Discoverable Parameters - JESD216]). \
84Flashrom will detect this automatically and inform you about it.\n\n\
85The names used below are designed to be as concise as possible and hence contain only the characters \
86describing properties that are relevant to flashrom. Irrelevant characters specify attributes flashrom can not \
87use or even detect by itself (e.g. the physical package) and have no effect on flashrom's operation. They are \
88replaced by dots ('.') functioning as wildcards (like in Regular Expressions) or are completely omitted at the \
89end of a name.\n";
90
Stefan Tauner00ec0272012-07-29 02:04:21 +000091static const char programmer_th[] = "\
Stefan Tauner4b24a2d2012-12-27 18:40:36 +000092! align=\"left\" | Programmer\n\
Stefan Tauner00ec0272012-07-29 02:04:21 +000093! align=\"left\" | Vendor\n\
94! align=\"left\" | Device\n\
Stefan Tauneraf358d62012-12-27 18:40:26 +000095! align=\"center\" | IDs\n\
Stefan Taunerf74a7b92011-09-14 22:09:48 +000096! align=\"center\" | Status\n\n";
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +000097
Stefan Tauner618d8972014-05-28 13:02:13 +000098/* The output of this module relies on MediaWiki templates to select special formatting styles for table cells
99 * reflecting the test status of the respective hardware. This functions returns the correct template name for
100 * the supplied enum test_state. */
101static const char *test_state_to_template(enum test_state test_state)
102{
103 switch (test_state) {
104 case OK: return "OK";
105 case BAD: return "No";
106 case NA: return "NA";
107 case DEP: return "Dep";
108 case NT:
109 default: return "?3";
110 }
111}
112
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000113#if CONFIG_INTERNAL == 1
Mathias Krausea60faab2011-01-17 07:50:42 +0000114static const char laptop_intro[] = "\n== Supported laptops/notebooks ==\n\n\
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000115In general, flashing laptops is more difficult because laptops\n\n\
116* often use the flash chip for stuff besides the BIOS,\n\
117* often have special protection stuff which has to be handled by flashrom,\n\
118* often use flash translation circuits which need drivers in flashrom.\n\n\
119<div style=\"margin-top:0.5em; padding:0.5em 0.5em 0.5em 0.5em; \
120background-color:#ff6666; align:right; border:1px solid #000000;\">\n\
121'''IMPORTANT:''' At this point we recommend to '''not''' use flashrom on \
122untested laptops unless you have a means to recover from a flashing that goes \
123wrong (a working backup flash chip and/or good soldering skills).\n</div>\n";
124
Uwe Hermanna6d9c4b2010-05-24 15:28:12 +0000125static void print_supported_chipsets_wiki(int cols)
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000126{
Stefan Tauner00ec0272012-07-29 02:04:21 +0000127 int i;
128 unsigned int lines_per_col;
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000129 const struct penable *e;
Stefan Tauner00ec0272012-07-29 02:04:21 +0000130 int enablescount = 0, color = 1;
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000131
132 for (e = chipset_enables; e->vendor_name != NULL; e++)
133 enablescount++;
134
Stefan Tauner00ec0272012-07-29 02:04:21 +0000135 /* +1 to force the resulting number of columns to be < cols */
136 lines_per_col = enablescount / cols + ((enablescount%cols) > 0 ? 1 : 0);
137
138 printf("\n== Supported chipsets ==\n\nTotal amount of supported chipsets: '''%d'''\n\n"
139 "{| border=\"0\" valign=\"top\"\n", enablescount);
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000140
141 e = chipset_enables;
Stefan Tauner00ec0272012-07-29 02:04:21 +0000142 for (i = 0; e[i].vendor_name != NULL; i++) {
143 if ((i % lines_per_col) == 0)
144 printf("%s%s", th_start, chipset_th);
145
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000146 /* Alternate colors if the vendor changes. */
147 if (i > 0 && strcmp(e[i].vendor_name, e[i - 1].vendor_name))
148 color = !color;
149
Uwe Hermanna6d9c4b2010-05-24 15:28:12 +0000150 printf("|- bgcolor=\"#%s\"\n| %s || %s "
Stefan Tauner618d8972014-05-28 13:02:13 +0000151 "|| %04x:%04x || {{%s}}\n", (color) ? "eeeeee" : "dddddd",
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000152 e[i].vendor_name, e[i].device_name,
153 e[i].vendor_id, e[i].device_id,
Stefan Tauner618d8972014-05-28 13:02:13 +0000154 test_state_to_template(e[i].status));
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000155
Stefan Tauner00ec0272012-07-29 02:04:21 +0000156 if (((i % lines_per_col) + 1) == lines_per_col)
157 printf("\n|}\n\n");
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000158 }
159
Stefan Tauner00ec0272012-07-29 02:04:21 +0000160 /* end inner table if it did not fill the last column fully */
161 if (((i % lines_per_col)) > 0)
162 printf("\n|}\n\n");
163 printf("\n\n|}\n");
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000164}
165
Stefan Tauneraf358d62012-12-27 18:40:26 +0000166static void print_supported_boards_wiki_helper(const char *devicetype, int cols, const struct board_info boards[])
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000167{
Stefan Tauner00ec0272012-07-29 02:04:21 +0000168 int i, k;
169 unsigned int boardcount, lines_per_col;
Stefan Tauner2c20b282012-07-28 19:35:26 +0000170 unsigned int boardcount_good = 0, boardcount_bad = 0, boardcount_nt = 0;
171 int num_notes = 0, color = 1;
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000172 char *notes = calloc(1, 1);
173 char tmp[900 + 1];
Carl-Daniel Hailfinger97d5b122011-08-31 16:19:50 +0000174 const struct board_match *b = board_matches;
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000175
Peter Lemenkov4adf8a62010-06-01 10:13:17 +0000176 for (i = 0; boards[i].vendor != NULL; i++) {
Stefan Tauner2c20b282012-07-28 19:35:26 +0000177 if (boards[i].working == OK)
Peter Lemenkov4adf8a62010-06-01 10:13:17 +0000178 boardcount_good++;
Stefan Tauner2c20b282012-07-28 19:35:26 +0000179 else if (boards[i].working == NT)
180 boardcount_nt++;
Peter Lemenkov4adf8a62010-06-01 10:13:17 +0000181 else
182 boardcount_bad++;
183 }
Stefan Tauner00ec0272012-07-29 02:04:21 +0000184 boardcount = boardcount_good + boardcount_nt + boardcount_bad;
185
186 /* +1 to force the resulting number of columns to be < cols */
187 lines_per_col = boardcount / cols + ((boardcount%cols) > 0 ? 1 : 0);
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000188
Stefan Tauner1c356bb2013-07-11 13:48:52 +0000189 printf("\n\nTotal amount of known good %s: '''%d'''; "
Stefan Tauner2c20b282012-07-28 19:35:26 +0000190 "Untested (e.g. user vanished before testing new code): '''%d'''; "
191 "Not yet supported (i.e. known-bad): '''%d'''.\n\n"
Stefan Tauner00ec0272012-07-29 02:04:21 +0000192 "{| border=\"0\" valign=\"top\"\n", devicetype, boardcount_good, boardcount_nt, boardcount_bad);
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000193
Stefan Tauner00ec0272012-07-29 02:04:21 +0000194 for (i = 0; boards[i].vendor != NULL; i++) {
195 if ((i % lines_per_col) == 0)
196 printf("%s%s", th_start, board_th);
Peter Lemenkov4adf8a62010-06-01 10:13:17 +0000197
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000198 /* Alternate colors if the vendor changes. */
Peter Lemenkov4adf8a62010-06-01 10:13:17 +0000199 if (i > 0 && strcmp(boards[i].vendor, boards[i - 1].vendor))
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000200 color = !color;
201
Peter Lemenkov4adf8a62010-06-01 10:13:17 +0000202 k = 0;
Carl-Daniel Hailfinger4146ced2010-06-07 11:10:43 +0000203 while ((b[k].vendor_name != NULL) &&
204 (strcmp(b[k].vendor_name, boards[i].vendor) ||
205 strcmp(b[k].board_name, boards[i].name))) {
Peter Lemenkov4adf8a62010-06-01 10:13:17 +0000206 k++;
207 }
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000208
Peter Lemenkov4adf8a62010-06-01 10:13:17 +0000209 printf("|- bgcolor=\"#%s\"\n| %s || %s%s %s%s || %s%s%s%s "
210 "|| {{%s}}", (color) ? "eeeeee" : "dddddd",
211 boards[i].vendor,
212 boards[i].url ? "[" : "",
213 boards[i].url ? boards[i].url : "",
214 boards[i].name,
215 boards[i].url ? "]" : "",
Carl-Daniel Hailfinger2d927fb2012-01-04 00:48:27 +0000216 b[k].lb_vendor ? "-p internal:mainboard=" : "&mdash;",
Peter Lemenkov4adf8a62010-06-01 10:13:17 +0000217 b[k].lb_vendor ? b[k].lb_vendor : "",
218 b[k].lb_vendor ? ":" : "",
219 b[k].lb_vendor ? b[k].lb_part : "",
Stefan Tauner618d8972014-05-28 13:02:13 +0000220 test_state_to_template(boards[i].working));
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000221
Peter Lemenkov4adf8a62010-06-01 10:13:17 +0000222 if (boards[i].note) {
Stefan Tauner1c356bb2013-07-11 13:48:52 +0000223 num_notes++;
224 printf(" <span id=\"%s_ref%d\"><sup>[[#%s_note%d|%d]]</sup></span>\n",
225 devicetype, num_notes, devicetype, num_notes, num_notes);
226 int ret = snprintf(tmp, sizeof(tmp),
227 "<span id=\"%s_note%d\">%d. [[#%s_ref%d|&#x2191;]]</span>"
228 " <nowiki>%s</nowiki><br />\n", devicetype, num_notes, num_notes,
229 devicetype, num_notes, boards[i].note);
230 if (ret < 0 || ret >= sizeof(tmp)) {
231 fprintf(stderr, "Footnote text #%d of %s truncated (ret=%d, sizeof(tmp)=%zu)\n",
232 num_notes, devicetype, ret, sizeof(tmp));
233 }
Mathias Krausea60faab2011-01-17 07:50:42 +0000234 notes = strcat_realloc(notes, tmp);
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000235 } else {
236 printf("\n");
237 }
238
Stefan Tauner00ec0272012-07-29 02:04:21 +0000239 if (((i % lines_per_col) + 1) == lines_per_col)
240 printf("\n|}\n\n");
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000241 }
242
Stefan Tauner00ec0272012-07-29 02:04:21 +0000243 /* end inner table if it did not fill the last column fully */
244 if (((i % lines_per_col)) > 0)
245 printf("\n|}\n\n");
Stefan Tauner352e50b2013-02-22 15:58:45 +0000246 printf("|}\n");
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000247
248 if (num_notes > 0)
249 printf("\n<small>\n%s</small>\n", notes);
250 free(notes);
251}
252
Uwe Hermanna6d9c4b2010-05-24 15:28:12 +0000253static void print_supported_boards_wiki(void)
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000254{
255 printf("%s", board_intro);
Stefan Tauneraf358d62012-12-27 18:40:26 +0000256 print_supported_boards_wiki_helper("boards", 2, boards_known);
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000257
258 printf("%s", laptop_intro);
Stefan Tauneraf358d62012-12-27 18:40:26 +0000259 print_supported_boards_wiki_helper("laptops", 1, laptops_known);
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000260}
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000261#endif
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000262
Uwe Hermanna6d9c4b2010-05-24 15:28:12 +0000263static void print_supported_chips_wiki(int cols)
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000264{
Stefan Tauner00ec0272012-07-29 02:04:21 +0000265 unsigned int lines_per_col;
Stefan Tauner00155492011-06-26 20:45:35 +0000266 char *s;
Stefan Taunerf74a7b92011-09-14 22:09:48 +0000267 char vmax[6];
268 char vmin[6];
Stefan Tauner00ec0272012-07-29 02:04:21 +0000269 const struct flashchip *f, *old = NULL;
270 int i = 0, c = 1, chipcount = 0;
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000271
Stefan Tauner93f70232011-07-26 14:33:46 +0000272 for (f = flashchips; f->name != NULL; f++) {
Stefan Tauner035492a2012-02-03 22:32:09 +0000273 /* Don't count generic entries. */
274 if (!strncmp(f->vendor, "Unknown", 7) ||
275 !strncmp(f->vendor, "Programmer", 10) ||
276 !strncmp(f->name, "unknown", 7))
Stefan Tauner4c5665f2012-02-17 20:03:37 +0000277 continue;
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000278 chipcount++;
Stefan Tauner93f70232011-07-26 14:33:46 +0000279 }
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000280
Stefan Tauner00ec0272012-07-29 02:04:21 +0000281 /* +1 to force the resulting number of columns to be < cols */
282 lines_per_col = chipcount / cols + ((chipcount%cols) > 0 ? 1 : 0);
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000283
Stefan Tauner1c356bb2013-07-11 13:48:52 +0000284 printf("%s", chip_intro);
285 printf("\nTotal amount of supported chips: '''%d'''\n\n"
Stefan Tauner00ec0272012-07-29 02:04:21 +0000286 "{| border=\"0\" valign=\"top\"\n", chipcount);
287
288 for (f = flashchips; f->name != NULL; f++) {
Stefan Tauner035492a2012-02-03 22:32:09 +0000289 /* Don't print generic entries. */
290 if (!strncmp(f->vendor, "Unknown", 7) ||
291 !strncmp(f->vendor, "Programmer", 10) ||
292 !strncmp(f->name, "unknown", 7))
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000293 continue;
294
Stefan Tauner00ec0272012-07-29 02:04:21 +0000295 if ((i % lines_per_col) == 0)
296 printf("%s%s", th_start, chip_th);
297
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000298 /* Alternate colors if the vendor changes. */
299 if (old != NULL && strcmp(old->vendor, f->vendor))
300 c = !c;
301
Stefan Tauner00ec0272012-07-29 02:04:21 +0000302 old = f;
Stefan Tauner00155492011-06-26 20:45:35 +0000303 s = flashbuses_to_text(f->bustype);
Stefan Taunerf74a7b92011-09-14 22:09:48 +0000304 sprintf(vmin, "%0.03f", f->voltage.min / (double)1000);
305 sprintf(vmax, "%0.03f", f->voltage.max / (double)1000);
Stefan Taunerf74a7b92011-09-14 22:09:48 +0000306 printf("|- bgcolor=\"#%s\"\n| %s || %s || align=\"right\" | %d "
307 "|| %s || {{%s}} || {{%s}} || {{%s}} || {{%s}}"
308 "|| %s || %s \n",
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000309 (c == 1) ? "eeeeee" : "dddddd", f->vendor, f->name,
Stefan Tauner00155492011-06-26 20:45:35 +0000310 f->total_size, s,
Stefan Tauner618d8972014-05-28 13:02:13 +0000311 test_state_to_template(f->tested.probe),
312 test_state_to_template(f->tested.read),
313 test_state_to_template(f->tested.erase),
314 test_state_to_template(f->tested.write),
Stefan Tauner6455dff2014-05-26 00:36:24 +0000315 f->voltage.min ? vmin : "?",
316 f->voltage.max ? vmax : "?");
Stefan Tauner00155492011-06-26 20:45:35 +0000317 free(s);
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000318
Stefan Tauner00ec0272012-07-29 02:04:21 +0000319 if (((i % lines_per_col) + 1) == lines_per_col)
320 printf("\n|}\n\n");
321 i++;
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000322 }
Stefan Tauner00ec0272012-07-29 02:04:21 +0000323 /* end inner table if it did not fill the last column fully */
324 if (((i % lines_per_col)) > 0)
325 printf("\n|}\n\n");
326 printf("|}\n\n");
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000327}
328
Stefan Tauneraf358d62012-12-27 18:40:26 +0000329/* Following functions are not needed when no PCI/USB programmers are compiled in,
330 * but since print_wiki code has no size constraints we include it unconditionally. */
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000331static int count_supported_devs_wiki(const struct dev_entry *devs)
Stefan Tauneraf358d62012-12-27 18:40:26 +0000332{
333 unsigned int count = 0;
334 unsigned int i = 0;
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000335 for (i = 0; devs[i].vendor_id != 0; i++)
Stefan Tauneraf358d62012-12-27 18:40:26 +0000336 count++;
337 return count;
338}
339
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000340static void print_supported_devs_wiki_helper(const struct programmer_entry prog)
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000341{
342 int i = 0;
343 static int c = 0;
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000344 const struct dev_entry *devs = prog.devs.dev;
345 const unsigned int count = count_supported_devs_wiki(devs);
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000346
347 /* Alternate colors if the vendor changes. */
348 c = !c;
349
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000350 for (i = 0; devs[i].vendor_id != 0; i++) {
351 printf("|- bgcolor=\"#%s\"\n", (c) ? "eeeeee" : "dddddd");
352 if (i == 0)
353 printf("| rowspan=\"%u\" | %s |", count, prog.name);
354 printf("| %s || %s || %04x:%04x || {{%s}}\n", devs[i].vendor_name, devs[i].device_name,
Stefan Tauner618d8972014-05-28 13:02:13 +0000355 devs[i].vendor_id, devs[i].device_id, test_state_to_template(devs[i].status));
Stefan Tauneraf358d62012-12-27 18:40:26 +0000356 }
357}
358
359static void print_supported_devs_wiki()
360{
361 unsigned int pci_count = 0;
362 unsigned int usb_count = 0;
363 unsigned int i;
364
365 for (i = 0; i < PROGRAMMER_INVALID; i++) {
366 const struct programmer_entry prog = programmer_table[i];
367 switch (prog.type) {
368 case USB:
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000369 usb_count += count_supported_devs_wiki(prog.devs.dev);
Stefan Tauneraf358d62012-12-27 18:40:26 +0000370 break;
371 case PCI:
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000372 pci_count += count_supported_devs_wiki(prog.devs.dev);
Stefan Tauneraf358d62012-12-27 18:40:26 +0000373 break;
374 case OTHER:
375 default:
376 break;
377 }
378 }
379
380 printf("\n== PCI Devices ==\n\n"
381 "Total amount of supported PCI devices flashrom can use as a programmer: '''%d'''\n\n"
382 "{%s%s", pci_count, th_start, programmer_th);
383
384 for (i = 0; i < PROGRAMMER_INVALID; i++) {
385 const struct programmer_entry prog = programmer_table[i];
386 if (prog.type == PCI) {
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000387 print_supported_devs_wiki_helper(prog);
Stefan Tauneraf358d62012-12-27 18:40:26 +0000388 }
389 }
390 printf("\n|}\n\n|}\n");
391
392 printf("\n== USB Devices ==\n\n"
393 "Total amount of supported USB devices flashrom can use as a programmer: '''%d'''\n\n"
394 "{%s%s", usb_count, th_start, programmer_th);
395
396 for (i = 0; i < PROGRAMMER_INVALID; i++) {
397 const struct programmer_entry prog = programmer_table[i];
398 if (prog.type == USB) {
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000399 print_supported_devs_wiki_helper(prog);
Stefan Tauneraf358d62012-12-27 18:40:26 +0000400 }
401 }
402 printf("\n|}\n\n|}\n");
Stefan Tauner2c421192012-12-27 18:40:40 +0000403
404 printf("\n== Other programmers ==\n\n"
405 "{%s", th_start);
406 printf("! align=\"left\" | Programmer\n"
407 "! align=\"left\" | Note\n\n");
408
409 for (i = 0; i < PROGRAMMER_INVALID; i++) {
410 static int c = 0;
411 const struct programmer_entry prog = programmer_table[i];
412 if (prog.type == OTHER && prog.devs.note != NULL) {
413 c = !c;
414 printf("|- bgcolor=\"#%s\"\n", (c) ? "eeeeee" : "dddddd");
415 printf("| %s || %s", prog.name, prog.devs.note);
416 }
417 }
418 printf("\n|}\n\n|}\n");
Stefan Tauneraf358d62012-12-27 18:40:26 +0000419}
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000420
Carl-Daniel Hailfingerf5292052009-11-17 09:57:34 +0000421void print_supported_wiki(void)
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000422{
423 time_t t = time(NULL);
424
425 printf(wiki_header, ctime(&t), flashrom_version);
Uwe Hermanna6d9c4b2010-05-24 15:28:12 +0000426 print_supported_chips_wiki(2);
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000427#if CONFIG_INTERNAL == 1
Uwe Hermanna6d9c4b2010-05-24 15:28:12 +0000428 print_supported_chipsets_wiki(3);
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000429 print_supported_boards_wiki();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000430#endif
Stefan Tauneraf358d62012-12-27 18:40:26 +0000431 print_supported_devs_wiki();
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000432}
433