MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / asm-mips / page.h
blob47ca67f25e54e98193038f10b7869c16db7741b3
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.
6 * Copyright (C) 1994 - 1999, 2000, 03 Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 */
9 #ifndef _ASM_PAGE_H
10 #define _ASM_PAGE_H
12 #include <linux/config.h>
14 #ifdef __KERNEL__
16 #include <spaces.h>
19 * PAGE_SHIFT determines the page size
21 #ifdef CONFIG_PAGE_SIZE_4KB
22 #define PAGE_SHIFT 12
23 #endif
24 #ifdef CONFIG_PAGE_SIZE_8KB
25 #define PAGE_SHIFT 13
26 #endif
27 #ifdef CONFIG_PAGE_SIZE_16KB
28 #define PAGE_SHIFT 14
29 #endif
30 #ifdef CONFIG_PAGE_SIZE_64KB
31 #define PAGE_SHIFT 16
32 #endif
33 #define PAGE_SIZE (1UL << PAGE_SHIFT)
34 #define PAGE_MASK (~(PAGE_SIZE-1))
36 #ifndef __ASSEMBLY__
38 extern void clear_page(void * page);
39 extern void copy_page(void * to, void * from);
41 extern unsigned long shm_align_mask;
43 static inline unsigned long pages_do_alias(unsigned long addr1,
44 unsigned long addr2)
46 return (addr1 ^ addr2) & shm_align_mask;
49 struct page;
51 static inline void clear_user_page(void *addr, unsigned long vaddr,
52 struct page *page)
54 extern void (*flush_data_cache_page)(unsigned long addr);
56 clear_page(addr);
57 if (pages_do_alias((unsigned long) addr, vaddr))
58 flush_data_cache_page((unsigned long)addr);
61 static inline void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
62 struct page *to)
64 extern void (*flush_data_cache_page)(unsigned long addr);
66 copy_page(vto, vfrom);
67 if (pages_do_alias((unsigned long)vto, vaddr))
68 flush_data_cache_page((unsigned long)vto);
72 * These are used to make use of C type-checking..
74 #ifdef CONFIG_64BIT_PHYS_ADDR
75 typedef struct { unsigned long long pte; } pte_t;
76 #else
77 typedef struct { unsigned long pte; } pte_t;
78 #endif
79 typedef struct { unsigned long pmd; } pmd_t;
80 typedef struct { unsigned long pgd; } pgd_t;
81 typedef struct { unsigned long pgprot; } pgprot_t;
83 #define pte_val(x) ((x).pte)
84 #define pmd_val(x) ((x).pmd)
85 #define pgd_val(x) ((x).pgd)
86 #define pgprot_val(x) ((x).pgprot)
88 #define ptep_buddy(x) ((pte_t *)((unsigned long)(x) ^ sizeof(pte_t)))
90 #define __pte(x) ((pte_t) { (x) } )
91 #define __pmd(x) ((pmd_t) { (x) } )
92 #define __pgd(x) ((pgd_t) { (x) } )
93 #define __pgprot(x) ((pgprot_t) { (x) } )
95 /* Pure 2^n version of get_order */
96 static __inline__ int get_order(unsigned long size)
98 int order;
100 size = (size-1) >> (PAGE_SHIFT-1);
101 order = -1;
102 do {
103 size >>= 1;
104 order++;
105 } while (size);
106 return order;
109 #endif /* !__ASSEMBLY__ */
111 /* to align the pointer to the (next) page boundary */
112 #define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
114 #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
115 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
117 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
119 #ifndef CONFIG_DISCONTIGMEM
120 #define pfn_to_page(pfn) (mem_map + (pfn))
121 #define page_to_pfn(page) ((unsigned long)((page) - mem_map))
122 #define pfn_valid(pfn) ((pfn) < max_mapnr)
123 #endif
125 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
126 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
128 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
129 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
131 #define UNCAC_ADDR(addr) ((addr) - PAGE_OFFSET + UNCAC_BASE)
132 #define CAC_ADDR(addr) ((addr) - UNCAC_BASE + PAGE_OFFSET)
134 #endif /* defined (__KERNEL__) */
136 #ifdef CONFIG_LIMITED_DMA
137 #define WANT_PAGE_VIRTUAL
138 #endif
140 #endif /* _ASM_PAGE_H */