summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/memrange.h4
-rw-r--r--src/lib/memrange.c13
2 files changed, 17 insertions, 0 deletions
diff --git a/src/include/memrange.h b/src/include/memrange.h
index 0e69b2ffeb..4f094f593e 100644
--- a/src/include/memrange.h
+++ b/src/include/memrange.h
@@ -110,6 +110,10 @@ void memranges_create_hole(struct memranges *ranges,
void memranges_insert(struct memranges *ranges,
resource_t base, resource_t size, unsigned long tag);
+/* Update all entries with old_tag to new_tag. */
+void memranges_update_tag(struct memranges *ranges, unsigned long old_tag,
+ unsigned long new_tag);
+
/* Returns next entry after the provided entry. NULL if r is last. */
struct range_entry *memranges_next_entry(struct memranges *ranges,
const struct range_entry *r);
diff --git a/src/lib/memrange.c b/src/lib/memrange.c
index af56e72159..0ebac0534e 100644
--- a/src/lib/memrange.c
+++ b/src/lib/memrange.c
@@ -204,6 +204,19 @@ static void merge_add_memranges(struct memranges *ranges,
merge_neighbor_entries(ranges);
}
+void memranges_update_tag(struct memranges *ranges, unsigned long old_tag,
+ unsigned long new_tag)
+{
+ struct range_entry *r;
+
+ memranges_each_entry(r, ranges) {
+ if (range_entry_tag(r) == old_tag)
+ range_entry_update_tag(r, new_tag);
+ }
+
+ merge_neighbor_entries(ranges);
+}
+
typedef void (*range_action_t)(struct memranges *ranges,
resource_t begin, resource_t end,
unsigned long tag);