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