mmu.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * xtensa mmu stuff
  3. *
  4. * Extracted from init.c
  5. */
  6. #include <linux/percpu.h>
  7. #include <linux/init.h>
  8. #include <linux/string.h>
  9. #include <linux/slab.h>
  10. #include <linux/cache.h>
  11. #include <asm/tlb.h>
  12. #include <asm/tlbflush.h>
  13. #include <asm/mmu_context.h>
  14. #include <asm/page.h>
  15. void __init paging_init(void)
  16. {
  17. memset(swapper_pg_dir, 0, PAGE_SIZE);
  18. }
  19. /*
  20. * Flush the mmu and reset associated register to default values.
  21. */
  22. void __init init_mmu(void)
  23. {
  24. /* Writing zeros to the <t>TLBCFG special registers ensure
  25. * that valid values exist in the register. For existing
  26. * PGSZID<w> fields, zero selects the first element of the
  27. * page-size array. For nonexistent PGSZID<w> fields, zero is
  28. * the best value to write. Also, when changing PGSZID<w>
  29. * fields, the corresponding TLB must be flushed.
  30. */
  31. set_itlbcfg_register(0);
  32. set_dtlbcfg_register(0);
  33. flush_tlb_all();
  34. /* Set rasid register to a known value. */
  35. set_rasid_register(ASID_USER_FIRST);
  36. /* Set PTEVADDR special register to the start of the page
  37. * table, which is in kernel mappable space (ie. not
  38. * statically mapped). This register's value is undefined on
  39. * reset.
  40. */
  41. set_ptevaddr_register(PGTABLE_START);
  42. }
  43. struct kmem_cache *pgtable_cache __read_mostly;
  44. static void pgd_ctor(void *addr)
  45. {
  46. pte_t *ptep = (pte_t *)addr;
  47. int i;
  48. for (i = 0; i < 1024; i++, ptep++)
  49. pte_clear(NULL, 0, ptep);
  50. }
  51. void __init pgtable_cache_init(void)
  52. {
  53. pgtable_cache = kmem_cache_create("pgd",
  54. PAGE_SIZE, PAGE_SIZE,
  55. SLAB_HWCACHE_ALIGN,
  56. pgd_ctor);
  57. }