pgalloc.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * OpenRISC Linux
  4. *
  5. * Linux architectural port borrowing liberally from similar works of
  6. * others. All original copyrights apply as per the original source
  7. * declaration.
  8. *
  9. * OpenRISC implementation:
  10. * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
  11. * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
  12. * et al.
  13. */
  14. #ifndef __ASM_OPENRISC_PGALLOC_H
  15. #define __ASM_OPENRISC_PGALLOC_H
  16. #include <asm/page.h>
  17. #include <linux/threads.h>
  18. #include <linux/mm.h>
  19. #include <linux/memblock.h>
  20. #define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
  21. #include <asm-generic/pgalloc.h>
  22. extern int mem_init_done;
  23. #define pmd_populate_kernel(mm, pmd, pte) \
  24. set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte)))
  25. static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  26. struct page *pte)
  27. {
  28. set_pmd(pmd, __pmd(_KERNPG_TABLE +
  29. ((unsigned long)page_to_pfn(pte) <<
  30. (unsigned long) PAGE_SHIFT)));
  31. }
  32. /*
  33. * Allocate and free page tables.
  34. */
  35. static inline pgd_t *pgd_alloc(struct mm_struct *mm)
  36. {
  37. pgd_t *ret = __pgd_alloc(mm, 0);
  38. if (ret)
  39. memcpy(ret + USER_PTRS_PER_PGD,
  40. swapper_pg_dir + USER_PTRS_PER_PGD,
  41. (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
  42. return ret;
  43. }
  44. #if 0
  45. /* FIXME: This seems to be the preferred style, but we are using
  46. * current_pgd (from mm->pgd) to load kernel pages so we need it
  47. * initialized. This needs to be looked into.
  48. */
  49. extern inline pgd_t *pgd_alloc(struct mm_struct *mm)
  50. {
  51. return (pgd_t *)get_zeroed_page(GFP_KERNEL);
  52. }
  53. #endif
  54. extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm);
  55. #define __pte_free_tlb(tlb, pte, addr) \
  56. tlb_remove_ptdesc((tlb), page_ptdesc(pte))
  57. #endif