Stefan Tauner | 9b32de9 | 2014-08-08 23:52:33 +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 | * Copyright (C) 2011-2014 Stefan Tauner |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ |
| 22 | |
| 23 | #include <stdlib.h> |
| 24 | #include <string.h> |
| 25 | #include "flash.h" |
| 26 | |
| 27 | /* |
| 28 | * Return a string corresponding to the bustype parameter. |
| 29 | * Memory is obtained with malloc() and must be freed with free() by the caller. |
| 30 | */ |
| 31 | char *flashbuses_to_text(enum chipbustype bustype) |
| 32 | { |
| 33 | char *ret = calloc(1, 1); |
| 34 | /* |
| 35 | * FIXME: Once all chipsets and flash chips have been updated, NONSPI |
| 36 | * will cease to exist and should be eliminated here as well. |
| 37 | */ |
| 38 | if (bustype == BUS_NONSPI) { |
| 39 | ret = strcat_realloc(ret, "Non-SPI, "); |
| 40 | } else { |
| 41 | if (bustype & BUS_PARALLEL) |
| 42 | ret = strcat_realloc(ret, "Parallel, "); |
| 43 | if (bustype & BUS_LPC) |
| 44 | ret = strcat_realloc(ret, "LPC, "); |
| 45 | if (bustype & BUS_FWH) |
| 46 | ret = strcat_realloc(ret, "FWH, "); |
| 47 | if (bustype & BUS_SPI) |
| 48 | ret = strcat_realloc(ret, "SPI, "); |
| 49 | if (bustype & BUS_PROG) |
| 50 | ret = strcat_realloc(ret, "Programmer-specific, "); |
| 51 | if (bustype == BUS_NONE) |
| 52 | ret = strcat_realloc(ret, "None, "); |
| 53 | } |
| 54 | /* Kill last comma. */ |
| 55 | ret[strlen(ret) - 2] = '\0'; |
| 56 | ret = realloc(ret, strlen(ret) + 1); |
| 57 | return ret; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | void print_chip_support_status(const struct flashchip *chip) |
| 62 | { |
| 63 | if (chip->feature_bits & FEATURE_OTP) { |
| 64 | msg_cdbg("This chip may contain one-time programmable memory. flashrom cannot read\n" |
| 65 | "and may never be able to write it, hence it may not be able to completely\n" |
| 66 | "clone the contents of this chip (see man page for details).\n"); |
| 67 | } |
| 68 | |
| 69 | if ((chip->tested.erase == NA) && (chip->tested.write == NA)) { |
| 70 | msg_cdbg("This chip's main memory can not be erased/written by design.\n"); |
| 71 | } |
| 72 | |
| 73 | if ((chip->tested.probe == BAD) || (chip->tested.probe == NT) || |
| 74 | (chip->tested.read == BAD) || (chip->tested.read == NT) || |
| 75 | (chip->tested.erase == BAD) || (chip->tested.erase == NT) || |
| 76 | (chip->tested.write == BAD) || (chip->tested.write == NT)){ |
| 77 | msg_cinfo("===\n"); |
| 78 | if ((chip->tested.probe == BAD) || |
| 79 | (chip->tested.read == BAD) || |
| 80 | (chip->tested.erase == BAD) || |
| 81 | (chip->tested.write == BAD)) { |
| 82 | msg_cinfo("This flash part has status NOT WORKING for operations:"); |
| 83 | if (chip->tested.probe == BAD) |
| 84 | msg_cinfo(" PROBE"); |
| 85 | if (chip->tested.read == BAD) |
| 86 | msg_cinfo(" READ"); |
| 87 | if (chip->tested.erase == BAD) |
| 88 | msg_cinfo(" ERASE"); |
| 89 | if (chip->tested.write == BAD) |
| 90 | msg_cinfo(" WRITE"); |
| 91 | msg_cinfo("\n"); |
| 92 | } |
| 93 | if ((chip->tested.probe == NT) || |
| 94 | (chip->tested.read == NT) || |
| 95 | (chip->tested.erase == NT) || |
| 96 | (chip->tested.write == NT)) { |
| 97 | msg_cinfo("This flash part has status UNTESTED for operations:"); |
| 98 | if (chip->tested.probe == NT) |
| 99 | msg_cinfo(" PROBE"); |
| 100 | if (chip->tested.read == NT) |
| 101 | msg_cinfo(" READ"); |
| 102 | if (chip->tested.erase == NT) |
| 103 | msg_cinfo(" ERASE"); |
| 104 | if (chip->tested.write == NT) |
| 105 | msg_cinfo(" WRITE"); |
| 106 | msg_cinfo("\n"); |
| 107 | } |
| 108 | msg_cinfo("The test status of this chip may have been updated in the latest development\n" |
| 109 | "version of flashrom. If you are running the latest development version,\n" |
| 110 | "please email a report to flashrom@flashrom.org if any of the above operations\n" |
| 111 | "work correctly for you with this flash chip. Please include the flashrom log\n" |
| 112 | "file for all operations you tested (see the man page for details), and mention\n" |
| 113 | "which mainboard or programmer you tested in the subject line.\n" |
| 114 | "Thanks for your help!\n"); |
| 115 | } |
| 116 | } |
| 117 | |