[POWERPC] Provide walk_memory_resource() for powerpc

Provide walk_memory_resource() for 64-bit powerpc.  PowerPC maintains
logical memory region mapping in the lmb.memory structure.  Walk
through these structures and do the callbacks for the contiguous
chunks.

Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
Badari Pulavarty 2008-04-18 13:33:53 -07:00 committed by Paul Mackerras
parent 98d5c21c81
commit 9d88a2eb6e
3 changed files with 57 additions and 7 deletions

View file

@ -474,3 +474,36 @@ int __init lmb_is_reserved(u64 addr)
}
return 0;
}
/*
* Given a <base, len>, find which memory regions belong to this range.
* Adjust the request and return a contiguous chunk.
*/
int lmb_find(struct lmb_property *res)
{
int i;
u64 rstart, rend;
rstart = res->base;
rend = rstart + res->size - 1;
for (i = 0; i < lmb.memory.cnt; i++) {
u64 start = lmb.memory.region[i].base;
u64 end = start + lmb.memory.region[i].size - 1;
if (start > rend)
return -1;
if ((end >= rstart) && (start < rend)) {
/* adjust the request */
if (rstart < start)
rstart = start;
if (rend > end)
rend = end;
res->base = rstart;
res->size = rend - rstart + 1;
return 0;
}
}
return -1;
}