mmu.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
  16. void __init paging_init(void)
  17. {
  18. memset(swapper_pg_dir, 0, PAGE_SIZE);
  19. }
  20. /*
  21. * Flush the mmu and reset associated register to default values.
  22. */
  23. void __init init_mmu(void)
  24. {
  25. /* Writing zeros to the <t>TLBCFG special registers ensure
  26. * that valid values exist in the register. For existing
  27. * PGSZID<w> fields, zero selects the first element of the
  28. * page-size array. For nonexistent PGSZID<w> fields, zero is
  29. * the best value to write. Also, when changing PGSZID<w>
  30. * fields, the corresponding TLB must be flushed.
  31. */
  32. set_itlbcfg_register(0);
  33. set_dtlbcfg_register(0);
  34. flush_tlb_all();
  35. /* Set rasid register to a known value. */
  36. set_rasid_register(ASID_USER_FIRST);
  37. /* Set PTEVADDR special register to the start of the page
  38. * table, which is in kernel mappable space (ie. not
  39. * statically mapped). This register's value is undefined on
  40. * reset.
  41. */
  42. set_ptevaddr_register(PGTABLE_START);
  43. }
  44. struct kmem_cache *pgtable_cache __read_mostly;
  45. static void pgd_ctor(void *addr)
  46. {
  47. pte_t *ptep = (pte_t *)addr;
  48. int i;
  49. for (i = 0; i < 1024; i++, ptep++)
  50. pte_clear(NULL, 0, ptep);
  51. }
  52. void __init pgtable_cache_init(void)
  53. {
  54. pgtable_cache = kmem_cache_create("pgd",
  55. PAGE_SIZE, PAGE_SIZE,
  56. SLAB_HWCACHE_ALIGN,
  57. pgd_ctor);
  58. }