init.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2012 Regents of the University of California
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/mm.h>
  15. #include <linux/memblock.h>
  16. #include <linux/initrd.h>
  17. #include <linux/swap.h>
  18. #include <linux/sizes.h>
  19. #include <asm/tlbflush.h>
  20. #include <asm/sections.h>
  21. #include <asm/pgtable.h>
  22. #include <asm/io.h>
  23. static void __init zone_sizes_init(void)
  24. {
  25. unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
  26. #ifdef CONFIG_ZONE_DMA32
  27. max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, max_low_pfn));
  28. #endif
  29. max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
  30. free_area_init_nodes(max_zone_pfns);
  31. }
  32. void setup_zero_page(void)
  33. {
  34. memset((void *)empty_zero_page, 0, PAGE_SIZE);
  35. }
  36. void __init paging_init(void)
  37. {
  38. setup_zero_page();
  39. local_flush_tlb_all();
  40. zone_sizes_init();
  41. }
  42. void __init mem_init(void)
  43. {
  44. #ifdef CONFIG_FLATMEM
  45. BUG_ON(!mem_map);
  46. #endif /* CONFIG_FLATMEM */
  47. high_memory = (void *)(__va(PFN_PHYS(max_low_pfn)));
  48. memblock_free_all();
  49. mem_init_print_info(NULL);
  50. }
  51. void free_initmem(void)
  52. {
  53. free_initmem_default(0);
  54. }
  55. #ifdef CONFIG_BLK_DEV_INITRD
  56. void free_initrd_mem(unsigned long start, unsigned long end)
  57. {
  58. }
  59. #endif /* CONFIG_BLK_DEV_INITRD */