aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sh64/page.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-sh64/page.h')
-rw-r--r--include/asm-sh64/page.h137
1 files changed, 137 insertions, 0 deletions
diff --git a/include/asm-sh64/page.h b/include/asm-sh64/page.h
new file mode 100644
index 000000000000..e1f7f5a41210
--- /dev/null
+++ b/include/asm-sh64/page.h
@@ -0,0 +1,137 @@
1#ifndef __ASM_SH64_PAGE_H
2#define __ASM_SH64_PAGE_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/page.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003, 2004 Paul Mundt
13 *
14 * benedict.gaster@superh.com 19th, 24th July 2002.
15 *
16 * Modified to take account of enabling for D-CACHE support.
17 *
18 */
19
20#include <linux/config.h>
21
22/* PAGE_SHIFT determines the page size */
23#define PAGE_SHIFT 12
24#ifdef __ASSEMBLY__
25#define PAGE_SIZE 4096
26#else
27#define PAGE_SIZE (1UL << PAGE_SHIFT)
28#endif
29#define PAGE_MASK (~(PAGE_SIZE-1))
30#define PTE_MASK PAGE_MASK
31
32#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
33#define HPAGE_SHIFT 16
34#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
35#define HPAGE_SHIFT 20
36#elif defined(CONFIG_HUGETLB_PAGE_SIZE_512MB)
37#define HPAGE_SHIFT 29
38#endif
39
40#ifdef CONFIG_HUGETLB_PAGE
41#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
42#define HPAGE_MASK (~(HPAGE_SIZE-1))
43#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
44#endif
45
46#ifdef __KERNEL__
47#ifndef __ASSEMBLY__
48
49extern struct page *mem_map;
50extern void sh64_page_clear(void *page);
51extern void sh64_page_copy(void *from, void *to);
52
53#define clear_page(page) sh64_page_clear(page)
54#define copy_page(to,from) sh64_page_copy(from, to)
55
56#if defined(CONFIG_DCACHE_DISABLED)
57
58#define clear_user_page(page, vaddr, pg) clear_page(page)
59#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
60
61#else
62
63extern void clear_user_page(void *to, unsigned long address, struct page *pg);
64extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
65
66#endif /* defined(CONFIG_DCACHE_DISABLED) */
67
68/*
69 * These are used to make use of C type-checking..
70 */
71typedef struct { unsigned long long pte; } pte_t;
72typedef struct { unsigned long pmd; } pmd_t;
73typedef struct { unsigned long pgd; } pgd_t;
74typedef struct { unsigned long pgprot; } pgprot_t;
75
76#define pte_val(x) ((x).pte)
77#define pmd_val(x) ((x).pmd)
78#define pgd_val(x) ((x).pgd)
79#define pgprot_val(x) ((x).pgprot)
80
81#define __pte(x) ((pte_t) { (x) } )
82#define __pmd(x) ((pmd_t) { (x) } )
83#define __pgd(x) ((pgd_t) { (x) } )
84#define __pgprot(x) ((pgprot_t) { (x) } )
85
86#endif /* !__ASSEMBLY__ */
87
88/* to align the pointer to the (next) page boundary */
89#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
90
91/*
92 * Kconfig defined.
93 */
94#define __MEMORY_START (CONFIG_MEMORY_START)
95#define PAGE_OFFSET (CONFIG_CACHED_MEMORY_OFFSET)
96
97#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
98#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
99#define MAP_NR(addr) ((__pa(addr)-__MEMORY_START) >> PAGE_SHIFT)
100#define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
101
102#define phys_to_page(phys) (mem_map + (((phys) - __MEMORY_START) >> PAGE_SHIFT))
103#define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START)
104
105/* PFN start number, because of __MEMORY_START */
106#define PFN_START (__MEMORY_START >> PAGE_SHIFT)
107
108#define pfn_to_page(pfn) (mem_map + (pfn) - PFN_START)
109#define page_to_pfn(page) ((unsigned long)((page) - mem_map) + PFN_START)
110#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
111#define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr)
112#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
113
114#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
115 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
116
117#ifndef __ASSEMBLY__
118
119/* Pure 2^n version of get_order */
120extern __inline__ int get_order(unsigned long size)
121{
122 int order;
123
124 size = (size-1) >> (PAGE_SHIFT-1);
125 order = -1;
126 do {
127 size >>= 1;
128 order++;
129 } while (size);
130 return order;
131}
132
133#endif
134
135#endif /* __KERNEL__ */
136
137#endif /* __ASM_SH64_PAGE_H */