init.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/arch/m68k/mm/init.c
  4. *
  5. * Copyright (C) 1995 Hamish Macdonald
  6. *
  7. * Contains common initialization routines, specific init code moved
  8. * to motorola.c and sun3mmu.c
  9. */
  10. #include <linux/module.h>
  11. #include <linux/signal.h>
  12. #include <linux/sched.h>
  13. #include <linux/mm.h>
  14. #include <linux/swap.h>
  15. #include <linux/kernel.h>
  16. #include <linux/string.h>
  17. #include <linux/types.h>
  18. #include <linux/init.h>
  19. #include <linux/memblock.h>
  20. #include <linux/gfp.h>
  21. #include <asm/setup.h>
  22. #include <linux/uaccess.h>
  23. #include <asm/page.h>
  24. #include <asm/pgalloc.h>
  25. #include <asm/traps.h>
  26. #include <asm/machdep.h>
  27. #include <asm/io.h>
  28. #ifdef CONFIG_ATARI
  29. #include <asm/atari_stram.h>
  30. #endif
  31. #include <asm/sections.h>
  32. #include <asm/tlb.h>
  33. /*
  34. * ZERO_PAGE is a special page that is used for zero-initialized
  35. * data and COW.
  36. */
  37. void *empty_zero_page;
  38. EXPORT_SYMBOL(empty_zero_page);
  39. #ifdef CONFIG_MMU
  40. int m68k_virt_to_node_shift;
  41. void __init m68k_setup_node(int node)
  42. {
  43. node_set_online(node);
  44. }
  45. #else /* CONFIG_MMU */
  46. /*
  47. * paging_init() continues the virtual memory environment setup which
  48. * was begun by the code in arch/head.S.
  49. * The parameters are pointers to where to stick the starting and ending
  50. * addresses of available kernel virtual memory.
  51. */
  52. void __init paging_init(void)
  53. {
  54. /*
  55. * Make sure start_mem is page aligned, otherwise bootmem and
  56. * page_alloc get different views of the world.
  57. */
  58. unsigned long end_mem = memory_end & PAGE_MASK;
  59. unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, };
  60. high_memory = (void *) end_mem;
  61. empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
  62. if (!empty_zero_page)
  63. panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
  64. __func__, PAGE_SIZE, PAGE_SIZE);
  65. max_zone_pfn[ZONE_DMA] = end_mem >> PAGE_SHIFT;
  66. free_area_init(max_zone_pfn);
  67. }
  68. #endif /* CONFIG_MMU */
  69. void free_initmem(void)
  70. {
  71. #ifndef CONFIG_MMU_SUN3
  72. free_initmem_default(-1);
  73. #endif /* CONFIG_MMU_SUN3 */
  74. }
  75. #if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
  76. #define VECTORS &vectors[0]
  77. #else
  78. #define VECTORS _ramvec
  79. #endif
  80. static inline void init_pointer_tables(void)
  81. {
  82. #if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
  83. int i, j;
  84. /* insert pointer tables allocated so far into the tablelist */
  85. init_pointer_table(kernel_pg_dir, TABLE_PGD);
  86. for (i = 0; i < PTRS_PER_PGD; i++) {
  87. pud_t *pud = (pud_t *)&kernel_pg_dir[i];
  88. pmd_t *pmd_dir;
  89. if (!pud_present(*pud))
  90. continue;
  91. pmd_dir = (pmd_t *)pgd_page_vaddr(kernel_pg_dir[i]);
  92. init_pointer_table(pmd_dir, TABLE_PMD);
  93. for (j = 0; j < PTRS_PER_PMD; j++) {
  94. pmd_t *pmd = &pmd_dir[j];
  95. pte_t *pte_dir;
  96. if (!pmd_present(*pmd))
  97. continue;
  98. pte_dir = (pte_t *)pmd_page_vaddr(*pmd);
  99. init_pointer_table(pte_dir, TABLE_PTE);
  100. }
  101. }
  102. #endif
  103. }
  104. void __init mem_init(void)
  105. {
  106. /* this will put all memory onto the freelists */
  107. memblock_free_all();
  108. init_pointer_tables();
  109. }