source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/asm/pgalloc.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 2.8 KB
RevLine 
[2]1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License.  See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 2001, 2003 by Ralf Baechle
7 * Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_PGALLOC_H
10#define _ASM_PGALLOC_H
11
12#include <linux/highmem.h>
13
14static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
15        pte_t *pte)
16{
17        set_pmd(pmd, __pmd((unsigned long)pte));
18}
19
20static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
21        struct page *pte)
22{
23        set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
24}
25
26/*
27 * Initialize a new pgd / pmd table with invalid pointers.
28 */
29extern void pgd_init(unsigned long page);
30extern void pmd_init(unsigned long page, unsigned long pagetable);
31
32static inline pgd_t *pgd_alloc(struct mm_struct *mm)
33{
34        pgd_t *ret, *init;
35
36        ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
37        if (ret) {
38                init = pgd_offset(&init_mm, 0);
39                pgd_init((unsigned long)ret);
40                memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
41                       (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
42        }
43
44        return ret;
45}
46
47static inline void pgd_free(pgd_t *pgd)
48{
49        free_pages((unsigned long)pgd, PGD_ORDER);
50}
51
52static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
53        unsigned long address)
54{
55        pte_t *pte;
56
57        pte = (pte_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, PTE_ORDER);
58
59        return pte;
60}
61
62static inline struct page *pte_alloc_one(struct mm_struct *mm,
63        unsigned long address)
64{
65        struct page *pte;
66
67        pte = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER);
68        if (pte)
69                clear_highpage(pte);
70
71        return pte;
72}
73
74static inline void pte_free_kernel(pte_t *pte)
75{
76        free_pages((unsigned long)pte, PTE_ORDER);
77}
78
79static inline void pte_free(struct page *pte)
80{
81        __free_pages(pte, PTE_ORDER);
82}
83
84#define __pte_free_tlb(tlb,pte)         tlb_remove_page((tlb),(pte))
85
86#ifndef __mips64
87#define pgd_populate(mm, pmd, pte)      BUG()
88
89/*
90 * allocating and freeing a pmd is trivial: the 1-entry pmd is
91 * inside the pgd, so has no extra memory associated with it.
92 */
93#define pmd_alloc_one(mm, addr)         ({ BUG(); ((pmd_t *)2); })
94#define pmd_free(x)                     do { } while (0)
95#define __pmd_free_tlb(tlb,x)           do { } while (0)
96#endif
97
98#ifdef __mips64
99
100#define pgd_populate(mm, pgd, pmd)      set_pgd(pgd, __pgd(pmd))
101
102static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
103{
104        pmd_t *pmd;
105
106        pmd = (pmd_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT, PMD_ORDER);
107        if (pmd)
108                pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
109        return pmd;
110}
111
112static inline void pmd_free(pmd_t *pmd)
113{
114        free_pages((unsigned long)pmd, PMD_ORDER);
115}
116
117#define __pmd_free_tlb(tlb,x)   pmd_free(x)
118
119#endif
120
121#define check_pgt_cache()       do { } while (0)
122
123#endif /* _ASM_PGALLOC_H */
Note: See TracBrowser for help on using the repository browser.