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
6 * Copyright (C) 1994 - 1999, 2000, 03 Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
12 #include <linux/config.h>
19 * PAGE_SHIFT determines the page size
21 #ifdef CONFIG_PAGE_SIZE_4KB
24 #ifdef CONFIG_PAGE_SIZE_8KB
27 #ifdef CONFIG_PAGE_SIZE_16KB
30 #ifdef CONFIG_PAGE_SIZE_64KB
33 #define PAGE_SIZE (1UL << PAGE_SHIFT)
34 #define PAGE_MASK (~(PAGE_SIZE-1))
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
,
46 return (addr1
^ addr2
) & shm_align_mask
;
51 static inline void clear_user_page(void *addr
, unsigned long vaddr
,
54 extern void (*flush_data_cache_page
)(unsigned long 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
,
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
;
77 typedef struct { unsigned long pte
; } pte_t
;
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
)
100 size
= (size
-1) >> (PAGE_SHIFT
-1);
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)
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
140 #endif /* _ASM_PAGE_H */