init.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * linux/arch/m68k/mm/init.c
  3. *
  4. * Copyright (C) 1995 Hamish Macdonald
  5. *
  6. * Contains common initialization routines, specific init code moved
  7. * to motorola.c and sun3mmu.c
  8. */
  9. #include <linux/module.h>
  10. #include <linux/signal.h>
  11. #include <linux/sched.h>
  12. #include <linux/mm.h>
  13. #include <linux/swap.h>
  14. #include <linux/kernel.h>
  15. #include <linux/string.h>
  16. #include <linux/types.h>
  17. #include <linux/init.h>
  18. #include <linux/bootmem.h>
  19. #include <linux/gfp.h>
  20. #include <asm/setup.h>
  21. #include <asm/uaccess.h>
  22. #include <asm/page.h>
  23. #include <asm/pgalloc.h>
  24. #include <asm/traps.h>
  25. #include <asm/machdep.h>
  26. #include <asm/io.h>
  27. #ifdef CONFIG_ATARI
  28. #include <asm/atari_stram.h>
  29. #endif
  30. #include <asm/sections.h>
  31. #include <asm/tlb.h>
  32. /*
  33. * ZERO_PAGE is a special page that is used for zero-initialized
  34. * data and COW.
  35. */
  36. void *empty_zero_page;
  37. EXPORT_SYMBOL(empty_zero_page);
  38. #if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
  39. extern void init_pointer_table(unsigned long ptable);
  40. extern pmd_t *zero_pgtable;
  41. #endif
  42. #ifdef CONFIG_MMU
  43. pg_data_t pg_data_map[MAX_NUMNODES];
  44. EXPORT_SYMBOL(pg_data_map);
  45. int m68k_virt_to_node_shift;
  46. #ifndef CONFIG_SINGLE_MEMORY_CHUNK
  47. pg_data_t *pg_data_table[65];
  48. EXPORT_SYMBOL(pg_data_table);
  49. #endif
  50. void __init m68k_setup_node(int node)
  51. {
  52. #ifndef CONFIG_SINGLE_MEMORY_CHUNK
  53. struct m68k_mem_info *info = m68k_memory + node;
  54. int i, end;
  55. i = (unsigned long)phys_to_virt(info->addr) >> __virt_to_node_shift();
  56. end = (unsigned long)phys_to_virt(info->addr + info->size - 1) >> __virt_to_node_shift();
  57. for (; i <= end; i++) {
  58. if (pg_data_table[i])
  59. printk("overlap at %u for chunk %u\n", i, node);
  60. pg_data_table[i] = pg_data_map + node;
  61. }
  62. #endif
  63. pg_data_map[node].bdata = bootmem_node_data + node;
  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. void __init print_memmap(void)
  103. {
  104. #define UL(x) ((unsigned long) (x))
  105. #define MLK(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 10
  106. #define MLM(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 20
  107. #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), 1024)
  108. pr_notice("Virtual kernel memory layout:\n"
  109. " vector : 0x%08lx - 0x%08lx (%4ld KiB)\n"
  110. " kmap : 0x%08lx - 0x%08lx (%4ld MiB)\n"
  111. " vmalloc : 0x%08lx - 0x%08lx (%4ld MiB)\n"
  112. " lowmem : 0x%08lx - 0x%08lx (%4ld MiB)\n"
  113. " .init : 0x%p" " - 0x%p" " (%4d KiB)\n"
  114. " .text : 0x%p" " - 0x%p" " (%4d KiB)\n"
  115. " .data : 0x%p" " - 0x%p" " (%4d KiB)\n"
  116. " .bss : 0x%p" " - 0x%p" " (%4d KiB)\n",
  117. MLK(VECTORS, VECTORS + 256),
  118. MLM(KMAP_START, KMAP_END),
  119. MLM(VMALLOC_START, VMALLOC_END),
  120. MLM(PAGE_OFFSET, (unsigned long)high_memory),
  121. MLK_ROUNDUP(__init_begin, __init_end),
  122. MLK_ROUNDUP(_stext, _etext),
  123. MLK_ROUNDUP(_sdata, _edata),
  124. MLK_ROUNDUP(__bss_start, __bss_stop));
  125. }
  126. static inline void init_pointer_tables(void)
  127. {
  128. #if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
  129. int i;
  130. /* insert pointer tables allocated so far into the tablelist */
  131. init_pointer_table((unsigned long)kernel_pg_dir);
  132. for (i = 0; i < PTRS_PER_PGD; i++) {
  133. if (pgd_present(kernel_pg_dir[i]))
  134. init_pointer_table(__pgd_page(kernel_pg_dir[i]));
  135. }
  136. /* insert also pointer table that we used to unmap the zero page */
  137. if (zero_pgtable)
  138. init_pointer_table((unsigned long)zero_pgtable);
  139. #endif
  140. }
  141. void __init mem_init(void)
  142. {
  143. /* this will put all memory onto the freelists */
  144. free_all_bootmem();
  145. init_pointer_tables();
  146. mem_init_print_info(NULL);
  147. print_memmap();
  148. }
  149. #ifdef CONFIG_BLK_DEV_INITRD
  150. void free_initrd_mem(unsigned long start, unsigned long end)
  151. {
  152. free_reserved_area((void *)start, (void *)end, -1, "initrd");
  153. }
  154. #endif