Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[wrt350n-kernel.git] / include / asm-xtensa / page.h
blob1213cde7543803d813f6a87c261525936138b07f
1 /*
2 * linux/include/asm-xtensa/page.h
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version2 as
6 * published by the Free Software Foundation.
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
11 #ifndef _XTENSA_PAGE_H
12 #define _XTENSA_PAGE_H
14 #ifdef __KERNEL__
16 #include <asm/processor.h>
18 #define XCHAL_KSEG_CACHED_VADDR 0xd0000000
19 #define XCHAL_KSEG_BYPASS_VADDR 0xd8000000
20 #define XCHAL_KSEG_PADDR 0x00000000
21 #define XCHAL_KSEG_SIZE 0x08000000
24 * PAGE_SHIFT determines the page size
25 * PAGE_ALIGN(x) aligns the pointer to the (next) page boundary
28 #define PAGE_SHIFT 12
29 #define PAGE_SIZE (1 << PAGE_SHIFT)
30 #define PAGE_MASK (~(PAGE_SIZE-1))
31 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE - 1) & PAGE_MASK)
33 #define PAGE_OFFSET XCHAL_KSEG_CACHED_VADDR
34 #define MAX_MEM_PFN XCHAL_KSEG_SIZE
35 #define PGTABLE_START 0x80000000
37 #ifdef __ASSEMBLY__
39 #define __pgprot(x) (x)
41 #else
44 * These are used to make use of C type-checking..
47 typedef struct { unsigned long pte; } pte_t; /* page table entry */
48 typedef struct { unsigned long pgd; } pgd_t; /* PGD table entry */
49 typedef struct { unsigned long pgprot; } pgprot_t;
51 #define pte_val(x) ((x).pte)
52 #define pgd_val(x) ((x).pgd)
53 #define pgprot_val(x) ((x).pgprot)
55 #define __pte(x) ((pte_t) { (x) } )
56 #define __pgd(x) ((pgd_t) { (x) } )
57 #define __pgprot(x) ((pgprot_t) { (x) } )
60 * Pure 2^n version of get_order
63 static inline int get_order(unsigned long size)
65 int order;
66 #ifndef XCHAL_HAVE_NSU
67 unsigned long x1, x2, x4, x8, x16;
69 size = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
70 x1 = size & 0xAAAAAAAA;
71 x2 = size & 0xCCCCCCCC;
72 x4 = size & 0xF0F0F0F0;
73 x8 = size & 0xFF00FF00;
74 x16 = size & 0xFFFF0000;
75 order = x2 ? 2 : 0;
76 order += (x16 != 0) * 16;
77 order += (x8 != 0) * 8;
78 order += (x4 != 0) * 4;
79 order += (x1 != 0);
81 return order;
82 #else
83 size = (size - 1) >> PAGE_SHIFT;
84 asm ("nsau %0, %1" : "=r" (order) : "r" (size));
85 return 32 - order;
86 #endif
90 struct page;
91 extern void clear_page(void *page);
92 extern void copy_page(void *to, void *from);
95 * If we have cache aliasing and writeback caches, we might have to do
96 * some extra work
99 #if (DCACHE_WAY_SIZE > PAGE_SIZE)
100 void clear_user_page(void *addr, unsigned long vaddr, struct page* page);
101 void copy_user_page(void *to,void* from,unsigned long vaddr,struct page* page);
102 #else
103 # define clear_user_page(page,vaddr,pg) clear_page(page)
104 # define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
105 #endif
108 * This handles the memory map. We handle pages at
109 * XCHAL_KSEG_CACHED_VADDR for kernels with 32 bit address space.
110 * These macros are for conversion of kernel address, not user
111 * addresses.
114 #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
115 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
116 #define pfn_valid(pfn) ((unsigned long)pfn < max_mapnr)
117 #ifdef CONFIG_DISCONTIGMEM
118 # error CONFIG_DISCONTIGMEM not supported
119 #endif
121 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
122 #define page_to_virt(page) __va(page_to_pfn(page) << PAGE_SHIFT)
123 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
124 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
126 #define WANT_PAGE_VIRTUAL
129 #endif /* __ASSEMBLY__ */
131 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
132 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
134 #include <asm-generic/memory_model.h>
135 #endif /* __KERNEL__ */
136 #endif /* _XTENSA_PAGE_H */