blob: 380fd62dd05ade8ac5806711c985ee96f94adf93 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070016/* PAGE_SHIFT determines the page size */
Paul Mundt21440cf2006-11-20 14:30:26 +090017#if defined(CONFIG_PAGE_SIZE_4KB)
18# define PAGE_SHIFT 12
19#elif defined(CONFIG_PAGE_SIZE_8KB)
20# define PAGE_SHIFT 13
21#elif defined(CONFIG_PAGE_SIZE_64KB)
22# define PAGE_SHIFT 16
23#else
24# error "Bogus kernel page size?"
25#endif
Paul Mundt8c12b5d2006-09-27 18:31:06 +090026
27#ifdef __ASSEMBLY__
Paul Mundtd153ea82006-09-27 18:20:16 +090028#define PAGE_SIZE (1 << PAGE_SHIFT)
Paul Mundt8c12b5d2006-09-27 18:31:06 +090029#else
30#define PAGE_SIZE (1UL << PAGE_SHIFT)
31#endif
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#define PAGE_MASK (~(PAGE_SIZE-1))
34#define PTE_MASK PAGE_MASK
35
36#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
37#define HPAGE_SHIFT 16
Paul Mundt21440cf2006-11-20 14:30:26 +090038#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
39#define HPAGE_SHIFT 18
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
41#define HPAGE_SHIFT 20
Paul Mundt21440cf2006-11-20 14:30:26 +090042#elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
43#define HPAGE_SHIFT 22
44#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
45#define HPAGE_SHIFT 26
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#endif
47
48#ifdef CONFIG_HUGETLB_PAGE
49#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
50#define HPAGE_MASK (~(HPAGE_SIZE-1))
51#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#endif
53
54#ifdef __KERNEL__
55#ifndef __ASSEMBLY__
56
57extern void (*clear_page)(void *to);
58extern void (*copy_page)(void *to, void *from);
59
Paul Mundtf3c25752006-09-27 18:36:17 +090060extern unsigned long shm_align_mask;
61
Yoshinori Satoe96636c2006-09-27 17:21:02 +090062#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -070063extern void clear_page_slow(void *to);
64extern void copy_page_slow(void *to, void *from);
Yoshinori Satoe96636c2006-09-27 17:21:02 +090065#else
66extern void clear_page_nommu(void *to);
67extern void copy_page_nommu(void *to, void *from);
68#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Paul Mundt26ff6c12006-09-27 15:13:36 +090070#if defined(CONFIG_MMU) && (defined(CONFIG_CPU_SH4) || \
71 defined(CONFIG_SH7705_CACHE_32KB))
Linus Torvalds1da177e2005-04-16 15:20:36 -070072struct page;
73extern void clear_user_page(void *to, unsigned long address, struct page *pg);
74extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
75extern void __clear_user_page(void *to, void *orig_to);
76extern void __copy_user_page(void *to, void *from, void *orig_to);
77#elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU)
78#define clear_user_page(page, vaddr, pg) clear_page(page)
79#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#endif
81
82/*
83 * These are used to make use of C type-checking..
84 */
Paul Mundt21440cf2006-11-20 14:30:26 +090085#ifdef CONFIG_X2TLB
86typedef struct { unsigned long pte_low, pte_high; } pte_t;
87typedef struct { unsigned long long pgprot; } pgprot_t;
88#define pte_val(x) \
89 ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
90#define __pte(x) \
91 ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
92#else
93typedef struct { unsigned long pte_low; } pte_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094typedef struct { unsigned long pgprot; } pgprot_t;
Paul Mundt21440cf2006-11-20 14:30:26 +090095#define pte_val(x) ((x).pte_low)
96#define __pte(x) ((pte_t) { (x) } )
97#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Paul Mundt21440cf2006-11-20 14:30:26 +090099typedef struct { unsigned long pgd; } pgd_t;
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101#define pgd_val(x) ((x).pgd)
102#define pgprot_val(x) ((x).pgprot)
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#define __pgd(x) ((pgd_t) { (x) } )
105#define __pgprot(x) ((pgprot_t) { (x) } )
106
107#endif /* !__ASSEMBLY__ */
108
109/* to align the pointer to the (next) page boundary */
110#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
111
112/*
113 * IF YOU CHANGE THIS, PLEASE ALSO CHANGE
114 *
115 * arch/sh/kernel/vmlinux.lds.S
116 *
117 * which has the same constant encoded..
118 */
119
120#define __MEMORY_START CONFIG_MEMORY_START
121#define __MEMORY_SIZE CONFIG_MEMORY_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
Paul Mundte7f93a32006-09-27 17:19:13 +0900123#define PAGE_OFFSET CONFIG_PAGE_OFFSET
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
125#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
126
127#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#define phys_to_page(phys) (mem_map + (((phys)-__MEMORY_START) >> PAGE_SHIFT))
130#define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
132/* PFN start number, because of __MEMORY_START */
133#define PFN_START (__MEMORY_START >> PAGE_SHIFT)
Alexey Dobriyan67bb2c62006-09-08 09:47:34 -0700134#define ARCH_PFN_OFFSET (PFN_START)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
136#define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr)
137#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
138
139#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
140 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
141
KAMEZAWA Hiroyuki104b8de2006-03-27 01:15:46 -0800142#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700143#include <asm-generic/page.h>
144
Paul Mundt19f9a342006-09-27 18:33:49 +0900145/* vDSO support */
146#ifdef CONFIG_VSYSCALL
147#define __HAVE_ARCH_GATE_AREA
148#endif
149
Paul Mundtb5233d02006-09-20 03:25:34 +0900150#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#endif /* __ASM_SH_PAGE_H */