[coreboot-gerrit] New patch to review for coreboot: 94d01fb memrange: add 2 new range_entry routines

Aaron Durbin (adurbin@google.com) gerrit at coreboot.org
Wed Mar 27 04:36:55 CET 2013


Aaron Durbin (adurbin at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2924

-gerrit

commit 94d01fbc0b590385f793bfcfb80098515aaef597
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Tue Mar 26 21:22:42 2013 -0500

    memrange: add 2 new range_entry routines
    
    Two convenience functions are added to operate on a range_entry:
    - range_entry_update_tag() - update the entry's tag
    - memranges_next_entry() - get the next entry after the one provide
    
    These functions will be used by a follow on patch to the MTRR code
    to allow hole punching in WB region when the default MTRR type is
    UC.
    
    Change-Id: I3c2be19c8ea1bbbdf7736c867e4a2aa82df2d611
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 src/include/memrange.h |  9 +++++++++
 src/lib/memrange.c     | 10 ++++++++++
 2 files changed, 19 insertions(+)

diff --git a/src/include/memrange.h b/src/include/memrange.h
index 222ce3c..5e14f75 100644
--- a/src/include/memrange.h
+++ b/src/include/memrange.h
@@ -62,6 +62,12 @@ static inline unsigned long range_entry_tag(const struct range_entry *r)
 	return r->tag;
 }
 
+static inline void range_entry_update_tag(struct range_entry *r,
+                                          unsigned long new_tag)
+{
+	r->tag = new_tag;
+}
+
 /* Iterate over each entry in a memranges structure. Ranges cannot
  * be deleted while processing each entry as the list cannot be safely
  * traversed after such an operation.
@@ -105,4 +111,7 @@ void memranges_create_hole(struct memranges *ranges,
 void memranges_insert(struct memranges *ranges,
                       resource_t base, resource_t size, unsigned long 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);
 #endif /* MEMRANGE_H_ */
diff --git a/src/lib/memrange.c b/src/lib/memrange.c
index 57637ba..5bc7755 100644
--- a/src/lib/memrange.c
+++ b/src/lib/memrange.c
@@ -304,3 +304,13 @@ void memranges_fill_holes_up_to(struct memranges *ranges,
 	/* Merge all entries that were newly added. */
 	merge_neighbor_entries(ranges);
 }
+
+/* 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)
+{
+	if (list_is_last(&r->siblings, &ranges->list))
+		return NULL;
+
+	return list_first_entry(&r->siblings, struct range_entry, siblings);
+}



More information about the coreboot-gerrit mailing list