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