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.
11 #ifndef _XTENSA_PAGE_H
12 #define _XTENSA_PAGE_H
16 #include <asm/processor.h>
17 #include <linux/config.h>
20 * PAGE_SHIFT determines the page size
21 * PAGE_ALIGN(x) aligns the pointer to the (next) page boundary
24 #define PAGE_SHIFT XCHAL_MMU_MIN_PTE_PAGE_SIZE
25 #define PAGE_SIZE (1 << PAGE_SHIFT)
26 #define PAGE_MASK (~(PAGE_SIZE-1))
27 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE - 1) & PAGE_MASK)
29 #define DCACHE_WAY_SIZE (XCHAL_DCACHE_SIZE / XCHAL_DCACHE_WAYS)
30 #define PAGE_OFFSET XCHAL_KSEG_CACHED_VADDR
34 #define __pgprot(x) (x)
39 * These are used to make use of C type-checking..
42 typedef struct { unsigned long pte
; } pte_t
; /* page table entry */
43 typedef struct { unsigned long pgd
; } pgd_t
; /* PGD table entry */
44 typedef struct { unsigned long pgprot
; } pgprot_t
;
46 #define pte_val(x) ((x).pte)
47 #define pgd_val(x) ((x).pgd)
48 #define pgprot_val(x) ((x).pgprot)
50 #define __pte(x) ((pte_t) { (x) } )
51 #define __pgd(x) ((pgd_t) { (x) } )
52 #define __pgprot(x) ((pgprot_t) { (x) } )
55 * Pure 2^n version of get_order
58 extern __inline__
int get_order(unsigned long size
)
61 #ifndef XCHAL_HAVE_NSU
62 unsigned long x1
, x2
, x4
, x8
, x16
;
64 size
= (size
+ PAGE_SIZE
- 1) >> PAGE_SHIFT
;
65 x1
= size
& 0xAAAAAAAA;
66 x2
= size
& 0xCCCCCCCC;
67 x4
= size
& 0xF0F0F0F0;
68 x8
= size
& 0xFF00FF00;
69 x16
= size
& 0xFFFF0000;
71 order
+= (x16
!= 0) * 16;
72 order
+= (x8
!= 0) * 8;
73 order
+= (x4
!= 0) * 4;
78 size
= (size
- 1) >> PAGE_SHIFT
;
79 asm ("nsau %0, %1" : "=r" (order
) : "r" (size
));
86 extern void clear_page(void *page
);
87 extern void copy_page(void *to
, void *from
);
90 * If we have cache aliasing and writeback caches, we might have to do
94 #if (DCACHE_WAY_SIZE > PAGE_SIZE)
95 void clear_user_page(void *addr
, unsigned long vaddr
, struct page
* page
);
96 void copy_user_page(void *to
,void* from
,unsigned long vaddr
,struct page
* page
);
98 # define clear_user_page(page,vaddr,pg) clear_page(page)
99 # define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
103 * This handles the memory map. We handle pages at
104 * XCHAL_KSEG_CACHED_VADDR for kernels with 32 bit address space.
105 * These macros are for conversion of kernel address, not user
109 #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
110 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
111 #define pfn_valid(pfn) ((unsigned long)pfn < max_mapnr)
112 #ifndef CONFIG_DISCONTIGMEM
113 # define pfn_to_page(pfn) (mem_map + (pfn))
114 # define page_to_pfn(page) ((unsigned long)((page) - mem_map))
116 # error CONFIG_DISCONTIGMEM not supported
119 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
120 #define page_to_virt(page) __va(page_to_pfn(page) << PAGE_SHIFT)
121 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
122 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
124 #define WANT_PAGE_VIRTUAL
127 #endif /* __ASSEMBLY__ */
129 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
130 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
132 #endif /* __KERNEL__ */
133 #endif /* _XTENSA_PAGE_H */