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