summaryrefslogtreecommitdiff
path: root/cli_classic.c
diff options
context:
space:
mode:
authorstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2014-08-30 23:39:51 +0000
committerstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2014-08-30 23:39:51 +0000
commite218311a53921ae44e7d23263c5f25b0e728e5bf (patch)
tree5ca7051747f8161639957c37d984cbe8f878271a /cli_classic.c
parentc7f893affc0116d2081da4ac4545e31dfebe56ed (diff)
downloadflashrom-e218311a53921ae44e7d23263c5f25b0e728e5bf.tar.gz
Refine physical address mapping of flash chips.
- Create distinct functions for mapping and unmapping for flash chips. - Map only when needed: map before probing and unmap immediately after it. Map again when a single chip was probed successfully before taking any actual actions and clean up afterwards. - Map special function chip registers centrally together with flash space instead of within (some) probing methods after successful probes. - Save the used base addresses of the mappings in struct flashctx as well. - Do not try to (un)map the zero-sized chip definitions that are merely hacks. This also fixes the printing of wrong warnings for these chip definitions introduced in r1765. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1847 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'cli_classic.c')
-rw-r--r--cli_classic.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/cli_classic.c b/cli_classic.c
index 945ad7b..8588881 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -481,8 +481,14 @@ int main(int argc, char *argv[])
ret = 1;
goto out_shutdown;
}
+ if (map_flash(&flashes[0]) != 0) {
+ free(flashes[0].chip);
+ ret = 1;
+ goto out_shutdown;
+ }
msg_cinfo("Please note that forced reads most likely contain garbage.\n");
ret = read_flash_to_file(&flashes[0], filename);
+ unmap_flash(&flashes[0]);
free(flashes[0].chip);
goto out_shutdown;
}
@@ -525,6 +531,12 @@ int main(int argc, char *argv[])
if (write_it && !dont_verify_it)
verify_it = 1;
+ /* Map the selected flash chip again. */
+ if (map_flash(fill_flash) != 0) {
+ ret = 1;
+ goto out_shutdown;
+ }
+
/* FIXME: We should issue an unconditional chip reset here. This can be
* done once we have a .reset function in struct flashchip.
* Give the chip time to settle.
@@ -532,6 +544,7 @@ int main(int argc, char *argv[])
programmer_delay(100000);
ret |= doit(fill_flash, force, filename, read_it, write_it, erase_it, verify_it);
+ unmap_flash(fill_flash);
out_shutdown:
programmer_shutdown();
out: