init.c 17 KB

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