Flashrom

Flashrom Svn Source Tree

Root/trunk/print_wiki.c

1/*
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
22#include <stdio.h>
23#include <string.h>
24#include <stdlib.h>
25#include <time.h>
26#include "flash.h"
27#include "flashchips.h"
28#include "programmer.h"
29
30static const char wiki_header[] = "= Supported devices =\n\n\
31<div style=\"margin-top:0.5em; padding:0.5em 0.5em 0.5em 0.5em; \
32background-color:#eeeeee; text-align:right; border:1px solid #aabbcc;\">\
33<small>\n\
34Please 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
38#if CONFIG_INTERNAL == 1
39static const char chipset_th[] = "{| border=\"0\" style=\"font-size: smaller\"\n\
40|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
41! align=\"left\" | Southbridge\n! align=\"center\" | PCI IDs\n\
42! align=\"center\" | Status\n\n";
43
44static const char board_th[] = "{| border=\"0\" style=\"font-size: smaller\" \
45valign=\"top\"\n|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
46! align=\"left\" | Mainboard\n! align=\"left\" | Required option\n\
47! align=\"center\" | Status\n\n";
48
49static const char board_intro[] = "\
50\n== Supported mainboards ==\n\n\
51In general, it is very likely that flashrom works out of the box even if your \
52mainboard is not listed below.\n\nThis is a list of mainboards where we have \
53verified that they either do or do not need any special initialization to \
54make flashrom work (given flashrom supports the respective chipset and flash \
55chip), or that they do not yet work at all. If they do not work, support may \
56or may not be added later.\n\n\
57Mainboards (or individual revisions) which don't appear in the list may or may \
58not work (we don't know, someone has to give it a try). Please report any \
59further verified mainboards on the [[Mailinglist|mailing list]].\n";
60#endif
61
62static const char chip_th[] = "{\
63| border=\"0\" style=\"font-size: smaller\" valign=\"top\"\n\
64|- bgcolor=\"#6699dd\"\n\
65! align=\"left\" | Vendor\n\
66! align=\"left\" | Device\n\
67! align=\"center\" | Size [kB]\n\
68! align=\"center\" | Type\n\
69! align=\"center\" colspan=\"4\" | Status\n\
70! align=\"center\" colspan=\"2\" | Voltage [V]\n\n\
71|- bgcolor=\"#6699ff\"\n| colspan=\"4\" | &nbsp;\n\
72| Probe\n| Read\n| Erase\n| Write\n\
73| align=\"center\" | Min \n| align=\"center\" | Max\n\n";
74
75static const char programmer_section[] = "\
76\n== Supported programmers ==\n\nThis is a list \
77of supported PCI devices flashrom can use as programmer:\n\n{| border=\"0\" \
78valign=\"top\"\n| valign=\"top\"|\n\n{| border=\"0\" style=\"font-size: \
79smaller\" valign=\"top\"\n|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
80! align=\"left\" | Device\n! align=\"center\" | PCI IDs\n\
81! align=\"center\" | Status\n\n";
82
83#if CONFIG_INTERNAL == 1
84static const char laptop_intro[] = "\n== Supported laptops/notebooks ==\n\n\
85In general, flashing laptops is more difficult because laptops\n\n\
86* often use the flash chip for stuff besides the BIOS,\n\
87* often have special protection stuff which has to be handled by flashrom,\n\
88* often use flash translation circuits which need drivers in flashrom.\n\n\
89<div style=\"margin-top:0.5em; padding:0.5em 0.5em 0.5em 0.5em; \
90background-color:#ff6666; align:right; border:1px solid #000000;\">\n\
91'''IMPORTANT:''' At this point we recommend to '''not''' use flashrom on \
92untested laptops unless you have a means to recover from a flashing that goes \
93wrong (a working backup flash chip and/or good soldering skills).\n</div>\n";
94
95static void print_supported_chipsets_wiki(int cols)
96{
97int i, j, enablescount = 0, color = 1;
98const struct penable *e;
99
100for (e = chipset_enables; e->vendor_name != NULL; e++)
101enablescount++;
102
103printf("\n== Supported chipsets ==\n\nTotal amount of supported "
104 "chipsets: '''%d'''\n\n{| border=\"0\" valign=\"top\"\n| "
105 "valign=\"top\"|\n\n%s", enablescount, chipset_th);
106
107e = chipset_enables;
108for (i = 0, j = 0; e[i].vendor_name != NULL; i++, j++) {
109/* Alternate colors if the vendor changes. */
110if (i > 0 && strcmp(e[i].vendor_name, e[i - 1].vendor_name))
111color = !color;
112
113printf("|- bgcolor=\"#%s\"\n| %s || %s "
114 "|| %04x:%04x || %s\n", (color) ? "eeeeee" : "dddddd",
115 e[i].vendor_name, e[i].device_name,
116 e[i].vendor_id, e[i].device_id,
117 (e[i].status == OK) ? "{{OK}}" : "{{?3}}");
118
119/* Split table in 'cols' columns. */
120if (j >= (enablescount / cols + 1)) {
121printf("\n|}\n\n| valign=\"top\"|\n\n%s", chipset_th);
122j = 0;
123}
124}
125
126printf("\n|}\n\n|}\n");
127}
128
129static void wiki_helper(const char *devicetype, int cols,
130const struct board_info boards[])
131{
132int i, j, k = 0, boardcount_good = 0, boardcount_bad = 0, color = 1;
133int num_notes = 0;
134char *notes = calloc(1, 1);
135char tmp[900 + 1];
136const struct board_match *b = board_matches;
137
138for (i = 0; boards[i].vendor != NULL; i++) {
139if (boards[i].working)
140boardcount_good++;
141else
142boardcount_bad++;
143}
144
145printf("\n\nTotal amount of supported %s: '''%d'''. "
146 "Not yet supported (i.e., known-bad): '''%d'''.\n\n"
147 "{| border=\"0\" valign=\"top\"\n| valign=\"top\"|\n\n%s",
148 devicetype, boardcount_good, boardcount_bad, board_th);
149
150for (i = 0, j = 0; boards[i].vendor != NULL; i++, j++) {
151
152/* Alternate colors if the vendor changes. */
153if (i > 0 && strcmp(boards[i].vendor, boards[i - 1].vendor))
154color = !color;
155
156k = 0;
157while ((b[k].vendor_name != NULL) &&
158(strcmp(b[k].vendor_name, boards[i].vendor) ||
159 strcmp(b[k].board_name, boards[i].name))) {
160k++;
161}
162
163printf("|- bgcolor=\"#%s\"\n| %s || %s%s %s%s || %s%s%s%s "
164 "|| {{%s}}", (color) ? "eeeeee" : "dddddd",
165 boards[i].vendor,
166 boards[i].url ? "[" : "",
167 boards[i].url ? boards[i].url : "",
168 boards[i].name,
169 boards[i].url ? "]" : "",
170 b[k].lb_vendor ? "-p internal:mainboard=" : "&mdash;",
171 b[k].lb_vendor ? b[k].lb_vendor : "",
172 b[k].lb_vendor ? ":" : "",
173 b[k].lb_vendor ? b[k].lb_part : "",
174 (boards[i].working) ? "OK" : "No");
175
176if (boards[i].note) {
177printf("<sup>%d</sup>\n", num_notes + 1);
178snprintf(tmp, sizeof(tmp), "<sup>%d</sup> %s<br />\n",
179 1 + num_notes++, boards[i].note);
180notes = strcat_realloc(notes, tmp);
181} else {
182printf("\n");
183}
184
185/* Split table in 'cols' columns. */
186if (j >= ((boardcount_good + boardcount_bad) / cols + 1)) {
187printf("\n|}\n\n| valign=\"top\"|\n\n%s", board_th);
188j = 0;
189}
190}
191
192printf("\n|}\n\n|}\n");
193
194if (num_notes > 0)
195printf("\n<small>\n%s</small>\n", notes);
196free(notes);
197}
198
199static void print_supported_boards_wiki(void)
200{
201printf("%s", board_intro);
202wiki_helper("boards", 2, boards_known);
203
204printf("%s", laptop_intro);
205wiki_helper("laptops", 1, laptops_known);
206}
207#endif
208
209static void print_supported_chips_wiki(int cols)
210{
211int i = 0, c = 1, chipcount = 0;
212const struct flashchip *f, *old = NULL;
213uint32_t t;
214char *s;
215char vmax[6];
216char vmin[6];
217
218for (f = flashchips; f->name != NULL; f++) {
219/* Don't count generic entries. */
220if (!strncmp(f->vendor, "Unknown", 7) ||
221 !strncmp(f->vendor, "Programmer", 10) ||
222 !strncmp(f->name, "unknown", 7))
223chipcount++;
224}
225
226printf("\n== Supported chips ==\n\nTotal amount of supported "
227 "chips: '''%d'''\n\n{| border=\"0\" valign=\"top\"\n"
228"| valign=\"top\"|\n\n%s", chipcount, chip_th);
229
230for (f = flashchips; f->name != NULL; f++, i++) {
231/* Don't print generic entries. */
232if (!strncmp(f->vendor, "Unknown", 7) ||
233 !strncmp(f->vendor, "Programmer", 10) ||
234 !strncmp(f->name, "unknown", 7))
235continue;
236
237/* Alternate colors if the vendor changes. */
238if (old != NULL && strcmp(old->vendor, f->vendor))
239c = !c;
240
241t = f->tested;
242s = flashbuses_to_text(f->bustype);
243sprintf(vmin, "%0.03f", f->voltage.min / (double)1000);
244sprintf(vmax, "%0.03f", f->voltage.max / (double)1000);
245/* '{{%s}}' is used in combination with 'OK', 'No' and '?3' to
246 * select special formatting templates for the bg color. */
247printf("|- bgcolor=\"#%s\"\n| %s || %s || align=\"right\" | %d "
248 "|| %s || {{%s}} || {{%s}} || {{%s}} || {{%s}}"
249 "|| %s || %s \n",
250 (c == 1) ? "eeeeee" : "dddddd", f->vendor, f->name,
251 f->total_size, s,
252 (t & TEST_OK_PROBE) ? "OK" :
253 (t & TEST_BAD_PROBE) ? "No" : "?3",
254 (t & TEST_OK_READ) ? "OK" :
255 (t & TEST_BAD_READ) ? "No" : "?3",
256 (t & TEST_OK_ERASE) ? "OK" :
257 (t & TEST_BAD_ERASE) ? "No" : "?3",
258 (t & TEST_OK_WRITE) ? "OK" :
259 (t & TEST_BAD_WRITE) ? "No" : "?3",
260 f->voltage.min ? vmin : "N/A",
261 f->voltage.min ? vmax : "N/A");
262free(s);
263
264/* Split table into 'cols' columns. */
265if (i >= (chipcount / cols + 1)) {
266printf("\n|}\n\n| valign=\"top\"|\n\n%s", chip_th);
267i = 0;
268}
269
270old = f;
271}
272
273printf("\n|}\n\n|}\n");
274}
275
276/* Not needed for CONFIG_INTERNAL, but for all other PCI-based programmers. */
277#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
278static void print_supported_pcidevs_wiki(const struct pcidev_status *devs)
279{
280int i = 0;
281static int c = 0;
282
283/* Alternate colors if the vendor changes. */
284c = !c;
285
286for (i = 0; devs[i].vendor_name != NULL; i++) {
287printf("|- bgcolor=\"#%s\"\n| %s || %s || "
288 "%04x:%04x || {{%s}}\n", (c) ? "eeeeee" : "dddddd",
289 devs[i].vendor_name, devs[i].device_name,
290 devs[i].vendor_id, devs[i].device_id,
291 (devs[i].status == NT) ? "?3" : "OK");
292}
293}
294#endif
295
296void print_supported_wiki(void)
297{
298time_t t = time(NULL);
299
300printf(wiki_header, ctime(&t), flashrom_version);
301print_supported_chips_wiki(2);
302#if CONFIG_INTERNAL == 1
303print_supported_chipsets_wiki(3);
304print_supported_boards_wiki();
305#endif
306printf("%s", programmer_section);
307#if CONFIG_NIC3COM == 1
308print_supported_pcidevs_wiki(nics_3com);
309#endif
310#if CONFIG_NICREALTEK == 1
311print_supported_pcidevs_wiki(nics_realtek);
312#endif
313#if CONFIG_NICNATSEMI == 1
314print_supported_pcidevs_wiki(nics_natsemi);
315#endif
316#if CONFIG_GFXNVIDIA == 1
317print_supported_pcidevs_wiki(gfx_nvidia);
318#endif
319#if CONFIG_DRKAISER == 1
320print_supported_pcidevs_wiki(drkaiser_pcidev);
321#endif
322#if CONFIG_SATASII == 1
323print_supported_pcidevs_wiki(satas_sii);
324#endif
325#if CONFIG_ATAHPT == 1
326print_supported_pcidevs_wiki(ata_hpt);
327#endif
328#if CONFIG_NICINTEL == 1
329print_supported_pcidevs_wiki(nics_intel);
330#endif
331#if CONFIG_NICINTEL_SPI == 1
332print_supported_pcidevs_wiki(nics_intel_spi);
333#endif
334#if CONFIG_OGP_SPI == 1
335print_supported_pcidevs_wiki(ogp_spi);
336#endif
337#if CONFIG_SATAMV == 1
338print_supported_pcidevs_wiki(satas_mv);
339#endif
340printf("\n|}\n");
341}
342
343

Archive Download this file

Revision: HEAD