blob: e21b0d12e139ee59ae24702b64bca7a5e9135b2b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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
Paul Mundta5ba7d52007-02-07 19:58:07 +090016#ifdef __KERNEL__
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018/* PAGE_SHIFT determines the page size */
Paul Mundt21440cf2006-11-20 14:30:26 +090019#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
Paul Mundt8c12b5d2006-09-27 18:31:06 +090028
29#ifdef __ASSEMBLY__
Paul Mundtd153ea82006-09-27 18:20:16 +090030#define PAGE_SIZE (1 << PAGE_SHIFT)
Paul Mundt8c12b5d2006-09-27 18:31:06 +090031#else
32#define PAGE_SIZE (1UL << PAGE_SHIFT)
33#endif
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#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
Paul Mundt21440cf2006-11-20 14:30:26 +090040#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
41#define HPAGE_SHIFT 18
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
43#define HPAGE_SHIFT 20
Paul Mundt21440cf2006-11-20 14:30:26 +090044#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
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#endif
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#ifndef __ASSEMBLY__
57
Paul Mundtf3c25752006-09-27 18:36:17 +090058extern unsigned long shm_align_mask;
Paul Mundt01066622007-03-28 16:38:13 +090059extern unsigned long max_low_pfn, min_low_pfn;
Paul Mundte08f4572007-05-14 12:52:56 +090060extern unsigned long memory_start, memory_end;
Paul Mundtf3c25752006-09-27 18:36:17 +090061
Paul Mundt379a95d2007-11-20 16:51:28 +090062extern void clear_page(void *to);
63extern void copy_page(void *to, void *from);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Paul Mundte7bd34a2007-07-31 17:07:28 +090065#if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_MMU) && \
66 (defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB))
Linus Torvalds1da177e2005-04-16 15:20:36 -070067struct page;
Paul Mundt7747b9a2007-11-05 16:12:32 +090068struct vm_area_struct;
Paul Mundtaf39c162007-11-05 16:20:42 +090069extern void clear_user_page(void *to, unsigned long address, struct page *page);
Paul Mundt7747b9a2007-11-05 16:12:32 +090070#ifdef CONFIG_CPU_SH4
71extern void copy_user_highpage(struct page *to, struct page *from,
72 unsigned long vaddr, struct vm_area_struct *vma);
73#define __HAVE_ARCH_COPY_USER_HIGHPAGE
74#endif
Paul Mundte7bd34a2007-07-31 17:07:28 +090075#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#define clear_user_page(page, vaddr, pg) clear_page(page)
77#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#endif
79
80/*
81 * These are used to make use of C type-checking..
82 */
Paul Mundt21440cf2006-11-20 14:30:26 +090083#ifdef CONFIG_X2TLB
84typedef struct { unsigned long pte_low, pte_high; } pte_t;
85typedef struct { unsigned long long pgprot; } pgprot_t;
Paul Mundtd04a0f72007-09-21 11:55:03 +090086typedef struct { unsigned long long pgd; } pgd_t;
Paul Mundt21440cf2006-11-20 14:30:26 +090087#define pte_val(x) \
88 ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
89#define __pte(x) \
90 ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
Paul Mundt249cfea2007-11-19 18:26:19 +090091#elif defined(CONFIG_SUPERH32)
Paul Mundt21440cf2006-11-20 14:30:26 +090092typedef struct { unsigned long pte_low; } pte_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093typedef struct { unsigned long pgprot; } pgprot_t;
Paul Mundtd04a0f72007-09-21 11:55:03 +090094typedef struct { unsigned long pgd; } pgd_t;
Paul Mundt21440cf2006-11-20 14:30:26 +090095#define pte_val(x) ((x).pte_low)
Paul Mundt249cfea2007-11-19 18:26:19 +090096#define __pte(x) ((pte_t) { (x) } )
97#else
98typedef struct { unsigned long long pte_low; } pte_t;
99typedef struct { unsigned long pgprot; } pgprot_t;
100typedef struct { unsigned long pgd; } pgd_t;
101#define pte_val(x) ((x).pte_low)
102#define __pte(x) ((pte_t) { (x) } )
Paul Mundt21440cf2006-11-20 14:30:26 +0900103#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#define pgd_val(x) ((x).pgd)
106#define pgprot_val(x) ((x).pgprot)
107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108#define __pgd(x) ((pgd_t) { (x) } )
109#define __pgprot(x) ((pgprot_t) { (x) } )
110
111#endif /* !__ASSEMBLY__ */
112
113/* to align the pointer to the (next) page boundary */
114#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
115
116/*
117 * IF YOU CHANGE THIS, PLEASE ALSO CHANGE
118 *
119 * arch/sh/kernel/vmlinux.lds.S
120 *
121 * which has the same constant encoded..
122 */
123
124#define __MEMORY_START CONFIG_MEMORY_START
125#define __MEMORY_SIZE CONFIG_MEMORY_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Paul Mundte7f93a32006-09-27 17:19:13 +0900127#define PAGE_OFFSET CONFIG_PAGE_OFFSET
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
129#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
Paul Mundt01066622007-03-28 16:38:13 +0900130#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
Paul Mundt01066622007-03-28 16:38:13 +0900132#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
134/* PFN start number, because of __MEMORY_START */
135#define PFN_START (__MEMORY_START >> PAGE_SHIFT)
Alexey Dobriyan67bb2c62006-09-08 09:47:34 -0700136#define ARCH_PFN_OFFSET (PFN_START)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
Paul Mundt59007112007-05-23 17:40:56 +0900138#ifdef CONFIG_FLATMEM
Paul Mundt01066622007-03-28 16:38:13 +0900139#define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) < max_low_pfn)
Paul Mundt59007112007-05-23 17:40:56 +0900140#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
142
143#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
144 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
145
KAMEZAWA Hiroyuki104b8de2006-03-27 01:15:46 -0800146#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700147#include <asm-generic/page.h>
148
Paul Mundt19f9a342006-09-27 18:33:49 +0900149/* vDSO support */
150#ifdef CONFIG_VSYSCALL
151#define __HAVE_ARCH_GATE_AREA
152#endif
153
Paul Mundtcbd2d9d2007-06-04 15:46:56 +0900154/*
155 * Slub defaults to 8-byte alignment, we're only interested in 4.
156 * Slab defaults to BYTES_PER_WORD, which ends up being the same anyways.
157 */
Paul Mundt01fed932007-11-10 19:57:58 +0900158#ifdef CONFIG_SUPERH32
Paul Mundtcbd2d9d2007-06-04 15:46:56 +0900159#define ARCH_KMALLOC_MINALIGN 4
160#define ARCH_SLAB_MINALIGN 4
Paul Mundt01fed932007-11-10 19:57:58 +0900161#else
162/* If gcc inlines memset, it will use st.q instructions. Therefore, we need
163 kmalloc allocations to be 8-byte aligned. Without this, the alignment
164 becomes BYTE_PER_WORD i.e. only 4 (since sizeof(long)==sizeof(void*)==4 on
165 sh64 at the moment). */
166#define ARCH_KMALLOC_MINALIGN 8
167
168/*
169 * We want 8-byte alignment for the slab caches as well, otherwise we have
170 * the same BYTES_PER_WORD (sizeof(void *)) min align in kmem_cache_create().
171 */
172#define ARCH_SLAB_MINALIGN 8
173#endif
Paul Mundtcbd2d9d2007-06-04 15:46:56 +0900174
Paul Mundtb5233d02006-09-20 03:25:34 +0900175#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176#endif /* __ASM_SH_PAGE_H */