From f6f6e13c46a4320f03fdf1286e37e05a8d047e56 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Tue, 26 Mar 2013 21:22:42 -0500 Subject: 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 Reviewed-on: http://review.coreboot.org/2924 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/include/memrange.h | 9 +++++++++ src/lib/memrange.c | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/include/memrange.h b/src/include/memrange.h index 23dae6a30a..0e69b2ffeb 100644 --- a/src/include/memrange.h +++ b/src/include/memrange.h @@ -61,6 +61,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. @@ -104,4 +110,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 c376d52816..1a16ef73ab 100644 --- a/src/lib/memrange.c +++ b/src/lib/memrange.c @@ -321,3 +321,9 @@ void memranges_fill_holes_up_to(struct memranges *ranges, /* Merge all entries that were newly added. */ merge_neighbor_entries(ranges); } + +struct range_entry *memranges_next_entry(struct memranges *ranges, + const struct range_entry *r) +{ + return r->next; +} -- cgit v1.2.3