[coreboot-gerrit] Change in coreboot[master]: lib/memrange: Introduce method to clone memrange

Patrick Rudolph (Code Review) gerrit at coreboot.org
Tue Apr 10 10:25:02 CEST 2018


Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/25582


Change subject: lib/memrange: Introduce method to clone memrange
......................................................................

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 at 9elements.com>
---
M src/include/memrange.h
M src/lib/memrange.c
2 files changed, 19 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/82/25582/1

diff --git a/src/include/memrange.h b/src/include/memrange.h
index 46a992a..7f42aa2 100644
--- a/src/include/memrange.h
+++ b/src/include/memrange.h
@@ -98,6 +98,9 @@
 		    unsigned long mask, unsigned long match,
 		    unsigned long tag);
 
+/* Clone a memrange. The new memrange has the same entries as the old one. */
+void memranges_clone(struct memranges *newranges, struct memranges *oldranges);
+
 /* Remove and free all entries within the memranges structure. */
 void memranges_teardown(struct memranges *ranges);
 
diff --git a/src/lib/memrange.c b/src/lib/memrange.c
index d3cda12..96d7524 100644
--- a/src/lib/memrange.c
+++ b/src/lib/memrange.c
@@ -310,6 +310,22 @@
 	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) {

-- 
To view, visit https://review.coreboot.org/25582
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I64b27bf2611ca310385ef680f030a3e4aa0c2680
Gerrit-Change-Number: 25582
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <patrick.rudolph at 9elements.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180410/12dd1ad8/attachment.html>


More information about the coreboot-gerrit mailing list