summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2016-01-15 21:59:37 -0600
committerAaron Durbin <adurbin@chromium.org>2016-01-23 18:25:26 +0100
commit1b915b89044c06ae7957544b97d6c30d496366e0 (patch)
tree5472249fc7700bd592c3d7d725ddef587e28aa13 /src/include
parent4a30ab90965ac68de723383897d38e5b59f558cd (diff)
lib/memrange: allow stack allocated free list
Instead of solely relying on malloc for building up an address space for the range_entry objects allow one to supply a list of free entries to memranges_init_empty(). Doing this and only calling malloc() in ramstage allows a memranges oboject to be used in a malloc()-free environment. Change-Id: I96c0f744fc04031a7ec228620a690b20bad36804 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/13020 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Martin Roth <martinroth@google.com> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/include')
-rw-r--r--src/include/memrange.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/include/memrange.h b/src/include/memrange.h
index 9e8c70457a..a4f7742c5b 100644
--- a/src/include/memrange.h
+++ b/src/include/memrange.h
@@ -21,6 +21,9 @@
* is exposed so that a memranges can be used on the stack if needed. */
struct memranges {
struct range_entry *entries;
+ /* Coreboot doesn't have a free() function. Therefore, keep a cache of
+ * free'd entries. */
+ struct range_entry *free_list;
};
/* Each region within a memranges structure is represented by a
@@ -71,8 +74,10 @@ static inline void range_entry_update_tag(struct range_entry *r,
#define memranges_each_entry(r, ranges) \
for (r = (ranges)->entries; r != NULL; r = r->next)
-/* Initialize memranges structure */
-void memranges_init_empty(struct memranges *ranges);
+/* Initialize memranges structure providing an optional array of range_entry
+ * to use as the free list. */
+void memranges_init_empty(struct memranges *ranges, struct range_entry *free,
+ size_t num_free);
/* Initialize and fill a memranges structure according to the
* mask and match type for all memory resources. Tag each entry with the