init.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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/config.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 <asm/setup.h>
  20. #include <asm/uaccess.h>
  21. #include <asm/page.h>
  22. #include <asm/pgalloc.h>
  23. #include <asm/system.h>
  24. #include <asm/machdep.h>
  25. #include <asm/io.h>
  26. #ifdef CONFIG_ATARI
  27. #include <asm/atari_stram.h>
  28. #endif
  29. #include <asm/tlb.h>
  30. DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
  31. /*
  32. * ZERO_PAGE is a special page that is used for zero-initialized
  33. * data and COW.
  34. */
  35. void *empty_zero_page;
  36. void show_mem(void)
  37. {
  38. unsigned long i;
  39. int free = 0, total = 0, reserved = 0, shared = 0;
  40. int cached = 0;
  41. printk("\nMem-info:\n");
  42. show_free_areas();
  43. printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
  44. i = max_mapnr;
  45. while (i-- > 0) {
  46. total++;
  47. if (PageReserved(mem_map+i))
  48. reserved++;
  49. else if (PageSwapCache(mem_map+i))
  50. cached++;
  51. else if (!page_count(mem_map+i))
  52. free++;
  53. else
  54. shared += page_count(mem_map+i) - 1;
  55. }
  56. printk("%d pages of RAM\n",total);
  57. printk("%d free pages\n",free);
  58. printk("%d reserved pages\n",reserved);
  59. printk("%d pages shared\n",shared);
  60. printk("%d pages swap cached\n",cached);
  61. }
  62. extern void init_pointer_table(unsigned long ptable);
  63. /* References to section boundaries */
  64. extern char _text, _etext, _edata, __bss_start, _end;
  65. extern char __init_begin, __init_end;
  66. extern pmd_t *zero_pgtable;
  67. void __init mem_init(void)
  68. {
  69. int codepages = 0;
  70. int datapages = 0;
  71. int initpages = 0;
  72. unsigned long tmp;
  73. #ifndef CONFIG_SUN3
  74. int i;
  75. #endif
  76. max_mapnr = num_physpages = (((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT);
  77. #ifdef CONFIG_ATARI
  78. if (MACH_IS_ATARI)
  79. atari_stram_mem_init_hook();
  80. #endif
  81. /* this will put all memory onto the freelists */
  82. totalram_pages = free_all_bootmem();
  83. for (tmp = PAGE_OFFSET ; tmp < (unsigned long)high_memory; tmp += PAGE_SIZE) {
  84. if (PageReserved(virt_to_page(tmp))) {
  85. if (tmp >= (unsigned long)&_text
  86. && tmp < (unsigned long)&_etext)
  87. codepages++;
  88. else if (tmp >= (unsigned long) &__init_begin
  89. && tmp < (unsigned long) &__init_end)
  90. initpages++;
  91. else
  92. datapages++;
  93. continue;
  94. }
  95. }
  96. #ifndef CONFIG_SUN3
  97. /* insert pointer tables allocated so far into the tablelist */
  98. init_pointer_table((unsigned long)kernel_pg_dir);
  99. for (i = 0; i < PTRS_PER_PGD; i++) {
  100. if (pgd_present(kernel_pg_dir[i]))
  101. init_pointer_table(__pgd_page(kernel_pg_dir[i]));
  102. }
  103. /* insert also pointer table that we used to unmap the zero page */
  104. if (zero_pgtable)
  105. init_pointer_table((unsigned long)zero_pgtable);
  106. #endif
  107. printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n",
  108. (unsigned long)nr_free_pages() << (PAGE_SHIFT-10),
  109. max_mapnr << (PAGE_SHIFT-10),
  110. codepages << (PAGE_SHIFT-10),
  111. datapages << (PAGE_SHIFT-10),
  112. initpages << (PAGE_SHIFT-10));
  113. }
  114. #ifdef CONFIG_BLK_DEV_INITRD
  115. void free_initrd_mem(unsigned long start, unsigned long end)
  116. {
  117. int pages = 0;
  118. for (; start < end; start += PAGE_SIZE) {
  119. ClearPageReserved(virt_to_page(start));
  120. set_page_count(virt_to_page(start), 1);
  121. free_page(start);
  122. totalram_pages++;
  123. pages++;
  124. }
  125. printk ("Freeing initrd memory: %dk freed\n", pages);
  126. }
  127. #endif