print.c 12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * This file is part of the flashrom project.
 *
 * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
 * Copyright (C) 2009 Carl-Daniel Hailfinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

22
#include <stdio.h>
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
#include <string.h>
#include <stdlib.h>
#include "flash.h"
#include "flashchips.h"

/*
 * Return a string corresponding to the bustype parameter.
 * Memory is obtained with malloc() and can be freed with free().
 */
char *flashbuses_to_text(enum chipbustype bustype)
{
	char *ret = calloc(1, 1);
	if (bustype == CHIP_BUSTYPE_UNKNOWN) {
		ret = strcat_realloc(ret, "Unknown,");
	/*
	 * FIXME: Once all chipsets and flash chips have been updated, NONSPI
	 * will cease to exist and should be eliminated here as well.
	 */
	} else if (bustype == CHIP_BUSTYPE_NONSPI) {
		ret = strcat_realloc(ret, "Non-SPI,");
	} else {
		if (bustype & CHIP_BUSTYPE_PARALLEL)
			ret = strcat_realloc(ret, "Parallel,");
		if (bustype & CHIP_BUSTYPE_LPC)
			ret = strcat_realloc(ret, "LPC,");
		if (bustype & CHIP_BUSTYPE_FWH)
			ret = strcat_realloc(ret, "FWH,");
		if (bustype & CHIP_BUSTYPE_SPI)
			ret = strcat_realloc(ret, "SPI,");
		if (bustype == CHIP_BUSTYPE_NONE)
			ret = strcat_realloc(ret, "None,");
	}
	/* Kill last comma. */
	ret[strlen(ret) - 1] = '\0';
	ret = realloc(ret, strlen(ret) + 1);
	return ret;
}

#define POS_PRINT(x) do { pos += strlen(x); printf(x); } while (0)

static int digits(int n)
{
	int i;

	if (!n)
		return 1;

	for (i = 0; n; ++i)
		n /= 10;

	return i;
}

void print_supported_chips(void)
{
	int okcol = 0, pos = 0, i, chipcount = 0;
	struct flashchip *f;

	for (f = flashchips; f->name != NULL; f++) {
		if (GENERIC_DEVICE_ID == f->model_id)
			continue;
		okcol = max(okcol, strlen(f->vendor) + 1 + strlen(f->name));
	}
	okcol = (okcol + 7) & ~7;

	for (f = flashchips; f->name != NULL; f++)
		chipcount++;

	printf("\nSupported flash chips (total: %d):\n\n", chipcount);
	POS_PRINT("Vendor:   Device:");
	while (pos < okcol) {
		printf("\t");
		pos += 8 - (pos % 8);
	}

	printf("Tested OK:\tKnown BAD:  Size/KB:  Type:\n\n");
	printf("(P = PROBE, R = READ, E = ERASE, W = WRITE)\n\n");

	for (f = flashchips; f->name != NULL; f++) {
		/* Don't print "unknown XXXX SPI chip" entries. */
		if (!strncmp(f->name, "unknown", 7))
			continue;

		printf("%s", f->vendor);
		for (i = 0; i < 10 - strlen(f->vendor); i++)
			printf(" ");
		printf("%s", f->name);

		pos = 10 + strlen(f->name);
		while (pos < okcol) {
			printf("\t");
			pos += 8 - (pos % 8);
		}
		if ((f->tested & TEST_OK_MASK)) {
			if ((f->tested & TEST_OK_PROBE))
				POS_PRINT("P ");
			if ((f->tested & TEST_OK_READ))
				POS_PRINT("R ");
			if ((f->tested & TEST_OK_ERASE))
				POS_PRINT("E ");
			if ((f->tested & TEST_OK_WRITE))
				POS_PRINT("W ");
		}
		while (pos < okcol + 9) {
			printf("\t");
			pos += 8 - (pos % 8);
		}
		if ((f->tested & TEST_BAD_MASK)) {
			if ((f->tested & TEST_BAD_PROBE))
				printf("P ");
			if ((f->tested & TEST_BAD_READ))
				printf("R ");
			if ((f->tested & TEST_BAD_ERASE))
				printf("E ");
			if ((f->tested & TEST_BAD_WRITE))
				printf("W ");
		}

		printf("\t    %d", f->total_size);
		for (i = 0; i < 10 - digits(f->total_size); i++)
			printf(" ");
		printf("%s\n", flashbuses_to_text(f->bustype));
	}
}

