[ARM] 4340/1: iop: fix iop_getttimeoffset
[linux-2.6/s3c2410-cpufreq.git] / include / asm-sh / page.h
blobac4b4677f28c49e7cfbfd97e78c94ab141927a0b
1 #ifndef __ASM_SH_PAGE_H
2 #define __ASM_SH_PAGE_H
4 /*
5 * Copyright (C) 1999 Niibe Yutaka
6 */
8 /*
9 [ P0/U0 (virtual) ] 0x00000000 <------ User space
10 [ P1 (fixed) cached ] 0x80000000 <------ Kernel space
11 [ P2 (fixed) non-cachable] 0xA0000000 <------ Physical access
12 [ P3 (virtual) cached] 0xC0000000 <------ vmalloced area
13 [ P4 control ] 0xE0000000
16 #ifdef __KERNEL__
18 /* PAGE_SHIFT determines the page size */
19 #if defined(CONFIG_PAGE_SIZE_4KB)
20 # define PAGE_SHIFT 12
21 #elif defined(CONFIG_PAGE_SIZE_8KB)
22 # define PAGE_SHIFT 13
23 #elif defined(CONFIG_PAGE_SIZE_64KB)
24 # define PAGE_SHIFT 16
25 #else
26 # error "Bogus kernel page size?"
27 #endif
29 #ifdef __ASSEMBLY__
30 #define PAGE_SIZE (1 << PAGE_SHIFT)
31 #else
32 #define PAGE_SIZE (1UL << PAGE_SHIFT)
33 #endif
35 #define PAGE_MASK (~(PAGE_SIZE-1))
36 #define PTE_MASK PAGE_MASK
38 #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
39 #define HPAGE_SHIFT 16
40 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
41 #define HPAGE_SHIFT 18
42 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
43 #define HPAGE_SHIFT 20
44 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
45 #define HPAGE_SHIFT 22
46 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
47 #define HPAGE_SHIFT 26
48 #endif
50 #ifdef CONFIG_HUGETLB_PAGE
51 #define HPAGE_SIZE (1UL << HPAGE_SHIFT)
52 #define HPAGE_MASK (~(HPAGE_SIZE-1))
53 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
54 #endif
56 #ifndef __ASSEMBLY__
58 extern void (*clear_page)(void *to);
59 extern void (*copy_page)(void *to, void *from);
61 extern unsigned long shm_align_mask;
63 #ifdef CONFIG_MMU
64 extern void clear_page_slow(void *to);
65 extern void copy_page_slow(void *to, void *from);
66 #else
67 extern void clear_page_nommu(void *to);
68 extern void copy_page_nommu(void *to, void *from);
69 #endif
71 #if defined(CONFIG_MMU) && (defined(CONFIG_CPU_SH4) || \
72 defined(CONFIG_SH7705_CACHE_32KB))
73 struct page;
74 extern void clear_user_page(void *to, unsigned long address, struct page *pg);
75 extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
76 extern void __clear_user_page(void *to, void *orig_to);
77 extern void __copy_user_page(void *to, void *from, void *orig_to);
78 #elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU)
79 #define clear_user_page(page, vaddr, pg) clear_page(page)
80 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
81 #endif
84 * These are used to make use of C type-checking..
86 #ifdef CONFIG_X2TLB
87 typedef struct { unsigned long pte_low, pte_high; } pte_t;
88 typedef struct { unsigned long long pgprot; } pgprot_t;
89 #define pte_val(x) \
90 ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
91 #define __pte(x) \
92 ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
93 #else
94 typedef struct { unsigned long pte_low; } pte_t;
95 typedef struct { unsigned long pgprot; } pgprot_t;
96 #define pte_val(x) ((x).pte_low)
97 #define __pte(x) ((pte_t) { (x) } )
98 #endif
100 typedef struct { unsigned long pgd; } pgd_t;
102 #define pgd_val(x) ((x).pgd)
103 #define pgprot_val(x) ((x).pgprot)
105 #define __pgd(x) ((pgd_t) { (x) } )
106 #define __pgprot(x) ((pgprot_t) { (x) } )
108 #endif /* !__ASSEMBLY__ */
110 /* to align the pointer to the (next) page boundary */
111 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
114 * IF YOU CHANGE THIS, PLEASE ALSO CHANGE
116 * arch/sh/kernel/vmlinux.lds.S
118 * which has the same constant encoded..
121 #define __MEMORY_START CONFIG_MEMORY_START
122 #define __MEMORY_SIZE CONFIG_MEMORY_SIZE
124 #define PAGE_OFFSET CONFIG_PAGE_OFFSET
125 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
126 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
128 #define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
130 #define phys_to_page(phys) (mem_map + (((phys)-__MEMORY_START) >> PAGE_SHIFT))
131 #define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START)
133 /* PFN start number, because of __MEMORY_START */
134 #define PFN_START (__MEMORY_START >> PAGE_SHIFT)
135 #define ARCH_PFN_OFFSET (PFN_START)
136 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
137 #define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr)
138 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
140 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
141 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
143 #include <asm-generic/memory_model.h>
144 #include <asm-generic/page.h>
146 /* vDSO support */
147 #ifdef CONFIG_VSYSCALL
148 #define __HAVE_ARCH_GATE_AREA
149 #endif
151 #endif /* __KERNEL__ */
152 #endif /* __ASM_SH_PAGE_H */