diff options
Diffstat (limited to 'include/asm-sh/page.h')
-rw-r--r-- | include/asm-sh/page.h | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h new file mode 100644 index 000000000000..4c6d129e7d91 --- /dev/null +++ b/include/asm-sh/page.h | |||
@@ -0,0 +1,144 @@ | |||
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 | |||
16 | #include <linux/config.h> | ||
17 | |||
18 | /* PAGE_SHIFT determines the page size */ | ||
19 | #define PAGE_SHIFT 12 | ||
20 | #define PAGE_SIZE (1UL << PAGE_SHIFT) | ||
21 | #define PAGE_MASK (~(PAGE_SIZE-1)) | ||
22 | #define PTE_MASK PAGE_MASK | ||
23 | |||
24 | #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) | ||
25 | #define HPAGE_SHIFT 16 | ||
26 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB) | ||
27 | #define HPAGE_SHIFT 20 | ||
28 | #endif | ||
29 | |||
30 | #ifdef CONFIG_HUGETLB_PAGE | ||
31 | #define HPAGE_SIZE (1UL << HPAGE_SHIFT) | ||
32 | #define HPAGE_MASK (~(HPAGE_SIZE-1)) | ||
33 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT) | ||
34 | #endif | ||
35 | |||
36 | #ifdef __KERNEL__ | ||
37 | #ifndef __ASSEMBLY__ | ||
38 | |||
39 | extern void (*clear_page)(void *to); | ||
40 | extern void (*copy_page)(void *to, void *from); | ||
41 | |||
42 | extern void clear_page_slow(void *to); | ||
43 | extern void copy_page_slow(void *to, void *from); | ||
44 | |||
45 | #if defined(CONFIG_SH7705_CACHE_32KB) && defined(CONFIG_MMU) | ||
46 | struct page; | ||
47 | extern void clear_user_page(void *to, unsigned long address, struct page *pg); | ||
48 | extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg); | ||
49 | extern void __clear_user_page(void *to, void *orig_to); | ||
50 | extern void __copy_user_page(void *to, void *from, void *orig_to); | ||
51 | #elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU) | ||
52 | #define clear_user_page(page, vaddr, pg) clear_page(page) | ||
53 | #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) | ||
54 | #elif defined(CONFIG_CPU_SH4) | ||
55 | struct page; | ||
56 | extern void clear_user_page(void *to, unsigned long address, struct page *pg); | ||
57 | extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg); | ||
58 | extern void __clear_user_page(void *to, void *orig_to); | ||
59 | extern void __copy_user_page(void *to, void *from, void *orig_to); | ||
60 | #endif | ||
61 | |||
62 | /* | ||
63 | * These are used to make use of C type-checking.. | ||
64 | */ | ||
65 | typedef struct { unsigned long pte; } pte_t; | ||
66 | typedef struct { unsigned long pmd; } pmd_t; | ||
67 | typedef struct { unsigned long pgd; } pgd_t; | ||
68 | typedef struct { unsigned long pgprot; } pgprot_t; | ||
69 | |||
70 | #define pte_val(x) ((x).pte) | ||
71 | #define pmd_val(x) ((x).pmd) | ||
72 | #define pgd_val(x) ((x).pgd) | ||
73 | #define pgprot_val(x) ((x).pgprot) | ||
74 | |||
75 | #define __pte(x) ((pte_t) { (x) } ) | ||
76 | #define __pmd(x) ((pmd_t) { (x) } ) | ||
77 | #define __pgd(x) ((pgd_t) { (x) } ) | ||
78 | #define __pgprot(x) ((pgprot_t) { (x) } ) | ||
79 | |||
80 | #endif /* !__ASSEMBLY__ */ | ||
81 | |||
82 | /* to align the pointer to the (next) page boundary */ | ||
83 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) | ||
84 | |||
85 | /* | ||
86 | * IF YOU CHANGE THIS, PLEASE ALSO CHANGE | ||
87 | * | ||
88 | * arch/sh/kernel/vmlinux.lds.S | ||
89 | * | ||
90 | * which has the same constant encoded.. | ||
91 | */ | ||
92 | |||
93 | #define __MEMORY_START CONFIG_MEMORY_START | ||
94 | #define __MEMORY_SIZE CONFIG_MEMORY_SIZE | ||
95 | #ifdef CONFIG_DISCONTIGMEM | ||
96 | /* Just for HP690, for now.. */ | ||
97 | #define __MEMORY_START_2ND (__MEMORY_START+0x02000000) | ||
98 | #define __MEMORY_SIZE_2ND 0x001000000 /* 16MB */ | ||
99 | #endif | ||
100 | |||
101 | #define PAGE_OFFSET (0x80000000UL) | ||
102 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) | ||
103 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) | ||
104 | |||
105 | #define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT) | ||
106 | |||
107 | #ifndef CONFIG_DISCONTIGMEM | ||
108 | #define phys_to_page(phys) (mem_map + (((phys)-__MEMORY_START) >> PAGE_SHIFT)) | ||
109 | #define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START) | ||
110 | #endif | ||
111 | |||
112 | /* PFN start number, because of __MEMORY_START */ | ||
113 | #define PFN_START (__MEMORY_START >> PAGE_SHIFT) | ||
114 | |||
115 | #define pfn_to_page(pfn) (mem_map + (pfn) - PFN_START) | ||
116 | #define page_to_pfn(page) ((unsigned long)((page) - mem_map) + PFN_START) | ||
117 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) | ||
118 | #define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr) | ||
119 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) | ||
120 | |||
121 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ | ||
122 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
123 | |||
124 | #ifndef __ASSEMBLY__ | ||
125 | |||
126 | /* Pure 2^n version of get_order */ | ||
127 | static __inline__ int get_order(unsigned long size) | ||
128 | { | ||
129 | int order; | ||
130 | |||
131 | size = (size-1) >> (PAGE_SHIFT-1); | ||
132 | order = -1; | ||
133 | do { | ||
134 | size >>= 1; | ||
135 | order++; | ||
136 | } while (size); | ||
137 | return order; | ||
138 | } | ||
139 | |||
140 | #endif | ||
141 | |||
142 | #endif /* __KERNEL__ */ | ||
143 | |||
144 | #endif /* __ASM_SH_PAGE_H */ | ||