summaryrefslogtreecommitdiffstats
path: root/lib/lmb.c
diff options
context:
space:
mode:
authorBadari Pulavarty <pbadari@us.ibm.com>2008-04-18 13:33:53 -0700
committerPaul Mackerras <paulus@samba.org>2008-04-29 15:57:53 +1000
commit9d88a2eb6e05c07aa0d484b8fa1372722fa921d0 (patch)
tree782b288099fbd96ed779c033f2c1322ff1822950 /lib/lmb.c
parent98d5c21c812e4e3b795f5bd912f407ed7c5e4e38 (diff)
downloadlinux-9d88a2eb6e05c07aa0d484b8fa1372722fa921d0.tar.bz2
[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>
Diffstat (limited to 'lib/lmb.c')
-rw-r--r--lib/lmb.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/lmb.c b/lib/lmb.c
index 5b2a739bc3d5..83287d3869a3 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -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;
+}