Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
motorola_pgalloc.h
Go to the documentation of this file.
1 #ifndef _MOTOROLA_PGALLOC_H
2 #define _MOTOROLA_PGALLOC_H
3 
4 #include <asm/tlb.h>
5 #include <asm/tlbflush.h>
6 
7 extern pmd_t *get_pointer_table(void);
8 extern int free_pointer_table(pmd_t *);
9 
10 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
11 {
12  pte_t *pte;
13 
15  if (pte) {
18  nocache_page(pte);
19  }
20 
21  return pte;
22 }
23 
24 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
25 {
26  cache_page(pte);
27  free_page((unsigned long) pte);
28 }
29 
30 static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
31 {
33  pte_t *pte;
34 
35  if(!page)
36  return NULL;
37 
38  pte = kmap(page);
41  nocache_page(pte);
42  kunmap(page);
43  pgtable_page_ctor(page);
44  return page;
45 }
46 
47 static inline void pte_free(struct mm_struct *mm, pgtable_t page)
48 {
49  pgtable_page_dtor(page);
50  cache_page(kmap(page));
51  kunmap(page);
52  __free_page(page);
53 }
54 
55 static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page,
56  unsigned long address)
57 {
58  pgtable_page_dtor(page);
59  cache_page(kmap(page));
60  kunmap(page);
61  __free_page(page);
62 }
63 
64 
65 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
66 {
67  return get_pointer_table();
68 }
69 
70 static inline int pmd_free(struct mm_struct *mm, pmd_t *pmd)
71 {
72  return free_pointer_table(pmd);
73 }
74 
75 static inline int __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
76  unsigned long address)
77 {
78  return free_pointer_table(pmd);
79 }
80 
81 
82 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
83 {
84  pmd_free(mm, (pmd_t *)pgd);
85 }
86 
87 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
88 {
89  return (pgd_t *)get_pointer_table();
90 }
91 
92 
93 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
94 {
95  pmd_set(pmd, pte);
96 }
97 
98 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page)
99 {
100  pmd_set(pmd, page_address(page));
101 }
102 #define pmd_pgtable(pmd) pmd_page(pmd)
103 
104 static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
105 {
106  pgd_set(pgd, pmd);
107 }
108 
109 #endif /* _MOTOROLA_PGALLOC_H */