init.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. /*
  2. * linux/arch/arm/mm/init.c
  3. *
  4. * Copyright (C) 1995-2005 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/errno.h>
  12. #include <linux/swap.h>
  13. #include <linux/init.h>
  14. #include <linux/bootmem.h>
  15. #include <linux/mman.h>
  16. #include <linux/nodemask.h>
  17. #include <linux/initrd.h>
  18. #include <linux/of_fdt.h>
  19. #include <linux/highmem.h>
  20. #include <linux/gfp.h>
  21. #include <linux/memblock.h>
  22. #include <linux/sort.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/prom.h>
  25. #include <asm/sections.h>
  26. #include <asm/setup.h>
  27. #include <asm/sizes.h>
  28. #include <asm/tlb.h>
  29. #include <asm/fixmap.h>
  30. #include <asm/memory.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include "mm.h"
  34. static unsigned long phys_initrd_start __initdata = 0;
  35. static unsigned long phys_initrd_size __initdata = 0;
  36. static int __init early_initrd(char *p)
  37. {
  38. unsigned long start, size;
  39. char *endp;
  40. start = memparse(p, &endp);
  41. if (*endp == ',') {
  42. size = memparse(endp + 1, NULL);
  43. phys_initrd_start = start;
  44. phys_initrd_size = size;
  45. }
  46. return 0;
  47. }
  48. early_param("initrd", early_initrd);
  49. static int __init parse_tag_initrd(const struct tag *tag)
  50. {
  51. printk(KERN_WARNING "ATAG_INITRD is deprecated; "
  52. "please update your bootloader.\n");
  53. phys_initrd_start = __virt_to_phys(tag->u.initrd.start);
  54. phys_initrd_size = tag->u.initrd.size;
  55. return 0;
  56. }
  57. __tagtable(ATAG_INITRD, parse_tag_initrd);
  58. static int __init parse_tag_initrd2(const struct tag *tag)
  59. {
  60. phys_initrd_start = tag->u.initrd.start;
  61. phys_initrd_size = tag->u.initrd.size;
  62. return 0;
  63. }
  64. __tagtable(ATAG_INITRD2, parse_tag_initrd2);
  65. #ifdef CONFIG_OF_FLATTREE
  66. void __init early_init_dt_setup_initrd_arch(unsigned long start, unsigned long end)
  67. {
  68. phys_initrd_start = start;
  69. phys_initrd_size = end - start;
  70. }
  71. #endif /* CONFIG_OF_FLATTREE */
  72. /*
  73. * This keeps memory configuration data used by a couple memory
  74. * initialization functions, as well as show_mem() for the skipping
  75. * of holes in the memory map. It is populated by arm_add_memory().
  76. */
  77. struct meminfo meminfo;
  78. void show_mem(unsigned int filter)
  79. {
  80. int free = 0, total = 0, reserved = 0;
  81. int shared = 0, cached = 0, slab = 0, i;
  82. struct meminfo * mi = &meminfo;
  83. printk("Mem-info:\n");
  84. show_free_areas(filter);
  85. for_each_bank (i, mi) {
  86. struct membank *bank = &mi->bank[i];
  87. unsigned int pfn1, pfn2;
  88. struct page *page, *end;
  89. pfn1 = bank_pfn_start(bank);
  90. pfn2 = bank_pfn_end(bank);
  91. page = pfn_to_page(pfn1);
  92. end = pfn_to_page(pfn2 - 1) + 1;
  93. do {
  94. total++;
  95. if (PageReserved(page))
  96. reserved++;
  97. else if (PageSwapCache(page))
  98. cached++;
  99. else if (PageSlab(page))
  100. slab++;
  101. else if (!page_count(page))
  102. free++;
  103. else
  104. shared += page_count(page) - 1;
  105. page++;
  106. } while (page < end);
  107. }
  108. printk("%d pages of RAM\n", total);
  109. printk("%d free pages\n", free);
  110. printk("%d reserved pages\n", reserved);
  111. printk("%d slab pages\n", slab);
  112. printk("%d pages shared\n", shared);
  113. printk("%d pages swap cached\n", cached);
  114. }
  115. static void __init find_limits(unsigned long *min, unsigned long *max_low,
  116. unsigned long *max_high)
  117. {
  118. struct meminfo *mi = &meminfo;
  119. int i;
  120. *min = -1UL;
  121. *max_low = *max_high = 0;
  122. for_each_bank (i, mi) {
  123. struct membank *bank = &mi->bank[i];
  124. unsigned long start, end;
  125. start = bank_pfn_start(bank);
  126. end = bank_pfn_end(bank);
  127. if (*min > start)
  128. *min = start;
  129. if (*max_high < end)
  130. *max_high = end;
  131. if (bank->highmem)
  132. continue;
  133. if (*max_low < end)
  134. *max_low = end;
  135. }
  136. }
  137. static void __init arm_bootmem_init(unsigned long start_pfn,
  138. unsigned long end_pfn)
  139. {
  140. struct memblock_region *reg;
  141. unsigned int boot_pages;
  142. phys_addr_t bitmap;
  143. pg_data_t *pgdat;
  144. /*
  145. * Allocate the bootmem bitmap page. This must be in a region
  146. * of memory which has already been mapped.
  147. */
  148. boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
  149. bitmap = memblock_alloc_base(boot_pages << PAGE_SHIFT, L1_CACHE_BYTES,
  150. __pfn_to_phys(end_pfn));
  151. /*
  152. * Initialise the bootmem allocator, handing the
  153. * memory banks over to bootmem.
  154. */
  155. node_set_online(0);
  156. pgdat = NODE_DATA(0);
  157. init_bootmem_node(pgdat, __phys_to_pfn(bitmap), start_pfn, end_pfn);
  158. /* Free the lowmem regions from memblock into bootmem. */
  159. for_each_memblock(memory, reg) {
  160. unsigned long start = memblock_region_memory_base_pfn(reg);
  161. unsigned long end = memblock_region_memory_end_pfn(reg);
  162. if (end >= end_pfn)
  163. end = end_pfn;
  164. if (start >= end)
  165. break;
  166. free_bootmem(__pfn_to_phys(start), (end - start) << PAGE_SHIFT);
  167. }
  168. /* Reserve the lowmem memblock reserved regions in bootmem. */
  169. for_each_memblock(reserved, reg) {
  170. unsigned long start = memblock_region_reserved_base_pfn(reg);
  171. unsigned long end = memblock_region_reserved_end_pfn(reg);
  172. if (end >= end_pfn)
  173. end = end_pfn;
  174. if (start >= end)
  175. break;
  176. reserve_bootmem(__pfn_to_phys(start),
  177. (end - start) << PAGE_SHIFT, BOOTMEM_DEFAULT);
  178. }
  179. }
  180. #ifdef CONFIG_ZONE_DMA
  181. #ifdef ARM_DMA_ZONE_SIZE
  182. unsigned long arm_dma_zone_size = ARM_DMA_ZONE_SIZE;
  183. #else
  184. unsigned long arm_dma_zone_size __read_mostly;
  185. #endif
  186. EXPORT_SYMBOL(arm_dma_zone_size);
  187. /*
  188. * The DMA mask corresponding to the maximum bus address allocatable
  189. * using GFP_DMA. The default here places no restriction on DMA
  190. * allocations. This must be the smallest DMA mask in the system,
  191. * so a successful GFP_DMA allocation will always satisfy this.
  192. */
  193. u32 arm_dma_limit;
  194. static void __init arm_adjust_dma_zone(unsigned long *size, unsigned long *hole,
  195. unsigned long dma_size)
  196. {
  197. if (size[0] <= dma_size)
  198. return;
  199. size[ZONE_NORMAL] = size[0] - dma_size;
  200. size[ZONE_DMA] = dma_size;
  201. hole[ZONE_NORMAL] = hole[0];
  202. hole[ZONE_DMA] = 0;
  203. }
  204. #endif
  205. static void __init arm_bootmem_free(unsigned long min, unsigned long max_low,
  206. unsigned long max_high)
  207. {
  208. unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
  209. struct memblock_region *reg;
  210. /*
  211. * initialise the zones.
  212. */
  213. memset(zone_size, 0, sizeof(zone_size));
  214. /*
  215. * The memory size has already been determined. If we need
  216. * to do anything fancy with the allocation of this memory
  217. * to the zones, now is the time to do it.
  218. */
  219. zone_size[0] = max_low - min;
  220. #ifdef CONFIG_HIGHMEM
  221. zone_size[ZONE_HIGHMEM] = max_high - max_low;
  222. #endif
  223. /*
  224. * Calculate the size of the holes.
  225. * holes = node_size - sum(bank_sizes)
  226. */
  227. memcpy(zhole_size, zone_size, sizeof(zhole_size));
  228. for_each_memblock(memory, reg) {
  229. unsigned long start = memblock_region_memory_base_pfn(reg);
  230. unsigned long end = memblock_region_memory_end_pfn(reg);
  231. if (start < max_low) {
  232. unsigned long low_end = min(end, max_low);
  233. zhole_size[0] -= low_end - start;
  234. }
  235. #ifdef CONFIG_HIGHMEM
  236. if (end > max_low) {
  237. unsigned long high_start = max(start, max_low);
  238. zhole_size[ZONE_HIGHMEM] -= end - high_start;
  239. }
  240. #endif
  241. }
  242. #ifdef CONFIG_ZONE_DMA
  243. /*
  244. * Adjust the sizes according to any special requirements for
  245. * this machine type.
  246. */
  247. if (arm_dma_zone_size) {
  248. arm_adjust_dma_zone(zone_size, zhole_size,
  249. arm_dma_zone_size >> PAGE_SHIFT);
  250. arm_dma_limit = PHYS_OFFSET + arm_dma_zone_size - 1;
  251. } else
  252. arm_dma_limit = 0xffffffff;
  253. #endif
  254. free_area_init_node(0, zone_size, min, zhole_size);
  255. }
  256. #ifdef CONFIG_HAVE_ARCH_PFN_VALID
  257. int pfn_valid(unsigned long pfn)
  258. {
  259. return memblock_is_memory(pfn << PAGE_SHIFT);
  260. }
  261. EXPORT_SYMBOL(pfn_valid);
  262. #endif
  263. #ifndef CONFIG_SPARSEMEM
  264. static void arm_memory_present(void)
  265. {
  266. }
  267. #else
  268. static void arm_memory_present(void)
  269. {
  270. struct memblock_region *reg;
  271. for_each_memblock(memory, reg)
  272. memory_present(0, memblock_region_memory_base_pfn(reg),
  273. memblock_region_memory_end_pfn(reg));
  274. }
  275. #endif
  276. static int __init meminfo_cmp(const void *_a, const void *_b)
  277. {
  278. const struct membank *a = _a, *b = _b;
  279. long cmp = bank_pfn_start(a) - bank_pfn_start(b);
  280. return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
  281. }
  282. void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
  283. {
  284. int i;
  285. sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL);
  286. memblock_init();
  287. for (i = 0; i < mi->nr_banks; i++)
  288. memblock_add(mi->bank[i].start, mi->bank[i].size);
  289. /* Register the kernel text, kernel data and initrd with memblock. */
  290. #ifdef CONFIG_XIP_KERNEL
  291. memblock_reserve(__pa(_sdata), _end - _sdata);
  292. #else
  293. memblock_reserve(__pa(_stext), _end - _stext);
  294. #endif
  295. #ifdef CONFIG_BLK_DEV_INITRD
  296. if (phys_initrd_size &&
  297. !memblock_is_region_memory(phys_initrd_start, phys_initrd_size)) {
  298. pr_err("INITRD: 0x%08lx+0x%08lx is not a memory region - disabling initrd\n",
  299. phys_initrd_start, phys_initrd_size);
  300. phys_initrd_start = phys_initrd_size = 0;
  301. }
  302. if (phys_initrd_size &&
  303. memblock_is_region_reserved(phys_initrd_start, phys_initrd_size)) {
  304. pr_err("INITRD: 0x%08lx+0x%08lx overlaps in-use memory region - disabling initrd\n",
  305. phys_initrd_start, phys_initrd_size);
  306. phys_initrd_start = phys_initrd_size = 0;
  307. }
  308. if (phys_initrd_size) {
  309. memblock_reserve(phys_initrd_start, phys_initrd_size);
  310. /* Now convert initrd to virtual addresses */
  311. initrd_start = __phys_to_virt(phys_initrd_start);
  312. initrd_end = initrd_start + phys_initrd_size;
  313. }
  314. #endif
  315. arm_mm_memblock_reserve();
  316. arm_dt_memblock_reserve();
  317. /* reserve any platform specific memblock areas */
  318. if (mdesc->reserve)
  319. mdesc->reserve();
  320. memblock_analyze();
  321. memblock_dump_all();
  322. }
  323. void __init bootmem_init(void)
  324. {
  325. unsigned long min, max_low, max_high;
  326. max_low = max_high = 0;
  327. find_limits(&min, &max_low, &max_high);
  328. arm_bootmem_init(min, max_low);
  329. /*
  330. * Sparsemem tries to allocate bootmem in memory_present(),
  331. * so must be done after the fixed reservations
  332. */
  333. arm_memory_present();
  334. /*
  335. * sparse_init() needs the bootmem allocator up and running.
  336. */
  337. sparse_init();
  338. /*
  339. * Now free the memory - free_area_init_node needs
  340. * the sparse mem_map arrays initialized by sparse_init()
  341. * for memmap_init_zone(), otherwise all PFNs are invalid.
  342. */
  343. arm_bootmem_free(min, max_low, max_high);
  344. high_memory = __va(((phys_addr_t)max_low << PAGE_SHIFT) - 1) + 1;
  345. /*
  346. * This doesn't seem to be used by the Linux memory manager any
  347. * more, but is used by ll_rw_block. If we can get rid of it, we
  348. * also get rid of some of the stuff above as well.
  349. *
  350. * Note: max_low_pfn and max_pfn reflect the number of _pages_ in
  351. * the system, not the maximum PFN.
  352. */
  353. max_low_pfn = max_low - PHYS_PFN_OFFSET;
  354. max_pfn = max_high - PHYS_PFN_OFFSET;
  355. }
  356. static inline int free_area(unsigned long pfn, unsigned long end, char *s)
  357. {
  358. unsigned int pages = 0, size = (end - pfn) << (PAGE_SHIFT - 10);
  359. for (; pfn < end; pfn++) {
  360. struct page *page = pfn_to_page(pfn);
  361. ClearPageReserved(page);
  362. init_page_count(page);
  363. __free_page(page);
  364. pages++;
  365. }
  366. if (size && s)
  367. printk(KERN_INFO "Freeing %s memory: %dK\n", s, size);
  368. return pages;
  369. }
  370. static inline void
  371. free_memmap(unsigned long start_pfn, unsigned long end_pfn)
  372. {
  373. struct page *start_pg, *end_pg;
  374. unsigned long pg, pgend;
  375. /*
  376. * Convert start_pfn/end_pfn to a struct page pointer.
  377. */
  378. start_pg = pfn_to_page(start_pfn - 1) + 1;
  379. end_pg = pfn_to_page(end_pfn - 1) + 1;
  380. /*
  381. * Convert to physical addresses, and
  382. * round start upwards and end downwards.
  383. */
  384. pg = (unsigned long)PAGE_ALIGN(__pa(start_pg));
  385. pgend = (unsigned long)__pa(end_pg) & PAGE_MASK;
  386. /*
  387. * If there are free pages between these,
  388. * free the section of the memmap array.
  389. */
  390. if (pg < pgend)
  391. free_bootmem(pg, pgend - pg);
  392. }
  393. /*
  394. * The mem_map array can get very big. Free the unused area of the memory map.
  395. */
  396. static void __init free_unused_memmap(struct meminfo *mi)
  397. {
  398. unsigned long bank_start, prev_bank_end = 0;
  399. unsigned int i;
  400. /*
  401. * This relies on each bank being in address order.
  402. * The banks are sorted previously in bootmem_init().
  403. */
  404. for_each_bank(i, mi) {
  405. struct membank *bank = &mi->bank[i];
  406. bank_start = bank_pfn_start(bank);
  407. #ifdef CONFIG_SPARSEMEM
  408. /*
  409. * Take care not to free memmap entries that don't exist
  410. * due to SPARSEMEM sections which aren't present.
  411. */
  412. bank_start = min(bank_start,
  413. ALIGN(prev_bank_end, PAGES_PER_SECTION));
  414. #endif
  415. /*
  416. * If we had a previous bank, and there is a space
  417. * between the current bank and the previous, free it.
  418. */
  419. if (prev_bank_end && prev_bank_end < bank_start)
  420. free_memmap(prev_bank_end, bank_start);
  421. /*
  422. * Align up here since the VM subsystem insists that the
  423. * memmap entries are valid from the bank end aligned to
  424. * MAX_ORDER_NR_PAGES.
  425. */
  426. prev_bank_end = ALIGN(bank_pfn_end(bank), MAX_ORDER_NR_PAGES);
  427. }
  428. #ifdef CONFIG_SPARSEMEM
  429. if (!IS_ALIGNED(prev_bank_end, PAGES_PER_SECTION))
  430. free_memmap(prev_bank_end,
  431. ALIGN(prev_bank_end, PAGES_PER_SECTION));
  432. #endif
  433. }
  434. static void __init free_highpages(void)
  435. {
  436. #ifdef CONFIG_HIGHMEM
  437. unsigned long max_low = max_low_pfn + PHYS_PFN_OFFSET;
  438. struct memblock_region *mem, *res;
  439. /* set highmem page free */
  440. for_each_memblock(memory, mem) {
  441. unsigned long start = memblock_region_memory_base_pfn(mem);
  442. unsigned long end = memblock_region_memory_end_pfn(mem);
  443. /* Ignore complete lowmem entries */
  444. if (end <= max_low)
  445. continue;
  446. /* Truncate partial highmem entries */
  447. if (start < max_low)
  448. start = max_low;
  449. /* Find and exclude any reserved regions */
  450. for_each_memblock(reserved, res) {
  451. unsigned long res_start, res_end;
  452. res_start = memblock_region_reserved_base_pfn(res);
  453. res_end = memblock_region_reserved_end_pfn(res);
  454. if (res_end < start)
  455. continue;
  456. if (res_start < start)
  457. res_start = start;
  458. if (res_start > end)
  459. res_start = end;
  460. if (res_end > end)
  461. res_end = end;
  462. if (res_start != start)
  463. totalhigh_pages += free_area(start, res_start,
  464. NULL);
  465. start = res_end;
  466. if (start == end)
  467. break;
  468. }
  469. /* And now free anything which remains */
  470. if (start < end)
  471. totalhigh_pages += free_area(start, end, NULL);
  472. }
  473. totalram_pages += totalhigh_pages;
  474. #endif
  475. }
  476. /*
  477. * mem_init() marks the free areas in the mem_map and tells us how much
  478. * memory is free. This is done after various parts of the system have
  479. * claimed their memory after the kernel image.
  480. */
  481. void __init mem_init(void)
  482. {
  483. unsigned long reserved_pages, free_pages;
  484. struct memblock_region *reg;
  485. int i;
  486. #ifdef CONFIG_HAVE_TCM
  487. /* These pointers are filled in on TCM detection */
  488. extern u32 dtcm_end;
  489. extern u32 itcm_end;
  490. #endif
  491. max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
  492. /* this will put all unused low memory onto the freelists */
  493. free_unused_memmap(&meminfo);
  494. totalram_pages += free_all_bootmem();
  495. #ifdef CONFIG_SA1111
  496. /* now that our DMA memory is actually so designated, we can free it */
  497. totalram_pages += free_area(PHYS_PFN_OFFSET,
  498. __phys_to_pfn(__pa(swapper_pg_dir)), NULL);
  499. #endif
  500. free_highpages();
  501. reserved_pages = free_pages = 0;
  502. for_each_bank(i, &meminfo) {
  503. struct membank *bank = &meminfo.bank[i];
  504. unsigned int pfn1, pfn2;
  505. struct page *page, *end;
  506. pfn1 = bank_pfn_start(bank);
  507. pfn2 = bank_pfn_end(bank);
  508. page = pfn_to_page(pfn1);
  509. end = pfn_to_page(pfn2 - 1) + 1;
  510. do {
  511. if (PageReserved(page))
  512. reserved_pages++;
  513. else if (!page_count(page))
  514. free_pages++;
  515. page++;
  516. } while (page < end);
  517. }
  518. /*
  519. * Since our memory may not be contiguous, calculate the
  520. * real number of pages we have in this system
  521. */
  522. printk(KERN_INFO "Memory:");
  523. num_physpages = 0;
  524. for_each_memblock(memory, reg) {
  525. unsigned long pages = memblock_region_memory_end_pfn(reg) -
  526. memblock_region_memory_base_pfn(reg);
  527. num_physpages += pages;
  528. printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
  529. }
  530. printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
  531. printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK highmem\n",
  532. nr_free_pages() << (PAGE_SHIFT-10),
  533. free_pages << (PAGE_SHIFT-10),
  534. reserved_pages << (PAGE_SHIFT-10),
  535. totalhigh_pages << (PAGE_SHIFT-10));
  536. #define MLK(b, t) b, t, ((t) - (b)) >> 10
  537. #define MLM(b, t) b, t, ((t) - (b)) >> 20
  538. #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), SZ_1K)
  539. printk(KERN_NOTICE "Virtual kernel memory layout:\n"
  540. " vector : 0x%08lx - 0x%08lx (%4ld kB)\n"
  541. #ifdef CONFIG_HAVE_TCM
  542. " DTCM : 0x%08lx - 0x%08lx (%4ld kB)\n"
  543. " ITCM : 0x%08lx - 0x%08lx (%4ld kB)\n"
  544. #endif
  545. " fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n"
  546. #ifdef CONFIG_MMU
  547. " DMA : 0x%08lx - 0x%08lx (%4ld MB)\n"
  548. #endif
  549. " vmalloc : 0x%08lx - 0x%08lx (%4ld MB)\n"
  550. " lowmem : 0x%08lx - 0x%08lx (%4ld MB)\n"
  551. #ifdef CONFIG_HIGHMEM
  552. " pkmap : 0x%08lx - 0x%08lx (%4ld MB)\n"
  553. #endif
  554. " modules : 0x%08lx - 0x%08lx (%4ld MB)\n"
  555. " .init : 0x%p" " - 0x%p" " (%4d kB)\n"
  556. " .text : 0x%p" " - 0x%p" " (%4d kB)\n"
  557. " .data : 0x%p" " - 0x%p" " (%4d kB)\n"
  558. " .bss : 0x%p" " - 0x%p" " (%4d kB)\n",
  559. MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
  560. (PAGE_SIZE)),
  561. #ifdef CONFIG_HAVE_TCM
  562. MLK(DTCM_OFFSET, (unsigned long) dtcm_end),
  563. MLK(ITCM_OFFSET, (unsigned long) itcm_end),
  564. #endif
  565. MLK(FIXADDR_START, FIXADDR_TOP),
  566. #ifdef CONFIG_MMU
  567. MLM(CONSISTENT_BASE, CONSISTENT_END),
  568. #endif
  569. MLM(VMALLOC_START, VMALLOC_END),
  570. MLM(PAGE_OFFSET, (unsigned long)high_memory),
  571. #ifdef CONFIG_HIGHMEM
  572. MLM(PKMAP_BASE, (PKMAP_BASE) + (LAST_PKMAP) *
  573. (PAGE_SIZE)),
  574. #endif
  575. MLM(MODULES_VADDR, MODULES_END),
  576. MLK_ROUNDUP(__init_begin, __init_end),
  577. MLK_ROUNDUP(_text, _etext),
  578. MLK_ROUNDUP(_sdata, _edata),
  579. MLK_ROUNDUP(__bss_start, __bss_stop));
  580. #undef MLK
  581. #undef MLM
  582. #undef MLK_ROUNDUP
  583. /*
  584. * Check boundaries twice: Some fundamental inconsistencies can
  585. * be detected at build time already.
  586. */
  587. #ifdef CONFIG_MMU
  588. BUILD_BUG_ON(VMALLOC_END > CONSISTENT_BASE);
  589. BUG_ON(VMALLOC_END > CONSISTENT_BASE);
  590. BUILD_BUG_ON(TASK_SIZE > MODULES_VADDR);
  591. BUG_ON(TASK_SIZE > MODULES_VADDR);
  592. #endif
  593. #ifdef CONFIG_HIGHMEM
  594. BUILD_BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE > PAGE_OFFSET);
  595. BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE > PAGE_OFFSET);
  596. #endif
  597. if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
  598. extern int sysctl_overcommit_memory;
  599. /*
  600. * On a machine this small we won't get
  601. * anywhere without overcommit, so turn
  602. * it on by default.
  603. */
  604. sysctl_overcommit_memory = OVERCOMMIT_ALWAYS;
  605. }
  606. }
  607. void free_initmem(void)
  608. {
  609. #ifdef CONFIG_HAVE_TCM
  610. extern char __tcm_start, __tcm_end;
  611. totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
  612. __phys_to_pfn(__pa(&__tcm_end)),
  613. "TCM link");
  614. #endif
  615. if (!machine_is_integrator() && !machine_is_cintegrator())
  616. totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)),
  617. __phys_to_pfn(__pa(__init_end)),
  618. "init");
  619. }
  620. #ifdef CONFIG_BLK_DEV_INITRD
  621. static int keep_initrd;
  622. void free_initrd_mem(unsigned long start, unsigned long end)
  623. {
  624. if (!keep_initrd)
  625. totalram_pages += free_area(__phys_to_pfn(__pa(start)),
  626. __phys_to_pfn(__pa(end)),
  627. "initrd");
  628. }
  629. static int __init keepinitrd_setup(char *__unused)
  630. {
  631. keep_initrd = 1;
  632. return 1;
  633. }
  634. __setup("keepinitrd", keepinitrd_setup);
  635. #endif