aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/early_res.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2010-02-10 04:20:25 -0500
committerH. Peter Anvin <hpa@zytor.com>2010-02-12 12:42:39 -0500
commit7da657d1f1dd27fa9d8289d5f7e53479c7fd3a95 (patch)
tree1983c2f84554434eccb580fb55b59a3353bc3def /arch/x86/kernel/early_res.c
parenta678c2be75773e112f6d656a22a7f1645c4dbd6c (diff)
x86: Add find_early_area_size
Prepare to move bck find_e820_area_size back to e820.c. Signed-off-by: Yinghai Lu <yinghai@kernel.org> LKML-Reference: <1265793639-15071-22-git-send-email-yinghai@kernel.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/kernel/early_res.c')
-rw-r--r--arch/x86/kernel/early_res.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/arch/x86/kernel/early_res.c b/arch/x86/kernel/early_res.c
index 1cf2c2f9ea68..bfa1ba705d48 100644
--- a/arch/x86/kernel/early_res.c
+++ b/arch/x86/kernel/early_res.c
@@ -476,6 +476,29 @@ out:
476 return -1ULL; 476 return -1ULL;
477} 477}
478 478
479u64 __init find_early_area_size(u64 ei_start, u64 ei_last, u64 start,
480 u64 *sizep, u64 align)
481{
482 u64 addr, last;
483
484 addr = round_up(ei_start, align);
485 if (addr < start)
486 addr = round_up(start, align);
487 if (addr >= ei_last)
488 goto out;
489 *sizep = ei_last - addr;
490 while (bad_addr_size(&addr, sizep, align) && addr + *sizep <= ei_last)
491 ;
492 last = addr + *sizep;
493 if (last > ei_last)
494 goto out;
495
496 return addr;
497
498out:
499 return -1ULL;
500}
501
479/* 502/*
480 * Find a free area with specified alignment in a specific range. 503 * Find a free area with specified alignment in a specific range.
481 */ 504 */
@@ -513,24 +536,20 @@ u64 __init find_e820_area_size(u64 start, u64 *sizep, u64 align)
513 536
514 for (i = 0; i < e820.nr_map; i++) { 537 for (i = 0; i < e820.nr_map; i++) {
515 struct e820entry *ei = &e820.map[i]; 538 struct e820entry *ei = &e820.map[i];
516 u64 addr, last; 539 u64 addr;
517 u64 ei_last; 540 u64 ei_start, ei_last;
518 541
519 if (ei->type != E820_RAM) 542 if (ei->type != E820_RAM)
520 continue; 543 continue;
521 addr = round_up(ei->addr, align); 544
522 ei_last = ei->addr + ei->size; 545 ei_last = ei->addr + ei->size;
523 if (addr < start) 546 ei_start = ei->addr;
524 addr = round_up(start, align); 547 addr = find_early_area_size(ei_start, ei_last, start,
525 if (addr >= ei_last) 548 sizep, align);
526 continue; 549
527 *sizep = ei_last - addr; 550 if (addr == -1ULL)
528 while (bad_addr_size(&addr, sizep, align) &&
529 addr + *sizep <= ei_last)
530 ;
531 last = addr + *sizep;
532 if (last > ei_last)
533 continue; 551 continue;
552
534 return addr; 553 return addr;
535 } 554 }
536 555