coreboot memrange: Changes to memrange lib

1) Add check for zero size in memrange.
2) Add public memrange_init_empty function to allow initializing only the
memrange structure without filling in device resources

BUG=None
BRANCH=None
TEST=Compiles and runs succesfully for rush MMU memranges.

Change-Id: I8e4d864cbc9a770cd208f8a9f83f509dc7ace894
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/208957
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
Furquan Shaikh 2014-07-18 10:25:54 -07:00 committed by chrome-internal-fetch
commit 5c42301c2a
2 changed files with 12 additions and 1 deletions

View file

@ -75,6 +75,9 @@ 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 and fill a memranges structure according to the
* mask and match type for all memory resources. Tag each entry with the
* specified type. */

View file

@ -215,6 +215,9 @@ static void do_action(struct memranges *ranges,
resource_t end;
resource_t begin;
if (size == 0)
return;
/* The addresses are aligned to 4096 bytes: the begin address is
* aligned down while the end address is aligned up to be conservative
* about the full range covered. */
@ -263,11 +266,16 @@ void memranges_add_resources(struct memranges *ranges,
search_global_resources(mask, match, collect_ranges, &context);
}
void memranges_init_empty(struct memranges *ranges)
{
ranges->entries = NULL;
}
void memranges_init(struct memranges *ranges,
unsigned long mask, unsigned long match,
unsigned long tag)
{
ranges->entries = NULL;
memranges_init_empty(ranges);
memranges_add_resources(ranges, mask, match, tag);
}