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