blob: 896eae12f32d8399aa3b44e20d060f2873417425 [file] [log] [blame]
Edward O'Callaghan83c77002019-06-04 15:56:19 +10001/*
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
19#include <stdlib.h>
20#include <string.h>
21#include "flash.h"
22
23void print_chip_support_status(const struct flashctx *flash)
24{
25 if (flash->chip->feature_bits & FEATURE_OTP) {
26 msg_cdbg("This chip may contain one-time programmable memory. "
27 "flashrom cannot read\nand may never be able to write "
28 "it, hence it may not be able to completely\n"
29 "clone the contents of this chip (see man page for "
30 "details).\n");
31 }
32 if ((flash->chip->tested.probe != OK) ||
33 (flash->chip->tested.read != OK) ||
34 (flash->chip->tested.erase != OK) ||
35 (flash->chip->tested.write != OK) ||
36 (flash->chip->tested.uread != OK)) {
37 msg_cdbg("===\n");
38 if ((flash->chip->tested.probe == BAD) ||
39 (flash->chip->tested.read == BAD) ||
40 (flash->chip->tested.erase == BAD) ||
41 (flash->chip->tested.write == BAD) ||
42 (flash->chip->tested.uread == BAD)) {
43 msg_cdbg("This flash part has status NOT WORKING for operations:");
44 if (flash->chip->tested.probe == BAD)
45 msg_cdbg(" PROBE");
46 if (flash->chip->tested.read == BAD)
47 msg_cdbg(" READ");
48 if (flash->chip->tested.erase == BAD)
49 msg_cdbg(" ERASE");
50 if (flash->chip->tested.write == BAD)
51 msg_cdbg(" WRITE");
52 if (flash->chip->tested.uread == BAD)
53 msg_cdbg(" UNBOUNDED READ");
54 msg_cdbg("\n");
55 }
56 if ((flash->chip->tested.probe == NT) ||
57 (flash->chip->tested.read == NT) ||
58 (flash->chip->tested.erase == NT) ||
59 (flash->chip->tested.write == NT) ||
60 (flash->chip->tested.uread == NT)) {
61 msg_cdbg("This flash part has status UNTESTED for operations:");
62 if (flash->chip->tested.probe == NT)
63 msg_cdbg(" PROBE");
64 if (flash->chip->tested.read == NT)
65 msg_cdbg(" READ");
66 if (flash->chip->tested.erase == NT)
67 msg_cdbg(" ERASE");
68 if (flash->chip->tested.write == NT)
69 msg_cdbg(" WRITE");
70 if (flash->chip->tested.uread == NT)
71 msg_cdbg(" UNBOUNDED READ");
72 msg_cdbg("\n");
73 }
74 /* FIXME: This message is designed towards CLI users. */
75 msg_cdbg("The test status of this chip may have been updated "
76 "in the latest development\n"
77 "version of flashrom. If you are running the latest "
78 "development version,\n"
79 "please email a report to flashrom@flashrom.org if "
80 "any of the above operations\n"
81 "work correctly for you with this flash part. Please "
82 "include the flashrom\n"
83 "output with the additional -V option for all "
84 "operations you tested (-V, -Vr,\n"
85 "-VE, -Vw), and mention which mainboard or "
86 "programmer you tested.\n"
87 "Please mention your board in the subject line. "
88 "Thanks for your help!\n");
89 }
90}
91
92/*
93 * Return a string corresponding to the bustype parameter.
94 * Memory is obtained with malloc() and must be freed with free() by the caller.
95 */
96char *flashbuses_to_text(enum chipbustype bustype)
97{
98 char *ret = calloc(1, 1);
99 /*
100 * FIXME: Once all chipsets and flash chips have been updated, NONSPI
101 * will cease to exist and should be eliminated here as well.
102 */
103 if (bustype == BUS_NONSPI) {
104 ret = strcat_realloc(ret, "Non-SPI, ");
105 } else {
106 if (bustype & BUS_PARALLEL)
107 ret = strcat_realloc(ret, "Parallel, ");
108 if (bustype & BUS_LPC)
109 ret = strcat_realloc(ret, "LPC, ");
110 if (bustype & BUS_FWH)
111 ret = strcat_realloc(ret, "FWH, ");
112 if (bustype & BUS_SPI)
113 ret = strcat_realloc(ret, "SPI, ");
114 if (bustype & BUS_PROG)
115 ret = strcat_realloc(ret, "Programmer-specific, ");
116 if (bustype == BUS_NONE)
117 ret = strcat_realloc(ret, "None, ");
118 }
119 /* Kill last comma. */
120 ret[strlen(ret) - 2] = '\0';
121 ret = realloc(ret, strlen(ret) + 1);
122 return ret;
123}