Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 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 | |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 22 | #include <stdio.h> |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 23 | #include <string.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <time.h> |
| 26 | #include "flash.h" |
| 27 | #include "flashchips.h" |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 28 | #include "programmer.h" |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 29 | |
Mathias Krause | a60faab | 2011-01-17 07:50:42 +0000 | [diff] [blame] | 30 | static const char wiki_header[] = "= Supported devices =\n\n\ |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 31 | <div style=\"margin-top:0.5em; padding:0.5em 0.5em 0.5em 0.5em; \ |
Stefan Tauner | f74a7b9 | 2011-09-14 22:09:48 +0000 | [diff] [blame] | 32 | background-color:#eeeeee; text-align:right; border:1px solid #aabbcc;\">\ |
| 33 | <small>\n\ |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 34 | Please do '''not''' edit these tables in the wiki directly, they are \ |
| 35 | generated by pasting '''flashrom -z''' output.<br />\ |
| 36 | '''Last update:''' %s(generated by flashrom %s)\n</small></div>\n"; |
| 37 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 38 | static 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 Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 42 | #if CONFIG_INTERNAL == 1 |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 43 | static const char chipset_th[] = "\ |
| 44 | ! align=\"left\" | Vendor\n\ |
| 45 | ! align=\"left\" | Southbridge\n\ |
| 46 | ! align=\"center\" | PCI IDs\n\ |
Stefan Tauner | f74a7b9 | 2011-09-14 22:09:48 +0000 | [diff] [blame] | 47 | ! align=\"center\" | Status\n\n"; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 48 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 49 | static const char board_th[] = "\ |
| 50 | ! align=\"left\" | Vendor\n\ |
| 51 | ! align=\"left\" | Mainboard\n\ |
| 52 | ! align=\"left\" | Required option\n\ |
Stefan Tauner | f74a7b9 | 2011-09-14 22:09:48 +0000 | [diff] [blame] | 53 | ! align=\"center\" | Status\n\n"; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 54 | |
Mathias Krause | a60faab | 2011-01-17 07:50:42 +0000 | [diff] [blame] | 55 | static const char board_intro[] = "\ |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 56 | \n== Supported mainboards ==\n\n\ |
| 57 | In general, it is very likely that flashrom works out of the box even if your \ |
| 58 | mainboard is not listed below.\n\nThis is a list of mainboards where we have \ |
| 59 | verified that they either do or do not need any special initialization to \ |
| 60 | make flashrom work (given flashrom supports the respective chipset and flash \ |
| 61 | chip), or that they do not yet work at all. If they do not work, support may \ |
| 62 | or may not be added later.\n\n\ |
Stefan Tauner | d06d941 | 2011-06-12 19:47:55 +0000 | [diff] [blame] | 63 | Mainboards (or individual revisions) which don't appear in the list may or may \ |
| 64 | not work (we don't know, someone has to give it a try). Please report any \ |
| 65 | further verified mainboards on the [[Mailinglist|mailing list]].\n"; |
Carl-Daniel Hailfinger | 8841d3e | 2010-05-15 15:04:37 +0000 | [diff] [blame] | 66 | #endif |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 67 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 68 | static const char chip_th[] = "\ |
Stefan Tauner | f74a7b9 | 2011-09-14 22:09:48 +0000 | [diff] [blame] | 69 | ! 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 Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 75 | |- bgcolor=\"#6699ff\"\n| colspan=\"4\" | \n\ |
Stefan Tauner | f74a7b9 | 2011-09-14 22:09:48 +0000 | [diff] [blame] | 76 | | Probe\n| Read\n| Erase\n| Write\n\ |
Paul Menzel | 018d482 | 2011-10-21 12:33:07 +0000 | [diff] [blame] | 77 | | align=\"center\" | Min \n| align=\"center\" | Max\n\n"; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 78 | |
Stefan Tauner | 1c356bb | 2013-07-11 13:48:52 +0000 | [diff] [blame] | 79 | static const char chip_intro[] = "\ |
| 80 | \n== Supported flash chips ==\n\n\ |
| 81 | The list below contains all chips that have some kind of explicit support added to flashrom and their last \ |
| 82 | known test status. Newer SPI flash chips might work even without explicit support if they implement SFDP ([\ |
| 83 | http://www.jedec.org/standards-documents/docs/jesd216 Serial Flash Discoverable Parameters - JESD216]). \ |
| 84 | Flashrom will detect this automatically and inform you about it.\n\n\ |
| 85 | The names used below are designed to be as concise as possible and hence contain only the characters \ |
| 86 | describing properties that are relevant to flashrom. Irrelevant characters specify attributes flashrom can not \ |
| 87 | use or even detect by itself (e.g. the physical package) and have no effect on flashrom's operation. They are \ |
| 88 | replaced by dots ('.') functioning as wildcards (like in Regular Expressions) or are completely omitted at the \ |
| 89 | end of a name.\n"; |
| 90 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 91 | static const char programmer_th[] = "\ |
Stefan Tauner | 4b24a2d | 2012-12-27 18:40:36 +0000 | [diff] [blame] | 92 | ! align=\"left\" | Programmer\n\ |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 93 | ! align=\"left\" | Vendor\n\ |
| 94 | ! align=\"left\" | Device\n\ |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 95 | ! align=\"center\" | IDs\n\ |
Stefan Tauner | f74a7b9 | 2011-09-14 22:09:48 +0000 | [diff] [blame] | 96 | ! align=\"center\" | Status\n\n"; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 97 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 98 | #if CONFIG_INTERNAL == 1 |
Mathias Krause | a60faab | 2011-01-17 07:50:42 +0000 | [diff] [blame] | 99 | static const char laptop_intro[] = "\n== Supported laptops/notebooks ==\n\n\ |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 100 | In general, flashing laptops is more difficult because laptops\n\n\ |
| 101 | * often use the flash chip for stuff besides the BIOS,\n\ |
| 102 | * often have special protection stuff which has to be handled by flashrom,\n\ |
| 103 | * often use flash translation circuits which need drivers in flashrom.\n\n\ |
| 104 | <div style=\"margin-top:0.5em; padding:0.5em 0.5em 0.5em 0.5em; \ |
| 105 | background-color:#ff6666; align:right; border:1px solid #000000;\">\n\ |
| 106 | '''IMPORTANT:''' At this point we recommend to '''not''' use flashrom on \ |
| 107 | untested laptops unless you have a means to recover from a flashing that goes \ |
| 108 | wrong (a working backup flash chip and/or good soldering skills).\n</div>\n"; |
| 109 | |
Uwe Hermann | a6d9c4b | 2010-05-24 15:28:12 +0000 | [diff] [blame] | 110 | static void print_supported_chipsets_wiki(int cols) |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 111 | { |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 112 | int i; |
| 113 | unsigned int lines_per_col; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 114 | const struct penable *e; |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 115 | int enablescount = 0, color = 1; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 116 | |
| 117 | for (e = chipset_enables; e->vendor_name != NULL; e++) |
| 118 | enablescount++; |
| 119 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 120 | /* +1 to force the resulting number of columns to be < cols */ |
| 121 | lines_per_col = enablescount / cols + ((enablescount%cols) > 0 ? 1 : 0); |
| 122 | |
| 123 | printf("\n== Supported chipsets ==\n\nTotal amount of supported chipsets: '''%d'''\n\n" |
| 124 | "{| border=\"0\" valign=\"top\"\n", enablescount); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 125 | |
| 126 | e = chipset_enables; |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 127 | for (i = 0; e[i].vendor_name != NULL; i++) { |
| 128 | if ((i % lines_per_col) == 0) |
| 129 | printf("%s%s", th_start, chipset_th); |
| 130 | |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 131 | /* Alternate colors if the vendor changes. */ |
| 132 | if (i > 0 && strcmp(e[i].vendor_name, e[i - 1].vendor_name)) |
| 133 | color = !color; |
| 134 | |
Uwe Hermann | a6d9c4b | 2010-05-24 15:28:12 +0000 | [diff] [blame] | 135 | printf("|- bgcolor=\"#%s\"\n| %s || %s " |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 136 | "|| %04x:%04x || %s\n", (color) ? "eeeeee" : "dddddd", |
| 137 | e[i].vendor_name, e[i].device_name, |
| 138 | e[i].vendor_id, e[i].device_id, |
Uwe Hermann | a6d9c4b | 2010-05-24 15:28:12 +0000 | [diff] [blame] | 139 | (e[i].status == OK) ? "{{OK}}" : "{{?3}}"); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 140 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 141 | if (((i % lines_per_col) + 1) == lines_per_col) |
| 142 | printf("\n|}\n\n"); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 145 | /* end inner table if it did not fill the last column fully */ |
| 146 | if (((i % lines_per_col)) > 0) |
| 147 | printf("\n|}\n\n"); |
| 148 | printf("\n\n|}\n"); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 149 | } |
| 150 | |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 151 | static void print_supported_boards_wiki_helper(const char *devicetype, int cols, const struct board_info boards[]) |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 152 | { |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 153 | int i, k; |
| 154 | unsigned int boardcount, lines_per_col; |
Stefan Tauner | 2c20b28 | 2012-07-28 19:35:26 +0000 | [diff] [blame] | 155 | unsigned int boardcount_good = 0, boardcount_bad = 0, boardcount_nt = 0; |
| 156 | int num_notes = 0, color = 1; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 157 | char *notes = calloc(1, 1); |
| 158 | char tmp[900 + 1]; |
Carl-Daniel Hailfinger | 97d5b12 | 2011-08-31 16:19:50 +0000 | [diff] [blame] | 159 | const struct board_match *b = board_matches; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 160 | |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 161 | for (i = 0; boards[i].vendor != NULL; i++) { |
Stefan Tauner | 2c20b28 | 2012-07-28 19:35:26 +0000 | [diff] [blame] | 162 | if (boards[i].working == OK) |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 163 | boardcount_good++; |
Stefan Tauner | 2c20b28 | 2012-07-28 19:35:26 +0000 | [diff] [blame] | 164 | else if (boards[i].working == NT) |
| 165 | boardcount_nt++; |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 166 | else |
| 167 | boardcount_bad++; |
| 168 | } |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 169 | boardcount = boardcount_good + boardcount_nt + boardcount_bad; |
| 170 | |
| 171 | /* +1 to force the resulting number of columns to be < cols */ |
| 172 | lines_per_col = boardcount / cols + ((boardcount%cols) > 0 ? 1 : 0); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 173 | |
Stefan Tauner | 1c356bb | 2013-07-11 13:48:52 +0000 | [diff] [blame] | 174 | printf("\n\nTotal amount of known good %s: '''%d'''; " |
Stefan Tauner | 2c20b28 | 2012-07-28 19:35:26 +0000 | [diff] [blame] | 175 | "Untested (e.g. user vanished before testing new code): '''%d'''; " |
| 176 | "Not yet supported (i.e. known-bad): '''%d'''.\n\n" |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 177 | "{| border=\"0\" valign=\"top\"\n", devicetype, boardcount_good, boardcount_nt, boardcount_bad); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 178 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 179 | for (i = 0; boards[i].vendor != NULL; i++) { |
| 180 | if ((i % lines_per_col) == 0) |
| 181 | printf("%s%s", th_start, board_th); |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 182 | |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 183 | /* Alternate colors if the vendor changes. */ |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 184 | if (i > 0 && strcmp(boards[i].vendor, boards[i - 1].vendor)) |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 185 | color = !color; |
| 186 | |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 187 | k = 0; |
Carl-Daniel Hailfinger | 4146ced | 2010-06-07 11:10:43 +0000 | [diff] [blame] | 188 | while ((b[k].vendor_name != NULL) && |
| 189 | (strcmp(b[k].vendor_name, boards[i].vendor) || |
| 190 | strcmp(b[k].board_name, boards[i].name))) { |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 191 | k++; |
| 192 | } |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 193 | |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 194 | printf("|- bgcolor=\"#%s\"\n| %s || %s%s %s%s || %s%s%s%s " |
| 195 | "|| {{%s}}", (color) ? "eeeeee" : "dddddd", |
| 196 | boards[i].vendor, |
| 197 | boards[i].url ? "[" : "", |
| 198 | boards[i].url ? boards[i].url : "", |
| 199 | boards[i].name, |
| 200 | boards[i].url ? "]" : "", |
Carl-Daniel Hailfinger | 2d927fb | 2012-01-04 00:48:27 +0000 | [diff] [blame] | 201 | b[k].lb_vendor ? "-p internal:mainboard=" : "—", |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 202 | b[k].lb_vendor ? b[k].lb_vendor : "", |
| 203 | b[k].lb_vendor ? ":" : "", |
| 204 | b[k].lb_vendor ? b[k].lb_part : "", |
Stefan Tauner | 2c20b28 | 2012-07-28 19:35:26 +0000 | [diff] [blame] | 205 | (boards[i].working == OK) ? "OK" : |
| 206 | (boards[i].working == NT) ? "?3" : "No"); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 207 | |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 208 | if (boards[i].note) { |
Stefan Tauner | 1c356bb | 2013-07-11 13:48:52 +0000 | [diff] [blame] | 209 | num_notes++; |
| 210 | printf(" <span id=\"%s_ref%d\"><sup>[[#%s_note%d|%d]]</sup></span>\n", |
| 211 | devicetype, num_notes, devicetype, num_notes, num_notes); |
| 212 | int ret = snprintf(tmp, sizeof(tmp), |
| 213 | "<span id=\"%s_note%d\">%d. [[#%s_ref%d|↑]]</span>" |
| 214 | " <nowiki>%s</nowiki><br />\n", devicetype, num_notes, num_notes, |
| 215 | devicetype, num_notes, boards[i].note); |
| 216 | if (ret < 0 || ret >= sizeof(tmp)) { |
| 217 | fprintf(stderr, "Footnote text #%d of %s truncated (ret=%d, sizeof(tmp)=%zu)\n", |
| 218 | num_notes, devicetype, ret, sizeof(tmp)); |
| 219 | } |
Mathias Krause | a60faab | 2011-01-17 07:50:42 +0000 | [diff] [blame] | 220 | notes = strcat_realloc(notes, tmp); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 221 | } else { |
| 222 | printf("\n"); |
| 223 | } |
| 224 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 225 | if (((i % lines_per_col) + 1) == lines_per_col) |
| 226 | printf("\n|}\n\n"); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 229 | /* end inner table if it did not fill the last column fully */ |
| 230 | if (((i % lines_per_col)) > 0) |
| 231 | printf("\n|}\n\n"); |
Stefan Tauner | 352e50b | 2013-02-22 15:58:45 +0000 | [diff] [blame] | 232 | printf("|}\n"); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 233 | |
| 234 | if (num_notes > 0) |
| 235 | printf("\n<small>\n%s</small>\n", notes); |
| 236 | free(notes); |
| 237 | } |
| 238 | |
Uwe Hermann | a6d9c4b | 2010-05-24 15:28:12 +0000 | [diff] [blame] | 239 | static void print_supported_boards_wiki(void) |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 240 | { |
| 241 | printf("%s", board_intro); |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 242 | print_supported_boards_wiki_helper("boards", 2, boards_known); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 243 | |
| 244 | printf("%s", laptop_intro); |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 245 | print_supported_boards_wiki_helper("laptops", 1, laptops_known); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 246 | } |
Carl-Daniel Hailfinger | 8841d3e | 2010-05-15 15:04:37 +0000 | [diff] [blame] | 247 | #endif |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 248 | |
Uwe Hermann | a6d9c4b | 2010-05-24 15:28:12 +0000 | [diff] [blame] | 249 | static void print_supported_chips_wiki(int cols) |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 250 | { |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 251 | unsigned int lines_per_col; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 252 | uint32_t t; |
Stefan Tauner | 0015549 | 2011-06-26 20:45:35 +0000 | [diff] [blame] | 253 | char *s; |
Stefan Tauner | f74a7b9 | 2011-09-14 22:09:48 +0000 | [diff] [blame] | 254 | char vmax[6]; |
| 255 | char vmin[6]; |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 256 | const struct flashchip *f, *old = NULL; |
| 257 | int i = 0, c = 1, chipcount = 0; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 258 | |
Stefan Tauner | 93f7023 | 2011-07-26 14:33:46 +0000 | [diff] [blame] | 259 | for (f = flashchips; f->name != NULL; f++) { |
Stefan Tauner | 035492a | 2012-02-03 22:32:09 +0000 | [diff] [blame] | 260 | /* Don't count generic entries. */ |
| 261 | if (!strncmp(f->vendor, "Unknown", 7) || |
| 262 | !strncmp(f->vendor, "Programmer", 10) || |
| 263 | !strncmp(f->name, "unknown", 7)) |
Stefan Tauner | 4c5665f | 2012-02-17 20:03:37 +0000 | [diff] [blame] | 264 | continue; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 265 | chipcount++; |
Stefan Tauner | 93f7023 | 2011-07-26 14:33:46 +0000 | [diff] [blame] | 266 | } |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 267 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 268 | /* +1 to force the resulting number of columns to be < cols */ |
| 269 | lines_per_col = chipcount / cols + ((chipcount%cols) > 0 ? 1 : 0); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 270 | |
Stefan Tauner | 1c356bb | 2013-07-11 13:48:52 +0000 | [diff] [blame] | 271 | printf("%s", chip_intro); |
| 272 | printf("\nTotal amount of supported chips: '''%d'''\n\n" |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 273 | "{| border=\"0\" valign=\"top\"\n", chipcount); |
| 274 | |
| 275 | for (f = flashchips; f->name != NULL; f++) { |
Stefan Tauner | 035492a | 2012-02-03 22:32:09 +0000 | [diff] [blame] | 276 | /* Don't print generic entries. */ |
| 277 | if (!strncmp(f->vendor, "Unknown", 7) || |
| 278 | !strncmp(f->vendor, "Programmer", 10) || |
| 279 | !strncmp(f->name, "unknown", 7)) |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 280 | continue; |
| 281 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 282 | if ((i % lines_per_col) == 0) |
| 283 | printf("%s%s", th_start, chip_th); |
| 284 | |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 285 | /* Alternate colors if the vendor changes. */ |
| 286 | if (old != NULL && strcmp(old->vendor, f->vendor)) |
| 287 | c = !c; |
| 288 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 289 | old = f; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 290 | t = f->tested; |
Stefan Tauner | 0015549 | 2011-06-26 20:45:35 +0000 | [diff] [blame] | 291 | s = flashbuses_to_text(f->bustype); |
Stefan Tauner | f74a7b9 | 2011-09-14 22:09:48 +0000 | [diff] [blame] | 292 | sprintf(vmin, "%0.03f", f->voltage.min / (double)1000); |
| 293 | sprintf(vmax, "%0.03f", f->voltage.max / (double)1000); |
| 294 | /* '{{%s}}' is used in combination with 'OK', 'No' and '?3' to |
| 295 | * select special formatting templates for the bg color. */ |
| 296 | printf("|- bgcolor=\"#%s\"\n| %s || %s || align=\"right\" | %d " |
| 297 | "|| %s || {{%s}} || {{%s}} || {{%s}} || {{%s}}" |
| 298 | "|| %s || %s \n", |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 299 | (c == 1) ? "eeeeee" : "dddddd", f->vendor, f->name, |
Stefan Tauner | 0015549 | 2011-06-26 20:45:35 +0000 | [diff] [blame] | 300 | f->total_size, s, |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 301 | (t & TEST_OK_PROBE) ? "OK" : |
Uwe Hermann | a6d9c4b | 2010-05-24 15:28:12 +0000 | [diff] [blame] | 302 | (t & TEST_BAD_PROBE) ? "No" : "?3", |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 303 | (t & TEST_OK_READ) ? "OK" : |
Uwe Hermann | a6d9c4b | 2010-05-24 15:28:12 +0000 | [diff] [blame] | 304 | (t & TEST_BAD_READ) ? "No" : "?3", |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 305 | (t & TEST_OK_ERASE) ? "OK" : |
Uwe Hermann | a6d9c4b | 2010-05-24 15:28:12 +0000 | [diff] [blame] | 306 | (t & TEST_BAD_ERASE) ? "No" : "?3", |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 307 | (t & TEST_OK_WRITE) ? "OK" : |
Stefan Tauner | f74a7b9 | 2011-09-14 22:09:48 +0000 | [diff] [blame] | 308 | (t & TEST_BAD_WRITE) ? "No" : "?3", |
| 309 | f->voltage.min ? vmin : "N/A", |
| 310 | f->voltage.min ? vmax : "N/A"); |
Stefan Tauner | 0015549 | 2011-06-26 20:45:35 +0000 | [diff] [blame] | 311 | free(s); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 312 | |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 313 | if (((i % lines_per_col) + 1) == lines_per_col) |
| 314 | printf("\n|}\n\n"); |
| 315 | i++; |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 316 | } |
Stefan Tauner | 00ec027 | 2012-07-29 02:04:21 +0000 | [diff] [blame] | 317 | /* end inner table if it did not fill the last column fully */ |
| 318 | if (((i % lines_per_col)) > 0) |
| 319 | printf("\n|}\n\n"); |
| 320 | printf("|}\n\n"); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 321 | } |
| 322 | |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 323 | /* Following functions are not needed when no PCI/USB programmers are compiled in, |
| 324 | * but since print_wiki code has no size constraints we include it unconditionally. */ |
Stefan Tauner | 4b24a2d | 2012-12-27 18:40:36 +0000 | [diff] [blame] | 325 | static int count_supported_devs_wiki(const struct dev_entry *devs) |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 326 | { |
| 327 | unsigned int count = 0; |
| 328 | unsigned int i = 0; |
Stefan Tauner | 4b24a2d | 2012-12-27 18:40:36 +0000 | [diff] [blame] | 329 | for (i = 0; devs[i].vendor_id != 0; i++) |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 330 | count++; |
| 331 | return count; |
| 332 | } |
| 333 | |
Stefan Tauner | 4b24a2d | 2012-12-27 18:40:36 +0000 | [diff] [blame] | 334 | static void print_supported_devs_wiki_helper(const struct programmer_entry prog) |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 335 | { |
| 336 | int i = 0; |
| 337 | static int c = 0; |
Stefan Tauner | 4b24a2d | 2012-12-27 18:40:36 +0000 | [diff] [blame] | 338 | const struct dev_entry *devs = prog.devs.dev; |
| 339 | const unsigned int count = count_supported_devs_wiki(devs); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 340 | |
| 341 | /* Alternate colors if the vendor changes. */ |
| 342 | c = !c; |
| 343 | |
Stefan Tauner | 4b24a2d | 2012-12-27 18:40:36 +0000 | [diff] [blame] | 344 | for (i = 0; devs[i].vendor_id != 0; i++) { |
| 345 | printf("|- bgcolor=\"#%s\"\n", (c) ? "eeeeee" : "dddddd"); |
| 346 | if (i == 0) |
| 347 | printf("| rowspan=\"%u\" | %s |", count, prog.name); |
| 348 | printf("| %s || %s || %04x:%04x || {{%s}}\n", devs[i].vendor_name, devs[i].device_name, |
| 349 | devs[i].vendor_id, devs[i].device_id, (devs[i].status == NT) ? "?3" : "OK"); |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 350 | } |
| 351 | } |
| 352 | |
| 353 | static void print_supported_devs_wiki() |
| 354 | { |
| 355 | unsigned int pci_count = 0; |
| 356 | unsigned int usb_count = 0; |
| 357 | unsigned int i; |
| 358 | |
| 359 | for (i = 0; i < PROGRAMMER_INVALID; i++) { |
| 360 | const struct programmer_entry prog = programmer_table[i]; |
| 361 | switch (prog.type) { |
| 362 | case USB: |
Stefan Tauner | 4b24a2d | 2012-12-27 18:40:36 +0000 | [diff] [blame] | 363 | usb_count += count_supported_devs_wiki(prog.devs.dev); |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 364 | break; |
| 365 | case PCI: |
Stefan Tauner | 4b24a2d | 2012-12-27 18:40:36 +0000 | [diff] [blame] | 366 | pci_count += count_supported_devs_wiki(prog.devs.dev); |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 367 | break; |
| 368 | case OTHER: |
| 369 | default: |
| 370 | break; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | printf("\n== PCI Devices ==\n\n" |
| 375 | "Total amount of supported PCI devices flashrom can use as a programmer: '''%d'''\n\n" |
| 376 | "{%s%s", pci_count, th_start, programmer_th); |
| 377 | |
| 378 | for (i = 0; i < PROGRAMMER_INVALID; i++) { |
| 379 | const struct programmer_entry prog = programmer_table[i]; |
| 380 | if (prog.type == PCI) { |
Stefan Tauner | 4b24a2d | 2012-12-27 18:40:36 +0000 | [diff] [blame] | 381 | print_supported_devs_wiki_helper(prog); |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 382 | } |
| 383 | } |
| 384 | printf("\n|}\n\n|}\n"); |
| 385 | |
| 386 | printf("\n== USB Devices ==\n\n" |
| 387 | "Total amount of supported USB devices flashrom can use as a programmer: '''%d'''\n\n" |
| 388 | "{%s%s", usb_count, th_start, programmer_th); |
| 389 | |
| 390 | for (i = 0; i < PROGRAMMER_INVALID; i++) { |
| 391 | const struct programmer_entry prog = programmer_table[i]; |
| 392 | if (prog.type == USB) { |
Stefan Tauner | 4b24a2d | 2012-12-27 18:40:36 +0000 | [diff] [blame] | 393 | print_supported_devs_wiki_helper(prog); |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 394 | } |
| 395 | } |
| 396 | printf("\n|}\n\n|}\n"); |
Stefan Tauner | 2c42119 | 2012-12-27 18:40:40 +0000 | [diff] [blame] | 397 | |
| 398 | printf("\n== Other programmers ==\n\n" |
| 399 | "{%s", th_start); |
| 400 | printf("! align=\"left\" | Programmer\n" |
| 401 | "! align=\"left\" | Note\n\n"); |
| 402 | |
| 403 | for (i = 0; i < PROGRAMMER_INVALID; i++) { |
| 404 | static int c = 0; |
| 405 | const struct programmer_entry prog = programmer_table[i]; |
| 406 | if (prog.type == OTHER && prog.devs.note != NULL) { |
| 407 | c = !c; |
| 408 | printf("|- bgcolor=\"#%s\"\n", (c) ? "eeeeee" : "dddddd"); |
| 409 | printf("| %s || %s", prog.name, prog.devs.note); |
| 410 | } |
| 411 | } |
| 412 | printf("\n|}\n\n|}\n"); |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 413 | } |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 414 | |
Carl-Daniel Hailfinger | f529205 | 2009-11-17 09:57:34 +0000 | [diff] [blame] | 415 | void print_supported_wiki(void) |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 416 | { |
| 417 | time_t t = time(NULL); |
| 418 | |
| 419 | printf(wiki_header, ctime(&t), flashrom_version); |
Uwe Hermann | a6d9c4b | 2010-05-24 15:28:12 +0000 | [diff] [blame] | 420 | print_supported_chips_wiki(2); |
Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 421 | #if CONFIG_INTERNAL == 1 |
Uwe Hermann | a6d9c4b | 2010-05-24 15:28:12 +0000 | [diff] [blame] | 422 | print_supported_chipsets_wiki(3); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 423 | print_supported_boards_wiki(); |
Carl-Daniel Hailfinger | 8841d3e | 2010-05-15 15:04:37 +0000 | [diff] [blame] | 424 | #endif |
Stefan Tauner | af358d6 | 2012-12-27 18:40:26 +0000 | [diff] [blame] | 425 | print_supported_devs_wiki(); |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 426 | } |
| 427 | |