blob: e14eae8c458f4908be5377173a1cf4eead797ef9 [file] [log] [blame]
Uwe Hermannba290d12009-06-17 12:07:12 +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
22#include <string.h>
23#include <stdlib.h>
24#include "flash.h"
25#include "flashchips.h"
26
27/*
28 * Return a string corresponding to the bustype parameter.
29 * Memory is obtained with malloc() and can be freed with free().
30 */
31char *flashbuses_to_text(enum chipbustype bustype)
32{
33 char *ret = calloc(1, 1);
34 if (bustype == CHIP_BUSTYPE_UNKNOWN) {
35 ret = strcat_realloc(ret, "Unknown,");
36 /*
37 * FIXME: Once all chipsets and flash chips have been updated, NONSPI
38 * will cease to exist and should be eliminated here as well.
39 */
40 } else if (bustype == CHIP_BUSTYPE_NONSPI) {
41 ret = strcat_realloc(ret, "Non-SPI,");
42 } else {
43 if (bustype & CHIP_BUSTYPE_PARALLEL)
44 ret = strcat_realloc(ret, "Parallel,");
45 if (bustype & CHIP_BUSTYPE_LPC)
46 ret = strcat_realloc(ret, "LPC,");
47 if (bustype & CHIP_BUSTYPE_FWH)
48 ret = strcat_realloc(ret, "FWH,");
49 if (bustype & CHIP_BUSTYPE_SPI)
50 ret = strcat_realloc(ret, "SPI,");
51 if (bustype == CHIP_BUSTYPE_NONE)
52 ret = strcat_realloc(ret, "None,");
53 }
54 /* Kill last comma. */
55 ret[strlen(ret) - 1] = '\0';
56 ret = realloc(ret, strlen(ret) + 1);
57 return ret;
58}
59
60#define POS_PRINT(x) do { pos += strlen(x); printf(x); } while (0)
61
62static int digits(int n)
63{
64 int i;
65
66 if (!n)
67 return 1;
68
69 for (i = 0; n; ++i)
70 n /= 10;
71
72 return i;
73}
74
75void print_supported_chips(void)
76{
77 int okcol = 0, pos = 0, i, chipcount = 0;
78 struct flashchip *f;
79
80 for (f = flashchips; f->name != NULL; f++) {
81 if (GENERIC_DEVICE_ID == f->model_id)
82 continue;
83 okcol = max(okcol, strlen(f->vendor) + 1 + strlen(f->name));
84 }
85 okcol = (okcol + 7) & ~7;
86
87 for (f = flashchips; f->name != NULL; f++)
88 chipcount++;
89
90 printf("\nSupported flash chips (total: %d):\n\n", chipcount);
91 POS_PRINT("Vendor: Device:");
92 while (pos < okcol) {
93 printf("\t");
94 pos += 8 - (pos % 8);
95 }
96
97 printf("Tested OK:\tKnown BAD: Size/KB: Type:\n\n");
98 printf("(P = PROBE, R = READ, E = ERASE, W = WRITE)\n\n");
99
100 for (f = flashchips; f->name != NULL; f++) {
101 /* Don't print "unknown XXXX SPI chip" entries. */
102 if (!strncmp(f->name, "unknown", 7))
103 continue;
104
105 printf("%s", f->vendor);
106 for (i = 0; i < 10 - strlen(f->vendor); i++)
107 printf(" ");
108 printf("%s", f->name);
109
110 pos = 10 + strlen(f->name);
111 while (pos < okcol) {
112 printf("\t");
113 pos += 8 - (pos % 8);
114 }
115 if ((f->tested & TEST_OK_MASK)) {
116 if ((f->tested & TEST_OK_PROBE))
117 POS_PRINT("P ");
118 if ((f->tested & TEST_OK_READ))
119 POS_PRINT("R ");
120 if ((f->tested & TEST_OK_ERASE))
121 POS_PRINT("E ");
122 if ((f->tested & TEST_OK_WRITE))
123 POS_PRINT("W ");
124 }
125 while (pos < okcol + 9) {
126 printf("\t");
127 pos += 8 - (pos % 8);
128 }
129 if ((f->tested & TEST_BAD_MASK)) {
130 if ((f->tested & TEST_BAD_PROBE))
131 printf("P ");
132 if ((f->tested & TEST_BAD_READ))
133 printf("R ");
134 if ((f->tested & TEST_BAD_ERASE))
135 printf("E ");
136 if ((f->tested & TEST_BAD_WRITE))
137 printf("W ");
138 }
139
140 printf("\t %d", f->total_size);
141 for (i = 0; i < 10 - digits(f->total_size); i++)
142 printf(" ");
143 printf("%s\n", flashbuses_to_text(f->bustype));
144 }
145}
146
147void print_supported_chipsets(void)
148{
149 int i, j, chipsetcount = 0;
150 const struct penable *c = chipset_enables;
151
152 for (i = 0; c[i].vendor_name != NULL; i++)
153 chipsetcount++;
154
155 printf("\nSupported chipsets (total: %d):\n\nVendor: "
156 "Chipset: PCI IDs:\n\n", chipsetcount);
157
158 for (i = 0; c[i].vendor_name != NULL; i++) {
159 printf("%s", c[i].vendor_name);
160 for (j = 0; j < 25 - strlen(c[i].vendor_name); j++)
161 printf(" ");
162 printf("%s", c[i].device_name);
163 for (j = 0; j < 25 - strlen(c[i].device_name); j++)
164 printf(" ");
165 printf("%04x:%04x%s\n", c[i].vendor_id, c[i].device_id,
166 (c[i].status == OK) ? "" : " (untested)");
167 }
168}
169
Uwe Hermanne1aa75e2009-06-18 14:04:44 +0000170void print_supported_boards_helper(const struct board_info *b, const char *msg)
Uwe Hermannba290d12009-06-17 12:07:12 +0000171{
172 int i, j, boardcount = 0;
173
174 for (i = 0; b[i].vendor != NULL; i++)
175 boardcount++;
176
Uwe Hermanne1aa75e2009-06-18 14:04:44 +0000177 printf("\n%s (total: %d):\n\n", msg, boardcount);
178
Uwe Hermannba290d12009-06-17 12:07:12 +0000179 for (i = 0; b[i].vendor != NULL; i++) {
180 printf("%s", b[i].vendor);
181 for (j = 0; j < 25 - strlen(b[i].vendor); j++)
182 printf(" ");
183 printf("%s", b[i].name);
184 for (j = 0; j < 23 - strlen(b[i].name); j++)
185 printf(" ");
186 printf("\n");
187 }
188}
189
190void print_supported_boards(void)
191{
192 int i, j, boardcount = 0;
193 struct board_pciid_enable *b = board_pciid_enables;
194
195 for (i = 0; b[i].vendor_name != NULL; i++)
196 boardcount++;
197
198 printf("\nSupported boards which need write-enable code (total: %d):"
199 "\n\nVendor: Board: "
200 "Required option:\n\n", boardcount);
201
202 for (i = 0; b[i].vendor_name != NULL; i++) {
203 printf("%s", b[i].vendor_name);
204 for (j = 0; j < 25 - strlen(b[i].vendor_name); j++)
205 printf(" ");
206 printf("%s", b[i].board_name);
207 for (j = 0; j < 25 - strlen(b[i].board_name); j++)
208 printf(" ");
209 if (b[i].lb_vendor != NULL)
210 printf("-m %s:%s\n", b[i].lb_vendor, b[i].lb_part);
211 else
212 printf("(none, board is autodetected)\n");
213 }
214
Uwe Hermanne1aa75e2009-06-18 14:04:44 +0000215 print_supported_boards_helper(boards_ok,
216 "Supported boards which don't need write-enable code");
217 print_supported_boards_helper(boards_bad,
218 "Boards which have been verified to NOT work yet");
219 print_supported_boards_helper(laptops_ok,
220 "Laptops which have been verified to work");
221 print_supported_boards_helper(laptops_bad,
222 "Laptops which have been verified to NOT work yet");
Uwe Hermannba290d12009-06-17 12:07:12 +0000223}
Uwe Hermann20a293f2009-06-19 10:42:43 +0000224
225#define CHIPSET_TH "{| border=\"0\" style=\"font-size: smaller\"\n\
226|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
227! align=\"left\" | Southbridge\n! align=\"left\" | PCI IDs\n\
228! align=\"left\" | Status\n\n"
229
230#define BOARD_TH "{| border=\"0\" style=\"font-size: smaller\" valign=\"top\"\
231\n|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
232! align=\"left\" | Mainboard\n! align=\"left\" | Status\n\n"
233
234#define BOARD_TH2 "{| border=\"0\" style=\"font-size: smaller\" valign=\"top\"\
235\n|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
236! align=\"left\" | Mainboard\n! align=\"left\" | Required option\n\
237! align=\"left\" | Status\n\n"
238
239#define BOARD_INTRO "\
240\n== Supported mainboards ==\n\n\
241In general, it is very likely that flashrom works out of the box even if your \
242mainboard is not listed below.\n\nThis is a list of mainboards where we have \
243verified that they either do or do not need any special initialization to \
244make flashrom work (given flashrom supports the respective chipset and flash \
245chip), or that they do not yet work at all. If they do not work, support may \
246or may not be added later.\n\n\
247Mainboards which don't appear in the list may or may not work (we don't \
248know, someone has to give it a try). Please report any further verified \
249mainboards on the [[Mailinglist|mailing list]].\n"
250
251#define CHIP_TH "{| border=\"0\" style=\"font-size: smaller\" valign=\"top\"\n\
252|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
253! align=\"left\" | Device\n! align=\"left\" | Size / KB\n\
254! align=\"left\" | Type\n! align=\"left\" colspan=\"4\" | Status\n\n\
255|- bgcolor=\"#6699ff\"\n| colspan=\"4\" | &nbsp;\n\
256| Probe\n| Read\n| Write\n| Erase\n\n"
257
258#define PROGRAMMER_SECTION "\n== Supported programmers ==\n\nThis is a list \
259of supported PCI devices flashrom can use as programmer:\n\n{| border=\"0\" \
260valign=\"top\"\n| valign=\"top\"|\n\n{| border=\"0\" style=\"font-size: \
261smaller\" valign=\"top\"\n|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
262! align=\"left\" | Device\n! align=\"left\" | PCI IDs\n\
263! align=\"left\" | Status\n\n"
264
265const struct board_info_url boards_url[] = {
266 /* Verified working boards that don't need write-enables. */
267 /* Please keep this list alphabetically ordered by vendor/board. */
268 { "Abit", "AX8", "http://www.abit.com.tw/page/en/motherboard/motherboard_detail.php?DEFTITLE=Y&fMTYPE=Socket%20939&pMODEL_NAME=AX8" },
269 { "Advantech", "PCM-5820", "http://taiwan.advantech.com.tw/products/Model_Detail.asp?model_id=1-1TGZL8&BU=ACG&PD=" },
270 { "ASI", "MB-5BLMP", "http://www.hojerteknik.com/winnet.htm" },
271 { "ASUS", "A8N-E", "http://www.asus.com.tw/products.aspx?l1=3&l2=15&l3=171&l4=0&model=455&modelmenu=2" },
272 { "ASUS", "A8NE-FM/S", "http://www.hardwareschotte.de/hardware/preise/proid_1266090/preis_ASUS+A8NE-FM" },
273 { "ASUS", "A8N-SLI Premium", "http://www.asus.com.tw/products.aspx?l1=3&l2=15&l3=148&l4=0&model=539&modelmenu=1" },
274 { "ASUS", "A8V-E Deluxe", "http://www.asus.com.tw/products.aspx?l1=3&l2=15&l3=143&l4=0&model=376&modelmenu=1" },
275 { "ASUS", "M2A-VM", "http://www.asus.com.tw/products.aspx?l1=3&l2=101&l3=496&l4=0&model=1568&modelmenu=1" },
276 { "ASUS", "M2N-E", "http://www.asus.com/products.aspx?l1=3&l2=101&l3=308&l4=0&model=1181&modelmenu=1" },
277 { "ASUS", "P2B", "http://www.motherboard.cz/mb/asus/P2B.htm" },
278 { "ASUS", "P2B-F", "http://www.motherboard.cz/mb/asus/P2B-F.htm" },
279 { "ASUS", "P2B-D", "ftp://ftp.asus.com.tw/pub/ASUS/mb/slot1/440bx/p2b-d/" },
280 { "ASUS", "P2B-DS", "ftp://ftp.asus.com.tw/pub/ASUS/mb/slot1/440bx/p2b-ds/" },
281 { "ASUS", "A7V400-MX", "http://www.asus.com.tw/products.aspx?l1=3&l2=13&l3=63&l4=0&model=228&modelmenu=1" },
282 { "ASUS", "A7V8X-MX", "http://www.asus.com.tw/products.aspx?l1=3&l2=13&l3=64&l4=0&model=229&modelmenu=1" },
283 { "ASUS", "P4B266", "http://www.ciao.co.uk/ASUS_Intel_845D_Chipset_P4B266__5409807#productdetail" },
284 { "ASUS", "A8V-E SE", "http://www.asus.com.tw/products.aspx?l1=3&l2=15&l3=143&l4=0&model=576&modelmenu=1" },
285 { "ASUS", "P2L97-S", "http://www.motherboard.cz/mb/asus/P2L97-S.htm" },
286 { "ASUS", "M2A-MX", "http://www.asus.com/products.aspx?l1=3&l2=101&l3=583&l4=0&model=1909&modelmenu=1" },
287 { "ASUS", "P5B-Deluxe", "ftp://ftp.asus.com.tw/pub/ASUS/mb/socket775/P5B-Deluxe/" },
288 { "ASUS", "P6T Deluxe V2", "http://www.asus.com/product.aspx?P_ID=iRlP8RG9han6saZx" },
289 { "A-Trend", "ATC-6220", "http://www.motherboard.cz/mb/atrend/atc6220.htm" },
290 { "BCOM", "WinNET100", "http://www.coreboot.org/BCOM_WINNET100_Build_Tutorial" },
291 { "GIGABYTE", "GA-6BXC", "http://www.gigabyte.com.tw/Products/Motherboard/Products_Spec.aspx?ClassValue=Motherboard&ProductID=1445&ProductName=GA-6BXC" },
292 { "GIGABYTE", "GA-6BXDU", "http://www.gigabyte.com.tw/Products/Motherboard/Products_Spec.aspx?ProductID=1429" },
293 { "GIGABYTE", "GA-6ZMA", "http://www.gigabyte.de/Support/Motherboard/BIOS_Model.aspx?ProductID=3289" },
294 { "Intel", "EP80759", NULL },
295 { "MSI", "KT4V", NULL },
296 { "MSI", "MS-7046", NULL },
297 { "MSI", "MS-7065", NULL },
298 { "MSI", "MS-7236 (945PL Neo3)", "http://global.msi.com.tw/index.php?func=prodmbspec&maincat_no=1&cat2_no=&cat3_no=&prod_no=1173#menu" },
299 { "MSI", "MS-7345 (P35 Neo2-FIR)","http://www.msi.com/index.php?func=prodcpusupport&maincat_no=1&cat2_no=170&cat3_no=&prod_no=1261#menu" },
300 { "MSI", "MS-7168 (Orion)", "http://support.packardbell.co.uk/uk/item/index.php?i=spec_orion&pi=platform_honeymoon_istart" },
301 { "NEC", "PowerMate 2000", "http://support.necam.com/mobilesolutions/hardware/Desktops/pm2000/celeron/" },
302 { "PC Engines", "Alix.1c", "http://pcengines.ch/alix1c.htm" },
303 { "PC Engines", "Alix.2c2", "http://pcengines.ch/alix2c2.htm" },
304 { "PC Engines", "Alix.2c3", "http://pcengines.ch/alix2c3.htm" },
305 { "PC Engines", "Alix.3c3", "http://pcengines.ch/alix3c3.htm" },
306 { "RCA", "RM4100", "http://www.settoplinux.org" },
307 { "Supermicro", "H8QC8", "http://www.supermicro.com/Aplus/motherboard/Opteron/nforce/H8QC8.cfm" },
308 { "Sun", "Blade x6250", "http://www.sun.com/servers/blades/x6250/" },
309 { "Thomson", "IP1000", "http://www.settoplinux.org" },
310 { "T-Online", "S-100", "http://wiki.freifunk-hannover.de/T-Online_S_100" },
311 { "Tyan", "S1846", "http://www.tyan.com/archive/products/html/tsunamiatx.html" },
312 // { "Tyan", "S2498 (Tomcat K7M)", "http://www.tyan.com/archive/products/html/tomcatk7m.html" },
313 { "Tyan", "S2881", "http://www.tyan.com/product_board_detail.aspx?pid=115" },
314 { "Tyan", "S2882", "http://www.tyan.com/product_board_detail.aspx?pid=121" },
315 { "Tyan", "S2882-D", "http://www.tyan.com/product_board_detail.aspx?pid=127" },
316 { "Tyan", "S2891", NULL },
317 { "Tyan", "S2892", NULL },
318 { "Tyan", "S2895", NULL },
319 { "Tyan", "S3095", "http://www.tyan.com/product_board_detail.aspx?pid=181" },
320 { "Tyan", "S5180", "http://www.tyan.com/product_board_detail.aspx?pid=456" },
321 { "Tyan", "S5191", "http://www.tyan.com/product_board_detail.aspx?pid=343" },
322 { "Tyan", "S5197", "http://www.tyan.com/product_board_detail.aspx?pid=349" },
323 { "Tyan", "S5211", "http://www.tyan.com/product_board_detail.aspx?pid=591" },
324 { "Tyan", "S5211-1U", "http://www.tyan.com/product_board_detail.aspx?pid=593" },
325 { "Tyan", "S5220", "http://www.tyan.com/product_board_detail.aspx?pid=597" },
326 { "Tyan", "S5375", "http://www.tyan.com/product_board_detail.aspx?pid=566" },
327 { "Tyan", "iS5375-1U", "http://www.tyan.com/product_board_detail.aspx?pid=610" },
328 { "Tyan", "S5376G2NR/S5376WAG2NR","http://www.tyan.com/product_board_detail.aspx?pid=605" },
329 { "Tyan", "S5377", "http://www.tyan.com/product_board_detail.aspx?pid=601" },
330 { "Tyan", "S5397", "http://www.tyan.com/product_board_detail.aspx?pid=560" },
331 { "VIA", "EPIA-M", "http://www.via.com.tw/en/products/mainboards/motherboards.jsp?motherboard_id=81" },
332 { "VIA", "EPIA-MII", "http://www.via.com.tw/en/products/mainboards/motherboards.jsp?motherboard_id=202" },
333 { "VIA", "EPIA-CN", "http://www.via.com.tw/en/products/mainboards/motherboards.jsp?motherboard_id=400" },
334 { "VIA", "EPIA-LN", "http://www.via.com.tw/en/products/mainboards/motherboards.jsp?motherboard_id=473" },
335 { "VIA", "VB700X", "http://www.via.com.tw/en/products/mainboards/motherboards.jsp?motherboard_id=490" },
336 { "VIA", "NAB74X0", "http://www.via.com.tw/en/products/mainboards/motherboards.jsp?motherboard_id=590" },
337 { "VIA", "pc2500e", "http://www.via.com.tw/en/initiatives/empowered/pc2500_mainboard/index.jsp" },
338
339 /* Verified working boards that DO need write-enables. */
340 /* Please keep this list alphabetically ordered by vendor/board. */
341 { "Acorp", "6A815EPD", NULL },
342 /* TODO: Fill in entries/URLs for the remaining boards. */
343
344 /* Verified non-working boards (for now). */
345 /* Please keep this list alphabetically ordered by vendor/board. */
346 { "Abit", "IS-10", "http://www.abit.com.tw/page/en/motherboard/motherboard_detail.php?pMODEL_NAME=IS-10&fMTYPE=Socket+478" },
347 { "ASUS", "A7N8X-E Deluxe", "http://www.asus.com/products.aspx?l1=3&l2=13&l3=56&l4=0&model=217&modelmenu=1" },
348 { "ASUS", "MEW-AM", "ftp://ftp.asus.com.tw/pub/ASUS/mb/sock370/810/mew-am/" },
349 { "ASUS", "MEW-VM", "http://www.elhvb.com/mboards/OEM/HP/manual/ASUS%20MEW-VM.htm" },
350 { "ASUS", "P3B-F", "ftp://ftp.asus.com.tw/pub/ASUS/mb/slot1/440bx/p3b-f/" },
351 { "ASUS", "P5B", "ftp://ftp.asus.com.tw/pub/ASUS/mb/socket775/P5B/" },
352 { "ASUS", "P5BV-M", "ftp://ftp.asus.com.tw/pub/ASUS/mb/socket775/P5B-VM/" },
353 { "Biostar", "M6TBA", "ftp://ftp.biostar-usa.com/manuals/M6TBA/" },
354 { "Boser", "HS-6637", "http://www.boser.com.tw/manual/HS-62376637v3.4.pdf" },
355 { "FIC", "VA-502", "ftp://ftp.fic.com.tw/motherboard/manual/socket7/va-502/" },
356 { "MSI", "MS-7260 (K9N Neo)", "http://global.msi.com.tw/index.php?func=proddesc&prod_no=255&maincat_no=1" },
357 { "PCCHIPS", "M537DMA33", "http://motherboards.mbarron.net/models/pcchips/m537dma.htm" },
358 { "Soyo", "SY-5VD", "http://www.soyo.com/content/Downloads/163/&c=80&p=464&l=English" },
359 { "Sun", "Fire x4540", "http://www.sun.com/servers/x64/x4540/" },
360 { "Sun", "Fire x4150", "http://www.sun.com/servers/x64/x4150/" },
361 { "Sun", "Fire x4200", "http://www.sun.com/servers/entry/x4200/" },
362 { "Sun", "Fire x4600", "http://www.sun.com/servers/x64/x4600/" },
363 { NULL, NULL, 0 },
364};
365
366static int url(const char *vendor, const char *board)
367{
368 int i;
369 const struct board_info_url *b = boards_url;
370
371 for (i = 0; b[i].vendor != NULL; i++) {
372 if (!strcmp(vendor, b[i].vendor) && !strcmp(board, b[i].name))
373 return i;
374 }
375
376 return -1;
377}
378
379void print_supported_chipsets_wiki(void)
380{
381 int i, j, enablescount = 0, color = 1;
382 const struct penable *e;
383
384 for (e = chipset_enables; e->vendor_name != NULL; e++)
385 enablescount++;
386
387 printf("\n== Supported chipsets ==\n\nTotal amount of supported "
388 "chipsets: '''%d'''\n\n{| border=\"0\" valign=\"top\"\n| "
389 "valign=\"top\"|\n\n%s", enablescount, CHIPSET_TH);
390
391 e = chipset_enables;
392 for (i = 0, j = 0; e[i].vendor_name != NULL; i++, j++) {
393 /* Alternate colors if the vendor changes. */
394 if (i > 0 && strcmp(e[i].vendor_name, e[i - 1].vendor_name))
395 color = !color;
396
397 printf("|- bgcolor=\"#%s\" valign=\"top\"\n| %s || %s "
398 "|| %04x:%04x || %s\n", (color) ? "eeeeee" : "dddddd",
399 e[i].vendor_name, e[i].device_name,
400 e[i].vendor_id, e[i].device_id,
401 (e[i].status == OK) ? "{{OK}}" : "?");
402
403 /* Split table in three columns. */
404 if (j >= (enablescount / 3 + 1)) {
405 printf("\n|}\n\n| valign=\"top\"|\n\n" CHIPSET_TH);
406 j = 0;
407 }
408 }
409
410 printf("\n|}\n\n|}\n");
411}
412
413static void wiki_helper(const char *heading, const char *status,
414 int cols, const struct board_info boards[])
415{
416 int i, j, k, boardcount = 0, color = 1;
417 const struct board_info *b;
418 const struct board_info_url *u = boards_url;
419
420 for (b = boards; b->vendor != NULL; b++)
421 boardcount++;
422
423 printf("\n'''%s'''\n\nTotal amount of boards: '''%d'''\n\n"
424 "{| border=\"0\" valign=\"top\"\n| valign=\"top\"|\n\n%s",
425 heading, boardcount, BOARD_TH);
426
427 for (i = 0, j = 0, b = boards; b[i].vendor != NULL; i++, j++) {
428 /* Alternate colors if the vendor changes. */
429 if (i > 0 && strcmp(b[i].vendor, b[i - 1].vendor))
430 color = !color;
431
432 k = url(b[i].vendor, b[i].name);
433
434 printf("|- bgcolor=\"#%s\" valign=\"top\"\n| %s || %s%s %s%s ||"
435 " {{%s}}\n", (color) ? "eeeeee" : "dddddd", b[i].vendor,
436 (k != -1 && u[k].url) ? "[" : "",
437 (k != -1 && u[k].url) ? u[k].url : "",
438 b[i].name, (k != -1 && u[k].url) ? "]" : "", status);
439
440 /* Split table in 'cols' columns. */
441 if (j >= (boardcount / cols + 1)) {
442 printf("\n|}\n\n| valign=\"top\"|\n\n" BOARD_TH);
443 j = 0;
444 }
445 }
446
447 printf("\n|}\n\n|}\n");
448}
449
450static void wiki_helper2(const char *heading, int cols)
451{
452 int i, j, boardcount = 0, color = 1;
453 struct board_pciid_enable *b;
454
455 for (b = board_pciid_enables; b->vendor_name != NULL; b++)
456 boardcount++;
457
458 printf("\n'''%s'''\n\nTotal amount of boards: '''%d'''\n\n"
459 "{| border=\"0\" valign=\"top\"\n| valign=\"top\"|\n\n%s",
460 heading, boardcount, BOARD_TH2);
461
462 b = board_pciid_enables;
463 for (i = 0, j = 0; b[i].vendor_name != NULL; i++, j++) {
464 /* Alternate colors if the vendor changes. */
465 if (i > 0 && strcmp(b[i].vendor_name, b[i - 1].vendor_name))
466 color = !color;
467
468 printf("|- bgcolor=\"#%s\" valign=\"top\"\n| %s || %s || "
469 "%s%s%s%s || {{OK}}\n", (color) ? "eeeeee" : "dddddd",
470 b[i].vendor_name, b[i].board_name,
471 (b[i].lb_vendor) ? "-m " : "&mdash;",
472 (b[i].lb_vendor) ? b[i].lb_vendor : "",
473 (b[i].lb_vendor) ? ":" : "",
474 (b[i].lb_vendor) ? b[i].lb_part : "");
475
476 /* Split table in three columns. */
477 if (j >= (boardcount / cols + 1)) {
478 printf("\n|}\n\n| valign=\"top\"|\n\n" BOARD_TH2);
479 j = 0;
480 }
481 }
482
483 printf("\n|}\n\n|}\n");
484}
485
486void print_supported_boards_wiki(void)
487{
488 printf("%s", BOARD_INTRO);
489 wiki_helper("Known good (worked out of the box)", "OK", 3, boards_ok);
490 wiki_helper2("Known good (with write-enable code in flashrom)", 3);
491 wiki_helper("Not supported (yet)", "No", 3, boards_bad);
492}
493
494void print_supported_chips_wiki(void)
495{
496 int i = 0, c = 1, chipcount = 0;
497 struct flashchip *f, *old = NULL;
498
499 for (f = flashchips; f->name != NULL; f++)
500 chipcount++;
501
502 printf("\n== Supported chips ==\n\nTotal amount of supported "
503 "chips: '''%d'''\n\n{| border=\"0\" valign=\"top\"\n"
504 "| valign=\"top\"|\n\n%s", chipcount, CHIP_TH);
505
506 for (f = flashchips; f->name != NULL; f++, i++) {
507 if (!strncmp(f->name, "unknown", 7))
508 continue;
509
510 /* Alternate colors if the vendor changes. */
511 if (old != NULL && strcmp(old->vendor, f->vendor))
512 c = !c;
513
514 printf("|- bgcolor=\"#%s\" valign=\"top\"\n| %s || %s || %d "
515 "|| %s || {{%s}} || {{%s}} || {{%s}} || {{%s}}\n",
516 (c == 1) ? "eeeeee" : "dddddd", f->vendor, f->name,
517 f->total_size, flashbuses_to_text(f->bustype),
518 ((f->tested & TEST_OK_PROBE) ? "OK" : (c) ? "?2" : "?"),
519 ((f->tested & TEST_OK_READ) ? "OK" : (c) ? "?2" : "?"),
520 ((f->tested & TEST_OK_ERASE) ? "OK" : (c) ? "?2" : "?"),
521 ((f->tested & TEST_OK_WRITE) ? "OK" : (c) ? "?2" : "?"));
522
523 /* Split table into three columns. */
524 if (i >= (chipcount / 3 + 1)) {
525 printf("\n|}\n\n| valign=\"top\"|\n\n" CHIP_TH);
526 i = 0;
527 }
528
529 old = f;
530 }
531
532 printf("\n|}\n\n|}\n");
533}
534
535void print_supported_pcidevs_wiki_header(void)
536{
537 printf("%s", PROGRAMMER_SECTION);
538}
539
540void print_supported_pcidevs_wiki_footer(void)
541{
542 printf("\n|}\n");
543}
544
545void print_supported_pcidevs_wiki(struct pcidev_status *devs)
546{
547 int i = 0;
548 static int c = 0;
549
550 /* Alternate colors if the vendor changes. */
551 c = !c;
552
553 for (i = 0; devs[i].vendor_name != NULL; i++) {
554 printf("|- bgcolor=\"#%s\" valign=\"top\"\n| %s || %s || "
555 "%04x:%04x || {{%s}}\n", (c) ? "eeeeee" : "dddddd",
556 devs[i].vendor_name, devs[i].device_name,
557 devs[i].vendor_id, devs[i].device_id,
558 (devs[i].status == PCI_NT) ? (c) ? "?2" : "?" : "OK");
559 }
560}