148
#if CONFIG_INTERNAL == 1
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
void print_supported_chipsets(void)
{
	int i, j, chipsetcount = 0;
	const struct penable *c = chipset_enables;

	for (i = 0; c[i].vendor_name != NULL; i++)
		chipsetcount++;

	printf("\nSupported chipsets (total: %d):\n\nVendor:                  "
	       "Chipset:                 PCI IDs:\n\n", chipsetcount);

	for (i = 0; c[i].vendor_name != NULL; i++) {
		printf("%s", c[i].vendor_name);
		for (j = 0; j < 25 - strlen(c[i].vendor_name); j++)
			printf(" ");
		printf("%s", c[i].device_name);
		for (j = 0; j < 25 - strlen(c[i].device_name); j++)
			printf(" ");
		printf("%04x:%04x%s\n", c[i].vendor_id, c[i].device_id,
		       (c[i].status == OK) ? "" : " (untested)");
	}
}

172
void print_supported_boards_helper(const struct board_info *b, const char *msg)
173 174 175 176 177 178
{
	int i, j, boardcount = 0;

	for (i = 0; b[i].vendor != NULL; i++)
		boardcount++;

179 180
	printf("\n%s (total: %d):\n\n", msg, boardcount);

181 182 183 184 185
	for (i = 0; b[i].vendor != NULL; i++) {
		printf("%s", b[i].vendor);
		for (j = 0; j < 25 - strlen(b[i].vendor); j++)
			printf(" ");
		printf("%s", b[i].name);
Uwe Hermann's avatar
Uwe Hermann committed
186
		for (j = 0; j < 28 - strlen(b[i].name); j++)
187 188 189 190 191 192 193 194 195 196 197 198 199 200
			printf(" ");
		printf("\n");
	}
}

void print_supported_boards(void)
{
	int i, j, boardcount = 0;
	struct board_pciid_enable *b = board_pciid_enables;

	for (i = 0; b[i].vendor_name != NULL; i++)
		boardcount++;

	printf("\nSupported boards which need write-enable code (total: %d):"
Uwe Hermann's avatar
Uwe Hermann committed
201
	       "\n\nVendor:                  Board:                        "
202 203 204 205 206 207 208
	       "Required option:\n\n", boardcount);

	for (i = 0; b[i].vendor_name != NULL; i++) {
		printf("%s", b[i].vendor_name);
		for (j = 0; j < 25 - strlen(b[i].vendor_name); j++)
			printf(" ");
		printf("%s", b[i].board_name);
Uwe Hermann's avatar
Uwe Hermann committed
209
		for (j = 0; j < 30 - strlen(b[i].board_name); j++)
210 211 212 213 214 215 216
			printf(" ");
		if (b[i].lb_vendor != NULL)
			printf("-m %s:%s\n", b[i].lb_vendor, b[i].lb_part);
		else
			printf("(none, board is autodetected)\n");
	}

217 218 219 220 221 222 223 224
	print_supported_boards_helper(boards_ok,
		"Supported boards which don't need write-enable code");
	print_supported_boards_helper(boards_bad,
		"Boards which have been verified to NOT work yet");
	print_supported_boards_helper(laptops_ok,
		"Laptops which have been verified to work");
	print_supported_boards_helper(laptops_bad,
		"Laptops which have been verified to NOT work yet");
225
}
226
#endif
227

228 229 230
void print_supported(void)
{
		print_supported_chips();
231
#if CONFIG_INTERNAL == 1
232 233
		print_supported_chipsets();
		print_supported_boards();
234
#endif
235
#if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT >= 1
236 237
		printf("\nSupported PCI devices flashrom can use "
		       "as programmer:\n\n");
238
#endif
239
#if CONFIG_NIC3COM == 1
240 241
		print_supported_pcidevs(nics_3com);
#endif
242
#if CONFIG_NICREALTEK == 1
Uwe Hermann's avatar
Uwe Hermann committed
243 244 245
		print_supported_pcidevs(nics_realtek);
		print_supported_pcidevs(nics_realteksmc1211);
#endif
246
#if CONFIG_GFXNVIDIA == 1
247 248
		print_supported_pcidevs(gfx_nvidia);
#endif
249
#if CONFIG_DRKAISER == 1
250 251
		print_supported_pcidevs(drkaiser_pcidev);
#endif
252
#if CONFIG_SATASII == 1
253 254
		print_supported_pcidevs(satas_sii);
#endif
255
#if CONFIG_ATAHPT == 1
256 257
		print_supported_pcidevs(ata_hpt);
#endif
258 259
}

260

