10 #include <linux/kernel.h>
11 #include <linux/errno.h>
15 #include <linux/mman.h>
23 #include <linux/export.h>
25 #include <asm/sections.h>
26 #include <asm/setup.h>
27 #include <asm/sizes.h>
29 #include <asm/memblock.h>
34 static unsigned long phys_initrd_start
__initdata = 0x01000000;
37 static int __init early_initrd(
char *
p)
46 phys_initrd_start =
start;
47 phys_initrd_size =
size;
71 unsigned int pfn1, pfn2;
82 if (PageReserved(page))
84 else if (PageSwapCache(page))
86 else if (PageSlab(page))
88 else if (!page_count(page))
91 shared += page_count(page) - 1;
104 static void __init find_limits(
unsigned long *
min,
unsigned long *max_low,
105 unsigned long *max_high)
111 *max_low = *max_high = 0;
131 static void __init uc32_bootmem_init(
unsigned long start_pfn,
132 unsigned long end_pfn)
134 struct memblock_region *
reg;
135 unsigned int boot_pages;
156 for_each_memblock(
memory, reg) {
157 unsigned long start = memblock_region_memory_base_pfn(reg);
158 unsigned long end = memblock_region_memory_end_pfn(reg);
170 unsigned long start = memblock_region_reserved_base_pfn(reg);
171 unsigned long end = memblock_region_reserved_end_pfn(reg);
183 static void __init uc32_bootmem_free(
unsigned long min,
unsigned long max_low,
184 unsigned long max_high)
186 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
187 struct memblock_region *
reg;
192 memset(zone_size, 0,
sizeof(zone_size));
199 zone_size[0] = max_low -
min;
205 memcpy(zhole_size, zone_size,
sizeof(zhole_size));
206 for_each_memblock(
memory, reg) {
207 unsigned long start = memblock_region_memory_base_pfn(reg);
208 unsigned long end = memblock_region_memory_end_pfn(reg);
210 if (start < max_low) {
211 unsigned long low_end =
min(end, max_low);
212 zhole_size[0] -= low_end -
start;
231 static void uc32_memory_present(
void)
235 static int __init meminfo_cmp(
const void *_a,
const void *_b)
239 return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
255 #ifdef CONFIG_BLK_DEV_INITRD
256 if (phys_initrd_size) {
273 unsigned long min, max_low, max_high;
275 max_low = max_high = 0;
277 find_limits(&min, &max_low, &max_high);
279 uc32_bootmem_init(min, max_low);
281 #ifdef CONFIG_SWIOTLB
288 uc32_memory_present();
300 uc32_bootmem_free(min, max_low, max_high);
316 static inline int free_area(
unsigned long pfn,
unsigned long end,
char *
s)
320 for (; pfn <
end; pfn++) {
322 ClearPageReserved(page);
323 init_page_count(page);
335 free_memmap(
unsigned long start_pfn,
unsigned long end_pfn)
337 struct page *start_pg, *end_pg;
338 unsigned long pg, pgend;
366 unsigned long bank_start, prev_bank_end = 0;
382 if (prev_bank_end && prev_bank_end < bank_start)
383 free_memmap(prev_bank_end, bank_start);
402 struct memblock_region *
reg;
412 reserved_pages = free_pages = 0;
416 unsigned int pfn1, pfn2;
426 if (PageReserved(page))
428 else if (!page_count(page))
431 }
while (page < end);
440 for_each_memblock(
memory, reg) {
441 unsigned long pages = memblock_region_memory_end_pfn(reg) -
442 memblock_region_memory_base_pfn(reg);
455 " vector : 0x%08lx - 0x%08lx (%4ld kB)\n"
456 " vmalloc : 0x%08lx - 0x%08lx (%4ld MB)\n"
457 " lowmem : 0x%08lx - 0x%08lx (%4ld MB)\n"
458 " modules : 0x%08lx - 0x%08lx (%4ld MB)\n"
459 " .init : 0x%p" " - 0x%p" " (%4d kB)\n"
460 " .text : 0x%p" " - 0x%p" " (%4d kB)\n"
461 " .data : 0x%p" " - 0x%p" " (%4d kB)\n",
499 #ifdef CONFIG_BLK_DEV_INITRD
501 static int keep_initrd;
517 __setup(
"keepinitrd", keepinitrd_setup);