Import 2.3.50pre1
[davej-history.git] / arch / m68k / mm / sun3mmu.c
blob8d6632d2f541af05e3d1153d84778b2436274fe2
1 /*
2 * linux/arch/m68k/mm/sun3mmu.c
4 * Implementations of mm routines specific to the sun3 MMU.
6 * Moved here 8/20/1999 Sam Creasey
8 */
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
23 #include <asm/setup.h>
24 #include <asm/uaccess.h>
25 #include <asm/page.h>
26 #include <asm/pgtable.h>
27 #include <asm/system.h>
28 #include <asm/machdep.h>
29 #include <asm/io.h>
31 extern void mmu_emu_init (void);
33 extern unsigned long free_area_init(unsigned long *zones_size);
35 const char bad_pmd_string[] = "Bad pmd in pte_alloc: %08lx\n";
37 extern unsigned long empty_bad_page_table;
38 extern unsigned long empty_bad_page;
40 void free_initmem(void)
43 /* For the sun3 we try to follow the i386 paging_init() more closely */
44 /* start_mem and end_mem have PAGE_OFFSET added already */
45 /* now sets up tables using sun3 PTEs rather than i386 as before. --m */
46 unsigned long __init paging_init(unsigned long start_mem,
47 unsigned long end_mem)
49 pgd_t * pg_dir;
50 pte_t * pg_table;
51 int i;
52 unsigned long address;
54 #ifdef TEST_VERIFY_AREA
55 wp_works_ok = 0;
56 #endif
57 start_mem = PAGE_ALIGN(start_mem);
58 empty_bad_page_table = start_mem;
59 start_mem += PAGE_SIZE;
60 empty_bad_page = start_mem;
61 start_mem += PAGE_SIZE;
62 empty_zero_page = start_mem;
63 start_mem += PAGE_SIZE;
64 memset((void *)empty_zero_page, 0, PAGE_SIZE);
66 address = PAGE_OFFSET;
67 pg_dir = swapper_pg_dir;
68 memset (swapper_pg_dir, 0, sizeof (swapper_pg_dir));
69 memset (kernel_pg_dir, 0, sizeof (kernel_pg_dir));
71 /* Map whole memory from PAGE_OFFSET (0x0E000000) */
72 pg_dir += PAGE_OFFSET >> PGDIR_SHIFT;
74 while (address < end_mem) {
75 pg_table = (pte_t *) __pa (start_mem);
76 start_mem += PTRS_PER_PTE * sizeof (pte_t);
77 pgd_val(*pg_dir) = (unsigned long) pg_table;
78 pg_dir++;
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 = __mk_pte(address, PAGE_INIT);
84 if (address >= end_mem)
85 pte_val (pte) = 0;
86 set_pte (pg_table, pte);
87 address += PAGE_SIZE;
91 mmu_emu_init();
93 current->mm = NULL;
95 return PAGE_ALIGN(free_area_init(start_mem, end_mem));