sun3mmu.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #include <linux/signal.h>
  11. #include <linux/sched.h>
  12. #include <linux/mm.h>
  13. #include <linux/swap.h>
  14. #include <linux/kernel.h>
  15. #include <linux/string.h>
  16. #include <linux/types.h>
  17. #include <linux/init.h>
  18. #include <linux/bootmem.h>
  19. #include <asm/setup.h>
  20. #include <linux/uaccess.h>
  21. #include <asm/page.h>
  22. #include <asm/pgtable.h>
  23. #include <asm/machdep.h>
  24. #include <asm/io.h>
  25. extern void mmu_emu_init (unsigned long bootmem_end);
  26. const char bad_pmd_string[] = "Bad pmd in pte_alloc: %08lx\n";
  27. extern unsigned long num_pages;
  28. /* For the sun3 we try to follow the i386 paging_init() more closely */
  29. /* start_mem and end_mem have PAGE_OFFSET added already */
  30. /* now sets up tables using sun3 PTEs rather than i386 as before. --m */
  31. void __init paging_init(void)
  32. {
  33. pgd_t * pg_dir;
  34. pte_t * pg_table;
  35. int i;
  36. unsigned long address;
  37. unsigned long next_pgtable;
  38. unsigned long bootmem_end;
  39. unsigned long zones_size[MAX_NR_ZONES] = { 0, };
  40. unsigned long size;
  41. empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
  42. address = PAGE_OFFSET;
  43. pg_dir = swapper_pg_dir;
  44. memset (swapper_pg_dir, 0, sizeof (swapper_pg_dir));
  45. memset (kernel_pg_dir, 0, sizeof (kernel_pg_dir));
  46. size = num_pages * sizeof(pte_t);
  47. size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1);
  48. next_pgtable = (unsigned long)alloc_bootmem_pages(size);
  49. bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK;
  50. /* Map whole memory from PAGE_OFFSET (0x0E000000) */
  51. pg_dir += PAGE_OFFSET >> PGDIR_SHIFT;
  52. while (address < (unsigned long)high_memory) {
  53. pg_table = (pte_t *) __pa (next_pgtable);
  54. next_pgtable += PTRS_PER_PTE * sizeof (pte_t);
  55. pgd_val(*pg_dir) = (unsigned long) pg_table;
  56. pg_dir++;
  57. /* now change pg_table to kernel virtual addresses */
  58. pg_table = (pte_t *) __va ((unsigned long) pg_table);
  59. for (i=0; i<PTRS_PER_PTE; ++i, ++pg_table) {
  60. pte_t pte = pfn_pte(virt_to_pfn(address), PAGE_INIT);
  61. if (address >= (unsigned long)high_memory)
  62. pte_val (pte) = 0;
  63. set_pte (pg_table, pte);
  64. address += PAGE_SIZE;
  65. }
  66. }
  67. mmu_emu_init(bootmem_end);
  68. current->mm = NULL;
  69. /* memory sizing is a hack stolen from motorola.c.. hope it works for us */
  70. zones_size[ZONE_DMA] = ((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
  71. /* I really wish I knew why the following change made things better... -- Sam */
  72. /* free_area_init(zones_size); */
  73. free_area_init_node(0, zones_size,
  74. (__pa(PAGE_OFFSET) >> PAGE_SHIFT) + 1, NULL);
  75. }