[PATCH] xtensa: Architecture support for Tensilica Xtensa Part 5
[linux-2.6.git] / arch / xtensa / mm / pgtable.c
1 /*
2  * arch/xtensa/mm/fault.c
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (C) 2001 - 2005 Tensilica Inc.
9  *
10  * Chris Zankel <chris@zankel.net>
11  */
12
13 #if (DCACHE_SIZE > PAGE_SIZE)
14
15 pte_t* pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
16 {
17         pte_t *pte, p;
18         int color = ADDR_COLOR(address);
19         int i;
20
21         p = (pte_t*) __get_free_pages(GFP_KERNEL|__GFP_REPEAT, COLOR_ORDER);
22
23         if (likely(p)) {
24                 struct page *page;
25
26                 for (i = 0; i < COLOR_SIZE; i++, p++) {
27                         page = virt_to_page(pte);
28
29                         set_page_count(page, 1);
30                         ClearPageCompound(page);
31
32                         if (ADDR_COLOR(p) == color)
33                                 pte = p;
34                         else
35                                 free_page(p);
36                 }
37                 clear_page(pte);
38         }
39         return pte;
40 }
41
42 #ifdef PROFILING
43
44 int mask;
45 int hit;
46 int flush;
47
48 #endif
49
50 struct page* pte_alloc_one(struct mm_struct *mm, unsigned long address)
51 {
52         struct page *page, p;
53         int color = ADDR_COLOR(address);
54
55         p = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER);
56
57         if (likely(p)) {
58                 for (i = 0; i < PAGE_ORDER; i++) {
59                         set_page_count(p, 1);
60                         ClearPageCompound(p);
61
62                         if (PADDR_COLOR(page_address(pg)) == color)
63                                 page = p;
64                         else
65                                 free_page(p);
66                 }
67                 clear_highpage(page);
68         }
69
70         return page;
71 }
72
73 #endif
74
75
76