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
10 #include <linux/config.h>
11 #include <linux/signal.h>
12 #include <linux/sched.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>
22 #include <linux/bootmem.h>
24 #include <asm/setup.h>
25 #include <asm/uaccess.h>
27 #include <asm/pgtable.h>
28 #include <asm/system.h>
29 #include <asm/machdep.h>
32 extern void mmu_emu_init (unsigned long bootmem_end
);
34 const char bad_pmd_string
[] = "Bad pmd in pte_alloc: %08lx\n";
36 extern unsigned long empty_bad_page_table
;
37 extern unsigned long empty_bad_page
;
38 extern unsigned long num_pages
;
40 void free_initmem(void)
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 */
47 void __init
paging_init(void)
52 unsigned long address
;
53 unsigned long next_pgtable
;
54 unsigned long bootmem_end
;
55 unsigned long zones_size
[3] = {0, 0, 0};
59 #ifdef TEST_VERIFY_AREA
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
);
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
));
72 size
= num_pages
* sizeof(pte_t
);
73 size
= (size
+ PAGE_SIZE
) & ~(PAGE_SIZE
-1);
75 next_pgtable
= (unsigned long)alloc_bootmem_pages(size
);
76 bootmem_end
= (next_pgtable
+ size
+ PAGE_SIZE
) & PAGE_MASK
;
78 /* Map whole memory from PAGE_OFFSET (0x0E000000) */
79 pg_dir
+= PAGE_OFFSET
>> PGDIR_SHIFT
;
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
;
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
)
93 set_pte (pg_table
, pte
);
98 mmu_emu_init(bootmem_end
);
102 /* memory sizing is a hack stolen from motorola.c.. hope it works for us */
103 zones_size
[1] = ((unsigned long)high_memory
- PAGE_OFFSET
) >> PAGE_SHIFT
;
104 zones_size
[0] = zones_size
[1]/2;
105 zones_size
[1] -= zones_size
[0];
107 free_area_init(zones_size
);