261
#if CONFIG_INTERNAL == 1
262 263 264
/* Please keep this list alphabetically ordered by vendor/board. */
const struct board_info boards_ok[] = {
	/* Verified working boards that don't need write-enables. */
265
#if defined(__i386__) || defined(__x86_64__)
266 267 268 269 270
	{ "Abit",		"AX8", },
	{ "Abit",		"Fatal1ty F-I90HD", },
	{ "Advantech",		"PCM-5820", },
	{ "ASI",		"MB-5BLMP", },
	{ "ASRock",		"A770CrossFire", },
271
	{ "ASRock",		"K8S8X", },
272
	{ "ASRock",		"M3A790GXH/128M" },
273 274
	{ "ASUS",		"A7N8X Deluxe", },
	{ "ASUS",		"A7N8X-E Deluxe", },
275
	{ "ASUS",		"A7V133", },
276 277 278 279 280 281 282 283 284
	{ "ASUS",		"A7V400-MX", },
	{ "ASUS",		"A7V8X-MX", },
	{ "ASUS",		"A8N-E", },
	{ "ASUS",		"A8NE-FM/S", },
	{ "ASUS",		"A8N-SLI", },
	{ "ASUS",		"A8N-SLI Premium", },
	{ "ASUS",		"A8V Deluxe", },
	{ "ASUS",		"A8V-E Deluxe", },
	{ "ASUS",		"A8V-E SE", },
285 286
	{ "ASUS",		"K8V", },
	{ "ASUS",		"K8V SE Deluxe", },
287
	{ "ASUS",		"K8V-X SE", },
288 289 290 291 292 293 294 295 296 297
	{ "ASUS",		"M2A-MX", },
	{ "ASUS",		"M2A-VM", },
	{ "ASUS",		"M2N-E", },
	{ "ASUS",		"M2V", },
	{ "ASUS",		"M3A78-EM", },
	{ "ASUS",		"P2B", },
	{ "ASUS",		"P2B-D", },
	{ "ASUS",		"P2B-DS", },
	{ "ASUS",		"P2B-F", },
	{ "ASUS",		"P2L97-S", },
Michael Karcher's avatar
Michael Karcher committed
298
	{ "ASUS",		"P5B", },
299 300 301
	{ "ASUS",		"P5B-Deluxe", },
	{ "ASUS",		"P5KC", },
	{ "ASUS",		"P5L-MX", },
Michael Karcher's avatar
Michael Karcher committed
302
	{ "ASUS",		"P6T Deluxe", },
303 304 305
	{ "ASUS",		"P6T Deluxe V2", },
	{ "A-Trend",		"ATC-6220", },
	{ "BCOM",		"WinNET100", },
306
	{ "DFI",		"Blood-Iron P35 T2RL", },
307
	{ "Elitegroup",		"K7S5A", },
308
	{ "Elitegroup",		"P6VAP-A+", },
309
	{ "GIGABYTE",		"GA-2761GXDK", },
310 311 312 313
	{ "GIGABYTE",		"GA-6BXC", },
	{ "GIGABYTE",		"GA-6BXDU", },
	{ "GIGABYTE",		"GA-6ZMA", },
	{ "GIGABYTE",		"GA-7ZM", },
Michael Karcher's avatar
Michael Karcher committed
314
	{ "GIGABYTE",		"GA-965P-DS4", },
315 316
	{ "GIGABYTE",		"GA-EP35-DS3L", },
	{ "GIGABYTE",		"GA-EX58-UD4P", },
317 318
	{ "GIGABYTE",		"GA-M57SLI-S4", },
	{ "GIGABYTE",		"GA-M61P-S3", },
Raúl Soriano's avatar
Raúl Soriano committed
319
	{ "GIGABYTE",		"GA-MA69VM-S2", },
320 321 322
	{ "GIGABYTE",		"GA-MA770T-UD3P", },
	{ "GIGABYTE",		"GA-MA78G-DS3H", },
	{ "GIGABYTE",		"GA-MA78GM-S2H", },
323
	{ "GIGABYTE",		"GA-MA78GPM-DS2H", },
324
	{ "GIGABYTE",		"GA-MA790FX-DQ6", },
325 326 327
	{ "GIGABYTE",		"GA-MA790GP-DS4H", },
	{ "Intel",		"EP80759", },
	{ "Jetway",		"J7F4K1G5D-PB", },
328 329
	{ "MSI",                "MS-6153", },
	{ "MSI",                "MS-6156", },
330
	{ "MSI",                "MS-6330 (K7T Turbo)", },
331 332 333 334 335
	{ "MSI",		"MS-6570 (K7N2)", },
	{ "MSI",		"MS-7065", },
	{ "MSI",		"MS-7168 (Orion)", },
	{ "MSI",		"MS-7236 (945PL Neo3)", },
	{ "MSI",		"MS-7255 (P4M890M)", },
Michael Karcher's avatar
Michael Karcher committed
336
	{ "MSI",		"MS-7312 (K9MM-V)", },
337 338
	{ "MSI",		"MS-7345 (P35 Neo2-FIR)", },
	{ "MSI",		"MS-7368 (K9AG Neo2-Digital)", },
339
	{ "MSI",                "MS-7376 (K9A2 Platinum)", },
340 341 342 343 344 345
	{ "NEC",		"PowerMate 2000", },
	{ "PC Engines",		"Alix.1c", },
	{ "PC Engines",		"Alix.2c2", },
	{ "PC Engines",		"Alix.2c3", },
	{ "PC Engines",		"Alix.3c3", },
	{ "PC Engines",		"Alix.3d3", },
Michael Karcher's avatar
Michael Karcher committed
346
	{ "PC Engines",		"WRAP.2E", },
347
	{ "RCA",		"RM4100", },
348
	{ "Shuttle",            "FD37", },
349 350
	{ "Sun",		"Blade x6250", },
	{ "Supermicro",		"H8QC8", },
Michael Karcher's avatar
Michael Karcher committed
351
	{ "Supermicro",		"X8DTT-F", },
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
	{ "Thomson",		"IP1000", },
	{ "TriGem",		"Lomita", },
	{ "T-Online",		"S-100", },
	{ "Tyan",		"iS5375-1U", },
	{ "Tyan",		"S1846", },
	{ "Tyan",		"S2466", },
	{ "Tyan",		"S2881", },
	{ "Tyan",		"S2882", },
	{ "Tyan",		"S2882-D", },
	{ "Tyan",		"S2891", },
	{ "Tyan",		"S2892", },
	{ "Tyan",		"S2895", },
	{ "Tyan",		"S3095", },
	{ "Tyan",		"S5180", },
	{ "Tyan",		"S5191", },
	{ "Tyan",		"S5197", },
	{ "Tyan",		"S5211", },
	{ "Tyan",		"S5211-1U", },
	{ "Tyan",		"S5220", },
	{ "Tyan",		"S5375", },
	{ "Tyan",		"S5376G2NR/S5376WAG2NR", },
	{ "Tyan",		"S5377", },
Michael Karcher's avatar
Michael Karcher committed
374
	{ "Tyan",		"S5382 (Tempest i5000PW)", },
375
	{ "Tyan",		"S5397", },
376
	{ "VIA",		"EPIA-CN", },
377 378 379 380
	{ "VIA",		"EPIA-EX15000G", },
	{ "VIA",		"EPIA-LN", },
	{ "VIA",		"EPIA-M700", },
	{ "VIA",		"EPIA-NX15000G", },
381
	{ "VIA",		"EPIA-SP", },
382 383
	{ "VIA",		"NAB74X0", },
	{ "VIA",		"pc2500e", },
384
	{ "VIA",		"PC3500G", },
385
	{ "VIA",		"VB700X", },
386
#endif
387 388 389 390 391 392
	{},
};

