[Pkg-electronics-commits] [openocd] 01/19: Revert "target: remove unused working area 'user' field"
Jonathan McDowell
noodles at moszumanska.debian.org
Tue Oct 31 21:15:13 UTC 2017
This is an automated email from the git hooks/post-receive script.
noodles pushed a commit to annotated tag v0.6.1
in repository openocd.
commit f254667a13872ffd8a5a8a238c8963abc004e13d
Author: Freddie Chopin <freddie.chopin at gmail.com>
Date: Tue Oct 2 08:59:47 2012 +0200
Revert "target: remove unused working area 'user' field"
This reverts commit 63a23e6fc862b94f00e0833ab474bd02901a019f, which
causes problems with various flash drivers (i.e. LPC1xxx/LPC2xxx)
due to working area handling.
Change-Id: I291ff2ac4f1eef7ecd553d0eb8895b790beb38c3
Signed-off-by: Freddie Chopin <freddie.chopin at gmail.com>
Reviewed-on: http://openocd.zylin.com/872
Reviewed-by: Øyvind Harboe <oyvindharboe at gmail.com>
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen at spen-soft.co.uk>
---
src/target/target.c | 14 ++++++++++++++
src/target/target.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/src/target/target.c b/src/target/target.c
index c71c536..b8e4c2f 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1405,6 +1405,7 @@ static void target_split_working_area(struct working_area *area, uint32_t size)
new_wa->size = area->size - size;
new_wa->address = area->address + size;
new_wa->backup = NULL;
+ new_wa->user = NULL;
new_wa->free = true;
area->next = new_wa;
@@ -1493,6 +1494,7 @@ int target_alloc_working_area_try(struct target *target, uint32_t size, struct w
new_wa->size = target->working_area_size & ~3UL; /* 4-byte align */
new_wa->address = target->working_area;
new_wa->backup = NULL;
+ new_wa->user = NULL;
new_wa->free = true;
}
@@ -1536,6 +1538,9 @@ int target_alloc_working_area_try(struct target *target, uint32_t size, struct w
c->free = false;
*area = c;
+ /* user pointer */
+ c->user = area;
+
print_wa_layout(target);
return ERROR_OK;
@@ -1586,6 +1591,13 @@ static int target_free_working_area_restore(struct target *target, struct workin
LOG_DEBUG("freed %"PRIu32" bytes of working area at address 0x%08"PRIx32,
area->size, area->address);
+ /* mark user pointer invalid */
+ /* TODO: Is this really safe? It points to some previous caller's memory.
+ * How could we know that the area pointer is still in that place and not
+ * some other vital data? What's the purpose of this, anyway? */
+ *area->user = NULL;
+ area->user = NULL;
+
target_merge_working_areas(target);
print_wa_layout(target);
@@ -1613,6 +1625,8 @@ static void target_free_all_working_areas_restore(struct target *target, int res
if (restore)
target_restore_working_area(target, c);
c->free = true;
+ *c->user = NULL; /* Same as above */
+ c->user = NULL;
}
c = c->next;
}
diff --git a/src/target/target.h b/src/target/target.h
index a610cd0..9707bcc 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -95,6 +95,7 @@ struct working_area {
uint32_t size;
bool free;
uint8_t *backup;
+ struct working_area **user;
struct working_area *next;
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-electronics/openocd.git
More information about the Pkg-electronics-commits
mailing list