summaryrefslogtreecommitdiffstats
path: root/src/lib/memrange.c
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2018-04-10 09:31:10 +0200
committerPatrick Georgi <pgeorgi@google.com>2018-04-11 15:11:04 +0000
commitd67a4bd5a7f2270294a83a15ba4bc58d16e67180 (patch)
tree16bd5e0352e709a30d933c5bf7cb56805502b816 /src/lib/memrange.c
parentc578efd9ca85db274403efe44f7422476541048e (diff)
downloadcoreboot-d67a4bd5a7f2270294a83a15ba4bc58d16e67180.tar.gz
coreboot-d67a4bd5a7f2270294a83a15ba4bc58d16e67180.tar.bz2
coreboot-d67a4bd5a7f2270294a83a15ba4bc58d16e67180.zip
lib/memrange: Introduce method to clone memrange
Add a new method to clone an existing memrange with all of its entries. Required for new bootmem type LB_MEM_RAM_DONT_OVERLAP. Change-Id: I64b27bf2611ca310385ef680f030a3e4aa0c2680 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/25582 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/lib/memrange.c')
-rw-r--r--src/lib/memrange.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/memrange.c b/src/lib/memrange.c
index d3cda121f1b3..96d752421850 100644
--- a/src/lib/memrange.c
+++ b/src/lib/memrange.c
@@ -310,6 +310,22 @@ void memranges_init(struct memranges *ranges,
memranges_add_resources(ranges, mask, match, tag);
}
+/* Clone a memrange. The new memrange has the same entries as the old one. */
+void memranges_clone(struct memranges *newranges, struct memranges *oldranges)
+{
+ struct range_entry *r, *cur;
+ struct range_entry **prev_ptr;
+
+ memranges_init_empty(newranges, NULL, 0);
+
+ prev_ptr = &newranges->entries;
+ memranges_each_entry(r, oldranges) {
+ cur = range_list_add(newranges, prev_ptr, r->begin, r->end,
+ r->tag);
+ prev_ptr = &cur->next;
+ }
+}
+
void memranges_teardown(struct memranges *ranges)
{
while (ranges->entries != NULL) {