init.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * linux/arch/cris/mm/init.c
  3. *
  4. * Copyright (C) 1995 Linus Torvalds
  5. * Copyright (C) 2000,2001 Axis Communications AB
  6. *
  7. * Authors: Bjorn Wesen (bjornw@axis.com)
  8. *
  9. * $Log: init.c,v $
  10. * Revision 1.11 2004/05/28 09:28:56 starvik
  11. * Calculation of loops_per_usec moved because initalization order has changed
  12. * in Linux 2.6.
  13. *
  14. * Revision 1.10 2004/05/14 07:58:05 starvik
  15. * Merge of changes from 2.4
  16. *
  17. * Revision 1.9 2003/07/04 08:27:54 starvik
  18. * Merge of Linux 2.5.74
  19. *
  20. * Revision 1.8 2003/04/09 05:20:48 starvik
  21. * Merge of Linux 2.5.67
  22. *
  23. * Revision 1.7 2003/01/22 06:48:38 starvik
  24. * Fixed warnings issued by GCC 3.2.1
  25. *
  26. * Revision 1.6 2002/12/11 14:44:48 starvik
  27. * Extracted v10 (ETRAX 100LX) specific stuff to arch/cris/arch-v10/mm
  28. *
  29. * Revision 1.5 2002/11/18 07:37:37 starvik
  30. * Added cache bug workaround (from Linux 2.4)
  31. *
  32. * Revision 1.4 2002/11/13 15:40:24 starvik
  33. * Removed the page table cache stuff (as done in other archs)
  34. *
  35. * Revision 1.3 2002/11/05 06:45:13 starvik
  36. * Merge of Linux 2.5.45
  37. *
  38. * Revision 1.2 2001/12/18 13:35:22 bjornw
  39. * Applied the 2.4.13->2.4.16 CRIS patch to 2.5.1 (is a copy of 2.4.15).
  40. *
  41. * Revision 1.31 2001/11/13 16:22:00 bjornw
  42. * Skip calculating totalram and sharedram in si_meminfo
  43. *
  44. * Revision 1.30 2001/11/12 19:02:10 pkj
  45. * Fixed compiler warnings.
  46. *
  47. * Revision 1.29 2001/07/25 16:09:50 bjornw
  48. * val->sharedram will stay 0
  49. *
  50. * Revision 1.28 2001/06/28 16:30:17 bjornw
  51. * Oops. This needs to wait until 2.4.6 is merged
  52. *
  53. * Revision 1.27 2001/06/28 14:04:07 bjornw
  54. * Fill in sharedram
  55. *
  56. * Revision 1.26 2001/06/18 06:36:02 hp
  57. * Enable free_initmem of __init-type pages
  58. *
  59. * Revision 1.25 2001/06/13 00:02:23 bjornw
  60. * Use a separate variable to store the current pgd to avoid races in schedule
  61. *
  62. * Revision 1.24 2001/05/15 00:52:20 hp
  63. * Only map segment 0xa as seg if CONFIG_JULIETTE
  64. *
  65. * Revision 1.23 2001/04/04 14:35:40 bjornw
  66. * * Removed get_pte_slow and friends (2.4.3 change)
  67. * * Removed bad_pmd handling (2.4.3 change)
  68. *
  69. * Revision 1.22 2001/04/04 13:38:04 matsfg
  70. * Moved ioremap to a separate function instead
  71. *
  72. * Revision 1.21 2001/03/27 09:28:33 bjornw
  73. * ioremap used too early - lets try it in mem_init instead
  74. *
  75. * Revision 1.20 2001/03/23 07:39:21 starvik
  76. * Corrected according to review remarks
  77. *
  78. * Revision 1.19 2001/03/15 14:25:17 bjornw
  79. * More general shadow registers and ioremaped addresses for external I/O
  80. *
  81. * Revision 1.18 2001/02/23 12:46:44 bjornw
  82. * * 0xc was not CSE1; 0x8 is, same as uncached flash, so we move the uncached
  83. * flash during CRIS_LOW_MAP from 0xe to 0x8 so both the flash and the I/O
  84. * is mapped straight over (for !CRIS_LOW_MAP the uncached flash is still 0xe)
  85. *
  86. * Revision 1.17 2001/02/22 15:05:21 bjornw
  87. * Map 0x9 straight over during LOW_MAP to allow for memory mapped LEDs
  88. *
  89. * Revision 1.16 2001/02/22 15:02:35 bjornw
  90. * Map 0xc straight over during LOW_MAP to allow for memory mapped I/O
  91. *
  92. * Revision 1.15 2001/01/10 21:12:10 bjornw
  93. * loops_per_sec -> loops_per_jiffy
  94. *
  95. * Revision 1.14 2000/11/22 16:23:20 bjornw
  96. * Initialize totalhigh counters to 0 to make /proc/meminfo look nice.
  97. *
  98. * Revision 1.13 2000/11/21 16:37:51 bjornw
  99. * Temporarily disable initmem freeing
  100. *
  101. * Revision 1.12 2000/11/21 13:55:07 bjornw
  102. * Use CONFIG_CRIS_LOW_MAP for the low VM map instead of explicit CPU type
  103. *
  104. * Revision 1.11 2000/10/06 12:38:22 bjornw
  105. * Cast empty_bad_page correctly (should really be of * type from the start..
  106. *
  107. * Revision 1.10 2000/10/04 16:53:57 bjornw
  108. * Fix memory-map due to LX features
  109. *
  110. * Revision 1.9 2000/09/13 15:47:49 bjornw
  111. * Wrong count in reserved-pages loop
  112. *
  113. * Revision 1.8 2000/09/13 14:35:10 bjornw
  114. * 2.4.0-test8 added a new arg to free_area_init_node
  115. *
  116. * Revision 1.7 2000/08/17 15:35:55 bjornw
  117. * 2.4.0-test6 removed MAP_NR and inserted virt_to_page
  118. *
  119. *
  120. */
  121. #include <linux/init.h>
  122. #include <linux/bootmem.h>
  123. #include <asm/tlb.h>
  124. DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
  125. unsigned long empty_zero_page;
  126. extern char _stext, _edata, _etext; /* From linkerscript */
  127. extern char __init_begin, __init_end;
  128. void
  129. show_mem(void)
  130. {
  131. int i,free = 0,total = 0,cached = 0, reserved = 0, nonshared = 0;
  132. int shared = 0;
  133. printk("\nMem-info:\n");
  134. show_free_areas();
  135. printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
  136. i = max_mapnr;
  137. while (i-- > 0) {
  138. total++;
  139. if (PageReserved(mem_map+i))
  140. reserved++;
  141. else if (PageSwapCache(mem_map+i))
  142. cached++;
  143. else if (!page_count(mem_map+i))
  144. free++;
  145. else if (page_count(mem_map+i) == 1)
  146. nonshared++;
  147. else
  148. shared += page_count(mem_map+i) - 1;
  149. }
  150. printk("%d pages of RAM\n",total);
  151. printk("%d free pages\n",free);
  152. printk("%d reserved pages\n",reserved);
  153. printk("%d pages nonshared\n",nonshared);
  154. printk("%d pages shared\n",shared);
  155. printk("%d pages swap cached\n",cached);
  156. }
  157. void __init
  158. mem_init(void)
  159. {
  160. int codesize, reservedpages, datasize, initsize;
  161. unsigned long tmp;
  162. if(!mem_map)
  163. BUG();
  164. /* max/min_low_pfn was set by setup.c
  165. * now we just copy it to some other necessary places...
  166. *
  167. * high_memory was also set in setup.c
  168. */
  169. max_mapnr = num_physpages = max_low_pfn - min_low_pfn;
  170. /* this will put all memory onto the freelists */
  171. totalram_pages = free_all_bootmem();
  172. reservedpages = 0;
  173. for (tmp = 0; tmp < max_mapnr; tmp++) {
  174. /*
  175. * Only count reserved RAM pages
  176. */
  177. if (PageReserved(mem_map + tmp))
  178. reservedpages++;
  179. }
  180. codesize = (unsigned long) &_etext - (unsigned long) &_stext;
  181. datasize = (unsigned long) &_edata - (unsigned long) &_etext;
  182. initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
  183. printk(KERN_INFO
  184. "Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk data, "
  185. "%dk init)\n" ,
  186. (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
  187. max_mapnr << (PAGE_SHIFT-10),
  188. codesize >> 10,
  189. reservedpages << (PAGE_SHIFT-10),
  190. datasize >> 10,
  191. initsize >> 10
  192. );
  193. }
  194. /* free the pages occupied by initialization code */
  195. void
  196. free_initmem(void)
  197. {
  198. unsigned long addr;
  199. addr = (unsigned long)(&__init_begin);
  200. for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
  201. ClearPageReserved(virt_to_page(addr));
  202. set_page_count(virt_to_page(addr), 1);
  203. free_page(addr);
  204. totalram_pages++;
  205. }
  206. printk (KERN_INFO "Freeing unused kernel memory: %luk freed\n",
  207. (unsigned long)((&__init_end - &__init_begin) >> 10));
  208. }