patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / arch / m68k / mm / sun3mmu.c
1 /*
2  * linux/arch/m68k/mm/sun3mmu.c
3  *
4  * Implementations of mm routines specific to the sun3 MMU.
5  *
6  * Moved here 8/20/1999 Sam Creasey
7  *
8  */
9
10 #include <linux/config.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
21 #include <asm/setup.h>
22 #include <asm/uaccess.h>
23 #include <asm/page.h>
24 #include <asm/pgtable.h>
25 #include <asm/system.h>
26 #include <asm/machdep.h>
27 #include <asm/io.h>
28
29 extern void mmu_emu_init (unsigned long bootmem_end);
30
31 const char bad_pmd_string[] = "Bad pmd in pte_alloc: %08lx\n";
32
33 extern unsigned long num_pages;
34
35 void free_initmem(void)
36 {
37 }
38
39 /* For the sun3 we try to follow the i386 paging_init() more closely */
40 /* start_mem and end_mem have PAGE_OFFSET added already */
41 /* now sets up tables using sun3 PTEs rather than i386 as before. --m */
42 void __init paging_init(void)
43 {
44         pgd_t * pg_dir;
45         pte_t * pg_table;
46         int i;
47         unsigned long address;
48         unsigned long next_pgtable;
49         unsigned long bootmem_end;
50         unsigned long zones_size[3] = {0, 0, 0};
51         unsigned long size;
52
53
54 #ifdef TEST_VERIFY_AREA
55         wp_works_ok = 0;
56 #endif
57         empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
58         memset(empty_zero_page, 0, PAGE_SIZE);
59
60         address = PAGE_OFFSET;
61         pg_dir = swapper_pg_dir;
62         memset (swapper_pg_dir, 0, sizeof (swapper_pg_dir));
63         memset (kernel_pg_dir,  0, sizeof (kernel_pg_dir));
64
65         size = num_pages * sizeof(pte_t);
66         size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1);
67
68         next_pgtable = (unsigned long)alloc_bootmem_pages(size);
69         bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK;
70
71         /* Map whole memory from PAGE_OFFSET (0x0E000000) */
72         pg_dir += PAGE_OFFSET >> PGDIR_SHIFT;
73
74         while (address < (unsigned long)high_memory) {
75                 pg_table = (pte_t *) __pa (next_pgtable);
76                 next_pgtable += PTRS_PER_PTE * sizeof (pte_t);
77                 pgd_val(*pg_dir) = (unsigned long) pg_table;
78                 pg_dir++;
79
80                 /* now change pg_table to kernel virtual addresses */
81                 pg_table = (pte_t *) __va ((unsigned long) pg_table);
82                 for (i=0; i<PTRS_PER_PTE; ++i, ++pg_table) {
83                         pte_t pte = pfn_pte(virt_to_pfn(address), PAGE_INIT);
84                         if (address >= (unsigned long)high_memory)
85                                 pte_val (pte) = 0;
86                         set_pte (pg_table, pte);
87                         address += PAGE_SIZE;
88                 }
89         }
90
91         mmu_emu_init(bootmem_end);
92
93         current->mm = NULL;
94
95         /* memory sizing is a hack stolen from motorola.c..  hope it works for us */
96         zones_size[0] = ((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
97         zones_size[1] = 0;
98
99         free_area_init(zones_size);
100
101 }
102
103