blob: 6979927382050532a4bb7d6dc47311e01ebcd18f [file] [log] [blame]
Chris Zankel3f65ce42005-06-23 22:01:24 -07001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * arch/xtensa/mm/pgtable.c
Chris Zankel3f65ce42005-06-23 22:01:24 -07003 *
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
15pte_t* pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
16{
Nick Piggin8e7a9aa2006-03-22 00:08:04 -080017 pte_t *pte = NULL, *p;
Chris Zankel3f65ce42005-06-23 22:01:24 -070018 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)) {
Nick Piggin8dfcc9b2006-03-22 00:08:05 -080024 split_page(virt_to_page(p), COLOR_ORDER);
Chris Zankel3f65ce42005-06-23 22:01:24 -070025
Nick Piggin8e7a9aa2006-03-22 00:08:04 -080026 for (i = 0; i < COLOR_SIZE; i++) {
Chris Zankel3f65ce42005-06-23 22:01:24 -070027 if (ADDR_COLOR(p) == color)
28 pte = p;
29 else
30 free_page(p);
Nick Piggin8e7a9aa2006-03-22 00:08:04 -080031 p += PTRS_PER_PTE;
Chris Zankel3f65ce42005-06-23 22:01:24 -070032 }
33 clear_page(pte);
34 }
35 return pte;
36}
37
38#ifdef PROFILING
39
40int mask;
41int hit;
42int flush;
43
44#endif
45
46struct page* pte_alloc_one(struct mm_struct *mm, unsigned long address)
47{
Nick Piggin8e7a9aa2006-03-22 00:08:04 -080048 struct page *page = NULL, *p;
Chris Zankel3f65ce42005-06-23 22:01:24 -070049 int color = ADDR_COLOR(address);
50
51 p = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER);
52
53 if (likely(p)) {
Nick Piggin8dfcc9b2006-03-22 00:08:05 -080054 split_page(p, COLOR_ORDER);
Chris Zankel3f65ce42005-06-23 22:01:24 -070055
Nick Piggin8dfcc9b2006-03-22 00:08:05 -080056 for (i = 0; i < PAGE_ORDER; i++) {
Nick Piggin8e7a9aa2006-03-22 00:08:04 -080057 if (PADDR_COLOR(page_address(p)) == color)
Chris Zankel3f65ce42005-06-23 22:01:24 -070058 page = p;
59 else
Nick Piggin8e7a9aa2006-03-22 00:08:04 -080060 __free_page(p);
61 p++;
Chris Zankel3f65ce42005-06-23 22:01:24 -070062 }
63 clear_highpage(page);
64 }
65
66 return page;
67}
68
69#endif
70
71
72