aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vanek <vanekt@fbl.cz>2018-12-07 18:34:39 +0100
committerTomas Vanek <vanekt@fbl.cz>2018-12-19 13:16:03 +0000
commit71eeda5da1f840a19e1a0ac97fceda8b8457ba1e (patch)
tree787d0b18171e681a461537c998ac18b073870a5f
parent936dc7cbd93492c1df567c0727bee251427ac270 (diff)
target: move all working_area functions to one block
The block of code moved without any changes Change-Id: I70b82dc3315dcc3f34de0537b362bee230007d02 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4796 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
-rw-r--r--src/target/target.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 74b332df..3d33a43d 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1919,6 +1919,57 @@ int target_free_working_area(struct target *target, struct working_area *area)
return target_free_working_area_restore(target, area, 1);
}
+/* free resources and restore memory, if restoring memory fails,
+ * free up resources anyway
+ */
+static void target_free_all_working_areas_restore(struct target *target, int restore)
+{
+ struct working_area *c = target->working_areas;
+
+ LOG_DEBUG("freeing all working areas");
+
+ /* Loop through all areas, restoring the allocated ones and marking them as free */
+ while (c) {
+ if (!c->free) {
+ if (restore)
+ target_restore_working_area(target, c);
+ c->free = true;
+ *c->user = NULL; /* Same as above */
+ c->user = NULL;
+ }
+ c = c->next;
+ }
+
+ /* Run a merge pass to combine all areas into one */
+ target_merge_working_areas(target);
+
+ print_wa_layout(target);
+}
+
+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;
+}
+
static void target_destroy(struct target *target)
{
if (target->type->deinit_target)
@@ -1993,57 +2044,6 @@ void target_quit(void)
all_targets = NULL;
}
-/* free resources and restore memory, if restoring memory fails,
- * free up resources anyway
- */
-static void target_free_all_working_areas_restore(struct target *target, int restore)
-{
- struct working_area *c = target->working_areas;
-
- LOG_DEBUG("freeing all working areas");
-
- /* Loop through all areas, restoring the allocated ones and marking them as free */
- while (c) {
- if (!c->free) {
- if (restore)
- target_restore_working_area(target, c);
- c->free = true;
- *c->user = NULL; /* Same as above */
- c->user = NULL;
- }
- c = c->next;
- }
-
- /* Run a merge pass to combine all areas into one */
- target_merge_working_areas(target);
-
- print_wa_layout(target);
-}
-
-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;