This is an automated email from Gerrit. Andreas Fritiofson ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/446
-- gerrit commit 177f33e0ba4576ec796f6f7f4c1be8ad338f48e0 Author: Andreas Fritiofson <[email protected]> Date: Mon Feb 13 01:19:57 2012 +0100 target: add function to get number of bytes available in working area This is a much cleaner solution to the problem of allocating as much working area as possible than what is currently being done in most/all flash drivers (which is: try an arbitrary sized chunk, if it fails, pick a smaller number, rinse and repeat). Use this function to find out how much working area is available, limit or restrict that amount at will and then simply allocate it. Change-Id: Ib7d5d0b7485aed3e0a4fad60c1bedb7dfd16146f Signed-off-by: Andreas Fritiofson <[email protected]> diff --git a/src/target/target.c b/src/target/target.c index 6ed859b..d275374 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1500,6 +1500,25 @@ void target_free_all_working_areas(struct target *target) target_free_all_working_areas_restore(target, 1); } +/* Find the largest number of bytes that can be allocated */ +uint32_t target_get_working_area_avail(struct target *target) +{ + struct working_area *c = target->working_areas; + uint32_t max_size = 0; + + if (c == NULL) + return target->working_area_size; + + while (c) { + if (c->free && max_size < c->size) + max_size = c->size; + + c = c->next; + } + + return max_size; +} + int target_arch_state(struct target *target) { int retval; diff --git a/src/target/target.h b/src/target/target.h index 680f8c3..a5ab3bd 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -540,6 +540,7 @@ int target_alloc_working_area_try(struct target *target, uint32_t size, struct working_area **area); int target_free_working_area(struct target *target, struct working_area *area); void target_free_all_working_areas(struct target *target); +uint32_t target_get_working_area_avail(struct target *target); extern struct target *all_targets; -- ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
