init.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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/config.h>
  11. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/ptrace.h>
  14. #include <linux/swap.h>
  15. #include <linux/init.h>
  16. #include <linux/bootmem.h>
  17. #include <linux/mman.h>
  18. #include <linux/nodemask.h>
  19. #include <linux/initrd.h>
  20. #include <asm/mach-types.h>
  21. #include <asm/setup.h>
  22. #include <asm/sizes.h>
  23. #include <asm/tlb.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/map.h>
  26. #define TABLE_SIZE (2 * PTRS_PER_PTE * sizeof(pte_t))
  27. DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
  28. extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
  29. extern void _stext, _text, _etext, __data_start, _end, __init_begin, __init_end;
  30. extern unsigned long phys_initrd_start;
  31. extern unsigned long phys_initrd_size;
  32. /*
  33. * The sole use of this is to pass memory configuration
  34. * data from paging_init to mem_init.
  35. */
  36. static struct meminfo meminfo __initdata = { 0, };
  37. /*
  38. * empty_zero_page is a special page that is used for
  39. * zero-initialized data and COW.
  40. */
  41. struct page *empty_zero_page;
  42. void show_mem(void)
  43. {
  44. int free = 0, total = 0, reserved = 0;
  45. int shared = 0, cached = 0, slab = 0, node;
  46. printk("Mem-info:\n");
  47. show_free_areas();
  48. printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
  49. for_each_online_node(node) {
  50. struct page *page, *end;
  51. page = NODE_MEM_MAP(node);
  52. end = page + NODE_DATA(node)->node_spanned_pages;
  53. do {
  54. total++;
  55. if (PageReserved(page))
  56. reserved++;
  57. else if (PageSwapCache(page))
  58. cached++;
  59. else if (PageSlab(page))
  60. slab++;
  61. else if (!page_count(page))
  62. free++;
  63. else
  64. shared += page_count(page) - 1;
  65. page++;
  66. } while (page < end);
  67. }
  68. printk("%d pages of RAM\n", total);
  69. printk("%d free pages\n", free);
  70. printk("%d reserved pages\n", reserved);
  71. printk("%d slab pages\n", slab);
  72. printk("%d pages shared\n", shared);
  73. printk("%d pages swap cached\n", cached);
  74. }
  75. static inline pmd_t *pmd_off(pgd_t *pgd, unsigned long virt)
  76. {
  77. return pmd_offset(pgd, virt);
  78. }
  79. static inline pmd_t *pmd_off_k(unsigned long virt)
  80. {
  81. return pmd_off(pgd_offset_k(virt), virt);
  82. }
  83. #define for_each_nodebank(iter,mi,no) \
  84. for (iter = 0; iter < mi->nr_banks; iter++) \
  85. if (mi->bank[iter].node == no)
  86. /*
  87. * FIXME: We really want to avoid allocating the bootmap bitmap
  88. * over the top of the initrd. Hopefully, this is located towards
  89. * the start of a bank, so if we allocate the bootmap bitmap at
  90. * the end, we won't clash.
  91. */
  92. static unsigned int __init
  93. find_bootmap_pfn(int node, struct meminfo *mi, unsigned int bootmap_pages)
  94. {
  95. unsigned int start_pfn, bank, bootmap_pfn;
  96. start_pfn = PAGE_ALIGN(__pa(&_end)) >> PAGE_SHIFT;
  97. bootmap_pfn = 0;
  98. for_each_nodebank(bank, mi, node) {
  99. unsigned int start, end;
  100. start = mi->bank[bank].start >> PAGE_SHIFT;
  101. end = (mi->bank[bank].size +
  102. mi->bank[bank].start) >> PAGE_SHIFT;
  103. if (end < start_pfn)
  104. continue;
  105. if (start < start_pfn)
  106. start = start_pfn;
  107. if (end <= start)
  108. continue;
  109. if (end - start >= bootmap_pages) {
  110. bootmap_pfn = start;
  111. break;
  112. }
  113. }
  114. if (bootmap_pfn == 0)
  115. BUG();
  116. return bootmap_pfn;
  117. }
  118. static int __init check_initrd(struct meminfo *mi)
  119. {
  120. int initrd_node = -2;
  121. #ifdef CONFIG_BLK_DEV_INITRD
  122. unsigned long end = phys_initrd_start + phys_initrd_size;
  123. /*
  124. * Make sure that the initrd is within a valid area of
  125. * memory.
  126. */
  127. if (phys_initrd_size) {
  128. unsigned int i;
  129. initrd_node = -1;
  130. for (i = 0; i < mi->nr_banks; i++) {
  131. unsigned long bank_end;
  132. bank_end = mi->bank[i].start + mi->bank[i].size;
  133. if (mi->bank[i].start <= phys_initrd_start &&
  134. end <= bank_end)
  135. initrd_node = mi->bank[i].node;
  136. }
  137. }
  138. if (initrd_node == -1) {
  139. printk(KERN_ERR "initrd (0x%08lx - 0x%08lx) extends beyond "
  140. "physical memory - disabling initrd\n",
  141. phys_initrd_start, end);
  142. phys_initrd_start = phys_initrd_size = 0;
  143. }
  144. #endif
  145. return initrd_node;
  146. }
  147. /*
  148. * Reserve the various regions of node 0
  149. */
  150. static __init void reserve_node_zero(pg_data_t *pgdat)
  151. {
  152. unsigned long res_size = 0;
  153. /*
  154. * Register the kernel text and data with bootmem.
  155. * Note that this can only be in node 0.
  156. */
  157. #ifdef CONFIG_XIP_KERNEL
  158. reserve_bootmem_node(pgdat, __pa(&__data_start), &_end - &__data_start);
  159. #else
  160. reserve_bootmem_node(pgdat, __pa(&_stext), &_end - &_stext);
  161. #endif
  162. /*
  163. * Reserve the page tables. These are already in use,
  164. * and can only be in node 0.
  165. */
  166. reserve_bootmem_node(pgdat, __pa(swapper_pg_dir),
  167. PTRS_PER_PGD * sizeof(pgd_t));
  168. /*
  169. * Hmm... This should go elsewhere, but we really really need to
  170. * stop things allocating the low memory; ideally we need a better
  171. * implementation of GFP_DMA which does not assume that DMA-able
  172. * memory starts at zero.
  173. */
  174. if (machine_is_integrator() || machine_is_cintegrator())
  175. res_size = __pa(swapper_pg_dir) - PHYS_OFFSET;
  176. /*
  177. * These should likewise go elsewhere. They pre-reserve the
  178. * screen memory region at the start of main system memory.
  179. */
  180. if (machine_is_edb7211())
  181. res_size = 0x00020000;
  182. if (machine_is_p720t())
  183. res_size = 0x00014000;
  184. #ifdef CONFIG_SA1111
  185. /*
  186. * Because of the SA1111 DMA bug, we want to preserve our
  187. * precious DMA-able memory...
  188. */
  189. res_size = __pa(swapper_pg_dir) - PHYS_OFFSET;
  190. #endif
  191. if (res_size)
  192. reserve_bootmem_node(pgdat, PHYS_OFFSET, res_size);
  193. }
  194. void __init build_mem_type_table(void);
  195. void __init create_mapping(struct map_desc *md);
  196. static unsigned long __init
  197. bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
  198. {
  199. unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
  200. unsigned long start_pfn, end_pfn, boot_pfn;
  201. unsigned int boot_pages;
  202. pg_data_t *pgdat;
  203. int i;
  204. start_pfn = -1UL;
  205. end_pfn = 0;
  206. /*
  207. * Calculate the pfn range, and map the memory banks for this node.
  208. */
  209. for_each_nodebank(i, mi, node) {
  210. unsigned long start, end;
  211. struct map_desc map;
  212. start = mi->bank[i].start >> PAGE_SHIFT;
  213. end = (mi->bank[i].start + mi->bank[i].size) >> PAGE_SHIFT;
  214. if (start_pfn > start)
  215. start_pfn = start;
  216. if (end_pfn < end)
  217. end_pfn = end;
  218. map.pfn = __phys_to_pfn(mi->bank[i].start);
  219. map.virtual = __phys_to_virt(mi->bank[i].start);
  220. map.length = mi->bank[i].size;
  221. map.type = MT_MEMORY;
  222. create_mapping(&map);
  223. }
  224. /*
  225. * If there is no memory in this node, ignore it.
  226. */
  227. if (end_pfn == 0)
  228. return end_pfn;
  229. /*
  230. * Allocate the bootmem bitmap page.
  231. */
  232. boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
  233. boot_pfn = find_bootmap_pfn(node, mi, boot_pages);
  234. /*
  235. * Initialise the bootmem allocator for this node, handing the
  236. * memory banks over to bootmem.
  237. */
  238. node_set_online(node);
  239. pgdat = NODE_DATA(node);
  240. init_bootmem_node(pgdat, boot_pfn, start_pfn, end_pfn);
  241. for_each_nodebank(i, mi, node)
  242. free_bootmem_node(pgdat, mi->bank[i].start, mi->bank[i].size);
  243. /*
  244. * Reserve the bootmem bitmap for this node.
  245. */
  246. reserve_bootmem_node(pgdat, boot_pfn << PAGE_SHIFT,
  247. boot_pages << PAGE_SHIFT);
  248. #ifdef CONFIG_BLK_DEV_INITRD
  249. /*
  250. * If the initrd is in this node, reserve its memory.
  251. */
  252. if (node == initrd_node) {
  253. reserve_bootmem_node(pgdat, phys_initrd_start,
  254. phys_initrd_size);
  255. initrd_start = __phys_to_virt(phys_initrd_start);
  256. initrd_end = initrd_start + phys_initrd_size;
  257. }
  258. #endif
  259. /*
  260. * Finally, reserve any node zero regions.
  261. */
  262. if (node == 0)
  263. reserve_node_zero(pgdat);
  264. /*
  265. * initialise the zones within this node.
  266. */
  267. memset(zone_size, 0, sizeof(zone_size));
  268. memset(zhole_size, 0, sizeof(zhole_size));
  269. /*
  270. * The size of this node has already been determined. If we need
  271. * to do anything fancy with the allocation of this memory to the
  272. * zones, now is the time to do it.
  273. */
  274. zone_size[0] = end_pfn - start_pfn;
  275. /*
  276. * For each bank in this node, calculate the size of the holes.
  277. * holes = node_size - sum(bank_sizes_in_node)
  278. */
  279. zhole_size[0] = zone_size[0];
  280. for_each_nodebank(i, mi, node)
  281. zhole_size[0] -= mi->bank[i].size >> PAGE_SHIFT;
  282. /*
  283. * Adjust the sizes according to any special requirements for
  284. * this machine type.
  285. */
  286. arch_adjust_zones(node, zone_size, zhole_size);
  287. free_area_init_node(node, pgdat, zone_size, start_pfn, zhole_size);
  288. return end_pfn;
  289. }
  290. static void __init bootmem_init(struct meminfo *mi)
  291. {
  292. unsigned long addr, memend_pfn = 0;
  293. int node, initrd_node, i;
  294. /*
  295. * Invalidate the node number for empty or invalid memory banks
  296. */
  297. for (i = 0; i < mi->nr_banks; i++)
  298. if (mi->bank[i].size == 0 || mi->bank[i].node >= MAX_NUMNODES)
  299. mi->bank[i].node = -1;
  300. memcpy(&meminfo, mi, sizeof(meminfo));
  301. /*
  302. * Clear out all the mappings below the kernel image.
  303. */
  304. for (addr = 0; addr < MODULE_START; addr += PGDIR_SIZE)
  305. pmd_clear(pmd_off_k(addr));
  306. #ifdef CONFIG_XIP_KERNEL
  307. /* The XIP kernel is mapped in the module area -- skip over it */
  308. addr = ((unsigned long)&_etext + PGDIR_SIZE - 1) & PGDIR_MASK;
  309. #endif
  310. for ( ; addr < PAGE_OFFSET; addr += PGDIR_SIZE)
  311. pmd_clear(pmd_off_k(addr));
  312. /*
  313. * Clear out all the kernel space mappings, except for the first
  314. * memory bank, up to the end of the vmalloc region.
  315. */
  316. for (addr = __phys_to_virt(mi->bank[0].start + mi->bank[0].size);
  317. addr < VMALLOC_END; addr += PGDIR_SIZE)
  318. pmd_clear(pmd_off_k(addr));
  319. /*
  320. * Locate which node contains the ramdisk image, if any.
  321. */
  322. initrd_node = check_initrd(mi);
  323. /*
  324. * Run through each node initialising the bootmem allocator.
  325. */
  326. for_each_node(node) {
  327. unsigned long end_pfn;
  328. end_pfn = bootmem_init_node(node, initrd_node, mi);
  329. /*
  330. * Remember the highest memory PFN.
  331. */
  332. if (end_pfn > memend_pfn)
  333. memend_pfn = end_pfn;
  334. }
  335. high_memory = __va(memend_pfn << PAGE_SHIFT);
  336. /*
  337. * This doesn't seem to be used by the Linux memory manager any
  338. * more, but is used by ll_rw_block. If we can get rid of it, we
  339. * also get rid of some of the stuff above as well.
  340. *
  341. * Note: max_low_pfn and max_pfn reflect the number of _pages_ in
  342. * the system, not the maximum PFN.
  343. */
  344. max_pfn = max_low_pfn = memend_pfn - PHYS_PFN_OFFSET;
  345. }
  346. /*
  347. * Set up device the mappings. Since we clear out the page tables for all
  348. * mappings above VMALLOC_END, we will remove any debug device mappings.
  349. * This means you have to be careful how you debug this function, or any
  350. * called function. This means you can't use any function or debugging
  351. * method which may touch any device, otherwise the kernel _will_ crash.
  352. */
  353. static void __init devicemaps_init(struct machine_desc *mdesc)
  354. {
  355. struct map_desc map;
  356. unsigned long addr;
  357. void *vectors;
  358. /*
  359. * Allocate the vector page early.
  360. */
  361. vectors = alloc_bootmem_low_pages(PAGE_SIZE);
  362. BUG_ON(!vectors);
  363. for (addr = VMALLOC_END; addr; addr += PGDIR_SIZE)
  364. pmd_clear(pmd_off_k(addr));
  365. /*
  366. * Map the kernel if it is XIP.
  367. * It is always first in the modulearea.
  368. */
  369. #ifdef CONFIG_XIP_KERNEL
  370. map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & PGDIR_MASK);
  371. map.virtual = MODULE_START;
  372. map.length = ((unsigned long)&_etext - map.virtual + ~PGDIR_MASK) & PGDIR_MASK;
  373. map.type = MT_ROM;
  374. create_mapping(&map);
  375. #endif
  376. /*
  377. * Map the cache flushing regions.
  378. */
  379. #ifdef FLUSH_BASE
  380. map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
  381. map.virtual = FLUSH_BASE;
  382. map.length = SZ_1M;
  383. map.type = MT_CACHECLEAN;
  384. create_mapping(&map);
  385. #endif
  386. #ifdef FLUSH_BASE_MINICACHE
  387. map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M);
  388. map.virtual = FLUSH_BASE_MINICACHE;
  389. map.length = SZ_1M;
  390. map.type = MT_MINICLEAN;
  391. create_mapping(&map);
  392. #endif
  393. /*
  394. * Create a mapping for the machine vectors at the high-vectors
  395. * location (0xffff0000). If we aren't using high-vectors, also
  396. * create a mapping at the low-vectors virtual address.
  397. */
  398. map.pfn = __phys_to_pfn(virt_to_phys(vectors));
  399. map.virtual = 0xffff0000;
  400. map.length = PAGE_SIZE;
  401. map.type = MT_HIGH_VECTORS;
  402. create_mapping(&map);
  403. if (!vectors_high()) {
  404. map.virtual = 0;
  405. map.type = MT_LOW_VECTORS;
  406. create_mapping(&map);
  407. }
  408. /*
  409. * Ask the machine support to map in the statically mapped devices.
  410. */
  411. if (mdesc->map_io)
  412. mdesc->map_io();
  413. /*
  414. * Finally flush the caches and tlb to ensure that we're in a
  415. * consistent state wrt the writebuffer. This also ensures that
  416. * any write-allocated cache lines in the vector page are written
  417. * back. After this point, we can start to touch devices again.
  418. */
  419. local_flush_tlb_all();
  420. flush_cache_all();
  421. }
  422. /*
  423. * paging_init() sets up the page tables, initialises the zone memory
  424. * maps, and sets up the zero page, bad page and bad page tables.
  425. */
  426. void __init paging_init(struct meminfo *mi, struct machine_desc *mdesc)
  427. {
  428. void *zero_page;
  429. build_mem_type_table();
  430. bootmem_init(mi);
  431. devicemaps_init(mdesc);
  432. top_pmd = pmd_off_k(0xffff0000);
  433. /*
  434. * allocate the zero page. Note that we count on this going ok.
  435. */
  436. zero_page = alloc_bootmem_low_pages(PAGE_SIZE);
  437. memzero(zero_page, PAGE_SIZE);
  438. empty_zero_page = virt_to_page(zero_page);
  439. flush_dcache_page(empty_zero_page);
  440. }
  441. static inline void free_area(unsigned long addr, unsigned long end, char *s)
  442. {
  443. unsigned int size = (end - addr) >> 10;
  444. for (; addr < end; addr += PAGE_SIZE) {
  445. struct page *page = virt_to_page(addr);
  446. ClearPageReserved(page);
  447. init_page_count(page);
  448. free_page(addr);
  449. totalram_pages++;
  450. }
  451. if (size && s)
  452. printk(KERN_INFO "Freeing %s memory: %dK\n", s, size);
  453. }
  454. static inline void
  455. free_memmap(int node, unsigned long start_pfn, unsigned long end_pfn)
  456. {
  457. struct page *start_pg, *end_pg;
  458. unsigned long pg, pgend;
  459. /*
  460. * Convert start_pfn/end_pfn to a struct page pointer.
  461. */
  462. start_pg = pfn_to_page(start_pfn);
  463. end_pg = pfn_to_page(end_pfn);
  464. /*
  465. * Convert to physical addresses, and
  466. * round start upwards and end downwards.
  467. */
  468. pg = PAGE_ALIGN(__pa(start_pg));
  469. pgend = __pa(end_pg) & PAGE_MASK;
  470. /*
  471. * If there are free pages between these,
  472. * free the section of the memmap array.
  473. */
  474. if (pg < pgend)
  475. free_bootmem_node(NODE_DATA(node), pg, pgend - pg);
  476. }
  477. /*
  478. * The mem_map array can get very big. Free the unused area of the memory map.
  479. */
  480. static void __init free_unused_memmap_node(int node, struct meminfo *mi)
  481. {
  482. unsigned long bank_start, prev_bank_end = 0;
  483. unsigned int i;
  484. /*
  485. * [FIXME] This relies on each bank being in address order. This
  486. * may not be the case, especially if the user has provided the
  487. * information on the command line.
  488. */
  489. for_each_nodebank(i, mi, node) {
  490. bank_start = mi->bank[i].start >> PAGE_SHIFT;
  491. if (bank_start < prev_bank_end) {
  492. printk(KERN_ERR "MEM: unordered memory banks. "
  493. "Not freeing memmap.\n");
  494. break;
  495. }
  496. /*
  497. * If we had a previous bank, and there is a space
  498. * between the current bank and the previous, free it.
  499. */
  500. if (prev_bank_end && prev_bank_end != bank_start)
  501. free_memmap(node, prev_bank_end, bank_start);
  502. prev_bank_end = (mi->bank[i].start +
  503. mi->bank[i].size) >> PAGE_SHIFT;
  504. }
  505. }
  506. /*
  507. * mem_init() marks the free areas in the mem_map and tells us how much
  508. * memory is free. This is done after various parts of the system have
  509. * claimed their memory after the kernel image.
  510. */
  511. void __init mem_init(void)
  512. {
  513. unsigned int codepages, datapages, initpages;
  514. int i, node;
  515. codepages = &_etext - &_text;
  516. datapages = &_end - &__data_start;
  517. initpages = &__init_end - &__init_begin;
  518. #ifndef CONFIG_DISCONTIGMEM
  519. max_mapnr = virt_to_page(high_memory) - mem_map;
  520. #endif
  521. /* this will put all unused low memory onto the freelists */
  522. for_each_online_node(node) {
  523. pg_data_t *pgdat = NODE_DATA(node);
  524. free_unused_memmap_node(node, &meminfo);
  525. if (pgdat->node_spanned_pages != 0)
  526. totalram_pages += free_all_bootmem_node(pgdat);
  527. }
  528. #ifdef CONFIG_SA1111
  529. /* now that our DMA memory is actually so designated, we can free it */
  530. free_area(PAGE_OFFSET, (unsigned long)swapper_pg_dir, NULL);
  531. #endif
  532. /*
  533. * Since our memory may not be contiguous, calculate the
  534. * real number of pages we have in this system
  535. */
  536. printk(KERN_INFO "Memory:");
  537. num_physpages = 0;
  538. for (i = 0; i < meminfo.nr_banks; i++) {
  539. num_physpages += meminfo.bank[i].size >> PAGE_SHIFT;
  540. printk(" %ldMB", meminfo.bank[i].size >> 20);
  541. }
  542. printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
  543. printk(KERN_NOTICE "Memory: %luKB available (%dK code, "
  544. "%dK data, %dK init)\n",
  545. (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
  546. codepages >> 10, datapages >> 10, initpages >> 10);
  547. if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
  548. extern int sysctl_overcommit_memory;
  549. /*
  550. * On a machine this small we won't get
  551. * anywhere without overcommit, so turn
  552. * it on by default.
  553. */
  554. sysctl_overcommit_memory = OVERCOMMIT_ALWAYS;
  555. }
  556. }
  557. void free_initmem(void)
  558. {
  559. if (!machine_is_integrator() && !machine_is_cintegrator()) {
  560. free_area((unsigned long)(&__init_begin),
  561. (unsigned long)(&__init_end),
  562. "init");
  563. }
  564. }
  565. #ifdef CONFIG_BLK_DEV_INITRD
  566. static int keep_initrd;
  567. void free_initrd_mem(unsigned long start, unsigned long end)
  568. {
  569. if (!keep_initrd)
  570. free_area(start, end, "initrd");
  571. }
  572. static int __init keepinitrd_setup(char *__unused)
  573. {
  574. keep_initrd = 1;
  575. return 1;
  576. }
  577. __setup("keepinitrd", keepinitrd_setup);
  578. #endif