summaryrefslogtreecommitdiffstats
path: root/internal.c
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2018-09-23 20:20:26 +0200
committerNico Huber <nico.h@gmx.de>2019-06-06 15:54:46 +0000
commit2e50cdc494bf4e44c01e9e331b82a3633b1d9ef2 (patch)
tree78a7f9d9a0dd67f97d25e60c02a10e9785590fbf /internal.c
parentba22411335f26601a76dbdf0d74a71e932b7cff8 (diff)
downloadflashrom-2e50cdc494bf4e44c01e9e331b82a3633b1d9ef2.tar.gz
flashrom-2e50cdc494bf4e44c01e9e331b82a3633b1d9ef2.tar.bz2
flashrom-2e50cdc494bf4e44c01e9e331b82a3633b1d9ef2.zip
Rework internal bus handling and laptop bail-out
We used to bail out on any unknown laptop. However, modern systems with SPI flashes don't suffer from the original problem. Even if a flash chip is shared with the EC, the latter has to expect the host to send regular JEDEC SPI commands any time. So instead of bailing out, we limit the set of buses to probe. If we suspect to be running on a laptop, we only allow probing of SPI and opaque programmers. The user can still use the existing force options to probe all buses. This will obsolete some board-enables that could be moved to `print.c` in follow-up commits. Change-Id: I1dbda8cf0c10d7786106f14f0d18c3dcce35f0a3 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/28716 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Thomas Heijligen <src@posteo.de>
Diffstat (limited to 'internal.c')
-rw-r--r--internal.c70
1 files changed, 39 insertions, 31 deletions
diff --git a/internal.c b/internal.c
index 1d6cff6b6..2bb437c3f 100644
--- a/internal.c
+++ b/internal.c
@@ -257,6 +257,8 @@ int internal_init(void)
#endif
#if IS_X86
+ is_laptop = 2; /* Assume that we don't know by default. */
+
dmi_init();
/* In case Super I/O probing would cause pretty explosions. */
@@ -275,36 +277,13 @@ int internal_init(void)
/* Check laptop whitelist. */
board_handle_before_laptop();
- /* Warn if a non-whitelisted laptop is detected. */
- if (is_laptop && !laptop_ok) {
- msg_perr("========================================================================\n");
- if (is_laptop == 1) {
- msg_perr("WARNING! You seem to be running flashrom on an unsupported laptop.\n");
- } else {
- msg_perr("WARNING! You may be running flashrom on an unsupported laptop. We could\n"
- "not detect this for sure because your vendor has not setup the SMBIOS\n"
- "tables correctly. You can enforce execution by adding\n"
- "'-p internal:laptop=this_is_not_a_laptop' to the command line, but\n"
- "please read the following warning if you are not sure.\n\n");
- }
- msg_perr("Laptops, notebooks and netbooks are difficult to support and we\n"
- "recommend to use the vendor flashing utility. The embedded controller\n"
- "(EC) in these machines often interacts badly with flashing.\n"
- "See the manpage and https://flashrom.org/Laptops for details.\n\n"
- "If flash is shared with the EC, erase is guaranteed to brick your laptop\n"
- "and write may brick your laptop.\n"
- "Read and probe may irritate your EC and cause fan failure, backlight\n"
- "failure and sudden poweroff.\n"
- "You have been warned.\n"
- "========================================================================\n");
-
- if (force_laptop || (not_a_laptop && (is_laptop == 2))) {
- msg_perr("Proceeding anyway because user forced us to.\n");
- } else {
- msg_perr("Aborting.\n");
- return 1;
- }
- }
+ /*
+ * Disable all internal buses by default if we are not sure
+ * this isn't a laptop. Board-enables may override this,
+ * non-legacy buses (SPI and opaque atm) are probed anyway.
+ */
+ if (is_laptop && !(laptop_ok || force_laptop || (not_a_laptop && is_laptop == 2)))
+ internal_buses_supported = BUS_NONE;
/* try to enable it. Failure IS an option, since not all motherboards
* really need this to be done, etc., etc.
@@ -327,7 +306,36 @@ int internal_init(void)
}
#endif
- register_par_master(&par_master_internal, internal_buses_supported);
+ if (internal_buses_supported & BUS_NONSPI)
+ register_par_master(&par_master_internal, internal_buses_supported);
+
+ /* Report if a non-whitelisted laptop is detected that likely uses a legacy bus. */
+ if (is_laptop && !laptop_ok) {
+ msg_pinfo("========================================================================\n");
+ if (is_laptop == 1) {
+ msg_pinfo("You seem to be running flashrom on an unknown laptop. Some\n"
+ "internal buses have been disabled for safety reasons.\n\n");
+ } else {
+ msg_pinfo("You may be running flashrom on an unknown laptop. We could not\n"
+ "detect this for sure because your vendor has not set up the SMBIOS\n"
+ "tables correctly. Some internal buses have been disabled for\n"
+ "safety reasons. You can enforce using all buses by adding\n"
+ " -p internal:laptop=this_is_not_a_laptop\n"
+ "to the command line, but please read the following warning if you\n"
+ "are not sure.\n\n");
+ }
+ msg_perr("Laptops, notebooks and netbooks are difficult to support and we\n"
+ "recommend to use the vendor flashing utility. The embedded controller\n"
+ "(EC) in these machines often interacts badly with flashing.\n"
+ "See the manpage and https://flashrom.org/Laptops for details.\n\n"
+ "If flash is shared with the EC, erase is guaranteed to brick your laptop\n"
+ "and write may brick your laptop.\n"
+ "Read and probe may irritate your EC and cause fan failure, backlight\n"
+ "failure and sudden poweroff.\n"
+ "You have been warned.\n"
+ "========================================================================\n");
+ }
+
return 0;
}