blob: 972c3f655b2a01030f78fc720056264361f1af88 [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
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)
David Gibson63551ae2005-06-21 17:14:44 -070034#define ARCH_HAS_SETCLEAR_HUGE_PTE
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#endif
36
37#ifdef __KERNEL__
38#ifndef __ASSEMBLY__
39
40extern void (*clear_page)(void *to);
41extern void (*copy_page)(void *to, void *from);
42
43extern void clear_page_slow(void *to);
44extern void copy_page_slow(void *to, void *from);
45
46#if defined(CONFIG_SH7705_CACHE_32KB) && defined(CONFIG_MMU)
47struct page;
48extern void clear_user_page(void *to, unsigned long address, struct page *pg);
49extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
50extern void __clear_user_page(void *to, void *orig_to);
51extern void __copy_user_page(void *to, void *from, void *orig_to);
52#elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU)
53#define clear_user_page(page, vaddr, pg) clear_page(page)
54#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
55#elif defined(CONFIG_CPU_SH4)
56struct page;
57extern void clear_user_page(void *to, unsigned long address, struct page *pg);
58extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
59extern void __clear_user_page(void *to, void *orig_to);
60extern void __copy_user_page(void *to, void *from, void *orig_to);
61#endif
62
63/*
64 * These are used to make use of C type-checking..
65 */
66typedef struct { unsigned long pte; } pte_t;
67typedef struct { unsigned long pmd; } pmd_t;
68typedef struct { unsigned long pgd; } pgd_t;
69typedef struct { unsigned long pgprot; } pgprot_t;
70
71#define pte_val(x) ((x).pte)
72#define pmd_val(x) ((x).pmd)
73#define pgd_val(x) ((x).pgd)
74#define pgprot_val(x) ((x).pgprot)
75
76#define __pte(x) ((pte_t) { (x) } )
77#define __pmd(x) ((pmd_t) { (x) } )
78#define __pgd(x) ((pgd_t) { (x) } )
79#define __pgprot(x) ((pgprot_t) { (x) } )
80
81#endif /* !__ASSEMBLY__ */
82
83/* to align the pointer to the (next) page boundary */
84#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
85
86/*
87 * IF YOU CHANGE THIS, PLEASE ALSO CHANGE
88 *
89 * arch/sh/kernel/vmlinux.lds.S
90 *
91 * which has the same constant encoded..
92 */
93
94#define __MEMORY_START CONFIG_MEMORY_START
95#define __MEMORY_SIZE CONFIG_MEMORY_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97#define PAGE_OFFSET (0x80000000UL)
98#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
99#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
100
101#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103#define phys_to_page(phys) (mem_map + (((phys)-__MEMORY_START) >> PAGE_SHIFT))
104#define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
106/* PFN start number, because of __MEMORY_START */
107#define PFN_START (__MEMORY_START >> PAGE_SHIFT)
108
109#define pfn_to_page(pfn) (mem_map + (pfn) - PFN_START)
110#define page_to_pfn(page) ((unsigned long)((page) - mem_map) + PFN_START)
111#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
112#define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr)
113#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
114
115#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
116 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
117
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118#endif /* __KERNEL__ */
119
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700120#include <asm-generic/page.h>
121
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122#endif /* __ASM_SH_PAGE_H */