]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef __ASM_SH_PAGE_H |
2 | #define __ASM_SH_PAGE_H | |
3 | ||
4 | /* | |
5 | * Copyright (C) 1999 Niibe Yutaka | |
6 | */ | |
7 | ||
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 | |
14 | */ | |
15 | ||
a5ba7d54 PM |
16 | #ifdef __KERNEL__ |
17 | ||
1da177e4 | 18 | /* PAGE_SHIFT determines the page size */ |
21440cf0 PM |
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 | |
8c12b5dc PM |
28 | |
29 | #ifdef __ASSEMBLY__ | |
d153ea88 | 30 | #define PAGE_SIZE (1 << PAGE_SHIFT) |
8c12b5dc PM |
31 | #else |
32 | #define PAGE_SIZE (1UL << PAGE_SHIFT) | |
33 | #endif | |
34 | ||
1da177e4 LT |
35 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
36 | #define PTE_MASK PAGE_MASK | |
37 | ||
38 | #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) | |
39 | #define HPAGE_SHIFT 16 | |
21440cf0 PM |
40 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K) |
41 | #define HPAGE_SHIFT 18 | |
1da177e4 LT |
42 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB) |
43 | #define HPAGE_SHIFT 20 | |
21440cf0 PM |
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 | |
1da177e4 LT |
48 | #endif |
49 | ||
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 | |
55 | ||
1da177e4 LT |
56 | #ifndef __ASSEMBLY__ |
57 | ||
58 | extern void (*clear_page)(void *to); | |
59 | extern void (*copy_page)(void *to, void *from); | |
60 | ||
f3c25758 | 61 | extern unsigned long shm_align_mask; |
01066625 | 62 | extern unsigned long max_low_pfn, min_low_pfn; |
e08f457c | 63 | extern unsigned long memory_start, memory_end; |
f3c25758 | 64 | |
e96636cc | 65 | #ifdef CONFIG_MMU |
1da177e4 LT |
66 | extern void clear_page_slow(void *to); |
67 | extern void copy_page_slow(void *to, void *from); | |
e96636cc YS |
68 | #else |
69 | extern void clear_page_nommu(void *to); | |
70 | extern void copy_page_nommu(void *to, void *from); | |
71 | #endif | |
1da177e4 | 72 | |
e7bd34a1 PM |
73 | #if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_MMU) && \ |
74 | (defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)) | |
1da177e4 LT |
75 | struct page; |
76 | extern void clear_user_page(void *to, unsigned long address, struct page *pg); | |
77 | extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg); | |
78 | extern void __clear_user_page(void *to, void *orig_to); | |
79 | extern void __copy_user_page(void *to, void *from, void *orig_to); | |
e7bd34a1 | 80 | #else |
1da177e4 LT |
81 | #define clear_user_page(page, vaddr, pg) clear_page(page) |
82 | #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) | |
1da177e4 LT |
83 | #endif |
84 | ||
85 | /* | |
86 | * These are used to make use of C type-checking.. | |
87 | */ | |
21440cf0 PM |
88 | #ifdef CONFIG_X2TLB |
89 | typedef struct { unsigned long pte_low, pte_high; } pte_t; | |
90 | typedef struct { unsigned long long pgprot; } pgprot_t; | |
d04a0f79 | 91 | typedef struct { unsigned long long pgd; } pgd_t; |
21440cf0 PM |
92 | #define pte_val(x) \ |
93 | ((x).pte_low | ((unsigned long long)(x).pte_high << 32)) | |
94 | #define __pte(x) \ | |
95 | ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; }) | |
96 | #else | |
97 | typedef struct { unsigned long pte_low; } pte_t; | |
1da177e4 | 98 | typedef struct { unsigned long pgprot; } pgprot_t; |
d04a0f79 | 99 | typedef struct { unsigned long pgd; } pgd_t; |
21440cf0 PM |
100 | #define pte_val(x) ((x).pte_low) |
101 | #define __pte(x) ((pte_t) { (x) } ) | |
102 | #endif | |
103 | ||
1da177e4 LT |
104 | #define pgd_val(x) ((x).pgd) |
105 | #define pgprot_val(x) ((x).pgprot) | |
106 | ||
1da177e4 LT |
107 | #define __pgd(x) ((pgd_t) { (x) } ) |
108 | #define __pgprot(x) ((pgprot_t) { (x) } ) | |
109 | ||
110 | #endif /* !__ASSEMBLY__ */ | |
111 | ||
112 | /* to align the pointer to the (next) page boundary */ | |
113 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) | |
114 | ||
115 | /* | |
116 | * IF YOU CHANGE THIS, PLEASE ALSO CHANGE | |
117 | * | |
118 | * arch/sh/kernel/vmlinux.lds.S | |
119 | * | |
120 | * which has the same constant encoded.. | |
121 | */ | |
122 | ||
123 | #define __MEMORY_START CONFIG_MEMORY_START | |
124 | #define __MEMORY_SIZE CONFIG_MEMORY_SIZE | |
1da177e4 | 125 | |
e7f93a35 | 126 | #define PAGE_OFFSET CONFIG_PAGE_OFFSET |
1da177e4 LT |
127 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) |
128 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) | |
01066625 | 129 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) |
1da177e4 | 130 | |
01066625 | 131 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) |
1da177e4 LT |
132 | |
133 | /* PFN start number, because of __MEMORY_START */ | |
134 | #define PFN_START (__MEMORY_START >> PAGE_SHIFT) | |
67bb2c69 | 135 | #define ARCH_PFN_OFFSET (PFN_START) |
1da177e4 | 136 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) |
5900711a | 137 | #ifdef CONFIG_FLATMEM |
01066625 | 138 | #define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) < max_low_pfn) |
5900711a | 139 | #endif |
1da177e4 LT |
140 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
141 | ||
142 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ | |
143 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | |
144 | ||
104b8dea | 145 | #include <asm-generic/memory_model.h> |
fd4fd5aa SR |
146 | #include <asm-generic/page.h> |
147 | ||
19f9a34f PM |
148 | /* vDSO support */ |
149 | #ifdef CONFIG_VSYSCALL | |
150 | #define __HAVE_ARCH_GATE_AREA | |
151 | #endif | |
152 | ||
cbd2d9d8 PM |
153 | /* |
154 | * Slub defaults to 8-byte alignment, we're only interested in 4. | |
155 | * Slab defaults to BYTES_PER_WORD, which ends up being the same anyways. | |
156 | */ | |
157 | #define ARCH_KMALLOC_MINALIGN 4 | |
158 | #define ARCH_SLAB_MINALIGN 4 | |
159 | ||
b5233d07 | 160 | #endif /* __KERNEL__ */ |
1da177e4 | 161 | #endif /* __ASM_SH_PAGE_H */ |