/* Please keep this list alphabetically ordered by vendor/board. */
const struct board_info boards_bad[] = {
	/* Verified non-working boards (for now). */
393
#if defined(__i386__) || defined(__x86_64__)
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
	{ "Abit",		"IS-10", },
	{ "ASRock",		"K7VT4A+", },
	{ "ASUS",		"MEW-AM", },
	{ "ASUS",		"MEW-VM", },
	{ "ASUS",		"P3B-F", },
	{ "ASUS",		"P5BV-M", },
	{ "Biostar",		"M6TBA", },
	{ "Boser",		"HS-6637", },
	{ "DFI",		"855GME-MGF", },
	{ "FIC",		"VA-502", },
	{ "MSI",		"MS-6178", },
	{ "MSI",		"MS-7260 (K9N Neo)", },
	{ "Soyo",		"SY-5VD", },
	{ "Sun",		"Fire x4150", },
	{ "Sun",		"Fire x4200", },
	{ "Sun",		"Fire x4540", },
	{ "Sun",		"Fire x4600", },
411
#endif
412 413 414 415 416 417
	{},
};

/* Please keep this list alphabetically ordered by vendor/board. */
const struct board_info laptops_ok[] = {
	/* Verified working laptops. */
418
#if defined(__i386__) || defined(__x86_64__)
419
	{ "Lenovo",		"3000 V100 TF05Cxx", },
420
	{ "Acer",               "Aspire 1520", },
421
#endif
422 423 424 425 426 427
	{},
};

/* Please keep this list alphabetically ordered by vendor/board. */
const struct board_info laptops_bad[] = {
	/* Verified non-working laptops (for now). */
428
#if defined(__i386__) || defined(__x86_64__)
429 430 431 432 433 434
	{ "Acer",		"Aspire One", },
	{ "ASUS",		"Eee PC 701 4G", },
	{ "Dell",		"Latitude CPi A366XT", },
	{ "HP/Compaq",		"nx9010", },
	{ "IBM/Lenovo",		"Thinkpad T40p", },
	{ "IBM/Lenovo",		"240", },
435
#endif
436 437
	{},
};
438
#endif
439