diff options
| author | Badari Pulavarty <pbadari@us.ibm.com> | 2008-04-18 16:33:53 -0400 |
|---|---|---|
| committer | Paul Mackerras <paulus@samba.org> | 2008-04-29 01:57:53 -0400 |
| commit | 9d88a2eb6e05c07aa0d484b8fa1372722fa921d0 (patch) | |
| tree | 782b288099fbd96ed779c033f2c1322ff1822950 /lib | |
| parent | 98d5c21c812e4e3b795f5bd912f407ed7c5e4e38 (diff) | |
[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')
| -rw-r--r-- | lib/lmb.c | 33 |
1 files changed, 33 insertions, 0 deletions
| @@ -474,3 +474,36 @@ int __init lmb_is_reserved(u64 addr) | |||
| 474 | } | 474 | } |
| 475 | return 0; | 475 | return 0; |
| 476 | } | 476 | } |
| 477 | |||
| 478 | /* | ||
| 479 | * Given a <base, len>, find which memory regions belong to this range. | ||
| 480 | * Adjust the request and return a contiguous chunk. | ||
| 481 | */ | ||
| 482 | int lmb_find(struct lmb_property *res) | ||
| 483 | { | ||
| 484 | int i; | ||
| 485 | u64 rstart, rend; | ||
| 486 | |||
| 487 | rstart = res->base; | ||
| 488 | rend = rstart + res->size - 1; | ||
| 489 | |||
| 490 | for (i = 0; i < lmb.memory.cnt; i++) { | ||
| 491 | u64 start = lmb.memory.region[i].base; | ||
| 492 | u64 end = start + lmb.memory.region[i].size - 1; | ||
| 493 | |||
| 494 | if (start > rend) | ||
| 495 | return -1; | ||
| 496 | |||
| 497 | if ((end >= rstart) && (start < rend)) { | ||
| 498 | /* adjust the request */ | ||
| 499 | if (rstart < start) | ||
| 500 | rstart = start; | ||
| 501 | if (rend > end) | ||
| 502 | rend = end; | ||
| 503 | res->base = rstart; | ||
| 504 | res->size = rend - rstart + 1; | ||
| 505 | return 0; | ||
| 506 | } | ||
| 507 | } | ||
| 508 | return -1; | ||
| 509 | } | ||
