pgalloc.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * linux/include/asm-arm/pgalloc.h
  3. *
  4. * Copyright (C) 2000-2001 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef _ASMARM_PGALLOC_H
  11. #define _ASMARM_PGALLOC_H
  12. #include <asm/processor.h>
  13. #include <asm/cacheflush.h>
  14. #include <asm/tlbflush.h>
  15. #include <linux/slab.h>
  16. extern kmem_cache_t *pte_cache;
  17. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr){
  18. return kmem_cache_alloc(pte_cache, GFP_KERNEL);
  19. }
  20. static inline void pte_free_kernel(pte_t *pte){
  21. if (pte)
  22. kmem_cache_free(pte_cache, pte);
  23. }
  24. /*
  25. * Populate the pmdp entry with a pointer to the pte. This pmd is part
  26. * of the mm address space.
  27. *
  28. * If 'mm' is the init tasks mm, then we are doing a vmalloc, and we
  29. * need to set stuff up correctly for it.
  30. */
  31. static inline void
  32. pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
  33. {
  34. //FIXME - is this doing the right thing?
  35. set_pmd(pmdp, (unsigned long)ptep | 1/*FIXME _PMD_PRESENT*/);
  36. }
  37. /*
  38. * FIXME - We use the old 2.5.5-rmk1 hack for this.
  39. * This is not truly correct, but should be functional.
  40. */
  41. #define pte_alloc_one(mm,addr) ((struct page *)pte_alloc_one_kernel(mm,addr))
  42. #define pte_free(pte) pte_free_kernel((pte_t *)pte)
  43. #define pmd_populate(mm,pmdp,ptep) pmd_populate_kernel(mm,pmdp,(pte_t *)ptep)
  44. /*
  45. * Since we have only two-level page tables, these are trivial
  46. *
  47. * trick __pmd_alloc into optimising away. The actual value is irrelevant though as it
  48. * is thrown away. It just cant be zero. -IM
  49. */
  50. #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
  51. #define pmd_free(pmd) do { } while (0)
  52. #define pgd_populate(mm,pmd,pte) BUG()
  53. extern pgd_t *get_pgd_slow(struct mm_struct *mm);
  54. extern void free_pgd_slow(pgd_t *pgd);
  55. #define pgd_alloc(mm) get_pgd_slow(mm)
  56. #define pgd_free(pgd) free_pgd_slow(pgd)
  57. #define check_pgt_cache() do { } while (0)
  58. #endif