2 * Handle the memory map.
3 * The functions here do the job until bootmem takes over.
5 * Getting sanitize_e820_map() in sync with i386 version by applying change:
6 * - Provisions for empty E820 memory regions (reported by certain BIOSes).
7 * Alex Achenbach <xela@slit.de>, December 2002.
8 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
11 #include <linux/kernel.h>
12 #include <linux/types.h>
13 #include <linux/init.h>
14 #include <linux/bootmem.h>
15 #include <linux/ioport.h>
16 #include <linux/string.h>
17 #include <linux/kexec.h>
18 #include <linux/module.h>
20 #include <linux/suspend.h>
21 #include <linux/pfn.h>
23 #include <asm/pgtable.h>
26 #include <asm/proto.h>
27 #include <asm/setup.h>
28 #include <asm/sections.h>
29 #include <asm/kdebug.h>
30 #include <asm/trampoline.h>
35 * PFN of last memory page.
37 unsigned long end_pfn
;
40 * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries.
41 * The direct mapping extends to max_pfn_mapped, so that we can directly access
42 * apertures, ACPI and other tables without having to play with fixmaps.
44 unsigned long max_pfn_mapped
;
47 * Last pfn which the user wants to use.
49 static unsigned long __initdata end_user_pfn
= MAXMEM
>>PAGE_SHIFT
;
52 * Early reserved memory areas.
54 #define MAX_EARLY_RES 20
57 unsigned long start
, end
;
60 static struct early_res early_res
[MAX_EARLY_RES
] __initdata
= {
61 { 0, PAGE_SIZE
, "BIOS data page" }, /* BIOS data page */
62 #ifdef CONFIG_X86_TRAMPOLINE
63 { TRAMPOLINE_BASE
, TRAMPOLINE_BASE
+ 2 * PAGE_SIZE
, "TRAMPOLINE" },
68 void __init
reserve_early(unsigned long start
, unsigned long end
, char *name
)
72 for (i
= 0; i
< MAX_EARLY_RES
&& early_res
[i
].end
; i
++) {
74 if (end
> r
->start
&& start
< r
->end
)
75 panic("Overlapping early reservations %lx-%lx %s to %lx-%lx %s\n",
76 start
, end
- 1, name
?name
:"", r
->start
, r
->end
- 1, r
->name
);
78 if (i
>= MAX_EARLY_RES
)
79 panic("Too many early reservations");
84 strncpy(r
->name
, name
, sizeof(r
->name
) - 1);
87 void __init
early_res_to_bootmem(void)
90 for (i
= 0; i
< MAX_EARLY_RES
&& early_res
[i
].end
; i
++) {
91 struct early_res
*r
= &early_res
[i
];
92 printk(KERN_INFO
"early res: %d [%lx-%lx] %s\n", i
,
93 r
->start
, r
->end
- 1, r
->name
);
94 reserve_bootmem_generic(r
->start
, r
->end
- r
->start
);
98 /* Check for already reserved areas */
99 static inline int __init
100 bad_addr(unsigned long *addrp
, unsigned long size
, unsigned long align
)
103 unsigned long addr
= *addrp
, last
;
107 for (i
= 0; i
< MAX_EARLY_RES
&& early_res
[i
].end
; i
++) {
108 struct early_res
*r
= &early_res
[i
];
109 if (last
>= r
->start
&& addr
< r
->end
) {
110 *addrp
= addr
= round_up(r
->end
, align
);
118 /* Check for already reserved areas */
119 static inline int __init
120 bad_addr_size(unsigned long *addrp
, unsigned long *sizep
, unsigned long align
)
123 unsigned long addr
= *addrp
, last
;
124 unsigned long size
= *sizep
;
128 for (i
= 0; i
< MAX_EARLY_RES
&& early_res
[i
].end
; i
++) {
129 struct early_res
*r
= &early_res
[i
];
130 if (last
> r
->start
&& addr
< r
->start
) {
131 size
= r
->start
- addr
;
135 if (last
> r
->end
&& addr
< r
->end
) {
136 addr
= round_up(r
->end
, align
);
141 if (last
<= r
->end
&& addr
>= r
->start
) {
153 * This function checks if any part of the range <start,end> is mapped
157 e820_any_mapped(unsigned long start
, unsigned long end
, unsigned type
)
161 for (i
= 0; i
< e820
.nr_map
; i
++) {
162 struct e820entry
*ei
= &e820
.map
[i
];
164 if (type
&& ei
->type
!= type
)
166 if (ei
->addr
>= end
|| ei
->addr
+ ei
->size
<= start
)
172 EXPORT_SYMBOL_GPL(e820_any_mapped
);
175 * This function checks if the entire range <start,end> is mapped with type.
177 * Note: this function only works correct if the e820 table is sorted and
178 * not-overlapping, which is the case
180 int __init
e820_all_mapped(unsigned long start
, unsigned long end
,
185 for (i
= 0; i
< e820
.nr_map
; i
++) {
186 struct e820entry
*ei
= &e820
.map
[i
];
188 if (type
&& ei
->type
!= type
)
190 /* is the region (part) in overlap with the current region ?*/
191 if (ei
->addr
>= end
|| ei
->addr
+ ei
->size
<= start
)
194 /* if the region is at the beginning of <start,end> we move
195 * start to the end of the region since it's ok until there
197 if (ei
->addr
<= start
)
198 start
= ei
->addr
+ ei
->size
;
200 * if start is now at or beyond end, we're done, full
210 * Find a free area with specified alignment in a specific range.
212 unsigned long __init
find_e820_area(unsigned long start
, unsigned long end
,
213 unsigned long size
, unsigned long align
)
217 for (i
= 0; i
< e820
.nr_map
; i
++) {
218 struct e820entry
*ei
= &e820
.map
[i
];
219 unsigned long addr
, last
;
220 unsigned long ei_last
;
222 if (ei
->type
!= E820_RAM
)
224 addr
= round_up(ei
->addr
, align
);
225 ei_last
= ei
->addr
+ ei
->size
;
227 addr
= round_up(start
, align
);
230 while (bad_addr(&addr
, size
, align
) && addr
+size
<= ei_last
)
243 * Find next free range after *start
245 unsigned long __init
find_e820_area_size(unsigned long start
,
246 unsigned long *sizep
,
251 for (i
= 0; i
< e820
.nr_map
; i
++) {
252 struct e820entry
*ei
= &e820
.map
[i
];
253 unsigned long addr
, last
;
254 unsigned long ei_last
;
256 if (ei
->type
!= E820_RAM
)
258 addr
= round_up(ei
->addr
, align
);
259 ei_last
= ei
->addr
+ ei
->size
;
261 addr
= round_up(start
, align
);
264 *sizep
= ei_last
- addr
;
265 while (bad_addr_size(&addr
, sizep
, align
) &&
266 addr
+ *sizep
<= ei_last
)
268 last
= addr
+ *sizep
;
277 * Find the highest page frame number we have available
279 unsigned long __init
e820_end_of_ram(void)
281 unsigned long end_pfn
;
283 end_pfn
= find_max_pfn_with_active_regions();
285 if (end_pfn
> max_pfn_mapped
)
286 max_pfn_mapped
= end_pfn
;
287 if (max_pfn_mapped
> MAXMEM
>>PAGE_SHIFT
)
288 max_pfn_mapped
= MAXMEM
>>PAGE_SHIFT
;
289 if (end_pfn
> end_user_pfn
)
290 end_pfn
= end_user_pfn
;
291 if (end_pfn
> max_pfn_mapped
)
292 end_pfn
= max_pfn_mapped
;
294 printk(KERN_INFO
"max_pfn_mapped = %lu\n", max_pfn_mapped
);
299 * Mark e820 reserved areas as busy for the resource manager.
301 void __init
e820_reserve_resources(void)
304 struct resource
*res
;
306 res
= alloc_bootmem_low(sizeof(struct resource
) * e820
.nr_map
);
307 for (i
= 0; i
< e820
.nr_map
; i
++) {
308 switch (e820
.map
[i
].type
) {
309 case E820_RAM
: res
->name
= "System RAM"; break;
310 case E820_ACPI
: res
->name
= "ACPI Tables"; break;
311 case E820_NVS
: res
->name
= "ACPI Non-volatile Storage"; break;
312 default: res
->name
= "reserved";
314 res
->start
= e820
.map
[i
].addr
;
315 res
->end
= res
->start
+ e820
.map
[i
].size
- 1;
316 res
->flags
= IORESOURCE_MEM
| IORESOURCE_BUSY
;
317 insert_resource(&iomem_resource
, res
);
323 * Find the ranges of physical addresses that do not correspond to
324 * e820 RAM areas and mark the corresponding pages as nosave for software
325 * suspend and suspend to RAM.
327 * This function requires the e820 map to be sorted and without any
328 * overlapping entries and assumes the first e820 area to be RAM.
330 void __init
e820_mark_nosave_regions(void)
335 paddr
= round_down(e820
.map
[0].addr
+ e820
.map
[0].size
, PAGE_SIZE
);
336 for (i
= 1; i
< e820
.nr_map
; i
++) {
337 struct e820entry
*ei
= &e820
.map
[i
];
339 if (paddr
< ei
->addr
)
340 register_nosave_region(PFN_DOWN(paddr
),
343 paddr
= round_down(ei
->addr
+ ei
->size
, PAGE_SIZE
);
344 if (ei
->type
!= E820_RAM
)
345 register_nosave_region(PFN_UP(ei
->addr
),
348 if (paddr
>= (end_pfn
<< PAGE_SHIFT
))
354 * Finds an active region in the address range from start_pfn to end_pfn and
355 * returns its range in ei_startpfn and ei_endpfn for the e820 entry.
357 static int __init
e820_find_active_region(const struct e820entry
*ei
,
358 unsigned long start_pfn
,
359 unsigned long end_pfn
,
360 unsigned long *ei_startpfn
,
361 unsigned long *ei_endpfn
)
363 *ei_startpfn
= round_up(ei
->addr
, PAGE_SIZE
) >> PAGE_SHIFT
;
364 *ei_endpfn
= round_down(ei
->addr
+ ei
->size
, PAGE_SIZE
) >> PAGE_SHIFT
;
366 /* Skip map entries smaller than a page */
367 if (*ei_startpfn
>= *ei_endpfn
)
370 /* Check if max_pfn_mapped should be updated */
371 if (ei
->type
!= E820_RAM
&& *ei_endpfn
> max_pfn_mapped
)
372 max_pfn_mapped
= *ei_endpfn
;
374 /* Skip if map is outside the node */
375 if (ei
->type
!= E820_RAM
|| *ei_endpfn
<= start_pfn
||
376 *ei_startpfn
>= end_pfn
)
379 /* Check for overlaps */
380 if (*ei_startpfn
< start_pfn
)
381 *ei_startpfn
= start_pfn
;
382 if (*ei_endpfn
> end_pfn
)
383 *ei_endpfn
= end_pfn
;
385 /* Obey end_user_pfn to save on memmap */
386 if (*ei_startpfn
>= end_user_pfn
)
388 if (*ei_endpfn
> end_user_pfn
)
389 *ei_endpfn
= end_user_pfn
;
394 /* Walk the e820 map and register active regions within a node */
396 e820_register_active_regions(int nid
, unsigned long start_pfn
,
397 unsigned long end_pfn
)
399 unsigned long ei_startpfn
;
400 unsigned long ei_endpfn
;
403 for (i
= 0; i
< e820
.nr_map
; i
++)
404 if (e820_find_active_region(&e820
.map
[i
],
406 &ei_startpfn
, &ei_endpfn
))
407 add_active_range(nid
, ei_startpfn
, ei_endpfn
);
411 * Add a memory region to the kernel e820 map.
413 void __init
add_memory_region(unsigned long start
, unsigned long size
, int type
)
418 printk(KERN_ERR
"Ooops! Too many entries in the memory map!\n");
422 e820
.map
[x
].addr
= start
;
423 e820
.map
[x
].size
= size
;
424 e820
.map
[x
].type
= type
;
429 * Find the hole size (in bytes) in the memory range.
430 * @start: starting address of the memory range to scan
431 * @end: ending address of the memory range to scan
433 unsigned long __init
e820_hole_size(unsigned long start
, unsigned long end
)
435 unsigned long start_pfn
= start
>> PAGE_SHIFT
;
436 unsigned long end_pfn
= end
>> PAGE_SHIFT
;
437 unsigned long ei_startpfn
, ei_endpfn
, ram
= 0;
440 for (i
= 0; i
< e820
.nr_map
; i
++) {
441 if (e820_find_active_region(&e820
.map
[i
],
443 &ei_startpfn
, &ei_endpfn
))
444 ram
+= ei_endpfn
- ei_startpfn
;
446 return end
- start
- (ram
<< PAGE_SHIFT
);
449 static void __init
e820_print_map(char *who
)
453 for (i
= 0; i
< e820
.nr_map
; i
++) {
454 printk(KERN_INFO
" %s: %016Lx - %016Lx ", who
,
455 (unsigned long long) e820
.map
[i
].addr
,
457 (e820
.map
[i
].addr
+ e820
.map
[i
].size
));
458 switch (e820
.map
[i
].type
) {
460 printk(KERN_CONT
"(usable)\n");
463 printk(KERN_CONT
"(reserved)\n");
466 printk(KERN_CONT
"(ACPI data)\n");
469 printk(KERN_CONT
"(ACPI NVS)\n");
472 printk(KERN_CONT
"type %u\n", e820
.map
[i
].type
);
479 * Sanitize the BIOS e820 map.
481 * Some e820 responses include overlapping entries. The following
482 * replaces the original e820 map with a new one, removing overlaps.
485 static int __init
sanitize_e820_map(struct e820entry
*biosmap
, char *pnr_map
)
487 struct change_member
{
488 struct e820entry
*pbios
; /* pointer to original bios entry */
489 unsigned long long addr
; /* address for this change point */
491 static struct change_member change_point_list
[2*E820MAX
] __initdata
;
492 static struct change_member
*change_point
[2*E820MAX
] __initdata
;
493 static struct e820entry
*overlap_list
[E820MAX
] __initdata
;
494 static struct e820entry new_bios
[E820MAX
] __initdata
;
495 struct change_member
*change_tmp
;
496 unsigned long current_type
, last_type
;
497 unsigned long long last_addr
;
498 int chgidx
, still_changing
;
501 int old_nr
, new_nr
, chg_nr
;
505 Visually we're performing the following
506 (1,2,3,4 = memory types)...
508 Sample memory map (w/overlaps):
509 ____22__________________
510 ______________________4_
511 ____1111________________
512 _44_____________________
513 11111111________________
514 ____________________33__
515 ___________44___________
516 __________33333_________
517 ______________22________
518 ___________________2222_
519 _________111111111______
520 _____________________11_
521 _________________4______
523 Sanitized equivalent (no overlap):
524 1_______________________
525 _44_____________________
526 ___1____________________
527 ____22__________________
528 ______11________________
529 _________1______________
530 __________3_____________
531 ___________44___________
532 _____________33_________
533 _______________2________
534 ________________1_______
535 _________________4______
536 ___________________2____
537 ____________________33__
538 ______________________4_
541 /* if there's only one memory region, don't bother */
547 /* bail out if we find any unreasonable addresses in bios map */
548 for (i
= 0; i
< old_nr
; i
++)
549 if (biosmap
[i
].addr
+ biosmap
[i
].size
< biosmap
[i
].addr
)
552 /* create pointers for initial change-point information (for sorting) */
553 for (i
= 0; i
< 2 * old_nr
; i
++)
554 change_point
[i
] = &change_point_list
[i
];
556 /* record all known change-points (starting and ending addresses),
557 omitting those that are for empty memory regions */
559 for (i
= 0; i
< old_nr
; i
++) {
560 if (biosmap
[i
].size
!= 0) {
561 change_point
[chgidx
]->addr
= biosmap
[i
].addr
;
562 change_point
[chgidx
++]->pbios
= &biosmap
[i
];
563 change_point
[chgidx
]->addr
= biosmap
[i
].addr
+
565 change_point
[chgidx
++]->pbios
= &biosmap
[i
];
570 /* sort change-point list by memory addresses (low -> high) */
572 while (still_changing
) {
574 for (i
= 1; i
< chg_nr
; i
++) {
575 unsigned long long curaddr
, lastaddr
;
576 unsigned long long curpbaddr
, lastpbaddr
;
578 curaddr
= change_point
[i
]->addr
;
579 lastaddr
= change_point
[i
- 1]->addr
;
580 curpbaddr
= change_point
[i
]->pbios
->addr
;
581 lastpbaddr
= change_point
[i
- 1]->pbios
->addr
;
584 * swap entries, when:
586 * curaddr > lastaddr or
587 * curaddr == lastaddr and curaddr == curpbaddr and
588 * lastaddr != lastpbaddr
590 if (curaddr
< lastaddr
||
591 (curaddr
== lastaddr
&& curaddr
== curpbaddr
&&
592 lastaddr
!= lastpbaddr
)) {
593 change_tmp
= change_point
[i
];
594 change_point
[i
] = change_point
[i
-1];
595 change_point
[i
-1] = change_tmp
;
601 /* create a new bios memory map, removing overlaps */
602 overlap_entries
= 0; /* number of entries in the overlap table */
603 new_bios_entry
= 0; /* index for creating new bios map entries */
604 last_type
= 0; /* start with undefined memory type */
605 last_addr
= 0; /* start with 0 as last starting address */
607 /* loop through change-points, determining affect on the new bios map */
608 for (chgidx
= 0; chgidx
< chg_nr
; chgidx
++) {
609 /* keep track of all overlapping bios entries */
610 if (change_point
[chgidx
]->addr
==
611 change_point
[chgidx
]->pbios
->addr
) {
613 * add map entry to overlap list (> 1 entry
614 * implies an overlap)
616 overlap_list
[overlap_entries
++] =
617 change_point
[chgidx
]->pbios
;
620 * remove entry from list (order independent,
623 for (i
= 0; i
< overlap_entries
; i
++) {
624 if (overlap_list
[i
] ==
625 change_point
[chgidx
]->pbios
)
627 overlap_list
[overlap_entries
-1];
632 * if there are overlapping entries, decide which
633 * "type" to use (larger value takes precedence --
634 * 1=usable, 2,3,4,4+=unusable)
637 for (i
= 0; i
< overlap_entries
; i
++)
638 if (overlap_list
[i
]->type
> current_type
)
639 current_type
= overlap_list
[i
]->type
;
641 * continue building up new bios map based on this
644 if (current_type
!= last_type
) {
645 if (last_type
!= 0) {
646 new_bios
[new_bios_entry
].size
=
647 change_point
[chgidx
]->addr
- last_addr
;
649 * move forward only if the new size
652 if (new_bios
[new_bios_entry
].size
!= 0)
654 * no more space left for new
657 if (++new_bios_entry
>= E820MAX
)
660 if (current_type
!= 0) {
661 new_bios
[new_bios_entry
].addr
=
662 change_point
[chgidx
]->addr
;
663 new_bios
[new_bios_entry
].type
= current_type
;
664 last_addr
= change_point
[chgidx
]->addr
;
666 last_type
= current_type
;
669 /* retain count for new bios entries */
670 new_nr
= new_bios_entry
;
672 /* copy new bios mapping into original location */
673 memcpy(biosmap
, new_bios
, new_nr
* sizeof(struct e820entry
));
680 * Copy the BIOS e820 map into a safe place.
682 * Sanity-check it while we're at it..
684 * If we're lucky and live on a modern system, the setup code
685 * will have given us a memory map that we can use to properly
686 * set up memory. If we aren't, we'll fake a memory map.
688 static int __init
copy_e820_map(struct e820entry
*biosmap
, int nr_map
)
690 /* Only one memory region (or negative)? Ignore it */
695 u64 start
= biosmap
->addr
;
696 u64 size
= biosmap
->size
;
697 u64 end
= start
+ size
;
698 u32 type
= biosmap
->type
;
700 /* Overflow in 64 bits? Ignore the memory map. */
704 add_memory_region(start
, size
, type
);
705 } while (biosmap
++, --nr_map
);
709 static void early_panic(char *msg
)
715 /* We're not void only for x86 32-bit compat */
716 char * __init
machine_specific_memory_setup(void)
718 char *who
= "BIOS-e820";
720 * Try to copy the BIOS-supplied E820-map.
722 * Otherwise fake a memory map; one section from 0k->640k,
723 * the next section from 1mb->appropriate_mem_k
725 sanitize_e820_map(boot_params
.e820_map
, &boot_params
.e820_entries
);
726 if (copy_e820_map(boot_params
.e820_map
, boot_params
.e820_entries
) < 0)
727 early_panic("Cannot find a valid memory map");
728 printk(KERN_INFO
"BIOS-provided physical RAM map:\n");
731 /* In case someone cares... */
735 static int __init
parse_memopt(char *p
)
739 end_user_pfn
= memparse(p
, &p
);
740 end_user_pfn
>>= PAGE_SHIFT
;
743 early_param("mem", parse_memopt
);
745 static int userdef __initdata
;
747 static int __init
parse_memmap_opt(char *p
)
750 unsigned long long start_at
, mem_size
;
752 if (!strcmp(p
, "exactmap")) {
753 #ifdef CONFIG_CRASH_DUMP
755 * If we are doing a crash dump, we still need to know
756 * the real mem size before original memory map is
759 e820_register_active_regions(0, 0, -1UL);
760 saved_max_pfn
= e820_end_of_ram();
761 remove_all_active_ranges();
770 mem_size
= memparse(p
, &p
);
776 start_at
= memparse(p
+1, &p
);
777 add_memory_region(start_at
, mem_size
, E820_RAM
);
778 } else if (*p
== '#') {
779 start_at
= memparse(p
+1, &p
);
780 add_memory_region(start_at
, mem_size
, E820_ACPI
);
781 } else if (*p
== '$') {
782 start_at
= memparse(p
+1, &p
);
783 add_memory_region(start_at
, mem_size
, E820_RESERVED
);
785 end_user_pfn
= (mem_size
>> PAGE_SHIFT
);
787 return *p
== '\0' ? 0 : -EINVAL
;
789 early_param("memmap", parse_memmap_opt
);
791 void __init
finish_e820_parsing(void)
794 char nr
= e820
.nr_map
;
796 if (sanitize_e820_map(e820
.map
, &nr
) < 0)
797 early_panic("Invalid user supplied memory map");
800 printk(KERN_INFO
"user-defined physical RAM map:\n");
801 e820_print_map("user");
805 void __init
update_memory_range(u64 start
, u64 size
, unsigned old_type
,
810 BUG_ON(old_type
== new_type
);
812 for (i
= 0; i
< e820
.nr_map
; i
++) {
813 struct e820entry
*ei
= &e820
.map
[i
];
814 u64 final_start
, final_end
;
815 if (ei
->type
!= old_type
)
817 /* totally covered? */
818 if (ei
->addr
>= start
&& ei
->size
<= size
) {
822 /* partially covered */
823 final_start
= max(start
, ei
->addr
);
824 final_end
= min(start
+ size
, ei
->addr
+ ei
->size
);
825 if (final_start
>= final_end
)
827 add_memory_region(final_start
, final_end
- final_start
,
832 void __init
update_e820(void)
836 nr_map
= e820
.nr_map
;
837 if (sanitize_e820_map(e820
.map
, &nr_map
))
839 e820
.nr_map
= nr_map
;
840 printk(KERN_INFO
"modified physical RAM map:\n");
841 e820_print_map("modified");
844 unsigned long pci_mem_start
= 0xaeedbabe;
845 EXPORT_SYMBOL(pci_mem_start
);
848 * Search for the biggest gap in the low 32 bits of the e820
849 * memory space. We pass this space to PCI to assign MMIO resources
850 * for hotplug or unconfigured devices in.
851 * Hopefully the BIOS let enough space left.
853 __init
void e820_setup_gap(void)
855 unsigned long gapstart
, gapsize
, round
;
860 last
= 0x100000000ull
;
861 gapstart
= 0x10000000;
865 unsigned long long start
= e820
.map
[i
].addr
;
866 unsigned long long end
= start
+ e820
.map
[i
].size
;
869 * Since "last" is at most 4GB, we know we'll
870 * fit in 32 bits if this condition is true
873 unsigned long gap
= last
- end
;
886 gapstart
= (end_pfn
<< PAGE_SHIFT
) + 1024*1024;
887 printk(KERN_ERR
"PCI: Warning: Cannot find a gap in the 32bit "
889 KERN_ERR
"PCI: Unassigned devices with 32bit resource "
890 "registers may break!\n");
894 * See how much we want to round up: start off with
895 * rounding to the next 1MB area.
898 while ((gapsize
>> 4) > round
)
900 /* Fun with two's complement */
901 pci_mem_start
= (gapstart
+ round
) & -round
;
904 "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
905 pci_mem_start
, gapstart
, gapsize
);
908 int __init
arch_get_ram_range(int slot
, u64
*addr
, u64
*size
)
912 if (slot
< 0 || slot
>= e820
.nr_map
)
914 for (i
= slot
; i
< e820
.nr_map
; i
++) {
915 if (e820
.map
[i
].type
!= E820_RAM
)
919 if (i
== e820
.nr_map
|| e820
.map
[i
].addr
> (max_pfn
<< PAGE_SHIFT
))
921 *addr
= e820
.map
[i
].addr
;
922 *size
= min_t(u64
, e820
.map
[i
].size
+ e820
.map
[i
].addr
,
923 max_pfn
<< PAGE_SHIFT
) - *addr
;