init.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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/bootmem.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. #if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
  40. extern void init_pointer_table(unsigned long ptable);
  41. extern pmd_t *zero_pgtable;
  42. #endif
  43. #ifdef CONFIG_MMU
  44. pg_data_t pg_data_map[MAX_NUMNODES];
  45. EXPORT_SYMBOL(pg_data_map);
  46. int m68k_virt_to_node_shift;
  47. #ifndef CONFIG_SINGLE_MEMORY_CHUNK
  48. pg_data_t *pg_data_table[65];
  49. EXPORT_SYMBOL(pg_data_table);
  50. #endif
  51. void __init m68k_setup_node(int node)
  52. {
  53. #ifndef CONFIG_SINGLE_MEMORY_CHUNK
  54. struct m68k_mem_info *info = m68k_memory + node;
  55. int i, end;
  56. i = (unsigned long)phys_to_virt(info->addr) >> __virt_to_node_shift();
  57. end = (unsigned long)phys_to_virt(info->addr + info->size - 1) >> __virt_to_node_shift();
  58. for (; i <= end; i++) {
  59. if (pg_data_table[i])
  60. pr_warn("overlap at %u for chunk %u\n", i, node);
  61. pg_data_table[i] = pg_data_map + node;
  62. }
  63. #endif
  64. node_set_online(node);
  65. }
  66. #else /* CONFIG_MMU */
  67. /*
  68. * paging_init() continues the virtual memory environment setup which
  69. * was begun by the code in arch/head.S.
  70. * The parameters are pointers to where to stick the starting and ending
  71. * addresses of available kernel virtual memory.
  72. */
  73. void __init paging_init(void)
  74. {
  75. /*
  76. * Make sure start_mem is page aligned, otherwise bootmem and
  77. * page_alloc get different views of the world.
  78. */
  79. unsigned long end_mem = memory_end & PAGE_MASK;
  80. unsigned long zones_size[MAX_NR_ZONES] = { 0, };
  81. high_memory = (void *) end_mem;
  82. empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
  83. /*
  84. * Set up SFC/DFC registers (user data space).
  85. */
  86. set_fs (USER_DS);
  87. zones_size[ZONE_DMA] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;
  88. free_area_init(zones_size);
  89. }
  90. #endif /* CONFIG_MMU */
  91. void free_initmem(void)
  92. {
  93. #ifndef CONFIG_MMU_SUN3
  94. free_initmem_default(-1);
  95. #endif /* CONFIG_MMU_SUN3 */
  96. }
  97. #if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
  98. #define VECTORS &vectors[0]
  99. #else
  100. #define VECTORS _ramvec
  101. #endif
  102. static inline void init_pointer_tables(void)
  103. {
  104. #if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
  105. int i;
  106. /* insert pointer tables allocated so far into the tablelist */
  107. init_pointer_table((unsigned long)kernel_pg_dir);
  108. for (i = 0; i < PTRS_PER_PGD; i++) {
  109. if (pgd_present(kernel_pg_dir[i]))
  110. init_pointer_table(__pgd_page(kernel_pg_dir[i]));
  111. }
  112. /* insert also pointer table that we used to unmap the zero page */
  113. if (zero_pgtable)
  114. init_pointer_table((unsigned long)zero_pgtable);
  115. #endif
  116. }
  117. void __init mem_init(void)
  118. {
  119. /* this will put all memory onto the freelists */
  120. free_all_bootmem();
  121. init_pointer_tables();
  122. mem_init_print_info(NULL);
  123. }
  124. #ifdef CONFIG_BLK_DEV_INITRD
  125. void free_initrd_mem(unsigned long start, unsigned long end)
  126. {
  127. free_reserved_area((void *)start, (void *)end, -1, "initrd");
  128. }
  129. #endif