init.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * arch/score/mm/init.c
  3. *
  4. * Score Processor version.
  5. *
  6. * Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
  7. * Lennox Wu <lennox.wu@sunplusct.com>
  8. * Chen Liqin <liqin.chen@sunplusct.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, see the file COPYING, or write
  22. * to the Free Software Foundation, Inc.,
  23. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  24. */
  25. #include <linux/errno.h>
  26. #include <linux/bootmem.h>
  27. #include <linux/kernel.h>
  28. #include <linux/gfp.h>
  29. #include <linux/init.h>
  30. #include <linux/mm.h>
  31. #include <linux/mman.h>
  32. #include <linux/pagemap.h>
  33. #include <linux/kcore.h>
  34. #include <linux/sched.h>
  35. #include <linux/initrd.h>
  36. #include <asm/sections.h>
  37. #include <asm/tlb.h>
  38. unsigned long empty_zero_page;
  39. EXPORT_SYMBOL_GPL(empty_zero_page);
  40. static void setup_zero_page(void)
  41. {
  42. struct page *page;
  43. empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, 0);
  44. if (!empty_zero_page)
  45. panic("Oh boy, that early out of memory?");
  46. page = virt_to_page((void *) empty_zero_page);
  47. mark_page_reserved(page);
  48. }
  49. #ifndef CONFIG_NEED_MULTIPLE_NODES
  50. int page_is_ram(unsigned long pagenr)
  51. {
  52. if (pagenr >= min_low_pfn && pagenr < max_low_pfn)
  53. return 1;
  54. else
  55. return 0;
  56. }
  57. void __init paging_init(void)
  58. {
  59. unsigned long max_zone_pfns[MAX_NR_ZONES];
  60. unsigned long lastpfn;
  61. pagetable_init();
  62. max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
  63. lastpfn = max_low_pfn;
  64. free_area_init_nodes(max_zone_pfns);
  65. }
  66. void __init mem_init(void)
  67. {
  68. high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
  69. free_all_bootmem();
  70. setup_zero_page(); /* Setup zeroed pages. */
  71. mem_init_print_info(NULL);
  72. }
  73. #endif /* !CONFIG_NEED_MULTIPLE_NODES */
  74. #ifdef CONFIG_BLK_DEV_INITRD
  75. void free_initrd_mem(unsigned long start, unsigned long end)
  76. {
  77. free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
  78. "initrd");
  79. }
  80. #endif
  81. void __ref free_initmem(void)
  82. {
  83. free_initmem_default(POISON_FREE_INITMEM);
  84. }
  85. unsigned long pgd_current;
  86. #define __page_aligned(order) __attribute__((__aligned__(PAGE_SIZE<<order)))
  87. /*
  88. * gcc 3.3 and older have trouble determining that PTRS_PER_PGD and PGD_ORDER
  89. * are constants. So we use the variants from asm-offset.h until that gcc
  90. * will officially be retired.
  91. */
  92. pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned(PTE_ORDER);
  93. pte_t invalid_pte_table[PTRS_PER_PTE] __page_aligned(PTE_ORDER);