diff options
Diffstat (limited to 'arch/x86/kernel/e820.c')
-rw-r--r-- | arch/x86/kernel/e820.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 3900ff51bc68..22cfd665224c 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c | |||
@@ -488,26 +488,22 @@ void __init update_e820(void) | |||
488 | } | 488 | } |
489 | 489 | ||
490 | /* | 490 | /* |
491 | * Search for the biggest gap in the low 32 bits of the e820 | 491 | * Search for a gap in the e820 memory space from start_addr to 2^32. |
492 | * memory space. We pass this space to PCI to assign MMIO resources | ||
493 | * for hotplug or unconfigured devices in. | ||
494 | * Hopefully the BIOS let enough space left. | ||
495 | */ | 492 | */ |
496 | __init void e820_setup_gap(void) | 493 | __init int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize, |
494 | unsigned long start_addr) | ||
497 | { | 495 | { |
498 | unsigned long gapstart, gapsize, round; | 496 | unsigned long long last = 0x100000000ull; |
499 | unsigned long long last; | 497 | int i = e820.nr_map; |
500 | int i; | ||
501 | int found = 0; | 498 | int found = 0; |
502 | 499 | ||
503 | last = 0x100000000ull; | ||
504 | gapstart = 0x10000000; | ||
505 | gapsize = 0x400000; | ||
506 | i = e820.nr_map; | ||
507 | while (--i >= 0) { | 500 | while (--i >= 0) { |
508 | unsigned long long start = e820.map[i].addr; | 501 | unsigned long long start = e820.map[i].addr; |
509 | unsigned long long end = start + e820.map[i].size; | 502 | unsigned long long end = start + e820.map[i].size; |
510 | 503 | ||
504 | if (end < start_addr) | ||
505 | continue; | ||
506 | |||
511 | /* | 507 | /* |
512 | * Since "last" is at most 4GB, we know we'll | 508 | * Since "last" is at most 4GB, we know we'll |
513 | * fit in 32 bits if this condition is true | 509 | * fit in 32 bits if this condition is true |
@@ -515,15 +511,32 @@ __init void e820_setup_gap(void) | |||
515 | if (last > end) { | 511 | if (last > end) { |
516 | unsigned long gap = last - end; | 512 | unsigned long gap = last - end; |
517 | 513 | ||
518 | if (gap > gapsize) { | 514 | if (gap >= *gapsize) { |
519 | gapsize = gap; | 515 | *gapsize = gap; |
520 | gapstart = end; | 516 | *gapstart = end; |
521 | found = 1; | 517 | found = 1; |
522 | } | 518 | } |
523 | } | 519 | } |
524 | if (start < last) | 520 | if (start < last) |
525 | last = start; | 521 | last = start; |
526 | } | 522 | } |
523 | return found; | ||
524 | } | ||
525 | |||
526 | /* | ||
527 | * Search for the biggest gap in the low 32 bits of the e820 | ||
528 | * memory space. We pass this space to PCI to assign MMIO resources | ||
529 | * for hotplug or unconfigured devices in. | ||
530 | * Hopefully the BIOS let enough space left. | ||
531 | */ | ||
532 | __init void e820_setup_gap(void) | ||
533 | { | ||
534 | unsigned long gapstart, gapsize, round; | ||
535 | int found; | ||
536 | |||
537 | gapstart = 0x10000000; | ||
538 | gapsize = 0x400000; | ||
539 | found = e820_search_gap(&gapstart, &gapsize, 0); | ||
527 | 540 | ||
528 | #ifdef CONFIG_X86_64 | 541 | #ifdef CONFIG_X86_64 |
529 | if (!found) { | 542 | if (!found) { |